]>
git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_snmp.c
3 * Copyright (C) 2013-2014
11 * This file is part of GNU Zebra.
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
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.
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
31 #include <net-snmp/net-snmp-config.h>
32 #include <net-snmp/net-snmp-includes.h>
40 #include "sockunion.h"
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"
62 struct list
*eigrp_snmp_iflist
;
64 /* Declare static local variables for convenience. */
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
70 /* EIGRP-MIB instances. */
71 oid eigrp_oid
[] = {EIGRPMIB
};
75 #define EIGRPVPNNAME 2
77 /* EIGRP Traffic statistics entry */
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
99 #define EIGRPXMITPENDREPLIES 22
100 #define EIGRPXMITDUMMIES 23
102 /* EIGRP topology entry */
103 #define EIGRPDESTNETTYPE 1
104 #define EIGRPDESTNET 2
105 #define EIGRPDESTNETPREFIXLEN 4
106 #define EIGRPACTIVE 5
107 #define EIGRPSTUCKINACTIVE 6
108 #define EIGRPDESTSUCCESSORS 7
109 #define EIGRPFDISTANCE 8
110 #define EIGRPROUTEORIGINTYPE 9
111 #define EIGRPROUTEORIGINADDRTYPE 10
112 #define EIGRPROUTEORIGINADDR 11
113 #define EIGRPNEXTHOPADDRESSTYPE 12
114 #define EIGRPNEXTHOPADDRESS 13
115 #define EIGRPNEXTHOPINTERFACE 14
116 #define EIGRPDISTANCE 15
117 #define EIGRPREPORTDISTANCE 16
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
128 #define EIGRPPKTSENQUEUED 9
129 #define EIGRPLASTSEQ 10
130 #define EIGRPVERSION 11
131 #define EIGRPRETRANS 12
132 #define EIGRPRETRIES 13
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
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
169 /* Hook functions. */
170 static uint8_t *eigrpVpnEntry(struct variable
*, oid
*, size_t *, int, size_t *,
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,
175 size_t *, WriteMethod
**);
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
**);
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}},
187 /* EIGRP traffic stats variables */
191 eigrpTraffStatsEntry
,
194 {EIGRPNBRCOUNT
, UINTEGER
, RONLY
, eigrpTraffStatsEntry
, 4, {2, 1, 1, 2}},
198 eigrpTraffStatsEntry
,
204 eigrpTraffStatsEntry
,
210 eigrpTraffStatsEntry
,
216 eigrpTraffStatsEntry
,
222 eigrpTraffStatsEntry
,
228 eigrpTraffStatsEntry
,
234 eigrpTraffStatsEntry
,
240 eigrpTraffStatsEntry
,
243 {EIGRPACKSSENT
, COUNTER
, RONLY
, eigrpTraffStatsEntry
, 4, {2, 1, 1, 11}},
244 {EIGRPACKSRCVD
, COUNTER
, RONLY
, eigrpTraffStatsEntry
, 4, {2, 1, 1, 12}},
245 {EIGRPINPUTQHIGHMARK
,
248 eigrpTraffStatsEntry
,
254 eigrpTraffStatsEntry
,
257 {EIGRPSIAQUERIESSENT
,
260 eigrpTraffStatsEntry
,
263 {EIGRPSIAQUERIESRCVD
,
266 eigrpTraffStatsEntry
,
269 {EIGRPASROUTERIDTYPE
,
272 eigrpTraffStatsEntry
,
278 eigrpTraffStatsEntry
,
284 eigrpTraffStatsEntry
,
290 eigrpTraffStatsEntry
,
296 eigrpTraffStatsEntry
,
299 {EIGRPXMITPENDREPLIES
,
302 eigrpTraffStatsEntry
,
308 eigrpTraffStatsEntry
,
312 /* EIGRP topology variables */
325 {EIGRPDESTNETPREFIXLEN
,
331 {EIGRPACTIVE
, INTEGER
, RONLY
, eigrpTopologyEntry
, 4, {3, 1, 1, 5}},
338 {EIGRPDESTSUCCESSORS
,
344 {EIGRPFDISTANCE
, INTEGER
, RONLY
, eigrpTopologyEntry
, 4, {3, 1, 1, 8}},
345 {EIGRPROUTEORIGINTYPE
,
351 {EIGRPROUTEORIGINADDRTYPE
,
357 {EIGRPROUTEORIGINADDR
,
363 {EIGRPNEXTHOPADDRESSTYPE
,
369 {EIGRPNEXTHOPADDRESS
,
375 {EIGRPNEXTHOPINTERFACE
,
381 {EIGRPDISTANCE
, INTEGER
, RONLY
, eigrpTopologyEntry
, 4, {3, 1, 1, 15}},
382 {EIGRPREPORTDISTANCE
,
389 /* EIGRP peer variables */
390 {EIGRPHANDLE
, INTEGER
, NOACCESS
, eigrpPeerEntry
, 4, {4, 1, 1, 1}},
397 {EIGRPPEERADDR
, IPADDRESS
, RONLY
, eigrpPeerEntry
, 4, {4, 1, 1, 3}},
399 INTERFACEINDEXORZERO
,
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}},
414 /* EIGRP interface variables */
415 {EIGRPPEERCOUNT
, GAUGE
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 3}},
422 {EIGRPXMITUNRELIABLEQ
,
428 {EIGRPMEANSRTT
, INTEGER
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 6}},
429 {EIGRPPACINGRELIABLE
,
435 {EIGRPPACINGUNRELIABLE
,
441 {EIGRPMFLOWTIMER
, INTEGER
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 9}},
454 {EIGRPXMITNEXTSERIAL
,
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}},
470 {EIGRPCRPKTS
, COUNTER
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 18}},
471 {EIGRPACKSSUPPRESSED
,
483 {EIGRPOOSRCVD
, COUNTER
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 21}},
484 {EIGRPAUTHMODE
, INTEGER
, RONLY
, eigrpInterfaceEntry
, 4, {5, 1, 1, 22}},
492 static struct eigrp_neighbor
*eigrp_snmp_nbr_lookup(struct eigrp
*eigrp
,
493 struct in_addr
*nbr_addr
,
494 unsigned int *ifindex
)
496 struct listnode
*node
, *nnode
, *node2
, *nnode2
;
497 struct eigrp_interface
*ei
;
498 struct eigrp_neighbor
*nbr
;
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
)) {
510 static struct eigrp_neighbor
*
511 eigrp_snmp_nbr_lookup_next(struct in_addr
*nbr_addr
, unsigned int *ifindex
,
514 struct listnode
*node
, *nnode
, *node2
, *nnode2
;
515 struct eigrp_interface
*ei
;
516 struct eigrp_neighbor
*nbr
;
517 struct eigrp_neighbor
*min
= NULL
;
520 eigrp
= eigrp_lookup();
522 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
, ei
)) {
523 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
527 else if (ntohl(nbr
->src
.s_addr
)
528 < ntohl(min
->src
.s_addr
))
530 } else if (ntohl(nbr
->src
.s_addr
)
531 > ntohl(nbr_addr
->s_addr
)) {
534 else if (ntohl(nbr
->src
.s_addr
)
535 < ntohl(min
->src
.s_addr
))
541 *nbr_addr
= min
->src
;
548 static struct eigrp_neighbor
*eigrpNbrLookup(struct variable
*v
, oid
*name
,
550 struct in_addr
*nbr_addr
,
551 unsigned int *ifindex
, int exact
)
555 struct eigrp_neighbor
*nbr
;
558 eigrp
= eigrp_lookup();
564 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ 1)
567 oid2in_addr(name
+ v
->namelen
, IN_ADDR_SIZE
, nbr_addr
);
568 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
570 return eigrp_snmp_nbr_lookup(eigrp
, nbr_addr
, ifindex
);
573 len
= *length
- v
->namelen
;
578 if (len
> IN_ADDR_SIZE
)
581 oid2in_addr(name
+ v
->namelen
, len
, nbr_addr
);
583 len
= *length
- v
->namelen
- IN_ADDR_SIZE
;
585 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
587 nbr
= eigrp_snmp_nbr_lookup_next(nbr_addr
, ifindex
, first
);
590 *length
= v
->namelen
+ IN_ADDR_SIZE
+ 1;
591 oid_copy_addr(name
+ v
->namelen
, nbr_addr
,
593 name
[v
->namelen
+ IN_ADDR_SIZE
] = *ifindex
;
601 static uint8_t *eigrpVpnEntry(struct variable
*v
, oid
*name
, size_t *length
,
602 int exact
, size_t *var_len
,
603 WriteMethod
**write_method
)
607 eigrp
= eigrp_lookup();
609 /* Check whether the instance identifier is valid */
610 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
614 /* Return the current value of the variable */
616 case EIGRPVPNID
: /* 1 */
617 /* The unique VPN identifier */
619 return SNMP_INTEGER(1);
621 return SNMP_INTEGER(0);
622 case EIGRPVPNNAME
: /* 2 */
623 /* The name given to the VPN */
625 return SNMP_INTEGER(1);
627 return SNMP_INTEGER(0);
634 static uint32_t eigrp_neighbor_count(struct eigrp
*eigrp
)
637 struct eigrp_interface
*ei
;
638 struct listnode
*node
, *node2
, *nnode2
;
639 struct eigrp_neighbor
*nbr
;
646 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
647 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
648 if (nbr
->state
== EIGRP_NEIGHBOR_UP
)
657 static uint8_t *eigrpTraffStatsEntry(struct variable
*v
, oid
*name
,
658 size_t *length
, int exact
, size_t *var_len
,
659 WriteMethod
**write_method
)
662 struct eigrp_interface
*ei
;
663 struct listnode
*node
, *nnode
;
666 eigrp
= eigrp_lookup();
668 /* Check whether the instance identifier is valid */
669 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
673 /* Return the current value of the variable */
675 case EIGRPASNUMBER
: /* 1 */
676 /* AS-number of this EIGRP instance. */
678 return SNMP_INTEGER(eigrp
->AS
);
680 return SNMP_INTEGER(0);
681 case EIGRPNBRCOUNT
: /* 2 */
682 /* Neighbor count of this EIGRP instance */
684 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
686 return SNMP_INTEGER(0);
687 case EIGRPHELLOSSENT
: /* 3 */
688 /* Hello packets output count */
691 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
693 counter
+= ei
->hello_out
;
695 return SNMP_INTEGER(counter
);
697 return SNMP_INTEGER(0);
698 case EIGRPHELLOSRCVD
: /* 4 */
699 /* Hello packets input count */
702 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
704 counter
+= ei
->hello_in
;
706 return SNMP_INTEGER(counter
);
708 return SNMP_INTEGER(0);
709 case EIGRPUPDATESSENT
: /* 5 */
710 /* Update packets output count */
713 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
715 counter
+= ei
->update_out
;
717 return SNMP_INTEGER(counter
);
719 return SNMP_INTEGER(0);
720 case EIGRPUPDATESRCVD
: /* 6 */
721 /* Update packets input count */
724 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
726 counter
+= ei
->update_in
;
728 return SNMP_INTEGER(counter
);
730 return SNMP_INTEGER(0);
731 case EIGRPQUERIESSENT
: /* 7 */
732 /* Querry packets output count */
735 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
737 counter
+= ei
->query_out
;
739 return SNMP_INTEGER(counter
);
741 return SNMP_INTEGER(0);
742 case EIGRPQUERIESRCVD
: /* 8 */
743 /* Querry packets input count */
746 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
748 counter
+= ei
->query_in
;
750 return SNMP_INTEGER(counter
);
752 return SNMP_INTEGER(0);
753 case EIGRPREPLIESSENT
: /* 9 */
754 /* Reply packets output count */
757 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
759 counter
+= ei
->reply_out
;
761 return SNMP_INTEGER(counter
);
763 return SNMP_INTEGER(0);
764 case EIGRPREPLIESRCVD
: /* 10 */
765 /* Reply packets input count */
768 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
770 counter
+= ei
->reply_in
;
772 return SNMP_INTEGER(counter
);
774 return SNMP_INTEGER(0);
775 case EIGRPACKSSENT
: /* 11 */
776 /* Acknowledgement packets output count */
779 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
781 counter
+= ei
->ack_out
;
783 return SNMP_INTEGER(counter
);
785 return SNMP_INTEGER(0);
786 case EIGRPACKSRCVD
: /* 12 */
787 /* Acknowledgement packets input count */
790 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
792 counter
+= ei
->ack_in
;
794 return SNMP_INTEGER(counter
);
796 return SNMP_INTEGER(0);
797 case EIGRPINPUTQHIGHMARK
: /* 13 */
798 /* The highest number of EIGRP packets in the input queue */
800 return SNMP_INTEGER(1);
802 return SNMP_INTEGER(0);
803 case EIGRPINPUTQDROPS
: /* 14 */
804 /* The number of EIGRP packets dropped from the input queue */
806 return SNMP_INTEGER(1);
808 return SNMP_INTEGER(0);
809 case EIGRPSIAQUERIESSENT
: /* 15 */
810 /* SIA querry packets output count */
813 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
815 counter
+= ei
->siaQuery_out
;
817 return SNMP_INTEGER(counter
);
819 return SNMP_INTEGER(0);
820 case EIGRPSIAQUERIESRCVD
: /* 16 */
821 /* SIA querry packets input count */
824 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
826 counter
+= ei
->siaQuery_in
;
828 return SNMP_INTEGER(counter
);
830 return SNMP_INTEGER(0);
831 case EIGRPASROUTERIDTYPE
: /* 17 */
832 /* Whether the router ID is set manually or automatically */
834 if (eigrp
->router_id_static
!= 0)
835 return SNMP_INTEGER(1);
837 return SNMP_INTEGER(1);
839 return SNMP_INTEGER(0);
840 case EIGRPASROUTERID
: /* 18 */
841 /* Router ID for this EIGRP AS */
843 if (eigrp
->router_id_static
!= 0)
844 return SNMP_INTEGER(eigrp
->router_id_static
);
846 return SNMP_INTEGER(eigrp
->router_id
);
848 return SNMP_INTEGER(0);
849 case EIGRPTOPOROUTES
: /* 19 */
850 /* The total number of EIGRP derived routes currently existing
851 in the topology table for the AS */
853 return SNMP_INTEGER(1);
855 return SNMP_INTEGER(0);
856 case EIGRPHEADSERIAL
: /* 20 */
857 /* The serial number of the first route in the internal
860 return SNMP_INTEGER(1);
862 return SNMP_INTEGER(0);
863 case EIGRPNEXTSERIAL
: /* 21 */
864 /* The serial number that would be assigned to the next new
865 or changed route in the topology table for the AS*/
867 return SNMP_INTEGER(1);
869 return SNMP_INTEGER(0);
870 case EIGRPXMITPENDREPLIES
: /* 22 */
871 /* Total number of outstanding replies expected to queries
872 that have been sent to peers in the current AS*/
874 return SNMP_INTEGER(1);
876 return SNMP_INTEGER(0);
877 case EIGRPXMITDUMMIES
: /* 23 */
878 /* Total number of currently existing dummies associated with
881 return SNMP_INTEGER(1);
883 return SNMP_INTEGER(0);
890 static uint8_t *eigrpTopologyEntry(struct variable
*v
, oid
*name
,
891 size_t *length
, int exact
, size_t *var_len
,
892 WriteMethod
**write_method
)
896 eigrp
= eigrp_lookup();
898 /* Check whether the instance identifier is valid */
899 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
903 /* Return the current value of the variable */
905 case EIGRPDESTNETTYPE
: /* 1 */
906 /* The format of the destination IP network number for a single
907 route in the topology table*/
909 return SNMP_INTEGER(1);
911 return SNMP_INTEGER(0);
912 case EIGRPDESTNET
: /* 2 */
913 /* The destination IP network number for a single route in the
916 return SNMP_INTEGER(1);
918 return SNMP_INTEGER(0);
919 case EIGRPDESTNETPREFIXLEN
: /* 4 */
920 /* The prefix length associated with the destination IP network
922 for a single route in the topology table in the AS*/
924 return SNMP_INTEGER(1);
926 return SNMP_INTEGER(0);
927 case EIGRPACTIVE
: /* 5 */
928 /* A value of true(1) indicates the route to the destination
930 A value of false(2) indicates the route is stable
933 return SNMP_INTEGER(1);
935 return SNMP_INTEGER(0);
936 case EIGRPSTUCKINACTIVE
: /* 6 */
937 /* A value of true(1) indicates that that this route which is in
939 has not received any replies to queries for alternate paths
942 return SNMP_INTEGER(1);
944 return SNMP_INTEGER(0);
945 case EIGRPDESTSUCCESSORS
: /* 7 */
946 /* Next routing hop for a path to the destination IP network */
948 return SNMP_INTEGER(1);
950 return SNMP_INTEGER(0);
951 case EIGRPFDISTANCE
: /* 8 */
952 /* Minimum distance from this router to the destination IP
955 return SNMP_INTEGER(1);
957 return SNMP_INTEGER(0);
958 case EIGRPROUTEORIGINTYPE
: /* 9 */
959 /* Text string describing the internal origin of the EIGRP route
962 return SNMP_INTEGER(1);
964 return SNMP_INTEGER(0);
965 case EIGRPROUTEORIGINADDRTYPE
: /* 10 */
966 /* The format of the IP address defined as the origin of this
967 topology route entry */
969 return SNMP_INTEGER(1);
971 return SNMP_INTEGER(0);
972 case EIGRPROUTEORIGINADDR
: /* 11 */
973 /* If the origin of the topology route entry is external to this
975 then this object is the IP address of the router from which
978 return SNMP_INTEGER(1);
980 return SNMP_INTEGER(0);
981 case EIGRPNEXTHOPADDRESSTYPE
: /* 12 */
982 /* The format of the next hop IP address */
984 return SNMP_INTEGER(1);
986 return SNMP_INTEGER(0);
987 case EIGRPNEXTHOPADDRESS
: /* 13 */
988 /* Next hop IP address for the route */
990 return SNMP_INTEGER(1);
992 return SNMP_INTEGER(0);
993 case EIGRPNEXTHOPINTERFACE
: /* 14 */
994 /* The interface through which the next hop IP address is
997 return SNMP_INTEGER(1);
999 return SNMP_INTEGER(0);
1000 case EIGRPDISTANCE
: /* 15 */
1001 /* The computed distance to the destination network entry from
1004 return SNMP_INTEGER(1);
1006 return SNMP_INTEGER(0);
1007 case EIGRPREPORTDISTANCE
: /* 16 */
1008 /* The computed distance to the destination network in the
1010 reported to this router by the originator of this route */
1012 return SNMP_INTEGER(1);
1014 return SNMP_INTEGER(0);
1021 static uint8_t *eigrpPeerEntry(struct variable
*v
, oid
*name
, size_t *length
,
1022 int exact
, size_t *var_len
,
1023 WriteMethod
**write_method
)
1025 struct eigrp
*eigrp
;
1026 struct eigrp_interface
*ei
;
1027 struct eigrp_neighbor
*nbr
;
1028 struct in_addr nbr_addr
;
1029 unsigned int ifindex
;
1031 eigrp
= eigrp_lookup();
1033 /* Check whether the instance identifier is valid */
1034 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1038 memset(&nbr_addr
, 0, sizeof(struct in_addr
));
1041 nbr
= eigrpNbrLookup(v
, name
, length
, &nbr_addr
, &ifindex
, exact
);
1048 /* Return the current value of the variable */
1050 case EIGRPHANDLE
: /* 1 */
1051 /* The unique internal identifier for the peer in the AS */
1053 return SNMP_INTEGER(1);
1055 return SNMP_INTEGER(0);
1056 case EIGRPPEERADDRTYPE
: /* 2 */
1057 /* The format of the remote source IP address used by the peer
1060 return SNMP_INTEGER(1);
1062 return SNMP_INTEGER(0);
1063 case EIGRPPEERADDR
: /* 3 */
1064 /* The source IP address used by the peer */
1066 return SNMP_INTEGER(1);
1068 return SNMP_INTEGER(0);
1069 case EIGRPPEERIFINDEX
: /* 4 */
1070 /* The ifIndex of the interface on this router */
1072 return SNMP_INTEGER(1);
1074 return SNMP_INTEGER(0);
1075 case EIGRPHOLDTIME
: /* 5 */
1076 /* How much time must pass without receiving a hello packet from
1078 EIGRP peer before this router declares the peer down */
1080 return SNMP_INTEGER(1);
1082 return SNMP_INTEGER(0);
1083 case EIGRPUPTIME
: /* 6 */
1084 /* The elapsed time since the EIGRP adjacency was first
1087 return SNMP_INTEGER(1);
1089 return SNMP_INTEGER(0);
1090 case EIGRPSRTT
: /* 7 */
1091 /* The computed smooth round trip time for packets to and from
1094 return SNMP_INTEGER(1);
1096 return SNMP_INTEGER(0);
1097 case EIGRPRTO
: /* 8 */
1098 /* The computed retransmission timeout for the peer */
1100 return SNMP_INTEGER(1);
1102 return SNMP_INTEGER(0);
1103 case EIGRPPKTSENQUEUED
: /* 9 */
1104 /* The number of any EIGRP packets currently enqueued */
1106 return SNMP_INTEGER(1);
1108 return SNMP_INTEGER(0);
1109 case EIGRPLASTSEQ
: /* 10 */
1110 /* sequence number of the last EIGRP packet sent to this peer */
1112 return SNMP_INTEGER(1);
1114 return SNMP_INTEGER(0);
1115 case EIGRPVERSION
: /* 11 */
1116 /* The EIGRP version information reported by the remote peer */
1118 return SNMP_INTEGER(1);
1120 return SNMP_INTEGER(0);
1121 case EIGRPRETRANS
: /* 12 */
1122 /* The cumulative number of retransmissions to this peer */
1124 return SNMP_INTEGER(1);
1126 return SNMP_INTEGER(0);
1127 case EIGRPRETRIES
: /* 13 */
1128 /* The number of times the current unacknowledged packet has
1131 return SNMP_INTEGER(1);
1133 return SNMP_INTEGER(0);
1140 static uint8_t *eigrpInterfaceEntry(struct variable
*v
, oid
*name
,
1141 size_t *length
, int exact
, size_t *var_len
,
1142 WriteMethod
**write_method
)
1144 struct eigrp
*eigrp
;
1145 struct listnode
*node
, *nnode
;
1146 struct keychain
*keychain
;
1147 struct list
*keylist
;
1149 eigrp
= eigrp_lookup();
1151 /* Check whether the instance identifier is valid */
1152 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1156 /* Return the current value of the variable */
1158 case EIGRPPEERCOUNT
: /* 3 */
1159 /* The number of EIGRP adjacencies currently formed with
1160 peers reached through this interface */
1162 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
1164 return SNMP_INTEGER(0);
1165 case EIGRPXMITRELIABLEQ
: /* 4 */
1166 /* The number of EIGRP packets currently waiting in the reliable
1167 transport transmission queue */
1169 return SNMP_INTEGER(1);
1171 return SNMP_INTEGER(0);
1172 case EIGRPXMITUNRELIABLEQ
: /* 5 */
1173 /* The number of EIGRP packets currently waiting in the
1175 transport transmission queue */
1177 return SNMP_INTEGER(1);
1179 return SNMP_INTEGER(0);
1180 case EIGRPMEANSRTT
: /* 6 */
1181 /* The average of all the computed smooth round trip time values
1182 for a packet to and from all peers established on this
1185 return SNMP_INTEGER(1);
1187 return SNMP_INTEGER(0);
1188 case EIGRPPACINGRELIABLE
: /* 7 */
1189 /* The configured time interval between EIGRP packet
1192 return SNMP_INTEGER(1);
1194 return SNMP_INTEGER(0);
1195 case EIGRPPACINGUNRELIABLE
: /* 8 */
1196 /* The configured time interval between EIGRP packet
1198 on the interface when the unreliable transport method is used
1201 return SNMP_INTEGER(1);
1203 return SNMP_INTEGER(0);
1204 case EIGRPMFLOWTIMER
: /* 9 */
1205 /* The configured multicast flow control timer value */
1207 return SNMP_INTEGER(1);
1209 return SNMP_INTEGER(0);
1210 case EIGRPPENDINGROUTES
: /* 10 */
1211 /* The number of queued EIGRP routing updates awaiting
1214 return SNMP_INTEGER(1);
1216 return SNMP_INTEGER(0);
1217 case EIGRPHELLOINTERVAL
: /* 11 */
1218 /* The configured time interval between Hello packet
1221 return SNMP_INTEGER(1);
1223 return SNMP_INTEGER(0);
1224 case EIGRPXMITNEXTSERIAL
: /* 12 */
1225 /* The serial number of the next EIGRP packet that is to be
1229 return SNMP_INTEGER(1);
1231 return SNMP_INTEGER(0);
1232 case EIGRPUMCASTS
: /* 13 */
1233 /* The total number of unreliable EIGRP multicast packets sent
1234 on this interface */
1236 return SNMP_INTEGER(1);
1238 return SNMP_INTEGER(0);
1239 case EIGRPRMCASTS
: /* 14 */
1240 /* The total number of reliable EIGRP multicast packets sent
1241 on this interface */
1243 return SNMP_INTEGER(1);
1245 return SNMP_INTEGER(0);
1246 case EIGRPUUCASTS
: /* 15 */
1247 /* The total number of unreliable EIGRP unicast packets sent
1248 on this interface */
1250 return SNMP_INTEGER(1);
1252 return SNMP_INTEGER(0);
1253 case EIGRPRUCASTS
: /* 16 */
1254 /* The total number of reliable EIGRP unicast packets sent
1255 on this interface */
1257 return SNMP_INTEGER(1);
1259 return SNMP_INTEGER(0);
1260 case EIGRPMCASTEXCEPTS
: /* 17 */
1261 /* The total number of EIGRP multicast exception transmissions
1264 return SNMP_INTEGER(1);
1266 return SNMP_INTEGER(0);
1267 case EIGRPCRPKTS
: /* 18 */
1268 /* The total number EIGRP Conditional-Receive packets sent on
1271 return SNMP_INTEGER(1);
1273 return SNMP_INTEGER(0);
1274 case EIGRPACKSSUPPRESSED
: /* 19 */
1275 /* The total number of individual EIGRP acknowledgement packets
1277 suppressed and combined in an already enqueued outbound
1278 reliable packet on this interface */
1280 return SNMP_INTEGER(1);
1282 return SNMP_INTEGER(0);
1283 case EIGRPRETRANSSENT
: /* 20 */
1284 /* The total number EIGRP packet retransmissions sent on the
1287 return SNMP_INTEGER(1);
1289 return SNMP_INTEGER(0);
1290 case EIGRPOOSRCVD
: /* 21 */
1291 /* The total number of out-of-sequence EIGRP packets received */
1293 return SNMP_INTEGER(1);
1295 return SNMP_INTEGER(0);
1296 case EIGRPAUTHMODE
: /* 22 */
1297 /* The EIGRP authentication mode of the interface */
1299 return SNMP_INTEGER(1);
1301 return SNMP_INTEGER(0);
1302 case EIGRPAUTHKEYCHAIN
: /* 23 */
1303 /* The name of the authentication key-chain configured
1304 on this interface. */
1305 keylist
= keychain_list_get();
1306 for (ALL_LIST_ELEMENTS(keylist
, node
, nnode
, keychain
)) {
1307 return (uint8_t *)keychain
->name
;
1309 if (eigrp
&& keychain
) {
1310 *var_len
= str_len(keychain
->name
);
1311 return (uint8_t *)keychain
->name
;
1313 return (uint8_t *)"TEST";
1321 /* Register EIGRP-MIB. */
1322 void eigrp_snmp_init()
1324 eigrp_snmp_iflist
= list_new();
1325 smux_init(eigrp_om
->master
);
1326 REGISTER_MIB("ciscoEigrpMIB", eigrp_variables
, variable
, eigrp_oid
);