com.oy.shared.lw.snmp.agent
Class SNMPAgent
java.lang.Object
com.oy.shared.lw.snmp.agent.SNMPAgent
- All Implemented Interfaces:
- ISNMPAgent, snmp.SNMPRequestListener
- public class SNMPAgent
- extends java.lang.Object
- implements snmp.SNMPRequestListener, ISNMPAgent
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_SNMP_SERVER_PORT
public static final int DEFAULT_SNMP_SERVER_PORT
- See Also:
- Constant Field Values
SNMP_VERSION
public static final int SNMP_VERSION
- See Also:
- Constant Field Values
communityName
private java.lang.String communityName
RECEIVE_BUFFER_SIZE
private static final int RECEIVE_BUFFER_SIZE
- See Also:
- Constant Field Values
trace
private ITrace trace
server
private snmp.OYSNMServer server
errorReader
private java.io.PipedReader errorReader
readerThread
private SNMPAgent.ServerThread readerThread
mibTreeRoot
final OIDTree mibTreeRoot
isRunning
private boolean isRunning
portNumber
private int portNumber
ctx
private SNMPAgentContext ctx
SNMPAgent
public SNMPAgent(SNMPAgentContext ctx)
throws java.lang.Exception
SNMPAgent
public SNMPAgent(ITrace trace,
SNMPAgentContext ctx)
throws java.lang.Exception
stop
public void stop()
getMonitor
public IPerfMonitor getMonitor()
getEnterprisesOID
public int getEnterprisesOID()
- Specified by:
getEnterprisesOID in interface ISNMPAgent
logRequest
private void logRequest(snmp.SNMPPDU pdu,
java.lang.String communityName)
updateException
private snmp.SNMPRequestException updateException(int i,
snmp.SNMPRequestException e)
isOIDScalar
private static boolean isOIDScalar(snmp.SNMPObjectIdentifier snmpOID)
cutTrailingZerro
private static snmp.SNMPObjectIdentifier cutTrailingZerro(snmp.SNMPObjectIdentifier snmpOID)
getCommunityName
public java.lang.String getCommunityName()
setCommunityName
public void setCommunityName(java.lang.String communityName)
generateMIBFile
public void generateMIBFile(java.lang.String fileName)
throws java.io.IOException
- Specified by:
generateMIBFile in interface ISNMPAgent
- Throws:
java.io.IOException
generateMIBFile
public void generateMIBFile(java.lang.StringBuffer sb)
- Specified by:
generateMIBFile in interface ISNMPAgent
processRequest
public snmp.SNMPSequence processRequest(snmp.SNMPPDU pdu,
java.lang.String communityName)
throws snmp.SNMPGetException,
snmp.SNMPSetException
- Description copied from interface:
snmp.SNMPRequestListener
- Handles Get- or Set- request messages. The supplied request PDU may contain multiple OIDs; this
method should process those OIDs it understands, and return an SNMPVarBindList containing those OIDs
which it has handled and their corresponding values. The order of returned OID-value pairs is not
important, as the SNMPv1AgentInterface will order the information appropriately. Each implementer of
SNMPRequestListener will likely handle only a subset of the list of supplied OIDs; those OIDs which
are not relevant to a particular listener should be ignored, to be handled by another SNMPRequestListener.
If any OIDs remain unhandled after all listeners' processRequest() methods have been called, the
SNMPv1AgentInterface will return an appropriate error indication to the management entity.
- Specified by:
processRequest in interface snmp.SNMPRequestListener
- Throws:
snmp.SNMPGetException
snmp.SNMPSetException
processGetNextRequest
public snmp.SNMPSequence processGetNextRequest(snmp.SNMPPDU pdu,
java.lang.String communityName)
throws snmp.SNMPGetException
- Description copied from interface:
snmp.SNMPRequestListener
- Handles Get-Next- request messages. The supplied request PDU may contain multiple OIDs; this
method should process those OIDs it understands, and return an SNMPVarBindList containing special
variable pairs indicating those supplied OIDs which it has handled, i.e., it must indicate a
supplied OID, the "next" OID, and the value of this next OID. To do this, the return value is a
sequence of SNMPVariablePairs, in which the first component - the OID - is one of the supplied OIDs,
and the second component - the value - is itself an SNMPVariablePair containing the "next" OID and
its value:
return value = sequence of SNMPVariablePair(original OID, SNMPVariablePair(following OID, value))
In this way the SNMPv1AgentInterface which calls this method will be able to determine which of the
supplied OIDs each "next" OID corresponds to.
The order of returned "double" OID-(OID-value) pairs is not important, as the SNMPv1AgentInterface
will order the information appropriately in the response. Each implementer of
SNMPRequestListener will likely handle only a subset of the list of supplied OIDs; those OIDs which
are not relevant to a particular listener should be ignored, to be handled by another SNMPRequestListener.
If any OIDs remain unhandled after all listeners' processRequest() methods have been called, the
SNMPv1AgentInterface will return an appropriate error indication to the management entity.
- Specified by:
processGetNextRequest in interface snmp.SNMPRequestListener
- Throws:
snmp.SNMPGetException - If a listener receives a request for an OID which it is intended to handle, but there is a problem with
the request - e.g., a get-next request for a value which is not readable for the supplied community name -
the listener should throw an SNMPGetException to indicate the error. The exception should
include both the index of the OID in the list of supplied OIDs, as well as an error status code (status values
are provided as constants in the SNMPRequestException class definition). The SNMPRequestException class and
subclasses provide constructors allowing the specification of the error index and status code. Note that the
error index follows the SNMP convention of starting at 1, not 0: thus if there is a problem with the first OID,
the error index should be 1. The SNMPAgentInterface will use the information in the exception to communicate
the error to the requesting management entity. The community name should also be used to determine if a request
is valid for the supplied community name.
contains
public boolean contains(java.lang.String oid)
- Specified by:
contains in interface ISNMPAgent
add
public void add(java.lang.String absoluteOID,
IValueGroup group)
- Specified by:
add in interface ISNMPAgent
add
public void add(java.lang.String absoluteOID,
IValueSource source)
- Specified by:
add in interface ISNMPAgent
remove
public void remove(java.lang.String absoluteOID)
- Specified by:
remove in interface ISNMPAgent
Copyright (C) 2005-2006 Pavel Simakov
http://www.softwaresecretweapons.com