[SNMP4J] Question on sending v2c trap

Frank Fock fock at agentpp.com
Thu Sep 22 22:35:23 CEST 2005


Hi Andrew,

The following code from the SnmpRequest example makes the
VB list of your PDU SNMP2c/v3 notification/inform conforming:

 private void checkTrapVariables(Vector vbs) {
   if ((pduType == PDU.INFORM) ||
       (pduType == PDU.TRAP)) {
     if ((vbs.size() == 0) ||
         ((vbs.size() > 1) &&
          (!((VariableBinding) vbs.get(0)).getOid().equals(SnmpConstants.
         sysUpTime)))) {
       vbs.add(0, new VariableBinding(SnmpConstants.sysUpTime, sysUpTime));
     }
     if ((vbs.size() == 1) ||
         ((vbs.size() > 2) &&
          (!((VariableBinding) vbs.get(1)).getOid().equals(SnmpConstants.
         snmpTrapOID)))) {
       vbs.add(1, new VariableBinding(SnmpConstants.snmpTrapOID, trapOID));
     }
   }
 }

Best regards,
Frank

Andrew Chan wrote:

>Dear all,
>  I can send v1 trap from my program, the pdu were created as follow
>  PDUv1 pdu = new PDUv1();
>pdu.setType(PDU.V1TRAP);
>pdu.setGenericTrap(PDUv1.ENTERPRISE_SPECIFIC);
> pdu.setSpecificTrap(4);
>pdu.add(new VariableBinding(new OID(MYOID + ".1"), new Integer32(1)));
>  When I try to migrate the code to v2c, how should I create the PDU?
>  PDU pdu = new PDU();
>pdu.setType(PDU.TRAP);
>pdu.add(new VariableBinding(SnmpConstants.snmpTrapEnterprise, new OID(MYOID
>+ "0.4"));
>pdu.add(new VariableBinding(new OID(MYOID + ".1"), new Integer32(1)));
> However, I capture a invalid notification format error from some MIB
>Browser (from MG-Soft), can you help me to solve this problem? Thanks.
> AC
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>  
>


-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com





More information about the SNMP4J mailing list