]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | extern struct lldpd *agent_scfg; | |
12 | extern struct timeval starttime; | |
13 | extern struct variable8 agent_lldp_vars[]; | |
4e22da4c VB |
14 | |
15 | /* Our test config */ | |
16 | struct lldpd test_cfg = { | |
d79c3de4 | 17 | .g_config = { |
8843f168 | 18 | .c_tx_interval = 30, |
d79c3de4 VB |
19 | .c_smart = 0 |
20 | } | |
4e22da4c VB |
21 | }; |
22 | struct timeval test_starttime = { .tv_sec = 100, .tv_usec = 0 }; | |
23 | ||
24 | /* First chassis */ | |
2eec5540 VB |
25 | struct 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 |
31 | struct 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 |
57 | struct 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 |
63 | struct 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 |
72 | struct 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 */ | |
95 | struct 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 */ | |
178 | struct 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 | |
238 | struct lldpd_vlan vlan47 = { | |
239 | .v_name = "VLAN #47", | |
240 | .v_vid = 47, | |
241 | }; | |
242 | struct lldpd_vlan vlan49 = { | |
243 | .v_name = "VLAN #49", | |
244 | .v_vid = 49, | |
245 | }; | |
246 | struct lldpd_vlan vlan1449 = { | |
247 | .v_name = "VLAN #1449", | |
248 | .v_vid = 1449, | |
249 | }; | |
250 | struct lldpd_ppvid ppvid47 = { | |
4b292b55 | 251 | .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED, |
4e22da4c VB |
252 | .p_ppvid = 47, |
253 | }; | |
254 | struct lldpd_ppvid ppvid118 = { | |
4b292b55 | 255 | .p_cap_status = LLDP_PPVID_CAP_SUPPORTED | LLDP_PPVID_CAP_ENABLED, |
4e22da4c VB |
256 | .p_ppvid = 118, |
257 | }; | |
258 | struct lldpd_pi pi88cc = { | |
259 | .p_pi = "\x88\xcc", | |
260 | .p_pi_len = 2, | |
261 | }; | |
262 | struct lldpd_pi pi888e01 = { | |
263 | .p_pi = "\x88\x8e\e01", | |
264 | .p_pi_len = 3, | |
265 | }; | |
266 | #endif | |
267 | ||
268 | /* First port of second chassis */ | |
269 | struct 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 | ||
279 | void | |
280 | snmp_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. */ | |
323 | char* | |
324 | snmp_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; | |
6a5334d4 VB |
336 | if (asprintf(&newbuffer, "%s.%lu", buffer[current]?buffer[current]:"", name[i]) == -1) { |
337 | free(buffer[current]); | |
338 | buffer[current] = NULL; | |
339 | return NULL; | |
340 | } | |
4e22da4c VB |
341 | if (buffer[current]) free(buffer[current]); |
342 | buffer[current] = newbuffer; | |
343 | } | |
344 | return buffer[current++]; | |
345 | } | |
346 | ||
347 | struct tree_node { | |
348 | oid name[MAX_OID_LEN]; | |
349 | size_t namelen; | |
350 | int type; /* ASN_* */ | |
351 | union { | |
352 | unsigned long int integer; | |
353 | struct { | |
354 | char *octet; | |
355 | size_t len; | |
356 | } string; | |
357 | } value; | |
358 | }; | |
359 | ||
360 | static oid zeroDotZero[2] = {0, 0}; | |
361 | struct tree_node snmp_tree[] = { | |
362 | { {1, 1, 1, 0}, 4, ASN_INTEGER, { .integer = 30 } }, /* lldpMessageTxInterval */ | |
363 | { {1, 1, 2, 0}, 4, ASN_INTEGER, { .integer = 2 } }, /* lldpMessageTxHoldMultiplier */ | |
364 | { {1, 1, 3, 0}, 4, ASN_INTEGER, { .integer = 1 } }, /* lldpReinitDelay */ | |
365 | { {1, 1, 4, 0}, 4, ASN_INTEGER, { .integer = 1 } }, /* lldpTxDelay */ | |
366 | { {1, 1, 5, 0}, 4, ASN_INTEGER, { .integer = 5 } }, /* lldpNotificationInterval */ | |
367 | { {1, 2, 1, 0}, 4, ASN_TIMETICKS, { .integer = 10000 } },/* lldpStatsRemTablesLastChangeTime */ | |
14052b61 VB |
368 | { {1, 2, 2, 0}, 4, ASN_GAUGE, { .integer = 1100 } }, /* lldpStatsRemTablesInserts */ |
369 | { {1, 2, 3, 0}, 4, ASN_GAUGE, { .integer = 56 } }, /* lldpStatsRemTablesDeletes */ | |
42589660 | 370 | { {1, 2, 4, 0}, 4, ASN_GAUGE, { .integer = 2 } }, /* lldpStatsRemTablesDrops */ |
14052b61 | 371 | { {1, 2, 5, 0}, 4, ASN_GAUGE, { .integer = 230 } }, /* lldpStatsRemTablesAgeouts */ |
4e22da4c VB |
372 | |
373 | { {1, 2, 6, 1, 2, 3}, 6, ASN_COUNTER, { .integer = 1352 } }, /* lldpStatsTxPortFramesTotal.3 */ | |
374 | { {1, 2, 6, 1, 2, 4}, 6, ASN_COUNTER, { .integer = 11352 } }, /* lldpStatsTxPortFramesTotal.4 */ | |
375 | { {1, 2, 7, 1, 2, 3}, 6, ASN_COUNTER, { .integer = 5 } }, /* lldpStatsRxPortFramesDiscardedTotal.3 */ | |
376 | { {1, 2, 7, 1, 2, 4}, 6, ASN_COUNTER, { .integer = 55 } }, /* lldpStatsRxPortFramesDiscardedTotal.4 */ | |
377 | { {1, 2, 7, 1, 3, 3}, 6, ASN_COUNTER, { .integer = 5 } }, /* lldpStatsRxPortFramesError.3 */ | |
378 | { {1, 2, 7, 1, 3, 4}, 6, ASN_COUNTER, { .integer = 55 } }, /* lldpStatsRxPortFramesError.4 */ | |
379 | { {1, 2, 7, 1, 4, 3}, 6, ASN_COUNTER, { .integer = 1458 } }, /* lldpStatsRxPortFramesTotal.3 */ | |
380 | { {1, 2, 7, 1, 4, 4}, 6, ASN_COUNTER, { .integer = 11458 } }, /* lldpStatsRxPortFramesTotal.4 */ | |
381 | { {1, 2, 7, 1, 5, 3}, 6, ASN_COUNTER, { .integer = 4 } }, /* lldpStatsRxPortTLVsDiscardedTotal.3 */ | |
382 | { {1, 2, 7, 1, 5, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsDiscardedTotal.4 */ | |
383 | { {1, 2, 7, 1, 6, 3}, 6, ASN_COUNTER, { .integer = 4 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.3 */ | |
384 | { {1, 2, 7, 1, 6, 4}, 6, ASN_COUNTER, { .integer = 14 } }, /* lldpStatsRxPortTLVsUnrecognizedTotal.4 */ | |
14052b61 VB |
385 | { {1, 2, 7, 1, 7, 3}, 6, ASN_GAUGE, { .integer = 20 } }, /* lldpStatsRxPortAgeoutsTotal.3 */ |
386 | { {1, 2, 7, 1, 7, 4}, 6, ASN_GAUGE, { .integer = 210 } }, /* lldpStatsRxPortAgeoutsTotal.4 */ | |
4e22da4c VB |
387 | |
388 | { {1, 3, 1, 0}, 4, ASN_INTEGER, { .integer = 4 } }, /* lldpLocChassisIdSubtype */ | |
389 | /* lldpLocChassisId */ | |
390 | { {1, 3, 2, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "AAA012", | |
391 | .len = 6 } }}, | |
392 | /* lldpLocSysName */ | |
393 | { {1, 3, 3, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "chassis1.example.com", | |
394 | .len = 20 } }}, | |
395 | /* lldpLocSysDesc */ | |
396 | { {1, 3, 4, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "First chassis", | |
397 | .len = 13 } }}, | |
398 | /* lldpLocSysCapSupported */ | |
399 | { {1, 3, 5, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x38", | |
400 | .len = 1 } }}, | |
401 | /* lldpLocSysCapEnabled */ | |
402 | { {1, 3, 6, 0}, 4, ASN_OCTET_STR, { .string = { .octet = "\x8", | |
403 | .len = 1 } }}, | |
404 | ||
405 | { {1, 3, 7, 1, 2, 3}, 6, ASN_INTEGER, { .integer = 3 } }, /* lldpLocPortIdSubtype.3 */ | |
406 | { {1, 3, 7, 1, 2, 4}, 6, ASN_INTEGER, { .integer = 5 } }, /* lldpLocPortIdSubtype.5 */ | |
407 | /* lldpLocPortId.3 */ | |
408 | { {1, 3, 7, 1, 3, 3}, 6, ASN_OCTET_STR, { .string = { .octet = "AAA012", | |
409 | .len = 6 } }}, | |
410 | /* lldpLocPortId.4 */ | |
411 | { {1, 3, 7, 1, 3, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "eth4", | |
412 | .len = 4 } }}, | |
413 | /* lldpLocPortDesc.3 */ | |
414 | { {1, 3, 7, 1, 4, 3}, 6, ASN_OCTET_STR, { .string = { .octet = "eth2", | |
415 | .len = 4 } }}, | |
416 | /* lldpLocPortDesc.4 */ | |
417 | { {1, 3, 7, 1, 4, 4}, 6, ASN_OCTET_STR, { .string = { .octet = "Intel 1000 GE", | |
418 | .len = 13 } }}, | |
419 | ||
420 | { {1, 3, 8, 1, 3, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 5 } }, /* lldpLocManAddrLen */ | |
421 | { {1, 3, 8, 1, 4, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 2 } }, /* lldpLocManAddrIfSubtype */ | |
422 | { {1, 3, 8, 1, 5, 1, 4, 192, 0, 2, 15}, 11, ASN_INTEGER, { .integer = 3 } }, /* lldpLocManAddrIfId */ | |
423 | /* lldpLocManAddrOID */ | |
424 | { {1, 3, 8, 1, 6, 1, 4, 192, 0, 2, 15}, 11, ASN_OBJECT_ID, | |
425 | { .string = { .octet = (char *)zeroDotZero, | |
426 | .len = sizeof(zeroDotZero) }} }, | |
427 | ||
428 | /* lldpRemChassisIdSubtype */ | |
429 | { {1, 4, 1, 1, 4, 0, 3, 1 }, 8, ASN_INTEGER, { .integer = 4 } }, | |
430 | { {1, 4, 1, 1, 4, 8000, 3, 4}, 8, ASN_INTEGER, { .integer = 7 } }, | |
431 | { {1, 4, 1, 1, 4, 10000, 4, 1}, 8, ASN_INTEGER, { .integer = 4 } }, | |
432 | /* lldpRemChassisId */ | |
433 | { {1, 4, 1, 1, 5, 0, 3, 1 }, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} }, | |
434 | { {1, 4, 1, 1, 5, 8000, 3, 4}, 8, ASN_OCTET_STR, { .string = | |
435 | { .octet = "chassis2", | |
436 | .len = 6 }} }, | |
437 | { {1, 4, 1, 1, 5, 10000, 4, 1}, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} }, | |
438 | /* lldpRemPortIdSubtype */ | |
439 | { {1, 4, 1, 1, 6, 0, 3, 1 }, 8, ASN_INTEGER, { .integer = 5 } }, | |
440 | { {1, 4, 1, 1, 6, 8000, 3, 4}, 8, ASN_INTEGER, { .integer = 1 } }, | |
441 | { {1, 4, 1, 1, 6, 10000, 4, 1}, 8, ASN_INTEGER, { .integer = 3 } }, | |
442 | /* lldpRemPortId */ | |
443 | { {1, 4, 1, 1, 7, 0, 3, 1 }, 8, ASN_OCTET_STR, { .string = { .octet = "eth4", .len = 4 }} }, | |
444 | { {1, 4, 1, 1, 7, 8000, 3, 4}, 8, ASN_OCTET_STR, { .string = | |
445 | { .octet = "Giga1/7", .len = 7 }} }, | |
446 | { {1, 4, 1, 1, 7, 10000, 4, 1}, 8, ASN_OCTET_STR, { .string = { .octet = "AAA012", .len = 6 }} }, | |
447 | /* lldpRemPortDesc */ | |
448 | { {1, 4, 1, 1, 8, 0, 3, 1 }, 8, ASN_OCTET_STR, | |
449 | { .string = { .octet = "Intel 1000 GE", .len = 13 }} }, | |
450 | { {1, 4, 1, 1, 8, 8000, 3, 4}, 8, ASN_OCTET_STR, | |
451 | { .string = { .octet = "Gigabit Ethernet 1/7", .len = 20 }} }, | |
452 | { {1, 4, 1, 1, 8, 10000, 4, 1}, 8, ASN_OCTET_STR, | |
453 | { .string = { .octet = "eth2", .len = 4 }} }, | |
454 | /* lldpRemSysName */ | |
455 | { {1, 4, 1, 1, 9, 0, 3, 1 }, 8, ASN_OCTET_STR, | |
456 | { .string = { .octet = "chassis1.example.com", .len = 20 }} }, | |
457 | { {1, 4, 1, 1, 9, 8000, 3, 4}, 8, ASN_OCTET_STR, | |
458 | { .string = { .octet = "chassis2.example.com", .len = 20 }} }, | |
459 | { {1, 4, 1, 1, 9, 10000, 4, 1}, 8, ASN_OCTET_STR, | |
460 | { .string = { .octet = "chassis1.example.com", .len = 20 }} }, | |
461 | /* lldpRemSysDesc */ | |
462 | { {1, 4, 1, 1, 10, 0, 3, 1 }, 8, ASN_OCTET_STR, | |
463 | { .string = { .octet = "First chassis", .len = 13 }} }, | |
464 | { {1, 4, 1, 1, 10, 8000, 3, 4}, 8, ASN_OCTET_STR, | |
465 | { .string = { .octet = "Second chassis", .len = 14 }} }, | |
466 | { {1, 4, 1, 1, 10, 10000, 4, 1}, 8, ASN_OCTET_STR, | |
467 | { .string = { .octet = "First chassis", .len = 13 }} }, | |
468 | /* lldpRemSysCapSupported */ | |
469 | { {1, 4, 1, 1, 11, 0, 3, 1 }, 8, ASN_OCTET_STR, | |
470 | { .string = { .octet = "\x38", .len = 1 }} }, | |
471 | { {1, 4, 1, 1, 11, 8000, 3, 4}, 8, ASN_OCTET_STR, | |
472 | { .string = { .octet = "\x8", .len = 1 }} }, | |
473 | { {1, 4, 1, 1, 11, 10000, 4, 1}, 8, ASN_OCTET_STR, | |
474 | { .string = { .octet = "\x38", .len = 1 }} }, | |
475 | /* lldpRemSysCapEnabled */ | |
476 | { {1, 4, 1, 1, 12, 0, 3, 1 }, 8, ASN_OCTET_STR, | |
477 | { .string = { .octet = "\x8", .len = 1 }} }, | |
478 | { {1, 4, 1, 1, 12, 8000, 3, 4}, 8, ASN_OCTET_STR, | |
479 | { .string = { .octet = "\x8", .len = 1 }} }, | |
480 | { {1, 4, 1, 1, 12, 10000, 4, 1}, 8, ASN_OCTET_STR, | |
481 | { .string = { .octet = "\x8", .len = 1 }} }, | |
482 | ||
483 | /* lldpRemManAddrIfSubtype */ | |
484 | { {1, 4, 2, 1, 3, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 2 } }, | |
485 | { {1, 4, 2, 1, 3, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER, { .integer = 2 } }, | |
af3caa3b VB |
486 | { {1, 4, 2, 1, 3, 8000, 3, 4, 2, 16, |
487 | 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00, | |
488 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER, { .integer = 2 } }, | |
4e22da4c VB |
489 | { {1, 4, 2, 1, 3, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 2 } }, |
490 | /* lldpRemManAddrIfId */ | |
491 | { {1, 4, 2, 1, 4, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 3 } }, | |
492 | { {1, 4, 2, 1, 4, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_INTEGER, { .integer = 5 } }, | |
af3caa3b VB |
493 | { {1, 4, 2, 1, 4, 8000, 3, 4, 2, 16, |
494 | 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00, | |
495 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_INTEGER, { .integer = 5 } }, | |
4e22da4c VB |
496 | { {1, 4, 2, 1, 4, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_INTEGER, { .integer = 3 } }, |
497 | /* lldpRemManAddrOID */ | |
498 | { {1, 4, 2, 1, 5, 0, 3, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID, | |
499 | { .string = { .octet = (char *)zeroDotZero, | |
500 | .len = sizeof(zeroDotZero) }} }, | |
501 | { {1, 4, 2, 1, 5, 8000, 3, 4, 1, 4, 192, 0, 2, 17 }, 14, ASN_OBJECT_ID, | |
502 | { .string = { .octet = (char *)zeroDotZero, | |
503 | .len = sizeof(zeroDotZero) }} }, | |
af3caa3b VB |
504 | { {1, 4, 2, 1, 5, 8000, 3, 4, 2, 16, |
505 | 0x20, 0x01, 0x0d, 0xb8, 0xca, 0xfe, 0x00, 0x00, | |
506 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17 }, 26, ASN_OBJECT_ID, | |
507 | { .string = { .octet = (char *)zeroDotZero, | |
508 | .len = sizeof(zeroDotZero) }} }, | |
4e22da4c VB |
509 | { {1, 4, 2, 1, 5, 10000, 4, 1, 1, 4, 192, 0, 2, 15 }, 14, ASN_OBJECT_ID, |
510 | { .string = { .octet = (char *)zeroDotZero, | |
511 | .len = sizeof(zeroDotZero) }} }, | |
512 | ||
513 | #ifdef ENABLE_DOT3 | |
514 | /* lldpXdot3LocPortAutoNegSupported */ | |
515 | { {1, 5, 4623, 1, 2, 1, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
516 | { {1, 5, 4623, 1, 2, 1, 1, 1, 4 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
517 | /* lldpXdot3LocPortAutoNegEnabled */ | |
518 | { {1, 5, 4623, 1, 2, 1, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
519 | { {1, 5, 4623, 1, 2, 1, 1, 2, 4 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
520 | /* lldpXdot3LocPortAutoNegAdvertisedCap */ | |
521 | { {1, 5, 4623, 1, 2, 1, 1, 3, 3 }, 9, ASN_OCTET_STR, | |
522 | { .string = { .octet = "\x0c\x00", .len = 2 }} }, | |
523 | { {1, 5, 4623, 1, 2, 1, 1, 3, 4 }, 9, ASN_OCTET_STR, | |
524 | { .string = { .octet = "\x04\x01", .len = 2 }} }, | |
525 | /* lldpXdot3LocPortOperMauType */ | |
526 | { {1, 5, 4623, 1, 2, 1, 1, 4, 3 }, 9, ASN_INTEGER, { .integer = 16 }}, | |
527 | { {1, 5, 4623, 1, 2, 1, 1, 4, 4 }, 9, ASN_INTEGER, { .integer = 30 }}, | |
528 | ||
529 | /* lldpXdot3LocPowerPortClass */ | |
530 | { {1, 5, 4623, 1, 2, 2, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 2 }}, | |
531 | /* lldpXdot3LocPowerMDISupported */ | |
532 | { {1, 5, 4623, 1, 2, 2, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
533 | /* lldpXdot3LocPowerMDIEnabled */ | |
534 | { {1, 5, 4623, 1, 2, 2, 1, 3, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
535 | /* lldpXdot3LocPowerPairControlable */ | |
536 | { {1, 5, 4623, 1, 2, 2, 1, 4, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
537 | /* lldpXdot3LocPowerPairs */ | |
538 | { {1, 5, 4623, 1, 2, 2, 1, 5, 3 }, 9, ASN_INTEGER, { .integer = 2 }}, | |
539 | /* lldpXdot3LocPowerClass */ | |
540 | { {1, 5, 4623, 1, 2, 2, 1, 6, 3 }, 9, ASN_INTEGER, { .integer = 3 }}, | |
541 | /* As per 802.3at-2009, not sure of the OID... */ | |
542 | /* lldpXdot3LocPowerType */ | |
543 | { {1, 5, 4623, 1, 2, 2, 1, 7, 3 }, 9, ASN_OCTET_STR, | |
544 | { .string = { .octet = "\xC0", .len = 1 } }}, | |
545 | /* lldpXdot3LocPowerSource */ | |
546 | { {1, 5, 4623, 1, 2, 2, 1, 8, 3 }, 9, ASN_OCTET_STR, | |
547 | { .string = { .octet = "\xC0", .len = 1 } }}, | |
548 | /* lldpXdot3LocPowerPriority */ | |
549 | { {1, 5, 4623, 1, 2, 2, 1, 9, 3 }, 9, ASN_INTEGER, { .integer = 1 }}, | |
550 | /* lldpXdot3LocPDRequestedPowerValue */ | |
551 | { {1, 5, 4623, 1, 2, 2, 1, 10, 3 }, 9, ASN_INTEGER, { .integer = 2000 }}, | |
552 | /* lldpXdot3LocPSEAllocatedPowerValue */ | |
553 | { {1, 5, 4623, 1, 2, 2, 1, 11, 3 }, 9, ASN_INTEGER, { .integer = 2500 }}, | |
554 | ||
555 | /* lldpXdot3LocLinkAggStatus */ | |
556 | { {1, 5, 4623, 1, 2, 3, 1, 1, 3 }, 9, ASN_OCTET_STR, | |
557 | { .string = { .octet = "\x00", .len = 1 }} }, | |
558 | { {1, 5, 4623, 1, 2, 3, 1, 1, 4 }, 9, ASN_OCTET_STR, | |
559 | { .string = { .octet = "\xC0", .len = 1 }} }, | |
560 | /* lldpXdot3LocLinkAggPortId */ | |
561 | { {1, 5, 4623, 1, 2, 3, 1, 2, 3 }, 9, ASN_INTEGER, { .integer = 0 }}, | |
562 | { {1, 5, 4623, 1, 2, 3, 1, 2, 4 }, 9, ASN_INTEGER, { .integer = 3 }}, | |
563 | ||
564 | /* lldpXdot3LocMaxFrameSize */ | |
565 | { {1, 5, 4623, 1, 2, 4, 1, 1, 3 }, 9, ASN_INTEGER, { .integer = 1600 }}, | |
566 | { {1, 5, 4623, 1, 2, 4, 1, 1, 4 }, 9, ASN_INTEGER, { .integer = 9000 }}, | |
567 | ||
568 | /* lldpXdot3RemPortAutoNegSupported */ | |
569 | { {1, 5, 4623, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
570 | { {1, 5, 4623, 1, 3, 1, 1, 1, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
571 | { {1, 5, 4623, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
572 | /* lldpXdot3RemPortAutoNegEnabled */ | |
573 | { {1, 5, 4623, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
574 | { {1, 5, 4623, 1, 3, 1, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
575 | { {1, 5, 4623, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
576 | /* lldpXdot3RemPortAutoNegAdvertisedCap */ | |
577 | { {1, 5, 4623, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
578 | { .string = { .octet = "\x04\x01", .len = 2 }} }, | |
579 | { {1, 5, 4623, 1, 3, 1, 1, 3, 8000, 3, 4 }, 11, ASN_OCTET_STR, | |
580 | { .string = { .octet = "\x00\x00", .len = 2 }} }, | |
581 | { {1, 5, 4623, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
582 | { .string = { .octet = "\x0c\x00", .len = 2 }} }, | |
583 | /* lldpXdot3RemPortOperMauType */ | |
584 | { {1, 5, 4623, 1, 3, 1, 1, 4, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 30 }}, | |
585 | { {1, 5, 4623, 1, 3, 1, 1, 4, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 0 }}, | |
586 | { {1, 5, 4623, 1, 3, 1, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 16 }}, | |
587 | ||
588 | /* lldpXdot3RemPowerPortClass */ | |
589 | { {1, 5, 4623, 1, 3, 2, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
590 | /* lldpXdot3RemPowerMDISupported */ | |
591 | { {1, 5, 4623, 1, 3, 2, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
592 | /* lldpXdot3RemPowerMDIEnabled */ | |
593 | { {1, 5, 4623, 1, 3, 2, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
594 | /* lldpXdot3RemPowerPairControlable */ | |
595 | { {1, 5, 4623, 1, 3, 2, 1, 4, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
596 | /* lldpXdot3RemPowerPairs */ | |
597 | { {1, 5, 4623, 1, 3, 2, 1, 5, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
598 | /* lldpXdot3RemPowerClass */ | |
599 | { {1, 5, 4623, 1, 3, 2, 1, 6, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 3 }}, | |
600 | /* As per 802.3at-2009, not sure of the OID... */ | |
601 | /* lldpXdot3RemPowerType */ | |
602 | { {1, 5, 4623, 1, 3, 2, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
603 | { .string = { .octet = "\xC0", .len = 1 } }}, | |
604 | /* lldpXdot3RemPowerSource */ | |
605 | { {1, 5, 4623, 1, 3, 2, 1, 8, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
606 | { .string = { .octet = "\xC0", .len = 1 } }}, | |
607 | /* lldpXdot3RemPowerPriority */ | |
608 | { {1, 5, 4623, 1, 3, 2, 1, 9, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1 }}, | |
609 | /* lldpXdot3RemPDRequestedPowerValue */ | |
610 | { {1, 5, 4623, 1, 3, 2, 1, 10, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2000 }}, | |
611 | /* lldpXdot3RemPSEAllocatedPowerValue */ | |
612 | { {1, 5, 4623, 1, 3, 2, 1, 11, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2500 }}, | |
613 | ||
614 | /* lldpXdot3RemLinkAggStatus */ | |
615 | { {1, 5, 4623, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
616 | { .string = { .octet = "\xC0", .len = 1 }} }, | |
617 | { {1, 5, 4623, 1, 3, 3, 1, 1, 8000, 3, 4 }, 11, ASN_OCTET_STR, | |
618 | { .string = { .octet = "\x00", .len = 1 }} }, | |
619 | { {1, 5, 4623, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
620 | { .string = { .octet = "\x00", .len = 1 }} }, | |
621 | /* lldpXdot3RemLinkAggPortId */ | |
622 | { {1, 5, 4623, 1, 3, 3, 1, 2, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 3 }}, | |
623 | { {1, 5, 4623, 1, 3, 3, 1, 2, 8000, 3, 4 }, 11, ASN_INTEGER, { .integer = 0 }}, | |
624 | { {1, 5, 4623, 1, 3, 3, 1, 2, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 0 }}, | |
625 | ||
626 | /* lldpXdot3RemMaxFrameSize */ | |
627 | { {1, 5, 4623, 1, 3, 4, 1, 1, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 9000 }}, | |
628 | { {1, 5, 4623, 1, 3, 4, 1, 1, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 1600 }}, | |
629 | #endif | |
630 | #ifdef ENABLE_LLDPMED | |
631 | /* lldpXMedLocDeviceClass */ | |
632 | { {1, 5, 4795, 1, 1, 1, 0 }, 7, ASN_INTEGER, { .integer = 2 }}, | |
633 | ||
634 | /* lldpXMedLocMediaPolicyVlanID */ | |
635 | { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 3 }, 10, ASN_INTEGER, { .integer = 475 }}, | |
636 | { {1, 5, 4795, 1, 2, 1, 1, 2, 3, 7 }, 10, ASN_INTEGER, { .integer = 472 }}, | |
637 | { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 3 }, 10, ASN_INTEGER, { .integer = 475 }}, | |
638 | { {1, 5, 4795, 1, 2, 1, 1, 2, 4, 6 }, 10, ASN_INTEGER, { .integer = 1007 }}, | |
639 | /* lldpXMedLocMediaPolicyPriority */ | |
640 | { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 3 }, 10, ASN_INTEGER, { .integer = 3 }}, | |
641 | { {1, 5, 4795, 1, 2, 1, 1, 3, 3, 7 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
642 | { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 3 }, 10, ASN_INTEGER, { .integer = 3 }}, | |
643 | { {1, 5, 4795, 1, 2, 1, 1, 3, 4, 6 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
644 | /* lldpXMedLocMediaPolicyDscp */ | |
645 | { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 3 }, 10, ASN_INTEGER, { .integer = 62 }}, | |
646 | { {1, 5, 4795, 1, 2, 1, 1, 4, 3, 7 }, 10, ASN_INTEGER, { .integer = 60 }}, | |
647 | { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 3 }, 10, ASN_INTEGER, { .integer = 62 }}, | |
648 | { {1, 5, 4795, 1, 2, 1, 1, 4, 4, 6 }, 10, ASN_INTEGER, { .integer = 49 }}, | |
649 | /* lldpXMedLocMediaPolicyUnknown */ | |
650 | { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 3 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
651 | { {1, 5, 4795, 1, 2, 1, 1, 5, 3, 7 }, 10, ASN_INTEGER, { .integer = 2 }}, | |
652 | { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 3 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
653 | { {1, 5, 4795, 1, 2, 1, 1, 5, 4, 6 }, 10, ASN_INTEGER, { .integer = 2 }}, | |
654 | /* lldpXMedLocMediaPolicyTagged */ | |
655 | { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 3 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
656 | { {1, 5, 4795, 1, 2, 1, 1, 6, 3, 7 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
657 | { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 3 }, 10, ASN_INTEGER, { .integer = 1 }}, | |
658 | { {1, 5, 4795, 1, 2, 1, 1, 6, 4, 6 }, 10, ASN_INTEGER, { .integer = 2 }}, | |
659 | ||
660 | /* lldpXMedLocHardwareRev */ | |
661 | { {1, 5, 4795, 1, 2, 2, 0 }, 7, ASN_OCTET_STR, | |
662 | { .string = { .octet = "Hardware 1", .len = 10 }} }, | |
663 | /* lldpXMedLocSoftwareRev */ | |
664 | { {1, 5, 4795, 1, 2, 4, 0 }, 7, ASN_OCTET_STR, | |
665 | { .string = { .octet = "Software 1", .len = 10 }} }, | |
666 | /* lldpXMedLocSerialNum */ | |
667 | { {1, 5, 4795, 1, 2, 5, 0 }, 7, ASN_OCTET_STR, | |
668 | { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} }, | |
669 | /* lldpXMedLocMfgName */ | |
670 | { {1, 5, 4795, 1, 2, 6, 0 }, 7, ASN_OCTET_STR, | |
671 | { .string = { .octet = "Manufacturer 1", .len = 14 }} }, | |
672 | /* lldpXMedLocModelName */ | |
673 | { {1, 5, 4795, 1, 2, 7, 0 }, 7, ASN_OCTET_STR, | |
674 | { .string = { .octet = "Model 1", .len = 7 }} }, | |
675 | /* lldpXMedLocAssetID */ | |
676 | { {1, 5, 4795, 1, 2, 8, 0 }, 7, ASN_OCTET_STR, | |
677 | { .string = { .octet = "Asset 1", .len = 7 }} }, | |
678 | ||
679 | /* lldpXMedLocLocationInfo */ | |
680 | { {1, 5, 4795, 1, 2, 9, 1, 2, 3, 3}, 10, ASN_OCTET_STR, | |
681 | { .string = { .octet = "\x15\x02FR\x06\x0dCommercial Rd\x13\x014", .len = 22 }} }, | |
682 | { {1, 5, 4795, 1, 2, 9, 1, 2, 4, 2}, 10, ASN_OCTET_STR, | |
683 | { .string = { .octet = "Not interpreted", .len = 15 }} }, | |
684 | ||
685 | /* lldpXMedLocXPoEDeviceType */ | |
686 | { {1, 5, 4795, 1, 2, 10, 0 }, 7, ASN_INTEGER, { .integer = 3 }}, | |
687 | /* lldpXMedLocXPoEPDPowerReq */ | |
688 | { {1, 5, 4795, 1, 2, 13, 0 }, 7, ASN_GAUGE, { .integer = 100 }}, | |
689 | /* lldpXMedLocXPoEPDPowerSource */ | |
690 | { {1, 5, 4795, 1, 2, 14, 0 }, 7, ASN_INTEGER, { .integer = 3 }}, | |
691 | /* lldpXMedLocXPoEPDPowerPriority */ | |
692 | { {1, 5, 4795, 1, 2, 15, 0 }, 7, ASN_INTEGER, { .integer = 3 }}, | |
693 | ||
694 | /* lldpXMedRemCapSupported */ | |
695 | { {1, 5, 4795, 1, 3, 1, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
696 | { .string = { .octet = "\xFC", .len = 1 }} }, | |
697 | { {1, 5, 4795, 1, 3, 1, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
698 | { .string = { .octet = "\xFC", .len = 1 }}}, | |
699 | /* lldpXMedRemCapCurrent */ | |
700 | { {1, 5, 4795, 1, 3, 1, 1, 2, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
701 | { .string = { .octet = "\xFC", .len = 1 }} }, | |
702 | { {1, 5, 4795, 1, 3, 1, 1, 2, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
703 | { .string = { .octet = "\xEC", .len = 1 }}}, | |
704 | /* lldpXMedRemDeviceClass */ | |
705 | { {1, 5, 4795, 1, 3, 1, 1, 3, 0, 3, 1 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
706 | { {1, 5, 4795, 1, 3, 1, 1, 3, 10000, 4, 1 }, 11, ASN_INTEGER, { .integer = 2 }}, | |
707 | ||
708 | /* lldpXMedRemMediaPolicyVlanID */ | |
709 | { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 475 }}, | |
710 | { {1, 5, 4795, 1, 3, 2, 1, 2, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 1007 }}, | |
711 | { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 475 }}, | |
712 | { {1, 5, 4795, 1, 3, 2, 1, 2, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 472 }}, | |
713 | /* lldpXMedRemMediaPolicyPriority */ | |
714 | { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 3 }}, | |
715 | { {1, 5, 4795, 1, 3, 2, 1, 3, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
716 | { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 3 }}, | |
717 | { {1, 5, 4795, 1, 3, 2, 1, 3, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
718 | /* lldpXMedLocMediaPolicyDscp */ | |
719 | { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 62 }}, | |
720 | { {1, 5, 4795, 1, 3, 2, 1, 4, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 49 }}, | |
721 | { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 62 }}, | |
722 | { {1, 5, 4795, 1, 3, 2, 1, 4, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 60 }}, | |
723 | /* lldpXMedLocMediaPolicyUnknown */ | |
724 | { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
725 | { {1, 5, 4795, 1, 3, 2, 1, 5, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 2 }}, | |
726 | { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
727 | { {1, 5, 4795, 1, 3, 2, 1, 5, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 2 }}, | |
728 | /* lldpXMedLocMediaPolicyTagged */ | |
729 | { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
730 | { {1, 5, 4795, 1, 3, 2, 1, 6, 0, 3, 1, 6 }, 12, ASN_INTEGER, { .integer = 2 }}, | |
731 | { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 3 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
732 | { {1, 5, 4795, 1, 3, 2, 1, 6, 10000, 4, 1, 7 }, 12, ASN_INTEGER, { .integer = 1 }}, | |
733 | ||
734 | /* lldpXMedRemHardwareRev */ | |
735 | { {1, 5, 4795, 1, 3, 3, 1, 1, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
736 | { .string = { .octet = "Hardware 1", .len = 10 }} }, | |
737 | { {1, 5, 4795, 1, 3, 3, 1, 1, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
738 | { .string = { .octet = "Hardware 1", .len = 10 }} }, | |
739 | /* lldpXMedRemSoftwareRev */ | |
740 | { {1, 5, 4795, 1, 3, 3, 1, 3, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
741 | { .string = { .octet = "Software 1", .len = 10 }} }, | |
742 | { {1, 5, 4795, 1, 3, 3, 1, 3, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
743 | { .string = { .octet = "Software 1", .len = 10 }} }, | |
744 | /* lldpXMedRemSerialNum */ | |
745 | { {1, 5, 4795, 1, 3, 3, 1, 4, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
746 | { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} }, | |
747 | { {1, 5, 4795, 1, 3, 3, 1, 4, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
748 | { .string = { .octet = "00-00-0000-AAAA", .len = 15 }} }, | |
749 | /* lldpXMedRemMfgName */ | |
750 | { {1, 5, 4795, 1, 3, 3, 1, 5, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
751 | { .string = { .octet = "Manufacturer 1", .len = 14 }} }, | |
752 | { {1, 5, 4795, 1, 3, 3, 1, 5, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
753 | { .string = { .octet = "Manufacturer 1", .len = 14 }} }, | |
754 | /* lldpXMedRemModelName */ | |
755 | { {1, 5, 4795, 1, 3, 3, 1, 6, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
756 | { .string = { .octet = "Model 1", .len = 7 }} }, | |
757 | { {1, 5, 4795, 1, 3, 3, 1, 6, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
758 | { .string = { .octet = "Model 1", .len = 7 }} }, | |
759 | /* lldpXMedRemAssetID */ | |
760 | { {1, 5, 4795, 1, 3, 3, 1, 7, 0, 3, 1 }, 11, ASN_OCTET_STR, | |
761 | { .string = { .octet = "Asset 1", .len = 7 }} }, | |
762 | { {1, 5, 4795, 1, 3, 3, 1, 7, 10000, 4, 1 }, 11, ASN_OCTET_STR, | |
763 | { .string = { .octet = "Asset 1", .len = 7 }} }, | |
764 | ||
765 | /* lldpXMedLocLocationInfo */ | |
766 | { {1, 5, 4795, 1, 3, 4, 1, 2, 0, 3, 1, 2}, 12, ASN_OCTET_STR, | |
767 | { .string = { .octet = "Not interpreted", .len = 15 }} }, | |
768 | { {1, 5, 4795, 1, 3, 4, 1, 2, 10000, 4, 1, 3}, 12, ASN_OCTET_STR, | |
769 | { .string = { .octet = "\x15\x02FR\x06\x0dCommercial Rd\x13\x014", .len = 22 }} }, | |
770 | ||
771 | /* lldpXMedRemXPoEDeviceType */ | |
772 | { {1, 5, 4795, 1, 3, 5, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 4 }}, | |
773 | { {1, 5, 4795, 1, 3, 5, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }}, | |
774 | ||
775 | /* lldpXMedRemXPoEPDPowerReq */ | |
776 | { {1, 5, 4795, 1, 3, 7, 1, 1, 10000, 4, 1}, 11, ASN_GAUGE, { .integer = 100 }}, | |
777 | /* lldpXMedRemXPoEPDPowerSource */ | |
778 | { {1, 5, 4795, 1, 3, 7, 1, 2, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }}, | |
779 | /* lldpXMedRemXPoEPDPowerPriority */ | |
780 | { {1, 5, 4795, 1, 3, 7, 1, 3, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 3 }}, | |
781 | ||
782 | #endif | |
783 | #ifdef ENABLE_DOT1 | |
784 | /* lldpXdot1LocPortVlanId */ | |
785 | { { 1, 5, 32962, 1, 2, 1, 1, 1, 3}, 9, ASN_INTEGER, { .integer = 47 }}, | |
786 | { { 1, 5, 32962, 1, 2, 1, 1, 1, 4}, 9, ASN_INTEGER, { .integer = 0 }}, | |
787 | /* lldpXdot1LocProtoVlanSupported */ | |
788 | { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 47}, 10, ASN_INTEGER, { .integer = 1 }}, | |
789 | { { 1, 5, 32962, 1, 2, 2, 1, 2, 3, 118}, 10, ASN_INTEGER, { .integer = 1 }}, | |
790 | /* lldpXdot1LocProtoVlanEnabled */ | |
791 | { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 47}, 10, ASN_INTEGER, { .integer = 1 }}, | |
792 | { { 1, 5, 32962, 1, 2, 2, 1, 3, 3, 118}, 10, ASN_INTEGER, { .integer = 1 }}, | |
793 | /* lldpXdot1LocVlanName */ | |
794 | { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 47}, 10, ASN_OCTET_STR, | |
795 | { .string = { .octet = "VLAN #47", .len = 8 }} }, | |
796 | { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 49}, 10, ASN_OCTET_STR, | |
797 | { .string = { .octet = "VLAN #49", .len = 8 }} }, | |
798 | { { 1, 5, 32962, 1, 2, 3, 1, 2, 3, 1449}, 10, ASN_OCTET_STR, | |
799 | { .string = { .octet = "VLAN #1449", .len = 10 }} }, | |
800 | /* lldpXdot1LocProtocolId */ | |
801 | { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 13175}, 10, ASN_OCTET_STR, | |
802 | { .string = { .octet = "\x88\xcc", .len = 2 } }}, | |
803 | { { 1, 5, 32962, 1, 2, 4, 1, 2, 3, 29020}, 10, ASN_OCTET_STR, | |
804 | { .string = { .octet = "\x88\x8e\e01", .len = 3 } }}, | |
805 | ||
806 | /* lldpXdot1RemPortVlanId */ | |
807 | { { 1, 5, 32962, 1, 3, 1, 1, 1, 0, 3, 1}, 11, ASN_INTEGER, { .integer = 0 }}, | |
808 | { { 1, 5, 32962, 1, 3, 1, 1, 1, 8000, 3, 4}, 11, ASN_INTEGER, { .integer = 0 }}, | |
809 | { { 1, 5, 32962, 1, 3, 1, 1, 1, 10000, 4, 1}, 11, ASN_INTEGER, { .integer = 47 }}, | |
810 | /* lldpXdot1RemProtoVlanSupported */ | |
811 | { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 47}, 12, ASN_INTEGER, { .integer = 1 }}, | |
812 | { { 1, 5, 32962, 1, 3, 2, 1, 2, 10000, 4, 1, 118}, 12, ASN_INTEGER, { .integer = 1 }}, | |
813 | /* lldpXdot1RemProtoVlanEnabled */ | |
814 | { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 47}, 12, ASN_INTEGER, { .integer = 1 }}, | |
815 | { { 1, 5, 32962, 1, 3, 2, 1, 3, 10000, 4, 1, 118}, 12, ASN_INTEGER, { .integer = 1 }}, | |
816 | /* lldpXdot1RemVlanName */ | |
817 | { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 47}, 12, ASN_OCTET_STR, | |
818 | { .string = { .octet = "VLAN #47", .len = 8 }} }, | |
819 | { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 49}, 12, ASN_OCTET_STR, | |
820 | { .string = { .octet = "VLAN #49", .len = 8 }} }, | |
821 | { { 1, 5, 32962, 1, 3, 3, 1, 2, 10000, 4, 1, 1449}, 12, ASN_OCTET_STR, | |
822 | { .string = { .octet = "VLAN #1449", .len = 10 }} }, | |
823 | /* lldpXdot1RemProtocolId */ | |
824 | { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 13175}, 12, ASN_OCTET_STR, | |
825 | { .string = { .octet = "\x88\xcc", .len = 2 } }}, | |
826 | { { 1, 5, 32962, 1, 3, 4, 1, 2, 10000, 4, 1, 29020}, 12, ASN_OCTET_STR, | |
827 | { .string = { .octet = "\x88\x8e\e01", .len = 3 } }}, | |
828 | #endif | |
829 | }; | |
830 | ||
831 | char* | |
832 | tohex(char *str, size_t len) | |
833 | { | |
834 | static char *hex[] = { NULL, NULL }; | |
835 | static int which = 0; | |
836 | if (hex[which]) free(hex[which]); hex[which] = NULL; | |
837 | hex[which] = malloc(len * 3 + 1); | |
838 | fail_unless(hex[which] != NULL, "Not enough memory?"); | |
839 | for (int i = 0; i < len; i++) | |
840 | snprintf(hex[which] + 3*i, 4, "%02X ", (unsigned char)str[i]); | |
841 | which = 1 - which; | |
842 | return hex[1 - which]; | |
843 | } | |
844 | ||
845 | int | |
846 | snmp_is_prefix_of(struct variable8 *vp, struct tree_node *n, char *repr) | |
847 | { | |
848 | if (n->namelen < vp->namelen) return 0; | |
849 | if (memcmp(n->name, | |
850 | vp->name, | |
851 | vp->namelen * sizeof(oid))) | |
852 | return 0; | |
853 | fail_unless(n->type == vp->type, "Inappropriate type for OID %s", repr); | |
854 | return 1; | |
855 | } | |
856 | ||
857 | void | |
858 | snmp_merge(struct variable8 *v1, struct tree_node *n, struct variable *vp, | |
859 | oid *target, size_t *targetlen) | |
860 | { | |
861 | vp->magic = v1->magic; | |
862 | vp->type = v1->type; | |
863 | vp->acl = v1->acl; | |
864 | vp->findVar = v1->findVar; | |
865 | vp->namelen = v1->namelen + | |
866 | sizeof(lldp_oid)/sizeof(oid); | |
867 | memcpy(vp->name, lldp_oid, sizeof(lldp_oid)); | |
868 | memcpy(vp->name + sizeof(lldp_oid)/sizeof(oid), | |
869 | v1->name, | |
870 | v1->namelen*sizeof(oid)); | |
871 | *targetlen = n->namelen + | |
872 | sizeof(lldp_oid)/sizeof(oid); | |
873 | memcpy(target, lldp_oid, sizeof(lldp_oid)); | |
874 | memcpy(target + sizeof(lldp_oid)/sizeof(oid), | |
875 | n->name, | |
876 | n->namelen * sizeof(oid)); | |
877 | } | |
878 | ||
879 | void | |
880 | snmp_compare(struct tree_node *n, | |
881 | u_char *result, size_t varlen, | |
882 | oid *target, size_t targetlen, char *repr) | |
883 | { | |
884 | fail_unless((targetlen == sizeof(lldp_oid)/sizeof(oid) + n->namelen) && | |
885 | !memcmp(target, lldp_oid, sizeof(lldp_oid)) && | |
886 | !memcmp(target + sizeof(lldp_oid)/sizeof(oid), | |
887 | n->name, | |
888 | n->namelen * sizeof(oid)), | |
889 | "Bad OID returned when querying %s: got %s", repr, | |
890 | snmp_oidrepr(target, targetlen)); | |
891 | switch (n->type) { | |
892 | case ASN_INTEGER: | |
893 | case ASN_TIMETICKS: | |
894 | case ASN_GAUGE: | |
895 | case ASN_COUNTER: | |
896 | fail_unless(varlen == sizeof(unsigned long int), | |
897 | "Inappropriate length for integer type for OID %s", | |
898 | repr); | |
899 | fail_unless(n->value.integer == | |
900 | *(unsigned long int *)result, | |
901 | "For OID %s, expected value %u but got %u instead", | |
902 | repr, | |
903 | n->value.integer, | |
904 | *(unsigned long int *)result); | |
905 | break; | |
906 | default: | |
907 | fail_unless(((n->value.string.len == varlen) && | |
908 | !memcmp(n->value.string.octet, | |
909 | result, varlen)), | |
910 | "OID %s: wanted %s, got %s", | |
911 | repr, | |
912 | tohex(n->value.string.octet, n->value.string.len), | |
913 | tohex((char *)result, varlen)); | |
914 | } | |
915 | } | |
916 | ||
917 | START_TEST (test_variable_order) | |
918 | { | |
919 | int i; | |
920 | for (i = 0; i < agent_lldp_vars_size() - 1; i++) { | |
921 | fail_unless(snmp_oid_compare(agent_lldp_vars[i].name, | |
922 | agent_lldp_vars[i].namelen, | |
923 | agent_lldp_vars[i+1].name, | |
924 | agent_lldp_vars[i+1].namelen) < 0, | |
925 | "Registered OID are out of orders (see %s and next one)", | |
926 | snmp_oidrepr(agent_lldp_vars[i].name, | |
927 | agent_lldp_vars[i].namelen)); | |
928 | } | |
929 | } | |
930 | END_TEST | |
931 | ||
932 | START_TEST (test_get) | |
933 | { | |
934 | int j; | |
935 | for (j = 0; | |
936 | j < sizeof(snmp_tree)/sizeof(struct tree_node); | |
937 | j++) { | |
938 | int i; | |
939 | int found = 0; | |
940 | struct variable vp; | |
941 | oid target[MAX_OID_LEN]; | |
942 | size_t targetlen; | |
943 | size_t varlen; | |
944 | u_char *result; | |
945 | WriteMethod *wmethod; | |
946 | char *repr = snmp_oidrepr(snmp_tree[j].name, | |
947 | snmp_tree[j].namelen); | |
948 | ||
949 | for (i = 0; i < agent_lldp_vars_size(); i++) { | |
950 | /* Search for the appropriate prefix. */ | |
951 | if (!snmp_is_prefix_of(&agent_lldp_vars[i], &snmp_tree[j], | |
952 | repr)) continue; | |
953 | ||
954 | /* We have our prefix. Fill out the vp struct | |
955 | correctly. We need to complete OID with | |
956 | LLDP prefix. */ | |
957 | snmp_merge(&agent_lldp_vars[i], &snmp_tree[j], &vp, target, &targetlen); | |
958 | ||
959 | /* Invoke the function */ | |
960 | result = vp.findVar(&vp, target, &targetlen, 1, &varlen, &wmethod); | |
961 | ||
962 | /* Check the result */ | |
963 | fail_unless(result != NULL, | |
964 | "No result when querying %s", repr); | |
965 | snmp_compare(&snmp_tree[j], result, varlen, target, targetlen, repr); | |
966 | ||
967 | found = 1; | |
968 | break; | |
969 | } | |
970 | if (!found) | |
971 | fail("OID %s not found", repr); | |
972 | } | |
973 | } | |
974 | END_TEST | |
975 | ||
976 | START_TEST (test_getnext) | |
977 | { | |
978 | int j; | |
979 | int end = sizeof(snmp_tree)/sizeof(struct tree_node); | |
980 | for (j = 0; | |
981 | j < end; | |
982 | j++) { | |
983 | int i; | |
984 | struct variable vp; | |
985 | oid target[MAX_OID_LEN]; | |
986 | size_t targetlen; | |
987 | size_t varlen; | |
988 | u_char *result = NULL; | |
989 | WriteMethod *wmethod; | |
990 | char *repr = snmp_oidrepr(snmp_tree[j].name, | |
991 | snmp_tree[j].namelen); | |
992 | for (i = 0; i < agent_lldp_vars_size(); i++) { | |
993 | snmp_merge(&agent_lldp_vars[i], &snmp_tree[j], &vp, target, &targetlen); | |
994 | result = vp.findVar(&vp, target, &targetlen, 0, &varlen, &wmethod); | |
995 | if (result) /* Check next! */ | |
996 | break; | |
997 | } | |
998 | if (!result) { | |
999 | fail_unless(j == end - 1, | |
1000 | "No next result found for %s", repr); | |
1001 | return; | |
1002 | } | |
1003 | fail_unless(j < end - 1, | |
1004 | "More results after %s", repr); | |
1005 | ||
1006 | /* For unknown reasons, snmp_compare can be executed | |
1007 | even when the above test fails... */ | |
1008 | if (j < end - 1) | |
1009 | snmp_compare(&snmp_tree[j+1], result, varlen, target, targetlen, repr); | |
1010 | ||
1011 | } | |
1012 | } | |
1013 | END_TEST | |
1014 | ||
1015 | Suite * | |
1016 | snmp_suite(void) | |
1017 | { | |
1018 | Suite *s = suite_create("SNMP"); | |
1019 | ||
1020 | TCase *tc_snmp = tcase_create("SNMP"); | |
1021 | tcase_add_checked_fixture(tc_snmp, snmp_config, NULL); | |
1022 | tcase_add_test(tc_snmp, test_variable_order); | |
1023 | tcase_add_test(tc_snmp, test_get); | |
1024 | tcase_add_test(tc_snmp, test_getnext); | |
1025 | suite_add_tcase(s, tc_snmp); | |
1026 | ||
1027 | return s; | |
1028 | } | |
1029 | ||
1030 | int | |
1031 | main() | |
1032 | { | |
1033 | int number_failed; | |
1034 | Suite *s = snmp_suite(); | |
1035 | SRunner *sr = srunner_create(s); | |
1036 | srunner_run_all(sr, CK_ENV); | |
1037 | number_failed = srunner_ntests_failed(sr); | |
1038 | srunner_free(sr); | |
1039 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; | |
1040 | } |