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
= {
39 struct timeval test_starttime
= { .tv_sec
= 100, .tv_usec
= 0 };
42 struct lldpd_mgmt mgmt1
= {
43 .m_family
= LLDPD_AF_IPV4
,
44 .m_addr
= { .octets
= { 0xc0, 0, 0x2, 0xf } }, /* 192.0.2.15 */
45 .m_addrsize
= sizeof(struct in_addr
),
48 struct lldpd_chassis chassis1
= {
50 .c_protocol
= LLDPD_MODE_LLDP
,
51 .c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
,
54 .c_name
= "chassis1.example.com",
55 .c_descr
= "First chassis",
56 .c_cap_available
= LLDP_CAP_BRIDGE
| LLDP_CAP_WLAN
| LLDP_CAP_ROUTER
,
57 .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 #ifdef ENABLE_LLDPMED
101 .c_med_hw
= "Hardware 2",
102 /* We skip c_med_fw */
103 .c_med_sw
= "Software 2",
104 .c_med_sn
= "00-00-0000-AAAC",
105 .c_med_manuf
= "Manufacturer 2",
106 .c_med_model
= "Model 2",
107 .c_med_asset
= "Asset 2",
111 /* First port of first chassis */
112 struct lldpd_hardware hardware1
= {
116 .h_rx_discarded_cnt
= 5,
117 .h_rx_unrecognized_cnt
= 4,
123 .p_chassis
= &chassis1
,
125 .p_protocol
= LLDPD_MODE_LLDP
,
126 .p_id_subtype
= LLDP_PORTID_SUBTYPE_LLADDR
,
134 .autoneg_support
= 1,
135 .autoneg_enabled
= 1,
136 .autoneg_advertised
= LLDP_DOT3_LINK_AUTONEG_100BASE_TX
| LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD
,
137 .mau_type
= LLDP_DOT3_MAU_100BASETXFD
,
140 .devicetype
= LLDP_DOT3_POWER_PD
,
146 .powertype
= LLDP_DOT3_POWER_8023AT_TYPE2
,
147 .source
= LLDP_DOT3_POWER_SOURCE_BOTH
,
148 .priority
= LLDP_DOT3_POWER_PRIO_LOW
,
153 #ifdef ENABLE_LLDPMED
154 .p_med_cap_enabled
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| LLDP_MED_CAP_MDI_PD
|
155 LLDP_MED_CAP_POLICY
| LLDP_MED_CAP_LOCATION
,
157 { .type
= 0 }, { .type
= 0 }, {
158 .type
= LLDP_MED_APPTYPE_GUESTVOICE
,
164 }, { .type
= 0 }, { .type
= 0 }, { .type
= 0 }, {
165 .type
= LLDP_MED_APPTYPE_VIDEOSTREAM
,
175 .format
= LLDP_MED_LOCFORMAT_CIVIC
,
176 /* 2:FR:6:Commercial Rd:19:4 */
177 .data
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4",
182 .devicetype
= LLDP_MED_POW_TYPE_PD
,
183 .source
= LLDP_MED_POW_SOURCE_LOCAL
,
184 .priority
= LLDP_MED_POW_PRIO_HIGH
,
190 /* Remaining is done is snmp_config */
194 /* Second port of first chassis */
195 struct lldpd_hardware hardware2
= {
199 .h_rx_discarded_cnt
= 55,
200 .h_rx_unrecognized_cnt
= 14,
201 .h_insert_cnt
= 1000,
206 .p_chassis
= &chassis1
,
208 .p_protocol
= LLDPD_MODE_LLDP
,
209 .p_id_subtype
= LLDP_PORTID_SUBTYPE_IFNAME
,
212 .p_descr
= "Intel 1000 GE",
217 .autoneg_support
= 1,
218 .autoneg_enabled
= 1,
219 .autoneg_advertised
= LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD
| LLDP_DOT3_LINK_AUTONEG_1000BASE_TFD
,
220 .mau_type
= LLDP_DOT3_MAU_1000BASETFD
,
223 #ifdef ENABLE_LLDPMED
224 .p_med_cap_enabled
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| LLDP_MED_CAP_MDI_PD
|
225 LLDP_MED_CAP_MDI_PSE
| LLDP_MED_CAP_POLICY
| LLDP_MED_CAP_LOCATION
,
227 { .type
= 0 }, { .type
= 0 }, {
228 .type
= LLDP_MED_APPTYPE_GUESTVOICE
,
234 }, { .type
= 0 }, { .type
= 0 }, {
235 .type
= LLDP_MED_APPTYPE_VIDEOCONFERENCE
,
241 }, { .type
= 0 }, { .type
= 0 }
245 .format
= LLDP_MED_LOCFORMAT_COORD
,
246 .data
= "Not interpreted",
248 }, { .format
= 0 }, { .format
= 0 },
255 struct lldpd_vlan vlan47
= {
256 .v_name
= "VLAN #47",
259 struct lldpd_vlan vlan49
= {
260 .v_name
= "VLAN #49",
263 struct lldpd_vlan vlan1449
= {
264 .v_name
= "VLAN #1449",
267 struct lldpd_ppvid ppvid47
= {
268 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
271 struct lldpd_ppvid ppvid118
= {
272 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
275 struct lldpd_pi pi88cc
= {
279 struct lldpd_pi pi888e01
= {
280 .p_pi
= "\x88\x8e\x01",
285 /* First port of second chassis */
286 struct lldpd_port port2
= {
287 .p_chassis
= &chassis2
,
289 .p_protocol
= LLDPD_MODE_LLDP
,
290 .p_id_subtype
= LLDP_PORTID_SUBTYPE_IFALIAS
,
293 .p_descr
= "Gigabit Ethernet 1/7",
299 starttime
= test_starttime
;
300 agent_scfg
= &test_cfg
;
301 TAILQ_INIT(&test_cfg
.g_chassis
);
302 TAILQ_INIT(&chassis1
.c_mgmt
);
303 TAILQ_INSERT_TAIL(&chassis1
.c_mgmt
, &mgmt1
, m_entries
);
304 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis1
, c_entries
);
305 TAILQ_INIT(&chassis2
.c_mgmt
);
306 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt2
, m_entries
);
307 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt3
, m_entries
);
308 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis2
, c_entries
);
309 TAILQ_INIT(&test_cfg
.g_hardware
);
310 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware1
, h_entries
);
311 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware2
, h_entries
);
313 TAILQ_INIT(&hardware1
.h_lport
.p_vlans
);
314 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan47
, v_entries
);
315 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan49
, v_entries
);
316 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan1449
, v_entries
);
317 TAILQ_INIT(&hardware1
.h_lport
.p_ppvids
);
318 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid47
, p_entries
);
319 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid118
, p_entries
);
320 TAILQ_INIT(&hardware1
.h_lport
.p_pids
);
321 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi88cc
, p_entries
);
322 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi888e01
, p_entries
);
323 TAILQ_INIT(&hardware2
.h_lport
.p_vlans
);
324 TAILQ_INIT(&hardware2
.h_lport
.p_ppvids
);
325 TAILQ_INIT(&hardware2
.h_lport
.p_pids
);
326 TAILQ_INIT(&port2
.p_vlans
);
327 TAILQ_INIT(&port2
.p_ppvids
);
328 TAILQ_INIT(&port2
.p_pids
);
330 TAILQ_INIT(&hardware1
.h_rports
);
331 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &port2
, p_entries
);
332 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &hardware2
.h_lport
, p_entries
);
333 TAILQ_INIT(&hardware2
.h_rports
);
334 TAILQ_INSERT_TAIL(&hardware2
.h_rports
, &hardware1
.h_lport
, p_entries
);
337 /* Convert OID to a string. Static buffer. */
339 snmp_oidrepr(oid
*name
, size_t namelen
)
341 static char *buffer
[4] = {NULL
, NULL
, NULL
, NULL
};
342 static int current
= 0;
345 current
= (current
+ 1)%4;
346 free(buffer
[current
]); buffer
[current
] = NULL
;
348 for (i
= 0; i
< namelen
; i
++) {
349 /* Not very efficient... */
350 char *newbuffer
= NULL
;
351 if (asprintf(&newbuffer
, "%s.%lu", buffer
[current
]?buffer
[current
]:"",
352 (unsigned long)name
[i
]) == -1) {
353 free(buffer
[current
]);
354 buffer
[current
] = NULL
;
357 free(buffer
[current
]);
358 buffer
[current
] = newbuffer
;
360 return buffer
[current
++];
364 oid name
[MAX_OID_LEN
];
366 int type
; /* ASN_* */
368 unsigned long int integer
;
376 static oid zeroDotZero
[2] = {0, 0};
377 struct tree_node snmp_tree
[] = {
378 { {1, 1, 1, 0}, 4, ASN_INTEGER
, { .integer
= 30 } }, /* lldpMessageTxInterval */
379 { {1, 1, 2, 0}, 4, ASN_INTEGER
, { .integer
= 2 } }, /* lldpMessageTxHoldMultiplier */
380 { {1, 1, 3, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpReinitDelay */
381 { {1, 1, 4, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpTxDelay */
382 { {1, 1, 5, 0}, 4, ASN_INTEGER
, { .integer
= 5 } }, /* lldpNotificationInterval */
383 { {1, 2, 1, 0}, 4, ASN_TIMETICKS
, { .integer
= 10000 } },/* lldpStatsRemTablesLastChangeTime */
384 { {1, 2, 2, 0}, 4, ASN_GAUGE
, { .integer
= 1100 } }, /* lldpStatsRemTablesInserts */
385 { {1, 2, 3, 0}, 4, ASN_GAUGE
, { .integer
= 56 } }, /* lldpStatsRemTablesDeletes */
386 { {1, 2, 4, 0}, 4, ASN_GAUGE
, { .integer
= 2 } }, /* lldpStatsRemTablesDrops */
387 { {1, 2, 5, 0}, 4, ASN_GAUGE
, { .integer
= 230 } }, /* lldpStatsRemTablesAgeouts */
389 { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 1352 } }, /* lldpStatsTxPortFramesTotal.3 */
390 { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 11352 } }, /* lldpStatsTxPortFramesTotal.4 */
391 { {1, 2, 7, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesDiscardedTotal.3 */
392 { {1, 2, 7, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesDiscardedTotal.4 */
393 { {1, 2, 7, 1, 3, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesError.3 */
394 { {1, 2, 7, 1, 3, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesError.4 */
395 { {1, 2, 7, 1, 4, 3}, 6, ASN_COUNTER
, { .integer
= 1458 } }, /* lldpStatsRxPortFramesTotal.3 */
396 { {1, 2, 7, 1, 4, 4}, 6, ASN_COUNTER
, { .integer
= 11458 } }, /* lldpStatsRxPortFramesTotal.4 */
397 { {1, 2, 7, 1, 5, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsDiscardedTotal.3 */
398 { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */
399 { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */
400 { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */
401 { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE
, { .integer
= 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
402 { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE
, { .integer
= 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
404 { {1, 3, 1, 0}, 4, ASN_INTEGER
, { .integer
= 4 } }, /* lldpLocChassisIdSubtype */
405 /* lldpLocChassisId */
406 { {1, 3, 2, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
409 { {1, 3, 3, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "chassis1.example.com",
412 { {1, 3, 4, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "First chassis",
414 /* lldpLocSysCapSupported */
415 { {1, 3, 5, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x38",
417 /* lldpLocSysCapEnabled */
418 { {1, 3, 6, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x8",
421 { {1, 3, 7, 1, 2, 3}, 6, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocPortIdSubtype.3 */
422 { {1, 3, 7, 1, 2, 4}, 6, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocPortIdSubtype.5 */
423 /* lldpLocPortId.3 */
424 { {1, 3, 7, 1, 3, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
426 /* lldpLocPortId.4 */
427 { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth4",
429 /* lldpLocPortDesc.3 */
430 { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth2",
432 /* lldpLocPortDesc.4 */
433 { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "Intel 1000 GE",
436 { {1, 3, 8, 1, 3, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocManAddrLen */
437 { {1, 3, 8, 1, 4, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 2 } }, /* lldpLocManAddrIfSubtype */
438 { {1, 3, 8, 1, 5, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocManAddrIfId */
439 /* lldpLocManAddrOID */
440 { {1, 3, 8, 1, 6, 1, 4, 192, 0, 2, 15}, 11, ASN_OBJECT_ID
,
441 { .string
= { .octet
= (char *)zeroDotZero
,
442 .len
= sizeof(zeroDotZero
) }} },
444 /* lldpRemChassisIdSubtype */
445 { {1, 4, 1, 1, 4, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 4 } },
446 { {1, 4, 1, 1, 4, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 7 } },
447 { {1, 4, 1, 1, 4, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 4 } },
448 /* lldpRemChassisId */
449 { {1, 4, 1, 1, 5, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
450 { {1, 4, 1, 1, 5, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
451 { .octet
= "chassis2",
453 { {1, 4, 1, 1, 5, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
454 /* lldpRemPortIdSubtype */
455 { {1, 4, 1, 1, 6, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 5 } },
456 { {1, 4, 1, 1, 6, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 1 } },
457 { {1, 4, 1, 1, 6, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 3 } },
459 { {1, 4, 1, 1, 7, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "eth4", .len
= 4 }} },
460 { {1, 4, 1, 1, 7, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
461 { .octet
= "Giga1/7", .len
= 7 }} },
462 { {1, 4, 1, 1, 7, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
463 /* lldpRemPortDesc */
464 { {1, 4, 1, 1, 8, 0, 3, 1 }, 8, ASN_OCTET_STR
,
465 { .string
= { .octet
= "Intel 1000 GE", .len
= 13 }} },
466 { {1, 4, 1, 1, 8, 8000, 3, 4}, 8, ASN_OCTET_STR
,
467 { .string
= { .octet
= "Gigabit Ethernet 1/7", .len
= 20 }} },
468 { {1, 4, 1, 1, 8, 10000, 4, 1}, 8, ASN_OCTET_STR
,
469 { .string
= { .octet
= "eth2", .len
= 4 }} },
471 { {1, 4, 1, 1, 9, 0, 3, 1 }, 8, ASN_OCTET_STR
,
472 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
473 { {1, 4, 1, 1, 9, 8000, 3, 4}, 8, ASN_OCTET_STR
,
474 { .string
= { .octet
= "chassis2.example.com", .len
= 20 }} },
475 { {1, 4, 1, 1, 9, 10000, 4, 1}, 8, ASN_OCTET_STR
,
476 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
478 { {1, 4, 1, 1, 10, 0, 3, 1 }, 8, ASN_OCTET_STR
,
479 { .string
= { .octet
= "First chassis", .len
= 13 }} },
480 { {1, 4, 1, 1, 10, 8000, 3, 4}, 8, ASN_OCTET_STR
,
481 { .string
= { .octet
= "Second chassis", .len
= 14 }} },
482 { {1, 4, 1, 1, 10, 10000, 4, 1}, 8, ASN_OCTET_STR
,
483 { .string
= { .octet
= "First chassis", .len
= 13 }} },
484 /* lldpRemSysCapSupported */
485 { {1, 4, 1, 1, 11, 0, 3, 1 }, 8, ASN_OCTET_STR
,
486 { .string
= { .octet
= "\x38", .len
= 1 }} },
487 { {1, 4, 1, 1, 11, 8000, 3, 4}, 8, ASN_OCTET_STR
,
488 { .string
= { .octet
= "\x8", .len
= 1 }} },
489 { {1, 4, 1, 1, 11, 10000, 4, 1}, 8, ASN_OCTET_STR
,
490 { .string
= { .octet
= "\x38", .len
= 1 }} },
491 /* lldpRemSysCapEnabled */
492 { {1, 4, 1, 1, 12, 0, 3, 1 }, 8, ASN_OCTET_STR
,
493 { .string
= { .octet
= "\x8", .len
= 1 }} },
494 { {1, 4, 1, 1, 12, 8000, 3, 4}, 8, ASN_OCTET_STR
,
495 { .string
= { .octet
= "\x8", .len
= 1 }} },
496 { {1, 4, 1, 1, 12, 10000, 4, 1}, 8, ASN_OCTET_STR
,
497 { .string
= { .octet
= "\x8", .len
= 1 }} },
499 /* lldpRemManAddrIfSubtype */
500 { {1, 4, 2, 1, 3, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
501 { {1, 4, 2, 1, 3, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 2 } },
502 { {1, 4, 2, 1, 3, 8000, 3, 4, 2, 16,
503 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
504 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 2 } },
505 { {1, 4, 2, 1, 3, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
506 /* lldpRemManAddrIfId */
507 { {1, 4, 2, 1, 4, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
508 { {1, 4, 2, 1, 4, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 5 } },
509 { {1, 4, 2, 1, 4, 8000, 3, 4, 2, 16,
510 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
511 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 5 } },
512 { {1, 4, 2, 1, 4, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
513 /* lldpRemManAddrOID */
514 { {1, 4, 2, 1, 5, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
515 { .string
= { .octet
= (char *)zeroDotZero
,
516 .len
= sizeof(zeroDotZero
) }} },
517 { {1, 4, 2, 1, 5, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_OBJECT_ID
,
518 { .string
= { .octet
= (char *)zeroDotZero
,
519 .len
= sizeof(zeroDotZero
) }} },
520 { {1, 4, 2, 1, 5, 8000, 3, 4, 2, 16,
521 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
522 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_OBJECT_ID
,
523 { .string
= { .octet
= (char *)zeroDotZero
,
524 .len
= sizeof(zeroDotZero
) }} },
525 { {1, 4, 2, 1, 5, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
526 { .string
= { .octet
= (char *)zeroDotZero
,
527 .len
= sizeof(zeroDotZero
) }} },
530 /* lldpXdot3LocPortAutoNegSupported */
531 { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
532 { {1, 5, 4623, 1, 2, 1, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
533 /* lldpXdot3LocPortAutoNegEnabled */
534 { {1, 5, 4623, 1, 2, 1, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
535 { {1, 5, 4623, 1, 2, 1, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
536 /* lldpXdot3LocPortAutoNegAdvertisedCap */
537 { {1, 5, 4623, 1, 2, 1, 1, 3, 3 }, 9, ASN_OCTET_STR
,
538 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
539 { {1, 5, 4623, 1, 2, 1, 1, 3, 4 }, 9, ASN_OCTET_STR
,
540 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
541 /* lldpXdot3LocPortOperMauType */
542 { {1, 5, 4623, 1, 2, 1, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 16 }},
543 { {1, 5, 4623, 1, 2, 1, 1, 4, 4 }, 9, ASN_INTEGER
, { .integer
= 30 }},
545 /* lldpXdot3LocPowerPortClass */
546 { {1, 5, 4623, 1, 2, 2, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
547 /* lldpXdot3LocPowerMDISupported */
548 { {1, 5, 4623, 1, 2, 2, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
549 /* lldpXdot3LocPowerMDIEnabled */
550 { {1, 5, 4623, 1, 2, 2, 1, 3, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
551 /* lldpXdot3LocPowerPairControlable */
552 { {1, 5, 4623, 1, 2, 2, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
553 /* lldpXdot3LocPowerPairs */
554 { {1, 5, 4623, 1, 2, 2, 1, 5, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
555 /* lldpXdot3LocPowerClass */
556 { {1, 5, 4623, 1, 2, 2, 1, 6, 3 }, 9, ASN_INTEGER
, { .integer
= 3 }},
557 /* As per 802.3at-2009, not sure of the OID... */
558 /* lldpXdot3LocPowerType */
559 { {1, 5, 4623, 1, 2, 2, 1, 7, 3 }, 9, ASN_OCTET_STR
,
560 { .string
= { .octet
= "\xC0", .len
= 1 } }},
561 /* lldpXdot3LocPowerSource */
562 { {1, 5, 4623, 1, 2, 2, 1, 8, 3 }, 9, ASN_OCTET_STR
,
563 { .string
= { .octet
= "\xC0", .len
= 1 } }},
564 /* lldpXdot3LocPowerPriority */
565 { {1, 5, 4623, 1, 2, 2, 1, 9, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
566 /* lldpXdot3LocPDRequestedPowerValue */
567 { {1, 5, 4623, 1, 2, 2, 1, 10, 3 }, 9, ASN_INTEGER
, { .integer
= 2000 }},
568 /* lldpXdot3LocPSEAllocatedPowerValue */
569 { {1, 5, 4623, 1, 2, 2, 1, 11, 3 }, 9, ASN_INTEGER
, { .integer
= 2500 }},
571 /* lldpXdot3LocLinkAggStatus */
572 { {1, 5, 4623, 1, 2, 3, 1, 1, 3 }, 9, ASN_OCTET_STR
,
573 { .string
= { .octet
= "\x00", .len
= 1 }} },
574 { {1, 5, 4623, 1, 2, 3, 1, 1, 4 }, 9, ASN_OCTET_STR
,
575 { .string
= { .octet
= "\xC0", .len
= 1 }} },
576 /* lldpXdot3LocLinkAggPortId */
577 { {1, 5, 4623, 1, 2, 3, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 0 }},
578 { {1, 5, 4623, 1, 2, 3, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 3 }},
580 /* lldpXdot3LocMaxFrameSize */
581 { {1, 5, 4623, 1, 2, 4, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1600 }},
582 { {1, 5, 4623, 1, 2, 4, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 9000 }},
584 /* lldpXdot3RemPortAutoNegSupported */
585 { {1, 5, 4623, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
586 { {1, 5, 4623, 1, 3, 1, 1, 1, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
587 { {1, 5, 4623, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
588 /* lldpXdot3RemPortAutoNegEnabled */
589 { {1, 5, 4623, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
590 { {1, 5, 4623, 1, 3, 1, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
591 { {1, 5, 4623, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
592 /* lldpXdot3RemPortAutoNegAdvertisedCap */
593 { {1, 5, 4623, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
594 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
595 { {1, 5, 4623, 1, 3, 1, 1, 3, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
596 { .string
= { .octet
= "\x00\x00", .len
= 2 }} },
597 { {1, 5, 4623, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
598 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
599 /* lldpXdot3RemPortOperMauType */
600 { {1, 5, 4623, 1, 3, 1, 1, 4, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 30 }},
601 { {1, 5, 4623, 1, 3, 1, 1, 4, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
602 { {1, 5, 4623, 1, 3, 1, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 16 }},
604 /* lldpXdot3RemPowerPortClass */
605 { {1, 5, 4623, 1, 3, 2, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
606 /* lldpXdot3RemPowerMDISupported */
607 { {1, 5, 4623, 1, 3, 2, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
608 /* lldpXdot3RemPowerMDIEnabled */
609 { {1, 5, 4623, 1, 3, 2, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
610 /* lldpXdot3RemPowerPairControlable */
611 { {1, 5, 4623, 1, 3, 2, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
612 /* lldpXdot3RemPowerPairs */
613 { {1, 5, 4623, 1, 3, 2, 1, 5, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
614 /* lldpXdot3RemPowerClass */
615 { {1, 5, 4623, 1, 3, 2, 1, 6, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
616 /* As per 802.3at-2009, not sure of the OID... */
617 /* lldpXdot3RemPowerType */
618 { {1, 5, 4623, 1, 3, 2, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
619 { .string
= { .octet
= "\xC0", .len
= 1 } }},
620 /* lldpXdot3RemPowerSource */
621 { {1, 5, 4623, 1, 3, 2, 1, 8, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
622 { .string
= { .octet
= "\xC0", .len
= 1 } }},
623 /* lldpXdot3RemPowerPriority */
624 { {1, 5, 4623, 1, 3, 2, 1, 9, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
625 /* lldpXdot3RemPDRequestedPowerValue */
626 { {1, 5, 4623, 1, 3, 2, 1, 10, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2000 }},
627 /* lldpXdot3RemPSEAllocatedPowerValue */
628 { {1, 5, 4623, 1, 3, 2, 1, 11, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2500 }},
630 /* lldpXdot3RemLinkAggStatus */
631 { {1, 5, 4623, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
632 { .string
= { .octet
= "\xC0", .len
= 1 }} },
633 { {1, 5, 4623, 1, 3, 3, 1, 1, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
634 { .string
= { .octet
= "\x00", .len
= 1 }} },
635 { {1, 5, 4623, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
636 { .string
= { .octet
= "\x00", .len
= 1 }} },
637 /* lldpXdot3RemLinkAggPortId */
638 { {1, 5, 4623, 1, 3, 3, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
639 { {1, 5, 4623, 1, 3, 3, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
640 { {1, 5, 4623, 1, 3, 3, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 0 }},
642 /* lldpXdot3RemMaxFrameSize */
643 { {1, 5, 4623, 1, 3, 4, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 9000 }},
644 { {1, 5, 4623, 1, 3, 4, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1600 }},
646 #ifdef ENABLE_LLDPMED
647 /* lldpXMedLocDeviceClass */
648 { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER
, { .integer
= 2 }},
650 /* lldpXMedLocMediaPolicyVlanID */
651 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
652 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 472 }},
653 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
654 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1007 }},
655 /* lldpXMedLocMediaPolicyPriority */
656 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
657 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
658 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
659 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1 }},
660 /* lldpXMedLocMediaPolicyDscp */
661 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
662 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 60 }},
663 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
664 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 49 }},
665 /* lldpXMedLocMediaPolicyUnknown */
666 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
667 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 2 }},
668 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
669 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
670 /* lldpXMedLocMediaPolicyTagged */
671 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
672 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
673 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
674 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
676 /* lldpXMedLocHardwareRev */
677 { {1, 5, 4795, 1, 2, 2, 0 }, 7, ASN_OCTET_STR
,
678 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
679 /* lldpXMedLocSoftwareRev */
680 { {1, 5, 4795, 1, 2, 4, 0 }, 7, ASN_OCTET_STR
,
681 { .string
= { .octet
= "Software 1", .len
= 10 }} },
682 /* lldpXMedLocSerialNum */
683 { {1, 5, 4795, 1, 2, 5, 0 }, 7, ASN_OCTET_STR
,
684 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
685 /* lldpXMedLocMfgName */
686 { {1, 5, 4795, 1, 2, 6, 0 }, 7, ASN_OCTET_STR
,
687 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
688 /* lldpXMedLocModelName */
689 { {1, 5, 4795, 1, 2, 7, 0 }, 7, ASN_OCTET_STR
,
690 { .string
= { .octet
= "Model 1", .len
= 7 }} },
691 /* lldpXMedLocAssetID */
692 { {1, 5, 4795, 1, 2, 8, 0 }, 7, ASN_OCTET_STR
,
693 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
695 /* lldpXMedLocLocationInfo */
696 { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR
,
697 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
698 { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR
,
699 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
701 /* lldpXMedLocXPoEDeviceType */
702 { {1, 5, 4795, 1, 2, 10, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
703 /* lldpXMedLocXPoEPDPowerReq */
704 { {1, 5, 4795, 1, 2, 13, 0 }, 7, ASN_GAUGE
, { .integer
= 100 }},
705 /* lldpXMedLocXPoEPDPowerSource */
706 { {1, 5, 4795, 1, 2, 14, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
707 /* lldpXMedLocXPoEPDPowerPriority */
708 { {1, 5, 4795, 1, 2, 15, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
710 /* lldpXMedRemCapSupported */
711 { {1, 5, 4795, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
712 { .string
= { .octet
= "\xFC", .len
= 1 }} },
713 { {1, 5, 4795, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
714 { .string
= { .octet
= "\xFC", .len
= 1 }}},
715 /* lldpXMedRemCapCurrent */
716 { {1, 5, 4795, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_OCTET_STR
,
717 { .string
= { .octet
= "\xFC", .len
= 1 }} },
718 { {1, 5, 4795, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
719 { .string
= { .octet
= "\xEC", .len
= 1 }}},
720 /* lldpXMedRemDeviceClass */
721 { {1, 5, 4795, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
722 { {1, 5, 4795, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
724 /* lldpXMedRemMediaPolicyVlanID */
725 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
726 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1007 }},
727 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
728 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 472 }},
729 /* lldpXMedRemMediaPolicyPriority */
730 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
731 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1 }},
732 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
733 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
734 /* lldpXMedLocMediaPolicyDscp */
735 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
736 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 49 }},
737 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
738 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 60 }},
739 /* lldpXMedLocMediaPolicyUnknown */
740 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
741 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
742 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
743 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 2 }},
744 /* lldpXMedLocMediaPolicyTagged */
745 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
746 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
747 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
748 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
750 /* lldpXMedRemHardwareRev */
751 { {1, 5, 4795, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
752 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
753 { {1, 5, 4795, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
754 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
755 /* lldpXMedRemSoftwareRev */
756 { {1, 5, 4795, 1, 3, 3, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
757 { .string
= { .octet
= "Software 1", .len
= 10 }} },
758 { {1, 5, 4795, 1, 3, 3, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
759 { .string
= { .octet
= "Software 1", .len
= 10 }} },
760 /* lldpXMedRemSerialNum */
761 { {1, 5, 4795, 1, 3, 3, 1, 4, 0, 3, 1 }, 11, ASN_OCTET_STR
,
762 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
763 { {1, 5, 4795, 1, 3, 3, 1, 4, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
764 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
765 /* lldpXMedRemMfgName */
766 { {1, 5, 4795, 1, 3, 3, 1, 5, 0, 3, 1 }, 11, ASN_OCTET_STR
,
767 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
768 { {1, 5, 4795, 1, 3, 3, 1, 5, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
769 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
770 /* lldpXMedRemModelName */
771 { {1, 5, 4795, 1, 3, 3, 1, 6, 0, 3, 1 }, 11, ASN_OCTET_STR
,
772 { .string
= { .octet
= "Model 1", .len
= 7 }} },
773 { {1, 5, 4795, 1, 3, 3, 1, 6, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
774 { .string
= { .octet
= "Model 1", .len
= 7 }} },
775 /* lldpXMedRemAssetID */
776 { {1, 5, 4795, 1, 3, 3, 1, 7, 0, 3, 1 }, 11, ASN_OCTET_STR
,
777 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
778 { {1, 5, 4795, 1, 3, 3, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
779 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
781 /* lldpXMedLocLocationInfo */
782 { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR
,
783 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
784 { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR
,
785 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
787 /* lldpXMedRemXPoEDeviceType */
788 { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 4 }},
789 { {1, 5, 4795, 1, 3, 5, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
791 /* lldpXMedRemXPoEPDPowerReq */
792 { {1, 5, 4795, 1, 3, 7, 1, 1, 10000, 4, 1}, 11, ASN_GAUGE
, { .integer
= 100 }},
793 /* lldpXMedRemXPoEPDPowerSource */
794 { {1, 5, 4795, 1, 3, 7, 1, 2, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
795 /* lldpXMedRemXPoEPDPowerPriority */
796 { {1, 5, 4795, 1, 3, 7, 1, 3, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
800 /* lldpXdot1LocPortVlanId */
801 { { 1, 5, 32962, 1, 2, 1, 1, 1, 3}, 9, ASN_INTEGER
, { .integer
= 47 }},
802 { { 1, 5, 32962, 1, 2, 1, 1, 1, 4}, 9, ASN_INTEGER
, { .integer
= 0 }},
803 /* lldpXdot1LocProtoVlanSupported */
804 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
805 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
806 /* lldpXdot1LocProtoVlanEnabled */
807 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
808 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
809 /* lldpXdot1LocVlanName */
810 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 47}, 10, ASN_OCTET_STR
,
811 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
812 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 49}, 10, ASN_OCTET_STR
,
813 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
814 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR
,
815 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
816 /* lldpXdot1LocProtocolId */
817 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30321}, 10, ASN_OCTET_STR
,
818 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
819 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30515}, 10, ASN_OCTET_STR
,
820 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }},
822 /* lldpXdot1RemPortVlanId */
823 { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 0 }},
824 { { 1, 5, 32962, 1, 3, 1, 1, 1, 8000, 3, 4}, 11, ASN_INTEGER
, { .integer
= 0 }},
825 { { 1, 5, 32962, 1, 3, 1, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 47 }},
826 /* lldpXdot1RemProtoVlanSupported */
827 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
828 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
829 /* lldpXdot1RemProtoVlanEnabled */
830 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
831 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
832 /* lldpXdot1RemVlanName */
833 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 47}, 12, ASN_OCTET_STR
,
834 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
835 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 49}, 12, ASN_OCTET_STR
,
836 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
837 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR
,
838 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
839 /* lldpXdot1RemProtocolId */
840 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30321}, 12, ASN_OCTET_STR
,
841 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
842 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30515}, 12, ASN_OCTET_STR
,
843 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }}
848 tohex(char *str
, size_t len
)
850 static char *hex
[] = { NULL
, NULL
};
851 static int which
= 0;
852 free(hex
[which
]); hex
[which
] = NULL
;
853 hex
[which
] = malloc(len
* 3 + 1);
854 fail_unless(hex
[which
] != NULL
, "Not enough memory?");
855 for (size_t i
= 0; i
< len
; i
++)
856 snprintf(hex
[which
] + 3*i
, 4, "%02X ", (unsigned char)str
[i
]);
858 return hex
[1 - which
];
862 snmp_is_prefix_of(struct variable8
*vp
, struct tree_node
*n
, char *repr
)
864 if (n
->namelen
< vp
->namelen
) return 0;
867 vp
->namelen
* sizeof(oid
)))
869 fail_unless(n
->type
== vp
->type
, "Inappropriate type for OID %s", repr
);
874 snmp_merge(struct variable8
*v1
, struct tree_node
*n
, struct variable
*vp
,
875 oid
*target
, size_t *targetlen
)
877 vp
->magic
= v1
->magic
;
880 vp
->findVar
= v1
->findVar
;
881 vp
->namelen
= v1
->namelen
+
882 sizeof(lldp_oid
)/sizeof(oid
);
883 memcpy(vp
->name
, lldp_oid
, sizeof(lldp_oid
));
884 memcpy(vp
->name
+ sizeof(lldp_oid
)/sizeof(oid
),
886 v1
->namelen
*sizeof(oid
));
887 *targetlen
= n
->namelen
+
888 sizeof(lldp_oid
)/sizeof(oid
);
889 memcpy(target
, lldp_oid
, sizeof(lldp_oid
));
890 memcpy(target
+ sizeof(lldp_oid
)/sizeof(oid
),
892 n
->namelen
* sizeof(oid
));
896 snmp_compare(struct tree_node
*n
,
897 u_char
*result
, size_t varlen
,
898 oid
*target
, size_t targetlen
, char *repr
)
900 unsigned long int value
;
901 fail_unless((targetlen
== sizeof(lldp_oid
)/sizeof(oid
) + n
->namelen
) &&
902 !memcmp(target
, lldp_oid
, sizeof(lldp_oid
)) &&
903 !memcmp(target
+ sizeof(lldp_oid
)/sizeof(oid
),
905 n
->namelen
* sizeof(oid
)),
906 "Bad OID returned when querying %s: got %s", repr
,
907 snmp_oidrepr(target
, targetlen
));
913 fail_unless(varlen
== sizeof(unsigned long int),
914 "Inappropriate length for integer type for OID %s",
916 memcpy(&value
, result
, sizeof(value
));
917 fail_unless(n
->value
.integer
== value
,
918 "For OID %s, expected value %u but got %u instead",
924 fail_unless(((n
->value
.string
.len
== varlen
) &&
925 !memcmp(n
->value
.string
.octet
,
927 "OID %s: wanted %s, got %s",
929 tohex(n
->value
.string
.octet
, n
->value
.string
.len
),
930 tohex((char *)result
, varlen
));
934 START_TEST (test_variable_order
)
937 for (i
= 0; i
< agent_lldp_vars_size() - 1; i
++) {
938 fail_unless(snmp_oid_compare(agent_lldp_vars
[i
].name
,
939 agent_lldp_vars
[i
].namelen
,
940 agent_lldp_vars
[i
+1].name
,
941 agent_lldp_vars
[i
+1].namelen
) < 0,
942 "Registered OID are out of orders (see %s and next one)",
943 snmp_oidrepr(agent_lldp_vars
[i
].name
,
944 agent_lldp_vars
[i
].namelen
));
949 START_TEST (test_get
)
953 j
< sizeof(snmp_tree
)/sizeof(struct tree_node
);
958 oid target
[MAX_OID_LEN
];
962 WriteMethod
*wmethod
;
963 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
964 snmp_tree
[j
].namelen
);
966 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
967 /* Search for the appropriate prefix. */
968 if (!snmp_is_prefix_of(&agent_lldp_vars
[i
], &snmp_tree
[j
],
971 /* We have our prefix. Fill out the vp struct
972 correctly. We need to complete OID with
974 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
976 /* Invoke the function */
977 result
= vp
.findVar(&vp
, target
, &targetlen
, 1, &varlen
, &wmethod
);
979 /* Check the result */
980 fail_unless(result
!= NULL
,
981 "No result when querying %s", repr
);
982 snmp_compare(&snmp_tree
[j
], result
, varlen
, target
, targetlen
, repr
);
988 fail("OID %s not found", repr
);
993 START_TEST (test_getnext
)
996 size_t end
= sizeof(snmp_tree
)/sizeof(struct tree_node
);
1002 oid target
[MAX_OID_LEN
];
1005 u_char
*result
= NULL
;
1006 WriteMethod
*wmethod
;
1007 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
1008 snmp_tree
[j
].namelen
);
1009 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
1010 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
1011 result
= vp
.findVar(&vp
, target
, &targetlen
, 0, &varlen
, &wmethod
);
1012 if (result
) /* Check next! */
1016 fail_unless(j
== end
- 1,
1017 "No next result found for %s", repr
);
1020 fail_unless(j
< end
- 1,
1021 "More results after %s", repr
);
1023 /* For unknown reasons, snmp_compare can be executed
1024 even when the above test fails... */
1026 snmp_compare(&snmp_tree
[j
+1], result
, varlen
, target
, targetlen
, repr
);
1035 Suite
*s
= suite_create("SNMP");
1037 TCase
*tc_snmp
= tcase_create("SNMP");
1038 tcase_add_checked_fixture(tc_snmp
, snmp_config
, NULL
);
1039 tcase_add_test(tc_snmp
, test_variable_order
);
1040 tcase_add_test(tc_snmp
, test_get
);
1041 tcase_add_test(tc_snmp
, test_getnext
);
1042 suite_add_tcase(s
, tc_snmp
);
1051 Suite
*s
= snmp_suite();
1052 SRunner
*sr
= srunner_create(s
);
1053 srunner_run_all(sr
, CK_ENV
);
1054 number_failed
= srunner_ntests_failed(sr
);
1056 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;