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