]>
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);
623 case EIGRPVPNNAME
: /* 2 */
624 /* The name given to the VPN */
626 return SNMP_INTEGER(1);
628 return SNMP_INTEGER(0);
636 static uint32_t eigrp_neighbor_count(struct eigrp
*eigrp
)
639 struct eigrp_interface
*ei
;
640 struct listnode
*node
, *node2
, *nnode2
;
641 struct eigrp_neighbor
*nbr
;
648 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
649 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
650 if (nbr
->state
== EIGRP_NEIGHBOR_UP
)
659 static uint8_t *eigrpTraffStatsEntry(struct variable
*v
, oid
*name
,
660 size_t *length
, int exact
, size_t *var_len
,
661 WriteMethod
**write_method
)
664 struct eigrp_interface
*ei
;
665 struct listnode
*node
, *nnode
;
668 eigrp
= eigrp_lookup();
670 /* Check whether the instance identifier is valid */
671 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
675 /* Return the current value of the variable */
677 case EIGRPASNUMBER
: /* 1 */
678 /* AS-number of this EIGRP instance. */
680 return SNMP_INTEGER(eigrp
->AS
);
682 return SNMP_INTEGER(0);
684 case EIGRPNBRCOUNT
: /* 2 */
685 /* Neighbor count of this EIGRP instance */
687 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
689 return SNMP_INTEGER(0);
691 case EIGRPHELLOSSENT
: /* 3 */
692 /* Hello packets output count */
695 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
697 counter
+= ei
->hello_out
;
699 return SNMP_INTEGER(counter
);
701 return SNMP_INTEGER(0);
703 case EIGRPHELLOSRCVD
: /* 4 */
704 /* Hello packets input count */
707 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
709 counter
+= ei
->hello_in
;
711 return SNMP_INTEGER(counter
);
713 return SNMP_INTEGER(0);
715 case EIGRPUPDATESSENT
: /* 5 */
716 /* Update packets output count */
719 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
721 counter
+= ei
->update_out
;
723 return SNMP_INTEGER(counter
);
725 return SNMP_INTEGER(0);
727 case EIGRPUPDATESRCVD
: /* 6 */
728 /* Update packets input count */
731 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
733 counter
+= ei
->update_in
;
735 return SNMP_INTEGER(counter
);
737 return SNMP_INTEGER(0);
739 case EIGRPQUERIESSENT
: /* 7 */
740 /* Querry packets output count */
743 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
745 counter
+= ei
->query_out
;
747 return SNMP_INTEGER(counter
);
749 return SNMP_INTEGER(0);
751 case EIGRPQUERIESRCVD
: /* 8 */
752 /* Querry packets input count */
755 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
757 counter
+= ei
->query_in
;
759 return SNMP_INTEGER(counter
);
761 return SNMP_INTEGER(0);
763 case EIGRPREPLIESSENT
: /* 9 */
764 /* Reply packets output count */
767 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
769 counter
+= ei
->reply_out
;
771 return SNMP_INTEGER(counter
);
773 return SNMP_INTEGER(0);
775 case EIGRPREPLIESRCVD
: /* 10 */
776 /* Reply packets input count */
779 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
781 counter
+= ei
->reply_in
;
783 return SNMP_INTEGER(counter
);
785 return SNMP_INTEGER(0);
787 case EIGRPACKSSENT
: /* 11 */
788 /* Acknowledgement packets output count */
791 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
793 counter
+= ei
->ack_out
;
795 return SNMP_INTEGER(counter
);
797 return SNMP_INTEGER(0);
799 case EIGRPACKSRCVD
: /* 12 */
800 /* Acknowledgement packets input count */
803 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
805 counter
+= ei
->ack_in
;
807 return SNMP_INTEGER(counter
);
809 return SNMP_INTEGER(0);
811 case EIGRPINPUTQHIGHMARK
: /* 13 */
812 /* The highest number of EIGRP packets in the input queue */
814 return SNMP_INTEGER(1);
816 return SNMP_INTEGER(0);
818 case EIGRPINPUTQDROPS
: /* 14 */
819 /* The number of EIGRP packets dropped from the input queue */
821 return SNMP_INTEGER(1);
823 return SNMP_INTEGER(0);
825 case EIGRPSIAQUERIESSENT
: /* 15 */
826 /* SIA querry packets output count */
829 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
831 counter
+= ei
->siaQuery_out
;
833 return SNMP_INTEGER(counter
);
835 return SNMP_INTEGER(0);
837 case EIGRPSIAQUERIESRCVD
: /* 16 */
838 /* SIA querry packets input count */
841 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
843 counter
+= ei
->siaQuery_in
;
845 return SNMP_INTEGER(counter
);
847 return SNMP_INTEGER(0);
849 case EIGRPASROUTERIDTYPE
: /* 17 */
850 /* Whether the router ID is set manually or automatically */
852 if (eigrp
->router_id_static
!= 0)
853 return SNMP_INTEGER(1);
855 return SNMP_INTEGER(1);
857 return SNMP_INTEGER(0);
859 case EIGRPASROUTERID
: /* 18 */
860 /* Router ID for this EIGRP AS */
862 if (eigrp
->router_id_static
!= 0)
863 return SNMP_INTEGER(eigrp
->router_id_static
);
865 return SNMP_INTEGER(eigrp
->router_id
);
867 return SNMP_INTEGER(0);
869 case EIGRPTOPOROUTES
: /* 19 */
870 /* The total number of EIGRP derived routes currently existing
871 in the topology table for the AS */
873 return SNMP_INTEGER(1);
875 return SNMP_INTEGER(0);
877 case EIGRPHEADSERIAL
: /* 20 */
878 /* The serial number of the first route in the internal
881 return SNMP_INTEGER(1);
883 return SNMP_INTEGER(0);
885 case EIGRPNEXTSERIAL
: /* 21 */
886 /* The serial number that would be assigned to the next new
887 or changed route in the topology table for the AS*/
889 return SNMP_INTEGER(1);
891 return SNMP_INTEGER(0);
893 case EIGRPXMITPENDREPLIES
: /* 22 */
894 /* Total number of outstanding replies expected to queries
895 that have been sent to peers in the current AS*/
897 return SNMP_INTEGER(1);
899 return SNMP_INTEGER(0);
901 case EIGRPXMITDUMMIES
: /* 23 */
902 /* Total number of currently existing dummies associated with
905 return SNMP_INTEGER(1);
907 return SNMP_INTEGER(0);
915 static uint8_t *eigrpTopologyEntry(struct variable
*v
, oid
*name
,
916 size_t *length
, int exact
, size_t *var_len
,
917 WriteMethod
**write_method
)
921 eigrp
= eigrp_lookup();
923 /* Check whether the instance identifier is valid */
924 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
928 /* Return the current value of the variable */
930 case EIGRPDESTNETTYPE
: /* 1 */
931 /* The format of the destination IP network number for a single
932 route in the topology table*/
934 return SNMP_INTEGER(1);
936 return SNMP_INTEGER(0);
938 case EIGRPDESTNET
: /* 2 */
939 /* The destination IP network number for a single route in the
942 return SNMP_INTEGER(1);
944 return SNMP_INTEGER(0);
946 case EIGRPDESTNETPREFIXLEN
: /* 4 */
947 /* The prefix length associated with the destination IP network
949 for a single route in the topology table in the AS*/
951 return SNMP_INTEGER(1);
953 return SNMP_INTEGER(0);
955 case EIGRPACTIVE
: /* 5 */
956 /* A value of true(1) indicates the route to the destination
958 A value of false(2) indicates the route is stable
961 return SNMP_INTEGER(1);
963 return SNMP_INTEGER(0);
965 case EIGRPSTUCKINACTIVE
: /* 6 */
966 /* A value of true(1) indicates that that this route which is in
968 has not received any replies to queries for alternate paths
971 return SNMP_INTEGER(1);
973 return SNMP_INTEGER(0);
975 case EIGRPDESTSUCCESSORS
: /* 7 */
976 /* Next routing hop for a path to the destination IP network */
978 return SNMP_INTEGER(1);
980 return SNMP_INTEGER(0);
982 case EIGRPFDISTANCE
: /* 8 */
983 /* Minimum distance from this router to the destination IP
986 return SNMP_INTEGER(1);
988 return SNMP_INTEGER(0);
990 case EIGRPROUTEORIGINTYPE
: /* 9 */
991 /* Text string describing the internal origin of the EIGRP route
994 return SNMP_INTEGER(1);
996 return SNMP_INTEGER(0);
998 case EIGRPROUTEORIGINADDRTYPE
: /* 10 */
999 /* The format of the IP address defined as the origin of this
1000 topology route entry */
1002 return SNMP_INTEGER(1);
1004 return SNMP_INTEGER(0);
1006 case EIGRPROUTEORIGINADDR
: /* 11 */
1007 /* If the origin of the topology route entry is external to this
1009 then this object is the IP address of the router from which
1012 return SNMP_INTEGER(1);
1014 return SNMP_INTEGER(0);
1016 case EIGRPNEXTHOPADDRESSTYPE
: /* 12 */
1017 /* The format of the next hop IP address */
1019 return SNMP_INTEGER(1);
1021 return SNMP_INTEGER(0);
1023 case EIGRPNEXTHOPADDRESS
: /* 13 */
1024 /* Next hop IP address for the route */
1026 return SNMP_INTEGER(1);
1028 return SNMP_INTEGER(0);
1030 case EIGRPNEXTHOPINTERFACE
: /* 14 */
1031 /* The interface through which the next hop IP address is
1034 return SNMP_INTEGER(1);
1036 return SNMP_INTEGER(0);
1038 case EIGRPDISTANCE
: /* 15 */
1039 /* The computed distance to the destination network entry from
1042 return SNMP_INTEGER(1);
1044 return SNMP_INTEGER(0);
1046 case EIGRPREPORTDISTANCE
: /* 16 */
1047 /* The computed distance to the destination network in the
1049 reported to this router by the originator of this route */
1051 return SNMP_INTEGER(1);
1053 return SNMP_INTEGER(0);
1061 static uint8_t *eigrpPeerEntry(struct variable
*v
, oid
*name
, size_t *length
,
1062 int exact
, size_t *var_len
,
1063 WriteMethod
**write_method
)
1065 struct eigrp
*eigrp
;
1066 struct eigrp_interface
*ei
;
1067 struct eigrp_neighbor
*nbr
;
1068 struct in_addr nbr_addr
;
1069 unsigned int ifindex
;
1071 eigrp
= eigrp_lookup();
1073 /* Check whether the instance identifier is valid */
1074 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1078 memset(&nbr_addr
, 0, sizeof(struct in_addr
));
1081 nbr
= eigrpNbrLookup(v
, name
, length
, &nbr_addr
, &ifindex
, exact
);
1088 /* Return the current value of the variable */
1090 case EIGRPHANDLE
: /* 1 */
1091 /* The unique internal identifier for the peer in the AS */
1093 return SNMP_INTEGER(1);
1095 return SNMP_INTEGER(0);
1097 case EIGRPPEERADDRTYPE
: /* 2 */
1098 /* The format of the remote source IP address used by the peer
1101 return SNMP_INTEGER(1);
1103 return SNMP_INTEGER(0);
1105 case EIGRPPEERADDR
: /* 3 */
1106 /* The source IP address used by the peer */
1108 return SNMP_INTEGER(1);
1110 return SNMP_INTEGER(0);
1112 case EIGRPPEERIFINDEX
: /* 4 */
1113 /* The ifIndex of the interface on this router */
1115 return SNMP_INTEGER(1);
1117 return SNMP_INTEGER(0);
1119 case EIGRPHOLDTIME
: /* 5 */
1120 /* How much time must pass without receiving a hello packet from
1122 EIGRP peer before this router declares the peer down */
1124 return SNMP_INTEGER(1);
1126 return SNMP_INTEGER(0);
1128 case EIGRPUPTIME
: /* 6 */
1129 /* The elapsed time since the EIGRP adjacency was first
1132 return SNMP_INTEGER(1);
1134 return SNMP_INTEGER(0);
1136 case EIGRPSRTT
: /* 7 */
1137 /* The computed smooth round trip time for packets to and from
1140 return SNMP_INTEGER(1);
1142 return SNMP_INTEGER(0);
1144 case EIGRPRTO
: /* 8 */
1145 /* The computed retransmission timeout for the peer */
1147 return SNMP_INTEGER(1);
1149 return SNMP_INTEGER(0);
1151 case EIGRPPKTSENQUEUED
: /* 9 */
1152 /* The number of any EIGRP packets currently enqueued */
1154 return SNMP_INTEGER(1);
1156 return SNMP_INTEGER(0);
1158 case EIGRPLASTSEQ
: /* 10 */
1159 /* sequence number of the last EIGRP packet sent to this peer */
1161 return SNMP_INTEGER(1);
1163 return SNMP_INTEGER(0);
1165 case EIGRPVERSION
: /* 11 */
1166 /* The EIGRP version information reported by the remote peer */
1168 return SNMP_INTEGER(1);
1170 return SNMP_INTEGER(0);
1172 case EIGRPRETRANS
: /* 12 */
1173 /* The cumulative number of retransmissions to this peer */
1175 return SNMP_INTEGER(1);
1177 return SNMP_INTEGER(0);
1179 case EIGRPRETRIES
: /* 13 */
1180 /* The number of times the current unacknowledged packet has
1183 return SNMP_INTEGER(1);
1185 return SNMP_INTEGER(0);
1193 static uint8_t *eigrpInterfaceEntry(struct variable
*v
, oid
*name
,
1194 size_t *length
, int exact
, size_t *var_len
,
1195 WriteMethod
**write_method
)
1197 struct eigrp
*eigrp
;
1198 struct listnode
*node
, *nnode
;
1199 struct keychain
*keychain
;
1200 struct list
*keylist
;
1202 eigrp
= eigrp_lookup();
1204 /* Check whether the instance identifier is valid */
1205 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1209 /* Return the current value of the variable */
1211 case EIGRPPEERCOUNT
: /* 3 */
1212 /* The number of EIGRP adjacencies currently formed with
1213 peers reached through this interface */
1215 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
1217 return SNMP_INTEGER(0);
1219 case EIGRPXMITRELIABLEQ
: /* 4 */
1220 /* The number of EIGRP packets currently waiting in the reliable
1221 transport transmission queue */
1223 return SNMP_INTEGER(1);
1225 return SNMP_INTEGER(0);
1227 case EIGRPXMITUNRELIABLEQ
: /* 5 */
1228 /* The number of EIGRP packets currently waiting in the
1230 transport transmission queue */
1232 return SNMP_INTEGER(1);
1234 return SNMP_INTEGER(0);
1236 case EIGRPMEANSRTT
: /* 6 */
1237 /* The average of all the computed smooth round trip time values
1238 for a packet to and from all peers established on this
1241 return SNMP_INTEGER(1);
1243 return SNMP_INTEGER(0);
1245 case EIGRPPACINGRELIABLE
: /* 7 */
1246 /* The configured time interval between EIGRP packet
1249 return SNMP_INTEGER(1);
1251 return SNMP_INTEGER(0);
1253 case EIGRPPACINGUNRELIABLE
: /* 8 */
1254 /* The configured time interval between EIGRP packet
1256 on the interface when the unreliable transport method is used
1259 return SNMP_INTEGER(1);
1261 return SNMP_INTEGER(0);
1263 case EIGRPMFLOWTIMER
: /* 9 */
1264 /* The configured multicast flow control timer value */
1266 return SNMP_INTEGER(1);
1268 return SNMP_INTEGER(0);
1270 case EIGRPPENDINGROUTES
: /* 10 */
1271 /* The number of queued EIGRP routing updates awaiting
1274 return SNMP_INTEGER(1);
1276 return SNMP_INTEGER(0);
1278 case EIGRPHELLOINTERVAL
: /* 11 */
1279 /* The configured time interval between Hello packet
1282 return SNMP_INTEGER(1);
1284 return SNMP_INTEGER(0);
1286 case EIGRPXMITNEXTSERIAL
: /* 12 */
1287 /* The serial number of the next EIGRP packet that is to be
1291 return SNMP_INTEGER(1);
1293 return SNMP_INTEGER(0);
1295 case EIGRPUMCASTS
: /* 13 */
1296 /* The total number of unreliable EIGRP multicast packets sent
1297 on this interface */
1299 return SNMP_INTEGER(1);
1301 return SNMP_INTEGER(0);
1303 case EIGRPRMCASTS
: /* 14 */
1304 /* The total number of reliable EIGRP multicast packets sent
1305 on this interface */
1307 return SNMP_INTEGER(1);
1309 return SNMP_INTEGER(0);
1311 case EIGRPUUCASTS
: /* 15 */
1312 /* The total number of unreliable EIGRP unicast packets sent
1313 on this interface */
1315 return SNMP_INTEGER(1);
1317 return SNMP_INTEGER(0);
1319 case EIGRPRUCASTS
: /* 16 */
1320 /* The total number of reliable EIGRP unicast packets sent
1321 on this interface */
1323 return SNMP_INTEGER(1);
1325 return SNMP_INTEGER(0);
1327 case EIGRPMCASTEXCEPTS
: /* 17 */
1328 /* The total number of EIGRP multicast exception transmissions
1331 return SNMP_INTEGER(1);
1333 return SNMP_INTEGER(0);
1335 case EIGRPCRPKTS
: /* 18 */
1336 /* The total number EIGRP Conditional-Receive packets sent on
1339 return SNMP_INTEGER(1);
1341 return SNMP_INTEGER(0);
1343 case EIGRPACKSSUPPRESSED
: /* 19 */
1344 /* The total number of individual EIGRP acknowledgement packets
1346 suppressed and combined in an already enqueued outbound
1347 reliable packet on this interface */
1349 return SNMP_INTEGER(1);
1351 return SNMP_INTEGER(0);
1353 case EIGRPRETRANSSENT
: /* 20 */
1354 /* The total number EIGRP packet retransmissions sent on the
1357 return SNMP_INTEGER(1);
1359 return SNMP_INTEGER(0);
1361 case EIGRPOOSRCVD
: /* 21 */
1362 /* The total number of out-of-sequence EIGRP packets received */
1364 return SNMP_INTEGER(1);
1366 return SNMP_INTEGER(0);
1368 case EIGRPAUTHMODE
: /* 22 */
1369 /* The EIGRP authentication mode of the interface */
1371 return SNMP_INTEGER(1);
1373 return SNMP_INTEGER(0);
1375 case EIGRPAUTHKEYCHAIN
: /* 23 */
1376 /* The name of the authentication key-chain configured
1377 on this interface. */
1378 keylist
= keychain_list_get();
1379 for (ALL_LIST_ELEMENTS(keylist
, node
, nnode
, keychain
)) {
1380 return (uint8_t *)keychain
->name
;
1382 if (eigrp
&& keychain
) {
1383 *var_len
= str_len(keychain
->name
);
1384 return (uint8_t *)keychain
->name
;
1386 return (uint8_t *)"TEST";
1394 /* Register EIGRP-MIB. */
1395 void eigrp_snmp_init()
1397 eigrp_snmp_iflist
= list_new();
1398 smux_init(eigrp_om
->master
);
1399 REGISTER_MIB("ciscoEigrpMIB", eigrp_variables
, variable
, eigrp_oid
);