]> git.ipfire.org Git - thirdparty/lldpd.git/blob - tests/check_snmp.c
tests: request CAP_DAC_OVERRIDE
[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_ttl = 60,
37 .c_smart = 0
38 }
39 };
40 struct timeval test_starttime = { .tv_sec = 100, .tv_usec = 0 };
41
42 /* First chassis */
43 struct lldpd_mgmt mgmt1 = {
44 .m_family = LLDPD_AF_IPV4,
45 .m_addr = { .octets = { 0xc0, 0, 0x2, 0xf } }, /* 192.0.2.15 */
46 .m_addrsize = sizeof(struct in_addr),
47 .m_iface = 3
48 };
49 struct lldpd_chassis chassis1 = {
50 .c_index = 1,
51 .c_protocol = LLDPD_MODE_LLDP,
52 .c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR,
53 .c_id = "AAA012",
54 .c_id_len = 6,
55 .c_name = "chassis1.example.com",
56 .c_descr = "First chassis",
57 .c_cap_available = LLDP_CAP_BRIDGE | LLDP_CAP_WLAN | LLDP_CAP_ROUTER,
58 .c_cap_enabled = LLDP_CAP_ROUTER,
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 #ifdef ENABLE_LLDPMED
100 .c_med_hw = "Hardware 2",
101 /* We skip c_med_fw */
102 .c_med_sw = "Software 2",
103 .c_med_sn = "00-00-0000-AAAC",
104 .c_med_manuf = "Manufacturer 2",
105 .c_med_model = "Model 2",
106 .c_med_asset = "Asset 2",
107 #endif
108 };
109
110 /* First port of first chassis */
111 struct lldpd_hardware hardware1 = {
112 .h_ifindex = 3,
113 .h_tx_cnt = 1352,
114 .h_rx_cnt = 1458,
115 .h_rx_discarded_cnt = 5,
116 .h_rx_unrecognized_cnt = 4,
117 .h_insert_cnt = 100,
118 .h_delete_cnt = 5,
119 .h_ageout_cnt = 20,
120 .h_drop_cnt = 1,
121 .h_lport = {
122 .p_chassis = &chassis1,
123 .p_lastchange = 200,
124 .p_protocol = LLDPD_MODE_LLDP,
125 .p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR,
126 .p_id = "AAA012",
127 .p_id_len = 6,
128 .p_descr = "eth2",
129 .p_mfs = 1600,
130 #ifdef ENABLE_DOT3
131 .p_aggregid = 0,
132 .p_macphy = {
133 .autoneg_support = 1,
134 .autoneg_enabled = 1,
135 .autoneg_advertised = LLDP_DOT3_LINK_AUTONEG_100BASE_TX | LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD,
136 .mau_type = LLDP_DOT3_MAU_100BASETXFD,
137 },
138 .p_power = {
139 .devicetype = LLDP_DOT3_POWER_PD,
140 .supported = 1,
141 .enabled = 1,
142 .paircontrol = 1,
143 .pairs = 2,
144 .class = 3,
145 .powertype = LLDP_DOT3_POWER_8023AT_TYPE2,
146 .source = LLDP_DOT3_POWER_SOURCE_BOTH,
147 .priority = LLDP_DOT3_POWER_PRIO_LOW,
148 .requested = 2000,
149 .allocated = 2500,
150 },
151 #endif
152 #ifdef ENABLE_LLDPMED
153 .p_med_cap_enabled = LLDP_MED_CAP_CAP | LLDP_MED_CAP_IV | LLDP_MED_CAP_MDI_PD |
154 LLDP_MED_CAP_POLICY | LLDP_MED_CAP_LOCATION,
155 .p_med_policy = {
156 { .type = 0 }, { .type = 0 }, {
157 .type = LLDP_MED_APPTYPE_GUESTVOICE,
158 .unknown = 1,
159 .tagged = 1,
160 .vid = 475,
161 .priority = 3,
162 .dscp = 62
163 }, { .type = 0 }, { .type = 0 }, { .type = 0 }, {
164 .type = LLDP_MED_APPTYPE_VIDEOSTREAM,
165 .unknown = 0,
166 .tagged = 1,
167 .vid = 472,
168 .priority = 1,
169 .dscp = 60
170 }, { .type = 0 }
171 },
172 .p_med_location = {
173 { .format = 0 }, {
174 .format = LLDP_MED_LOCFORMAT_CIVIC,
175 /* 2:FR:6:Commercial Rd:19:4 */
176 .data = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4",
177 .data_len = 22,
178 }, { .format = 0 }
179 },
180 .p_med_power = {
181 .devicetype = LLDP_MED_POW_TYPE_PD,
182 .source = LLDP_MED_POW_SOURCE_LOCAL,
183 .priority = LLDP_MED_POW_PRIO_HIGH,
184 .val = 100
185 },
186 #endif
187 #ifdef ENABLE_DOT1
188 .p_pvid = 47,
189 /* Remaining is done is snmp_config */
190 #endif
191 }
192 };
193 /* Second port of first chassis */
194 struct lldpd_hardware hardware2 = {
195 .h_ifindex = 4,
196 .h_tx_cnt = 11352,
197 .h_rx_cnt = 11458,
198 .h_rx_discarded_cnt = 55,
199 .h_rx_unrecognized_cnt = 14,
200 .h_insert_cnt = 1000,
201 .h_delete_cnt = 51,
202 .h_ageout_cnt = 210,
203 .h_drop_cnt = 1,
204 .h_lport = {
205 .p_chassis = &chassis1,
206 .p_lastchange = 50,
207 .p_protocol = LLDPD_MODE_LLDP,
208 .p_id_subtype = LLDP_PORTID_SUBTYPE_IFNAME,
209 .p_id = "eth4",
210 .p_id_len = 4,
211 .p_descr = "Intel 1000 GE",
212 .p_mfs = 9000,
213 #ifdef ENABLE_DOT3
214 .p_aggregid = 3,
215 .p_macphy = {
216 .autoneg_support = 1,
217 .autoneg_enabled = 1,
218 .autoneg_advertised = LLDP_DOT3_LINK_AUTONEG_100BASE_TXFD | LLDP_DOT3_LINK_AUTONEG_1000BASE_TFD,
219 .mau_type = LLDP_DOT3_MAU_1000BASETFD,
220 },
221 #endif
222 #ifdef ENABLE_LLDPMED
223 .p_med_cap_enabled = LLDP_MED_CAP_CAP | LLDP_MED_CAP_IV | LLDP_MED_CAP_MDI_PD |
224 LLDP_MED_CAP_MDI_PSE | LLDP_MED_CAP_POLICY | LLDP_MED_CAP_LOCATION,
225 .p_med_policy = {
226 { .type = 0 }, { .type = 0 }, {
227 .type = LLDP_MED_APPTYPE_GUESTVOICE,
228 .unknown = 1,
229 .tagged = 1,
230 .vid = 475,
231 .priority = 3,
232 .dscp = 62
233 }, { .type = 0 }, { .type = 0 }, {
234 .type = LLDP_MED_APPTYPE_VIDEOCONFERENCE,
235 .unknown = 0,
236 .tagged = 0,
237 .vid = 1007,
238 .priority = 1,
239 .dscp = 49
240 }, { .type = 0 }, { .type = 0 }
241 },
242 .p_med_location = {
243 {
244 .format = LLDP_MED_LOCFORMAT_COORD,
245 .data = "Not interpreted",
246 .data_len = 15,
247 }, { .format = 0 }, { .format = 0 },
248 },
249 #endif
250 }
251 };
252
253 #ifdef ENABLE_DOT1
254 struct lldpd_vlan vlan47 = {
255 .v_name = "VLAN #47",
256 .v_vid = 47,
257 };
258 struct lldpd_vlan vlan49 = {
259 .v_name = "VLAN #49",
260 .v_vid = 49,
261 };
262 struct lldpd_vlan vlan1449 = {
263 .v_name = "VLAN #1449",
264 .v_vid = 1449,
265 };
266 struct lldpd_ppvid ppvid47 = {
267 .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
268 .p_ppvid = 47,
269 };
270 struct lldpd_ppvid ppvid118 = {
271 .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED,
272 .p_ppvid = 118,
273 };
274 struct lldpd_pi pi88cc = {
275 .p_pi = "\x88\xcc",
276 .p_pi_len = 2,
277 };
278 struct lldpd_pi pi888e01 = {
279 .p_pi = "\x88\x8e\x01",
280 .p_pi_len = 3,
281 };
282 #endif
283
284 /* First port of second chassis */
285 struct lldpd_port port2 = {
286 .p_chassis = &chassis2,
287 .p_lastchange = 180,
288 .p_protocol = LLDPD_MODE_LLDP,
289 .p_id_subtype = LLDP_PORTID_SUBTYPE_IFALIAS,
290 .p_id = "Giga1/7",
291 .p_id_len = 7,
292 .p_descr = "Gigabit Ethernet 1/7",
293 };
294
295 void
296 snmp_config()
297 {
298 starttime = test_starttime;
299 agent_scfg = &test_cfg;
300 TAILQ_INIT(&test_cfg.g_chassis);
301 TAILQ_INIT(&chassis1.c_mgmt);
302 TAILQ_INSERT_TAIL(&chassis1.c_mgmt, &mgmt1, m_entries);
303 TAILQ_INSERT_TAIL(&test_cfg.g_chassis, &chassis1, c_entries);
304 TAILQ_INIT(&chassis2.c_mgmt);
305 TAILQ_INSERT_TAIL(&chassis2.c_mgmt, &mgmt2, m_entries);
306 TAILQ_INSERT_TAIL(&chassis2.c_mgmt, &mgmt3, m_entries);
307 TAILQ_INSERT_TAIL(&test_cfg.g_chassis, &chassis2, c_entries);
308 TAILQ_INIT(&test_cfg.g_hardware);
309 TAILQ_INSERT_TAIL(&test_cfg.g_hardware, &hardware1, h_entries);
310 TAILQ_INSERT_TAIL(&test_cfg.g_hardware, &hardware2, h_entries);
311 #ifdef ENABLE_DOT1
312 TAILQ_INIT(&hardware1.h_lport.p_vlans);
313 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_vlans, &vlan47, v_entries);
314 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_vlans, &vlan49, v_entries);
315 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_vlans, &vlan1449, v_entries);
316 TAILQ_INIT(&hardware1.h_lport.p_ppvids);
317 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_ppvids, &ppvid47, p_entries);
318 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_ppvids, &ppvid118, p_entries);
319 TAILQ_INIT(&hardware1.h_lport.p_pids);
320 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_pids, &pi88cc, p_entries);
321 TAILQ_INSERT_TAIL(&hardware1.h_lport.p_pids, &pi888e01, p_entries);
322 TAILQ_INIT(&hardware2.h_lport.p_vlans);
323 TAILQ_INIT(&hardware2.h_lport.p_ppvids);
324 TAILQ_INIT(&hardware2.h_lport.p_pids);
325 TAILQ_INIT(&port2.p_vlans);
326 TAILQ_INIT(&port2.p_ppvids);
327 TAILQ_INIT(&port2.p_pids);
328 #endif
329 TAILQ_INIT(&hardware1.h_rports);
330 TAILQ_INSERT_TAIL(&hardware1.h_rports, &port2, p_entries);
331 TAILQ_INSERT_TAIL(&hardware1.h_rports, &hardware2.h_lport, p_entries);
332 TAILQ_INIT(&hardware2.h_rports);
333 TAILQ_INSERT_TAIL(&hardware2.h_rports, &hardware1.h_lport, p_entries);
334 }
335
336 /* Convert OID to a string. Static buffer. */
337 char*
338 snmp_oidrepr(oid *name, size_t namelen)
339 {
340 static char *buffer[4] = {NULL, NULL, NULL, NULL};
341 static int current = 0;
342 size_t i;
343
344 current = (current + 1)%4;
345 free(buffer[current]); buffer[current] = NULL;
346
347 for (i = 0; i < namelen; i++) {
348 /* Not very efficient... */
349 char *newbuffer = NULL;
350 if (asprintf(&newbuffer, "%s.%lu", buffer[current]?buffer[current]:"",
351 (unsigned long)name[i]) == -1) {
352 free(buffer[current]);
353 buffer[current] = NULL;
354 return NULL;
355 }
356 free(buffer[current]);
357 buffer[current] = newbuffer;
358 }
359 return buffer[current++];
360 }
361
362 struct tree_node {
363 oid name[MAX_OID_LEN];
364 size_t namelen;
365 int type; /* ASN_* */
366 union {
367 unsigned long int integer;
368 struct {
369 char *octet;
370 size_t len;
371 } string;
372 } value;
373 };
374
375 static oid zeroDotZero[2] = {0, 0};
376 struct tree_node snmp_tree[] = {
377 { {1, 1, 1, 0}, 4, ASN_INTEGER, { .integer = 30 } }, /* lldpMessageTxInterval */
378 { {1, 1, 2, 0}, 4, ASN_INTEGER, { .integer = 2 } }, /* lldpMessageTxHoldMultiplier */
379 { {1, 1, 3, 0}, 4, ASN_INTEGER, { .integer = 1 } }, /* lldpReinitDelay */
380 { {1, 1, 4, 0}, 4, ASN_INTEGER, { .integer = 1 } }, /* lldpTxDelay */
381 { {1, 1, 5, 0}, 4, ASN_INTEGER, { .integer = 5 } }, /* lldpNotificationInterval */
382 { {1, 2, 1, 0}, 4, ASN_TIMETICKS, { .integer = 10000 } },/* lldpStatsRemTablesLastChangeTime */
383 { {1, 2, 2, 0}, 4, ASN_GAUGE, { .integer = 1100 } }, /* lldpStatsRemTablesInserts */
384 { {1, 2, 3, 0}, 4, ASN_GAUGE, { .integer = 56 } }, /* lldpStatsRemTablesDeletes */
385 { {1, 2, 4, 0}, 4, ASN_GAUGE, { .integer = 2 } }, /* lldpStatsRemTablesDrops */
386 { {1, 2, 5, 0}, 4, ASN_GAUGE, { .integer = 230 } }, /* lldpStatsRemTablesAgeouts */
387
388 { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER, { .integer = 1352 } }, /* lldpStatsTxPortFramesTotal.3 */
389 { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER, { .integer = 11352 } }, /* lldpStatsTxPortFramesTotal.4 */
390 { {1, 2, 7, 1, 2, 3}, 6, ASN_COUNTER, { .integer = 5 } }, /* lldpStatsRxPortFramesDiscardedTotal.3 */
391 { {1, 2, 7, 1, 2, 4}, 6, ASN_COUNTER, { .integer = 55 } }, /* lldpStatsRxPortFramesDiscardedTotal.4 */
392 { {1, 2, 7, 1, 3, 3}, 6, ASN_COUNTER, { .integer = 5 } }, /* lldpStatsRxPortFramesError.3 */
393 { {1, 2, 7, 1, 3, 4}, 6, ASN_COUNTER, { .integer = 55 } }, /* lldpStatsRxPortFramesError.4 */
394 { {1, 2, 7, 1, 4, 3}, 6, ASN_COUNTER, { .integer = 1458 } }, /* lldpStatsRxPortFramesTotal.3 */
395 { {1, 2, 7, 1, 4, 4}, 6, ASN_COUNTER, { .integer = 11458 } }, /* lldpStatsRxPortFramesTotal.4 */
396 { {1, 2, 7, 1, 5, 3}, 6, ASN_COUNTER, { .integer = 4 } }, /* lldpStatsRxPortTLVsDiscardedTotal.3 */
397 { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */
398 { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER, { .integer = 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */
399 { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */
400 { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE, { .integer = 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */
401 { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE, { .integer = 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */
402
403 { {1, 3, 1, 0}, 4, ASN_INTEGER, { .integer = 4 } }, /* lldpLocChassisIdSubtype */
404 /* lldpLocChassisId */
405 { {1, 3, 2, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "AAA012",
406 .len = 6 } }},
407 /* lldpLocSysName */
408 { {1, 3, 3, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "chassis1.example.com",
409 .len = 20 } }},
410 /* lldpLocSysDesc */
411 { {1, 3, 4, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "First chassis",
412 .len = 13 } }},
413 /* lldpLocSysCapSupported */
414 { {1, 3, 5, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x38",
415 .len = 1 } }},
416 /* lldpLocSysCapEnabled */
417 { {1, 3, 6, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x8",
418 .len = 1 } }},
419
420 { {1, 3, 7, 1, 2, 3}, 6, ASN_INTEGER, { .integer = 3 } }, /* lldpLocPortIdSubtype.3 */
421 { {1, 3, 7, 1, 2, 4}, 6, ASN_INTEGER, { .integer = 5 } }, /* lldpLocPortIdSubtype.5 */
422 /* lldpLocPortId.3 */
423 { {1, 3, 7, 1, 3, 3}, 6, ASN_OCTET_STR, { .string = { .octet = "AAA012",
424 .len = 6 } }},
425 /* lldpLocPortId.4 */
426 { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "eth4",
427 .len = 4 } }},
428 /* lldpLocPortDesc.3 */
429 { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR, { .string = { .octet = "eth2",
430 .len = 4 } }},
431 /* lldpLocPortDesc.4 */
432 { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "Intel 1000 GE",
433 .len = 13 } }},
434
435 { {1, 3, 8, 1, 3, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 5 } }, /* lldpLocManAddrLen */
436 { {1, 3, 8, 1, 4, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 2 } }, /* lldpLocManAddrIfSubtype */
437 { {1, 3, 8, 1, 5, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 3 } }, /* lldpLocManAddrIfId */
438 /* lldpLocManAddrOID */
439 { {1, 3, 8, 1, 6, 1, 4, 192, 0, 2, 15}, 11, ASN_OBJECT_ID,
440 { .string = { .octet = (char *)zeroDotZero,
441 .len = sizeof(zeroDotZero) }} },
442
443 /* lldpRemChassisIdSubtype */
444 { {1, 4, 1, 1, 4, 0, 3, 1 }, 8, ASN_INTEGER, { .integer = 4 } },
445 { {1, 4, 1, 1, 4, 8000, 3, 4}, 8, ASN_INTEGER, { .integer = 7 } },
446 { {1, 4, 1, 1, 4, 10000, 4, 1}, 8, ASN_INTEGER, { .integer = 4 } },
447 /* lldpRemChassisId */
448 { {1, 4, 1, 1, 5, 0, 3, 1 }, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} },
449 { {1, 4, 1, 1, 5, 8000, 3, 4}, 8, ASN_OCTET_STR, { .string =
450 { .octet = "chassis2",
451 .len = 6 }} },
452 { {1, 4, 1, 1, 5, 10000, 4, 1}, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} },
453 /* lldpRemPortIdSubtype */
454 { {1, 4, 1, 1, 6, 0, 3, 1 }, 8, ASN_INTEGER, { .integer = 5 } },
455 { {1, 4, 1, 1, 6, 8000, 3, 4}, 8, ASN_INTEGER, { .integer = 1 } },
456 { {1, 4, 1, 1, 6, 10000, 4, 1}, 8, ASN_INTEGER, { .integer = 3 } },
457 /* lldpRemPortId */
458 { {1, 4, 1, 1, 7, 0, 3, 1 }, 8, ASN_OCTET_STR, { .string = { .octet = "eth4", .len = 4 }} },
459 { {1, 4, 1, 1, 7, 8000, 3, 4}, 8, ASN_OCTET_STR, { .string =
460 { .octet = "Giga1/7", .len = 7 }} },
461 { {1, 4, 1, 1, 7, 10000, 4, 1}, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} },
462 /* lldpRemPortDesc */
463 { {1, 4, 1, 1, 8, 0, 3, 1 }, 8, ASN_OCTET_STR,
464 { .string = { .octet = "Intel 1000 GE", .len = 13 }} },
465 { {1, 4, 1, 1, 8, 8000, 3, 4}, 8, ASN_OCTET_STR,
466 { .string = { .octet = "Gigabit Ethernet 1/7", .len = 20 }} },
467 { {1, 4, 1, 1, 8, 10000, 4, 1}, 8, ASN_OCTET_STR,
468 { .string = { .octet = "eth2", .len = 4 }} },
469 /* lldpRemSysName */
470 { {1, 4, 1, 1, 9, 0, 3, 1 }, 8, ASN_OCTET_STR,
471 { .string = { .octet = "chassis1.example.com", .len = 20 }} },
472 { {1, 4, 1, 1, 9, 8000, 3, 4}, 8, ASN_OCTET_STR,
473 { .string = { .octet = "chassis2.example.com", .len = 20 }} },
474 { {1, 4, 1, 1, 9, 10000, 4, 1}, 8, ASN_OCTET_STR,
475 { .string = { .octet = "chassis1.example.com", .len = 20 }} },
476 /* lldpRemSysDesc */
477 { {1, 4, 1, 1, 10, 0, 3, 1 }, 8, ASN_OCTET_STR,
478 { .string = { .octet = "First chassis", .len = 13 }} },
479 { {1, 4, 1, 1, 10, 8000, 3, 4}, 8, ASN_OCTET_STR,
480 { .string = { .octet = "Second chassis", .len = 14 }} },
481 { {1, 4, 1, 1, 10, 10000, 4, 1}, 8, ASN_OCTET_STR,
482 { .string = { .octet = "First chassis", .len = 13 }} },
483 /* lldpRemSysCapSupported */
484 { {1, 4, 1, 1, 11, 0, 3, 1 }, 8, ASN_OCTET_STR,
485 { .string = { .octet = "\x38", .len = 1 }} },
486 { {1, 4, 1, 1, 11, 8000, 3, 4}, 8, ASN_OCTET_STR,
487 { .string = { .octet = "\x8", .len = 1 }} },
488 { {1, 4, 1, 1, 11, 10000, 4, 1}, 8, ASN_OCTET_STR,
489 { .string = { .octet = "\x38", .len = 1 }} },
490 /* lldpRemSysCapEnabled */
491 { {1, 4, 1, 1, 12, 0, 3, 1 }, 8, ASN_OCTET_STR,
492 { .string = { .octet = "\x8", .len = 1 }} },
493 { {1, 4, 1, 1, 12, 8000, 3, 4}, 8, ASN_OCTET_STR,
494 { .string = { .octet = "\x8", .len = 1 }} },
495 { {1, 4, 1, 1, 12, 10000, 4, 1}, 8, ASN_OCTET_STR,
496 { .string = { .octet = "\x8", .len = 1 }} },
497
498 /* lldpRemManAddrIfSubtype */
499 { {1, 4, 2, 1, 3, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 2 } },
500 { {1, 4, 2, 1, 3, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER, { .integer = 2 } },
501 { {1, 4, 2, 1, 3, 8000, 3, 4, 2, 16,
502 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
503 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER, { .integer = 2 } },
504 { {1, 4, 2, 1, 3, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 2 } },
505 /* lldpRemManAddrIfId */
506 { {1, 4, 2, 1, 4, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 3 } },
507 { {1, 4, 2, 1, 4, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER, { .integer = 5 } },
508 { {1, 4, 2, 1, 4, 8000, 3, 4, 2, 16,
509 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
510 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER, { .integer = 5 } },
511 { {1, 4, 2, 1, 4, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 3 } },
512 /* lldpRemManAddrOID */
513 { {1, 4, 2, 1, 5, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID,
514 { .string = { .octet = (char *)zeroDotZero,
515 .len = sizeof(zeroDotZero) }} },
516 { {1, 4, 2, 1, 5, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_OBJECT_ID,
517 { .string = { .octet = (char *)zeroDotZero,
518 .len = sizeof(zeroDotZero) }} },
519 { {1, 4, 2, 1, 5, 8000, 3, 4, 2, 16,
520 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00,
521 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_OBJECT_ID,
522 { .string = { .octet = (char *)zeroDotZero,
523 .len = sizeof(zeroDotZero) }} },
524 { {1, 4, 2, 1, 5, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID,
525 { .string = { .octet = (char *)zeroDotZero,
526 .len = sizeof(zeroDotZero) }} },
527
528 #ifdef ENABLE_DOT3
529 /* lldpXdot3LocPortAutoNegSupported */
530 { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
531 { {1, 5, 4623, 1, 2, 1, 1, 1, 4 }, 9, ASN_INTEGER, { .integer = 1 }},
532 /* lldpXdot3LocPortAutoNegEnabled */
533 { {1, 5, 4623, 1, 2, 1, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
534 { {1, 5, 4623, 1, 2, 1, 1, 2, 4 }, 9, ASN_INTEGER, { .integer = 1 }},
535 /* lldpXdot3LocPortAutoNegAdvertisedCap */
536 { {1, 5, 4623, 1, 2, 1, 1, 3, 3 }, 9, ASN_OCTET_STR,
537 { .string = { .octet = "\x0c\x00", .len = 2 }} },
538 { {1, 5, 4623, 1, 2, 1, 1, 3, 4 }, 9, ASN_OCTET_STR,
539 { .string = { .octet = "\x04\x01", .len = 2 }} },
540 /* lldpXdot3LocPortOperMauType */
541 { {1, 5, 4623, 1, 2, 1, 1, 4, 3 }, 9, ASN_INTEGER, { .integer = 16 }},
542 { {1, 5, 4623, 1, 2, 1, 1, 4, 4 }, 9, ASN_INTEGER, { .integer = 30 }},
543
544 /* lldpXdot3LocPowerPortClass */
545 { {1, 5, 4623, 1, 2, 2, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 2 }},
546 /* lldpXdot3LocPowerMDISupported */
547 { {1, 5, 4623, 1, 2, 2, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
548 /* lldpXdot3LocPowerMDIEnabled */
549 { {1, 5, 4623, 1, 2, 2, 1, 3, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
550 /* lldpXdot3LocPowerPairControlable */
551 { {1, 5, 4623, 1, 2, 2, 1, 4, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
552 /* lldpXdot3LocPowerPairs */
553 { {1, 5, 4623, 1, 2, 2, 1, 5, 3 }, 9, ASN_INTEGER, { .integer = 2 }},
554 /* lldpXdot3LocPowerClass */
555 { {1, 5, 4623, 1, 2, 2, 1, 6, 3 }, 9, ASN_INTEGER, { .integer = 3 }},
556 /* As per 802.3at-2009, not sure of the OID... */
557 /* lldpXdot3LocPowerType */
558 { {1, 5, 4623, 1, 2, 2, 1, 7, 3 }, 9, ASN_OCTET_STR,
559 { .string = { .octet = "\xC0", .len = 1 } }},
560 /* lldpXdot3LocPowerSource */
561 { {1, 5, 4623, 1, 2, 2, 1, 8, 3 }, 9, ASN_OCTET_STR,
562 { .string = { .octet = "\xC0", .len = 1 } }},
563 /* lldpXdot3LocPowerPriority */
564 { {1, 5, 4623, 1, 2, 2, 1, 9, 3 }, 9, ASN_INTEGER, { .integer = 1 }},
565 /* lldpXdot3LocPDRequestedPowerValue */
566 { {1, 5, 4623, 1, 2, 2, 1, 10, 3 }, 9, ASN_INTEGER, { .integer = 2000 }},
567 /* lldpXdot3LocPSEAllocatedPowerValue */
568 { {1, 5, 4623, 1, 2, 2, 1, 11, 3 }, 9, ASN_INTEGER, { .integer = 2500 }},
569
570 /* lldpXdot3LocLinkAggStatus */
571 { {1, 5, 4623, 1, 2, 3, 1, 1, 3 }, 9, ASN_OCTET_STR,
572 { .string = { .octet = "\x00", .len = 1 }} },
573 { {1, 5, 4623, 1, 2, 3, 1, 1, 4 }, 9, ASN_OCTET_STR,
574 { .string = { .octet = "\xC0", .len = 1 }} },
575 /* lldpXdot3LocLinkAggPortId */
576 { {1, 5, 4623, 1, 2, 3, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 0 }},
577 { {1, 5, 4623, 1, 2, 3, 1, 2, 4 }, 9, ASN_INTEGER, { .integer = 3 }},
578
579 /* lldpXdot3LocMaxFrameSize */
580 { {1, 5, 4623, 1, 2, 4, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 1600 }},
581 { {1, 5, 4623, 1, 2, 4, 1, 1, 4 }, 9, ASN_INTEGER, { .integer = 9000 }},
582
583 /* lldpXdot3RemPortAutoNegSupported */
584 { {1, 5, 4623, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
585 { {1, 5, 4623, 1, 3, 1, 1, 1, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 2 }},
586 { {1, 5, 4623, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
587 /* lldpXdot3RemPortAutoNegEnabled */
588 { {1, 5, 4623, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
589 { {1, 5, 4623, 1, 3, 1, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 2 }},
590 { {1, 5, 4623, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
591 /* lldpXdot3RemPortAutoNegAdvertisedCap */
592 { {1, 5, 4623, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR,
593 { .string = { .octet = "\x04\x01", .len = 2 }} },
594 { {1, 5, 4623, 1, 3, 1, 1, 3, 8000, 3, 4 }, 11, ASN_OCTET_STR,
595 { .string = { .octet = "\x00\x00", .len = 2 }} },
596 { {1, 5, 4623, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR,
597 { .string = { .octet = "\x0c\x00", .len = 2 }} },
598 /* lldpXdot3RemPortOperMauType */
599 { {1, 5, 4623, 1, 3, 1, 1, 4, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 30 }},
600 { {1, 5, 4623, 1, 3, 1, 1, 4, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 0 }},
601 { {1, 5, 4623, 1, 3, 1, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 16 }},
602
603 /* lldpXdot3RemPowerPortClass */
604 { {1, 5, 4623, 1, 3, 2, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }},
605 /* lldpXdot3RemPowerMDISupported */
606 { {1, 5, 4623, 1, 3, 2, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
607 /* lldpXdot3RemPowerMDIEnabled */
608 { {1, 5, 4623, 1, 3, 2, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
609 /* lldpXdot3RemPowerPairControlable */
610 { {1, 5, 4623, 1, 3, 2, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
611 /* lldpXdot3RemPowerPairs */
612 { {1, 5, 4623, 1, 3, 2, 1, 5, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }},
613 /* lldpXdot3RemPowerClass */
614 { {1, 5, 4623, 1, 3, 2, 1, 6, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 3 }},
615 /* As per 802.3at-2009, not sure of the OID... */
616 /* lldpXdot3RemPowerType */
617 { {1, 5, 4623, 1, 3, 2, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR,
618 { .string = { .octet = "\xC0", .len = 1 } }},
619 /* lldpXdot3RemPowerSource */
620 { {1, 5, 4623, 1, 3, 2, 1, 8, 10000, 4, 1 }, 11, ASN_OCTET_STR,
621 { .string = { .octet = "\xC0", .len = 1 } }},
622 /* lldpXdot3RemPowerPriority */
623 { {1, 5, 4623, 1, 3, 2, 1, 9, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }},
624 /* lldpXdot3RemPDRequestedPowerValue */
625 { {1, 5, 4623, 1, 3, 2, 1, 10, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2000 }},
626 /* lldpXdot3RemPSEAllocatedPowerValue */
627 { {1, 5, 4623, 1, 3, 2, 1, 11, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2500 }},
628
629 /* lldpXdot3RemLinkAggStatus */
630 { {1, 5, 4623, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR,
631 { .string = { .octet = "\xC0", .len = 1 }} },
632 { {1, 5, 4623, 1, 3, 3, 1, 1, 8000, 3, 4 }, 11, ASN_OCTET_STR,
633 { .string = { .octet = "\x00", .len = 1 }} },
634 { {1, 5, 4623, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR,
635 { .string = { .octet = "\x00", .len = 1 }} },
636 /* lldpXdot3RemLinkAggPortId */
637 { {1, 5, 4623, 1, 3, 3, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 3 }},
638 { {1, 5, 4623, 1, 3, 3, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 0 }},
639 { {1, 5, 4623, 1, 3, 3, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 0 }},
640
641 /* lldpXdot3RemMaxFrameSize */
642 { {1, 5, 4623, 1, 3, 4, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 9000 }},
643 { {1, 5, 4623, 1, 3, 4, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1600 }},
644 #endif
645 #ifdef ENABLE_LLDPMED
646 /* lldpXMedLocDeviceClass */
647 { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER, { .integer = 2 }},
648
649 /* lldpXMedLocMediaPolicyVlanID */
650 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 3 }, 10, ASN_INTEGER, { .integer = 475 }},
651 { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 7 }, 10, ASN_INTEGER, { .integer = 472 }},
652 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 3 }, 10, ASN_INTEGER, { .integer = 475 }},
653 { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 6 }, 10, ASN_INTEGER, { .integer = 1007 }},
654 /* lldpXMedLocMediaPolicyPriority */
655 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 3 }, 10, ASN_INTEGER, { .integer = 3 }},
656 { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 7 }, 10, ASN_INTEGER, { .integer = 1 }},
657 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 3 }, 10, ASN_INTEGER, { .integer = 3 }},
658 { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 6 }, 10, ASN_INTEGER, { .integer = 1 }},
659 /* lldpXMedLocMediaPolicyDscp */
660 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 3 }, 10, ASN_INTEGER, { .integer = 62 }},
661 { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 7 }, 10, ASN_INTEGER, { .integer = 60 }},
662 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 3 }, 10, ASN_INTEGER, { .integer = 62 }},
663 { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 6 }, 10, ASN_INTEGER, { .integer = 49 }},
664 /* lldpXMedLocMediaPolicyUnknown */
665 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 3 }, 10, ASN_INTEGER, { .integer = 1 }},
666 { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 7 }, 10, ASN_INTEGER, { .integer = 2 }},
667 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 3 }, 10, ASN_INTEGER, { .integer = 1 }},
668 { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 6 }, 10, ASN_INTEGER, { .integer = 2 }},
669 /* lldpXMedLocMediaPolicyTagged */
670 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 3 }, 10, ASN_INTEGER, { .integer = 1 }},
671 { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 7 }, 10, ASN_INTEGER, { .integer = 1 }},
672 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 3 }, 10, ASN_INTEGER, { .integer = 1 }},
673 { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 6 }, 10, ASN_INTEGER, { .integer = 2 }},
674
675 /* lldpXMedLocHardwareRev */
676 { {1, 5, 4795, 1, 2, 2, 0 }, 7, ASN_OCTET_STR,
677 { .string = { .octet = "Hardware 1", .len = 10 }} },
678 /* lldpXMedLocSoftwareRev */
679 { {1, 5, 4795, 1, 2, 4, 0 }, 7, ASN_OCTET_STR,
680 { .string = { .octet = "Software 1", .len = 10 }} },
681 /* lldpXMedLocSerialNum */
682 { {1, 5, 4795, 1, 2, 5, 0 }, 7, ASN_OCTET_STR,
683 { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} },
684 /* lldpXMedLocMfgName */
685 { {1, 5, 4795, 1, 2, 6, 0 }, 7, ASN_OCTET_STR,
686 { .string = { .octet = "Manufacturer 1", .len = 14 }} },
687 /* lldpXMedLocModelName */
688 { {1, 5, 4795, 1, 2, 7, 0 }, 7, ASN_OCTET_STR,
689 { .string = { .octet = "Model 1", .len = 7 }} },
690 /* lldpXMedLocAssetID */
691 { {1, 5, 4795, 1, 2, 8, 0 }, 7, ASN_OCTET_STR,
692 { .string = { .octet = "Asset 1", .len = 7 }} },
693
694 /* lldpXMedLocLocationInfo */
695 { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR,
696 { .string = { .octet = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len = 22 }} },
697 { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR,
698 { .string = { .octet = "Not interpreted", .len = 15 }} },
699
700 /* lldpXMedLocXPoEDeviceType */
701 { {1, 5, 4795, 1, 2, 10, 0 }, 7, ASN_INTEGER, { .integer = 3 }},
702 /* lldpXMedLocXPoEPDPowerReq */
703 { {1, 5, 4795, 1, 2, 13, 0 }, 7, ASN_GAUGE, { .integer = 100 }},
704 /* lldpXMedLocXPoEPDPowerSource */
705 { {1, 5, 4795, 1, 2, 14, 0 }, 7, ASN_INTEGER, { .integer = 3 }},
706 /* lldpXMedLocXPoEPDPowerPriority */
707 { {1, 5, 4795, 1, 2, 15, 0 }, 7, ASN_INTEGER, { .integer = 3 }},
708
709 /* lldpXMedRemCapSupported */
710 { {1, 5, 4795, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR,
711 { .string = { .octet = "\xFC", .len = 1 }} },
712 { {1, 5, 4795, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR,
713 { .string = { .octet = "\xFC", .len = 1 }}},
714 /* lldpXMedRemCapCurrent */
715 { {1, 5, 4795, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_OCTET_STR,
716 { .string = { .octet = "\xFC", .len = 1 }} },
717 { {1, 5, 4795, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_OCTET_STR,
718 { .string = { .octet = "\xEC", .len = 1 }}},
719 /* lldpXMedRemDeviceClass */
720 { {1, 5, 4795, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 2 }},
721 { {1, 5, 4795, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }},
722
723 /* lldpXMedRemMediaPolicyVlanID */
724 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 475 }},
725 { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 1007 }},
726 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 475 }},
727 { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 472 }},
728 /* lldpXMedRemMediaPolicyPriority */
729 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 3 }},
730 { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 1 }},
731 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 3 }},
732 { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 1 }},
733 /* lldpXMedLocMediaPolicyDscp */
734 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 62 }},
735 { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 49 }},
736 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 62 }},
737 { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 60 }},
738 /* lldpXMedLocMediaPolicyUnknown */
739 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }},
740 { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 2 }},
741 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }},
742 { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 2 }},
743 /* lldpXMedLocMediaPolicyTagged */
744 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }},
745 { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 2 }},
746 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }},
747 { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 1 }},
748
749 /* lldpXMedRemHardwareRev */
750 { {1, 5, 4795, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR,
751 { .string = { .octet = "Hardware 1", .len = 10 }} },
752 { {1, 5, 4795, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR,
753 { .string = { .octet = "Hardware 1", .len = 10 }} },
754 /* lldpXMedRemSoftwareRev */
755 { {1, 5, 4795, 1, 3, 3, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR,
756 { .string = { .octet = "Software 1", .len = 10 }} },
757 { {1, 5, 4795, 1, 3, 3, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR,
758 { .string = { .octet = "Software 1", .len = 10 }} },
759 /* lldpXMedRemSerialNum */
760 { {1, 5, 4795, 1, 3, 3, 1, 4, 0, 3, 1 }, 11, ASN_OCTET_STR,
761 { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} },
762 { {1, 5, 4795, 1, 3, 3, 1, 4, 10000, 4, 1 }, 11, ASN_OCTET_STR,
763 { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} },
764 /* lldpXMedRemMfgName */
765 { {1, 5, 4795, 1, 3, 3, 1, 5, 0, 3, 1 }, 11, ASN_OCTET_STR,
766 { .string = { .octet = "Manufacturer 1", .len = 14 }} },
767 { {1, 5, 4795, 1, 3, 3, 1, 5, 10000, 4, 1 }, 11, ASN_OCTET_STR,
768 { .string = { .octet = "Manufacturer 1", .len = 14 }} },
769 /* lldpXMedRemModelName */
770 { {1, 5, 4795, 1, 3, 3, 1, 6, 0, 3, 1 }, 11, ASN_OCTET_STR,
771 { .string = { .octet = "Model 1", .len = 7 }} },
772 { {1, 5, 4795, 1, 3, 3, 1, 6, 10000, 4, 1 }, 11, ASN_OCTET_STR,
773 { .string = { .octet = "Model 1", .len = 7 }} },
774 /* lldpXMedRemAssetID */
775 { {1, 5, 4795, 1, 3, 3, 1, 7, 0, 3, 1 }, 11, ASN_OCTET_STR,
776 { .string = { .octet = "Asset 1", .len = 7 }} },
777 { {1, 5, 4795, 1, 3, 3, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR,
778 { .string = { .octet = "Asset 1", .len = 7 }} },
779
780 /* lldpXMedLocLocationInfo */
781 { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR,
782 { .string = { .octet = "Not interpreted", .len = 15 }} },
783 { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR,
784 { .string = { .octet = "\x15" "\x02" "FR" "\x06" "\x0d" "Commercial Rd" "\x13" "\x01" "4", .len = 22 }} },
785
786 /* lldpXMedRemXPoEDeviceType */
787 { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 4 }},
788 { {1, 5, 4795, 1, 3, 5, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }},
789
790 /* lldpXMedRemXPoEPDPowerReq */
791 { {1, 5, 4795, 1, 3, 7, 1, 1, 10000, 4, 1}, 11, ASN_GAUGE, { .integer = 100 }},
792 /* lldpXMedRemXPoEPDPowerSource */
793 { {1, 5, 4795, 1, 3, 7, 1, 2, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }},
794 /* lldpXMedRemXPoEPDPowerPriority */
795 { {1, 5, 4795, 1, 3, 7, 1, 3, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }},
796
797 #endif
798 #ifdef ENABLE_DOT1
799 /* lldpXdot1LocPortVlanId */
800 { { 1, 5, 32962, 1, 2, 1, 1, 1, 3}, 9, ASN_INTEGER, { .integer = 47 }},
801 { { 1, 5, 32962, 1, 2, 1, 1, 1, 4}, 9, ASN_INTEGER, { .integer = 0 }},
802 /* lldpXdot1LocProtoVlanSupported */
803 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 47}, 10, ASN_INTEGER, { .integer = 1 }},
804 { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 118}, 10, ASN_INTEGER, { .integer = 1 }},
805 /* lldpXdot1LocProtoVlanEnabled */
806 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 47}, 10, ASN_INTEGER, { .integer = 1 }},
807 { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 118}, 10, ASN_INTEGER, { .integer = 1 }},
808 /* lldpXdot1LocVlanName */
809 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 47}, 10, ASN_OCTET_STR,
810 { .string = { .octet = "VLAN #47", .len = 8 }} },
811 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 49}, 10, ASN_OCTET_STR,
812 { .string = { .octet = "VLAN #49", .len = 8 }} },
813 { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR,
814 { .string = { .octet = "VLAN #1449", .len = 10 }} },
815 /* lldpXdot1LocProtocolId */
816 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30321}, 10, ASN_OCTET_STR,
817 { .string = { .octet = "\x88\x8e\x01", .len = 3 } }},
818 { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 30515}, 10, ASN_OCTET_STR,
819 { .string = { .octet = "\x88\xcc", .len = 2 } }},
820
821 /* lldpXdot1RemPortVlanId */
822 { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 0 }},
823 { { 1, 5, 32962, 1, 3, 1, 1, 1, 8000, 3, 4}, 11, ASN_INTEGER, { .integer = 0 }},
824 { { 1, 5, 32962, 1, 3, 1, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 47 }},
825 /* lldpXdot1RemProtoVlanSupported */
826 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 47}, 12, ASN_INTEGER, { .integer = 1 }},
827 { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 118}, 12, ASN_INTEGER, { .integer = 1 }},
828 /* lldpXdot1RemProtoVlanEnabled */
829 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 47}, 12, ASN_INTEGER, { .integer = 1 }},
830 { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 118}, 12, ASN_INTEGER, { .integer = 1 }},
831 /* lldpXdot1RemVlanName */
832 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 47}, 12, ASN_OCTET_STR,
833 { .string = { .octet = "VLAN #47", .len = 8 }} },
834 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 49}, 12, ASN_OCTET_STR,
835 { .string = { .octet = "VLAN #49", .len = 8 }} },
836 { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR,
837 { .string = { .octet = "VLAN #1449", .len = 10 }} },
838 /* lldpXdot1RemProtocolId */
839 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30321}, 12, ASN_OCTET_STR,
840 { .string = { .octet = "\x88\x8e\x01", .len = 3 } }},
841 { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 30515}, 12, ASN_OCTET_STR,
842 { .string = { .octet = "\x88\xcc", .len = 2 } }}
843 #endif
844 };
845
846 char*
847 tohex(char *str, size_t len)
848 {
849 static char *hex[] = { NULL, NULL };
850 static int which = 0;
851 free(hex[which]); hex[which] = NULL;
852 hex[which] = malloc(len * 3 + 1);
853 fail_unless(hex[which] != NULL, "Not enough memory?");
854 for (size_t i = 0; i < len; i++)
855 snprintf(hex[which] + 3*i, 4, "%02X ", (unsigned char)str[i]);
856 which = 1 - which;
857 return hex[1 - which];
858 }
859
860 int
861 snmp_is_prefix_of(struct variable8 *vp, struct tree_node *n, char *repr)
862 {
863 if (n->namelen < vp->namelen) return 0;
864 if (memcmp(n->name,
865 vp->name,
866 vp->namelen * sizeof(oid)))
867 return 0;
868 fail_unless(n->type == vp->type, "Inappropriate type for OID %s", repr);
869 return 1;
870 }
871
872 void
873 snmp_merge(struct variable8 *v1, struct tree_node *n, struct variable *vp,
874 oid *target, size_t *targetlen)
875 {
876 vp->magic = v1->magic;
877 vp->type = v1->type;
878 vp->acl = v1->acl;
879 vp->findVar = v1->findVar;
880 vp->namelen = v1->namelen +
881 sizeof(lldp_oid)/sizeof(oid);
882 memcpy(vp->name, lldp_oid, sizeof(lldp_oid));
883 memcpy(vp->name + sizeof(lldp_oid)/sizeof(oid),
884 v1->name,
885 v1->namelen*sizeof(oid));
886 *targetlen = n->namelen +
887 sizeof(lldp_oid)/sizeof(oid);
888 memcpy(target, lldp_oid, sizeof(lldp_oid));
889 memcpy(target + sizeof(lldp_oid)/sizeof(oid),
890 n->name,
891 n->namelen * sizeof(oid));
892 }
893
894 void
895 snmp_compare(struct tree_node *n,
896 u_char *result, size_t varlen,
897 oid *target, size_t targetlen, char *repr)
898 {
899 unsigned long int value;
900 fail_unless((targetlen == sizeof(lldp_oid)/sizeof(oid) + n->namelen) &&
901 !memcmp(target, lldp_oid, sizeof(lldp_oid)) &&
902 !memcmp(target + sizeof(lldp_oid)/sizeof(oid),
903 n->name,
904 n->namelen * sizeof(oid)),
905 "Bad OID returned when querying %s: got %s", repr,
906 snmp_oidrepr(target, targetlen));
907 switch (n->type) {
908 case ASN_INTEGER:
909 case ASN_TIMETICKS:
910 case ASN_GAUGE:
911 case ASN_COUNTER:
912 fail_unless(varlen == sizeof(unsigned long int),
913 "Inappropriate length for integer type for OID %s",
914 repr);
915 memcpy(&value, result, sizeof(value));
916 fail_unless(n->value.integer == value,
917 "For OID %s, expected value %u but got %u instead",
918 repr,
919 n->value.integer,
920 value);
921 break;
922 default:
923 fail_unless(((n->value.string.len == varlen) &&
924 !memcmp(n->value.string.octet,
925 result, varlen)),
926 "OID %s: wanted %s, got %s",
927 repr,
928 tohex(n->value.string.octet, n->value.string.len),
929 tohex((char *)result, varlen));
930 }
931 }
932
933 START_TEST (test_variable_order)
934 {
935 size_t i;
936 for (i = 0; i < agent_lldp_vars_size() - 1; i++) {
937 fail_unless(snmp_oid_compare(agent_lldp_vars[i].name,
938 agent_lldp_vars[i].namelen,
939 agent_lldp_vars[i+1].name,
940 agent_lldp_vars[i+1].namelen) < 0,
941 "Registered OID are out of orders (see %s and next one)",
942 snmp_oidrepr(agent_lldp_vars[i].name,
943 agent_lldp_vars[i].namelen));
944 }
945 }
946 END_TEST
947
948 START_TEST (test_get)
949 {
950 size_t j;
951 for (j = 0;
952 j < sizeof(snmp_tree)/sizeof(struct tree_node);
953 j++) {
954 size_t i;
955 int found = 0;
956 struct variable vp;
957 oid target[MAX_OID_LEN];
958 size_t targetlen;
959 size_t varlen;
960 u_char *result;
961 WriteMethod *wmethod;
962 char *repr = snmp_oidrepr(snmp_tree[j].name,
963 snmp_tree[j].namelen);
964
965 for (i = 0; i < agent_lldp_vars_size(); i++) {
966 /* Search for the appropriate prefix. */
967 if (!snmp_is_prefix_of(&agent_lldp_vars[i], &snmp_tree[j],
968 repr)) continue;
969
970 /* We have our prefix. Fill out the vp struct
971 correctly. We need to complete OID with
972 LLDP prefix. */
973 snmp_merge(&agent_lldp_vars[i], &snmp_tree[j], &vp, target, &targetlen);
974
975 /* Invoke the function */
976 result = vp.findVar(&vp, target, &targetlen, 1, &varlen, &wmethod);
977
978 /* Check the result */
979 fail_unless(result != NULL,
980 "No result when querying %s", repr);
981 snmp_compare(&snmp_tree[j], result, varlen, target, targetlen, repr);
982
983 found = 1;
984 break;
985 }
986 if (!found)
987 fail("OID %s not found", repr);
988 }
989 }
990 END_TEST
991
992 START_TEST (test_getnext)
993 {
994 size_t j;
995 size_t end = sizeof(snmp_tree)/sizeof(struct tree_node);
996 for (j = 0;
997 j < end;
998 j++) {
999 size_t i;
1000 struct variable vp;
1001 oid target[MAX_OID_LEN];
1002 size_t targetlen;
1003 size_t varlen;
1004 u_char *result = NULL;
1005 WriteMethod *wmethod;
1006 char *repr = snmp_oidrepr(snmp_tree[j].name,
1007 snmp_tree[j].namelen);
1008 for (i = 0; i < agent_lldp_vars_size(); i++) {
1009 snmp_merge(&agent_lldp_vars[i], &snmp_tree[j], &vp, target, &targetlen);
1010 result = vp.findVar(&vp, target, &targetlen, 0, &varlen, &wmethod);
1011 if (result) /* Check next! */
1012 break;
1013 }
1014 if (!result) {
1015 fail_unless(j == end - 1,
1016 "No next result found for %s", repr);
1017 return;
1018 }
1019 fail_unless(j < end - 1,
1020 "More results after %s", repr);
1021
1022 /* For unknown reasons, snmp_compare can be executed
1023 even when the above test fails... */
1024 if (j < end - 1)
1025 snmp_compare(&snmp_tree[j+1], result, varlen, target, targetlen, repr);
1026
1027 }
1028 }
1029 END_TEST
1030
1031 Suite *
1032 snmp_suite(void)
1033 {
1034 Suite *s = suite_create("SNMP");
1035
1036 TCase *tc_snmp = tcase_create("SNMP");
1037 tcase_add_checked_fixture(tc_snmp, snmp_config, NULL);
1038 tcase_add_test(tc_snmp, test_variable_order);
1039 tcase_add_test(tc_snmp, test_get);
1040 tcase_add_test(tc_snmp, test_getnext);
1041 suite_add_tcase(s, tc_snmp);
1042
1043 return s;
1044 }
1045
1046 int
1047 main()
1048 {
1049 int number_failed;
1050 Suite *s = snmp_suite();
1051 SRunner *sr = srunner_create(s);
1052 srunner_run_all(sr, CK_ENV);
1053 number_failed = srunner_ntests_failed(sr);
1054 srunner_free(sr);
1055 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
1056 }