public interface SnmpContextBasisFace
SnmpContext
,
SnmpContextv2c
,
SnmpContextv3
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT
The default port number where SNMP requests are sent to (161).
|
static int |
MAXPDU
The Maximum number of outstanding PDUs one context can handle at a
given moment in time.
|
static int |
MSS
The Maximum size of a message in octets (1300).
|
static java.lang.String |
STANDARD_SOCKET
The Standard Socket type.
|
static java.lang.String |
TCP_SOCKET
The TCP Socket type.
|
static java.lang.String |
version_id |
Modifier and Type | Method and Description |
---|---|
boolean |
addPdu(Pdu pdu)
Adds a PDU to the context.
|
void |
addRequestPduListener(RequestPduListener l)
Adds the specified request pdu listener to receive PDUs on the
default request pdu port 161 from the host that matches
this context.
|
void |
addRequestPduListener(RequestPduListener l,
int port)
Adds the specified request pdu listener to receive PDUs on the specified
port from the host that matches this context.
|
void |
addRequestPduListener(RequestPduListener l,
ListeningContextPool lcontext)
Adds the specified request pdu listener to receive PDUs on the
specified listening context that matches this context.
|
void |
addTrapListener(TrapListener l)
Adds the specified trap listener to receive traps on the default trap
port 162 from the host that matches this context.
|
void |
addTrapListener(TrapListener l,
int port)
Adds the specified trap listener to receive traps on the specified
port from the host that matches this context.
|
void |
addTrapListener(TrapListener l,
ListeningContextPool lcontext)
Adds the specified trap listener to receive traps on the specified
listening context that matches this context.
|
java.lang.Object |
clone()
Returns a clone of this SnmpContext.
|
void |
destroy()
Removes the resouces held by this context.
|
byte[] |
encodePacket(byte msg_type,
int rId,
int errstat,
int errind,
java.util.Enumeration ve,
java.lang.Object obj)
Encodes a PDU.
|
java.lang.String |
getBindAddress()
Returns the local bind address.
|
java.lang.String |
getHashKey()
Returns the hash key.
|
java.lang.String |
getHost()
Returns the host.
|
int |
getPort()
Returns the port number.
|
java.lang.String |
getReceivedFromHostAddress()
Returns the IP address string
aaa.bbb.ccc.ddd (IPv4) or a:b:c:d:e:f:g:h (IPv6)
of the (latest) host the packets where received from.
|
java.lang.String |
getSendToHostAddress()
Returns the IP address string
aaa.bbb.ccc.ddd (IPv4) or a:b:c:d:e:f:g:h (IPv6)
of the host the packets where sent to.
|
java.lang.String |
getTypeSocket()
Returns the type of socket.
|
int |
getVersion()
Returns the SNMP version of the context.
|
boolean |
isDestroyed()
Returns whether or not this context has been destroyed.
|
Pdu |
processIncomingPdu(byte[] message)
Processes an incoming PDU.
|
boolean |
removePdu(int requestId)
Removes a PDU from the context.
|
void |
removeRequestPduListener(RequestPduListener l)
Removes the specified request pdu listener from listening for packets
on the default request pdu port 161.
|
void |
removeRequestPduListener(RequestPduListener l,
int port)
Removes the specified request pdu listener from listening for packets
on the specified port.
|
void |
removeRequestPduListener(RequestPduListener l,
ListeningContextPool lcontext)
Removes the specified request pdu listener from listening for packets
on the specified listening context.
|
void |
removeTrapListener(TrapListener l)
Removes the specified trap listener from listening for packets on
the default trap port 162.
|
void |
removeTrapListener(TrapListener l,
int port)
Removes the specified trap listener from listening for packets on the
specified port.
|
void |
removeTrapListener(TrapListener l,
ListeningContextPool lcontext)
Removes the specified trap listener from listening for packets on the
specified listening context.
|
void |
sendPacket(byte[] packet)
Sends an encoded PDU.
|
static final java.lang.String version_id
static final int DEFAULT_PORT
static final java.lang.String STANDARD_SOCKET
static final java.lang.String TCP_SOCKET
static final int MAXPDU
static final int MSS
int getVersion()
SnmpConstants.SNMP_VERSION_1
,
SnmpConstants.SNMP_VERSION_2c
,
SnmpConstants.SNMP_VERSION_3
java.lang.String getHost()
int getPort()
java.lang.String getBindAddress()
java.lang.String getTypeSocket()
STANDARD_SOCKET
,
TCP_SOCKET
java.lang.String getSendToHostAddress()
ContextSocketFace.getSendToHostAddress()
java.lang.String getReceivedFromHostAddress()
ContextSocketFace.getReceivedFromHostAddress()
boolean addPdu(Pdu pdu) throws java.io.IOException, PduException
pdu
- the PDUjava.io.IOException
PduException
boolean removePdu(int requestId)
requestId
- the PDU request idbyte[] encodePacket(byte msg_type, int rId, int errstat, int errind, java.util.Enumeration ve, java.lang.Object obj) throws java.io.IOException, EncodingException
msg_type
- The message typerId
- The message iderrstat
- The error statuserrind
- The error indexve
- The varbind listobj
- Additional object (only used in SNMPv3)java.io.IOException
EncodingException
void sendPacket(byte[] packet)
packet
- The encoded packetvoid destroy()
boolean isDestroyed()
void addTrapListener(TrapListener l) throws java.io.IOException
The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.
l
- The trap listenerjava.io.IOException
addTrapListener(TrapListener, int)
,
ListeningContextFace.DEFAULT_TRAP_PORT
void removeTrapListener(TrapListener l) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()
l
- The trap listenerjava.io.IOException
removeTrapListener(TrapListener, int)
,
ListeningContextFace.DEFAULT_TRAP_PORT
void addTrapListener(TrapListener l, int port) throws java.io.IOException
The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.
l
- The trap listenerport
- The port the traps are received onjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.addRawPduListener(RawPduListener)
void removeTrapListener(TrapListener l, int port) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()
l
- The trap listenerport
- The port the traps are received onjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.removeRawPduListener(RawPduListener)
,
ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)
void addTrapListener(TrapListener l, ListeningContextPool lcontext) throws java.io.IOException
The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.
l
- The trap listenerlcontext
- The listening contextjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.addRawPduListener(RawPduListener)
void removeTrapListener(TrapListener l, ListeningContextPool lcontext) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()
l
- The trap listenerlcontext
- The listening contextjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.removeRawPduListener(RawPduListener)
,
ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)
void addRequestPduListener(RequestPduListener l) throws java.io.IOException
The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.
Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.
l
- The request PDU listenerjava.io.IOException
addRequestPduListener(RequestPduListener, int)
,
DEFAULT_PORT
void removeRequestPduListener(RequestPduListener l) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()
l
- The request PDU listenerjava.io.IOException
removeRequestPduListener(RequestPduListener, int)
,
DEFAULT_PORT
void addRequestPduListener(RequestPduListener l, int port) throws java.io.IOException
The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.
Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.
l
- The request PDU listenerport
- The port the request PDUs are received onjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.addRawPduListener(RawPduListener)
void removeRequestPduListener(RequestPduListener l, int port) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()
l
- The request PDU listenerport
- The port the request PDUs are received onjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.removeRawPduListener(RawPduListener)
,
ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)
void addRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws java.io.IOException
The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.
Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.
l
- The request PDU listenerlcontext
- The listening contextjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.addRawPduListener(RawPduListener)
void removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws java.io.IOException
The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()
l
- The request PDU listenerlcontext
- The listening contextjava.io.IOException
ListeningContextPool.ListeningContextPool(int, String, String)
,
ListeningContextPool.removeRawPduListener(RawPduListener)
,
ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)
Pdu processIncomingPdu(byte[] message) throws DecodingException, java.io.IOException
DecodingException
java.io.IOException
java.lang.Object clone() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
- Thrown when the constructor
generates an IOException or when in one of the Pool classes.java.lang.String getHashKey()