Debian Codegraph @

testing/fulltests/unit-tests/T105trap_parse_clib.c

raw
1 /* HEADER Parsing of an SNMP trap with no varbinds */
2 static u_char trap_pdu[] = {
3 /* Sequence with length of 0x2d = 45 bytes. */
4 [ 0] = 0x30, [ 1] = 0x82, [ 2] = 0x00, [ 3] = 0x2d,
5 /* version = INTEGER 0 */
6 [ 4] = 0x02, [ 5] = 0x01, [ 6] = 0x00,
7 /* community = public (OCTET STRING 0x70 0x75 0x62 0x6c 0x69 0x63) */
8 [ 7] = 0x04, [ 8] = 0x06, [ 9] = 0x70, [10] = 0x75,
9 [11] = 0x62, [12] = 0x6c, [13] = 0x69, [14] = 0x63,
10 /* SNMP_MSG_TRAP; 32 bytes. */
11 [15] = 0xa4, [16] = 0x20,
12 /* enterprise = OBJECT IDENTIFIER .1.3.6.1.6.3.1.1.5 = snmpTraps */
13 [17] = 0x06, [18] = 0x08,
14 [19] = 0x2b, [20] = 0x06, [21] = 0x01, [22] = 0x06,
15 [23] = 0x03, [24] = 0x01, [25] = 0x01, [26] = 0x05,
16 /* agent-addr = ASN_IPADDRESS 192.168.1.34 */
17 [27] = 0x40, [28] = 0x04, [29] = 0xc0, [30] = 0xa8,
18 [31] = 0x01, [32] = 0x22,
19 /* generic-trap = INTEGER 0 */
20 [33] = 0x02, [34] = 0x01, [35] = 0x00,
21 /* specific-trap = INTEGER 0 */
22 [36] = 0x02, [37] = 0x01, [38] = 0x00,
23 /* ASN_TIMETICKS 0x117f243a */
24 [39] = 0x43, [40] = 0x04, [41] = 0x11, [42] = 0x7f,
25 [43] = 0x24, [44] = 0x3a,
26 /* varbind list */
27 [45] = 0x30, [46] = 0x82, [47] = 0x00, [48] = 0x00,
28 };
29 static size_t trap_pdu_length = sizeof(trap_pdu);
30 netsnmp_session session;
31 netsnmp_pdu *pdu = calloc(1, sizeof(*pdu));
32 int rc;
33
34 snmp_set_do_debugging(TRUE);
35 debug_register_tokens("dumpv_recv,dumpv_send,asn,recv");
36 memset(&session, 0, sizeof(session));
37 snmp_sess_init(&session);
38 rc = snmp_parse(NULL, &session, pdu, trap_pdu, trap_pdu_length);
39
40 OKF((rc == 0), ("Parsing of a trap PDU"));
41
42 snmp_free_pdu(pdu);
43
44 netsnmp_cleanup_session(&session);