Low-Level API Changes

 

The API changes in SnmpAPI are listed below.

 

S.No. Deprecated Method/Variable Comment

1

BITSTRING

This variable has been deprecated in SNMPv2.

2

NSAP 

This variable has been deprecated in SNMPv2.

3

Standard_Prefix

This should not be a public string variable. Variables should not be public.

Instead, use the setOIDPrefix(SnmpOID oid) and getOIDPrefix() methods.

4

UINTEGER32 

This variable has been deprecated in SNMP.

5

getCommunityTable()

This method is no longer supported. The getSecurityProvider().getTable(1), where 1 stands for v1 security model, provides an equivalent method. All the user-defined security implementation should be got from the provider.

6

getUSMTable()

This method is no longer supported. The getSecurityProvider().getTable(3), where 3 stands for User-based Security Model, provides an equivalent method. The USMUserTable is instantiated by the constructor of this class. The USMUserTable has a list of USMUserEntries.

 

The API changes in SnmpPDU are listed below.

 

S.No. Deprecated Method/Variable Comment

1

getAddress()

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the InetAddress is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) SnmpPDU.getProtocolOptions();
InetAddress address = opt.getRemoteAddress();

2

getRemoteHost()

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the host is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) SnmpPDU.getProtocolOptions();
String remoteHost = opt.getRemoteHost();

3

getRemotePort()

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the port is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) SnmpPDU.getProtocolOptions();
int remotePort = opt.getRemotePort();

4

setAddress(InetAddress address)

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the InetAddress is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) SnmpPDU.getProtocolOptions();  
opt.setRemoteAddress(address);

5

setDNSLookup(boolean lookup)

No lookup is done.

6

setRemoteHost(java.lang.String host)

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the host is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions)SnmpPDU.getProtocolOptions();
opt.setRemoteHost(host);

7

setRemotePort(int port)

SnmpPDU should know only the SNMP variables and protocol-independent variables. Here, the port is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions)SnmpPDU.getProtocolOptions();
opt.setRemotePort(port);

 

The API changes in SnmpSession are listed below.

 

S.No. Deprecated Method/Variable Comment

1

IP 

This is a static constant for identifying IP. This is not required because all SNMP communications are through a single transport provider.

2

TRANSPORT_PROVIDER

This is a static constant for transport provider framework. This is not required because all SNMP communications are through a single transport provider.

3

get(SnmpOID oid)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();  
pdu.addNull(oid);
pdu.setCommand(SnmpAPI.GET_REQ_MSG);
SnmpPDU response_pdu = SnmpSession.syncSend(pdu);

SnmpVar var = null;
if(response_pdu != null)
{
var = response_pdu.getVariable(0);
}

4

get(String oidString)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();
pdu.addNull(oid);
pdu.setCommand(SnmpAPI.GET_REQ_MSG);
SnmpPDU response_pdu = snmpSession.syncSend(pdu);

SnmpVar var = null;
if(response_pdu != null)
{
var = response_pdu.getVariable(0);
}

5

getLocalAddresses()

SnmpSession should know only the SNMP variables and protocol-independent variables. Here, the address is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) snmpSession.getProtocolOptions();
String[] local_address = opt.getLocalAddresses();

6

int getLocalPort()

SnmpSession should know only the SNMP variables and protocol-independent variables. Here, the port is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) snmpSession.getProtocolOptions();
int local_port = opt.getLocalPort();

7

getnext(SnmpOID oid)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();
pdu.addNull(oid);  
pdu.setCommand(SnmpAPI.GETNEXT_REQ_MSG);
SnmpPDU response_pdu = snmpSession.syncSend(pdu);
SnmpVar var = null;
if(response_pdu != null)
{
var = response_pdu.getVariable(0);
}

8

getnext(String oidString)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();
pdu.addNull(new SnmpOID(oidString));
pdu.setCommand(SnmpAPI.GETNEXT_REQ_MSG);
SnmpPDU response_pdu = snmpSession.syncSend(pdu);
SnmpVar var = null;  
if(response_pdu != null)
{
var = response_pdu.getVariable(0);
}

9

getPeername()

SnmpSession should know only the SNMP variables and protocol-independent variables. Here, the address is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions) SnmpSession.getProtocolOptions();
opt.getRemoteHost();

10

getProtocol()

This returns the protocol associated with the session object. This is not required because all SNMP communications are through a single transport provider.

11

getRemotePort()

This returns the remote port on the peer to which the session communicates. This is not required because all SNMP communications are through a single transport provider.

12

getSASClient()

This method is not required because all SNMP communications are through a single transport provider.

Use the following instead.

SASProtocolOptions opt = (SASProtocolOptions)SnmpSession.getProtocolOptions();
SASClient sasclient = opt.getSASClient();

13

getSASProtocol()

This method is not required because all SNMP communications are through a single transport provider.

Use the following instead.

SASProtocolOptions opt = (SASProtocolOptions)snmpSession.getProtocolOptions();
int sasprotocol = opt.getProtocol();

14

getSnmpClientsSize()

This method is no longer supported. Use the following instead.

int snmpClientsSize = (snmpSession.getSnmpClients()).size();

15

getStartLocalPort()

At present, the open(Applet) method throws an SnmpException if connection to the SAServer fails. When such an exception is received, the user can decide to call the open(void) method.

16

open(Applet applet)

This method is not required because all SNMP communications are through a single transport provider.

Use the following instead.

SnmpAPI api = new SnmpAPI();
SnmpSession ses = new SnmpSession(api);
SASProtocolOptions opt = new SASProtocolOptions();
opt.setApplet(applet);
ses.setProtocolOptions(opt);
ses.open();

17

set(SnmpOID oid, SnmpVar var)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();
SnmpVarBind varbind = new SnmpVarBind(oid, var);  
pdu.addVariableBinding(varbind);

 

pdu.setCommand(SnmpAPI.SET_REQ_MSG);
SnmpPDU response_pdu = SnmpSession.syncSend(pdu);

SnmpVar response_var = null;  
if(response_pdu != null)
{
response_var = response_pdu.getVariable(0);
}

18

set(String oidString, String setString, byte type)

SnmpSession is used for any type of SNMP communication and therefore methods specific to get or set operations are not required.

Use the following instead.

SnmpPDU pdu = new SnmpPDU();
SnmpVar variable = SnmpVar.createVariable(setString, type);
SnmpOID oid = new SnmpOID(oidString);  
SnmpVarBind varbind = new SnmpVarBind(oid, variable);
pdu.addVariableBinding(varbind);
pdu.setCommand(SnmpAPI.SET_REQ_MSG);
SnmpPDU response_pdu = snmpSession.syncSend(pdu);

SnmpVar var = null;
if(response_pdu != null)
{
var = response_pdu.getVariable(0);
}

19

setLocalAddresses(String[] local_addrs)

LocalAddresses should be specified only through a ProtocolOptions because all SNMP communications are through a single transport provider.

Use the following instead

UDPProtocolOptions opt = (UDPProtocolOptions)snmpSession.getProtocolOptions();
opt.setLocalAddresses(local_addrs);

20

setLocalPort(int local_port)

LocalPort should be specified only through a ProtocolOptions because all SNMP communications are through a single transport provider.

UDPProtocolOptions opt = (UDPProtocolOptions)snmpSession.getProtocolOptions();  
opt.setLocalPort(local_port);

21

setPeername(String peername)

SnmpSession should know only the SNMP variables and protocol-independent variables. Here, the peer name is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions)snmpSession.getProtocolOptions();
opt.setRemoteHost(peername);

22

setProtocol(int protocol)

This method is not required because all SNMP communications are through a single transport provider.

23

setRemotePort(int port)

SnmpSession should know only the SNMP variables and protocol-independent variables. Here, the port is specific to UDP and therefore this method is deprecated.

Use the following instead.

UDPProtocolOptions opt = (UDPProtocolOptions)snmpSession.getProtocolOptions();  
opt.setRemotePort(port);

24

setSASProtocol(int prot)

SASProtocol should be specified only through a ProtocolOptions because all SNMP communications are through a single transport provider.

Use the following instead.

SASProtocolOptions opt = new SASProtocolOptions();
opt.setApplet(applet);
opt.setProtocol(SASClient.TCP_PROTOCOL); //or SASClient.HTTP_PROTOCOL
SnmpSession.setProtocolOptions(opt);
SnmpSession.open();

25

setSocketParms(int socketTimeout, int socketDelay)

This method is not required because all SNMP communications are through a single transport provider.

26

setStartLocalPort(int startLocalPort)

At present, the open(Applet) method throws an SnmpException if connection to the SAServer fails. When such an exception is received, the user can decide to call the open(void) method.

 

The Release 3.x provides security frame work where API users can plug-in their implementation of SecurityModel to be used in SNMPV3 Security SubSystem. WebNMS SNMP API provides User Based Security Model (USM) as a default implementation for the SecurityFramework. The USM is also registered as the default Security Model. This is available as a separate package called com.adventnet.snmp.snmp2.usm.link to javadocs

 

The 2.x release had USM related classes as part of snmp2 package. In the current release because of the new security framework, the USM classes are moved to a new package called com.adventnet.snmp.snmp2.usm.

 

The existing API users using release 2.2 will require some changes in their application. This is limited to importing the com.adventnet.snmp.snmp2.usm package.

 

i.e., the existing 2.x applications will have to add the following line in their imports.

 

import com.adventnet.snmp.snmp2.usm.*;

 

In the 2.2 release to get the reference of USMUserTable the method SnmpAPI.getUSMTable() is used. This method is deprecated and the preferred way is to use the following method.

 

USMUserTable uut = (USMUserTable)api.getSecurityProvider()

getTable(USMUserEntry.USM_SECURITY_MODEL);

 

where USM_SECURITY_MODEL = 3.

 

WebNMS SNMP Release 3.x also provides an Access Control Framework where API users can plug-in their implementation of Access Control Model, to be used in SNMPV3 Access Control SubSystem. WebNMS SNMP API provides View Based Access Control Model (VACM) as a default implementation for the Access Control Framework. The VACM is also registered as the default Access Control Model. This is available as a separate package called com.adventnet.snmp.snmp2.vacm.link to javadocs

 

The existing API users using release 2.2 will require some changes in their application. This is limited to importing the com.adventnet.snmp.snmp2.vacm. package.

 

i.e the existing 2.x applications will have to add the following line in their imports.

 

import com.adventnet.snmp.snmp2.vacm.*;



Copyright © 2012, ZOHO Corp. All Rights Reserved.