- java.lang.Object
-
- org.snmp4j.tools.console.SnmpCommand
-
- All Implemented Interfaces:
java.lang.Runnable,java.util.EventListener,CommandResponder,TransportListener
public class SnmpCommand extends java.lang.Object implements java.lang.Runnable, CommandResponder, TransportListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSnmpCommand.SnmpCommandMessageDispatcher
-
Field Summary
Fields Modifier and Type Field Description protected intoperation
-
Constructor Summary
Constructors Constructor Description SnmpCommand(java.lang.String command, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> args)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringexample(java.lang.String prefix, java.lang.String command)java.lang.Stringhelp(java.lang.String prefix, java.lang.String command, boolean listOptionsDetails, boolean withDescription)intlisten()static voidmain(java.lang.String[] args)protected static voidprintReport(PDU response)static voidprintUsage()protected static voidprintVariableBindings(PDU response)protected static voidprintVersion()voidprocessMessage(TransportMapping<?> sourceTransport, Address destAddress, byte[] message)<A extends Address>
voidprocessMessage(TransportMapping<? super A> sourceTransport, A incomingAddress, java.nio.ByteBuffer wholeMessage, TransportStateReference tmStateReference)Processes an incoming message.<A extends Address>
voidprocessPdu(CommandResponderEvent<A> e)Process an incoming request, report or notification PDU.voidrun()PDUsend()static java.lang.Stringspaces(int n)inttable()
-
-
-
Method Detail
-
help
public java.lang.String help(java.lang.String prefix, java.lang.String command, boolean listOptionsDetails, boolean withDescription)
-
example
public java.lang.String example(java.lang.String prefix, java.lang.String command)
-
spaces
public static java.lang.String spaces(int n)
-
send
public PDU send() throws java.io.IOException
- Throws:
java.io.IOException
-
printReport
protected static void printReport(PDU response)
-
processPdu
public <A extends Address> void processPdu(CommandResponderEvent<A> e)
Description copied from interface:CommandResponderProcess an incoming request, report or notification PDU.- Specified by:
processPduin interfaceCommandResponder- Type Parameters:
A- type of the peerAddress.- Parameters:
e- aCommandResponderEventinstance containing the PDU to process and some additional information returned by the message processing model that decoded the SNMP message.
-
printVariableBindings
protected static void printVariableBindings(PDU response)
-
table
public int table() throws java.io.IOException- Throws:
java.io.IOException
-
listen
public int listen() throws java.io.IOException- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args)
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
printVersion
protected static void printVersion()
-
printUsage
public static void printUsage() throws java.io.IOException- Throws:
java.io.IOException
-
processMessage
public <A extends Address> void processMessage(TransportMapping<? super A> sourceTransport, A incomingAddress, java.nio.ByteBuffer wholeMessage, TransportStateReference tmStateReference)
Description copied from interface:TransportListenerProcesses an incoming message.- Specified by:
processMessagein interfaceTransportListener- Type Parameters:
A- theAddresstype.- Parameters:
sourceTransport- aTransportMappinginstance denoting the transport that received the message and that will be used to send any responses to this message. ThesourceTransporthas to support theincomingAddress's implementation class.incomingAddress- theAddressfrom which the message has been received.wholeMessage- anByteBuffercontaining the received message.tmStateReference- the transport model state reference as defined by RFC 5590.
-
processMessage
public void processMessage(TransportMapping<?> sourceTransport, Address destAddress, byte[] message)
-
-