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