The mibble-users group is for questions concerning Mibble. Please go to the respective forums for those other products or projects you're mentioning instead of misusing this group. Thanks.
/Per On Fri, Mar 28, 2008 at 6:37 AM, Padala <[EMAIL PROTECTED]> wrote: > Hi All > > My Application using SNMP4J API is to give response for snmp v3 requests. > > I have given the following netsnmp command from my linux box. > > snmpget -v 3 -a MD5 -A 'hello1234' -l authPriv -u 'snmpuser1' -x DES -X > hello1234 annra01-xp1 1.3.6.1.2.1.2.2.1.2.1 -t 30 -d > > > > My Agent application is responding to snmp request and it is sending the > response but NetSNMP Get command unable to decode the message. > > I also attaching netsnmp output. > > > > class MySNMPResponse extends Thread implements CommandResponder > { > > public MySNMPResponse() > > { > try > > { > > udpAddress = new UdpAddress('0.0.0.0/161'); > > TransportMapping transport = new DefaultUdpTransportMapping(udpAddress); > > snmp = new Snmp(transport); > > localEngineID = ((MPv3)snmp.getMessageProcessingModel > > (MessageProcessingModel.MPv3)).createLocalEngineID(); > > USM usm = new USM(SecurityProtocols.getInstance(), new > OctetString(localEngineID), 0); > > SecurityModels.getInstance().addSecurityModel(usm); > > snmp.getUSM().addUser(new OctetString('snmpuser1'), > > new UsmUser(new OctetString('snmpuser1'), > > AuthMD5.ID, new OctetString('hello1234'), > > PrivDES.ID, new OctetString('hello1234'))); > > snmp.setLocalEngine(localEngineID, 0, 0); > > snmp.addCommandResponder(this); > > transport.listen(); > > start(); > > } > > catch(Exception e) > > { > > e.printStackTrace(); > > } > > }//MySNMPResponse() > > > > public void run() > > { > > //infinite loop > > while(1); > > }//Run() > > > > > > public synchronized void processPdu(CommandResponderEvent e) > > { > > System.out.println('in ProcessPDU'); > > > //System.out.println(e.getSecurityLevel()); > > /*Creating Target Object*/ > > PDU pdu = e.getPDU(); > > TransportMapping tm = e.getTransportMapping(); > > if(pdu != null ) > > { > > int snmpVersion = e.getMessageProcessingModel(); > > PDU responsePDU = null; > > Target target = null; > > if(snmpVersion == MessageProcessingModel.MPv1 || snmpVersion == > > MessageProcessingModel.MPv2c ||snmpVersion == MessageProcessingModel.MPv2u) > > { > > //Create an object of CommunityTarget and assing to target > > //Create an object of PDU and assign to responsePDU > > } > > else if(snmpVersion == MessageProcessingModel.MPv3) > > { > > UserTarget userTarget = new UserTarget(); > > userTarget.setAddress((UdpAddress) e.getPeerAddress()); > > userTarget.setRetries(1); > > // set timeout to 500 milliseconds -> 2*500ms = 1s total timeout > > userTarget.setTimeout(500); > > userTarget.setVersion(SnmpConstants.version3); > > System.out.println(e.getSecurityLevel()); > > System.out.println(new OctetString(e.getSecurityName())); > > userTarget.setSecurityLevel(e.getSecurityLevel()); > > userTarget.setSecurityName(new OctetString(e.getSecurityName())); > > ScopedPDU scopedPDU = new ScopedPDU(); > > scopedPDU.setContextName(new OctetString('snmpuser1')); > > scopedPDU.setContextEngineID(new OctetString('123456789123456789')); > > responsePDU = scopedPDU; > > target = userTarget; > > } > > } > > try > > { > > //Setting Response Packet Attributes > > responsePDU.setRequestID(new Integer32(pdu.getRequestID().getValue())); > > responsePDU.setType(PDU.RESPONSE); > > responsePDU.setErrorStatus(PDU.noError); > > responsePDU.setErrorIndex(0); // NO ERROR > > Vector variableBindings = pdu.getVariableBindings(); > > for(int index = 0;index < variableBindings.size();index++) > > { > > Variable value = null; > > VariableBinding var = (VariableBinding)variableBindings.get(index); > > OID oid = var.getOid(); > > VariableBinding vbObj = new VariableBinding(oid,new Integer32(4)); > > responsePDU.add(vbObj); > > } > > snmp.send(responsePDU, target, tm); > > } > > catch(Exception e) > > { > > e.printStackTrace(); > > } > > }//ProcessPDU > > public void main(String s[]) > > { > > MySNMPResponse resObj = new MySNMPResponse(); > > }//main > > }//MySnmpResponse > > > > I would appreciate if you provide any inputs to solve porblem. > > > > Thanks in advance, > > Sai > > ________________________________ > > Looking for last minute shopping deals? Find them fast with Yahoo! Search. > _______________________________________________ > Mibble-users mailing list > Mibble-users@nongnu.org > http://lists.nongnu.org/mailman/listinfo/mibble-users > > _______________________________________________ Mibble-users mailing list Mibble-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/mibble-users