]>
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_in_addr(name
+ v
->namelen
, nbr_addr
);
592 name
[v
->namelen
+ IN_ADDR_SIZE
] = *ifindex
;
600 static uint8_t *eigrpVpnEntry(struct variable
*v
, oid
*name
, size_t *length
,
601 int exact
, size_t *var_len
,
602 WriteMethod
**write_method
)
606 eigrp
= eigrp_lookup();
608 /* Check whether the instance identifier is valid */
609 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
613 /* Return the current value of the variable */
615 case EIGRPVPNID
: /* 1 */
616 /* The unique VPN identifier */
618 return SNMP_INTEGER(1);
620 return SNMP_INTEGER(0);
621 case EIGRPVPNNAME
: /* 2 */
622 /* The name given to the VPN */
624 return SNMP_INTEGER(1);
626 return SNMP_INTEGER(0);
633 static uint32_t eigrp_neighbor_count(struct eigrp
*eigrp
)
636 struct eigrp_interface
*ei
;
637 struct listnode
*node
, *node2
, *nnode2
;
638 struct eigrp_neighbor
*nbr
;
645 for (ALL_LIST_ELEMENTS_RO(eigrp
->eiflist
, node
, ei
)) {
646 for (ALL_LIST_ELEMENTS(ei
->nbrs
, node2
, nnode2
, nbr
)) {
647 if (nbr
->state
== EIGRP_NEIGHBOR_UP
)
656 static uint8_t *eigrpTraffStatsEntry(struct variable
*v
, oid
*name
,
657 size_t *length
, int exact
, size_t *var_len
,
658 WriteMethod
**write_method
)
661 struct eigrp_interface
*ei
;
662 struct listnode
*node
, *nnode
;
665 eigrp
= eigrp_lookup();
667 /* Check whether the instance identifier is valid */
668 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
672 /* Return the current value of the variable */
674 case EIGRPASNUMBER
: /* 1 */
675 /* AS-number of this EIGRP instance. */
677 return SNMP_INTEGER(eigrp
->AS
);
679 return SNMP_INTEGER(0);
680 case EIGRPNBRCOUNT
: /* 2 */
681 /* Neighbor count of this EIGRP instance */
683 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
685 return SNMP_INTEGER(0);
686 case EIGRPHELLOSSENT
: /* 3 */
687 /* Hello packets output count */
690 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
692 counter
+= ei
->hello_out
;
694 return SNMP_INTEGER(counter
);
696 return SNMP_INTEGER(0);
697 case EIGRPHELLOSRCVD
: /* 4 */
698 /* Hello packets input count */
701 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
703 counter
+= ei
->hello_in
;
705 return SNMP_INTEGER(counter
);
707 return SNMP_INTEGER(0);
708 case EIGRPUPDATESSENT
: /* 5 */
709 /* Update packets output count */
712 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
714 counter
+= ei
->update_out
;
716 return SNMP_INTEGER(counter
);
718 return SNMP_INTEGER(0);
719 case EIGRPUPDATESRCVD
: /* 6 */
720 /* Update packets input count */
723 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
725 counter
+= ei
->update_in
;
727 return SNMP_INTEGER(counter
);
729 return SNMP_INTEGER(0);
730 case EIGRPQUERIESSENT
: /* 7 */
731 /* Querry packets output count */
734 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
736 counter
+= ei
->query_out
;
738 return SNMP_INTEGER(counter
);
740 return SNMP_INTEGER(0);
741 case EIGRPQUERIESRCVD
: /* 8 */
742 /* Querry packets input count */
745 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
747 counter
+= ei
->query_in
;
749 return SNMP_INTEGER(counter
);
751 return SNMP_INTEGER(0);
752 case EIGRPREPLIESSENT
: /* 9 */
753 /* Reply packets output count */
756 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
758 counter
+= ei
->reply_out
;
760 return SNMP_INTEGER(counter
);
762 return SNMP_INTEGER(0);
763 case EIGRPREPLIESRCVD
: /* 10 */
764 /* Reply packets input count */
767 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
769 counter
+= ei
->reply_in
;
771 return SNMP_INTEGER(counter
);
773 return SNMP_INTEGER(0);
774 case EIGRPACKSSENT
: /* 11 */
775 /* Acknowledgement packets output count */
778 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
780 counter
+= ei
->ack_out
;
782 return SNMP_INTEGER(counter
);
784 return SNMP_INTEGER(0);
785 case EIGRPACKSRCVD
: /* 12 */
786 /* Acknowledgement packets input count */
789 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
791 counter
+= ei
->ack_in
;
793 return SNMP_INTEGER(counter
);
795 return SNMP_INTEGER(0);
796 case EIGRPINPUTQHIGHMARK
: /* 13 */
797 /* The highest number of EIGRP packets in the input queue */
799 return SNMP_INTEGER(1);
801 return SNMP_INTEGER(0);
802 case EIGRPINPUTQDROPS
: /* 14 */
803 /* The number of EIGRP packets dropped from the input queue */
805 return SNMP_INTEGER(1);
807 return SNMP_INTEGER(0);
808 case EIGRPSIAQUERIESSENT
: /* 15 */
809 /* SIA querry packets output count */
812 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
814 counter
+= ei
->siaQuery_out
;
816 return SNMP_INTEGER(counter
);
818 return SNMP_INTEGER(0);
819 case EIGRPSIAQUERIESRCVD
: /* 16 */
820 /* SIA querry packets input count */
823 for (ALL_LIST_ELEMENTS(eigrp
->eiflist
, node
, nnode
,
825 counter
+= ei
->siaQuery_in
;
827 return SNMP_INTEGER(counter
);
829 return SNMP_INTEGER(0);
830 case EIGRPASROUTERIDTYPE
: /* 17 */
831 /* Whether the router ID is set manually or automatically */
833 if (eigrp
->router_id_static
!= 0)
834 return SNMP_INTEGER(1);
836 return SNMP_INTEGER(1);
838 return SNMP_INTEGER(0);
839 case EIGRPASROUTERID
: /* 18 */
840 /* Router ID for this EIGRP AS */
842 if (eigrp
->router_id_static
!= 0)
843 return SNMP_INTEGER(eigrp
->router_id_static
);
845 return SNMP_INTEGER(eigrp
->router_id
);
847 return SNMP_INTEGER(0);
848 case EIGRPTOPOROUTES
: /* 19 */
849 /* The total number of EIGRP derived routes currently existing
850 in the topology table for the AS */
852 return SNMP_INTEGER(1);
854 return SNMP_INTEGER(0);
855 case EIGRPHEADSERIAL
: /* 20 */
856 /* The serial number of the first route in the internal
859 return SNMP_INTEGER(1);
861 return SNMP_INTEGER(0);
862 case EIGRPNEXTSERIAL
: /* 21 */
863 /* The serial number that would be assigned to the next new
864 or changed route in the topology table for the AS*/
866 return SNMP_INTEGER(1);
868 return SNMP_INTEGER(0);
869 case EIGRPXMITPENDREPLIES
: /* 22 */
870 /* Total number of outstanding replies expected to queries
871 that have been sent to peers in the current AS*/
873 return SNMP_INTEGER(1);
875 return SNMP_INTEGER(0);
876 case EIGRPXMITDUMMIES
: /* 23 */
877 /* Total number of currently existing dummies associated with
880 return SNMP_INTEGER(1);
882 return SNMP_INTEGER(0);
889 static uint8_t *eigrpTopologyEntry(struct variable
*v
, oid
*name
,
890 size_t *length
, int exact
, size_t *var_len
,
891 WriteMethod
**write_method
)
895 eigrp
= eigrp_lookup();
897 /* Check whether the instance identifier is valid */
898 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
902 /* Return the current value of the variable */
904 case EIGRPDESTNETTYPE
: /* 1 */
905 /* The format of the destination IP network number for a single
906 route in the topology table*/
908 return SNMP_INTEGER(1);
910 return SNMP_INTEGER(0);
911 case EIGRPDESTNET
: /* 2 */
912 /* The destination IP network number for a single route in the
915 return SNMP_INTEGER(1);
917 return SNMP_INTEGER(0);
918 case EIGRPDESTNETPREFIXLEN
: /* 4 */
919 /* The prefix length associated with the destination IP network
921 for a single route in the topology table in the AS*/
923 return SNMP_INTEGER(1);
925 return SNMP_INTEGER(0);
926 case EIGRPACTIVE
: /* 5 */
927 /* A value of true(1) indicates the route to the destination
929 A value of false(2) indicates the route is stable
932 return SNMP_INTEGER(1);
934 return SNMP_INTEGER(0);
935 case EIGRPSTUCKINACTIVE
: /* 6 */
936 /* A value of true(1) indicates that that this route which is in
938 has not received any replies to queries for alternate paths
941 return SNMP_INTEGER(1);
943 return SNMP_INTEGER(0);
944 case EIGRPDESTSUCCESSORS
: /* 7 */
945 /* Next routing hop for a path to the destination IP network */
947 return SNMP_INTEGER(1);
949 return SNMP_INTEGER(0);
950 case EIGRPFDISTANCE
: /* 8 */
951 /* Minimum distance from this router to the destination IP
954 return SNMP_INTEGER(1);
956 return SNMP_INTEGER(0);
957 case EIGRPROUTEORIGINTYPE
: /* 9 */
958 /* Text string describing the internal origin of the EIGRP route
961 return SNMP_INTEGER(1);
963 return SNMP_INTEGER(0);
964 case EIGRPROUTEORIGINADDRTYPE
: /* 10 */
965 /* The format of the IP address defined as the origin of this
966 topology route entry */
968 return SNMP_INTEGER(1);
970 return SNMP_INTEGER(0);
971 case EIGRPROUTEORIGINADDR
: /* 11 */
972 /* If the origin of the topology route entry is external to this
974 then this object is the IP address of the router from which
977 return SNMP_INTEGER(1);
979 return SNMP_INTEGER(0);
980 case EIGRPNEXTHOPADDRESSTYPE
: /* 12 */
981 /* The format of the next hop IP address */
983 return SNMP_INTEGER(1);
985 return SNMP_INTEGER(0);
986 case EIGRPNEXTHOPADDRESS
: /* 13 */
987 /* Next hop IP address for the route */
989 return SNMP_INTEGER(1);
991 return SNMP_INTEGER(0);
992 case EIGRPNEXTHOPINTERFACE
: /* 14 */
993 /* The interface through which the next hop IP address is
996 return SNMP_INTEGER(1);
998 return SNMP_INTEGER(0);
999 case EIGRPDISTANCE
: /* 15 */
1000 /* The computed distance to the destination network entry from
1003 return SNMP_INTEGER(1);
1005 return SNMP_INTEGER(0);
1006 case EIGRPREPORTDISTANCE
: /* 16 */
1007 /* The computed distance to the destination network in the
1009 reported to this router by the originator of this route */
1011 return SNMP_INTEGER(1);
1013 return SNMP_INTEGER(0);
1020 static uint8_t *eigrpPeerEntry(struct variable
*v
, oid
*name
, size_t *length
,
1021 int exact
, size_t *var_len
,
1022 WriteMethod
**write_method
)
1024 struct eigrp
*eigrp
;
1025 struct eigrp_interface
*ei
;
1026 struct eigrp_neighbor
*nbr
;
1027 struct in_addr nbr_addr
;
1028 unsigned int ifindex
;
1030 eigrp
= eigrp_lookup();
1032 /* Check whether the instance identifier is valid */
1033 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1037 memset(&nbr_addr
, 0, sizeof(nbr_addr
));
1040 nbr
= eigrpNbrLookup(v
, name
, length
, &nbr_addr
, &ifindex
, exact
);
1047 /* Return the current value of the variable */
1049 case EIGRPHANDLE
: /* 1 */
1050 /* The unique internal identifier for the peer in the AS */
1052 return SNMP_INTEGER(1);
1054 return SNMP_INTEGER(0);
1055 case EIGRPPEERADDRTYPE
: /* 2 */
1056 /* The format of the remote source IP address used by the peer
1059 return SNMP_INTEGER(1);
1061 return SNMP_INTEGER(0);
1062 case EIGRPPEERADDR
: /* 3 */
1063 /* The source IP address used by the peer */
1065 return SNMP_INTEGER(1);
1067 return SNMP_INTEGER(0);
1068 case EIGRPPEERIFINDEX
: /* 4 */
1069 /* The ifIndex of the interface on this router */
1071 return SNMP_INTEGER(1);
1073 return SNMP_INTEGER(0);
1074 case EIGRPHOLDTIME
: /* 5 */
1075 /* How much time must pass without receiving a hello packet from
1077 EIGRP peer before this router declares the peer down */
1079 return SNMP_INTEGER(1);
1081 return SNMP_INTEGER(0);
1082 case EIGRPUPTIME
: /* 6 */
1083 /* The elapsed time since the EIGRP adjacency was first
1086 return SNMP_INTEGER(1);
1088 return SNMP_INTEGER(0);
1089 case EIGRPSRTT
: /* 7 */
1090 /* The computed smooth round trip time for packets to and from
1093 return SNMP_INTEGER(1);
1095 return SNMP_INTEGER(0);
1096 case EIGRPRTO
: /* 8 */
1097 /* The computed retransmission timeout for the peer */
1099 return SNMP_INTEGER(1);
1101 return SNMP_INTEGER(0);
1102 case EIGRPPKTSENQUEUED
: /* 9 */
1103 /* The number of any EIGRP packets currently enqueued */
1105 return SNMP_INTEGER(1);
1107 return SNMP_INTEGER(0);
1108 case EIGRPLASTSEQ
: /* 10 */
1109 /* sequence number of the last EIGRP packet sent to this peer */
1111 return SNMP_INTEGER(1);
1113 return SNMP_INTEGER(0);
1114 case EIGRPVERSION
: /* 11 */
1115 /* The EIGRP version information reported by the remote peer */
1117 return SNMP_INTEGER(1);
1119 return SNMP_INTEGER(0);
1120 case EIGRPRETRANS
: /* 12 */
1121 /* The cumulative number of retransmissions to this peer */
1123 return SNMP_INTEGER(1);
1125 return SNMP_INTEGER(0);
1126 case EIGRPRETRIES
: /* 13 */
1127 /* The number of times the current unacknowledged packet has
1130 return SNMP_INTEGER(1);
1132 return SNMP_INTEGER(0);
1139 static uint8_t *eigrpInterfaceEntry(struct variable
*v
, oid
*name
,
1140 size_t *length
, int exact
, size_t *var_len
,
1141 WriteMethod
**write_method
)
1143 struct eigrp
*eigrp
;
1144 struct listnode
*node
, *nnode
;
1145 struct keychain
*keychain
;
1146 struct list
*keylist
;
1148 eigrp
= eigrp_lookup();
1150 /* Check whether the instance identifier is valid */
1151 if (smux_header_generic(v
, name
, length
, exact
, var_len
, write_method
)
1155 /* Return the current value of the variable */
1157 case EIGRPPEERCOUNT
: /* 3 */
1158 /* The number of EIGRP adjacencies currently formed with
1159 peers reached through this interface */
1161 return SNMP_INTEGER(eigrp_neighbor_count(eigrp
));
1163 return SNMP_INTEGER(0);
1164 case EIGRPXMITRELIABLEQ
: /* 4 */
1165 /* The number of EIGRP packets currently waiting in the reliable
1166 transport transmission queue */
1168 return SNMP_INTEGER(1);
1170 return SNMP_INTEGER(0);
1171 case EIGRPXMITUNRELIABLEQ
: /* 5 */
1172 /* The number of EIGRP packets currently waiting in the
1174 transport transmission queue */
1176 return SNMP_INTEGER(1);
1178 return SNMP_INTEGER(0);
1179 case EIGRPMEANSRTT
: /* 6 */
1180 /* The average of all the computed smooth round trip time values
1181 for a packet to and from all peers established on this
1184 return SNMP_INTEGER(1);
1186 return SNMP_INTEGER(0);
1187 case EIGRPPACINGRELIABLE
: /* 7 */
1188 /* The configured time interval between EIGRP packet
1191 return SNMP_INTEGER(1);
1193 return SNMP_INTEGER(0);
1194 case EIGRPPACINGUNRELIABLE
: /* 8 */
1195 /* The configured time interval between EIGRP packet
1197 on the interface when the unreliable transport method is used
1200 return SNMP_INTEGER(1);
1202 return SNMP_INTEGER(0);
1203 case EIGRPMFLOWTIMER
: /* 9 */
1204 /* The configured multicast flow control timer value */
1206 return SNMP_INTEGER(1);
1208 return SNMP_INTEGER(0);
1209 case EIGRPPENDINGROUTES
: /* 10 */
1210 /* The number of queued EIGRP routing updates awaiting
1213 return SNMP_INTEGER(1);
1215 return SNMP_INTEGER(0);
1216 case EIGRPHELLOINTERVAL
: /* 11 */
1217 /* The configured time interval between Hello packet
1220 return SNMP_INTEGER(1);
1222 return SNMP_INTEGER(0);
1223 case EIGRPXMITNEXTSERIAL
: /* 12 */
1224 /* The serial number of the next EIGRP packet that is to be
1228 return SNMP_INTEGER(1);
1230 return SNMP_INTEGER(0);
1231 case EIGRPUMCASTS
: /* 13 */
1232 /* The total number of unreliable EIGRP multicast packets sent
1233 on this interface */
1235 return SNMP_INTEGER(1);
1237 return SNMP_INTEGER(0);
1238 case EIGRPRMCASTS
: /* 14 */
1239 /* The total number of reliable EIGRP multicast packets sent
1240 on this interface */
1242 return SNMP_INTEGER(1);
1244 return SNMP_INTEGER(0);
1245 case EIGRPUUCASTS
: /* 15 */
1246 /* The total number of unreliable EIGRP unicast packets sent
1247 on this interface */
1249 return SNMP_INTEGER(1);
1251 return SNMP_INTEGER(0);
1252 case EIGRPRUCASTS
: /* 16 */
1253 /* The total number of reliable EIGRP unicast packets sent
1254 on this interface */
1256 return SNMP_INTEGER(1);
1258 return SNMP_INTEGER(0);
1259 case EIGRPMCASTEXCEPTS
: /* 17 */
1260 /* The total number of EIGRP multicast exception transmissions
1263 return SNMP_INTEGER(1);
1265 return SNMP_INTEGER(0);
1266 case EIGRPCRPKTS
: /* 18 */
1267 /* The total number EIGRP Conditional-Receive packets sent on
1270 return SNMP_INTEGER(1);
1272 return SNMP_INTEGER(0);
1273 case EIGRPACKSSUPPRESSED
: /* 19 */
1274 /* The total number of individual EIGRP acknowledgement packets
1276 suppressed and combined in an already enqueued outbound
1277 reliable packet on this interface */
1279 return SNMP_INTEGER(1);
1281 return SNMP_INTEGER(0);
1282 case EIGRPRETRANSSENT
: /* 20 */
1283 /* The total number EIGRP packet retransmissions sent on the
1286 return SNMP_INTEGER(1);
1288 return SNMP_INTEGER(0);
1289 case EIGRPOOSRCVD
: /* 21 */
1290 /* The total number of out-of-sequence EIGRP packets received */
1292 return SNMP_INTEGER(1);
1294 return SNMP_INTEGER(0);
1295 case EIGRPAUTHMODE
: /* 22 */
1296 /* The EIGRP authentication mode of the interface */
1298 return SNMP_INTEGER(1);
1300 return SNMP_INTEGER(0);
1301 case EIGRPAUTHKEYCHAIN
: /* 23 */
1302 /* The name of the authentication key-chain configured
1303 on this interface. */
1304 keylist
= keychain_list_get();
1305 for (ALL_LIST_ELEMENTS(keylist
, node
, nnode
, keychain
)) {
1306 return (uint8_t *)keychain
->name
;
1308 if (eigrp
&& keychain
) {
1309 *var_len
= str_len(keychain
->name
);
1310 return (uint8_t *)keychain
->name
;
1312 return (uint8_t *)"TEST";
1320 /* Register EIGRP-MIB. */
1321 void eigrp_snmp_init()
1323 eigrp_snmp_iflist
= list_new();
1324 smux_init(eigrp_om
->master
);
1325 REGISTER_MIB("ciscoEigrpMIB", eigrp_variables
, variable
, eigrp_oid
);