]> git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/check_snmp.c
tests: correctly encode civic address for SNMP tests
[thirdparty/lldpd.git] / tests / check_snmp.c
1 /* -*- mode: c; c-file-style: "openbsd" -*- */
2 /*
3 * Copyright (c) 2015 Vincent Bernat <bernat@luffy.cx>
4 *
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.
8 *
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.
16 */
17
18 #include <check.h>
19
20 #include "../src/daemon/lldpd.h"
21 #include "../src/daemon/agent.h"
22
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>
27
28 extern struct lldpd *agent_scfg;
29 extern struct timeval starttime;
30 extern struct variable8 agent_lldp_vars[];
31
32 /* Our test config */
33 struct lldpd test_cfg = {
34 .g_config = {
35 .c_tx_interval = 30,
36 .c_smart = 0
37 }
38 };
39 struct timeval test_starttime = { .tv_sec = 100, .tv_usec = 0 };
40
41 /* First chassis */
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),
46 .m_iface = 3
47 };
48 struct lldpd_chassis chassis1 = {
49 .c_index = 1,
50 .c_protocol = LLDPD_MODE_LLDP,
51 .c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR,
52 .c_id = "AAA012",
53 .c_id_len = 6,
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,
58 .c_ttl = 60,
59 #ifdef ENABLE_LLDPMED
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",
71 #endif
72 };
73 /* Second chassis */
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),
78 .m_iface = 5
79 };
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),
87 .m_iface = 5
88 };
89 struct lldpd_chassis chassis2 = {
90 .c_index = 4,
91 .c_protocol = LLDPD_MODE_LLDP,
92 .c_id_subtype = LLDP_CHASSISID_SUBTYPE_LOCAL,
93 .c_id = "chassis2",
94 .c_id_len = 6,
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,
99 .c_ttl = 60,
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",
108 #endif
109 };
110
111 /* First port of first chassis */
112 struct lldpd_hardware hardware1 = {
113 .h_ifindex = 3,
114 .h_tx_cnt = 1352,
115 .h_rx_cnt = 1458,
116 .h_rx_discarded_cnt = 5,
117 .h_rx_unrecognized_cnt = 4,
118 .h_insert_cnt = 100,
119 .h_delete_cnt = 5,
120 .h_ageout_cnt = 20,
121 .h_drop_cnt = 1,
122 .h_lport = {
123 .p_chassis = &chassis1,
124 .p_lastchange = 200,
125 .p_protocol = LLDPD_MODE_LLDP,
126 .p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR,
127 .p_id = "AAA012",
128 .p_id_len = 6,
129 .p_descr = "eth2",
130 .p_mfs = 1600,
131 #ifdef ENABLE_DOT3
132 .p_aggregid = 0,
133 .p_macphy = {
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,
138 },
139 .p_power = {
140 .devicetype = LLDP_DOT3_POWER_PD,
141 .supported = 1,
142 .enabled = 1,
143 .paircontrol = 1,
144 .pairs = 2,
145 .class = 3,
146 .powertype = LLDP_DOT3_POWER_8023AT_TYPE2,
147 .source = LLDP_DOT3_POWER_SOURCE_BOTH,
148 .priority = LLDP_DOT3_POWER_PRIO_LOW,
149 .requested = 2000,
150 .allocated = 2500,
151 },
152 #endif
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,
156 .p_med_policy = {
157 { .type = 0 }, { .type = 0 }, {
158 .type = LLDP_MED_APPTYPE_GUESTVOICE,
159 .unknown = 1,
160 .tagged = 1,
161 .vid = 475,
162 .priority = 3,
163 .dscp = 62
164 }, { .type = 0 }, { .type = 0 }, { .type = 0 }, {
165 .type = LLDP_MED_APPTYPE_VIDEOSTREAM,
166 .unknown = 0,
167 .tagged = 1,
168 .vid = 472,
169 .priority = 1,
170 .dscp = 60
171 }, { .type = 0 }
172 },
173 .p_med_location = {
174 { .format = 0 }, {
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",
178 .data_len = 22,
179 }, { .format = 0 }
180 },
181 .p_med_power = {
182 .devicetype = LLDP_MED_POW_TYPE_PD,
183 .source = LLDP_MED_POW_SOURCE_LOCAL,
184 .priority = LLDP_MED_POW_PRIO_HIGH,
185 .val = 100
186 },
187 #endif
188 #ifdef ENABLE_DOT1
189 .p_pvid = 47,
190 /* Remaining is done is snmp_config */
191 #endif
192 }
193 };
194 /* Second port of first chassis */
195 struct lldpd_hardware hardware2 = {
196 .h_ifindex = 4,
197 .h_tx_cnt = 11352,
198 .h_rx_cnt = 11458,
199 .h_rx_discarded_cnt = 55,
200 .h_rx_unrecognized_cnt = 14,
201 .h_insert_cnt = 1000,
202 .h_delete_cnt = 51,
203 .h_ageout_cnt = 210,
204 .h_drop_cnt = 1,
205 .h_lport = {
206 .p_chassis = &chassis1,
207 .p_lastchange = 50,
208 .p_protocol = LLDPD_MODE_LLDP,
209 .p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME,
210 .p_id = "eth4",
211 .p_id_len = 4,
212 .p_descr = "Intel 1000 GE",
213 .p_mfs = 9000,
214 #ifdef ENABLE_DOT3
215 .p_aggregid = 3,
216 .p_macphy = {
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,
221 },
222 #endif
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,
226 .p_med_policy = {
227 { .type = 0 }, { .type = 0 }, {
228 .type = LLDP_MED_APPTYPE_GUESTVOICE,
229 .unknown = 1,
230 .tagged = 1,
231 .vid = 475,
232 .priority = 3,
233 .dscp = 62
234 }, { .type = 0 }, { .type = 0 }, {
235 .type = LLDP_MED_APPTYPE_VIDEOCONFERENCE,
236 .unknown = 0,
237 .tagged = 0,
238 .vid = 1007,
239 .priority = 1,
240 .dscp = 49
241 }, { .type = 0 }, { .type = 0 }
242 },
243 .p_med_location = {
244 {
245 .format = LLDP_MED_LOCFORMAT_COORD,
246 .data = "Not interpreted",
247 .data_len = 15,
248 }, { .format = 0 }, { .format = 0 },
249 },
250 #endif
251 }
252 };
253
254 #ifdef ENABLE_DOT1
255 struct lldpd_vlan vlan47 = {
256 .v_name = "VLAN #47",
257 .v_vid = 47,
258 };
259 struct lldpd_vlan vlan49 = {
260 .v_name = "VLAN #49",
261 .v_vid = 49,
262 };
263 struct lldpd_vlan vlan1449 = {
264 .v_name = "VLAN #1449",
265 .v_vid = 1449,
266 };
267 struct lldpd_ppvid ppvid47 = {
268 .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
269 .p_ppvid = 47,
270 };
271 struct lldpd_ppvid ppvid118 = {
272 .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
273 .p_ppvid = 118,
274 };
275 struct lldpd_pi pi88cc = {
276 .p_pi = "\x88\xcc",
277 .p_pi_len = 2,
278 };
279 struct lldpd_pi pi888e01 = {
280 .p_pi = "\x88\x8e\x01",
281 .p_pi_len = 3,
282 };
283 #endif
284
285 /* First port of second chassis */
286 struct lldpd_port port2 = {
287 .p_chassis = &chassis2,
288 .p_lastchange = 180,
289 .p_protocol = LLDPD_MODE_LLDP,
290 .p_id_subtype = LLDP_PORTID_SUBTYPE_IFALIAS,
291 .p_id = "Giga1/7",
292 .p_id_len = 7,
293 .p_descr = "Gigabit Ethernet 1/7",
294 };
295
296 void
297 snmp_config()
298 {
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);
312 #ifdef ENABLE_DOT1
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);
329 #endif
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);
335 }
336
337 /* Convert OID to a string. Static buffer. */
338 char*
339 snmp_oidrepr(oid *name, size_t namelen)
340 {
341 static char *buffer[4] = {NULL, NULL, NULL, NULL};
342 static int current = 0;
343 size_t i;
344
345 current = (current + 1)%4;
346 free(buffer[current]); buffer[current] = NULL;
347
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;
355 return NULL;
356 }
357 free(buffer[current]);
358 buffer[current] = newbuffer;
359 }
360 return buffer[current++];
361 }
362
363 struct tree_node {
364 oid name[MAX_OID_LEN];
365 size_t namelen;
366 int type; /* ASN_* */
367 union {
368 unsigned long int integer;
369 struct {
370 char *octet;
371 size_t len;
372 } string;
373 } value;
374 };
375
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 */
388
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 */
403
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",
407 .len = 6 } }},
408 /* lldpLocSysName */
409 { {1, 3, 3, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "chassis1.example.com",
410 .len = 20 } }},
411 /* lldpLocSysDesc */
412 { {1, 3, 4, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "First chassis",
413 .len = 13 } }},
414 /* lldpLocSysCapSupported */
415 { {1, 3, 5, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x38",
416 .len = 1 } }},
417 /* lldpLocSysCapEnabled */
418 { {1, 3, 6, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x8",
419 .len = 1 } }},
420
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",
425 .len = 6 } }},
426 /* lldpLocPortId.4 */
427 { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "eth4",
428 .len = 4 } }},
429 /* lldpLocPortDesc.3 */
430 { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR, { .string = { .octet = "eth2",
431 .len = 4 } }},
432 /* lldpLocPortDesc.4 */
433 { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "Intel 1000 GE",
434 .len = 13 } }},
435
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) }} },
443
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",
452 .len = 6 }} },
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 } },
458 /* lldpRemPortId */
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 }} },
470 /* lldpRemSysName */
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 }} },
477 /* lldpRemSysDesc */
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 }} },
498
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) }} },
528
529 #ifdef ENABLE_DOT3
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 }},
544
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 }},
570
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 }},
579
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 }},
583
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 }},
603
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 }},
629
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 }},
641
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 }},
645 #endif
646 #ifdef ENABLE_LLDPMED
647 /* lldpXMedLocDeviceClass */
648 { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER, { .integer = 2 }},
649
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 }},
675
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 }} },
694
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 }} },
700
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 }},
709
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 }},
723
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 }},
749
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 }} },
780
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 }} },
786
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 }},
790
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 }},
797
798 #endif
799 #ifdef ENABLE_DOT1
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 } }},
821
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 } }}
844 #endif
845 };
846
847 char*
848 tohex(char *str, size_t len)
849 {
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]);
857 which = 1 - which;
858 return hex[1 - which];
859 }
860
861 int
862 snmp_is_prefix_of(struct variable8 *vp, struct tree_node *n, char *repr)
863 {
864 if (n->namelen < vp->namelen) return 0;
865 if (memcmp(n->name,
866 vp->name,
867 vp->namelen * sizeof(oid)))
868 return 0;
869 fail_unless(n->type == vp->type, "Inappropriate type for OID %s", repr);
870 return 1;
871 }
872
873 void
874 snmp_merge(struct variable8 *v1, struct tree_node *n, struct variable *vp,
875 oid *target, size_t *targetlen)
876 {
877 vp->magic = v1->magic;
878 vp->type = v1->type;
879 vp->acl = v1->acl;
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),
885 v1->name,
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),
891 n->name,
892 n->namelen * sizeof(oid));
893 }
894
895 void
896 snmp_compare(struct tree_node *n,
897 u_char *result, size_t varlen,
898 oid *target, size_t targetlen, char *repr)
899 {
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),
904 n->name,
905 n->namelen * sizeof(oid)),
906 "Bad OID returned when querying %s: got %s", repr,
907 snmp_oidrepr(target, targetlen));
908 switch (n->type) {
909 case ASN_INTEGER:
910 case ASN_TIMETICKS:
911 case ASN_GAUGE:
912 case ASN_COUNTER:
913 fail_unless(varlen == sizeof(unsigned long int),
914 "Inappropriate length for integer type for OID %s",
915 repr);
916 memcpy(&value, result, sizeof(value));
917 fail_unless(n->value.integer == value,
918 "For OID %s, expected value %u but got %u instead",
919 repr,
920 n->value.integer,
921 value);
922 break;
923 default:
924 fail_unless(((n->value.string.len == varlen) &&
925 !memcmp(n->value.string.octet,
926 result, varlen)),
927 "OID %s: wanted %s, got %s",
928 repr,
929 tohex(n->value.string.octet, n->value.string.len),
930 tohex((char *)result, varlen));
931 }
932 }
933
934 START_TEST (test_variable_order)
935 {
936 size_t i;
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));
945 }
946 }
947 END_TEST
948
949 START_TEST (test_get)
950 {
951 size_t j;
952 for (j = 0;
953 j < sizeof(snmp_tree)/sizeof(struct tree_node);
954 j++) {
955 size_t i;
956 int found = 0;
957 struct variable vp;
958 oid target[MAX_OID_LEN];
959 size_t targetlen;
960 size_t varlen;
961 u_char *result;
962 WriteMethod *wmethod;
963 char *repr = snmp_oidrepr(snmp_tree[j].name,
964 snmp_tree[j].namelen);
965
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],
969 repr)) continue;
970
971 /* We have our prefix. Fill out the vp struct
972 correctly. We need to complete OID with
973 LLDP prefix. */
974 snmp_merge(&agent_lldp_vars[i], &snmp_tree[j], &vp, target, &targetlen);
975
976 /* Invoke the function */
977 result = vp.findVar(&vp, target, &targetlen, 1, &varlen, &wmethod);
978
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);
983
984 found = 1;
985 break;
986 }
987 if (!found)
988 fail("OID %s not found", repr);
989 }
990 }
991 END_TEST
992
993 START_TEST (test_getnext)
994 {
995 size_t j;
996 size_t end = sizeof(snmp_tree)/sizeof(struct tree_node);
997 for (j = 0;
998 j < end;
999 j++) {
1000 size_t i;
1001 struct variable vp;
1002 oid target[MAX_OID_LEN];
1003 size_t targetlen;
1004 size_t varlen;
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! */
1013 break;
1014 }
1015 if (!result) {
1016 fail_unless(j == end - 1,
1017 "No next result found for %s", repr);
1018 return;
1019 }
1020 fail_unless(j < end - 1,
1021 "More results after %s", repr);
1022
1023 /* For unknown reasons, snmp_compare can be executed
1024 even when the above test fails... */
1025 if (j < end - 1)
1026 snmp_compare(&snmp_tree[j+1], result, varlen, target, targetlen, repr);
1027
1028 }
1029 }
1030 END_TEST
1031
1032 Suite *
1033 snmp_suite(void)
1034 {
1035 Suite *s = suite_create("SNMP");
1036
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);
1043
1044 return s;
1045 }
1046
1047 int
1048 main()
1049 {
1050 int number_failed;
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);
1055 srunner_free(sr);
1056 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
1057 }