1 /* -*- mode: c; c-file-style: "openbsd" -*- */
3 * Copyright (c) 2015 Vincent Bernat <bernat@luffy.cx>
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #include "../src/daemon/lldpd.h"
21 #include "../src/daemon/agent.h"
23 #include <net-snmp/net-snmp-config.h>
24 #include <net-snmp/net-snmp-includes.h>
25 #include <net-snmp/agent/net-snmp-agent-includes.h>
26 #include <net-snmp/agent/snmp_vars.h>
28 extern struct lldpd
*agent_scfg
;
29 extern struct timeval starttime
;
30 extern struct variable8 agent_lldp_vars
[];
33 struct lldpd test_cfg
= {
40 struct timeval test_starttime
= { .tv_sec
= 100, .tv_usec
= 0 };
43 struct lldpd_mgmt mgmt1
= {
44 .m_family
= LLDPD_AF_IPV4
,
45 .m_addr
= { .octets
= { 0xc0, 0, 0x2, 0xf } }, /* 192.0.2.15 */
46 .m_addrsize
= sizeof(struct in_addr
),
49 struct lldpd_chassis chassis1
= {
51 .c_protocol
= LLDPD_MODE_LLDP
,
52 .c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
,
55 .c_name
= "chassis1.example.com",
56 .c_descr
= "First chassis",
57 .c_cap_available
= LLDP_CAP_BRIDGE
| LLDP_CAP_WLAN
| LLDP_CAP_ROUTER
,
58 .c_cap_enabled
= LLDP_CAP_ROUTER
,
60 .c_med_cap_available
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| \
61 LLDP_MED_CAP_LOCATION
| LLDP_MED_CAP_POLICY
| \
62 LLDP_MED_CAP_MDI_PSE
| LLDP_MED_CAP_MDI_PD
,
63 .c_med_type
= LLDP_MED_CLASS_II
,
64 .c_med_hw
= "Hardware 1",
65 /* We skip c_med_fw */
66 .c_med_sw
= "Software 1",
67 .c_med_sn
= "00-00-0000-AAAA",
68 .c_med_manuf
= "Manufacturer 1",
69 .c_med_model
= "Model 1",
70 .c_med_asset
= "Asset 1",
74 struct lldpd_mgmt mgmt2
= {
75 .m_family
= LLDPD_AF_IPV4
,
76 .m_addr
= { .octets
= { 0xc0, 0, 0x2, 0x11 } }, /* 192.0.2.17 */
77 .m_addrsize
= sizeof(struct in_addr
),
80 struct lldpd_mgmt mgmt3
= {
81 .m_family
= LLDPD_AF_IPV6
,
82 .m_addr
= { .octets
= { 0x20, 0x01, 0x0d, 0xb8,
83 0xca, 0xfe, 0x00, 0x00,
84 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x17 } }, /* 2001:db8:cafe::17 */
86 .m_addrsize
= sizeof(struct in6_addr
),
89 struct lldpd_chassis chassis2
= {
91 .c_protocol
= LLDPD_MODE_LLDP
,
92 .c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LOCAL
,
95 .c_name
= "chassis2.example.com",
96 .c_descr
= "Second chassis",
97 .c_cap_available
= LLDP_CAP_ROUTER
,
98 .c_cap_enabled
= LLDP_CAP_ROUTER
,
100 .c_med_hw
= "Hardware 2",
101 /* We skip c_med_fw */
102 .c_med_sw
= "Software 2",
103 .c_med_sn
= "00-00-0000-AAAC",
104 .c_med_manuf
= "Manufacturer 2",
105 .c_med_model
= "Model 2",
106 .c_med_asset
= "Asset 2",
110 /* First port of first chassis */
111 struct lldpd_hardware hardware1
= {
115 .h_rx_discarded_cnt
= 5,
116 .h_rx_unrecognized_cnt
= 4,
122 .p_chassis
= &chassis1
,
124 .p_protocol
= LLDPD_MODE_LLDP
,
125 .p_id_subtype
= LLDP_PORTID_SUBTYPE_LLADDR
,
133 .autoneg_support
= 1,
134 .autoneg_enabled
= 1,
135 .autoneg_advertised
= LLDP_DOT3_LINK_AUTONEG_100BASE_TX
| LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD
,
136 .mau_type
= LLDP_DOT3_MAU_100BASETXFD
,
139 .devicetype
= LLDP_DOT3_POWER_PD
,
145 .powertype
= LLDP_DOT3_POWER_8023AT_TYPE2
,
146 .source
= LLDP_DOT3_POWER_SOURCE_BOTH
,
147 .priority
= LLDP_DOT3_POWER_PRIO_LOW
,
152 #ifdef ENABLE_LLDPMED
153 .p_med_cap_enabled
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| LLDP_MED_CAP_MDI_PD
|
154 LLDP_MED_CAP_POLICY
| LLDP_MED_CAP_LOCATION
,
156 { .type
= 0 }, { .type
= 0 }, {
157 .type
= LLDP_MED_APPTYPE_GUESTVOICE
,
163 }, { .type
= 0 }, { .type
= 0 }, { .type
= 0 }, {
164 .type
= LLDP_MED_APPTYPE_VIDEOSTREAM
,
174 .format
= LLDP_MED_LOCFORMAT_CIVIC
,
175 /* 2:FR:6:Commercial Rd:19:4 */
176 .data
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4",
181 .devicetype
= LLDP_MED_POW_TYPE_PD
,
182 .source
= LLDP_MED_POW_SOURCE_LOCAL
,
183 .priority
= LLDP_MED_POW_PRIO_HIGH
,
189 /* Remaining is done is snmp_config */
193 /* Second port of first chassis */
194 struct lldpd_hardware hardware2
= {
198 .h_rx_discarded_cnt
= 55,
199 .h_rx_unrecognized_cnt
= 14,
200 .h_insert_cnt
= 1000,
205 .p_chassis
= &chassis1
,
207 .p_protocol
= LLDPD_MODE_LLDP
,
208 .p_id_subtype
= LLDP_PORTID_SUBTYPE_IFNAME
,
211 .p_descr
= "Intel 1000 GE",
216 .autoneg_support
= 1,
217 .autoneg_enabled
= 1,
218 .autoneg_advertised
= LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD
| LLDP_DOT3_LINK_AUTONEG_1000BASE_TFD
,
219 .mau_type
= LLDP_DOT3_MAU_1000BASETFD
,
222 #ifdef ENABLE_LLDPMED
223 .p_med_cap_enabled
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| LLDP_MED_CAP_MDI_PD
|
224 LLDP_MED_CAP_MDI_PSE
| LLDP_MED_CAP_POLICY
| LLDP_MED_CAP_LOCATION
,
226 { .type
= 0 }, { .type
= 0 }, {
227 .type
= LLDP_MED_APPTYPE_GUESTVOICE
,
233 }, { .type
= 0 }, { .type
= 0 }, {
234 .type
= LLDP_MED_APPTYPE_VIDEOCONFERENCE
,
240 }, { .type
= 0 }, { .type
= 0 }
244 .format
= LLDP_MED_LOCFORMAT_COORD
,
245 .data
= "Not interpreted",
247 }, { .format
= 0 }, { .format
= 0 },
254 struct lldpd_vlan vlan47
= {
255 .v_name
= "VLAN #47",
258 struct lldpd_vlan vlan49
= {
259 .v_name
= "VLAN #49",
262 struct lldpd_vlan vlan1449
= {
263 .v_name
= "VLAN #1449",
266 struct lldpd_ppvid ppvid47
= {
267 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
270 struct lldpd_ppvid ppvid118
= {
271 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
274 struct lldpd_pi pi88cc
= {
278 struct lldpd_pi pi888e01
= {
279 .p_pi
= "\x88\x8e\x01",
284 /* First port of second chassis */
285 struct lldpd_port port2
= {
286 .p_chassis
= &chassis2
,
288 .p_protocol
= LLDPD_MODE_LLDP
,
289 .p_id_subtype
= LLDP_PORTID_SUBTYPE_IFALIAS
,
292 .p_descr
= "Gigabit Ethernet 1/7",
298 starttime
= test_starttime
;
299 agent_scfg
= &test_cfg
;
300 TAILQ_INIT(&test_cfg
.g_chassis
);
301 TAILQ_INIT(&chassis1
.c_mgmt
);
302 TAILQ_INSERT_TAIL(&chassis1
.c_mgmt
, &mgmt1
, m_entries
);
303 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis1
, c_entries
);
304 TAILQ_INIT(&chassis2
.c_mgmt
);
305 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt2
, m_entries
);
306 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt3
, m_entries
);
307 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis2
, c_entries
);
308 TAILQ_INIT(&test_cfg
.g_hardware
);
309 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware1
, h_entries
);
310 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware2
, h_entries
);
312 TAILQ_INIT(&hardware1
.h_lport
.p_vlans
);
313 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan47
, v_entries
);
314 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan49
, v_entries
);
315 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan1449
, v_entries
);
316 TAILQ_INIT(&hardware1
.h_lport
.p_ppvids
);
317 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid47
, p_entries
);
318 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid118
, p_entries
);
319 TAILQ_INIT(&hardware1
.h_lport
.p_pids
);
320 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi88cc
, p_entries
);
321 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi888e01
, p_entries
);
322 TAILQ_INIT(&hardware2
.h_lport
.p_vlans
);
323 TAILQ_INIT(&hardware2
.h_lport
.p_ppvids
);
324 TAILQ_INIT(&hardware2
.h_lport
.p_pids
);
325 TAILQ_INIT(&port2
.p_vlans
);
326 TAILQ_INIT(&port2
.p_ppvids
);
327 TAILQ_INIT(&port2
.p_pids
);
329 TAILQ_INIT(&hardware1
.h_rports
);
330 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &port2
, p_entries
);
331 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &hardware2
.h_lport
, p_entries
);
332 TAILQ_INIT(&hardware2
.h_rports
);
333 TAILQ_INSERT_TAIL(&hardware2
.h_rports
, &hardware1
.h_lport
, p_entries
);
336 /* Convert OID to a string. Static buffer. */
338 snmp_oidrepr(oid
*name
, size_t namelen
)
340 static char *buffer
[4] = {NULL
, NULL
, NULL
, NULL
};
341 static int current
= 0;
344 current
= (current
+ 1)%4;
345 free(buffer
[current
]); buffer
[current
] = NULL
;
347 for (i
= 0; i
< namelen
; i
++) {
348 /* Not very efficient... */
349 char *newbuffer
= NULL
;
350 if (asprintf(&newbuffer
, "%s.%lu", buffer
[current
]?buffer
[current
]:"",
351 (unsigned long)name
[i
]) == -1) {
352 free(buffer
[current
]);
353 buffer
[current
] = NULL
;
356 free(buffer
[current
]);
357 buffer
[current
] = newbuffer
;
359 return buffer
[current
++];
363 oid name
[MAX_OID_LEN
];
365 int type
; /* ASN_* */
367 unsigned long int integer
;
375 static oid zeroDotZero
[2] = {0, 0};
376 struct tree_node snmp_tree
[] = {
377 { {1, 1, 1, 0}, 4, ASN_INTEGER
, { .integer
= 30 } }, /* lldpMessageTxInterval */
378 { {1, 1, 2, 0}, 4, ASN_INTEGER
, { .integer
= 2 } }, /* lldpMessageTxHoldMultiplier */
379 { {1, 1, 3, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpReinitDelay */
380 { {1, 1, 4, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpTxDelay */
381 { {1, 1, 5, 0}, 4, ASN_INTEGER
, { .integer
= 5 } }, /* lldpNotificationInterval */
382 { {1, 2, 1, 0}, 4, ASN_TIMETICKS
, { .integer
= 10000 } },/* lldpStatsRemTablesLastChangeTime */
383 { {1, 2, 2, 0}, 4, ASN_GAUGE
, { .integer
= 1100 } }, /* lldpStatsRemTablesInserts */
384 { {1, 2, 3, 0}, 4, ASN_GAUGE
, { .integer
= 56 } }, /* lldpStatsRemTablesDeletes */
385 { {1, 2, 4, 0}, 4, ASN_GAUGE
, { .integer
= 2 } }, /* lldpStatsRemTablesDrops */
386 { {1, 2, 5, 0}, 4, ASN_GAUGE
, { .integer
= 230 } }, /* lldpStatsRemTablesAgeouts */
388 { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 1352 } }, /* lldpStatsTxPortFramesTotal.3 */
389 { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 11352 } }, /* lldpStatsTxPortFramesTotal.4 */
390 { {1, 2, 7, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesDiscardedTotal.3 */
391 { {1, 2, 7, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesDiscardedTotal.4 */
392 { {1, 2, 7, 1, 3, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesError.3 */
393 { {1, 2, 7, 1, 3, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesError.4 */
394 { {1, 2, 7, 1, 4, 3}, 6, ASN_COUNTER
, { .integer
= 1458 } }, /* lldpStatsRxPortFramesTotal.3 */
395 { {1, 2, 7, 1, 4, 4}, 6, ASN_COUNTER
, { .integer
= 11458 } }, /* lldpStatsRxPortFramesTotal.4 */
396 { {1, 2, 7, 1, 5, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsDiscardedTotal.3 */
397 { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */
398 { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */
399 { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */
400 { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE
, { .integer
= 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
401 { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE
, { .integer
= 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
403 { {1, 3, 1, 0}, 4, ASN_INTEGER
, { .integer
= 4 } }, /* lldpLocChassisIdSubtype */
404 /* lldpLocChassisId */
405 { {1, 3, 2, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
408 { {1, 3, 3, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "chassis1.example.com",
411 { {1, 3, 4, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "First chassis",
413 /* lldpLocSysCapSupported */
414 { {1, 3, 5, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x38",
416 /* lldpLocSysCapEnabled */
417 { {1, 3, 6, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x8",
420 { {1, 3, 7, 1, 2, 3}, 6, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocPortIdSubtype.3 */
421 { {1, 3, 7, 1, 2, 4}, 6, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocPortIdSubtype.5 */
422 /* lldpLocPortId.3 */
423 { {1, 3, 7, 1, 3, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
425 /* lldpLocPortId.4 */
426 { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth4",
428 /* lldpLocPortDesc.3 */
429 { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth2",
431 /* lldpLocPortDesc.4 */
432 { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "Intel 1000 GE",
435 { {1, 3, 8, 1, 3, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocManAddrLen */
436 { {1, 3, 8, 1, 4, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 2 } }, /* lldpLocManAddrIfSubtype */
437 { {1, 3, 8, 1, 5, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocManAddrIfId */
438 /* lldpLocManAddrOID */
439 { {1, 3, 8, 1, 6, 1, 4, 192, 0, 2, 15}, 11, ASN_OBJECT_ID
,
440 { .string
= { .octet
= (char *)zeroDotZero
,
441 .len
= sizeof(zeroDotZero
) }} },
443 /* lldpRemChassisIdSubtype */
444 { {1, 4, 1, 1, 4, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 4 } },
445 { {1, 4, 1, 1, 4, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 7 } },
446 { {1, 4, 1, 1, 4, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 4 } },
447 /* lldpRemChassisId */
448 { {1, 4, 1, 1, 5, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
449 { {1, 4, 1, 1, 5, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
450 { .octet
= "chassis2",
452 { {1, 4, 1, 1, 5, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
453 /* lldpRemPortIdSubtype */
454 { {1, 4, 1, 1, 6, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 5 } },
455 { {1, 4, 1, 1, 6, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 1 } },
456 { {1, 4, 1, 1, 6, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 3 } },
458 { {1, 4, 1, 1, 7, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "eth4", .len
= 4 }} },
459 { {1, 4, 1, 1, 7, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
460 { .octet
= "Giga1/7", .len
= 7 }} },
461 { {1, 4, 1, 1, 7, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
462 /* lldpRemPortDesc */
463 { {1, 4, 1, 1, 8, 0, 3, 1 }, 8, ASN_OCTET_STR
,
464 { .string
= { .octet
= "Intel 1000 GE", .len
= 13 }} },
465 { {1, 4, 1, 1, 8, 8000, 3, 4}, 8, ASN_OCTET_STR
,
466 { .string
= { .octet
= "Gigabit Ethernet 1/7", .len
= 20 }} },
467 { {1, 4, 1, 1, 8, 10000, 4, 1}, 8, ASN_OCTET_STR
,
468 { .string
= { .octet
= "eth2", .len
= 4 }} },
470 { {1, 4, 1, 1, 9, 0, 3, 1 }, 8, ASN_OCTET_STR
,
471 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
472 { {1, 4, 1, 1, 9, 8000, 3, 4}, 8, ASN_OCTET_STR
,
473 { .string
= { .octet
= "chassis2.example.com", .len
= 20 }} },
474 { {1, 4, 1, 1, 9, 10000, 4, 1}, 8, ASN_OCTET_STR
,
475 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
477 { {1, 4, 1, 1, 10, 0, 3, 1 }, 8, ASN_OCTET_STR
,
478 { .string
= { .octet
= "First chassis", .len
= 13 }} },
479 { {1, 4, 1, 1, 10, 8000, 3, 4}, 8, ASN_OCTET_STR
,
480 { .string
= { .octet
= "Second chassis", .len
= 14 }} },
481 { {1, 4, 1, 1, 10, 10000, 4, 1}, 8, ASN_OCTET_STR
,
482 { .string
= { .octet
= "First chassis", .len
= 13 }} },
483 /* lldpRemSysCapSupported */
484 { {1, 4, 1, 1, 11, 0, 3, 1 }, 8, ASN_OCTET_STR
,
485 { .string
= { .octet
= "\x38", .len
= 1 }} },
486 { {1, 4, 1, 1, 11, 8000, 3, 4}, 8, ASN_OCTET_STR
,
487 { .string
= { .octet
= "\x8", .len
= 1 }} },
488 { {1, 4, 1, 1, 11, 10000, 4, 1}, 8, ASN_OCTET_STR
,
489 { .string
= { .octet
= "\x38", .len
= 1 }} },
490 /* lldpRemSysCapEnabled */
491 { {1, 4, 1, 1, 12, 0, 3, 1 }, 8, ASN_OCTET_STR
,
492 { .string
= { .octet
= "\x8", .len
= 1 }} },
493 { {1, 4, 1, 1, 12, 8000, 3, 4}, 8, ASN_OCTET_STR
,
494 { .string
= { .octet
= "\x8", .len
= 1 }} },
495 { {1, 4, 1, 1, 12, 10000, 4, 1}, 8, ASN_OCTET_STR
,
496 { .string
= { .octet
= "\x8", .len
= 1 }} },
498 /* lldpRemManAddrIfSubtype */
499 { {1, 4, 2, 1, 3, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
500 { {1, 4, 2, 1, 3, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 2 } },
501 { {1, 4, 2, 1, 3, 8000, 3, 4, 2, 16,
502 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
503 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 2 } },
504 { {1, 4, 2, 1, 3, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
505 /* lldpRemManAddrIfId */
506 { {1, 4, 2, 1, 4, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
507 { {1, 4, 2, 1, 4, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 5 } },
508 { {1, 4, 2, 1, 4, 8000, 3, 4, 2, 16,
509 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
510 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 5 } },
511 { {1, 4, 2, 1, 4, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
512 /* lldpRemManAddrOID */
513 { {1, 4, 2, 1, 5, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
514 { .string
= { .octet
= (char *)zeroDotZero
,
515 .len
= sizeof(zeroDotZero
) }} },
516 { {1, 4, 2, 1, 5, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_OBJECT_ID
,
517 { .string
= { .octet
= (char *)zeroDotZero
,
518 .len
= sizeof(zeroDotZero
) }} },
519 { {1, 4, 2, 1, 5, 8000, 3, 4, 2, 16,
520 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
521 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_OBJECT_ID
,
522 { .string
= { .octet
= (char *)zeroDotZero
,
523 .len
= sizeof(zeroDotZero
) }} },
524 { {1, 4, 2, 1, 5, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
525 { .string
= { .octet
= (char *)zeroDotZero
,
526 .len
= sizeof(zeroDotZero
) }} },
529 /* lldpXdot3LocPortAutoNegSupported */
530 { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
531 { {1, 5, 4623, 1, 2, 1, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
532 /* lldpXdot3LocPortAutoNegEnabled */
533 { {1, 5, 4623, 1, 2, 1, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
534 { {1, 5, 4623, 1, 2, 1, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
535 /* lldpXdot3LocPortAutoNegAdvertisedCap */
536 { {1, 5, 4623, 1, 2, 1, 1, 3, 3 }, 9, ASN_OCTET_STR
,
537 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
538 { {1, 5, 4623, 1, 2, 1, 1, 3, 4 }, 9, ASN_OCTET_STR
,
539 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
540 /* lldpXdot3LocPortOperMauType */
541 { {1, 5, 4623, 1, 2, 1, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 16 }},
542 { {1, 5, 4623, 1, 2, 1, 1, 4, 4 }, 9, ASN_INTEGER
, { .integer
= 30 }},
544 /* lldpXdot3LocPowerPortClass */
545 { {1, 5, 4623, 1, 2, 2, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
546 /* lldpXdot3LocPowerMDISupported */
547 { {1, 5, 4623, 1, 2, 2, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
548 /* lldpXdot3LocPowerMDIEnabled */
549 { {1, 5, 4623, 1, 2, 2, 1, 3, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
550 /* lldpXdot3LocPowerPairControlable */
551 { {1, 5, 4623, 1, 2, 2, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
552 /* lldpXdot3LocPowerPairs */
553 { {1, 5, 4623, 1, 2, 2, 1, 5, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
554 /* lldpXdot3LocPowerClass */
555 { {1, 5, 4623, 1, 2, 2, 1, 6, 3 }, 9, ASN_INTEGER
, { .integer
= 3 }},
556 /* As per 802.3at-2009, not sure of the OID... */
557 /* lldpXdot3LocPowerType */
558 { {1, 5, 4623, 1, 2, 2, 1, 7, 3 }, 9, ASN_OCTET_STR
,
559 { .string
= { .octet
= "\xC0", .len
= 1 } }},
560 /* lldpXdot3LocPowerSource */
561 { {1, 5, 4623, 1, 2, 2, 1, 8, 3 }, 9, ASN_OCTET_STR
,
562 { .string
= { .octet
= "\xC0", .len
= 1 } }},
563 /* lldpXdot3LocPowerPriority */
564 { {1, 5, 4623, 1, 2, 2, 1, 9, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
565 /* lldpXdot3LocPDRequestedPowerValue */
566 { {1, 5, 4623, 1, 2, 2, 1, 10, 3 }, 9, ASN_INTEGER
, { .integer
= 2000 }},
567 /* lldpXdot3LocPSEAllocatedPowerValue */
568 { {1, 5, 4623, 1, 2, 2, 1, 11, 3 }, 9, ASN_INTEGER
, { .integer
= 2500 }},
570 /* lldpXdot3LocLinkAggStatus */
571 { {1, 5, 4623, 1, 2, 3, 1, 1, 3 }, 9, ASN_OCTET_STR
,
572 { .string
= { .octet
= "\x00", .len
= 1 }} },
573 { {1, 5, 4623, 1, 2, 3, 1, 1, 4 }, 9, ASN_OCTET_STR
,
574 { .string
= { .octet
= "\xC0", .len
= 1 }} },
575 /* lldpXdot3LocLinkAggPortId */
576 { {1, 5, 4623, 1, 2, 3, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 0 }},
577 { {1, 5, 4623, 1, 2, 3, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 3 }},
579 /* lldpXdot3LocMaxFrameSize */
580 { {1, 5, 4623, 1, 2, 4, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1600 }},
581 { {1, 5, 4623, 1, 2, 4, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 9000 }},
583 /* lldpXdot3RemPortAutoNegSupported */
584 { {1, 5, 4623, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
585 { {1, 5, 4623, 1, 3, 1, 1, 1, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
586 { {1, 5, 4623, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
587 /* lldpXdot3RemPortAutoNegEnabled */
588 { {1, 5, 4623, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
589 { {1, 5, 4623, 1, 3, 1, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
590 { {1, 5, 4623, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
591 /* lldpXdot3RemPortAutoNegAdvertisedCap */
592 { {1, 5, 4623, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
593 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
594 { {1, 5, 4623, 1, 3, 1, 1, 3, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
595 { .string
= { .octet
= "\x00\x00", .len
= 2 }} },
596 { {1, 5, 4623, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
597 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
598 /* lldpXdot3RemPortOperMauType */
599 { {1, 5, 4623, 1, 3, 1, 1, 4, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 30 }},
600 { {1, 5, 4623, 1, 3, 1, 1, 4, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
601 { {1, 5, 4623, 1, 3, 1, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 16 }},
603 /* lldpXdot3RemPowerPortClass */
604 { {1, 5, 4623, 1, 3, 2, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
605 /* lldpXdot3RemPowerMDISupported */
606 { {1, 5, 4623, 1, 3, 2, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
607 /* lldpXdot3RemPowerMDIEnabled */
608 { {1, 5, 4623, 1, 3, 2, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
609 /* lldpXdot3RemPowerPairControlable */
610 { {1, 5, 4623, 1, 3, 2, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
611 /* lldpXdot3RemPowerPairs */
612 { {1, 5, 4623, 1, 3, 2, 1, 5, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
613 /* lldpXdot3RemPowerClass */
614 { {1, 5, 4623, 1, 3, 2, 1, 6, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
615 /* As per 802.3at-2009, not sure of the OID... */
616 /* lldpXdot3RemPowerType */
617 { {1, 5, 4623, 1, 3, 2, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
618 { .string
= { .octet
= "\xC0", .len
= 1 } }},
619 /* lldpXdot3RemPowerSource */
620 { {1, 5, 4623, 1, 3, 2, 1, 8, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
621 { .string
= { .octet
= "\xC0", .len
= 1 } }},
622 /* lldpXdot3RemPowerPriority */
623 { {1, 5, 4623, 1, 3, 2, 1, 9, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
624 /* lldpXdot3RemPDRequestedPowerValue */
625 { {1, 5, 4623, 1, 3, 2, 1, 10, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2000 }},
626 /* lldpXdot3RemPSEAllocatedPowerValue */
627 { {1, 5, 4623, 1, 3, 2, 1, 11, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2500 }},
629 /* lldpXdot3RemLinkAggStatus */
630 { {1, 5, 4623, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
631 { .string
= { .octet
= "\xC0", .len
= 1 }} },
632 { {1, 5, 4623, 1, 3, 3, 1, 1, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
633 { .string
= { .octet
= "\x00", .len
= 1 }} },
634 { {1, 5, 4623, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
635 { .string
= { .octet
= "\x00", .len
= 1 }} },
636 /* lldpXdot3RemLinkAggPortId */
637 { {1, 5, 4623, 1, 3, 3, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
638 { {1, 5, 4623, 1, 3, 3, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
639 { {1, 5, 4623, 1, 3, 3, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 0 }},
641 /* lldpXdot3RemMaxFrameSize */
642 { {1, 5, 4623, 1, 3, 4, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 9000 }},
643 { {1, 5, 4623, 1, 3, 4, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1600 }},
645 #ifdef ENABLE_LLDPMED
646 /* lldpXMedLocDeviceClass */
647 { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER
, { .integer
= 2 }},
649 /* lldpXMedLocMediaPolicyVlanID */
650 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
651 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 472 }},
652 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
653 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1007 }},
654 /* lldpXMedLocMediaPolicyPriority */
655 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
656 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
657 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
658 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1 }},
659 /* lldpXMedLocMediaPolicyDscp */
660 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
661 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 60 }},
662 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
663 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 49 }},
664 /* lldpXMedLocMediaPolicyUnknown */
665 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
666 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 2 }},
667 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
668 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
669 /* lldpXMedLocMediaPolicyTagged */
670 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
671 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
672 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
673 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
675 /* lldpXMedLocHardwareRev */
676 { {1, 5, 4795, 1, 2, 2, 0 }, 7, ASN_OCTET_STR
,
677 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
678 /* lldpXMedLocSoftwareRev */
679 { {1, 5, 4795, 1, 2, 4, 0 }, 7, ASN_OCTET_STR
,
680 { .string
= { .octet
= "Software 1", .len
= 10 }} },
681 /* lldpXMedLocSerialNum */
682 { {1, 5, 4795, 1, 2, 5, 0 }, 7, ASN_OCTET_STR
,
683 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
684 /* lldpXMedLocMfgName */
685 { {1, 5, 4795, 1, 2, 6, 0 }, 7, ASN_OCTET_STR
,
686 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
687 /* lldpXMedLocModelName */
688 { {1, 5, 4795, 1, 2, 7, 0 }, 7, ASN_OCTET_STR
,
689 { .string
= { .octet
= "Model 1", .len
= 7 }} },
690 /* lldpXMedLocAssetID */
691 { {1, 5, 4795, 1, 2, 8, 0 }, 7, ASN_OCTET_STR
,
692 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
694 /* lldpXMedLocLocationInfo */
695 { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR
,
696 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
697 { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR
,
698 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
700 /* lldpXMedLocXPoEDeviceType */
701 { {1, 5, 4795, 1, 2, 10, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
702 /* lldpXMedLocXPoEPDPowerReq */
703 { {1, 5, 4795, 1, 2, 13, 0 }, 7, ASN_GAUGE
, { .integer
= 100 }},
704 /* lldpXMedLocXPoEPDPowerSource */
705 { {1, 5, 4795, 1, 2, 14, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
706 /* lldpXMedLocXPoEPDPowerPriority */
707 { {1, 5, 4795, 1, 2, 15, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
709 /* lldpXMedRemCapSupported */
710 { {1, 5, 4795, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
711 { .string
= { .octet
= "\xFC", .len
= 1 }} },
712 { {1, 5, 4795, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
713 { .string
= { .octet
= "\xFC", .len
= 1 }}},
714 /* lldpXMedRemCapCurrent */
715 { {1, 5, 4795, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_OCTET_STR
,
716 { .string
= { .octet
= "\xFC", .len
= 1 }} },
717 { {1, 5, 4795, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
718 { .string
= { .octet
= "\xEC", .len
= 1 }}},
719 /* lldpXMedRemDeviceClass */
720 { {1, 5, 4795, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
721 { {1, 5, 4795, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
723 /* lldpXMedRemMediaPolicyVlanID */
724 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
725 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1007 }},
726 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
727 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 472 }},
728 /* lldpXMedRemMediaPolicyPriority */
729 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
730 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1 }},
731 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
732 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
733 /* lldpXMedLocMediaPolicyDscp */
734 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
735 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 49 }},
736 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
737 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 60 }},
738 /* lldpXMedLocMediaPolicyUnknown */
739 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
740 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
741 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
742 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 2 }},
743 /* lldpXMedLocMediaPolicyTagged */
744 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
745 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
746 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
747 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
749 /* lldpXMedRemHardwareRev */
750 { {1, 5, 4795, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
751 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
752 { {1, 5, 4795, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
753 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
754 /* lldpXMedRemSoftwareRev */
755 { {1, 5, 4795, 1, 3, 3, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
756 { .string
= { .octet
= "Software 1", .len
= 10 }} },
757 { {1, 5, 4795, 1, 3, 3, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
758 { .string
= { .octet
= "Software 1", .len
= 10 }} },
759 /* lldpXMedRemSerialNum */
760 { {1, 5, 4795, 1, 3, 3, 1, 4, 0, 3, 1 }, 11, ASN_OCTET_STR
,
761 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
762 { {1, 5, 4795, 1, 3, 3, 1, 4, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
763 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
764 /* lldpXMedRemMfgName */
765 { {1, 5, 4795, 1, 3, 3, 1, 5, 0, 3, 1 }, 11, ASN_OCTET_STR
,
766 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
767 { {1, 5, 4795, 1, 3, 3, 1, 5, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
768 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
769 /* lldpXMedRemModelName */
770 { {1, 5, 4795, 1, 3, 3, 1, 6, 0, 3, 1 }, 11, ASN_OCTET_STR
,
771 { .string
= { .octet
= "Model 1", .len
= 7 }} },
772 { {1, 5, 4795, 1, 3, 3, 1, 6, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
773 { .string
= { .octet
= "Model 1", .len
= 7 }} },
774 /* lldpXMedRemAssetID */
775 { {1, 5, 4795, 1, 3, 3, 1, 7, 0, 3, 1 }, 11, ASN_OCTET_STR
,
776 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
777 { {1, 5, 4795, 1, 3, 3, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
778 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
780 /* lldpXMedLocLocationInfo */
781 { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR
,
782 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
783 { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR
,
784 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
786 /* lldpXMedRemXPoEDeviceType */
787 { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 4 }},
788 { {1, 5, 4795, 1, 3, 5, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
790 /* lldpXMedRemXPoEPDPowerReq */
791 { {1, 5, 4795, 1, 3, 7, 1, 1, 10000, 4, 1}, 11, ASN_GAUGE
, { .integer
= 100 }},
792 /* lldpXMedRemXPoEPDPowerSource */
793 { {1, 5, 4795, 1, 3, 7, 1, 2, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
794 /* lldpXMedRemXPoEPDPowerPriority */
795 { {1, 5, 4795, 1, 3, 7, 1, 3, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
799 /* lldpXdot1LocPortVlanId */
800 { { 1, 5, 32962, 1, 2, 1, 1, 1, 3}, 9, ASN_INTEGER
, { .integer
= 47 }},
801 { { 1, 5, 32962, 1, 2, 1, 1, 1, 4}, 9, ASN_INTEGER
, { .integer
= 0 }},
802 /* lldpXdot1LocProtoVlanSupported */
803 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
804 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
805 /* lldpXdot1LocProtoVlanEnabled */
806 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
807 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
808 /* lldpXdot1LocVlanName */
809 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 47}, 10, ASN_OCTET_STR
,
810 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
811 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 49}, 10, ASN_OCTET_STR
,
812 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
813 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR
,
814 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
815 /* lldpXdot1LocProtocolId */
816 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30321}, 10, ASN_OCTET_STR
,
817 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
818 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30515}, 10, ASN_OCTET_STR
,
819 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }},
821 /* lldpXdot1RemPortVlanId */
822 { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 0 }},
823 { { 1, 5, 32962, 1, 3, 1, 1, 1, 8000, 3, 4}, 11, ASN_INTEGER
, { .integer
= 0 }},
824 { { 1, 5, 32962, 1, 3, 1, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 47 }},
825 /* lldpXdot1RemProtoVlanSupported */
826 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
827 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
828 /* lldpXdot1RemProtoVlanEnabled */
829 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
830 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
831 /* lldpXdot1RemVlanName */
832 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 47}, 12, ASN_OCTET_STR
,
833 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
834 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 49}, 12, ASN_OCTET_STR
,
835 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
836 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR
,
837 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
838 /* lldpXdot1RemProtocolId */
839 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30321}, 12, ASN_OCTET_STR
,
840 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
841 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30515}, 12, ASN_OCTET_STR
,
842 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }}
847 tohex(char *str
, size_t len
)
849 static char *hex
[] = { NULL
, NULL
};
850 static int which
= 0;
851 free(hex
[which
]); hex
[which
] = NULL
;
852 hex
[which
] = malloc(len
* 3 + 1);
853 fail_unless(hex
[which
] != NULL
, "Not enough memory?");
854 for (size_t i
= 0; i
< len
; i
++)
855 snprintf(hex
[which
] + 3*i
, 4, "%02X ", (unsigned char)str
[i
]);
857 return hex
[1 - which
];
861 snmp_is_prefix_of(struct variable8
*vp
, struct tree_node
*n
, char *repr
)
863 if (n
->namelen
< vp
->namelen
) return 0;
866 vp
->namelen
* sizeof(oid
)))
868 fail_unless(n
->type
== vp
->type
, "Inappropriate type for OID %s", repr
);
873 snmp_merge(struct variable8
*v1
, struct tree_node
*n
, struct variable
*vp
,
874 oid
*target
, size_t *targetlen
)
876 vp
->magic
= v1
->magic
;
879 vp
->findVar
= v1
->findVar
;
880 vp
->namelen
= v1
->namelen
+
881 sizeof(lldp_oid
)/sizeof(oid
);
882 memcpy(vp
->name
, lldp_oid
, sizeof(lldp_oid
));
883 memcpy(vp
->name
+ sizeof(lldp_oid
)/sizeof(oid
),
885 v1
->namelen
*sizeof(oid
));
886 *targetlen
= n
->namelen
+
887 sizeof(lldp_oid
)/sizeof(oid
);
888 memcpy(target
, lldp_oid
, sizeof(lldp_oid
));
889 memcpy(target
+ sizeof(lldp_oid
)/sizeof(oid
),
891 n
->namelen
* sizeof(oid
));
895 snmp_compare(struct tree_node
*n
,
896 u_char
*result
, size_t varlen
,
897 oid
*target
, size_t targetlen
, char *repr
)
899 unsigned long int value
;
900 fail_unless((targetlen
== sizeof(lldp_oid
)/sizeof(oid
) + n
->namelen
) &&
901 !memcmp(target
, lldp_oid
, sizeof(lldp_oid
)) &&
902 !memcmp(target
+ sizeof(lldp_oid
)/sizeof(oid
),
904 n
->namelen
* sizeof(oid
)),
905 "Bad OID returned when querying %s: got %s", repr
,
906 snmp_oidrepr(target
, targetlen
));
912 fail_unless(varlen
== sizeof(unsigned long int),
913 "Inappropriate length for integer type for OID %s",
915 memcpy(&value
, result
, sizeof(value
));
916 fail_unless(n
->value
.integer
== value
,
917 "For OID %s, expected value %u but got %u instead",
923 fail_unless(((n
->value
.string
.len
== varlen
) &&
924 !memcmp(n
->value
.string
.octet
,
926 "OID %s: wanted %s, got %s",
928 tohex(n
->value
.string
.octet
, n
->value
.string
.len
),
929 tohex((char *)result
, varlen
));
933 START_TEST (test_variable_order
)
936 for (i
= 0; i
< agent_lldp_vars_size() - 1; i
++) {
937 fail_unless(snmp_oid_compare(agent_lldp_vars
[i
].name
,
938 agent_lldp_vars
[i
].namelen
,
939 agent_lldp_vars
[i
+1].name
,
940 agent_lldp_vars
[i
+1].namelen
) < 0,
941 "Registered OID are out of orders (see %s and next one)",
942 snmp_oidrepr(agent_lldp_vars
[i
].name
,
943 agent_lldp_vars
[i
].namelen
));
948 START_TEST (test_get
)
952 j
< sizeof(snmp_tree
)/sizeof(struct tree_node
);
957 oid target
[MAX_OID_LEN
];
961 WriteMethod
*wmethod
;
962 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
963 snmp_tree
[j
].namelen
);
965 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
966 /* Search for the appropriate prefix. */
967 if (!snmp_is_prefix_of(&agent_lldp_vars
[i
], &snmp_tree
[j
],
970 /* We have our prefix. Fill out the vp struct
971 correctly. We need to complete OID with
973 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
975 /* Invoke the function */
976 result
= vp
.findVar(&vp
, target
, &targetlen
, 1, &varlen
, &wmethod
);
978 /* Check the result */
979 fail_unless(result
!= NULL
,
980 "No result when querying %s", repr
);
981 snmp_compare(&snmp_tree
[j
], result
, varlen
, target
, targetlen
, repr
);
987 fail("OID %s not found", repr
);
992 START_TEST (test_getnext
)
995 size_t end
= sizeof(snmp_tree
)/sizeof(struct tree_node
);
1001 oid target
[MAX_OID_LEN
];
1004 u_char
*result
= NULL
;
1005 WriteMethod
*wmethod
;
1006 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
1007 snmp_tree
[j
].namelen
);
1008 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
1009 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
1010 result
= vp
.findVar(&vp
, target
, &targetlen
, 0, &varlen
, &wmethod
);
1011 if (result
) /* Check next! */
1015 fail_unless(j
== end
- 1,
1016 "No next result found for %s", repr
);
1019 fail_unless(j
< end
- 1,
1020 "More results after %s", repr
);
1022 /* For unknown reasons, snmp_compare can be executed
1023 even when the above test fails... */
1025 snmp_compare(&snmp_tree
[j
+1], result
, varlen
, target
, targetlen
, repr
);
1034 Suite
*s
= suite_create("SNMP");
1036 TCase
*tc_snmp
= tcase_create("SNMP");
1037 tcase_add_checked_fixture(tc_snmp
, snmp_config
, NULL
);
1038 tcase_add_test(tc_snmp
, test_variable_order
);
1039 tcase_add_test(tc_snmp
, test_get
);
1040 tcase_add_test(tc_snmp
, test_getnext
);
1041 suite_add_tcase(s
, tc_snmp
);
1050 Suite
*s
= snmp_suite();
1051 SRunner
*sr
= srunner_create(s
);
1052 srunner_run_all(sr
, CK_ENV
);
1053 number_failed
= srunner_ntests_failed(sr
);
1055 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;