]>
Commit | Line | Data |
---|---|---|
7f57883e DS |
1 | /* |
2 | * EIGRP SNMP Support. | |
3 | * Copyright (C) 2013-2014 | |
4 | * Authors: | |
5 | * Donnie Savage | |
6 | * Jan Janovic | |
7 | * Matej Perina | |
8 | * Peter Orsag | |
9 | * Peter Paluch | |
10 | * | |
11 | * This file is part of GNU Zebra. | |
12 | * | |
13 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
14 | * under the terms of the GNU General Public License as published by the | |
15 | * Free Software Foundation; either version 2, or (at your option) any | |
16 | * later version. | |
17 | * | |
18 | * GNU Zebra is distributed in the hope that it will be useful, but | |
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | * General Public License for more details. | |
22 | * | |
896014f4 DL |
23 | * You should have received a copy of the GNU General Public License along |
24 | * with this program; see the file COPYING; if not, write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
7f57883e DS |
26 | */ |
27 | ||
28 | #include <zebra.h> | |
29 | ||
30 | #ifdef HAVE_SNMP | |
31 | #include <net-snmp/net-snmp-config.h> | |
32 | #include <net-snmp/net-snmp-includes.h> | |
33 | ||
34 | #include "thread.h" | |
35 | #include "memory.h" | |
36 | #include "linklist.h" | |
37 | #include "prefix.h" | |
38 | #include "if.h" | |
39 | #include "table.h" | |
40 | #include "sockunion.h" | |
41 | #include "stream.h" | |
42 | #include "log.h" | |
43 | #include "sockopt.h" | |
44 | #include "checksum.h" | |
45 | #include "md5.h" | |
46 | #include "keychain.h" | |
47 | #include "smux.h" | |
48 | ||
49 | #include "eigrpd/eigrp_structs.h" | |
50 | #include "eigrpd/eigrpd.h" | |
51 | #include "eigrpd/eigrp_interface.h" | |
52 | #include "eigrpd/eigrp_neighbor.h" | |
53 | #include "eigrpd/eigrp_packet.h" | |
54 | #include "eigrpd/eigrp_zebra.h" | |
55 | #include "eigrpd/eigrp_vty.h" | |
56 | #include "eigrpd/eigrp_dump.h" | |
57 | #include "eigrpd/eigrp_network.h" | |
58 | #include "eigrpd/eigrp_topology.h" | |
59 | #include "eigrpd/eigrp_fsm.h" | |
60 | #include "eigrpd/eigrp_snmp.h" | |
61 | ||
7f57883e DS |
62 | struct list *eigrp_snmp_iflist; |
63 | ||
64 | /* Declare static local variables for convenience. */ | |
65 | SNMP_LOCAL_VARIABLES | |
66 | ||
67 | /* EIGRP-MIB - 1.3.6.1.4.1.9.9.449.1*/ | |
68 | #define EIGRPMIB 1,3,6,1,4,1,9,9,449,1 | |
69 | ||
70 | /* EIGRP-MIB instances. */ | |
d62a17ae | 71 | oid eigrp_oid[] = {EIGRPMIB}; |
7f57883e DS |
72 | |
73 | /* EIGRP VPN entry */ | |
f9e5c9ca | 74 | #define EIGRPVPNID 1 |
7f57883e DS |
75 | #define EIGRPVPNNAME 2 |
76 | ||
77 | /* EIGRP Traffic statistics entry */ | |
f9e5c9ca DS |
78 | #define EIGRPASNUMBER 1 |
79 | #define EIGRPNBRCOUNT 2 | |
80 | #define EIGRPHELLOSSENT 3 | |
81 | #define EIGRPHELLOSRCVD 4 | |
82 | #define EIGRPUPDATESSENT 5 | |
83 | #define EIGRPUPDATESRCVD 6 | |
84 | #define EIGRPQUERIESSENT 7 | |
85 | #define EIGRPQUERIESRCVD 8 | |
86 | #define EIGRPREPLIESSENT 9 | |
87 | #define EIGRPREPLIESRCVD 10 | |
88 | #define EIGRPACKSSENT 11 | |
89 | #define EIGRPACKSRCVD 12 | |
90 | #define EIGRPINPUTQHIGHMARK 13 | |
91 | #define EIGRPINPUTQDROPS 14 | |
92 | #define EIGRPSIAQUERIESSENT 15 | |
93 | #define EIGRPSIAQUERIESRCVD 16 | |
94 | #define EIGRPASROUTERIDTYPE 17 | |
95 | #define EIGRPASROUTERID 18 | |
96 | #define EIGRPTOPOROUTES 19 | |
97 | #define EIGRPHEADSERIAL 20 | |
98 | #define EIGRPNEXTSERIAL 21 | |
7f57883e | 99 | #define EIGRPXMITPENDREPLIES 22 |
f9e5c9ca | 100 | #define EIGRPXMITDUMMIES 23 |
7f57883e DS |
101 | |
102 | /* EIGRP topology entry */ | |
f9e5c9ca DS |
103 | #define EIGRPDESTNETTYPE 1 |
104 | #define EIGRPDESTNET 2 | |
7f57883e | 105 | #define EIGRPDESTNETPREFIXLEN 4 |
f9e5c9ca DS |
106 | #define EIGRPACTIVE 5 |
107 | #define EIGRPSTUCKINACTIVE 6 | |
108 | #define EIGRPDESTSUCCESSORS 7 | |
109 | #define EIGRPFDISTANCE 8 | |
7f57883e DS |
110 | #define EIGRPROUTEORIGINTYPE 9 |
111 | #define EIGRPROUTEORIGINADDRTYPE 10 | |
112 | #define EIGRPROUTEORIGINADDR 11 | |
113 | #define EIGRPNEXTHOPADDRESSTYPE 12 | |
f9e5c9ca | 114 | #define EIGRPNEXTHOPADDRESS 13 |
7f57883e | 115 | #define EIGRPNEXTHOPINTERFACE 14 |
f9e5c9ca DS |
116 | #define EIGRPDISTANCE 15 |
117 | #define EIGRPREPORTDISTANCE 16 | |
7f57883e DS |
118 | |
119 | /* EIGRP peer entry */ | |
120 | #define EIGRPHANDLE 1 | |
121 | #define EIGRPPEERADDRTYPE 2 | |
122 | #define EIGRPPEERADDR 3 | |
123 | #define EIGRPPEERIFINDEX 4 | |
124 | #define EIGRPHOLDTIME 5 | |
125 | #define EIGRPUPTIME 6 | |
126 | #define EIGRPSRTT 7 | |
127 | #define EIGRPRTO 8 | |
128 | #define EIGRPPKTSENQUEUED 9 | |
129 | #define EIGRPLASTSEQ 10 | |
130 | #define EIGRPVERSION 11 | |
131 | #define EIGRPRETRANS 12 | |
132 | #define EIGRPRETRIES 13 | |
133 | ||
134 | /* EIGRP interface entry */ | |
135 | #define EIGRPPEERCOUNT 3 | |
136 | #define EIGRPXMITRELIABLEQ 4 | |
137 | #define EIGRPXMITUNRELIABLEQ 5 | |
138 | #define EIGRPMEANSRTT 6 | |
139 | #define EIGRPPACINGRELIABLE 7 | |
140 | #define EIGRPPACINGUNRELIABLE 8 | |
141 | #define EIGRPMFLOWTIMER 9 | |
142 | #define EIGRPPENDINGROUTES 10 | |
143 | #define EIGRPHELLOINTERVAL 11 | |
144 | #define EIGRPXMITNEXTSERIAL 12 | |
145 | #define EIGRPUMCASTS 13 | |
146 | #define EIGRPRMCASTS 14 | |
147 | #define EIGRPUUCASTS 15 | |
148 | #define EIGRPRUCASTS 16 | |
149 | #define EIGRPMCASTEXCEPTS 17 | |
150 | #define EIGRPCRPKTS 18 | |
151 | #define EIGRPACKSSUPPRESSED 19 | |
152 | #define EIGRPRETRANSSENT 20 | |
153 | #define EIGRPOOSRCVD 21 | |
154 | #define EIGRPAUTHMODE 22 | |
155 | #define EIGRPAUTHKEYCHAIN 23 | |
156 | ||
157 | /* SNMP value hack. */ | |
158 | #define COUNTER ASN_COUNTER | |
159 | #define INTEGER ASN_INTEGER | |
160 | #define GAUGE ASN_GAUGE | |
161 | #define TIMETICKS ASN_TIMETICKS | |
162 | #define IPADDRESS ASN_IPADDRESS | |
163 | #define STRING ASN_OCTET_STR | |
164 | #define IPADDRESSPREFIXLEN ASN_INTEGER | |
165 | #define IPADDRESSTYPE ASN_INTEGER | |
166 | #define INTERFACEINDEXORZERO ASN_INTEGER | |
167 | #define UINTEGER ASN_UNSIGNED | |
168 | ||
7f57883e | 169 | /* Hook functions. */ |
d7c0a89a | 170 | static uint8_t *eigrpVpnEntry(struct variable *, oid *, size_t *, int, size_t *, |
d62a17ae | 171 | WriteMethod **); |
d7c0a89a QY |
172 | static uint8_t *eigrpTraffStatsEntry(struct variable *, oid *, size_t *, int, |
173 | size_t *, WriteMethod **); | |
174 | static uint8_t *eigrpTopologyEntry(struct variable *, oid *, size_t *, int, | |
d62a17ae | 175 | size_t *, WriteMethod **); |
d7c0a89a QY |
176 | static uint8_t *eigrpPeerEntry(struct variable *, oid *, size_t *, int, |
177 | size_t *, WriteMethod **); | |
178 | static uint8_t *eigrpInterfaceEntry(struct variable *, oid *, size_t *, int, | |
179 | size_t *, WriteMethod **); | |
d62a17ae | 180 | |
181 | ||
182 | struct variable eigrp_variables[] = { | |
183 | /* EIGRP vpn variables */ | |
184 | {EIGRPVPNID, INTEGER, NOACCESS, eigrpVpnEntry, 4, {1, 1, 1, 1}}, | |
185 | {EIGRPVPNNAME, STRING, RONLY, eigrpVpnEntry, 4, {1, 1, 1, 2}}, | |
186 | ||
187 | /* EIGRP traffic stats variables */ | |
188 | {EIGRPASNUMBER, | |
189 | UINTEGER, | |
190 | NOACCESS, | |
191 | eigrpTraffStatsEntry, | |
192 | 4, | |
193 | {2, 1, 1, 1}}, | |
194 | {EIGRPNBRCOUNT, UINTEGER, RONLY, eigrpTraffStatsEntry, 4, {2, 1, 1, 2}}, | |
195 | {EIGRPHELLOSSENT, | |
196 | COUNTER, | |
197 | RONLY, | |
198 | eigrpTraffStatsEntry, | |
199 | 4, | |
200 | {2, 1, 1, 3}}, | |
201 | {EIGRPHELLOSRCVD, | |
202 | COUNTER, | |
203 | RONLY, | |
204 | eigrpTraffStatsEntry, | |
205 | 4, | |
206 | {2, 1, 1, 4}}, | |
207 | {EIGRPUPDATESSENT, | |
208 | COUNTER, | |
209 | RONLY, | |
210 | eigrpTraffStatsEntry, | |
211 | 4, | |
212 | {2, 1, 1, 5}}, | |
213 | {EIGRPUPDATESRCVD, | |
214 | COUNTER, | |
215 | RONLY, | |
216 | eigrpTraffStatsEntry, | |
217 | 4, | |
218 | {2, 1, 1, 6}}, | |
219 | {EIGRPQUERIESSENT, | |
220 | COUNTER, | |
221 | RONLY, | |
222 | eigrpTraffStatsEntry, | |
223 | 4, | |
224 | {2, 1, 1, 7}}, | |
225 | {EIGRPQUERIESRCVD, | |
226 | COUNTER, | |
227 | RONLY, | |
228 | eigrpTraffStatsEntry, | |
229 | 4, | |
230 | {2, 1, 1, 8}}, | |
231 | {EIGRPREPLIESSENT, | |
232 | COUNTER, | |
233 | RONLY, | |
234 | eigrpTraffStatsEntry, | |
235 | 4, | |
236 | {2, 1, 1, 9}}, | |
237 | {EIGRPREPLIESRCVD, | |
238 | COUNTER, | |
239 | RONLY, | |
240 | eigrpTraffStatsEntry, | |
241 | 4, | |
242 | {2, 1, 1, 10}}, | |
243 | {EIGRPACKSSENT, COUNTER, RONLY, eigrpTraffStatsEntry, 4, {2, 1, 1, 11}}, | |
244 | {EIGRPACKSRCVD, COUNTER, RONLY, eigrpTraffStatsEntry, 4, {2, 1, 1, 12}}, | |
245 | {EIGRPINPUTQHIGHMARK, | |
246 | INTEGER, | |
247 | RONLY, | |
248 | eigrpTraffStatsEntry, | |
249 | 4, | |
250 | {2, 1, 1, 13}}, | |
251 | {EIGRPINPUTQDROPS, | |
252 | COUNTER, | |
253 | RONLY, | |
254 | eigrpTraffStatsEntry, | |
255 | 4, | |
256 | {2, 1, 1, 14}}, | |
257 | {EIGRPSIAQUERIESSENT, | |
258 | COUNTER, | |
259 | RONLY, | |
260 | eigrpTraffStatsEntry, | |
261 | 4, | |
262 | {2, 1, 1, 15}}, | |
263 | {EIGRPSIAQUERIESRCVD, | |
264 | COUNTER, | |
265 | RONLY, | |
266 | eigrpTraffStatsEntry, | |
267 | 4, | |
268 | {2, 1, 1, 16}}, | |
269 | {EIGRPASROUTERIDTYPE, | |
270 | IPADDRESSTYPE, | |
271 | RONLY, | |
272 | eigrpTraffStatsEntry, | |
273 | 4, | |
274 | {2, 1, 1, 17}}, | |
275 | {EIGRPASROUTERID, | |
276 | IPADDRESS, | |
277 | RONLY, | |
278 | eigrpTraffStatsEntry, | |
279 | 4, | |
280 | {2, 1, 1, 18}}, | |
281 | {EIGRPTOPOROUTES, | |
282 | COUNTER, | |
283 | RONLY, | |
284 | eigrpTraffStatsEntry, | |
285 | 4, | |
286 | {2, 1, 1, 19}}, | |
287 | {EIGRPHEADSERIAL, | |
288 | COUNTER, | |
289 | RONLY, | |
290 | eigrpTraffStatsEntry, | |
291 | 4, | |
292 | {2, 1, 1, 20}}, | |
293 | {EIGRPNEXTSERIAL, | |
294 | COUNTER, | |
295 | RONLY, | |
296 | eigrpTraffStatsEntry, | |
297 | 4, | |
298 | {2, 1, 1, 21}}, | |
299 | {EIGRPXMITPENDREPLIES, | |
300 | INTEGER, | |
301 | RONLY, | |
302 | eigrpTraffStatsEntry, | |
303 | 4, | |
304 | {2, 1, 1, 22}}, | |
305 | {EIGRPXMITDUMMIES, | |
306 | COUNTER, | |
307 | RONLY, | |
308 | eigrpTraffStatsEntry, | |
309 | 4, | |
310 | {2, 1, 1, 23}}, | |
311 | ||
312 | /* EIGRP topology variables */ | |
313 | {EIGRPDESTNETTYPE, | |
314 | IPADDRESSTYPE, | |
315 | NOACCESS, | |
316 | eigrpTopologyEntry, | |
317 | 4, | |
318 | {3, 1, 1, 1}}, | |
319 | {EIGRPDESTNET, | |
320 | IPADDRESSPREFIXLEN, | |
321 | NOACCESS, | |
322 | eigrpTopologyEntry, | |
323 | 4, | |
324 | {3, 1, 1, 2}}, | |
325 | {EIGRPDESTNETPREFIXLEN, | |
326 | IPADDRESSTYPE, | |
327 | NOACCESS, | |
328 | eigrpTopologyEntry, | |
329 | 4, | |
330 | {3, 1, 1, 4}}, | |
331 | {EIGRPACTIVE, INTEGER, RONLY, eigrpTopologyEntry, 4, {3, 1, 1, 5}}, | |
332 | {EIGRPSTUCKINACTIVE, | |
333 | INTEGER, | |
334 | RONLY, | |
335 | eigrpTopologyEntry, | |
336 | 4, | |
337 | {3, 1, 1, 6}}, | |
338 | {EIGRPDESTSUCCESSORS, | |
339 | INTEGER, | |
340 | RONLY, | |
341 | eigrpTopologyEntry, | |
342 | 4, | |
343 | {3, 1, 1, 7}}, | |
344 | {EIGRPFDISTANCE, INTEGER, RONLY, eigrpTopologyEntry, 4, {3, 1, 1, 8}}, | |
345 | {EIGRPROUTEORIGINTYPE, | |
346 | STRING, | |
347 | RONLY, | |
348 | eigrpTopologyEntry, | |
349 | 4, | |
350 | {3, 1, 1, 9}}, | |
351 | {EIGRPROUTEORIGINADDRTYPE, | |
352 | IPADDRESSTYPE, | |
353 | RONLY, | |
354 | eigrpTopologyEntry, | |
355 | 4, | |
356 | {3, 1, 1, 10}}, | |
357 | {EIGRPROUTEORIGINADDR, | |
358 | IPADDRESS, | |
359 | RONLY, | |
360 | eigrpTopologyEntry, | |
361 | 4, | |
362 | {3, 1, 1, 11}}, | |
363 | {EIGRPNEXTHOPADDRESSTYPE, | |
364 | IPADDRESSTYPE, | |
365 | RONLY, | |
366 | eigrpTopologyEntry, | |
367 | 4, | |
368 | {3, 1, 1, 12}}, | |
369 | {EIGRPNEXTHOPADDRESS, | |
370 | IPADDRESS, | |
371 | RONLY, | |
372 | eigrpTopologyEntry, | |
373 | 4, | |
374 | {3, 1, 1, 13}}, | |
375 | {EIGRPNEXTHOPINTERFACE, | |
376 | STRING, | |
377 | RONLY, | |
378 | eigrpTopologyEntry, | |
379 | 4, | |
380 | {3, 1, 1, 14}}, | |
381 | {EIGRPDISTANCE, INTEGER, RONLY, eigrpTopologyEntry, 4, {3, 1, 1, 15}}, | |
382 | {EIGRPREPORTDISTANCE, | |
383 | INTEGER, | |
384 | RONLY, | |
385 | eigrpTopologyEntry, | |
386 | 4, | |
387 | {3, 1, 1, 16}}, | |
388 | ||
389 | /* EIGRP peer variables */ | |
390 | {EIGRPHANDLE, INTEGER, NOACCESS, eigrpPeerEntry, 4, {4, 1, 1, 1}}, | |
391 | {EIGRPPEERADDRTYPE, | |
392 | IPADDRESSTYPE, | |
393 | RONLY, | |
394 | eigrpPeerEntry, | |
395 | 4, | |
396 | {4, 1, 1, 2}}, | |
397 | {EIGRPPEERADDR, IPADDRESS, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 3}}, | |
398 | {EIGRPPEERIFINDEX, | |
399 | INTERFACEINDEXORZERO, | |
400 | RONLY, | |
401 | eigrpPeerEntry, | |
402 | 4, | |
403 | {4, 1, 1, 4}}, | |
404 | {EIGRPHOLDTIME, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 5}}, | |
405 | {EIGRPUPTIME, STRING, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 6}}, | |
406 | {EIGRPSRTT, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 7}}, | |
407 | {EIGRPRTO, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 8}}, | |
408 | {EIGRPPKTSENQUEUED, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 9}}, | |
409 | {EIGRPLASTSEQ, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 10}}, | |
410 | {EIGRPVERSION, STRING, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 11}}, | |
411 | {EIGRPRETRANS, COUNTER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 12}}, | |
412 | {EIGRPRETRIES, INTEGER, RONLY, eigrpPeerEntry, 4, {4, 1, 1, 13}}, | |
413 | ||
414 | /* EIGRP interface variables */ | |
415 | {EIGRPPEERCOUNT, GAUGE, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 3}}, | |
416 | {EIGRPXMITRELIABLEQ, | |
417 | GAUGE, | |
418 | RONLY, | |
419 | eigrpInterfaceEntry, | |
420 | 4, | |
421 | {5, 1, 1, 4}}, | |
422 | {EIGRPXMITUNRELIABLEQ, | |
423 | GAUGE, | |
424 | RONLY, | |
425 | eigrpInterfaceEntry, | |
426 | 4, | |
427 | {5, 1, 1, 5}}, | |
428 | {EIGRPMEANSRTT, INTEGER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 6}}, | |
429 | {EIGRPPACINGRELIABLE, | |
430 | INTEGER, | |
431 | RONLY, | |
432 | eigrpInterfaceEntry, | |
433 | 4, | |
434 | {5, 1, 1, 7}}, | |
435 | {EIGRPPACINGUNRELIABLE, | |
436 | INTEGER, | |
437 | RONLY, | |
438 | eigrpInterfaceEntry, | |
439 | 4, | |
440 | {5, 1, 1, 8}}, | |
441 | {EIGRPMFLOWTIMER, INTEGER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 9}}, | |
442 | {EIGRPPENDINGROUTES, | |
443 | GAUGE, | |
444 | RONLY, | |
445 | eigrpInterfaceEntry, | |
446 | 4, | |
447 | {5, 1, 1, 10}}, | |
448 | {EIGRPHELLOINTERVAL, | |
449 | INTEGER, | |
450 | RONLY, | |
451 | eigrpInterfaceEntry, | |
452 | 4, | |
453 | {5, 1, 1, 11}}, | |
454 | {EIGRPXMITNEXTSERIAL, | |
455 | COUNTER, | |
456 | RONLY, | |
457 | eigrpInterfaceEntry, | |
458 | 4, | |
459 | {5, 1, 1, 12}}, | |
460 | {EIGRPUMCASTS, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 13}}, | |
461 | {EIGRPRMCASTS, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 14}}, | |
462 | {EIGRPUUCASTS, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 15}}, | |
463 | {EIGRPRUCASTS, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 16}}, | |
464 | {EIGRPMCASTEXCEPTS, | |
465 | COUNTER, | |
466 | RONLY, | |
467 | eigrpInterfaceEntry, | |
468 | 4, | |
469 | {5, 1, 1, 17}}, | |
470 | {EIGRPCRPKTS, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 18}}, | |
471 | {EIGRPACKSSUPPRESSED, | |
472 | COUNTER, | |
473 | RONLY, | |
474 | eigrpInterfaceEntry, | |
475 | 4, | |
476 | {5, 1, 1, 19}}, | |
477 | {EIGRPRETRANSSENT, | |
478 | COUNTER, | |
479 | RONLY, | |
480 | eigrpInterfaceEntry, | |
481 | 4, | |
482 | {5, 1, 1, 20}}, | |
483 | {EIGRPOOSRCVD, COUNTER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 21}}, | |
484 | {EIGRPAUTHMODE, INTEGER, RONLY, eigrpInterfaceEntry, 4, {5, 1, 1, 22}}, | |
485 | {EIGRPAUTHKEYCHAIN, | |
486 | STRING, | |
487 | RONLY, | |
488 | eigrpInterfaceEntry, | |
489 | 4, | |
490 | {5, 1, 1, 23}}}; | |
491 | ||
492 | static struct eigrp_neighbor *eigrp_snmp_nbr_lookup(struct eigrp *eigrp, | |
493 | struct in_addr *nbr_addr, | |
494 | unsigned int *ifindex) | |
7f57883e | 495 | { |
d62a17ae | 496 | struct listnode *node, *nnode, *node2, *nnode2; |
497 | struct eigrp_interface *ei; | |
498 | struct eigrp_neighbor *nbr; | |
499 | ||
500 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, ei)) { | |
501 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
502 | if (IPV4_ADDR_SAME(&nbr->src, nbr_addr)) { | |
503 | return nbr; | |
504 | } | |
505 | } | |
506 | } | |
507 | return NULL; | |
7f57883e DS |
508 | } |
509 | ||
510 | static struct eigrp_neighbor * | |
d62a17ae | 511 | eigrp_snmp_nbr_lookup_next(struct in_addr *nbr_addr, unsigned int *ifindex, |
512 | int first) | |
7f57883e | 513 | { |
d62a17ae | 514 | struct listnode *node, *nnode, *node2, *nnode2; |
515 | struct eigrp_interface *ei; | |
516 | struct eigrp_neighbor *nbr; | |
d62a17ae | 517 | struct eigrp_neighbor *min = NULL; |
1aa37b48 | 518 | struct eigrp *eigrp; |
d62a17ae | 519 | |
520 | eigrp = eigrp_lookup(); | |
521 | ||
522 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, ei)) { | |
523 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
524 | if (first) { | |
525 | if (!min) | |
526 | min = nbr; | |
527 | else if (ntohl(nbr->src.s_addr) | |
528 | < ntohl(min->src.s_addr)) | |
529 | min = nbr; | |
530 | } else if (ntohl(nbr->src.s_addr) | |
531 | > ntohl(nbr_addr->s_addr)) { | |
532 | if (!min) | |
533 | min = nbr; | |
534 | else if (ntohl(nbr->src.s_addr) | |
535 | < ntohl(min->src.s_addr)) | |
536 | min = nbr; | |
537 | } | |
538 | } | |
539 | } | |
540 | if (min) { | |
541 | *nbr_addr = min->src; | |
542 | *ifindex = 0; | |
543 | return min; | |
544 | } | |
545 | return NULL; | |
7f57883e DS |
546 | } |
547 | ||
d62a17ae | 548 | static struct eigrp_neighbor *eigrpNbrLookup(struct variable *v, oid *name, |
549 | size_t *length, | |
550 | struct in_addr *nbr_addr, | |
551 | unsigned int *ifindex, int exact) | |
7f57883e | 552 | { |
d62a17ae | 553 | unsigned int len; |
554 | int first; | |
555 | struct eigrp_neighbor *nbr; | |
556 | struct eigrp *eigrp; | |
557 | ||
558 | eigrp = eigrp_lookup(); | |
559 | ||
560 | if (!eigrp) | |
561 | return NULL; | |
562 | ||
563 | if (exact) { | |
564 | if (*length != v->namelen + IN_ADDR_SIZE + 1) | |
565 | return NULL; | |
566 | ||
567 | oid2in_addr(name + v->namelen, IN_ADDR_SIZE, nbr_addr); | |
568 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
569 | ||
570 | return eigrp_snmp_nbr_lookup(eigrp, nbr_addr, ifindex); | |
571 | } else { | |
572 | first = 0; | |
573 | len = *length - v->namelen; | |
574 | ||
d11c6941 | 575 | if (len == 0) |
d62a17ae | 576 | first = 1; |
577 | ||
578 | if (len > IN_ADDR_SIZE) | |
579 | len = IN_ADDR_SIZE; | |
580 | ||
581 | oid2in_addr(name + v->namelen, len, nbr_addr); | |
582 | ||
583 | len = *length - v->namelen - IN_ADDR_SIZE; | |
584 | if (len >= 1) | |
585 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
586 | ||
587 | nbr = eigrp_snmp_nbr_lookup_next(nbr_addr, ifindex, first); | |
588 | ||
589 | if (nbr) { | |
590 | *length = v->namelen + IN_ADDR_SIZE + 1; | |
9e263221 | 591 | oid_copy_in_addr(name + v->namelen, nbr_addr); |
d62a17ae | 592 | name[v->namelen + IN_ADDR_SIZE] = *ifindex; |
593 | return nbr; | |
594 | } | |
595 | } | |
596 | return NULL; | |
7f57883e DS |
597 | } |
598 | ||
599 | ||
d7c0a89a QY |
600 | static uint8_t *eigrpVpnEntry(struct variable *v, oid *name, size_t *length, |
601 | int exact, size_t *var_len, | |
602 | WriteMethod **write_method) | |
f9e5c9ca | 603 | { |
d62a17ae | 604 | struct eigrp *eigrp; |
605 | ||
606 | eigrp = eigrp_lookup(); | |
607 | ||
608 | /* Check whether the instance identifier is valid */ | |
609 | if (smux_header_generic(v, name, length, exact, var_len, write_method) | |
610 | == MATCH_FAILED) | |
611 | return NULL; | |
612 | ||
613 | /* Return the current value of the variable */ | |
614 | switch (v->magic) { | |
615 | case EIGRPVPNID: /* 1 */ | |
616 | /* The unique VPN identifier */ | |
617 | if (eigrp) { | |
618 | return SNMP_INTEGER(1); | |
619 | } else | |
620 | return SNMP_INTEGER(0); | |
d62a17ae | 621 | case EIGRPVPNNAME: /* 2 */ |
622 | /* The name given to the VPN */ | |
623 | if (eigrp) { | |
624 | return SNMP_INTEGER(1); | |
625 | } else | |
626 | return SNMP_INTEGER(0); | |
d62a17ae | 627 | default: |
628 | return NULL; | |
629 | } | |
630 | return NULL; | |
f9e5c9ca DS |
631 | } |
632 | ||
d62a17ae | 633 | static uint32_t eigrp_neighbor_count(struct eigrp *eigrp) |
f9e5c9ca | 634 | { |
d62a17ae | 635 | uint32_t count; |
636 | struct eigrp_interface *ei; | |
637 | struct listnode *node, *node2, *nnode2; | |
638 | struct eigrp_neighbor *nbr; | |
639 | ||
640 | if (eigrp == NULL) { | |
641 | return 0; | |
642 | } | |
643 | ||
644 | count = 0; | |
645 | for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) { | |
646 | for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) { | |
647 | if (nbr->state == EIGRP_NEIGHBOR_UP) | |
648 | count++; | |
649 | } | |
650 | } | |
651 | ||
652 | return count; | |
f9e5c9ca | 653 | } |
7f57883e DS |
654 | |
655 | ||
d7c0a89a QY |
656 | static uint8_t *eigrpTraffStatsEntry(struct variable *v, oid *name, |
657 | size_t *length, int exact, size_t *var_len, | |
658 | WriteMethod **write_method) | |
f9e5c9ca | 659 | { |
d62a17ae | 660 | struct eigrp *eigrp; |
661 | struct eigrp_interface *ei; | |
662 | struct listnode *node, *nnode; | |
663 | int counter; | |
664 | ||
665 | eigrp = eigrp_lookup(); | |
666 | ||
667 | /* Check whether the instance identifier is valid */ | |
668 | if (smux_header_generic(v, name, length, exact, var_len, write_method) | |
669 | == MATCH_FAILED) | |
670 | return NULL; | |
671 | ||
672 | /* Return the current value of the variable */ | |
673 | switch (v->magic) { | |
674 | case EIGRPASNUMBER: /* 1 */ | |
675 | /* AS-number of this EIGRP instance. */ | |
676 | if (eigrp) | |
677 | return SNMP_INTEGER(eigrp->AS); | |
678 | else | |
679 | return SNMP_INTEGER(0); | |
d62a17ae | 680 | case EIGRPNBRCOUNT: /* 2 */ |
681 | /* Neighbor count of this EIGRP instance */ | |
682 | if (eigrp) | |
683 | return SNMP_INTEGER(eigrp_neighbor_count(eigrp)); | |
684 | else | |
685 | return SNMP_INTEGER(0); | |
d62a17ae | 686 | case EIGRPHELLOSSENT: /* 3 */ |
687 | /* Hello packets output count */ | |
688 | if (eigrp) { | |
689 | counter = 0; | |
690 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
691 | ei)) { | |
692 | counter += ei->hello_out; | |
693 | } | |
694 | return SNMP_INTEGER(counter); | |
695 | } else | |
696 | return SNMP_INTEGER(0); | |
d62a17ae | 697 | case EIGRPHELLOSRCVD: /* 4 */ |
698 | /* Hello packets input count */ | |
699 | if (eigrp) { | |
700 | counter = 0; | |
701 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
702 | ei)) { | |
703 | counter += ei->hello_in; | |
704 | } | |
705 | return SNMP_INTEGER(counter); | |
706 | } else | |
707 | return SNMP_INTEGER(0); | |
d62a17ae | 708 | case EIGRPUPDATESSENT: /* 5 */ |
709 | /* Update packets output count */ | |
710 | if (eigrp) { | |
711 | counter = 0; | |
712 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
713 | ei)) { | |
714 | counter += ei->update_out; | |
715 | } | |
716 | return SNMP_INTEGER(counter); | |
717 | } else | |
718 | return SNMP_INTEGER(0); | |
d62a17ae | 719 | case EIGRPUPDATESRCVD: /* 6 */ |
720 | /* Update packets input count */ | |
721 | if (eigrp) { | |
722 | counter = 0; | |
723 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
724 | ei)) { | |
725 | counter += ei->update_in; | |
726 | } | |
727 | return SNMP_INTEGER(counter); | |
728 | } else | |
729 | return SNMP_INTEGER(0); | |
d62a17ae | 730 | case EIGRPQUERIESSENT: /* 7 */ |
731 | /* Querry packets output count */ | |
732 | if (eigrp) { | |
733 | counter = 0; | |
734 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
735 | ei)) { | |
736 | counter += ei->query_out; | |
737 | } | |
738 | return SNMP_INTEGER(counter); | |
739 | } else | |
740 | return SNMP_INTEGER(0); | |
d62a17ae | 741 | case EIGRPQUERIESRCVD: /* 8 */ |
742 | /* Querry packets input count */ | |
743 | if (eigrp) { | |
744 | counter = 0; | |
745 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
746 | ei)) { | |
747 | counter += ei->query_in; | |
748 | } | |
749 | return SNMP_INTEGER(counter); | |
750 | } else | |
751 | return SNMP_INTEGER(0); | |
d62a17ae | 752 | case EIGRPREPLIESSENT: /* 9 */ |
753 | /* Reply packets output count */ | |
754 | if (eigrp) { | |
755 | counter = 0; | |
756 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
757 | ei)) { | |
758 | counter += ei->reply_out; | |
759 | } | |
760 | return SNMP_INTEGER(counter); | |
761 | } else | |
762 | return SNMP_INTEGER(0); | |
d62a17ae | 763 | case EIGRPREPLIESRCVD: /* 10 */ |
764 | /* Reply packets input count */ | |
765 | if (eigrp) { | |
766 | counter = 0; | |
767 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
768 | ei)) { | |
769 | counter += ei->reply_in; | |
770 | } | |
771 | return SNMP_INTEGER(counter); | |
772 | } else | |
773 | return SNMP_INTEGER(0); | |
d62a17ae | 774 | case EIGRPACKSSENT: /* 11 */ |
775 | /* Acknowledgement packets output count */ | |
776 | if (eigrp) { | |
777 | counter = 0; | |
778 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
779 | ei)) { | |
780 | counter += ei->ack_out; | |
781 | } | |
782 | return SNMP_INTEGER(counter); | |
783 | } else | |
784 | return SNMP_INTEGER(0); | |
d62a17ae | 785 | case EIGRPACKSRCVD: /* 12 */ |
786 | /* Acknowledgement packets input count */ | |
787 | if (eigrp) { | |
788 | counter = 0; | |
789 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
790 | ei)) { | |
791 | counter += ei->ack_in; | |
792 | } | |
793 | return SNMP_INTEGER(counter); | |
794 | } else | |
795 | return SNMP_INTEGER(0); | |
d62a17ae | 796 | case EIGRPINPUTQHIGHMARK: /* 13 */ |
797 | /* The highest number of EIGRP packets in the input queue */ | |
798 | if (eigrp) { | |
799 | return SNMP_INTEGER(1); | |
800 | } else | |
801 | return SNMP_INTEGER(0); | |
d62a17ae | 802 | case EIGRPINPUTQDROPS: /* 14 */ |
803 | /* The number of EIGRP packets dropped from the input queue */ | |
804 | if (eigrp) { | |
805 | return SNMP_INTEGER(1); | |
806 | } else | |
807 | return SNMP_INTEGER(0); | |
d62a17ae | 808 | case EIGRPSIAQUERIESSENT: /* 15 */ |
809 | /* SIA querry packets output count */ | |
810 | if (eigrp) { | |
811 | counter = 0; | |
812 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
813 | ei)) { | |
814 | counter += ei->siaQuery_out; | |
815 | } | |
816 | return SNMP_INTEGER(counter); | |
817 | } else | |
818 | return SNMP_INTEGER(0); | |
d62a17ae | 819 | case EIGRPSIAQUERIESRCVD: /* 16 */ |
820 | /* SIA querry packets input count */ | |
821 | if (eigrp) { | |
822 | counter = 0; | |
823 | for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, | |
824 | ei)) { | |
825 | counter += ei->siaQuery_in; | |
826 | } | |
827 | return SNMP_INTEGER(counter); | |
828 | } else | |
829 | return SNMP_INTEGER(0); | |
d62a17ae | 830 | case EIGRPASROUTERIDTYPE: /* 17 */ |
831 | /* Whether the router ID is set manually or automatically */ | |
832 | if (eigrp) | |
833 | if (eigrp->router_id_static != 0) | |
834 | return SNMP_INTEGER(1); | |
835 | else | |
836 | return SNMP_INTEGER(1); | |
837 | else | |
838 | return SNMP_INTEGER(0); | |
d62a17ae | 839 | case EIGRPASROUTERID: /* 18 */ |
840 | /* Router ID for this EIGRP AS */ | |
841 | if (eigrp) | |
842 | if (eigrp->router_id_static != 0) | |
843 | return SNMP_INTEGER(eigrp->router_id_static); | |
844 | else | |
845 | return SNMP_INTEGER(eigrp->router_id); | |
846 | else | |
847 | return SNMP_INTEGER(0); | |
d62a17ae | 848 | case EIGRPTOPOROUTES: /* 19 */ |
849 | /* The total number of EIGRP derived routes currently existing | |
850 | in the topology table for the AS */ | |
851 | if (eigrp) { | |
852 | return SNMP_INTEGER(1); | |
853 | } else | |
854 | return SNMP_INTEGER(0); | |
d62a17ae | 855 | case EIGRPHEADSERIAL: /* 20 */ |
856 | /* The serial number of the first route in the internal | |
857 | sequence for an AS*/ | |
858 | if (eigrp) { | |
859 | return SNMP_INTEGER(1); | |
860 | } else | |
861 | return SNMP_INTEGER(0); | |
d62a17ae | 862 | case EIGRPNEXTSERIAL: /* 21 */ |
863 | /* The serial number that would be assigned to the next new | |
864 | or changed route in the topology table for the AS*/ | |
865 | if (eigrp) { | |
866 | return SNMP_INTEGER(1); | |
867 | } else | |
868 | return SNMP_INTEGER(0); | |
d62a17ae | 869 | case EIGRPXMITPENDREPLIES: /* 22 */ |
870 | /* Total number of outstanding replies expected to queries | |
871 | that have been sent to peers in the current AS*/ | |
872 | if (eigrp) { | |
873 | return SNMP_INTEGER(1); | |
874 | } else | |
875 | return SNMP_INTEGER(0); | |
d62a17ae | 876 | case EIGRPXMITDUMMIES: /* 23 */ |
877 | /* Total number of currently existing dummies associated with | |
878 | * the AS*/ | |
879 | if (eigrp) { | |
880 | return SNMP_INTEGER(1); | |
881 | } else | |
882 | return SNMP_INTEGER(0); | |
d62a17ae | 883 | default: |
884 | return NULL; | |
885 | } | |
886 | return NULL; | |
f9e5c9ca DS |
887 | } |
888 | ||
d7c0a89a QY |
889 | static uint8_t *eigrpTopologyEntry(struct variable *v, oid *name, |
890 | size_t *length, int exact, size_t *var_len, | |
891 | WriteMethod **write_method) | |
f9e5c9ca | 892 | { |
d62a17ae | 893 | struct eigrp *eigrp; |
d62a17ae | 894 | |
895 | eigrp = eigrp_lookup(); | |
896 | ||
897 | /* Check whether the instance identifier is valid */ | |
898 | if (smux_header_generic(v, name, length, exact, var_len, write_method) | |
899 | == MATCH_FAILED) | |
900 | return NULL; | |
901 | ||
902 | /* Return the current value of the variable */ | |
903 | switch (v->magic) { | |
904 | case EIGRPDESTNETTYPE: /* 1 */ | |
905 | /* The format of the destination IP network number for a single | |
906 | route in the topology table*/ | |
907 | if (eigrp) { | |
908 | return SNMP_INTEGER(1); | |
909 | } else | |
910 | return SNMP_INTEGER(0); | |
d62a17ae | 911 | case EIGRPDESTNET: /* 2 */ |
912 | /* The destination IP network number for a single route in the | |
913 | * topology table*/ | |
914 | if (eigrp) { | |
915 | return SNMP_INTEGER(1); | |
916 | } else | |
917 | return SNMP_INTEGER(0); | |
d62a17ae | 918 | case EIGRPDESTNETPREFIXLEN: /* 4 */ |
919 | /* The prefix length associated with the destination IP network | |
920 | address | |
921 | for a single route in the topology table in the AS*/ | |
922 | if (eigrp) { | |
923 | return SNMP_INTEGER(1); | |
924 | } else | |
925 | return SNMP_INTEGER(0); | |
d62a17ae | 926 | case EIGRPACTIVE: /* 5 */ |
927 | /* A value of true(1) indicates the route to the destination | |
928 | network has failed | |
929 | A value of false(2) indicates the route is stable | |
930 | (passive).*/ | |
931 | if (eigrp) { | |
932 | return SNMP_INTEGER(1); | |
933 | } else | |
934 | return SNMP_INTEGER(0); | |
d62a17ae | 935 | case EIGRPSTUCKINACTIVE: /* 6 */ |
936 | /* A value of true(1) indicates that that this route which is in | |
937 | active state | |
938 | has not received any replies to queries for alternate paths | |
939 | */ | |
940 | if (eigrp) { | |
941 | return SNMP_INTEGER(1); | |
942 | } else | |
943 | return SNMP_INTEGER(0); | |
d62a17ae | 944 | case EIGRPDESTSUCCESSORS: /* 7 */ |
945 | /* Next routing hop for a path to the destination IP network */ | |
946 | if (eigrp) { | |
947 | return SNMP_INTEGER(1); | |
948 | } else | |
949 | return SNMP_INTEGER(0); | |
d62a17ae | 950 | case EIGRPFDISTANCE: /* 8 */ |
951 | /* Minimum distance from this router to the destination IP | |
952 | * network */ | |
953 | if (eigrp) { | |
954 | return SNMP_INTEGER(1); | |
955 | } else | |
956 | return SNMP_INTEGER(0); | |
d62a17ae | 957 | case EIGRPROUTEORIGINTYPE: /* 9 */ |
958 | /* Text string describing the internal origin of the EIGRP route | |
959 | */ | |
960 | if (eigrp) { | |
961 | return SNMP_INTEGER(1); | |
962 | } else | |
963 | return SNMP_INTEGER(0); | |
d62a17ae | 964 | case EIGRPROUTEORIGINADDRTYPE: /* 10 */ |
965 | /* The format of the IP address defined as the origin of this | |
966 | topology route entry */ | |
967 | if (eigrp) { | |
968 | return SNMP_INTEGER(1); | |
969 | } else | |
970 | return SNMP_INTEGER(0); | |
d62a17ae | 971 | case EIGRPROUTEORIGINADDR: /* 11 */ |
972 | /* If the origin of the topology route entry is external to this | |
973 | router, | |
974 | then this object is the IP address of the router from which | |
975 | it originated */ | |
976 | if (eigrp) { | |
977 | return SNMP_INTEGER(1); | |
978 | } else | |
979 | return SNMP_INTEGER(0); | |
d62a17ae | 980 | case EIGRPNEXTHOPADDRESSTYPE: /* 12 */ |
981 | /* The format of the next hop IP address */ | |
982 | if (eigrp) { | |
983 | return SNMP_INTEGER(1); | |
984 | } else | |
985 | return SNMP_INTEGER(0); | |
d62a17ae | 986 | case EIGRPNEXTHOPADDRESS: /* 13 */ |
987 | /* Next hop IP address for the route */ | |
988 | if (eigrp) { | |
989 | return SNMP_INTEGER(1); | |
990 | } else | |
991 | return SNMP_INTEGER(0); | |
d62a17ae | 992 | case EIGRPNEXTHOPINTERFACE: /* 14 */ |
993 | /* The interface through which the next hop IP address is | |
994 | * reached */ | |
995 | if (eigrp) { | |
996 | return SNMP_INTEGER(1); | |
997 | } else | |
998 | return SNMP_INTEGER(0); | |
d62a17ae | 999 | case EIGRPDISTANCE: /* 15 */ |
1000 | /* The computed distance to the destination network entry from | |
1001 | * this router */ | |
1002 | if (eigrp) { | |
1003 | return SNMP_INTEGER(1); | |
1004 | } else | |
1005 | return SNMP_INTEGER(0); | |
d62a17ae | 1006 | case EIGRPREPORTDISTANCE: /* 16 */ |
1007 | /* The computed distance to the destination network in the | |
1008 | topology entry | |
1009 | reported to this router by the originator of this route */ | |
1010 | if (eigrp) { | |
1011 | return SNMP_INTEGER(1); | |
1012 | } else | |
1013 | return SNMP_INTEGER(0); | |
d62a17ae | 1014 | default: |
1015 | return NULL; | |
1016 | } | |
1017 | return NULL; | |
f9e5c9ca DS |
1018 | } |
1019 | ||
d7c0a89a QY |
1020 | static uint8_t *eigrpPeerEntry(struct variable *v, oid *name, size_t *length, |
1021 | int exact, size_t *var_len, | |
1022 | WriteMethod **write_method) | |
f9e5c9ca | 1023 | { |
d62a17ae | 1024 | struct eigrp *eigrp; |
1025 | struct eigrp_interface *ei; | |
d62a17ae | 1026 | struct eigrp_neighbor *nbr; |
1027 | struct in_addr nbr_addr; | |
1028 | unsigned int ifindex; | |
1029 | ||
1030 | eigrp = eigrp_lookup(); | |
1031 | ||
1032 | /* Check whether the instance identifier is valid */ | |
1033 | if (smux_header_generic(v, name, length, exact, var_len, write_method) | |
1034 | == MATCH_FAILED) | |
1035 | return NULL; | |
1036 | ||
6006b807 | 1037 | memset(&nbr_addr, 0, sizeof(nbr_addr)); |
d62a17ae | 1038 | ifindex = 0; |
1039 | ||
1040 | nbr = eigrpNbrLookup(v, name, length, &nbr_addr, &ifindex, exact); | |
1041 | if (!nbr) | |
1042 | return NULL; | |
1043 | ei = nbr->ei; | |
1044 | if (!ei) | |
1045 | return NULL; | |
1046 | ||
1047 | /* Return the current value of the variable */ | |
1048 | switch (v->magic) { | |
1049 | case EIGRPHANDLE: /* 1 */ | |
1050 | /* The unique internal identifier for the peer in the AS */ | |
1051 | if (eigrp) { | |
1052 | return SNMP_INTEGER(1); | |
1053 | } else | |
1054 | return SNMP_INTEGER(0); | |
d62a17ae | 1055 | case EIGRPPEERADDRTYPE: /* 2 */ |
1056 | /* The format of the remote source IP address used by the peer | |
1057 | */ | |
1058 | if (eigrp) { | |
1059 | return SNMP_INTEGER(1); | |
1060 | } else | |
1061 | return SNMP_INTEGER(0); | |
d62a17ae | 1062 | case EIGRPPEERADDR: /* 3 */ |
1063 | /* The source IP address used by the peer */ | |
1064 | if (eigrp) { | |
1065 | return SNMP_INTEGER(1); | |
1066 | } else | |
1067 | return SNMP_INTEGER(0); | |
d62a17ae | 1068 | case EIGRPPEERIFINDEX: /* 4 */ |
1069 | /* The ifIndex of the interface on this router */ | |
1070 | if (eigrp) { | |
1071 | return SNMP_INTEGER(1); | |
1072 | } else | |
1073 | return SNMP_INTEGER(0); | |
d62a17ae | 1074 | case EIGRPHOLDTIME: /* 5 */ |
1075 | /* How much time must pass without receiving a hello packet from | |
1076 | this | |
1077 | EIGRP peer before this router declares the peer down */ | |
1078 | if (eigrp) { | |
1079 | return SNMP_INTEGER(1); | |
1080 | } else | |
1081 | return SNMP_INTEGER(0); | |
d62a17ae | 1082 | case EIGRPUPTIME: /* 6 */ |
1083 | /* The elapsed time since the EIGRP adjacency was first | |
1084 | * established */ | |
1085 | if (eigrp) { | |
1086 | return SNMP_INTEGER(1); | |
1087 | } else | |
1088 | return SNMP_INTEGER(0); | |
d62a17ae | 1089 | case EIGRPSRTT: /* 7 */ |
1090 | /* The computed smooth round trip time for packets to and from | |
1091 | * the peer */ | |
1092 | if (eigrp) { | |
1093 | return SNMP_INTEGER(1); | |
1094 | } else | |
1095 | return SNMP_INTEGER(0); | |
d62a17ae | 1096 | case EIGRPRTO: /* 8 */ |
1097 | /* The computed retransmission timeout for the peer */ | |
1098 | if (eigrp) { | |
1099 | return SNMP_INTEGER(1); | |
1100 | } else | |
1101 | return SNMP_INTEGER(0); | |
d62a17ae | 1102 | case EIGRPPKTSENQUEUED: /* 9 */ |
1103 | /* The number of any EIGRP packets currently enqueued */ | |
1104 | if (eigrp) { | |
1105 | return SNMP_INTEGER(1); | |
1106 | } else | |
1107 | return SNMP_INTEGER(0); | |
d62a17ae | 1108 | case EIGRPLASTSEQ: /* 10 */ |
1109 | /* sequence number of the last EIGRP packet sent to this peer */ | |
1110 | if (eigrp) { | |
1111 | return SNMP_INTEGER(1); | |
1112 | } else | |
1113 | return SNMP_INTEGER(0); | |
d62a17ae | 1114 | case EIGRPVERSION: /* 11 */ |
1115 | /* The EIGRP version information reported by the remote peer */ | |
1116 | if (eigrp) { | |
1117 | return SNMP_INTEGER(1); | |
1118 | } else | |
1119 | return SNMP_INTEGER(0); | |
d62a17ae | 1120 | case EIGRPRETRANS: /* 12 */ |
1121 | /* The cumulative number of retransmissions to this peer */ | |
1122 | if (eigrp) { | |
1123 | return SNMP_INTEGER(1); | |
1124 | } else | |
1125 | return SNMP_INTEGER(0); | |
d62a17ae | 1126 | case EIGRPRETRIES: /* 13 */ |
1127 | /* The number of times the current unacknowledged packet has | |
1128 | * been retried */ | |
1129 | if (eigrp) { | |
1130 | return SNMP_INTEGER(1); | |
1131 | } else | |
1132 | return SNMP_INTEGER(0); | |
d62a17ae | 1133 | default: |
1134 | return NULL; | |
1135 | } | |
1136 | return NULL; | |
f9e5c9ca | 1137 | } |
7f57883e | 1138 | |
d7c0a89a QY |
1139 | static uint8_t *eigrpInterfaceEntry(struct variable *v, oid *name, |
1140 | size_t *length, int exact, size_t *var_len, | |
1141 | WriteMethod **write_method) | |
f9e5c9ca | 1142 | { |
d62a17ae | 1143 | struct eigrp *eigrp; |
d62a17ae | 1144 | struct listnode *node, *nnode; |
1145 | struct keychain *keychain; | |
1146 | struct list *keylist; | |
d62a17ae | 1147 | |
1148 | eigrp = eigrp_lookup(); | |
1149 | ||
1150 | /* Check whether the instance identifier is valid */ | |
1151 | if (smux_header_generic(v, name, length, exact, var_len, write_method) | |
1152 | == MATCH_FAILED) | |
1153 | return NULL; | |
1154 | ||
1155 | /* Return the current value of the variable */ | |
1156 | switch (v->magic) { | |
1157 | case EIGRPPEERCOUNT: /* 3 */ | |
1158 | /* The number of EIGRP adjacencies currently formed with | |
1159 | peers reached through this interface */ | |
1160 | if (eigrp) { | |
1161 | return SNMP_INTEGER(eigrp_neighbor_count(eigrp)); | |
1162 | } else | |
1163 | return SNMP_INTEGER(0); | |
d62a17ae | 1164 | case EIGRPXMITRELIABLEQ: /* 4 */ |
1165 | /* The number of EIGRP packets currently waiting in the reliable | |
1166 | transport transmission queue */ | |
1167 | if (eigrp) { | |
1168 | return SNMP_INTEGER(1); | |
1169 | } else | |
1170 | return SNMP_INTEGER(0); | |
d62a17ae | 1171 | case EIGRPXMITUNRELIABLEQ: /* 5 */ |
1172 | /* The number of EIGRP packets currently waiting in the | |
1173 | unreliable | |
1174 | transport transmission queue */ | |
1175 | if (eigrp) { | |
1176 | return SNMP_INTEGER(1); | |
1177 | } else | |
1178 | return SNMP_INTEGER(0); | |
d62a17ae | 1179 | case EIGRPMEANSRTT: /* 6 */ |
1180 | /* The average of all the computed smooth round trip time values | |
1181 | for a packet to and from all peers established on this | |
1182 | interface */ | |
1183 | if (eigrp) { | |
1184 | return SNMP_INTEGER(1); | |
1185 | } else | |
1186 | return SNMP_INTEGER(0); | |
d62a17ae | 1187 | case EIGRPPACINGRELIABLE: /* 7 */ |
1188 | /* The configured time interval between EIGRP packet | |
1189 | * transmissions */ | |
1190 | if (eigrp) { | |
1191 | return SNMP_INTEGER(1); | |
1192 | } else | |
1193 | return SNMP_INTEGER(0); | |
d62a17ae | 1194 | case EIGRPPACINGUNRELIABLE: /* 8 */ |
1195 | /* The configured time interval between EIGRP packet | |
1196 | transmissions | |
1197 | on the interface when the unreliable transport method is used | |
1198 | */ | |
1199 | if (eigrp) { | |
1200 | return SNMP_INTEGER(1); | |
1201 | } else | |
1202 | return SNMP_INTEGER(0); | |
d62a17ae | 1203 | case EIGRPMFLOWTIMER: /* 9 */ |
1204 | /* The configured multicast flow control timer value */ | |
1205 | if (eigrp) { | |
1206 | return SNMP_INTEGER(1); | |
1207 | } else | |
1208 | return SNMP_INTEGER(0); | |
d62a17ae | 1209 | case EIGRPPENDINGROUTES: /* 10 */ |
1210 | /* The number of queued EIGRP routing updates awaiting | |
1211 | * transmission */ | |
1212 | if (eigrp) { | |
1213 | return SNMP_INTEGER(1); | |
1214 | } else | |
1215 | return SNMP_INTEGER(0); | |
d62a17ae | 1216 | case EIGRPHELLOINTERVAL: /* 11 */ |
1217 | /* The configured time interval between Hello packet | |
1218 | * transmissions */ | |
1219 | if (eigrp) { | |
1220 | return SNMP_INTEGER(1); | |
1221 | } else | |
1222 | return SNMP_INTEGER(0); | |
d62a17ae | 1223 | case EIGRPXMITNEXTSERIAL: /* 12 */ |
1224 | /* The serial number of the next EIGRP packet that is to be | |
1225 | queued | |
1226 | for transmission */ | |
1227 | if (eigrp) { | |
1228 | return SNMP_INTEGER(1); | |
1229 | } else | |
1230 | return SNMP_INTEGER(0); | |
d62a17ae | 1231 | case EIGRPUMCASTS: /* 13 */ |
1232 | /* The total number of unreliable EIGRP multicast packets sent | |
1233 | on this interface */ | |
1234 | if (eigrp) { | |
1235 | return SNMP_INTEGER(1); | |
1236 | } else | |
1237 | return SNMP_INTEGER(0); | |
d62a17ae | 1238 | case EIGRPRMCASTS: /* 14 */ |
1239 | /* The total number of reliable EIGRP multicast packets sent | |
1240 | on this interface */ | |
1241 | if (eigrp) { | |
1242 | return SNMP_INTEGER(1); | |
1243 | } else | |
1244 | return SNMP_INTEGER(0); | |
d62a17ae | 1245 | case EIGRPUUCASTS: /* 15 */ |
1246 | /* The total number of unreliable EIGRP unicast packets sent | |
1247 | on this interface */ | |
1248 | if (eigrp) { | |
1249 | return SNMP_INTEGER(1); | |
1250 | } else | |
1251 | return SNMP_INTEGER(0); | |
d62a17ae | 1252 | case EIGRPRUCASTS: /* 16 */ |
1253 | /* The total number of reliable EIGRP unicast packets sent | |
1254 | on this interface */ | |
1255 | if (eigrp) { | |
1256 | return SNMP_INTEGER(1); | |
1257 | } else | |
1258 | return SNMP_INTEGER(0); | |
d62a17ae | 1259 | case EIGRPMCASTEXCEPTS: /* 17 */ |
1260 | /* The total number of EIGRP multicast exception transmissions | |
1261 | */ | |
1262 | if (eigrp) { | |
1263 | return SNMP_INTEGER(1); | |
1264 | } else | |
1265 | return SNMP_INTEGER(0); | |
d62a17ae | 1266 | case EIGRPCRPKTS: /* 18 */ |
1267 | /* The total number EIGRP Conditional-Receive packets sent on | |
1268 | * this interface */ | |
1269 | if (eigrp) { | |
1270 | return SNMP_INTEGER(1); | |
1271 | } else | |
1272 | return SNMP_INTEGER(0); | |
d62a17ae | 1273 | case EIGRPACKSSUPPRESSED: /* 19 */ |
1274 | /* The total number of individual EIGRP acknowledgement packets | |
1275 | that have been | |
1276 | suppressed and combined in an already enqueued outbound | |
1277 | reliable packet on this interface */ | |
1278 | if (eigrp) { | |
1279 | return SNMP_INTEGER(1); | |
1280 | } else | |
1281 | return SNMP_INTEGER(0); | |
d62a17ae | 1282 | case EIGRPRETRANSSENT: /* 20 */ |
1283 | /* The total number EIGRP packet retransmissions sent on the | |
1284 | * interface */ | |
1285 | if (eigrp) { | |
1286 | return SNMP_INTEGER(1); | |
1287 | } else | |
1288 | return SNMP_INTEGER(0); | |
d62a17ae | 1289 | case EIGRPOOSRCVD: /* 21 */ |
1290 | /* The total number of out-of-sequence EIGRP packets received */ | |
1291 | if (eigrp) { | |
1292 | return SNMP_INTEGER(1); | |
1293 | } else | |
1294 | return SNMP_INTEGER(0); | |
d62a17ae | 1295 | case EIGRPAUTHMODE: /* 22 */ |
1296 | /* The EIGRP authentication mode of the interface */ | |
1297 | if (eigrp) { | |
1298 | return SNMP_INTEGER(1); | |
1299 | } else | |
1300 | return SNMP_INTEGER(0); | |
d62a17ae | 1301 | case EIGRPAUTHKEYCHAIN: /* 23 */ |
1302 | /* The name of the authentication key-chain configured | |
1303 | on this interface. */ | |
1304 | keylist = keychain_list_get(); | |
1305 | for (ALL_LIST_ELEMENTS(keylist, node, nnode, keychain)) { | |
d7c0a89a | 1306 | return (uint8_t *)keychain->name; |
d62a17ae | 1307 | } |
1308 | if (eigrp && keychain) { | |
1309 | *var_len = str_len(keychain->name); | |
d7c0a89a | 1310 | return (uint8_t *)keychain->name; |
d62a17ae | 1311 | } else |
d7c0a89a | 1312 | return (uint8_t *)"TEST"; |
d62a17ae | 1313 | break; |
1314 | default: | |
1315 | return NULL; | |
1316 | } | |
1317 | return NULL; | |
f9e5c9ca | 1318 | } |
7f57883e | 1319 | |
f9e5c9ca | 1320 | /* Register EIGRP-MIB. */ |
d62a17ae | 1321 | void eigrp_snmp_init() |
f9e5c9ca | 1322 | { |
d62a17ae | 1323 | eigrp_snmp_iflist = list_new(); |
1324 | smux_init(eigrp_om->master); | |
1325 | REGISTER_MIB("ciscoEigrpMIB", eigrp_variables, variable, eigrp_oid); | |
f9e5c9ca | 1326 | } |
7f57883e | 1327 | #endif |