[SNMP4J] Agent always sends V3 Trap

Saraswat, Deepak deepak.saraswat at hp.com
Wed Jul 18 15:20:40 CEST 2007


Hi All,

 

I have added a Snmp Version 2 Notification Target in SnmpTargetMib. But
I always see a trap that is sent with "SecName :  SHADES Security Level
is 3 Cummunity is  null Address is 16.150.24.87/162 Model is 3" I am not
sure why Snmp Agent API's are always sending a V3 traps even though my
target and the added Traget Params are from v2c.

 

I have debugged it further and found that while I am adding a target it
is added correctly like:

 

CALLINING ADD NOTIFICATION TARGETS

In ADD TARGET PARAM FUNCTION >>> Get Column Count is 6

 In ADD TARGET PARAM FUNCTION >>> Index is  118.50.99

 In ADD TARGET PARAM FUNCTION >>> VB 0 is   1

 In ADD TARGET PARAM FUNCTION >>> VB 1 is   2

 In ADD TARGET PARAM FUNCTION >>> VB 2 is   public

 In ADD TARGET PARAM FUNCTION >>> VB 3 is   1

 In ADD TARGET PARAM FUNCTION >>> VB 4 is   4

 In ADD TARGET PARAM FUNCTION >>> VB 5 is   1

 

 

but while retrieving this target by using  notify() call in
NotificationOriginatorImpl class:

 

 

if (aFilter.passesFilter(addr)) {

          OctetString params =

 
(OctetString)addr.getValue(SnmpTargetMIB.idxSnmpTargetAddrParams);

          

          System.out.println("PARAM Name is  " + params); ===>>> This
gives a correct value as v2c

          

          MOTableRow paramsRow = targetMIB.getTargetParamsRow(params);

          

          System.out.println("PARANM ROW IS " + paramsRow.toString());
==>> this gives value related to Shades

 

 

 

Output is

 

PARAM Name is  v2c

 paramName is v2c and it's Index is 118.50.99 =====>> Index id is same

PARANM ROW IS DefaultMOMutableRow2PC[index=118.50.99,values=[3, 3,
SHADES, 3, 4, 1]  ===>>> This is different

 

 

Moreover, In the Trap receiver program I found a error like:

 

Received trap at: Wed Jul 18 06:33:27 CEST 2007

com.orillion.protocol.snmp.SnmpParseException: Bad SnmpOctetString tag:
0x30

Received trap at: Wed Jul 18 06:33:27 CEST 2007

com.orillion.protocol.snmp.SnmpParseException: Bad SnmpOctetString tag:
0x30

Received trap at: Wed Jul 18 06:36:21 CEST 2007

com.orillion.protocol.snmp.SnmpParseException: Bad SnmpOctetString tag:
0x30

Received trap at: Wed Jul 18 06:36:21 CEST 2007

com.orillion.protocol.snmp.SnmpParseException: Bad SnmpOctetString tag:
0x30

 

Here is a Code in TestAgent for adding a Target configuration:

============================================

 

protected void addNotificationTargets(SnmpTargetMIB targetMIB,

                                        SnmpNotificationMIB
notificationMIB) {

              System.out.println("CALLINING ADD NOTIFICATION TARGETS");

    targetMIB.addDefaultTDomains();

 

    targetMIB.addTargetAddress(new OctetString("notification"),

                               TransportDomains.transportDomainUdpIpv4,

                               new OctetString(new
UdpAddress("16.150.24.87/162").getValue()),

                               200, 1,

                               new OctetString("notify"),

                               new OctetString("v2c"),

                               StorageType.permanent);

    targetMIB.addTargetParams(new OctetString("v2c"),

                              MessageProcessingModel.MPv2c,

                              SecurityModel.SECURITY_MODEL_SNMPv2c,

                              new OctetString("public"),

                              SecurityLevel.NOAUTH_NOPRIV,

                              StorageType.permanent);

   

    notificationMIB.addNotifyEntry(new OctetString("default"),

                                   new OctetString("notify"),

 
SnmpNotificationMIB.SnmpNotifyTypeEnum.trap,

                                   StorageType.permanent);

        

  }

 

  protected void addViews(VacmMIB vacm) {

    vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv1,

                  new OctetString("public"),

                  new OctetString("v1v2group"),

                  StorageType.nonVolatile);

    vacm.addGroup(SecurityModel.SECURITY_MODEL_SNMPv2c,

                  new OctetString("public"),

                  new OctetString("v1v2group"),

                  StorageType.nonVolatile);

    vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,

                  new OctetString("SHADES"),

                  new OctetString("v3group"),

                  StorageType.nonVolatile);

    vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,

                  new OctetString("TEST"),

                  new OctetString("v3test"),

                  StorageType.nonVolatile);

    vacm.addGroup(SecurityModel.SECURITY_MODEL_USM,

                  new OctetString("SHA"),

                  new OctetString("v3restricted"),

                  StorageType.nonVolatile);

 

    vacm.addAccess(new OctetString("v1v2group"), new OctetString(),

                   SecurityModel.SECURITY_MODEL_ANY,

                   SecurityLevel.NOAUTH_NOPRIV,

                   MutableVACM.VACM_MATCH_EXACT,

                   new OctetString("fullReadView"),

                   new OctetString("fullWriteView"),

                   new OctetString("fullNotifyView"),

                   StorageType.nonVolatile);    

    

    vacm.addAccess(new OctetString("v3group"), new OctetString(),

                   SecurityModel.SECURITY_MODEL_USM,

                   SecurityLevel.AUTH_PRIV,

                   MutableVACM.VACM_MATCH_EXACT,

                   new OctetString("fullReadView"),

                   new OctetString("fullWriteView"),

                   new OctetString("fullNotifyView"),

                   StorageType.nonVolatile);

    vacm.addAccess(new OctetString("v3restricted"), new OctetString(),

                   SecurityModel.SECURITY_MODEL_USM,

                   SecurityLevel.AUTH_NOPRIV,

                   MutableVACM.VACM_MATCH_EXACT,

                   new OctetString("restrictedReadView"),

                   new OctetString("restrictedWriteView"),

                   new OctetString("restrictedNotifyView"),

                   StorageType.nonVolatile);

    vacm.addAccess(new OctetString("v3test"), new OctetString(),

                   SecurityModel.SECURITY_MODEL_USM,

                   SecurityLevel.AUTH_PRIV,

                   MutableVACM.VACM_MATCH_EXACT,

                   new OctetString("testReadView"),

                   new OctetString("testWriteView"),

                   new OctetString("testNotifyView"),

                   StorageType.nonVolatile);

 

    vacm.addViewTreeFamily(new OctetString("fullReadView"), new
OID("1.3"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("fullWriteView"), new
OID("1.3"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("fullNotifyView"), new
OID("1.3"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

 

    vacm.addViewTreeFamily(new OctetString("restrictedReadView"),

                           new OID("1.3.6.1.2"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("restrictedWriteView"),

                           new OID("1.3.6.1.2.1"),

                           new OctetString(),

                           VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("restrictedNotifyView"),

                           new OID("1.3.6.1.2"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

 

    vacm.addViewTreeFamily(new OctetString("testReadView"),

                           new OID("1.3.6.1.2"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("testReadView"),

                           new OID("1.3.6.1.2.1.1"),

                           new OctetString(), VacmMIB.vacmViewExcluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("testWriteView"),

                           new OID("1.3.6.1.2.1"),

                           new OctetString(),

                           VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

    vacm.addViewTreeFamily(new OctetString("testNotifyView"),

                           new OID("1.3.6.1.2"),

                           new OctetString(), VacmMIB.vacmViewIncluded,

                           StorageType.nonVolatile);

 

  }

 

Please help me with this.

 

Thank for your help in advance.

 

Regards,

Deepak




More information about the SNMP4J mailing list