]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_snmp.c
Merge pull request #2457 from pacovn/Coverity_1465491_Untrusted_value_as_argument
[mirror_frr.git] / eigrpd / eigrp_snmp.c
CommitLineData
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
62struct list *eigrp_snmp_iflist;
63
64/* Declare static local variables for convenience. */
65SNMP_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 71oid 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 170static uint8_t *eigrpVpnEntry(struct variable *, oid *, size_t *, int, size_t *,
d62a17ae 171 WriteMethod **);
d7c0a89a
QY
172static uint8_t *eigrpTraffStatsEntry(struct variable *, oid *, size_t *, int,
173 size_t *, WriteMethod **);
174static uint8_t *eigrpTopologyEntry(struct variable *, oid *, size_t *, int,
d62a17ae 175 size_t *, WriteMethod **);
d7c0a89a
QY
176static uint8_t *eigrpPeerEntry(struct variable *, oid *, size_t *, int,
177 size_t *, WriteMethod **);
178static uint8_t *eigrpInterfaceEntry(struct variable *, oid *, size_t *, int,
179 size_t *, WriteMethod **);
d62a17ae 180
181
182struct 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
492static 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
510static struct eigrp_neighbor *
d62a17ae 511eigrp_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;
517 struct route_node *rn;
518 struct eigrp_neighbor *min = NULL;
1aa37b48 519 struct eigrp *eigrp;
d62a17ae 520
521 eigrp = eigrp_lookup();
522
523 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, ei)) {
524 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
525 if (first) {
526 if (!min)
527 min = nbr;
528 else if (ntohl(nbr->src.s_addr)
529 < ntohl(min->src.s_addr))
530 min = nbr;
531 } else if (ntohl(nbr->src.s_addr)
532 > ntohl(nbr_addr->s_addr)) {
533 if (!min)
534 min = nbr;
535 else if (ntohl(nbr->src.s_addr)
536 < ntohl(min->src.s_addr))
537 min = nbr;
538 }
539 }
540 }
541 if (min) {
542 *nbr_addr = min->src;
543 *ifindex = 0;
544 return min;
545 }
546 return NULL;
7f57883e
DS
547}
548
d62a17ae 549static struct eigrp_neighbor *eigrpNbrLookup(struct variable *v, oid *name,
550 size_t *length,
551 struct in_addr *nbr_addr,
552 unsigned int *ifindex, int exact)
7f57883e 553{
d62a17ae 554 unsigned int len;
555 int first;
556 struct eigrp_neighbor *nbr;
557 struct eigrp *eigrp;
558
559 eigrp = eigrp_lookup();
560
561 if (!eigrp)
562 return NULL;
563
564 if (exact) {
565 if (*length != v->namelen + IN_ADDR_SIZE + 1)
566 return NULL;
567
568 oid2in_addr(name + v->namelen, IN_ADDR_SIZE, nbr_addr);
569 *ifindex = name[v->namelen + IN_ADDR_SIZE];
570
571 return eigrp_snmp_nbr_lookup(eigrp, nbr_addr, ifindex);
572 } else {
573 first = 0;
574 len = *length - v->namelen;
575
576 if (len <= 0)
577 first = 1;
578
579 if (len > IN_ADDR_SIZE)
580 len = IN_ADDR_SIZE;
581
582 oid2in_addr(name + v->namelen, len, nbr_addr);
583
584 len = *length - v->namelen - IN_ADDR_SIZE;
585 if (len >= 1)
586 *ifindex = name[v->namelen + IN_ADDR_SIZE];
587
588 nbr = eigrp_snmp_nbr_lookup_next(nbr_addr, ifindex, first);
589
590 if (nbr) {
591 *length = v->namelen + IN_ADDR_SIZE + 1;
592 oid_copy_addr(name + v->namelen, nbr_addr,
593 IN_ADDR_SIZE);
594 name[v->namelen + IN_ADDR_SIZE] = *ifindex;
595 return nbr;
596 }
597 }
598 return NULL;
7f57883e
DS
599}
600
601
d7c0a89a
QY
602static uint8_t *eigrpVpnEntry(struct variable *v, oid *name, size_t *length,
603 int exact, size_t *var_len,
604 WriteMethod **write_method)
f9e5c9ca 605{
d62a17ae 606 struct eigrp *eigrp;
607
608 eigrp = eigrp_lookup();
609
610 /* Check whether the instance identifier is valid */
611 if (smux_header_generic(v, name, length, exact, var_len, write_method)
612 == MATCH_FAILED)
613 return NULL;
614
615 /* Return the current value of the variable */
616 switch (v->magic) {
617 case EIGRPVPNID: /* 1 */
618 /* The unique VPN identifier */
619 if (eigrp) {
620 return SNMP_INTEGER(1);
621 } else
622 return SNMP_INTEGER(0);
623 break;
624 case EIGRPVPNNAME: /* 2 */
625 /* The name given to the VPN */
626 if (eigrp) {
627 return SNMP_INTEGER(1);
628 } else
629 return SNMP_INTEGER(0);
630 break;
631 default:
632 return NULL;
633 }
634 return NULL;
f9e5c9ca
DS
635}
636
d62a17ae 637static uint32_t eigrp_neighbor_count(struct eigrp *eigrp)
f9e5c9ca 638{
d62a17ae 639 uint32_t count;
640 struct eigrp_interface *ei;
641 struct listnode *node, *node2, *nnode2;
642 struct eigrp_neighbor *nbr;
643
644 if (eigrp == NULL) {
645 return 0;
646 }
647
648 count = 0;
649 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
650 for (ALL_LIST_ELEMENTS(ei->nbrs, node2, nnode2, nbr)) {
651 if (nbr->state == EIGRP_NEIGHBOR_UP)
652 count++;
653 }
654 }
655
656 return count;
f9e5c9ca 657}
7f57883e
DS
658
659
d7c0a89a
QY
660static uint8_t *eigrpTraffStatsEntry(struct variable *v, oid *name,
661 size_t *length, int exact, size_t *var_len,
662 WriteMethod **write_method)
f9e5c9ca 663{
d62a17ae 664 struct eigrp *eigrp;
665 struct eigrp_interface *ei;
666 struct listnode *node, *nnode;
667 int counter;
668
669 eigrp = eigrp_lookup();
670
671 /* Check whether the instance identifier is valid */
672 if (smux_header_generic(v, name, length, exact, var_len, write_method)
673 == MATCH_FAILED)
674 return NULL;
675
676 /* Return the current value of the variable */
677 switch (v->magic) {
678 case EIGRPASNUMBER: /* 1 */
679 /* AS-number of this EIGRP instance. */
680 if (eigrp)
681 return SNMP_INTEGER(eigrp->AS);
682 else
683 return SNMP_INTEGER(0);
684 break;
685 case EIGRPNBRCOUNT: /* 2 */
686 /* Neighbor count of this EIGRP instance */
687 if (eigrp)
688 return SNMP_INTEGER(eigrp_neighbor_count(eigrp));
689 else
690 return SNMP_INTEGER(0);
691 break;
692 case EIGRPHELLOSSENT: /* 3 */
693 /* Hello packets output count */
694 if (eigrp) {
695 counter = 0;
696 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
697 ei)) {
698 counter += ei->hello_out;
699 }
700 return SNMP_INTEGER(counter);
701 } else
702 return SNMP_INTEGER(0);
703 break;
704 case EIGRPHELLOSRCVD: /* 4 */
705 /* Hello packets input count */
706 if (eigrp) {
707 counter = 0;
708 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
709 ei)) {
710 counter += ei->hello_in;
711 }
712 return SNMP_INTEGER(counter);
713 } else
714 return SNMP_INTEGER(0);
715 break;
716 case EIGRPUPDATESSENT: /* 5 */
717 /* Update packets output count */
718 if (eigrp) {
719 counter = 0;
720 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
721 ei)) {
722 counter += ei->update_out;
723 }
724 return SNMP_INTEGER(counter);
725 } else
726 return SNMP_INTEGER(0);
727 break;
728 case EIGRPUPDATESRCVD: /* 6 */
729 /* Update packets input count */
730 if (eigrp) {
731 counter = 0;
732 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
733 ei)) {
734 counter += ei->update_in;
735 }
736 return SNMP_INTEGER(counter);
737 } else
738 return SNMP_INTEGER(0);
739 break;
740 case EIGRPQUERIESSENT: /* 7 */
741 /* Querry packets output count */
742 if (eigrp) {
743 counter = 0;
744 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
745 ei)) {
746 counter += ei->query_out;
747 }
748 return SNMP_INTEGER(counter);
749 } else
750 return SNMP_INTEGER(0);
751 break;
752 case EIGRPQUERIESRCVD: /* 8 */
753 /* Querry packets input count */
754 if (eigrp) {
755 counter = 0;
756 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
757 ei)) {
758 counter += ei->query_in;
759 }
760 return SNMP_INTEGER(counter);
761 } else
762 return SNMP_INTEGER(0);
763 break;
764 case EIGRPREPLIESSENT: /* 9 */
765 /* Reply packets output count */
766 if (eigrp) {
767 counter = 0;
768 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
769 ei)) {
770 counter += ei->reply_out;
771 }
772 return SNMP_INTEGER(counter);
773 } else
774 return SNMP_INTEGER(0);
775 break;
776 case EIGRPREPLIESRCVD: /* 10 */
777 /* Reply packets input count */
778 if (eigrp) {
779 counter = 0;
780 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
781 ei)) {
782 counter += ei->reply_in;
783 }
784 return SNMP_INTEGER(counter);
785 } else
786 return SNMP_INTEGER(0);
787 break;
788 case EIGRPACKSSENT: /* 11 */
789 /* Acknowledgement packets output count */
790 if (eigrp) {
791 counter = 0;
792 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
793 ei)) {
794 counter += ei->ack_out;
795 }
796 return SNMP_INTEGER(counter);
797 } else
798 return SNMP_INTEGER(0);
799 break;
800 case EIGRPACKSRCVD: /* 12 */
801 /* Acknowledgement packets input count */
802 if (eigrp) {
803 counter = 0;
804 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
805 ei)) {
806 counter += ei->ack_in;
807 }
808 return SNMP_INTEGER(counter);
809 } else
810 return SNMP_INTEGER(0);
811 break;
812 case EIGRPINPUTQHIGHMARK: /* 13 */
813 /* The highest number of EIGRP packets in the input queue */
814 if (eigrp) {
815 return SNMP_INTEGER(1);
816 } else
817 return SNMP_INTEGER(0);
818 break;
819 case EIGRPINPUTQDROPS: /* 14 */
820 /* The number of EIGRP packets dropped from the input queue */
821 if (eigrp) {
822 return SNMP_INTEGER(1);
823 } else
824 return SNMP_INTEGER(0);
825 break;
826 case EIGRPSIAQUERIESSENT: /* 15 */
827 /* SIA querry packets output count */
828 if (eigrp) {
829 counter = 0;
830 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
831 ei)) {
832 counter += ei->siaQuery_out;
833 }
834 return SNMP_INTEGER(counter);
835 } else
836 return SNMP_INTEGER(0);
837 break;
838 case EIGRPSIAQUERIESRCVD: /* 16 */
839 /* SIA querry packets input count */
840 if (eigrp) {
841 counter = 0;
842 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode,
843 ei)) {
844 counter += ei->siaQuery_in;
845 }
846 return SNMP_INTEGER(counter);
847 } else
848 return SNMP_INTEGER(0);
849 break;
850 case EIGRPASROUTERIDTYPE: /* 17 */
851 /* Whether the router ID is set manually or automatically */
852 if (eigrp)
853 if (eigrp->router_id_static != 0)
854 return SNMP_INTEGER(1);
855 else
856 return SNMP_INTEGER(1);
857 else
858 return SNMP_INTEGER(0);
859 break;
860 case EIGRPASROUTERID: /* 18 */
861 /* Router ID for this EIGRP AS */
862 if (eigrp)
863 if (eigrp->router_id_static != 0)
864 return SNMP_INTEGER(eigrp->router_id_static);
865 else
866 return SNMP_INTEGER(eigrp->router_id);
867 else
868 return SNMP_INTEGER(0);
869 break;
870 case EIGRPTOPOROUTES: /* 19 */
871 /* The total number of EIGRP derived routes currently existing
872 in the topology table for the AS */
873 if (eigrp) {
874 return SNMP_INTEGER(1);
875 } else
876 return SNMP_INTEGER(0);
877 break;
878 case EIGRPHEADSERIAL: /* 20 */
879 /* The serial number of the first route in the internal
880 sequence for an AS*/
881 if (eigrp) {
882 return SNMP_INTEGER(1);
883 } else
884 return SNMP_INTEGER(0);
885 break;
886 case EIGRPNEXTSERIAL: /* 21 */
887 /* The serial number that would be assigned to the next new
888 or changed route in the topology table for the AS*/
889 if (eigrp) {
890 return SNMP_INTEGER(1);
891 } else
892 return SNMP_INTEGER(0);
893 break;
894 case EIGRPXMITPENDREPLIES: /* 22 */
895 /* Total number of outstanding replies expected to queries
896 that have been sent to peers in the current AS*/
897 if (eigrp) {
898 return SNMP_INTEGER(1);
899 } else
900 return SNMP_INTEGER(0);
901 break;
902 case EIGRPXMITDUMMIES: /* 23 */
903 /* Total number of currently existing dummies associated with
904 * the AS*/
905 if (eigrp) {
906 return SNMP_INTEGER(1);
907 } else
908 return SNMP_INTEGER(0);
909 break;
910 default:
911 return NULL;
912 }
913 return NULL;
f9e5c9ca
DS
914}
915
d7c0a89a
QY
916static uint8_t *eigrpTopologyEntry(struct variable *v, oid *name,
917 size_t *length, int exact, size_t *var_len,
918 WriteMethod **write_method)
f9e5c9ca 919{
d62a17ae 920 struct eigrp *eigrp;
921 struct eigrp_interface *ei;
922 struct listnode *node, *nnode;
923
924 eigrp = eigrp_lookup();
925
926 /* Check whether the instance identifier is valid */
927 if (smux_header_generic(v, name, length, exact, var_len, write_method)
928 == MATCH_FAILED)
929 return NULL;
930
931 /* Return the current value of the variable */
932 switch (v->magic) {
933 case EIGRPDESTNETTYPE: /* 1 */
934 /* The format of the destination IP network number for a single
935 route in the topology table*/
936 if (eigrp) {
937 return SNMP_INTEGER(1);
938 } else
939 return SNMP_INTEGER(0);
940 break;
941 case EIGRPDESTNET: /* 2 */
942 /* The destination IP network number for a single route in the
943 * topology table*/
944 if (eigrp) {
945 return SNMP_INTEGER(1);
946 } else
947 return SNMP_INTEGER(0);
948 break;
949 case EIGRPDESTNETPREFIXLEN: /* 4 */
950 /* The prefix length associated with the destination IP network
951 address
952 for a single route in the topology table in the AS*/
953 if (eigrp) {
954 return SNMP_INTEGER(1);
955 } else
956 return SNMP_INTEGER(0);
957 break;
958 case EIGRPACTIVE: /* 5 */
959 /* A value of true(1) indicates the route to the destination
960 network has failed
961 A value of false(2) indicates the route is stable
962 (passive).*/
963 if (eigrp) {
964 return SNMP_INTEGER(1);
965 } else
966 return SNMP_INTEGER(0);
967 break;
968 case EIGRPSTUCKINACTIVE: /* 6 */
969 /* A value of true(1) indicates that that this route which is in
970 active state
971 has not received any replies to queries for alternate paths
972 */
973 if (eigrp) {
974 return SNMP_INTEGER(1);
975 } else
976 return SNMP_INTEGER(0);
977 break;
978 case EIGRPDESTSUCCESSORS: /* 7 */
979 /* Next routing hop for a path to the destination IP network */
980 if (eigrp) {
981 return SNMP_INTEGER(1);
982 } else
983 return SNMP_INTEGER(0);
984 break;
985 case EIGRPFDISTANCE: /* 8 */
986 /* Minimum distance from this router to the destination IP
987 * network */
988 if (eigrp) {
989 return SNMP_INTEGER(1);
990 } else
991 return SNMP_INTEGER(0);
992 break;
993 case EIGRPROUTEORIGINTYPE: /* 9 */
994 /* Text string describing the internal origin of the EIGRP route
995 */
996 if (eigrp) {
997 return SNMP_INTEGER(1);
998 } else
999 return SNMP_INTEGER(0);
1000 break;
1001 case EIGRPROUTEORIGINADDRTYPE: /* 10 */
1002 /* The format of the IP address defined as the origin of this
1003 topology route entry */
1004 if (eigrp) {
1005 return SNMP_INTEGER(1);
1006 } else
1007 return SNMP_INTEGER(0);
1008 break;
1009 case EIGRPROUTEORIGINADDR: /* 11 */
1010 /* If the origin of the topology route entry is external to this
1011 router,
1012 then this object is the IP address of the router from which
1013 it originated */
1014 if (eigrp) {
1015 return SNMP_INTEGER(1);
1016 } else
1017 return SNMP_INTEGER(0);
1018 break;
1019 case EIGRPNEXTHOPADDRESSTYPE: /* 12 */
1020 /* The format of the next hop IP address */
1021 if (eigrp) {
1022 return SNMP_INTEGER(1);
1023 } else
1024 return SNMP_INTEGER(0);
1025 break;
1026 case EIGRPNEXTHOPADDRESS: /* 13 */
1027 /* Next hop IP address for the route */
1028 if (eigrp) {
1029 return SNMP_INTEGER(1);
1030 } else
1031 return SNMP_INTEGER(0);
1032 break;
1033 case EIGRPNEXTHOPINTERFACE: /* 14 */
1034 /* The interface through which the next hop IP address is
1035 * reached */
1036 if (eigrp) {
1037 return SNMP_INTEGER(1);
1038 } else
1039 return SNMP_INTEGER(0);
1040 break;
1041 case EIGRPDISTANCE: /* 15 */
1042 /* The computed distance to the destination network entry from
1043 * this router */
1044 if (eigrp) {
1045 return SNMP_INTEGER(1);
1046 } else
1047 return SNMP_INTEGER(0);
1048 break;
1049 case EIGRPREPORTDISTANCE: /* 16 */
1050 /* The computed distance to the destination network in the
1051 topology entry
1052 reported to this router by the originator of this route */
1053 if (eigrp) {
1054 return SNMP_INTEGER(1);
1055 } else
1056 return SNMP_INTEGER(0);
1057 break;
1058 default:
1059 return NULL;
1060 }
1061 return NULL;
f9e5c9ca
DS
1062}
1063
d7c0a89a
QY
1064static uint8_t *eigrpPeerEntry(struct variable *v, oid *name, size_t *length,
1065 int exact, size_t *var_len,
1066 WriteMethod **write_method)
f9e5c9ca 1067{
d62a17ae 1068 struct eigrp *eigrp;
1069 struct eigrp_interface *ei;
1070 struct listnode *node, *nnode;
1071 struct eigrp_neighbor *nbr;
1072 struct in_addr nbr_addr;
1073 unsigned int ifindex;
1074
1075 eigrp = eigrp_lookup();
1076
1077 /* Check whether the instance identifier is valid */
1078 if (smux_header_generic(v, name, length, exact, var_len, write_method)
1079 == MATCH_FAILED)
1080 return NULL;
1081
1082 memset(&nbr_addr, 0, sizeof(struct in_addr));
1083 ifindex = 0;
1084
1085 nbr = eigrpNbrLookup(v, name, length, &nbr_addr, &ifindex, exact);
1086 if (!nbr)
1087 return NULL;
1088 ei = nbr->ei;
1089 if (!ei)
1090 return NULL;
1091
1092 /* Return the current value of the variable */
1093 switch (v->magic) {
1094 case EIGRPHANDLE: /* 1 */
1095 /* The unique internal identifier for the peer in the AS */
1096 if (eigrp) {
1097 return SNMP_INTEGER(1);
1098 } else
1099 return SNMP_INTEGER(0);
1100 break;
1101 case EIGRPPEERADDRTYPE: /* 2 */
1102 /* The format of the remote source IP address used by the peer
1103 */
1104 if (eigrp) {
1105 return SNMP_INTEGER(1);
1106 } else
1107 return SNMP_INTEGER(0);
1108 break;
1109 case EIGRPPEERADDR: /* 3 */
1110 /* The source IP address used by the peer */
1111 if (eigrp) {
1112 return SNMP_INTEGER(1);
1113 } else
1114 return SNMP_INTEGER(0);
1115 break;
1116 case EIGRPPEERIFINDEX: /* 4 */
1117 /* The ifIndex of the interface on this router */
1118 if (eigrp) {
1119 return SNMP_INTEGER(1);
1120 } else
1121 return SNMP_INTEGER(0);
1122 break;
1123 case EIGRPHOLDTIME: /* 5 */
1124 /* How much time must pass without receiving a hello packet from
1125 this
1126 EIGRP peer before this router declares the peer down */
1127 if (eigrp) {
1128 return SNMP_INTEGER(1);
1129 } else
1130 return SNMP_INTEGER(0);
1131 break;
1132 case EIGRPUPTIME: /* 6 */
1133 /* The elapsed time since the EIGRP adjacency was first
1134 * established */
1135 if (eigrp) {
1136 return SNMP_INTEGER(1);
1137 } else
1138 return SNMP_INTEGER(0);
1139 break;
1140 case EIGRPSRTT: /* 7 */
1141 /* The computed smooth round trip time for packets to and from
1142 * the peer */
1143 if (eigrp) {
1144 return SNMP_INTEGER(1);
1145 } else
1146 return SNMP_INTEGER(0);
1147 break;
1148 case EIGRPRTO: /* 8 */
1149 /* The computed retransmission timeout for the peer */
1150 if (eigrp) {
1151 return SNMP_INTEGER(1);
1152 } else
1153 return SNMP_INTEGER(0);
1154 break;
1155 case EIGRPPKTSENQUEUED: /* 9 */
1156 /* The number of any EIGRP packets currently enqueued */
1157 if (eigrp) {
1158 return SNMP_INTEGER(1);
1159 } else
1160 return SNMP_INTEGER(0);
1161 break;
1162 case EIGRPLASTSEQ: /* 10 */
1163 /* sequence number of the last EIGRP packet sent to this peer */
1164 if (eigrp) {
1165 return SNMP_INTEGER(1);
1166 } else
1167 return SNMP_INTEGER(0);
1168 break;
1169 case EIGRPVERSION: /* 11 */
1170 /* The EIGRP version information reported by the remote peer */
1171 if (eigrp) {
1172 return SNMP_INTEGER(1);
1173 } else
1174 return SNMP_INTEGER(0);
1175 break;
1176 case EIGRPRETRANS: /* 12 */
1177 /* The cumulative number of retransmissions to this peer */
1178 if (eigrp) {
1179 return SNMP_INTEGER(1);
1180 } else
1181 return SNMP_INTEGER(0);
1182 break;
1183 case EIGRPRETRIES: /* 13 */
1184 /* The number of times the current unacknowledged packet has
1185 * been retried */
1186 if (eigrp) {
1187 return SNMP_INTEGER(1);
1188 } else
1189 return SNMP_INTEGER(0);
1190 break;
1191 default:
1192 return NULL;
1193 }
1194 return NULL;
f9e5c9ca 1195}
7f57883e 1196
d7c0a89a
QY
1197static uint8_t *eigrpInterfaceEntry(struct variable *v, oid *name,
1198 size_t *length, int exact, size_t *var_len,
1199 WriteMethod **write_method)
f9e5c9ca 1200{
d62a17ae 1201 struct eigrp *eigrp;
1202 struct eigrp_interface *ei;
1203 struct listnode *node, *nnode;
1204 struct keychain *keychain;
1205 struct list *keylist;
1206 int counter;
1207
1208 eigrp = eigrp_lookup();
1209
1210 /* Check whether the instance identifier is valid */
1211 if (smux_header_generic(v, name, length, exact, var_len, write_method)
1212 == MATCH_FAILED)
1213 return NULL;
1214
1215 /* Return the current value of the variable */
1216 switch (v->magic) {
1217 case EIGRPPEERCOUNT: /* 3 */
1218 /* The number of EIGRP adjacencies currently formed with
1219 peers reached through this interface */
1220 if (eigrp) {
1221 return SNMP_INTEGER(eigrp_neighbor_count(eigrp));
1222 } else
1223 return SNMP_INTEGER(0);
1224 break;
1225 case EIGRPXMITRELIABLEQ: /* 4 */
1226 /* The number of EIGRP packets currently waiting in the reliable
1227 transport transmission queue */
1228 if (eigrp) {
1229 return SNMP_INTEGER(1);
1230 } else
1231 return SNMP_INTEGER(0);
1232 break;
1233 case EIGRPXMITUNRELIABLEQ: /* 5 */
1234 /* The number of EIGRP packets currently waiting in the
1235 unreliable
1236 transport transmission queue */
1237 if (eigrp) {
1238 return SNMP_INTEGER(1);
1239 } else
1240 return SNMP_INTEGER(0);
1241 break;
1242 case EIGRPMEANSRTT: /* 6 */
1243 /* The average of all the computed smooth round trip time values
1244 for a packet to and from all peers established on this
1245 interface */
1246 if (eigrp) {
1247 return SNMP_INTEGER(1);
1248 } else
1249 return SNMP_INTEGER(0);
1250 break;
1251 case EIGRPPACINGRELIABLE: /* 7 */
1252 /* The configured time interval between EIGRP packet
1253 * transmissions */
1254 if (eigrp) {
1255 return SNMP_INTEGER(1);
1256 } else
1257 return SNMP_INTEGER(0);
1258 break;
1259 case EIGRPPACINGUNRELIABLE: /* 8 */
1260 /* The configured time interval between EIGRP packet
1261 transmissions
1262 on the interface when the unreliable transport method is used
1263 */
1264 if (eigrp) {
1265 return SNMP_INTEGER(1);
1266 } else
1267 return SNMP_INTEGER(0);
1268 break;
1269 case EIGRPMFLOWTIMER: /* 9 */
1270 /* The configured multicast flow control timer value */
1271 if (eigrp) {
1272 return SNMP_INTEGER(1);
1273 } else
1274 return SNMP_INTEGER(0);
1275 break;
1276 case EIGRPPENDINGROUTES: /* 10 */
1277 /* The number of queued EIGRP routing updates awaiting
1278 * transmission */
1279 if (eigrp) {
1280 return SNMP_INTEGER(1);
1281 } else
1282 return SNMP_INTEGER(0);
1283 break;
1284 case EIGRPHELLOINTERVAL: /* 11 */
1285 /* The configured time interval between Hello packet
1286 * transmissions */
1287 if (eigrp) {
1288 return SNMP_INTEGER(1);
1289 } else
1290 return SNMP_INTEGER(0);
1291 break;
1292 case EIGRPXMITNEXTSERIAL: /* 12 */
1293 /* The serial number of the next EIGRP packet that is to be
1294 queued
1295 for transmission */
1296 if (eigrp) {
1297 return SNMP_INTEGER(1);
1298 } else
1299 return SNMP_INTEGER(0);
1300 break;
1301 case EIGRPUMCASTS: /* 13 */
1302 /* The total number of unreliable EIGRP multicast packets sent
1303 on this interface */
1304 if (eigrp) {
1305 return SNMP_INTEGER(1);
1306 } else
1307 return SNMP_INTEGER(0);
1308 break;
1309 case EIGRPRMCASTS: /* 14 */
1310 /* The total number of reliable EIGRP multicast packets sent
1311 on this interface */
1312 if (eigrp) {
1313 return SNMP_INTEGER(1);
1314 } else
1315 return SNMP_INTEGER(0);
1316 break;
1317 case EIGRPUUCASTS: /* 15 */
1318 /* The total number of unreliable EIGRP unicast packets sent
1319 on this interface */
1320 if (eigrp) {
1321 return SNMP_INTEGER(1);
1322 } else
1323 return SNMP_INTEGER(0);
1324 break;
1325 case EIGRPRUCASTS: /* 16 */
1326 /* The total number of reliable EIGRP unicast packets sent
1327 on this interface */
1328 if (eigrp) {
1329 return SNMP_INTEGER(1);
1330 } else
1331 return SNMP_INTEGER(0);
1332 break;
1333 case EIGRPMCASTEXCEPTS: /* 17 */
1334 /* The total number of EIGRP multicast exception transmissions
1335 */
1336 if (eigrp) {
1337 return SNMP_INTEGER(1);
1338 } else
1339 return SNMP_INTEGER(0);
1340 break;
1341 case EIGRPCRPKTS: /* 18 */
1342 /* The total number EIGRP Conditional-Receive packets sent on
1343 * this interface */
1344 if (eigrp) {
1345 return SNMP_INTEGER(1);
1346 } else
1347 return SNMP_INTEGER(0);
1348 break;
1349 case EIGRPACKSSUPPRESSED: /* 19 */
1350 /* The total number of individual EIGRP acknowledgement packets
1351 that have been
1352 suppressed and combined in an already enqueued outbound
1353 reliable packet on this interface */
1354 if (eigrp) {
1355 return SNMP_INTEGER(1);
1356 } else
1357 return SNMP_INTEGER(0);
1358 break;
1359 case EIGRPRETRANSSENT: /* 20 */
1360 /* The total number EIGRP packet retransmissions sent on the
1361 * interface */
1362 if (eigrp) {
1363 return SNMP_INTEGER(1);
1364 } else
1365 return SNMP_INTEGER(0);
1366 break;
1367 case EIGRPOOSRCVD: /* 21 */
1368 /* The total number of out-of-sequence EIGRP packets received */
1369 if (eigrp) {
1370 return SNMP_INTEGER(1);
1371 } else
1372 return SNMP_INTEGER(0);
1373 break;
1374 case EIGRPAUTHMODE: /* 22 */
1375 /* The EIGRP authentication mode of the interface */
1376 if (eigrp) {
1377 return SNMP_INTEGER(1);
1378 } else
1379 return SNMP_INTEGER(0);
1380 break;
1381 case EIGRPAUTHKEYCHAIN: /* 23 */
1382 /* The name of the authentication key-chain configured
1383 on this interface. */
1384 keylist = keychain_list_get();
1385 for (ALL_LIST_ELEMENTS(keylist, node, nnode, keychain)) {
d7c0a89a 1386 return (uint8_t *)keychain->name;
d62a17ae 1387 }
1388 if (eigrp && keychain) {
1389 *var_len = str_len(keychain->name);
d7c0a89a 1390 return (uint8_t *)keychain->name;
d62a17ae 1391 } else
d7c0a89a 1392 return (uint8_t *)"TEST";
d62a17ae 1393 break;
1394 default:
1395 return NULL;
1396 }
1397 return NULL;
f9e5c9ca 1398}
7f57883e 1399
f9e5c9ca 1400/* Register EIGRP-MIB. */
d62a17ae 1401void eigrp_snmp_init()
f9e5c9ca 1402{
d62a17ae 1403 eigrp_snmp_iflist = list_new();
1404 smux_init(eigrp_om->master);
1405 REGISTER_MIB("ciscoEigrpMIB", eigrp_variables, variable, eigrp_oid);
f9e5c9ca 1406}
7f57883e 1407#endif