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
= {
35 .c_tx_interval
= 30000,
41 struct timeval test_starttime
= { .tv_sec
= 100, .tv_usec
= 0 };
44 struct lldpd_mgmt mgmt1
= {
45 .m_family
= LLDPD_AF_IPV4
,
46 .m_addr
= { .octets
= { 0xc0, 0, 0x2, 0xf } }, /* 192.0.2.15 */
47 .m_addrsize
= sizeof(struct in_addr
),
50 struct lldpd_chassis chassis1
= {
52 .c_protocol
= LLDPD_MODE_LLDP
,
53 .c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LLADDR
,
56 .c_name
= "chassis1.example.com",
57 .c_descr
= "First chassis",
58 .c_cap_available
= LLDP_CAP_BRIDGE
| LLDP_CAP_WLAN
| LLDP_CAP_ROUTER
,
59 .c_cap_enabled
= LLDP_CAP_ROUTER
,
61 .c_med_cap_available
= LLDP_MED_CAP_CAP
| LLDP_MED_CAP_IV
| \
62 LLDP_MED_CAP_LOCATION
| LLDP_MED_CAP_POLICY
| \
63 LLDP_MED_CAP_MDI_PSE
| LLDP_MED_CAP_MDI_PD
,
64 .c_med_type
= LLDP_MED_CLASS_II
,
65 .c_med_hw
= "Hardware 1",
66 /* We skip c_med_fw */
67 .c_med_sw
= "Software 1",
68 .c_med_sn
= "00-00-0000-AAAA",
69 .c_med_manuf
= "Manufacturer 1",
70 .c_med_model
= "Model 1",
71 .c_med_asset
= "Asset 1",
75 struct lldpd_mgmt mgmt2
= {
76 .m_family
= LLDPD_AF_IPV4
,
77 .m_addr
= { .octets
= { 0xc0, 0, 0x2, 0x11 } }, /* 192.0.2.17 */
78 .m_addrsize
= sizeof(struct in_addr
),
81 struct lldpd_mgmt mgmt3
= {
82 .m_family
= LLDPD_AF_IPV6
,
83 .m_addr
= { .octets
= { 0x20, 0x01, 0x0d, 0xb8,
84 0xca, 0xfe, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x17 } }, /* 2001:db8:cafe::17 */
87 .m_addrsize
= sizeof(struct in6_addr
),
90 struct lldpd_chassis chassis2
= {
92 .c_protocol
= LLDPD_MODE_LLDP
,
93 .c_id_subtype
= LLDP_CHASSISID_SUBTYPE_LOCAL
,
96 .c_name
= "chassis2.example.com",
97 .c_descr
= "Second chassis",
98 .c_cap_available
= LLDP_CAP_ROUTER
,
99 .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_custom custom1
= {
256 .oui
= { 33, 44, 55 },
258 .oui_info
= (u_int8_t
*)"OUI content",
260 struct lldpd_custom custom2
= {
261 .oui
= { 33, 44, 55 },
263 .oui_info
= (u_int8_t
*)"More content",
265 struct lldpd_custom custom3
= {
266 .oui
= { 33, 44, 55 },
268 .oui_info
= (u_int8_t
*)"More more content",
270 struct lldpd_custom custom4
= {
271 .oui
= { 33, 44, 56 },
273 .oui_info
= (u_int8_t
*)"Even more content",
275 struct lldpd_custom custom5
= {
276 .oui
= { 33, 44, 55 },
278 .oui_info
= (u_int8_t
*)"Still more content",
283 struct lldpd_vlan vlan47
= {
284 .v_name
= "VLAN #47",
287 struct lldpd_vlan vlan49
= {
288 .v_name
= "VLAN #49",
291 struct lldpd_vlan vlan1449
= {
292 .v_name
= "VLAN #1449",
295 struct lldpd_ppvid ppvid47
= {
296 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
299 struct lldpd_ppvid ppvid118
= {
300 .p_cap_status
= LLDP_PPVID_CAP_SUPPORTED
| LLDP_PPVID_CAP_ENABLED
,
303 struct lldpd_pi pi88cc
= {
307 struct lldpd_pi pi888e01
= {
308 .p_pi
= "\x88\x8e\x01",
313 /* First port of second chassis */
314 struct lldpd_port port2
= {
315 .p_chassis
= &chassis2
,
317 .p_protocol
= LLDPD_MODE_LLDP
,
318 .p_id_subtype
= LLDP_PORTID_SUBTYPE_IFALIAS
,
321 .p_descr
= "Gigabit Ethernet 1/7",
327 starttime
= test_starttime
;
328 agent_scfg
= &test_cfg
;
329 TAILQ_INIT(&test_cfg
.g_chassis
);
330 TAILQ_INIT(&chassis1
.c_mgmt
);
331 TAILQ_INSERT_TAIL(&chassis1
.c_mgmt
, &mgmt1
, m_entries
);
332 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis1
, c_entries
);
333 TAILQ_INIT(&chassis2
.c_mgmt
);
334 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt2
, m_entries
);
335 TAILQ_INSERT_TAIL(&chassis2
.c_mgmt
, &mgmt3
, m_entries
);
336 TAILQ_INSERT_TAIL(&test_cfg
.g_chassis
, &chassis2
, c_entries
);
337 TAILQ_INIT(&test_cfg
.g_hardware
);
338 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware1
, h_entries
);
339 TAILQ_INSERT_TAIL(&test_cfg
.g_hardware
, &hardware2
, h_entries
);
341 custom1
.oui_info_len
= strlen((char*)custom1
.oui_info
);
342 custom2
.oui_info_len
= strlen((char*)custom2
.oui_info
);
343 custom3
.oui_info_len
= strlen((char*)custom3
.oui_info
);
344 custom4
.oui_info_len
= strlen((char*)custom4
.oui_info
);
345 custom5
.oui_info_len
= strlen((char*)custom5
.oui_info
);
346 TAILQ_INIT(&hardware1
.h_lport
.p_custom_list
);
347 TAILQ_INIT(&hardware2
.h_lport
.p_custom_list
);
348 TAILQ_INIT(&port2
.p_custom_list
);
349 TAILQ_INSERT_TAIL(&hardware2
.h_lport
.p_custom_list
, &custom1
, next
);
350 TAILQ_INSERT_TAIL(&hardware2
.h_lport
.p_custom_list
, &custom2
, next
);
351 TAILQ_INSERT_TAIL(&hardware2
.h_lport
.p_custom_list
, &custom3
, next
);
352 TAILQ_INSERT_TAIL(&hardware2
.h_lport
.p_custom_list
, &custom4
, next
);
353 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_custom_list
, &custom5
, next
);
356 TAILQ_INIT(&hardware1
.h_lport
.p_vlans
);
357 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan47
, v_entries
);
358 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan49
, v_entries
);
359 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_vlans
, &vlan1449
, v_entries
);
360 TAILQ_INIT(&hardware1
.h_lport
.p_ppvids
);
361 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid47
, p_entries
);
362 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_ppvids
, &ppvid118
, p_entries
);
363 TAILQ_INIT(&hardware1
.h_lport
.p_pids
);
364 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi88cc
, p_entries
);
365 TAILQ_INSERT_TAIL(&hardware1
.h_lport
.p_pids
, &pi888e01
, p_entries
);
366 TAILQ_INIT(&hardware2
.h_lport
.p_vlans
);
367 TAILQ_INIT(&hardware2
.h_lport
.p_ppvids
);
368 TAILQ_INIT(&hardware2
.h_lport
.p_pids
);
369 TAILQ_INIT(&port2
.p_vlans
);
370 TAILQ_INIT(&port2
.p_ppvids
);
371 TAILQ_INIT(&port2
.p_pids
);
373 TAILQ_INIT(&hardware1
.h_rports
);
374 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &port2
, p_entries
);
375 TAILQ_INSERT_TAIL(&hardware1
.h_rports
, &hardware2
.h_lport
, p_entries
);
376 TAILQ_INIT(&hardware2
.h_rports
);
377 TAILQ_INSERT_TAIL(&hardware2
.h_rports
, &hardware1
.h_lport
, p_entries
);
380 /* Convert OID to a string. Static buffer. */
382 snmp_oidrepr(oid
*name
, size_t namelen
)
384 static char *buffer
[4] = {NULL
, NULL
, NULL
, NULL
};
385 static int current
= 0;
388 current
= (current
+ 1)%4;
389 free(buffer
[current
]); buffer
[current
] = NULL
;
391 for (i
= 0; i
< namelen
; i
++) {
392 /* Not very efficient... */
393 char *newbuffer
= NULL
;
394 if (asprintf(&newbuffer
, "%s.%lu", buffer
[current
]?buffer
[current
]:"",
395 (unsigned long)name
[i
]) == -1) {
396 free(buffer
[current
]);
397 buffer
[current
] = NULL
;
400 free(buffer
[current
]);
401 buffer
[current
] = newbuffer
;
403 return buffer
[current
++];
407 oid name
[MAX_OID_LEN
];
409 int type
; /* ASN_* */
411 unsigned long int integer
;
419 static oid zeroDotZero
[2] = {0, 0};
420 struct tree_node snmp_tree
[] = {
421 { {1, 1, 1, 0}, 4, ASN_INTEGER
, { .integer
= 30 } }, /* lldpMessageTxInterval */
422 { {1, 1, 2, 0}, 4, ASN_INTEGER
, { .integer
= 2 } }, /* lldpMessageTxHoldMultiplier */
423 { {1, 1, 3, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpReinitDelay */
424 { {1, 1, 4, 0}, 4, ASN_INTEGER
, { .integer
= 1 } }, /* lldpTxDelay */
425 { {1, 1, 5, 0}, 4, ASN_INTEGER
, { .integer
= 5 } }, /* lldpNotificationInterval */
426 { {1, 2, 1, 0}, 4, ASN_TIMETICKS
, { .integer
= 10000 } },/* lldpStatsRemTablesLastChangeTime */
427 { {1, 2, 2, 0}, 4, ASN_GAUGE
, { .integer
= 1100 } }, /* lldpStatsRemTablesInserts */
428 { {1, 2, 3, 0}, 4, ASN_GAUGE
, { .integer
= 56 } }, /* lldpStatsRemTablesDeletes */
429 { {1, 2, 4, 0}, 4, ASN_GAUGE
, { .integer
= 2 } }, /* lldpStatsRemTablesDrops */
430 { {1, 2, 5, 0}, 4, ASN_GAUGE
, { .integer
= 230 } }, /* lldpStatsRemTablesAgeouts */
432 { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 1352 } }, /* lldpStatsTxPortFramesTotal.3 */
433 { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 11352 } }, /* lldpStatsTxPortFramesTotal.4 */
434 { {1, 2, 7, 1, 2, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesDiscardedTotal.3 */
435 { {1, 2, 7, 1, 2, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesDiscardedTotal.4 */
436 { {1, 2, 7, 1, 3, 3}, 6, ASN_COUNTER
, { .integer
= 5 } }, /* lldpStatsRxPortFramesError.3 */
437 { {1, 2, 7, 1, 3, 4}, 6, ASN_COUNTER
, { .integer
= 55 } }, /* lldpStatsRxPortFramesError.4 */
438 { {1, 2, 7, 1, 4, 3}, 6, ASN_COUNTER
, { .integer
= 1458 } }, /* lldpStatsRxPortFramesTotal.3 */
439 { {1, 2, 7, 1, 4, 4}, 6, ASN_COUNTER
, { .integer
= 11458 } }, /* lldpStatsRxPortFramesTotal.4 */
440 { {1, 2, 7, 1, 5, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsDiscardedTotal.3 */
441 { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */
442 { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER
, { .integer
= 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */
443 { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER
, { .integer
= 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */
444 { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE
, { .integer
= 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
445 { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE
, { .integer
= 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
447 { {1, 3, 1, 0}, 4, ASN_INTEGER
, { .integer
= 4 } }, /* lldpLocChassisIdSubtype */
448 /* lldpLocChassisId */
449 { {1, 3, 2, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
452 { {1, 3, 3, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "chassis1.example.com",
455 { {1, 3, 4, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "First chassis",
457 /* lldpLocSysCapSupported */
458 { {1, 3, 5, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x38",
460 /* lldpLocSysCapEnabled */
461 { {1, 3, 6, 0}, 4, ASN_OCTET_STR
, { .string
= { .octet
= "\x8",
464 { {1, 3, 7, 1, 2, 3}, 6, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocPortIdSubtype.3 */
465 { {1, 3, 7, 1, 2, 4}, 6, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocPortIdSubtype.5 */
466 /* lldpLocPortId.3 */
467 { {1, 3, 7, 1, 3, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012",
469 /* lldpLocPortId.4 */
470 { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth4",
472 /* lldpLocPortDesc.3 */
473 { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "eth2",
475 /* lldpLocPortDesc.4 */
476 { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR
, { .string
= { .octet
= "Intel 1000 GE",
479 { {1, 3, 8, 1, 3, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 5 } }, /* lldpLocManAddrLen */
480 { {1, 3, 8, 1, 4, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 2 } }, /* lldpLocManAddrIfSubtype */
481 { {1, 3, 8, 1, 5, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER
, { .integer
= 3 } }, /* lldpLocManAddrIfId */
482 /* lldpLocManAddrOID */
483 { {1, 3, 8, 1, 6, 1, 4, 192, 0, 2, 15}, 11, ASN_OBJECT_ID
,
484 { .string
= { .octet
= (char *)zeroDotZero
,
485 .len
= sizeof(zeroDotZero
) }} },
487 /* lldpRemChassisIdSubtype */
488 { {1, 4, 1, 1, 4, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 4 } },
489 { {1, 4, 1, 1, 4, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 7 } },
490 { {1, 4, 1, 1, 4, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 4 } },
491 /* lldpRemChassisId */
492 { {1, 4, 1, 1, 5, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
493 { {1, 4, 1, 1, 5, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
494 { .octet
= "chassis2",
496 { {1, 4, 1, 1, 5, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
497 /* lldpRemPortIdSubtype */
498 { {1, 4, 1, 1, 6, 0, 3, 1 }, 8, ASN_INTEGER
, { .integer
= 5 } },
499 { {1, 4, 1, 1, 6, 8000, 3, 4}, 8, ASN_INTEGER
, { .integer
= 1 } },
500 { {1, 4, 1, 1, 6, 10000, 4, 1}, 8, ASN_INTEGER
, { .integer
= 3 } },
502 { {1, 4, 1, 1, 7, 0, 3, 1 }, 8, ASN_OCTET_STR
, { .string
= { .octet
= "eth4", .len
= 4 }} },
503 { {1, 4, 1, 1, 7, 8000, 3, 4}, 8, ASN_OCTET_STR
, { .string
=
504 { .octet
= "Giga1/7", .len
= 7 }} },
505 { {1, 4, 1, 1, 7, 10000, 4, 1}, 8, ASN_OCTET_STR
, { .string
= { .octet
= "AAA012", .len
= 6 }} },
506 /* lldpRemPortDesc */
507 { {1, 4, 1, 1, 8, 0, 3, 1 }, 8, ASN_OCTET_STR
,
508 { .string
= { .octet
= "Intel 1000 GE", .len
= 13 }} },
509 { {1, 4, 1, 1, 8, 8000, 3, 4}, 8, ASN_OCTET_STR
,
510 { .string
= { .octet
= "Gigabit Ethernet 1/7", .len
= 20 }} },
511 { {1, 4, 1, 1, 8, 10000, 4, 1}, 8, ASN_OCTET_STR
,
512 { .string
= { .octet
= "eth2", .len
= 4 }} },
514 { {1, 4, 1, 1, 9, 0, 3, 1 }, 8, ASN_OCTET_STR
,
515 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
516 { {1, 4, 1, 1, 9, 8000, 3, 4}, 8, ASN_OCTET_STR
,
517 { .string
= { .octet
= "chassis2.example.com", .len
= 20 }} },
518 { {1, 4, 1, 1, 9, 10000, 4, 1}, 8, ASN_OCTET_STR
,
519 { .string
= { .octet
= "chassis1.example.com", .len
= 20 }} },
521 { {1, 4, 1, 1, 10, 0, 3, 1 }, 8, ASN_OCTET_STR
,
522 { .string
= { .octet
= "First chassis", .len
= 13 }} },
523 { {1, 4, 1, 1, 10, 8000, 3, 4}, 8, ASN_OCTET_STR
,
524 { .string
= { .octet
= "Second chassis", .len
= 14 }} },
525 { {1, 4, 1, 1, 10, 10000, 4, 1}, 8, ASN_OCTET_STR
,
526 { .string
= { .octet
= "First chassis", .len
= 13 }} },
527 /* lldpRemSysCapSupported */
528 { {1, 4, 1, 1, 11, 0, 3, 1 }, 8, ASN_OCTET_STR
,
529 { .string
= { .octet
= "\x38", .len
= 1 }} },
530 { {1, 4, 1, 1, 11, 8000, 3, 4}, 8, ASN_OCTET_STR
,
531 { .string
= { .octet
= "\x8", .len
= 1 }} },
532 { {1, 4, 1, 1, 11, 10000, 4, 1}, 8, ASN_OCTET_STR
,
533 { .string
= { .octet
= "\x38", .len
= 1 }} },
534 /* lldpRemSysCapEnabled */
535 { {1, 4, 1, 1, 12, 0, 3, 1 }, 8, ASN_OCTET_STR
,
536 { .string
= { .octet
= "\x8", .len
= 1 }} },
537 { {1, 4, 1, 1, 12, 8000, 3, 4}, 8, ASN_OCTET_STR
,
538 { .string
= { .octet
= "\x8", .len
= 1 }} },
539 { {1, 4, 1, 1, 12, 10000, 4, 1}, 8, ASN_OCTET_STR
,
540 { .string
= { .octet
= "\x8", .len
= 1 }} },
542 /* lldpRemManAddrIfSubtype */
543 { {1, 4, 2, 1, 3, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
544 { {1, 4, 2, 1, 3, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 2 } },
545 { {1, 4, 2, 1, 3, 8000, 3, 4, 2, 16,
546 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
547 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 2 } },
548 { {1, 4, 2, 1, 3, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 2 } },
549 /* lldpRemManAddrIfId */
550 { {1, 4, 2, 1, 4, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
551 { {1, 4, 2, 1, 4, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER
, { .integer
= 5 } },
552 { {1, 4, 2, 1, 4, 8000, 3, 4, 2, 16,
553 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
554 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER
, { .integer
= 5 } },
555 { {1, 4, 2, 1, 4, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER
, { .integer
= 3 } },
556 /* lldpRemManAddrOID */
557 { {1, 4, 2, 1, 5, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
558 { .string
= { .octet
= (char *)zeroDotZero
,
559 .len
= sizeof(zeroDotZero
) }} },
560 { {1, 4, 2, 1, 5, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_OBJECT_ID
,
561 { .string
= { .octet
= (char *)zeroDotZero
,
562 .len
= sizeof(zeroDotZero
) }} },
563 { {1, 4, 2, 1, 5, 8000, 3, 4, 2, 16,
564 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
565 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_OBJECT_ID
,
566 { .string
= { .octet
= (char *)zeroDotZero
,
567 .len
= sizeof(zeroDotZero
) }} },
568 { {1, 4, 2, 1, 5, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID
,
569 { .string
= { .octet
= (char *)zeroDotZero
,
570 .len
= sizeof(zeroDotZero
) }} },
573 /* lldpRemOrgDefInfo */
574 { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 44, 1 }, 13, ASN_OCTET_STR
,
575 { .string
= { .octet
= "OUI content", .len
= 11 }} },
576 { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 44, 2 }, 13, ASN_OCTET_STR
,
577 { .string
= { .octet
= "More content", .len
= 12 }} },
578 { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 55, 45, 3 }, 13, ASN_OCTET_STR
,
579 { .string
= { .octet
= "More more content", .len
= 17 }} },
580 { {1, 4, 4, 1, 4, 0, 3, 1, 33, 44, 56, 44, 4 }, 13, ASN_OCTET_STR
,
581 { .string
= { .octet
= "Even more content", .len
= 17 }} },
582 { {1, 4, 4, 1, 4, 10000, 4, 1, 33, 44, 55, 44, 1 }, 13, ASN_OCTET_STR
,
583 { .string
= { .octet
= "Still more content", .len
= 18 }} },
587 /* lldpXdot3LocPortAutoNegSupported */
588 { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
589 { {1, 5, 4623, 1, 2, 1, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
590 /* lldpXdot3LocPortAutoNegEnabled */
591 { {1, 5, 4623, 1, 2, 1, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
592 { {1, 5, 4623, 1, 2, 1, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 1 }},
593 /* lldpXdot3LocPortAutoNegAdvertisedCap */
594 { {1, 5, 4623, 1, 2, 1, 1, 3, 3 }, 9, ASN_OCTET_STR
,
595 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
596 { {1, 5, 4623, 1, 2, 1, 1, 3, 4 }, 9, ASN_OCTET_STR
,
597 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
598 /* lldpXdot3LocPortOperMauType */
599 { {1, 5, 4623, 1, 2, 1, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 16 }},
600 { {1, 5, 4623, 1, 2, 1, 1, 4, 4 }, 9, ASN_INTEGER
, { .integer
= 30 }},
602 /* lldpXdot3LocPowerPortClass */
603 { {1, 5, 4623, 1, 2, 2, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
604 /* lldpXdot3LocPowerMDISupported */
605 { {1, 5, 4623, 1, 2, 2, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
606 /* lldpXdot3LocPowerMDIEnabled */
607 { {1, 5, 4623, 1, 2, 2, 1, 3, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
608 /* lldpXdot3LocPowerPairControlable */
609 { {1, 5, 4623, 1, 2, 2, 1, 4, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
610 /* lldpXdot3LocPowerPairs */
611 { {1, 5, 4623, 1, 2, 2, 1, 5, 3 }, 9, ASN_INTEGER
, { .integer
= 2 }},
612 /* lldpXdot3LocPowerClass */
613 { {1, 5, 4623, 1, 2, 2, 1, 6, 3 }, 9, ASN_INTEGER
, { .integer
= 3 }},
614 /* As per 802.3at-2009, not sure of the OID... */
615 /* lldpXdot3LocPowerType */
616 { {1, 5, 4623, 1, 2, 2, 1, 7, 3 }, 9, ASN_OCTET_STR
,
617 { .string
= { .octet
= "\xC0", .len
= 1 } }},
618 /* lldpXdot3LocPowerSource */
619 { {1, 5, 4623, 1, 2, 2, 1, 8, 3 }, 9, ASN_OCTET_STR
,
620 { .string
= { .octet
= "\xC0", .len
= 1 } }},
621 /* lldpXdot3LocPowerPriority */
622 { {1, 5, 4623, 1, 2, 2, 1, 9, 3 }, 9, ASN_INTEGER
, { .integer
= 1 }},
623 /* lldpXdot3LocPDRequestedPowerValue */
624 { {1, 5, 4623, 1, 2, 2, 1, 10, 3 }, 9, ASN_INTEGER
, { .integer
= 2000 }},
625 /* lldpXdot3LocPSEAllocatedPowerValue */
626 { {1, 5, 4623, 1, 2, 2, 1, 11, 3 }, 9, ASN_INTEGER
, { .integer
= 2500 }},
628 /* lldpXdot3LocLinkAggStatus */
629 { {1, 5, 4623, 1, 2, 3, 1, 1, 3 }, 9, ASN_OCTET_STR
,
630 { .string
= { .octet
= "\x00", .len
= 1 }} },
631 { {1, 5, 4623, 1, 2, 3, 1, 1, 4 }, 9, ASN_OCTET_STR
,
632 { .string
= { .octet
= "\xC0", .len
= 1 }} },
633 /* lldpXdot3LocLinkAggPortId */
634 { {1, 5, 4623, 1, 2, 3, 1, 2, 3 }, 9, ASN_INTEGER
, { .integer
= 0 }},
635 { {1, 5, 4623, 1, 2, 3, 1, 2, 4 }, 9, ASN_INTEGER
, { .integer
= 3 }},
637 /* lldpXdot3LocMaxFrameSize */
638 { {1, 5, 4623, 1, 2, 4, 1, 1, 3 }, 9, ASN_INTEGER
, { .integer
= 1600 }},
639 { {1, 5, 4623, 1, 2, 4, 1, 1, 4 }, 9, ASN_INTEGER
, { .integer
= 9000 }},
641 /* lldpXdot3RemPortAutoNegSupported */
642 { {1, 5, 4623, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
643 { {1, 5, 4623, 1, 3, 1, 1, 1, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
644 { {1, 5, 4623, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
645 /* lldpXdot3RemPortAutoNegEnabled */
646 { {1, 5, 4623, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
647 { {1, 5, 4623, 1, 3, 1, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 2 }},
648 { {1, 5, 4623, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
649 /* lldpXdot3RemPortAutoNegAdvertisedCap */
650 { {1, 5, 4623, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
651 { .string
= { .octet
= "\x04\x01", .len
= 2 }} },
652 { {1, 5, 4623, 1, 3, 1, 1, 3, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
653 { .string
= { .octet
= "\x00\x00", .len
= 2 }} },
654 { {1, 5, 4623, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
655 { .string
= { .octet
= "\x0c\x00", .len
= 2 }} },
656 /* lldpXdot3RemPortOperMauType */
657 { {1, 5, 4623, 1, 3, 1, 1, 4, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 30 }},
658 { {1, 5, 4623, 1, 3, 1, 1, 4, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
659 { {1, 5, 4623, 1, 3, 1, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 16 }},
661 /* lldpXdot3RemPowerPortClass */
662 { {1, 5, 4623, 1, 3, 2, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
663 /* lldpXdot3RemPowerMDISupported */
664 { {1, 5, 4623, 1, 3, 2, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
665 /* lldpXdot3RemPowerMDIEnabled */
666 { {1, 5, 4623, 1, 3, 2, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
667 /* lldpXdot3RemPowerPairControlable */
668 { {1, 5, 4623, 1, 3, 2, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
669 /* lldpXdot3RemPowerPairs */
670 { {1, 5, 4623, 1, 3, 2, 1, 5, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
671 /* lldpXdot3RemPowerClass */
672 { {1, 5, 4623, 1, 3, 2, 1, 6, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
673 /* As per 802.3at-2009, not sure of the OID... */
674 /* lldpXdot3RemPowerType */
675 { {1, 5, 4623, 1, 3, 2, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
676 { .string
= { .octet
= "\xC0", .len
= 1 } }},
677 /* lldpXdot3RemPowerSource */
678 { {1, 5, 4623, 1, 3, 2, 1, 8, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
679 { .string
= { .octet
= "\xC0", .len
= 1 } }},
680 /* lldpXdot3RemPowerPriority */
681 { {1, 5, 4623, 1, 3, 2, 1, 9, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1 }},
682 /* lldpXdot3RemPDRequestedPowerValue */
683 { {1, 5, 4623, 1, 3, 2, 1, 10, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2000 }},
684 /* lldpXdot3RemPSEAllocatedPowerValue */
685 { {1, 5, 4623, 1, 3, 2, 1, 11, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2500 }},
687 /* lldpXdot3RemLinkAggStatus */
688 { {1, 5, 4623, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
689 { .string
= { .octet
= "\xC0", .len
= 1 }} },
690 { {1, 5, 4623, 1, 3, 3, 1, 1, 8000, 3, 4 }, 11, ASN_OCTET_STR
,
691 { .string
= { .octet
= "\x00", .len
= 1 }} },
692 { {1, 5, 4623, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
693 { .string
= { .octet
= "\x00", .len
= 1 }} },
694 /* lldpXdot3RemLinkAggPortId */
695 { {1, 5, 4623, 1, 3, 3, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 3 }},
696 { {1, 5, 4623, 1, 3, 3, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER
, { .integer
= 0 }},
697 { {1, 5, 4623, 1, 3, 3, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 0 }},
699 /* lldpXdot3RemMaxFrameSize */
700 { {1, 5, 4623, 1, 3, 4, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 9000 }},
701 { {1, 5, 4623, 1, 3, 4, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 1600 }},
703 #ifdef ENABLE_LLDPMED
704 /* lldpXMedLocDeviceClass */
705 { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER
, { .integer
= 2 }},
707 /* lldpXMedLocMediaPolicyVlanID */
708 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
709 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 472 }},
710 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 475 }},
711 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1007 }},
712 /* lldpXMedLocMediaPolicyPriority */
713 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
714 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
715 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 3 }},
716 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 1 }},
717 /* lldpXMedLocMediaPolicyDscp */
718 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
719 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 60 }},
720 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 62 }},
721 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 49 }},
722 /* lldpXMedLocMediaPolicyUnknown */
723 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
724 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 2 }},
725 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
726 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
727 /* lldpXMedLocMediaPolicyTagged */
728 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
729 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 7 }, 10, ASN_INTEGER
, { .integer
= 1 }},
730 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 3 }, 10, ASN_INTEGER
, { .integer
= 1 }},
731 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 6 }, 10, ASN_INTEGER
, { .integer
= 2 }},
733 /* lldpXMedLocHardwareRev */
734 { {1, 5, 4795, 1, 2, 2, 0 }, 7, ASN_OCTET_STR
,
735 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
736 /* lldpXMedLocSoftwareRev */
737 { {1, 5, 4795, 1, 2, 4, 0 }, 7, ASN_OCTET_STR
,
738 { .string
= { .octet
= "Software 1", .len
= 10 }} },
739 /* lldpXMedLocSerialNum */
740 { {1, 5, 4795, 1, 2, 5, 0 }, 7, ASN_OCTET_STR
,
741 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
742 /* lldpXMedLocMfgName */
743 { {1, 5, 4795, 1, 2, 6, 0 }, 7, ASN_OCTET_STR
,
744 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
745 /* lldpXMedLocModelName */
746 { {1, 5, 4795, 1, 2, 7, 0 }, 7, ASN_OCTET_STR
,
747 { .string
= { .octet
= "Model 1", .len
= 7 }} },
748 /* lldpXMedLocAssetID */
749 { {1, 5, 4795, 1, 2, 8, 0 }, 7, ASN_OCTET_STR
,
750 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
752 /* lldpXMedLocLocationInfo */
753 { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR
,
754 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
755 { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR
,
756 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
758 /* lldpXMedLocXPoEDeviceType */
759 { {1, 5, 4795, 1, 2, 10, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
760 /* lldpXMedLocXPoEPDPowerReq */
761 { {1, 5, 4795, 1, 2, 13, 0 }, 7, ASN_GAUGE
, { .integer
= 100 }},
762 /* lldpXMedLocXPoEPDPowerSource */
763 { {1, 5, 4795, 1, 2, 14, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
764 /* lldpXMedLocXPoEPDPowerPriority */
765 { {1, 5, 4795, 1, 2, 15, 0 }, 7, ASN_INTEGER
, { .integer
= 3 }},
767 /* lldpXMedRemCapSupported */
768 { {1, 5, 4795, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
769 { .string
= { .octet
= "\xFC", .len
= 1 }} },
770 { {1, 5, 4795, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
771 { .string
= { .octet
= "\xFC", .len
= 1 }}},
772 /* lldpXMedRemCapCurrent */
773 { {1, 5, 4795, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_OCTET_STR
,
774 { .string
= { .octet
= "\xFC", .len
= 1 }} },
775 { {1, 5, 4795, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
776 { .string
= { .octet
= "\xEC", .len
= 1 }}},
777 /* lldpXMedRemDeviceClass */
778 { {1, 5, 4795, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
779 { {1, 5, 4795, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER
, { .integer
= 2 }},
781 /* lldpXMedRemMediaPolicyVlanID */
782 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
783 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1007 }},
784 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 475 }},
785 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 472 }},
786 /* lldpXMedRemMediaPolicyPriority */
787 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
788 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 1 }},
789 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 3 }},
790 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
791 /* lldpXMedLocMediaPolicyDscp */
792 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
793 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 49 }},
794 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 62 }},
795 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 60 }},
796 /* lldpXMedLocMediaPolicyUnknown */
797 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
798 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
799 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
800 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 2 }},
801 /* lldpXMedLocMediaPolicyTagged */
802 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
803 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 6 }, 12, ASN_INTEGER
, { .integer
= 2 }},
804 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 3 }, 12, ASN_INTEGER
, { .integer
= 1 }},
805 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 7 }, 12, ASN_INTEGER
, { .integer
= 1 }},
807 /* lldpXMedRemHardwareRev */
808 { {1, 5, 4795, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR
,
809 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
810 { {1, 5, 4795, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
811 { .string
= { .octet
= "Hardware 1", .len
= 10 }} },
812 /* lldpXMedRemSoftwareRev */
813 { {1, 5, 4795, 1, 3, 3, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR
,
814 { .string
= { .octet
= "Software 1", .len
= 10 }} },
815 { {1, 5, 4795, 1, 3, 3, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
816 { .string
= { .octet
= "Software 1", .len
= 10 }} },
817 /* lldpXMedRemSerialNum */
818 { {1, 5, 4795, 1, 3, 3, 1, 4, 0, 3, 1 }, 11, ASN_OCTET_STR
,
819 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
820 { {1, 5, 4795, 1, 3, 3, 1, 4, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
821 { .string
= { .octet
= "00-00-0000-AAAA", .len
= 15 }} },
822 /* lldpXMedRemMfgName */
823 { {1, 5, 4795, 1, 3, 3, 1, 5, 0, 3, 1 }, 11, ASN_OCTET_STR
,
824 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
825 { {1, 5, 4795, 1, 3, 3, 1, 5, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
826 { .string
= { .octet
= "Manufacturer 1", .len
= 14 }} },
827 /* lldpXMedRemModelName */
828 { {1, 5, 4795, 1, 3, 3, 1, 6, 0, 3, 1 }, 11, ASN_OCTET_STR
,
829 { .string
= { .octet
= "Model 1", .len
= 7 }} },
830 { {1, 5, 4795, 1, 3, 3, 1, 6, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
831 { .string
= { .octet
= "Model 1", .len
= 7 }} },
832 /* lldpXMedRemAssetID */
833 { {1, 5, 4795, 1, 3, 3, 1, 7, 0, 3, 1 }, 11, ASN_OCTET_STR
,
834 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
835 { {1, 5, 4795, 1, 3, 3, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR
,
836 { .string
= { .octet
= "Asset 1", .len
= 7 }} },
838 /* lldpXMedLocLocationInfo */
839 { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR
,
840 { .string
= { .octet
= "Not interpreted", .len
= 15 }} },
841 { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR
,
842 { .string
= { .octet
= "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len
= 22 }} },
844 /* lldpXMedRemXPoEDeviceType */
845 { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 4 }},
846 { {1, 5, 4795, 1, 3, 5, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
848 /* lldpXMedRemXPoEPDPowerReq */
849 { {1, 5, 4795, 1, 3, 7, 1, 1, 10000, 4, 1}, 11, ASN_GAUGE
, { .integer
= 100 }},
850 /* lldpXMedRemXPoEPDPowerSource */
851 { {1, 5, 4795, 1, 3, 7, 1, 2, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
852 /* lldpXMedRemXPoEPDPowerPriority */
853 { {1, 5, 4795, 1, 3, 7, 1, 3, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 3 }},
857 /* lldpXdot1LocPortVlanId */
858 { { 1, 5, 32962, 1, 2, 1, 1, 1, 3}, 9, ASN_INTEGER
, { .integer
= 47 }},
859 { { 1, 5, 32962, 1, 2, 1, 1, 1, 4}, 9, ASN_INTEGER
, { .integer
= 0 }},
860 /* lldpXdot1LocProtoVlanSupported */
861 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
862 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
863 /* lldpXdot1LocProtoVlanEnabled */
864 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 47}, 10, ASN_INTEGER
, { .integer
= 1 }},
865 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 118}, 10, ASN_INTEGER
, { .integer
= 1 }},
866 /* lldpXdot1LocVlanName */
867 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 47}, 10, ASN_OCTET_STR
,
868 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
869 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 49}, 10, ASN_OCTET_STR
,
870 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
871 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR
,
872 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
873 /* lldpXdot1LocProtocolId */
874 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30321}, 10, ASN_OCTET_STR
,
875 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
876 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30515}, 10, ASN_OCTET_STR
,
877 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }},
879 /* lldpXdot1RemPortVlanId */
880 { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER
, { .integer
= 0 }},
881 { { 1, 5, 32962, 1, 3, 1, 1, 1, 8000, 3, 4}, 11, ASN_INTEGER
, { .integer
= 0 }},
882 { { 1, 5, 32962, 1, 3, 1, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER
, { .integer
= 47 }},
883 /* lldpXdot1RemProtoVlanSupported */
884 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
885 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
886 /* lldpXdot1RemProtoVlanEnabled */
887 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 47}, 12, ASN_INTEGER
, { .integer
= 1 }},
888 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 118}, 12, ASN_INTEGER
, { .integer
= 1 }},
889 /* lldpXdot1RemVlanName */
890 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 47}, 12, ASN_OCTET_STR
,
891 { .string
= { .octet
= "VLAN #47", .len
= 8 }} },
892 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 49}, 12, ASN_OCTET_STR
,
893 { .string
= { .octet
= "VLAN #49", .len
= 8 }} },
894 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR
,
895 { .string
= { .octet
= "VLAN #1449", .len
= 10 }} },
896 /* lldpXdot1RemProtocolId */
897 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30321}, 12, ASN_OCTET_STR
,
898 { .string
= { .octet
= "\x88\x8e\x01", .len
= 3 } }},
899 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30515}, 12, ASN_OCTET_STR
,
900 { .string
= { .octet
= "\x88\xcc", .len
= 2 } }}
905 tohex(char *str
, size_t len
)
907 static char *hex
[] = { NULL
, NULL
};
908 static int which
= 0;
909 free(hex
[which
]); hex
[which
] = NULL
;
910 hex
[which
] = malloc(len
* 3 + 1);
911 fail_unless(hex
[which
] != NULL
, "Not enough memory?");
912 for (size_t i
= 0; i
< len
; i
++)
913 snprintf(hex
[which
] + 3*i
, 4, "%02X ", (unsigned char)str
[i
]);
915 return hex
[1 - which
];
919 snmp_is_prefix_of(struct variable8
*vp
, struct tree_node
*n
, char *repr
)
921 if (n
->namelen
< vp
->namelen
) return 0;
924 vp
->namelen
* sizeof(oid
)))
926 fail_unless(n
->type
== vp
->type
, "Inappropriate type for OID %s", repr
);
931 snmp_merge(struct variable8
*v1
, struct tree_node
*n
, struct variable
*vp
,
932 oid
*target
, size_t *targetlen
)
934 vp
->magic
= v1
->magic
;
937 vp
->findVar
= v1
->findVar
;
938 vp
->namelen
= v1
->namelen
+
939 sizeof(lldp_oid
)/sizeof(oid
);
940 memcpy(vp
->name
, lldp_oid
, sizeof(lldp_oid
));
941 memcpy(vp
->name
+ sizeof(lldp_oid
)/sizeof(oid
),
943 v1
->namelen
*sizeof(oid
));
944 *targetlen
= n
->namelen
+
945 sizeof(lldp_oid
)/sizeof(oid
);
946 memcpy(target
, lldp_oid
, sizeof(lldp_oid
));
947 memcpy(target
+ sizeof(lldp_oid
)/sizeof(oid
),
949 n
->namelen
* sizeof(oid
));
953 snmp_compare(struct tree_node
*n
,
954 u_char
*result
, size_t varlen
,
955 oid
*target
, size_t targetlen
, char *repr
)
957 unsigned long int value
;
958 fail_unless((targetlen
== sizeof(lldp_oid
)/sizeof(oid
) + n
->namelen
) &&
959 !memcmp(target
, lldp_oid
, sizeof(lldp_oid
)) &&
960 !memcmp(target
+ sizeof(lldp_oid
)/sizeof(oid
),
962 n
->namelen
* sizeof(oid
)),
963 "Bad OID returned when querying %s: got %s", repr
,
964 snmp_oidrepr(target
, targetlen
));
970 fail_unless(varlen
== sizeof(unsigned long int),
971 "Inappropriate length for integer type for OID %s",
973 memcpy(&value
, result
, sizeof(value
));
974 fail_unless(n
->value
.integer
== value
,
975 "For OID %s, expected value %u but got %u instead",
981 fail_unless(((n
->value
.string
.len
== varlen
) &&
982 !memcmp(n
->value
.string
.octet
,
984 "OID %s: wanted %s, got %s",
986 tohex(n
->value
.string
.octet
, n
->value
.string
.len
),
987 tohex((char *)result
, varlen
));
991 START_TEST (test_variable_order
)
994 for (i
= 0; i
< agent_lldp_vars_size() - 1; i
++) {
995 fail_unless(snmp_oid_compare(agent_lldp_vars
[i
].name
,
996 agent_lldp_vars
[i
].namelen
,
997 agent_lldp_vars
[i
+1].name
,
998 agent_lldp_vars
[i
+1].namelen
) < 0,
999 "Registered OID are out of orders (see %s and next one)",
1000 snmp_oidrepr(agent_lldp_vars
[i
].name
,
1001 agent_lldp_vars
[i
].namelen
));
1006 START_TEST (test_get
)
1010 j
< sizeof(snmp_tree
)/sizeof(struct tree_node
);
1015 oid target
[MAX_OID_LEN
];
1019 WriteMethod
*wmethod
;
1020 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
1021 snmp_tree
[j
].namelen
);
1023 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
1024 /* Search for the appropriate prefix. */
1025 if (!snmp_is_prefix_of(&agent_lldp_vars
[i
], &snmp_tree
[j
],
1028 /* We have our prefix. Fill out the vp struct
1029 correctly. We need to complete OID with
1031 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
1033 /* Invoke the function */
1034 result
= vp
.findVar(&vp
, target
, &targetlen
, 1, &varlen
, &wmethod
);
1036 /* Check the result */
1037 fail_unless(result
!= NULL
,
1038 "No result when querying %s", repr
);
1039 snmp_compare(&snmp_tree
[j
], result
, varlen
, target
, targetlen
, repr
);
1045 fail("OID %s not found", repr
);
1050 START_TEST (test_getnext
)
1053 size_t end
= sizeof(snmp_tree
)/sizeof(struct tree_node
);
1059 oid target
[MAX_OID_LEN
];
1062 u_char
*result
= NULL
;
1063 WriteMethod
*wmethod
;
1064 char *repr
= snmp_oidrepr(snmp_tree
[j
].name
,
1065 snmp_tree
[j
].namelen
);
1066 for (i
= 0; i
< agent_lldp_vars_size(); i
++) {
1067 snmp_merge(&agent_lldp_vars
[i
], &snmp_tree
[j
], &vp
, target
, &targetlen
);
1068 result
= vp
.findVar(&vp
, target
, &targetlen
, 0, &varlen
, &wmethod
);
1069 if (result
) /* Check next! */
1073 fail_unless(j
== end
- 1,
1074 "No next result found for %s", repr
);
1077 fail_unless(j
< end
- 1,
1078 "More results after %s", repr
);
1080 /* For unknown reasons, snmp_compare can be executed
1081 even when the above test fails... */
1083 snmp_compare(&snmp_tree
[j
+1], result
, varlen
, target
, targetlen
, repr
);
1092 Suite
*s
= suite_create("SNMP");
1094 TCase
*tc_snmp
= tcase_create("SNMP");
1095 tcase_add_checked_fixture(tc_snmp
, snmp_config
, NULL
);
1096 tcase_add_test(tc_snmp
, test_variable_order
);
1097 tcase_add_test(tc_snmp
, test_get
);
1098 tcase_add_test(tc_snmp
, test_getnext
);
1099 suite_add_tcase(s
, tc_snmp
);
1108 Suite
*s
= snmp_suite();
1109 SRunner
*sr
= srunner_create(s
);
1110 srunner_run_all(sr
, CK_ENV
);
1111 number_failed
= srunner_ntests_failed(sr
);
1113 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;