Package org.snmp4j.agent.agentx
Class AgentXMessageDispatcherImpl
java.lang.Object
org.snmp4j.agent.agentx.AgentXMessageDispatcherImpl
- All Implemented Interfaces:
AgentXMessageDispatcher,org.snmp4j.transport.TransportListener
The
AgentXMessageDispatcherImpl implements an AgentX AgentXMessageDispatcher.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aAgentXCommandListenerto this message dispatcher.voidaddTransportMapping(org.snmp4j.TransportMapping<?> transport) Adds aTransportMappingto the dispatcher.protected org.snmp4j.mp.PduHandleCreates a new PDU handle.protected voidfireCommandEvent(AgentXCommandEvent<?> event) Fires aAgentXCommandEventintIncrements the internal packet ID counter and returns the next ID.Collection<org.snmp4j.TransportMapping<?>> Gets theCollectionof transport mappings in this message dispatcher.<A extends org.snmp4j.smi.Address>
voidprocessMessage(org.snmp4j.TransportMapping<? super A> sourceTransport, A incomingAddress, ByteBuffer wholeMessage, org.snmp4j.TransportStateReference tmStateReference) voidRemoves aAgentXCommandListenerfrom this message dispatcher.org.snmp4j.TransportMapping<?> removeTransportMapping(org.snmp4j.TransportMapping<?> transport) Removes a previously addedTransportMappingfrom the dispatcher.<A extends org.snmp4j.smi.Address>
voidsend(A address, org.snmp4j.TransportMapping<? super A> transport, ByteBuffer message, org.snmp4j.TransportStateReference tmStateReference) Sends aAgentXPDUencoded in aByteBufferto a target.<A extends org.snmp4j.smi.Address>
org.snmp4j.mp.PduHandlesend(org.snmp4j.TransportMapping<? super A> transport, A address, AgentXPDU message, org.snmp4j.mp.PduHandleCallback<AgentXPDU> callback) Sends aAgentXPDUto a target.
-
Constructor Details
-
AgentXMessageDispatcherImpl
public AgentXMessageDispatcherImpl()Creates aAgentXMessageDispatcherImpl.
-
-
Method Details
-
getNextPacketID
public int getNextPacketID()Increments the internal packet ID counter and returns the next ID.- Returns:
- a new (positive) packet ID. If there is an overrun, 1 is returned.
-
createPduHandle
protected org.snmp4j.mp.PduHandle createPduHandle()Creates a new PDU handle.- Returns:
- a new
PduHandle.
-
addTransportMapping
public void addTransportMapping(org.snmp4j.TransportMapping<?> transport) Description copied from interface:AgentXMessageDispatcherAdds aTransportMappingto the dispatcher. The transport mapping is used to send and receive messages to/from the network.- Specified by:
addTransportMappingin interfaceAgentXMessageDispatcher- Parameters:
transport- aTransportMappinginstance.
-
getTransportMappings
Description copied from interface:AgentXMessageDispatcherGets theCollectionof transport mappings in this message dispatcher.- Specified by:
getTransportMappingsin interfaceAgentXMessageDispatcher- Returns:
- Collection
-
processMessage
public <A extends org.snmp4j.smi.Address> void processMessage(org.snmp4j.TransportMapping<? super A> sourceTransport, A incomingAddress, ByteBuffer wholeMessage, org.snmp4j.TransportStateReference tmStateReference) - Specified by:
processMessagein interfaceorg.snmp4j.transport.TransportListener
-
removeTransportMapping
public org.snmp4j.TransportMapping<?> removeTransportMapping(org.snmp4j.TransportMapping<?> transport) Description copied from interface:AgentXMessageDispatcherRemoves a previously addedTransportMappingfrom the dispatcher.- Specified by:
removeTransportMappingin interfaceAgentXMessageDispatcher- Parameters:
transport- aTransportMappinginstance.- Returns:
- the
TransportMappinginstance supplied if it could be successfully removed,nullotherwise.
-
send
public <A extends org.snmp4j.smi.Address> org.snmp4j.mp.PduHandle send(org.snmp4j.TransportMapping<? super A> transport, A address, AgentXPDU message, org.snmp4j.mp.PduHandleCallback<AgentXPDU> callback) throws IOException Sends aAgentXPDUto a target.- Specified by:
sendin interfaceAgentXMessageDispatcher- Type Parameters:
A- the address type.- Parameters:
transport- theTransportMapping.address- the target address.message- theAgentXPDUto be sent.callback- thePduHandleCallbackto generate aPduHandlewhe required.- Returns:
- the PduHandle associated with the PDU.
- Throws:
IOException- if sending fails because of anIOException.
-
send
public <A extends org.snmp4j.smi.Address> void send(A address, org.snmp4j.TransportMapping<? super A> transport, ByteBuffer message, org.snmp4j.TransportStateReference tmStateReference) throws IOException Sends aAgentXPDUencoded in aByteBufferto a target.- Type Parameters:
A- the address type.- Parameters:
address- the target address.transport- theTransportMapping.message- the message to be sent.tmStateReference- theTransportStateReferenceto hold SNMPv3 state reference.- Throws:
IOException- if sending fails because of anIOException.
-
fireCommandEvent
Fires aAgentXCommandEvent- Parameters:
event- theAgentXCommandEventto be fired.
-
addCommandListener
Description copied from interface:AgentXMessageDispatcherAdds aAgentXCommandListenerto this message dispatcher.- Specified by:
addCommandListenerin interfaceAgentXMessageDispatcher- Parameters:
l- the command listener to add.
-
removeCommandListener
Description copied from interface:AgentXMessageDispatcherRemoves aAgentXCommandListenerfrom this message dispatcher.- Specified by:
removeCommandListenerin interfaceAgentXMessageDispatcher- Parameters:
l- the listener to be removed.
-