Methods Summary |
---|
public void | add(SnmpMibNode meta, int depth, com.sun.jmx.snmp.SnmpVarBind varbind)
registerNode(meta,depth,null,varbind,false,null);
|
public void | add(SnmpMibNode meta, int depth, com.sun.jmx.snmp.SnmpOid entryoid, com.sun.jmx.snmp.SnmpVarBind varbind, boolean isnew)
registerNode(meta,depth,entryoid,varbind,isnew,null);
|
public void | add(SnmpMibNode meta, int depth, com.sun.jmx.snmp.SnmpOid entryoid, com.sun.jmx.snmp.SnmpVarBind varbind, boolean isnew, com.sun.jmx.snmp.SnmpVarBind statusvb)
registerNode(meta,depth,entryoid,varbind,isnew,statusvb);
|
private static final void | debug(java.lang.String func, java.lang.String info)
Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP,
"SnmpRequestTree", func, info);
|
private static int | findOid(com.sun.jmx.snmp.SnmpOid[] oids, int count, com.sun.jmx.snmp.SnmpOid oid)
final int size = count;
int low= 0;
int max= size - 1;
int curr= low + (max-low)/2;
//System.out.println("Try to retrieve: " + oid.toString());
while (low <= max) {
final SnmpOid pos = oids[curr];
//System.out.println("Compare with" + pos.toString());
// never know ...we might find something ...
//
final int comp = oid.compareTo(pos);
if (comp == 0)
return curr;
if (oid.equals(pos)) {
return curr;
}
if (comp > 0) {
low = curr + 1;
} else {
max = curr - 1;
}
curr = low + (max-low)/2;
}
return -1;
|
private com.sun.jmx.snmp.agent.SnmpRequestTree$Handler | get(java.lang.Object key)
if (key == null) return null;
if (hashtable == null) return null;
return (Handler) hashtable.get(key);
|
public java.util.Enumeration | getHandlers()
return hashtable.elements();
|
private static int | getInsertionPoint(com.sun.jmx.snmp.SnmpOid[] oids, int count, com.sun.jmx.snmp.SnmpOid oid)
final SnmpOid[] localoids = oids;
final int size = count;
int low= 0;
int max= size - 1;
int curr= low + (max-low)/2;
while (low <= max) {
final SnmpOid pos = localoids[curr];
// never know ...we might find something ...
//
final int comp= oid.compareTo(pos);
// In the calling method we will have to check for this case...
// if (comp == 0)
// return -1;
// Returning curr instead of -1 avoids having to call
// findOid() first and getInsertionPoint() afterwards.
// We can simply call getInsertionPoint() and then checks whether
// there's an OID at the returned position which equals the
// given OID.
if (comp == 0)
return curr;
if (comp>0) {
low= curr +1;
} else {
max= curr -1;
}
curr= low + (max-low)/2;
}
return curr;
|
public SnmpMibNode | getMetaNode(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler)
return handler.meta;
|
public int | getOidDepth(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler)
return handler.depth;
|
public int | getRequestPduVersion()
return request.getRequestPduVersion();
|
SnmpMibSubRequest | getSubRequest(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler)
if (handler == null) return null;
return new SnmpMibSubRequestImpl(request,handler.getSubList(),
null,false,getnextflag,null);
|
SnmpMibSubRequest | getSubRequest(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler, com.sun.jmx.snmp.SnmpOid oid)
if (handler == null) return null;
final int pos = handler.getEntryPos(oid);
if (pos == -1) return null;
return new SnmpMibSubRequestImpl(request,
handler.getEntrySubList(pos),
handler.getEntryOid(pos),
handler.isNewEntry(pos),
getnextflag,
handler.getRowStatusVarBind(pos));
|
SnmpMibSubRequest | getSubRequest(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler, int entry)
if (handler == null) return null;
return new
SnmpMibSubRequestImpl(request,handler.getEntrySubList(entry),
handler.getEntryOid(entry),
handler.isNewEntry(entry),getnextflag,
handler.getRowStatusVarBind(entry));
|
public java.util.Enumeration | getSubRequests(com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler)
return new Enum(this,handler);
|
public java.lang.Object | getUserData() return request.getUserData();
|
public int | getVersion()
return version;
|
public boolean | isCreationAllowed()
return creationflag;
|
private static final boolean | isDebugOn()
return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP);
|
public boolean | isSetRequest()
return setreqflag;
|
public static int | mapGetException(int errorStatus, int version)
final int errorCode = errorStatus;
if (version == SnmpDefinitions.snmpVersionOne)
return errorCode;
int mappedErrorCode = errorCode;
// Now take care of V2 errorCodes that can be stored
// in the varbind itself:
if (errorCode ==
SnmpStatusException.noSuchObject)
// noSuchObject => noSuchObject
mappedErrorCode = errorCode;
else if (errorCode ==
SnmpStatusException.noSuchInstance)
// noSuchInstance => noSuchInstance
mappedErrorCode = errorCode;
// Now we're going to try to transform every other
// global code in either noSuchInstance or noSuchObject,
// so that the get can return a partial result.
//
// Only noSuchInstance or noSuchObject can be stored
// in the varbind itself.
//
// According to RFC 1905: noAccess is emitted when the
// the access is denied because it is not in the MIB view...
//
else if (errorCode ==
SnmpStatusException.noAccess)
// noAccess => noSuchInstance
mappedErrorCode = SnmpStatusException.noSuchInstance;
// According to RFC 1905: (my interpretation because it is not
// really clear) The specified variable name exists - but the
// variable does not exists and cannot be created under the
// present circumstances (probably because the request specifies
// another variable/value which is incompatible, or because the
// value of some other variable in the MIB prevents the creation)
//
// Note that this error should never be raised in a GET context
// but who knows?
//
else if (errorCode == SnmpStatusException.snmpRspInconsistentName)
// inconsistentName => noSuchInstance
mappedErrorCode = SnmpStatusException.noSuchInstance;
// All the errors comprised between snmpRspWrongType and
// snmpRspInconsistentValue concern values: so we're going
// to assume the OID was correct, and reply with noSuchInstance.
//
// Note that this error should never be raised in a GET context
// but who knows?
//
else if ((errorCode >= SnmpStatusException.snmpRspWrongType) &&
(errorCode <= SnmpStatusException.snmpRspInconsistentValue))
mappedErrorCode = SnmpStatusException.noSuchInstance;
// We're going to assume the OID was correct, and reply
// with noSuchInstance.
//
else if (errorCode == SnmpStatusException.readOnly)
mappedErrorCode = SnmpStatusException.noSuchInstance;
// For all other errors but genErr, we're going to reply with
// noSuchObject
//
else if (errorCode != SnmpStatusException.snmpRspAuthorizationError &&
errorCode != SnmpStatusException.snmpRspGenErr)
mappedErrorCode = SnmpStatusException.noSuchObject;
// Only genErr will abort the GET and be returned as global
// error.
//
return mappedErrorCode;
|
public static int | mapSetException(int errorStatus, int version)
final int errorCode = errorStatus;
if (version == SnmpDefinitions.snmpVersionOne)
return errorCode;
int mappedErrorCode = errorCode;
// Now take care of V2 errorCodes that can be stored
// in the varbind itself:
if (errorCode == SnmpStatusException.noSuchObject)
// noSuchObject => notWritable
mappedErrorCode = SnmpStatusException.snmpRspNotWritable;
else if (errorCode == SnmpStatusException.noSuchInstance)
// noSuchInstance => notWritable
mappedErrorCode = SnmpStatusException.snmpRspNotWritable;
return mappedErrorCode;
|
private void | put(java.lang.Object key, com.sun.jmx.snmp.agent.SnmpRequestTree$Handler handler)
if (handler == null) return;
if (key == null) return;
if (hashtable == null) hashtable = new Hashtable();
hashtable.put(key,handler);
|
private void | registerNode(SnmpMibNode meta, int depth, com.sun.jmx.snmp.SnmpOid entryoid, com.sun.jmx.snmp.SnmpVarBind varbind, boolean isnew, com.sun.jmx.snmp.SnmpVarBind statusvb)
if (meta == null) {
if (isDebugOn())
debug("registerNode","meta-node is null!!!");
return;
}
if (varbind == null) {
if (isDebugOn())
debug("registerNode","varbind is null!!!");
return ;
}
final Object key = meta;
// retrieve the handler node associated with the given meta,
// if any
Handler handler = get(key);
// If no handler node was found for that meta, create one.
if (handler == null) {
// if (isDebugOn())
// debug("registerNode", "adding node for " +
// varbind.oid.toString());
handler = new Handler(type);
handler.meta = meta;
handler.depth = depth;
put(key,handler);
}
// else {
// if (isDebugOn())
// debug("registerNode","found node for " +
// varbind.oid.toString());
// }
// Adds the varbind in the handler node's sublist.
if (entryoid == null)
handler.addVarbind(varbind);
else
handler.addVarbind(varbind,entryoid,isnew,statusvb);
return ;
|
void | setGetNextFlag()
getnextflag = true;
|
void | setPduType(int pduType)
type = pduType;
setreqflag = ((pduType == SnmpDefinitions.pduWalkRequest) ||
(pduType == SnmpDefinitions.pduSetRequestPdu));
|
void | switchCreationFlag(boolean flag)
creationflag = flag;
|