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