|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.snmp2.UDPProtocolOptions
This is an implementation of ProtocolOptions class.
The default protocol that is used for SNMP communications
is UDP.
Now every packet that is sent through SnmpSession will go
through the UDP implementation of SnmpTransportProvider and
parameters that is needed for such operations should be
given through this UDPProtocolOptions.
The UDPProtocolOptions that should be constructed before opening a SnmpSession should look like the following:
UDPProtocolOptions options = new UDPProtocolOptions();
// If the session should be opened on a particular port.
options.setLocalPort(localPort);
// If the session should be opened on particular local_address.
options.setLocalAddress(local_address);
SnmpSession session = new SnmpSession(api);
session.setProtocolOptions(options);
session.open();
Once SnmpSession is opened for SNMP communication, the default values such as remoteHost, remotePort can be set on this UDPProtocolOptions object. If the remoteHost and remotePort is not specified in the SnmpPDU object then the API will take it from the SnmpSession.
For setting the remoteHost and remotePort, the following should be done:
UDPProtocolOptions options = (UDPProtocolOptions)session.getProtocolOptions();
options.setRemoteHost(remoteHost);
options.setRemotePort(remotePort);
Constructor Summary | |
UDPProtocolOptions()
The default constructor which will assign default values to all the variables in this class. |
|
UDPProtocolOptions(java.net.InetAddress remoteAddress)
Constructs a new UDPProtocolOptions object with
remoteAddress as target address and 161 as the target port. |
|
UDPProtocolOptions(java.net.InetAddress remoteAddress,
int remotePort)
Constructs a new UDPProtocolOptions object with
remoteAddress and remotePort as
target host and port. |
|
UDPProtocolOptions(java.lang.String remoteHost)
Constructs a new UDPProtocolOptions object with
remoteHost as target host and 161 as the target port. |
|
UDPProtocolOptions(java.lang.String remoteHost,
int remotePort)
Constructs a new UDPProtocolOptions object with
remoteHost and remotePort as
target host and port. |
Method Summary | |
java.lang.String[] |
getLocalAddresses()
This method gets the local addresses for which the session should bind with. |
int |
getLocalPort()
This method returns the local port at which the session should be opened. |
int |
getReceiveBufferSize()
This method returns the previously set buffer size or zero. |
java.net.InetAddress |
getRemoteAddress()
This method gets the remoteAddress as an InetAddress object. |
java.lang.String |
getRemoteHost()
This method returns the remoteHost. |
int |
getRemotePort()
This method gets the remotePort to which the SNMP packets should be sent. |
java.lang.String |
getSessionId()
This is the method present in ProtocolOptions. |
void |
setLocalAddresses(java.lang.String[] addrs)
This method sets the list of local addresses for which the session should bind. |
void |
setLocalPort(int port)
This method sets the local port on which the session should be opened. |
void |
setReceiveBufferSize(int size)
This method sets the buffer size of this receiver when the receiver is ready for receiving the next packet. |
void |
setRemoteAddress(java.net.InetAddress addr)
This method sets the remoteAddress. |
void |
setRemoteHost(java.lang.String host)
This method sets the remoteHost to this UDPProtocolOptions object. |
void |
setRemotePort(int port)
This method sets the remotePort to which the SNMP packets should be sent. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UDPProtocolOptions()
public UDPProtocolOptions(java.lang.String remoteHost, int remotePort)
UDPProtocolOptions
object with
remoteHost
and remotePort
as
target host and port.remoteHost
- the target host to which a SNMP request is
to be sent.remotePort
- the target port to which a SNMP request is
to be sent.java.lang.IllegalArgumentException
- If remoteHost
is null or an empty string.remotePort
is less than zero or greater
than 65535.public UDPProtocolOptions(java.net.InetAddress remoteAddress, int remotePort)
UDPProtocolOptions
object with
remoteAddress
and remotePort
as
target host and port.remoteAddress
- the target address to which a SNMP request is
to be sent.remotePort
- the target port to which a SNMP request is
to be sent.java.lang.IllegalArgumentException
- If remoteAddress
is null.remotePort
is less than zero or greater
than 65535.public UDPProtocolOptions(java.lang.String remoteHost)
UDPProtocolOptions
object with
remoteHost
as target host and 161 as the target port.remoteHost
- the target host to which a SNMP request is
to be sent.java.lang.IllegalArgumentException
- If remoteHost is null or
an empty string.public UDPProtocolOptions(java.net.InetAddress remoteAddress)
UDPProtocolOptions
object with
remoteAddress
as target address and 161 as the target port.remoteAddress
- the target address to which a SNMP request is
to be sent.java.lang.IllegalArgumentException
- If remoteAddress is null.Method Detail |
public java.lang.String getSessionId()
getSessionId
in interface ProtocolOptions
public java.lang.String getRemoteHost()
public void setRemoteHost(java.lang.String host)
host
- The remoteHost that is to be set.public java.net.InetAddress getRemoteAddress()
public void setRemoteAddress(java.net.InetAddress addr)
addr
- the remote inet address.public int getLocalPort()
public void setLocalPort(int port)
port
- the port at which the session should be opened.java.lang.IllegalArgumentException
- If the port is negative or
greater than 65535.public java.lang.String[] getLocalAddresses()
public void setLocalAddresses(java.lang.String[] addrs)
addrs
- the list of addresses to which the session
should try binding.public int getRemotePort()
public void setRemotePort(int port)
port
- the remote port to which the SNMP packet should be
sent.java.lang.IllegalArgumentException
- If the port is negative or
greater than 65535.public void setReceiveBufferSize(int size)
The following should be done to set the receive buffer
size in the SnmpTransportProvider.
UDPProtocolOptions opt = (UDPProtocolOptions)session.getProtocolOptions();
if(opt != null)
{
opt.setReceiveBufferSize(size);
}
else
{
UDPProtocolOptions opt = new UDPProtocolOptions();
opt.setReceiveBufferSize(size);
session.setProtocolOptions(opt);
}
Usaually the protocolOptions in the session will not be
null, unless session.setProtocolOptions() is called with
a null value.
This method will accept only values that are greater than zero. If the value is less than or equal to zero, then an IllegalArgumentException will be thrown. The validity of the value that is passed should be done by the user. Any invalid value that is passed will not be set on the SnmpTransportProvider.
size
- the size of the buffer.java.lang.IllegalArgumentException
- if the value is 0 or is
negative.public int getReceiveBufferSize()
The UDPProtocolOptions object that is used to open the SnmpSession will return the present buffer size of the socket.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |