Hi Nitin, Wha is your goal? Writing a SNMP agent? Then you should use SNMP4J-Agent on top of SNMP4J. Beginning writing a SNMP agent with SNMP4J from scratch needs a lot of SNMP know how.
SNMP4J-Agent already implements most of complex agent stuff. But finally, what is the printing for? Best regards, Frank > On 19 Jan 2015, at 05:20, nitin sharma <[email protected]> wrote: > > thanks Shivi... > > -- Kindly excuse me for this lengthy email..... > > > i looked at the CommandResponder interface, it does have "ProcessPdu". i > created a class ( Snmp_commandResponder) that implements this interface and > overrides ProcessPdu(CommandResponder event) method. right now i am just > printing event.toString() and getting the following text.. > > ========================== > *processPdu received!CommandResponderEvent[securityModel=2, > securityLevel=1, maxSizeResponsePDU=65535, pduHandle=PduHandle[16071], > stateReference=StateReference[msgID=0,pduHandle=PduHandle[16071],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null], > pdu=GETBULK[requestID=16071, errorStatus=Success(0), errorIndex=16, VBS[0.0 > = Null]], messageProcessingModel=1, securityName=public, processed=false, > peerAddress=127.0.0.1/65469 <http://127.0.0.1/65469>, > transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@16f144c, > tmStateReference=null]* > > *=====================* > > However, CommandResponder doesn't have method for sending back the snmp > message. So, i looked at the CommandProcessor class in org.snmp4j.agent > package.. this class too have ProcessPdu method. Well, as a quick and dirty > way i changed my Snmp_commandResponder to extend from CommandProcessor and > in overwritten ProcessPdu method, i am calling super.ProcessPdu(event). > > My code is working, but i would like to know > a. if that is a correct way? > b. is the printed Pdu message (above) seems to be a correct one? > c. Is there a way i can get to know source server and port from where the > request to my client was originated ? > > my Code is attached as zip file to this email > > > > Regards, > Nitin Kumar Sharma. > > > On Thu, Jan 15, 2015 at 10:46 PM, Shivi Goel -X (shivigoe - NICHEPRO > TECHNOLOGIES PRIVATE LIMITED at Cisco) <[email protected]> wrote: > >> Hi Nitin, >> An incoming request or notification is stored as an instance of >> CommandRespondentEvent class in snmp4j. This class gives you api to get pdu >> and other info. >> Please refer to the API doc: >> http://www.snmp4j.org/doc/org/snmp4j/CommandResponderEvent.html >> >> Regards, >> Shivi >> >> -----Original Message----- >> From: SNMP4J [mailto:[email protected]] On Behalf Of nitin sharma >> Sent: Friday, January 16, 2015 7:35 AM >> To: [email protected] >> Subject: [SNMP4J] Snmp4j agent -- can print and store the incoming requests >> >> HI team, >> >> I am building a Snmp4j agent code that will print the incoming Snmp >> request . is it possible scenario to be coded? if yes, then please do >> provide some guidance. >> >> Regards, >> Nitin Kumar Sharma. >> _______________________________________________ >> SNMP4J mailing list >> [email protected] >> https://oosnmp.net/mailman/listinfo/snmp4j >> > _______________________________________________ > SNMP4J mailing list > [email protected] > https://oosnmp.net/mailman/listinfo/snmp4j _______________________________________________ SNMP4J mailing list [email protected] https://oosnmp.net/mailman/listinfo/snmp4j
