2

I am trying to send snmptrap from my centos machine to other centos machine. I am seeing the below in logs, snmptrap V3 with net-snmp not working "usm: no match on engineID"

trace: sc_hash(): scapi.c, 464:
trace: sc_get_properlength(): scapi.c, 138:
trace: set_enginetime(): lcd_time.c, 393:
lcd_set_enginetime: engineID 7A 7A 7D 80 7A 7A 7A 83 86 89 8C 8F : boots=0, time=0
trace: usm_get_user_from_list(): snmpusm.c, 3527:
usm: match on user doit
trace: usm_get_user_from_list(): snmpusm.c, 3533:
**usm: no match on engineID (7A 7A 7D 80 7A 7A 7A 83 86 89 8C 8F )**
trace: usm_get_user_from_list(): snmpusm.c, 3527:
usm: match on user doit
trace: usm_get_user_from_list(): snmpusm.c, 3533:

My snmptrapd.conf file looks like below

[root@localhost crash]# cat /etc/snmp/snmptrapd.conf
# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
# authCommunity   log,execute,net public
# traphandle SNMPv2-MIB::coldStart    /usr/bin/bin/my_great_script cold

createUser -e 00002E390000005056877fb3 doit MD5 doitpassword DES
authUser log doit AuthNoPriv

I have used net-snmp module of C and below is code block to create engine id,

    char engineID[13];
    engineID[0]= "0x00";
    engineID[1]= "00";
    engineID[2]= "2e";
    engineID[3]= "39";
    engineID[4]= "00";
    engineID[5]= "00";
    engineID[6]= "00";
    engineID[7]= "50";
    engineID[8]= "56";
    engineID[9]= "87";
    engineID[10]= "7f";
    engineID[11]= "b3";
    engineID[12]= "\0";

    session.securityEngineID = (u_char *)engineID;
    session.securityEngineIDLen = 12;

Apart from this I have not done any setup on TARGET machine which is receiving the trap.

The main issue the target machine receiving traps showing blank description which. Please check the below screen shot. Not sure what I am doing wrong here. Please advice.

enter image description here

2
  • Hint: your issue is 100% with your basic C programming, not with net-snmp. Apr 8, 2019 at 18:02
  • I learned that engine id is expected to be octel string. Not sure how to define it. That might be the problem. Apr 8, 2019 at 18:18

1 Answer 1

1

First of all, that's not how C strings or char arrays work. Each element of a char[] is a char; i.e. a single number in the [-128; 127] range, or [0; 255] if it's unsigned char. For example, 0x41 or 'A' is a valid value for char, but "A" is not – and "0x41" is definitely not (that's a pointer to char[5], roughly speaking).


Second: "Octet string" is ASN.1 term for a byte array (an 'octet' being an 8-bit byte), aka unsigned char[] in C. In other words, it just means plain binary data.

Binary data can be represented in several ways – as series of ASCII characters, or as series of hexadecimal numbers, or as a single long hexadecimal number, ... For example, ABC and 0x414243 (with or without the 0x) and {0x41, 0x42, 0x43} and {'A', 'B', 'C'} are different ways of writing the same data.


So if you have a hexadecimal string like 00002E390000005056877fb3 (you know it's hexadecimal because the snmpd.conf manual says so), you can write it in C like this:

unsigned char engineID[12];
engineID[0] = 0x00;
engineID[1] = 0x00;
engineID[2] = 0x2e;
engineID[3] = 0x39;
...
engineID[11] = 0xb3;

Alternatively like this:

unsigned char engineID[] = {0x00, 0x00, 0x2e, 0x39, ..., 0xb3};
4
  • Thank you so much....this has solved my engineID issue. The only issue I am facing now is blank description in MIB browser. There used to be an OID but now only showing me as "iso". Please advice if you are aware of this. Apr 9, 2019 at 4:11
  • After further debugging found below error, Cannot find TrapOID in TRAP2 PDU Apr 9, 2019 at 8:24
  • Below code need to be added ``` pdu = snmp_pdu_create(SNMP_MSG_TRAP2); snmp_add_var(pdu, objid_sysuptime, sizeof(objid_sysuptime) / sizeof(oid), 't', uptime); snmp_add_var(pdu, objid_snmptrap, sizeof(objid_snmptrap) / sizeof(oid), 'o', trap) ``` Now the question is what would be the value of trap and uptime? Apr 9, 2019 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .