Module org.snmp4j

Package org.snmp4j.smi

Provides classes for the representation of SMIv1/v2 data types (which also includes some basic ASN.1 primitive data types).

The org.snmp4j.smi classes are capable of BER encoding and decoding themselves to/from a byte stream. In addition, the SMI data type classes provide convenient functions for manipulating their content.

The VariantVariable is a special class that can be used in command responder applications to intercept access to a SMI value.

Variable Binding Examples

import org.snmp4j.smi.*;
VariableBinding vb = new VariableBinding(new OID(""));
vb.setValue(new OctetString("SNMP4J Text"));
vb = new VariableBinding();
vb.setOid(new OID(new int[] { 1,3,6,1,2,1,1,2,0 }));
vb = new VariableBinding(vb.getOid(), new IpAddress(""));
vb = new VariableBinding(vb.getOid(), new Gauge32(2^32-1));
int syntax = vb.getSyntax();
if (syntax != SMIConstants.SYNTAX_GAUGE32) {
  // never reached
else {
  long value = ((UnsignedInteger32)vb.getValue()).getValue();
  System.out.println(vb.getOid() + " = " + value);
  // prints: = 4294967295

The following UML class diagram shows the most important classes of the org.snmp4j.smi package and their relationships (relationships to other packages are not shown):

UML Class Diagram for SMI package