2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 IP Infusion Inc.
5 * Written by Kunihiro Ishiguro <kunihiro@zebra.org>
7 * This file is part of GNU Zebra.
9 * GNU Zebra is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
14 * GNU Zebra is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GNU Zebra; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 #include <net-snmp/net-snmp-config.h>
29 #include <net-snmp/net-snmp-includes.h>
39 #include "ospfd/ospfd.h"
40 #include "ospfd/ospf_interface.h"
41 #include "ospfd/ospf_asbr.h"
42 #include "ospfd/ospf_lsa.h"
43 #include "ospfd/ospf_lsdb.h"
44 #include "ospfd/ospf_abr.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_nsm.h"
47 #include "ospfd/ospf_flood.h"
48 #include "ospfd/ospf_ism.h"
49 #include "ospfd/ospf_dump.h"
50 #include "ospfd/ospf_snmp.h"
53 #define OSPF2MIB 1,3,6,1,2,1,14
55 /* OSPF MIB General Group values. */
56 #define OSPFROUTERID 1
57 #define OSPFADMINSTAT 2
58 #define OSPFVERSIONNUMBER 3
59 #define OSPFAREABDRRTRSTATUS 4
60 #define OSPFASBDRRTRSTATUS 5
61 #define OSPFEXTERNLSACOUNT 6
62 #define OSPFEXTERNLSACKSUMSUM 7
63 #define OSPFTOSSUPPORT 8
64 #define OSPFORIGINATENEWLSAS 9
65 #define OSPFRXNEWLSAS 10
66 #define OSPFEXTLSDBLIMIT 11
67 #define OSPFMULTICASTEXTENSIONS 12
68 #define OSPFEXITOVERFLOWINTERVAL 13
69 #define OSPFDEMANDEXTENSIONS 14
71 /* OSPF MIB ospfAreaTable. */
73 #define OSPFAUTHTYPE 2
74 #define OSPFIMPORTASEXTERN 3
76 #define OSPFAREABDRRTRCOUNT 5
77 #define OSPFASBDRRTRCOUNT 6
78 #define OSPFAREALSACOUNT 7
79 #define OSPFAREALSACKSUMSUM 8
80 #define OSPFAREASUMMARY 9
81 #define OSPFAREASTATUS 10
83 /* OSPF MIB ospfStubAreaTable. */
84 #define OSPFSTUBAREAID 1
86 #define OSPFSTUBMETRIC 3
87 #define OSPFSTUBSTATUS 4
88 #define OSPFSTUBMETRICTYPE 5
90 /* OSPF MIB ospfLsdbTable. */
91 #define OSPFLSDBAREAID 1
92 #define OSPFLSDBTYPE 2
93 #define OSPFLSDBLSID 3
94 #define OSPFLSDBROUTERID 4
95 #define OSPFLSDBSEQUENCE 5
97 #define OSPFLSDBCHECKSUM 7
98 #define OSPFLSDBADVERTISEMENT 8
100 /* OSPF MIB ospfAreaRangeTable. */
101 #define OSPFAREARANGEAREAID 1
102 #define OSPFAREARANGENET 2
103 #define OSPFAREARANGEMASK 3
104 #define OSPFAREARANGESTATUS 4
105 #define OSPFAREARANGEEFFECT 5
107 /* OSPF MIB ospfHostTable. */
108 #define OSPFHOSTIPADDRESS 1
109 #define OSPFHOSTTOS 2
110 #define OSPFHOSTMETRIC 3
111 #define OSPFHOSTSTATUS 4
112 #define OSPFHOSTAREAID 5
114 /* OSPF MIB ospfIfTable. */
115 #define OSPFIFIPADDRESS 1
116 #define OSPFADDRESSLESSIF 2
117 #define OSPFIFAREAID 3
119 #define OSPFIFADMINSTAT 5
120 #define OSPFIFRTRPRIORITY 6
121 #define OSPFIFTRANSITDELAY 7
122 #define OSPFIFRETRANSINTERVAL 8
123 #define OSPFIFHELLOINTERVAL 9
124 #define OSPFIFRTRDEADINTERVAL 10
125 #define OSPFIFPOLLINTERVAL 11
126 #define OSPFIFSTATE 12
127 #define OSPFIFDESIGNATEDROUTER 13
128 #define OSPFIFBACKUPDESIGNATEDROUTER 14
129 #define OSPFIFEVENTS 15
130 #define OSPFIFAUTHKEY 16
131 #define OSPFIFSTATUS 17
132 #define OSPFIFMULTICASTFORWARDING 18
133 #define OSPFIFDEMAND 19
134 #define OSPFIFAUTHTYPE 20
136 /* OSPF MIB ospfIfMetricTable. */
137 #define OSPFIFMETRICIPADDRESS 1
138 #define OSPFIFMETRICADDRESSLESSIF 2
139 #define OSPFIFMETRICTOS 3
140 #define OSPFIFMETRICVALUE 4
141 #define OSPFIFMETRICSTATUS 5
143 /* OSPF MIB ospfVirtIfTable. */
144 #define OSPFVIRTIFAREAID 1
145 #define OSPFVIRTIFNEIGHBOR 2
146 #define OSPFVIRTIFTRANSITDELAY 3
147 #define OSPFVIRTIFRETRANSINTERVAL 4
148 #define OSPFVIRTIFHELLOINTERVAL 5
149 #define OSPFVIRTIFRTRDEADINTERVAL 6
150 #define OSPFVIRTIFSTATE 7
151 #define OSPFVIRTIFEVENTS 8
152 #define OSPFVIRTIFAUTHKEY 9
153 #define OSPFVIRTIFSTATUS 10
154 #define OSPFVIRTIFAUTHTYPE 11
156 /* OSPF MIB ospfNbrTable. */
157 #define OSPFNBRIPADDR 1
158 #define OSPFNBRADDRESSLESSINDEX 2
159 #define OSPFNBRRTRID 3
160 #define OSPFNBROPTIONS 4
161 #define OSPFNBRPRIORITY 5
162 #define OSPFNBRSTATE 6
163 #define OSPFNBREVENTS 7
164 #define OSPFNBRLSRETRANSQLEN 8
165 #define OSPFNBMANBRSTATUS 9
166 #define OSPFNBMANBRPERMANENCE 10
167 #define OSPFNBRHELLOSUPPRESSED 11
169 /* OSPF MIB ospfVirtNbrTable. */
170 #define OSPFVIRTNBRAREA 1
171 #define OSPFVIRTNBRRTRID 2
172 #define OSPFVIRTNBRIPADDR 3
173 #define OSPFVIRTNBROPTIONS 4
174 #define OSPFVIRTNBRSTATE 5
175 #define OSPFVIRTNBREVENTS 6
176 #define OSPFVIRTNBRLSRETRANSQLEN 7
177 #define OSPFVIRTNBRHELLOSUPPRESSED 8
179 /* OSPF MIB ospfExtLsdbTable. */
180 #define OSPFEXTLSDBTYPE 1
181 #define OSPFEXTLSDBLSID 2
182 #define OSPFEXTLSDBROUTERID 3
183 #define OSPFEXTLSDBSEQUENCE 4
184 #define OSPFEXTLSDBAGE 5
185 #define OSPFEXTLSDBCHECKSUM 6
186 #define OSPFEXTLSDBADVERTISEMENT 7
188 /* OSPF MIB ospfAreaAggregateTable. */
189 #define OSPFAREAAGGREGATEAREAID 1
190 #define OSPFAREAAGGREGATELSDBTYPE 2
191 #define OSPFAREAAGGREGATENET 3
192 #define OSPFAREAAGGREGATEMASK 4
193 #define OSPFAREAAGGREGATESTATUS 5
194 #define OSPFAREAAGGREGATEEFFECT 6
196 /* SYNTAX Status from OSPF-MIB. */
197 #define OSPF_STATUS_ENABLED 1
198 #define OSPF_STATUS_DISABLED 2
200 /* SNMP value hack. */
201 #define COUNTER ASN_COUNTER
202 #define INTEGER ASN_INTEGER
203 #define GAUGE ASN_GAUGE
204 #define TIMETICKS ASN_TIMETICKS
205 #define IPADDRESS ASN_IPADDRESS
206 #define STRING ASN_OCTET_STR
208 /* Declare static local variables for convenience. */
211 /* OSPF-MIB instances. */
212 oid ospf_oid [] = { OSPF2MIB };
213 oid ospf_trap_oid [] = { OSPF2MIB, 16, 2 }; /* Not reverse mappable! */
215 /* IP address 0.0.0.0. */
216 static struct in_addr ospf_empty_addr = { .s_addr = 0 };
218 /* Hook functions. */
219 static u_char *ospfGeneralGroup (struct variable *, oid *, size_t *,
220 int, size_t *, WriteMethod **);
221 static u_char *ospfAreaEntry (struct variable *, oid *, size_t *, int,
222 size_t *, WriteMethod **);
223 static u_char *ospfStubAreaEntry (struct variable *, oid *, size_t *,
224 int, size_t *, WriteMethod **);
225 static u_char *ospfLsdbEntry (struct variable *, oid *, size_t *, int,
226 size_t *, WriteMethod **);
227 static u_char *ospfAreaRangeEntry (struct variable *, oid *, size_t *, int,
228 size_t *, WriteMethod **);
229 static u_char *ospfHostEntry (struct variable *, oid *, size_t *, int,
230 size_t *, WriteMethod **);
231 static u_char *ospfIfEntry (struct variable *, oid *, size_t *, int,
232 size_t *, WriteMethod **);
233 static u_char *ospfIfMetricEntry (struct variable *, oid *, size_t *, int,
234 size_t *, WriteMethod **);
235 static u_char *ospfVirtIfEntry (struct variable *, oid *, size_t *, int,
236 size_t *, WriteMethod **);
237 static u_char *ospfNbrEntry (struct variable *, oid *, size_t *, int,
238 size_t *, WriteMethod **);
239 static u_char *ospfVirtNbrEntry (struct variable *, oid *, size_t *, int,
240 size_t *, WriteMethod **);
241 static u_char *ospfExtLsdbEntry (struct variable *, oid *, size_t *, int,
242 size_t *, WriteMethod **);
243 static u_char *ospfAreaAggregateEntry (struct variable *, oid *, size_t *,
244 int, size_t *, WriteMethod **);
246 struct variable ospf_variables[] =
248 /* OSPF general variables */
249 {OSPFROUTERID, IPADDRESS, RWRITE, ospfGeneralGroup,
251 {OSPFADMINSTAT, INTEGER, RWRITE, ospfGeneralGroup,
253 {OSPFVERSIONNUMBER, INTEGER, RONLY, ospfGeneralGroup,
255 {OSPFAREABDRRTRSTATUS, INTEGER, RONLY, ospfGeneralGroup,
257 {OSPFASBDRRTRSTATUS, INTEGER, RWRITE, ospfGeneralGroup,
259 {OSPFEXTERNLSACOUNT, GAUGE, RONLY, ospfGeneralGroup,
261 {OSPFEXTERNLSACKSUMSUM, INTEGER, RONLY, ospfGeneralGroup,
263 {OSPFTOSSUPPORT, INTEGER, RWRITE, ospfGeneralGroup,
265 {OSPFORIGINATENEWLSAS, COUNTER, RONLY, ospfGeneralGroup,
267 {OSPFRXNEWLSAS, COUNTER, RONLY, ospfGeneralGroup,
269 {OSPFEXTLSDBLIMIT, INTEGER, RWRITE, ospfGeneralGroup,
271 {OSPFMULTICASTEXTENSIONS, INTEGER, RWRITE, ospfGeneralGroup,
273 {OSPFEXITOVERFLOWINTERVAL, INTEGER, RWRITE, ospfGeneralGroup,
275 {OSPFDEMANDEXTENSIONS, INTEGER, RWRITE, ospfGeneralGroup,
278 /* OSPF area data structure. */
279 {OSPFAREAID, IPADDRESS, RONLY, ospfAreaEntry,
281 {OSPFAUTHTYPE, INTEGER, RWRITE, ospfAreaEntry,
283 {OSPFIMPORTASEXTERN, INTEGER, RWRITE, ospfAreaEntry,
285 {OSPFSPFRUNS, COUNTER, RONLY, ospfAreaEntry,
287 {OSPFAREABDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry,
289 {OSPFASBDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry,
291 {OSPFAREALSACOUNT, GAUGE, RONLY, ospfAreaEntry,
293 {OSPFAREALSACKSUMSUM, INTEGER, RONLY, ospfAreaEntry,
295 {OSPFAREASUMMARY, INTEGER, RWRITE, ospfAreaEntry,
297 {OSPFAREASTATUS, INTEGER, RWRITE, ospfAreaEntry,
300 /* OSPF stub area information. */
301 {OSPFSTUBAREAID, IPADDRESS, RONLY, ospfStubAreaEntry,
303 {OSPFSTUBTOS, INTEGER, RONLY, ospfStubAreaEntry,
305 {OSPFSTUBMETRIC, INTEGER, RWRITE, ospfStubAreaEntry,
307 {OSPFSTUBSTATUS, INTEGER, RWRITE, ospfStubAreaEntry,
309 {OSPFSTUBMETRICTYPE, INTEGER, RWRITE, ospfStubAreaEntry,
312 /* OSPF link state database. */
313 {OSPFLSDBAREAID, IPADDRESS, RONLY, ospfLsdbEntry,
315 {OSPFLSDBTYPE, INTEGER, RONLY, ospfLsdbEntry,
317 {OSPFLSDBLSID, IPADDRESS, RONLY, ospfLsdbEntry,
319 {OSPFLSDBROUTERID, IPADDRESS, RONLY, ospfLsdbEntry,
321 {OSPFLSDBSEQUENCE, INTEGER, RONLY, ospfLsdbEntry,
323 {OSPFLSDBAGE, INTEGER, RONLY, ospfLsdbEntry,
325 {OSPFLSDBCHECKSUM, INTEGER, RONLY, ospfLsdbEntry,
327 {OSPFLSDBADVERTISEMENT, STRING, RONLY, ospfLsdbEntry,
330 /* Area range table. */
331 {OSPFAREARANGEAREAID, IPADDRESS, RONLY, ospfAreaRangeEntry,
333 {OSPFAREARANGENET, IPADDRESS, RONLY, ospfAreaRangeEntry,
335 {OSPFAREARANGEMASK, IPADDRESS, RWRITE, ospfAreaRangeEntry,
337 {OSPFAREARANGESTATUS, INTEGER, RWRITE, ospfAreaRangeEntry,
339 {OSPFAREARANGEEFFECT, INTEGER, RWRITE, ospfAreaRangeEntry,
342 /* OSPF host table. */
343 {OSPFHOSTIPADDRESS, IPADDRESS, RONLY, ospfHostEntry,
345 {OSPFHOSTTOS, INTEGER, RONLY, ospfHostEntry,
347 {OSPFHOSTMETRIC, INTEGER, RWRITE, ospfHostEntry,
349 {OSPFHOSTSTATUS, INTEGER, RWRITE, ospfHostEntry,
351 {OSPFHOSTAREAID, IPADDRESS, RONLY, ospfHostEntry,
354 /* OSPF interface table. */
355 {OSPFIFIPADDRESS, IPADDRESS, RONLY, ospfIfEntry,
357 {OSPFADDRESSLESSIF, INTEGER, RONLY, ospfIfEntry,
359 {OSPFIFAREAID, IPADDRESS, RWRITE, ospfIfEntry,
361 {OSPFIFTYPE, INTEGER, RWRITE, ospfIfEntry,
363 {OSPFIFADMINSTAT, INTEGER, RWRITE, ospfIfEntry,
365 {OSPFIFRTRPRIORITY, INTEGER, RWRITE, ospfIfEntry,
367 {OSPFIFTRANSITDELAY, INTEGER, RWRITE, ospfIfEntry,
369 {OSPFIFRETRANSINTERVAL, INTEGER, RWRITE, ospfIfEntry,
371 {OSPFIFHELLOINTERVAL, INTEGER, RWRITE, ospfIfEntry,
373 {OSPFIFRTRDEADINTERVAL, INTEGER, RWRITE, ospfIfEntry,
375 {OSPFIFPOLLINTERVAL, INTEGER, RWRITE, ospfIfEntry,
377 {OSPFIFSTATE, INTEGER, RONLY, ospfIfEntry,
379 {OSPFIFDESIGNATEDROUTER, IPADDRESS, RONLY, ospfIfEntry,
381 {OSPFIFBACKUPDESIGNATEDROUTER, IPADDRESS, RONLY, ospfIfEntry,
383 {OSPFIFEVENTS, COUNTER, RONLY, ospfIfEntry,
385 {OSPFIFAUTHKEY, STRING, RWRITE, ospfIfEntry,
387 {OSPFIFSTATUS, INTEGER, RWRITE, ospfIfEntry,
389 {OSPFIFMULTICASTFORWARDING, INTEGER, RWRITE, ospfIfEntry,
391 {OSPFIFDEMAND, INTEGER, RWRITE, ospfIfEntry,
393 {OSPFIFAUTHTYPE, INTEGER, RWRITE, ospfIfEntry,
396 /* OSPF interface metric table. */
397 {OSPFIFMETRICIPADDRESS, IPADDRESS, RONLY, ospfIfMetricEntry,
399 {OSPFIFMETRICADDRESSLESSIF, INTEGER, RONLY, ospfIfMetricEntry,
401 {OSPFIFMETRICTOS, INTEGER, RONLY, ospfIfMetricEntry,
403 {OSPFIFMETRICVALUE, INTEGER, RWRITE, ospfIfMetricEntry,
405 {OSPFIFMETRICSTATUS, INTEGER, RWRITE, ospfIfMetricEntry,
408 /* OSPF virtual interface table. */
409 {OSPFVIRTIFAREAID, IPADDRESS, RONLY, ospfVirtIfEntry,
411 {OSPFVIRTIFNEIGHBOR, IPADDRESS, RONLY, ospfVirtIfEntry,
413 {OSPFVIRTIFTRANSITDELAY, INTEGER, RWRITE, ospfVirtIfEntry,
415 {OSPFVIRTIFRETRANSINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry,
417 {OSPFVIRTIFHELLOINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry,
419 {OSPFVIRTIFRTRDEADINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry,
421 {OSPFVIRTIFSTATE, INTEGER, RONLY, ospfVirtIfEntry,
423 {OSPFVIRTIFEVENTS, COUNTER, RONLY, ospfVirtIfEntry,
425 {OSPFVIRTIFAUTHKEY, STRING, RWRITE, ospfVirtIfEntry,
427 {OSPFVIRTIFSTATUS, INTEGER, RWRITE, ospfVirtIfEntry,
429 {OSPFVIRTIFAUTHTYPE, INTEGER, RWRITE, ospfVirtIfEntry,
432 /* OSPF neighbor table. */
433 {OSPFNBRIPADDR, IPADDRESS, RONLY, ospfNbrEntry,
435 {OSPFNBRADDRESSLESSINDEX, INTEGER, RONLY, ospfNbrEntry,
437 {OSPFNBRRTRID, IPADDRESS, RONLY, ospfNbrEntry,
439 {OSPFNBROPTIONS, INTEGER, RONLY, ospfNbrEntry,
441 {OSPFNBRPRIORITY, INTEGER, RWRITE, ospfNbrEntry,
443 {OSPFNBRSTATE, INTEGER, RONLY, ospfNbrEntry,
445 {OSPFNBREVENTS, COUNTER, RONLY, ospfNbrEntry,
447 {OSPFNBRLSRETRANSQLEN, GAUGE, RONLY, ospfNbrEntry,
449 {OSPFNBMANBRSTATUS, INTEGER, RWRITE, ospfNbrEntry,
451 {OSPFNBMANBRPERMANENCE, INTEGER, RONLY, ospfNbrEntry,
453 {OSPFNBRHELLOSUPPRESSED, INTEGER, RONLY, ospfNbrEntry,
456 /* OSPF virtual neighbor table. */
457 {OSPFVIRTNBRAREA, IPADDRESS, RONLY, ospfVirtNbrEntry,
459 {OSPFVIRTNBRRTRID, IPADDRESS, RONLY, ospfVirtNbrEntry,
461 {OSPFVIRTNBRIPADDR, IPADDRESS, RONLY, ospfVirtNbrEntry,
463 {OSPFVIRTNBROPTIONS, INTEGER, RONLY, ospfVirtNbrEntry,
465 {OSPFVIRTNBRSTATE, INTEGER, RONLY, ospfVirtNbrEntry,
467 {OSPFVIRTNBREVENTS, COUNTER, RONLY, ospfVirtNbrEntry,
469 {OSPFVIRTNBRLSRETRANSQLEN, INTEGER, RONLY, ospfVirtNbrEntry,
471 {OSPFVIRTNBRHELLOSUPPRESSED, INTEGER, RONLY, ospfVirtNbrEntry,
474 /* OSPF link state database, external. */
475 {OSPFEXTLSDBTYPE, INTEGER, RONLY, ospfExtLsdbEntry,
477 {OSPFEXTLSDBLSID, IPADDRESS, RONLY, ospfExtLsdbEntry,
479 {OSPFEXTLSDBROUTERID, IPADDRESS, RONLY, ospfExtLsdbEntry,
481 {OSPFEXTLSDBSEQUENCE, INTEGER, RONLY, ospfExtLsdbEntry,
483 {OSPFEXTLSDBAGE, INTEGER, RONLY, ospfExtLsdbEntry,
485 {OSPFEXTLSDBCHECKSUM, INTEGER, RONLY, ospfExtLsdbEntry,
487 {OSPFEXTLSDBADVERTISEMENT, STRING, RONLY, ospfExtLsdbEntry,
490 /* OSPF area aggregate table. */
491 {OSPFAREAAGGREGATEAREAID, IPADDRESS, RONLY, ospfAreaAggregateEntry,
493 {OSPFAREAAGGREGATELSDBTYPE, INTEGER, RONLY, ospfAreaAggregateEntry,
495 {OSPFAREAAGGREGATENET, IPADDRESS, RONLY, ospfAreaAggregateEntry,
497 {OSPFAREAAGGREGATEMASK, IPADDRESS, RONLY, ospfAreaAggregateEntry,
499 {OSPFAREAAGGREGATESTATUS, INTEGER, RWRITE, ospfAreaAggregateEntry,
501 {OSPFAREAAGGREGATEEFFECT, INTEGER, RWRITE, ospfAreaAggregateEntry,
505 /* The administrative status of OSPF. When OSPF is enbled on at least
506 one interface return 1. */
508 ospf_admin_stat (struct ospf *ospf)
510 struct listnode *node;
511 struct ospf_interface *oi;
516 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
517 if (oi && oi->address)
524 ospfGeneralGroup (struct variable *v, oid *name, size_t *length,
525 int exact, size_t *var_len, WriteMethod **write_method)
529 ospf = ospf_lookup ();
531 /* Check whether the instance identifier is valid */
532 if (smux_header_generic (v, name, length, exact, var_len, write_method)
536 /* Return the current value of the variable */
539 case OSPFROUTERID: /* 1 */
540 /* Router-ID of this OSPF instance. */
542 return SNMP_IPADDRESS (ospf->router_id);
544 return SNMP_IPADDRESS (ospf_empty_addr);
546 case OSPFADMINSTAT: /* 2 */
547 /* The administrative status of OSPF in the router. */
548 if (ospf_admin_stat (ospf))
549 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
551 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
553 case OSPFVERSIONNUMBER: /* 3 */
554 /* OSPF version 2. */
555 return SNMP_INTEGER (OSPF_VERSION);
557 case OSPFAREABDRRTRSTATUS: /* 4 */
558 /* Area Border router status. */
559 if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
560 return SNMP_INTEGER (SNMP_TRUE);
562 return SNMP_INTEGER (SNMP_FALSE);
564 case OSPFASBDRRTRSTATUS: /* 5 */
565 /* AS Border router status. */
566 if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
567 return SNMP_INTEGER (SNMP_TRUE);
569 return SNMP_INTEGER (SNMP_FALSE);
571 case OSPFEXTERNLSACOUNT: /* 6 */
572 /* External LSA counts. */
574 return SNMP_INTEGER (ospf_lsdb_count_all (ospf->lsdb));
576 return SNMP_INTEGER (0);
578 case OSPFEXTERNLSACKSUMSUM: /* 7 */
579 /* External LSA checksum. */
580 return SNMP_INTEGER (0);
582 case OSPFTOSSUPPORT: /* 8 */
583 /* TOS is not supported. */
584 return SNMP_INTEGER (SNMP_FALSE);
586 case OSPFORIGINATENEWLSAS: /* 9 */
587 /* The number of new link-state advertisements. */
589 return SNMP_INTEGER (ospf->lsa_originate_count);
591 return SNMP_INTEGER (0);
593 case OSPFRXNEWLSAS: /* 10 */
594 /* The number of link-state advertisements received determined
595 to be new instantiations. */
597 return SNMP_INTEGER (ospf->rx_lsa_count);
599 return SNMP_INTEGER (0);
601 case OSPFEXTLSDBLIMIT: /* 11 */
602 /* There is no limit for the number of non-default
604 return SNMP_INTEGER (-1);
606 case OSPFMULTICASTEXTENSIONS: /* 12 */
607 /* Multicast Extensions to OSPF is not supported. */
608 return SNMP_INTEGER (0);
610 case OSPFEXITOVERFLOWINTERVAL: /* 13 */
611 /* Overflow is not supported. */
612 return SNMP_INTEGER (0);
614 case OSPFDEMANDEXTENSIONS: /* 14 */
615 /* Demand routing is not supported. */
616 return SNMP_INTEGER (SNMP_FALSE);
624 static struct ospf_area *
625 ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first)
627 struct ospf_area *area;
628 struct listnode *node;
635 node = listhead (ospf->areas);
638 area = listgetdata (node);
639 *area_id = area->area_id;
644 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
646 if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr))
648 *area_id = area->area_id;
655 static struct ospf_area *
656 ospfAreaLookup (struct variable *v, oid name[], size_t *length,
657 struct in_addr *addr, int exact)
660 struct ospf_area *area;
663 ospf = ospf_lookup ();
669 /* Length is insufficient to lookup OSPF area. */
670 if (*length - v->namelen != sizeof (struct in_addr))
673 oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
675 area = ospf_area_lookup_by_area_id (ospf, *addr);
681 len = *length - v->namelen;
685 oid2in_addr (name + v->namelen, len, addr);
687 area = ospf_area_lookup_next (ospf, addr, len == 0 ? 1 : 0);
692 oid_copy_addr (name + v->namelen, addr, sizeof (struct in_addr));
693 *length = sizeof (struct in_addr) + v->namelen;
701 ospfAreaEntry (struct variable *v, oid *name, size_t *length, int exact,
702 size_t *var_len, WriteMethod **write_method)
704 struct ospf_area *area;
707 if (smux_header_table(v, name, length, exact, var_len, write_method)
711 memset (&addr, 0, sizeof (struct in_addr));
713 area = ospfAreaLookup (v, name, length, &addr, exact);
717 /* Return the current value of the variable */
720 case OSPFAREAID: /* 1 */
721 return SNMP_IPADDRESS (area->area_id);
723 case OSPFAUTHTYPE: /* 2 */
724 return SNMP_INTEGER (area->auth_type);
726 case OSPFIMPORTASEXTERN: /* 3 */
727 return SNMP_INTEGER (area->external_routing + 1);
729 case OSPFSPFRUNS: /* 4 */
730 return SNMP_INTEGER (area->spf_calculation);
732 case OSPFAREABDRRTRCOUNT: /* 5 */
733 return SNMP_INTEGER (area->abr_count);
735 case OSPFASBDRRTRCOUNT: /* 6 */
736 return SNMP_INTEGER (area->asbr_count);
738 case OSPFAREALSACOUNT: /* 7 */
739 return SNMP_INTEGER (area->lsdb->total);
741 case OSPFAREALSACKSUMSUM: /* 8 */
742 return SNMP_INTEGER (0);
744 case OSPFAREASUMMARY: /* 9 */
745 #define OSPF_noAreaSummary 1
746 #define OSPF_sendAreaSummary 2
747 if (area->no_summary)
748 return SNMP_INTEGER (OSPF_noAreaSummary);
750 return SNMP_INTEGER (OSPF_sendAreaSummary);
752 case OSPFAREASTATUS: /* 10 */
753 return SNMP_INTEGER (SNMP_VALID);
762 static struct ospf_area *
763 ospf_stub_area_lookup_next (struct in_addr *area_id, int first)
765 struct ospf_area *area;
766 struct listnode *node;
769 ospf = ospf_lookup ();
773 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
775 if (area->external_routing == OSPF_AREA_STUB)
779 *area_id = area->area_id;
782 else if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr))
784 *area_id = area->area_id;
792 static struct ospf_area *
793 ospfStubAreaLookup (struct variable *v, oid name[], size_t *length,
794 struct in_addr *addr, int exact)
797 struct ospf_area *area;
800 ospf = ospf_lookup ();
807 /* ospfStubAreaID + ospfStubTOS. */
808 if (*length != v->namelen + sizeof (struct in_addr) + 1)
811 /* Check ospfStubTOS is zero. */
812 if (name[*length - 1] != 0)
815 oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr);
817 area = ospf_area_lookup_by_area_id (ospf, *addr);
819 if (area->external_routing == OSPF_AREA_STUB)
826 len = *length - v->namelen;
830 oid2in_addr (name + v->namelen, len, addr);
832 area = ospf_stub_area_lookup_next (addr, len == 0 ? 1 : 0);
837 oid_copy_addr (name + v->namelen, addr, sizeof (struct in_addr));
839 name[v->namelen + sizeof (struct in_addr)] = 0;
840 *length = v->namelen + sizeof (struct in_addr) + 1;
848 ospfStubAreaEntry (struct variable *v, oid *name, size_t *length,
849 int exact, size_t *var_len, WriteMethod **write_method)
851 struct ospf_area *area;
854 if (smux_header_table(v, name, length, exact, var_len, write_method)
858 memset (&addr, 0, sizeof (struct in_addr));
860 area = ospfStubAreaLookup (v, name, length, &addr, exact);
864 /* Return the current value of the variable */
867 case OSPFSTUBAREAID: /* 1 */
868 /* OSPF stub area id. */
869 return SNMP_IPADDRESS (area->area_id);
871 case OSPFSTUBTOS: /* 2 */
872 /* TOS value is not supported. */
873 return SNMP_INTEGER (0);
875 case OSPFSTUBMETRIC: /* 3 */
876 /* Default cost to stub area. */
877 return SNMP_INTEGER (area->default_cost);
879 case OSPFSTUBSTATUS: /* 4 */
880 /* Status of the stub area. */
881 return SNMP_INTEGER (SNMP_VALID);
883 case OSPFSTUBMETRICTYPE: /* 5 */
884 /* OSPF Metric type. */
885 #define OSPF_ospfMetric 1
886 #define OSPF_comparableCost 2
887 #define OSPF_nonComparable 3
888 return SNMP_INTEGER (OSPF_ospfMetric);
897 static struct ospf_lsa *
898 lsdb_lookup_next (struct ospf_area *area, u_char *type, int type_next,
899 struct in_addr *ls_id, int ls_id_next,
900 struct in_addr *router_id, int router_id_next)
902 struct ospf_lsa *lsa;
910 /* Sanity check, if LSA type unknwon
911 merley skip any LSA */
912 if ((i < OSPF_MIN_LSA) || (i >= OSPF_MAX_LSA))
914 zlog_debug("Strange request with LSA type %d\n", i);
918 for (; i < OSPF_MAX_LSA; i++)
922 lsa = ospf_lsdb_lookup_by_id_next (area->lsdb, *type, *ls_id, *router_id,
932 static struct ospf_lsa *
933 ospfLsdbLookup (struct variable *v, oid *name, size_t *length,
934 struct in_addr *area_id, u_char *type,
935 struct in_addr *ls_id, struct in_addr *router_id, int exact)
938 struct ospf_area *area;
939 struct ospf_lsa *lsa;
947 ospf = ospf_lookup ();
949 #define OSPF_LSDB_ENTRY_OFFSET \
950 (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
954 /* Area ID + Type + LS ID + Router ID. */
955 if (*length - v->namelen != OSPF_LSDB_ENTRY_OFFSET)
958 /* Set OID offset for Area ID. */
959 offset = name + v->namelen;
961 /* Lookup area first. */
962 oid2in_addr (offset, IN_ADDR_SIZE, area_id);
963 area = ospf_area_lookup_by_area_id (ospf, *area_id);
966 offset += IN_ADDR_SIZE;
973 oid2in_addr (offset, IN_ADDR_SIZE, ls_id);
974 offset += IN_ADDR_SIZE;
977 oid2in_addr (offset, IN_ADDR_SIZE, router_id);
980 return ospf_lsdb_lookup_by_id (area->lsdb, *type, *ls_id, *router_id);
984 /* Get variable length. */
985 offset = name + v->namelen;
986 offsetlen = *length - v->namelen;
989 if (len > (int)IN_ADDR_SIZE)
992 oid2in_addr (offset, len, area_id);
994 /* First we search area. */
995 if (len == IN_ADDR_SIZE)
996 area = ospf_area_lookup_by_area_id (ospf, *area_id);
998 area = ospf_area_lookup_next (ospf, area_id, 1);
1005 /* Next we lookup type. */
1029 if (len > (int)IN_ADDR_SIZE)
1032 oid2in_addr (offset, len, ls_id);
1036 offset += IN_ADDR_SIZE;
1037 offsetlen -= IN_ADDR_SIZE;
1045 if (len > (int)IN_ADDR_SIZE)
1048 oid2in_addr (offset, len, router_id);
1051 lsa = lsdb_lookup_next (area, type, type_next, ls_id, ls_id_next,
1052 router_id, router_id_next);
1056 /* Fill in length. */
1057 *length = v->namelen + OSPF_LSDB_ENTRY_OFFSET;
1059 /* Fill in value. */
1060 offset = name + v->namelen;
1061 oid_copy_addr (offset, area_id, IN_ADDR_SIZE);
1062 offset += IN_ADDR_SIZE;
1063 *offset = lsa->data->type;
1065 oid_copy_addr (offset, &lsa->data->id, IN_ADDR_SIZE);
1066 offset += IN_ADDR_SIZE;
1067 oid_copy_addr (offset, &lsa->data->adv_router, IN_ADDR_SIZE);
1072 while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
1078 ospfLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
1079 size_t *var_len, WriteMethod **write_method)
1081 struct ospf_lsa *lsa;
1082 struct lsa_header *lsah;
1083 struct in_addr area_id;
1085 struct in_addr ls_id;
1086 struct in_addr router_id;
1089 if (smux_header_table(v, name, length, exact, var_len, write_method)
1093 /* INDEX { ospfLsdbAreaId, ospfLsdbType,
1094 ospfLsdbLsid, ospfLsdbRouterId } */
1096 memset (&area_id, 0, sizeof (struct in_addr));
1098 memset (&ls_id, 0, sizeof (struct in_addr));
1099 memset (&router_id, 0, sizeof (struct in_addr));
1101 /* Check OSPF instance. */
1102 ospf = ospf_lookup ();
1106 lsa = ospfLsdbLookup (v, name, length, &area_id, &type, &ls_id, &router_id,
1113 /* Return the current value of the variable */
1116 case OSPFLSDBAREAID: /* 1 */
1117 return SNMP_IPADDRESS (lsa->area->area_id);
1119 case OSPFLSDBTYPE: /* 2 */
1120 return SNMP_INTEGER (lsah->type);
1122 case OSPFLSDBLSID: /* 3 */
1123 return SNMP_IPADDRESS (lsah->id);
1125 case OSPFLSDBROUTERID: /* 4 */
1126 return SNMP_IPADDRESS (lsah->adv_router);
1128 case OSPFLSDBSEQUENCE: /* 5 */
1129 return SNMP_INTEGER (lsah->ls_seqnum);
1131 case OSPFLSDBAGE: /* 6 */
1132 return SNMP_INTEGER (lsah->ls_age);
1134 case OSPFLSDBCHECKSUM: /* 7 */
1135 return SNMP_INTEGER (lsah->checksum);
1137 case OSPFLSDBADVERTISEMENT: /* 8 */
1138 *var_len = ntohs (lsah->length);
1139 return (u_char *) lsah;
1148 static struct ospf_area_range *
1149 ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length,
1150 struct in_addr *area_id, struct in_addr *range_net,
1157 struct ospf_area *area;
1158 struct ospf_area_range *range;
1159 struct prefix_ipv4 p;
1161 p.prefixlen = IPV4_MAX_BITLEN;
1163 ospf = ospf_lookup ();
1167 /* Area ID + Range Network. */
1168 if (v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE != *length)
1171 /* Set OID offset for Area ID. */
1172 offset = name + v->namelen;
1174 /* Lookup area first. */
1175 oid2in_addr (offset, IN_ADDR_SIZE, area_id);
1177 area = ospf_area_lookup_by_area_id (ospf, *area_id);
1181 offset += IN_ADDR_SIZE;
1183 /* Lookup area range. */
1184 oid2in_addr (offset, IN_ADDR_SIZE, range_net);
1185 p.prefix = *range_net;
1187 return ospf_area_range_lookup (area, &p);
1191 /* Set OID offset for Area ID. */
1192 offset = name + v->namelen;
1193 offsetlen = *length - v->namelen;
1196 if (len > (int)IN_ADDR_SIZE)
1199 oid2in_addr (offset, len, area_id);
1201 /* First we search area. */
1202 if (len == IN_ADDR_SIZE)
1203 area = ospf_area_lookup_by_area_id (ospf,*area_id);
1205 area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0);
1212 offset += IN_ADDR_SIZE;
1213 offsetlen -= IN_ADDR_SIZE;
1218 if (len > (int)IN_ADDR_SIZE)
1221 oid2in_addr (offset, len, range_net);
1223 range = ospf_area_range_lookup_next (area, range_net,
1228 /* Fill in length. */
1229 *length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE;
1231 /* Fill in value. */
1232 offset = name + v->namelen;
1233 oid_copy_addr (offset, area_id, IN_ADDR_SIZE);
1234 offset += IN_ADDR_SIZE;
1235 oid_copy_addr (offset, range_net, IN_ADDR_SIZE);
1240 while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL);
1246 ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact,
1247 size_t *var_len, WriteMethod **write_method)
1249 struct ospf_area_range *range;
1250 struct in_addr area_id;
1251 struct in_addr range_net;
1252 struct in_addr mask;
1255 if (smux_header_table(v, name, length, exact, var_len, write_method)
1259 /* Check OSPF instance. */
1260 ospf = ospf_lookup ();
1264 memset (&area_id, 0, IN_ADDR_SIZE);
1265 memset (&range_net, 0, IN_ADDR_SIZE);
1267 range = ospfAreaRangeLookup (v, name, length, &area_id, &range_net, exact);
1271 /* Convert prefixlen to network mask format. */
1272 masklen2ip (range->subst_masklen, &mask);
1274 /* Return the current value of the variable */
1277 case OSPFAREARANGEAREAID: /* 1 */
1278 return SNMP_IPADDRESS (area_id);
1280 case OSPFAREARANGENET: /* 2 */
1281 return SNMP_IPADDRESS (range_net);
1283 case OSPFAREARANGEMASK: /* 3 */
1284 return SNMP_IPADDRESS (mask);
1286 case OSPFAREARANGESTATUS: /* 4 */
1287 return SNMP_INTEGER (SNMP_VALID);
1289 case OSPFAREARANGEEFFECT: /* 5 */
1290 #define OSPF_advertiseMatching 1
1291 #define OSPF_doNotAdvertiseMatching 2
1292 return SNMP_INTEGER (OSPF_advertiseMatching);
1301 static struct ospf_nbr_nbma *
1302 ospfHostLookup (struct variable *v, oid *name, size_t *length,
1303 struct in_addr *addr, int exact)
1306 struct ospf_nbr_nbma *nbr_nbma;
1309 ospf = ospf_lookup ();
1315 /* INDEX { ospfHostIpAddress, ospfHostTOS } */
1316 if (*length != v->namelen + IN_ADDR_SIZE + 1)
1319 /* Check ospfHostTOS. */
1320 if (name[*length - 1] != 0)
1323 oid2in_addr (name + v->namelen, IN_ADDR_SIZE, addr);
1325 nbr_nbma = ospf_nbr_nbma_lookup (ospf, *addr);
1331 len = *length - v->namelen;
1335 oid2in_addr (name + v->namelen, len, addr);
1337 nbr_nbma = ospf_nbr_nbma_lookup_next (ospf, addr, len == 0 ? 1 : 0);
1339 if (nbr_nbma == NULL)
1342 oid_copy_addr (name + v->namelen, addr, IN_ADDR_SIZE);
1345 name[v->namelen + IN_ADDR_SIZE] = 0;
1347 *length = v->namelen + IN_ADDR_SIZE + 1;
1355 ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact,
1356 size_t *var_len, WriteMethod **write_method)
1358 struct ospf_nbr_nbma *nbr_nbma;
1359 struct ospf_interface *oi;
1360 struct in_addr addr;
1363 if (smux_header_table(v, name, length, exact, var_len, write_method)
1367 /* Check OSPF instance. */
1368 ospf = ospf_lookup ();
1372 memset (&addr, 0, sizeof (struct in_addr));
1374 nbr_nbma = ospfHostLookup (v, name, length, &addr, exact);
1375 if (nbr_nbma == NULL)
1380 /* Return the current value of the variable */
1383 case OSPFHOSTIPADDRESS: /* 1 */
1384 return SNMP_IPADDRESS (nbr_nbma->addr);
1386 case OSPFHOSTTOS: /* 2 */
1387 return SNMP_INTEGER (0);
1389 case OSPFHOSTMETRIC: /* 3 */
1391 return SNMP_INTEGER (oi->output_cost);
1393 return SNMP_INTEGER (1);
1395 case OSPFHOSTSTATUS: /* 4 */
1396 return SNMP_INTEGER (SNMP_VALID);
1398 case OSPFHOSTAREAID: /* 5 */
1400 return SNMP_IPADDRESS (oi->area->area_id);
1402 return SNMP_IPADDRESS (ospf_empty_addr);
1411 struct list *ospf_snmp_iflist;
1415 struct in_addr addr;
1417 struct interface *ifp;
1420 static struct ospf_snmp_if *
1421 ospf_snmp_if_new (void)
1423 return XCALLOC (MTYPE_TMP, sizeof (struct ospf_snmp_if));
1427 ospf_snmp_if_free (struct ospf_snmp_if *osif)
1429 XFREE (MTYPE_TMP, osif);
1433 ospf_snmp_if_delete (struct interface *ifp)
1435 struct listnode *node, *nnode;
1436 struct ospf_snmp_if *osif;
1438 for (ALL_LIST_ELEMENTS (ospf_snmp_iflist, node, nnode, osif))
1440 if (osif->ifp == ifp)
1442 list_delete_node (ospf_snmp_iflist, node);
1443 ospf_snmp_if_free (osif);
1450 ospf_snmp_if_update (struct interface *ifp)
1452 struct listnode *node;
1453 struct listnode *pn;
1454 struct connected *ifc;
1456 struct ospf_snmp_if *osif;
1457 struct in_addr *addr;
1460 ospf_snmp_if_delete (ifp);
1466 /* Lookup first IPv4 address entry. */
1467 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc))
1469 p = CONNECTED_ID(ifc);
1471 if (p->family == AF_INET)
1473 addr = &p->u.prefix4;
1478 ifindex = ifp->ifindex;
1480 /* Add interface to the list. */
1482 for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
1486 /* Usual interfaces --> Sort them based on interface IPv4 addresses */
1487 if (ntohl (osif->addr.s_addr) > ntohl (addr->s_addr))
1492 /* Unnumbered interfaces --> Sort them based on interface indexes */
1493 if (osif->addr.s_addr != 0 || osif->ifindex > ifindex)
1499 osif = ospf_snmp_if_new ();
1500 if (addr) /* Usual interface */
1504 /* This field is used for storing ospfAddressLessIf OID value,
1505 * conform to RFC1850 OSPF-MIB specification, it must be 0 for
1506 * usual interface */
1509 else /* Unnumbered interface */
1510 osif->ifindex = ifindex;
1513 listnode_add_after (ospf_snmp_iflist, pn, osif);
1517 ospf_snmp_is_if_have_addr (struct interface *ifp)
1519 struct listnode *nn;
1520 struct connected *ifc;
1522 /* Is this interface having any connected IPv4 address ? */
1523 for (ALL_LIST_ELEMENTS_RO (ifp->connected, nn, ifc))
1525 if (CONNECTED_PREFIX(ifc)->family == AF_INET)
1532 static struct ospf_interface *
1533 ospf_snmp_if_lookup (struct in_addr *ifaddr, ifindex_t *ifindex)
1535 struct listnode *node;
1536 struct ospf_snmp_if *osif;
1537 struct ospf_interface *oi = NULL;
1538 struct ospf *ospf = ospf_lookup ();
1540 for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif))
1544 if (IPV4_ADDR_SAME (&osif->addr, ifaddr))
1545 oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
1549 if (osif->ifindex == *ifindex)
1550 oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
1556 static struct ospf_interface *
1557 ospf_snmp_if_lookup_next (struct in_addr *ifaddr, ifindex_t *ifindex,
1558 int ifaddr_next, ifindex_t ifindex_next)
1560 struct ospf_snmp_if *osif;
1561 struct listnode *nn;
1562 struct ospf *ospf = ospf_lookup ();
1563 struct ospf_interface *oi = NULL;
1568 /* No instance is specified --> Return the first OSPF interface */
1571 for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif))
1573 osif = listgetdata (nn);
1574 *ifaddr = osif->addr;
1575 *ifindex = osif->ifindex;
1576 /* Because no instance is specified, we don't care about the kind of
1577 * interface (usual or unnumbered), just returning the first valid
1579 oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
1586 /* An instance is specified --> Return the next OSPF interface */
1587 for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif))
1589 /* Usual interface */
1592 /* The interface must have valid AF_INET connected address */
1593 /* it must have lager IPv4 address value than the lookup entry */
1594 if ((ospf_snmp_is_if_have_addr(osif->ifp)) &&
1595 (ntohl (osif->addr.s_addr) > ntohl (ifaddr->s_addr)))
1597 *ifaddr = osif->addr;
1598 *ifindex = osif->ifindex;
1600 /* and it must be an OSPF interface */
1601 oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
1606 /* Unnumbered interface */
1608 /* The interface must NOT have valid AF_INET connected address */
1609 /* it must have lager interface index than the lookup entry */
1610 if ((!ospf_snmp_is_if_have_addr(osif->ifp)) &&
1611 (osif->ifindex > *ifindex))
1613 *ifaddr = osif->addr;
1614 *ifindex = osif->ifindex;
1616 /* and it must be an OSPF interface */
1617 oi = ospf_if_lookup_by_local_addr (ospf, osif->ifp, *ifaddr);
1626 ospf_snmp_iftype (struct interface *ifp)
1628 #define ospf_snmp_iftype_broadcast 1
1629 #define ospf_snmp_iftype_nbma 2
1630 #define ospf_snmp_iftype_pointToPoint 3
1631 #define ospf_snmp_iftype_pointToMultipoint 5
1632 if (if_is_broadcast (ifp))
1633 return ospf_snmp_iftype_broadcast;
1634 if (if_is_pointopoint (ifp))
1635 return ospf_snmp_iftype_pointToPoint;
1636 return ospf_snmp_iftype_broadcast;
1639 static struct ospf_interface *
1640 ospfIfLookup (struct variable *v, oid *name, size_t *length,
1641 struct in_addr *ifaddr, ifindex_t *ifindex, int exact)
1644 int ifaddr_next = 0;
1645 ifindex_t ifindex_next = 0;
1646 struct ospf_interface *oi;
1651 if (*length != v->namelen + IN_ADDR_SIZE + 1)
1654 oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr);
1655 *ifindex = name[v->namelen + IN_ADDR_SIZE];
1657 return ospf_snmp_if_lookup (ifaddr, ifindex);
1661 len = *length - v->namelen;
1662 if (len >= IN_ADDR_SIZE)
1667 oid2in_addr (name + v->namelen, len, ifaddr);
1669 len = *length - v->namelen - IN_ADDR_SIZE;
1676 *ifindex = name[v->namelen + IN_ADDR_SIZE];
1678 oi = ospf_snmp_if_lookup_next (ifaddr, ifindex, ifaddr_next,
1682 *length = v->namelen + IN_ADDR_SIZE + 1;
1683 offset = name + v->namelen;
1684 oid_copy_addr (offset, ifaddr, IN_ADDR_SIZE);
1685 offset += IN_ADDR_SIZE;
1694 ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact,
1695 size_t *var_len, WriteMethod **write_method)
1698 struct in_addr ifaddr;
1699 struct ospf_interface *oi;
1702 if (smux_header_table(v, name, length, exact, var_len, write_method)
1707 memset (&ifaddr, 0, sizeof (struct in_addr));
1709 /* Check OSPF instance. */
1710 ospf = ospf_lookup ();
1714 oi = ospfIfLookup (v, name, length, &ifaddr, &ifindex, exact);
1718 /* Return the current value of the variable */
1721 case OSPFIFIPADDRESS: /* 1 */
1722 return SNMP_IPADDRESS (ifaddr);
1724 case OSPFADDRESSLESSIF: /* 2 */
1725 return SNMP_INTEGER (ifindex);
1727 case OSPFIFAREAID: /* 3 */
1729 return SNMP_IPADDRESS (oi->area->area_id);
1731 return SNMP_IPADDRESS (ospf_empty_addr);
1733 case OSPFIFTYPE: /* 4 */
1734 return SNMP_INTEGER (ospf_snmp_iftype (oi->ifp));
1736 case OSPFIFADMINSTAT: /* 5 */
1738 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
1740 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
1742 case OSPFIFRTRPRIORITY: /* 6 */
1743 return SNMP_INTEGER (PRIORITY (oi));
1745 case OSPFIFTRANSITDELAY: /* 7 */
1746 return SNMP_INTEGER (OSPF_IF_PARAM (oi, transmit_delay));
1748 case OSPFIFRETRANSINTERVAL: /* 8 */
1749 return SNMP_INTEGER (OSPF_IF_PARAM (oi, retransmit_interval));
1751 case OSPFIFHELLOINTERVAL: /* 9 */
1752 return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_hello));
1754 case OSPFIFRTRDEADINTERVAL: /* 10 */
1755 return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_wait));
1757 case OSPFIFPOLLINTERVAL: /* 11 */
1758 return SNMP_INTEGER (OSPF_POLL_INTERVAL_DEFAULT);
1760 case OSPFIFSTATE: /* 12 */
1761 return SNMP_INTEGER (ISM_SNMP(oi->state));
1763 case OSPFIFDESIGNATEDROUTER: /* 13 */
1764 return SNMP_IPADDRESS (DR (oi));
1766 case OSPFIFBACKUPDESIGNATEDROUTER: /* 14 */
1767 return SNMP_IPADDRESS (BDR (oi));
1769 case OSPFIFEVENTS: /* 15 */
1770 return SNMP_INTEGER (oi->state_change);
1772 case OSPFIFAUTHKEY: /* 16 */
1774 return (u_char *) OSPF_IF_PARAM (oi, auth_simple);
1776 case OSPFIFSTATUS: /* 17 */
1777 return SNMP_INTEGER (SNMP_VALID);
1779 case OSPFIFMULTICASTFORWARDING: /* 18 */
1780 #define ospf_snmp_multiforward_blocked 1
1781 #define ospf_snmp_multiforward_multicast 2
1782 #define ospf_snmp_multiforward_unicast 3
1783 return SNMP_INTEGER (ospf_snmp_multiforward_blocked);
1785 case OSPFIFDEMAND: /* 19 */
1786 return SNMP_INTEGER (SNMP_FALSE);
1788 case OSPFIFAUTHTYPE: /* 20 */
1790 return SNMP_INTEGER (oi->area->auth_type);
1792 return SNMP_INTEGER (0);
1801 #define OSPF_SNMP_METRIC_VALUE 1
1803 static struct ospf_interface *
1804 ospfIfMetricLookup (struct variable *v, oid *name, size_t *length,
1805 struct in_addr *ifaddr, ifindex_t *ifindex, int exact)
1808 int ifaddr_next = 0;
1809 ifindex_t ifindex_next = 0;
1810 struct ospf_interface *oi;
1816 if (*length != v->namelen + IN_ADDR_SIZE + 1 + 1)
1819 oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr);
1820 *ifindex = name[v->namelen + IN_ADDR_SIZE];
1821 metric = name[v->namelen + IN_ADDR_SIZE + 1];
1823 if (metric != OSPF_SNMP_METRIC_VALUE)
1826 return ospf_snmp_if_lookup (ifaddr, ifindex);
1830 len = *length - v->namelen;
1831 if (len >= IN_ADDR_SIZE)
1836 oid2in_addr (name + v->namelen, len, ifaddr);
1838 len = *length - v->namelen - IN_ADDR_SIZE;
1845 *ifindex = name[v->namelen + IN_ADDR_SIZE];
1847 oi = ospf_snmp_if_lookup_next (ifaddr, ifindex, ifaddr_next,
1851 *length = v->namelen + IN_ADDR_SIZE + 1 + 1;
1852 offset = name + v->namelen;
1853 oid_copy_addr (offset, ifaddr, IN_ADDR_SIZE);
1854 offset += IN_ADDR_SIZE;
1857 *offset = OSPF_SNMP_METRIC_VALUE;
1865 ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact,
1866 size_t *var_len, WriteMethod **write_method)
1868 /* Currently we support metric 1 only. */
1870 struct in_addr ifaddr;
1871 struct ospf_interface *oi;
1874 if (smux_header_table(v, name, length, exact, var_len, write_method)
1879 memset (&ifaddr, 0, sizeof (struct in_addr));
1881 /* Check OSPF instance. */
1882 ospf = ospf_lookup ();
1886 oi = ospfIfMetricLookup (v, name, length, &ifaddr, &ifindex, exact);
1890 /* Return the current value of the variable */
1893 case OSPFIFMETRICIPADDRESS:
1894 return SNMP_IPADDRESS (ifaddr);
1896 case OSPFIFMETRICADDRESSLESSIF:
1897 return SNMP_INTEGER (ifindex);
1899 case OSPFIFMETRICTOS:
1900 return SNMP_INTEGER (0);
1902 case OSPFIFMETRICVALUE:
1903 return SNMP_INTEGER (OSPF_SNMP_METRIC_VALUE);
1905 case OSPFIFMETRICSTATUS:
1906 return SNMP_INTEGER (1);
1915 struct route_table *ospf_snmp_vl_table;
1918 ospf_snmp_vl_add (struct ospf_vl_data *vl_data)
1920 struct prefix_ls lp;
1921 struct route_node *rn;
1923 memset (&lp, 0, sizeof (struct prefix_ls));
1926 lp.id = vl_data->vl_area_id;
1927 lp.adv_router = vl_data->vl_peer;
1929 rn = route_node_get (ospf_snmp_vl_table, (struct prefix *) &lp);
1931 route_unlock_node (rn);
1937 ospf_snmp_vl_delete (struct ospf_vl_data *vl_data)
1939 struct prefix_ls lp;
1940 struct route_node *rn;
1942 memset (&lp, 0, sizeof (struct prefix_ls));
1945 lp.id = vl_data->vl_area_id;
1946 lp.adv_router = vl_data->vl_peer;
1948 rn = route_node_lookup (ospf_snmp_vl_table, (struct prefix *) &lp);
1952 route_unlock_node (rn);
1953 route_unlock_node (rn);
1956 static struct ospf_vl_data *
1957 ospf_snmp_vl_lookup (struct in_addr *area_id, struct in_addr *neighbor)
1959 struct prefix_ls lp;
1960 struct route_node *rn;
1961 struct ospf_vl_data *vl_data;
1963 memset (&lp, 0, sizeof (struct prefix_ls));
1967 lp.adv_router = *neighbor;
1969 rn = route_node_lookup (ospf_snmp_vl_table, (struct prefix *) &lp);
1973 route_unlock_node (rn);
1979 static struct ospf_vl_data *
1980 ospf_snmp_vl_lookup_next (struct in_addr *area_id, struct in_addr *neighbor,
1983 struct prefix_ls lp;
1984 struct route_node *rn;
1985 struct ospf_vl_data *vl_data;
1987 memset (&lp, 0, sizeof (struct prefix_ls));
1991 lp.adv_router = *neighbor;
1994 rn = route_top (ospf_snmp_vl_table);
1997 rn = route_node_get (ospf_snmp_vl_table, (struct prefix *) &lp);
1998 rn = route_next (rn);
2001 for (; rn; rn = route_next (rn))
2008 *area_id = vl_data->vl_area_id;
2009 *neighbor = vl_data->vl_peer;
2010 route_unlock_node (rn);
2016 static struct ospf_vl_data *
2017 ospfVirtIfLookup (struct variable *v, oid *name, size_t *length,
2018 struct in_addr *area_id, struct in_addr *neighbor, int exact)
2022 struct ospf_vl_data *vl_data;
2026 if (*length != v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE)
2029 oid2in_addr (name + v->namelen, IN_ADDR_SIZE, area_id);
2030 oid2in_addr (name + v->namelen + IN_ADDR_SIZE, IN_ADDR_SIZE, neighbor);
2032 return ospf_snmp_vl_lookup (area_id, neighbor);
2038 len = *length - v->namelen;
2041 if (len > IN_ADDR_SIZE)
2043 oid2in_addr (name + v->namelen, len, area_id);
2045 len = *length - v->namelen - IN_ADDR_SIZE;
2046 if (len > IN_ADDR_SIZE)
2048 oid2in_addr (name + v->namelen + IN_ADDR_SIZE, len, neighbor);
2050 vl_data = ospf_snmp_vl_lookup_next (area_id, neighbor, first);
2054 *length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE;
2055 oid_copy_addr (name + v->namelen, area_id, IN_ADDR_SIZE);
2056 oid_copy_addr (name + v->namelen + IN_ADDR_SIZE, neighbor,
2065 ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact,
2066 size_t *var_len, WriteMethod **write_method)
2068 struct ospf_vl_data *vl_data;
2069 struct ospf_interface *oi;
2070 struct in_addr area_id;
2071 struct in_addr neighbor;
2073 if (smux_header_table(v, name, length, exact, var_len, write_method)
2077 memset (&area_id, 0, sizeof (struct in_addr));
2078 memset (&neighbor, 0, sizeof (struct in_addr));
2080 vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact);
2083 oi = vl_data->vl_oi;
2087 /* Return the current value of the variable */
2090 case OSPFVIRTIFAREAID:
2091 return SNMP_IPADDRESS (area_id);
2093 case OSPFVIRTIFNEIGHBOR:
2094 return SNMP_IPADDRESS (neighbor);
2096 case OSPFVIRTIFTRANSITDELAY:
2097 return SNMP_INTEGER (OSPF_IF_PARAM (oi, transmit_delay));
2099 case OSPFVIRTIFRETRANSINTERVAL:
2100 return SNMP_INTEGER (OSPF_IF_PARAM (oi, retransmit_interval));
2102 case OSPFVIRTIFHELLOINTERVAL:
2103 return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_hello));
2105 case OSPFVIRTIFRTRDEADINTERVAL:
2106 return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_wait));
2108 case OSPFVIRTIFSTATE:
2109 return SNMP_INTEGER (oi->state);
2111 case OSPFVIRTIFEVENTS:
2112 return SNMP_INTEGER (oi->state_change);
2114 case OSPFVIRTIFAUTHKEY:
2116 return (u_char *) OSPF_IF_PARAM (oi, auth_simple);
2118 case OSPFVIRTIFSTATUS:
2119 return SNMP_INTEGER (SNMP_VALID);
2121 case OSPFVIRTIFAUTHTYPE:
2123 return SNMP_INTEGER (oi->area->auth_type);
2125 return SNMP_INTEGER (0);
2134 static struct ospf_neighbor *
2135 ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr,
2138 struct listnode *node, *nnode;
2139 struct ospf_interface *oi;
2140 struct ospf_neighbor *nbr;
2141 struct route_node *rn;
2143 for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
2145 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2146 if ((nbr = rn->info) != NULL
2147 && nbr != oi->nbr_self
2148 /* If EXACT match is needed, provide ALL entry found
2149 && nbr->state != NSM_Down
2151 && nbr->src.s_addr != 0)
2153 if (IPV4_ADDR_SAME (&nbr->src, nbr_addr))
2155 route_unlock_node (rn);
2163 static struct ospf_neighbor *
2164 ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, ifindex_t *ifindex,
2167 struct listnode *nn;
2168 struct ospf_interface *oi;
2169 struct ospf_neighbor *nbr;
2170 struct route_node *rn;
2171 struct ospf_neighbor *min = NULL;
2172 struct ospf *ospf = ospf;
2174 ospf = ospf_lookup ();
2176 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, nn, oi))
2178 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
2179 if ((nbr = rn->info) != NULL
2180 && nbr != oi->nbr_self
2181 && nbr->state != NSM_Down
2182 && nbr->src.s_addr != 0)
2188 else if (ntohl (nbr->src.s_addr) < ntohl (min->src.s_addr))
2191 else if (ntohl (nbr->src.s_addr) > ntohl (nbr_addr->s_addr))
2195 else if (ntohl (nbr->src.s_addr) < ntohl (min->src.s_addr))
2202 *nbr_addr = min->src;
2209 static struct ospf_neighbor *
2210 ospfNbrLookup (struct variable *v, oid *name, size_t *length,
2211 struct in_addr *nbr_addr, ifindex_t *ifindex, int exact)
2215 struct ospf_neighbor *nbr;
2218 ospf = ospf_lookup ();
2225 if (*length != v->namelen + IN_ADDR_SIZE + 1)
2228 oid2in_addr (name + v->namelen, IN_ADDR_SIZE, nbr_addr);
2229 *ifindex = name[v->namelen + IN_ADDR_SIZE];
2231 return ospf_snmp_nbr_lookup (ospf, nbr_addr, ifindex);
2236 len = *length - v->namelen;
2241 if (len > IN_ADDR_SIZE)
2244 oid2in_addr (name + v->namelen, len, nbr_addr);
2246 len = *length - v->namelen - IN_ADDR_SIZE;
2248 *ifindex = name[v->namelen + IN_ADDR_SIZE];
2250 nbr = ospf_snmp_nbr_lookup_next (nbr_addr, ifindex, first);
2254 *length = v->namelen + IN_ADDR_SIZE + 1;
2255 oid_copy_addr (name + v->namelen, nbr_addr, IN_ADDR_SIZE);
2256 name[v->namelen + IN_ADDR_SIZE] = *ifindex;
2263 /* map internal quagga neighbor states to official MIB values:
2265 ospfNbrState OBJECT-TYPE
2278 ospf_snmp_neighbor_state(u_char nst)
2297 return 1; /* down */
2302 ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
2303 size_t *var_len, WriteMethod **write_method)
2305 struct in_addr nbr_addr;
2307 struct ospf_neighbor *nbr;
2308 struct ospf_interface *oi;
2310 if (smux_header_table(v, name, length, exact, var_len, write_method)
2314 memset (&nbr_addr, 0, sizeof (struct in_addr));
2317 nbr = ospfNbrLookup (v, name, length, &nbr_addr, &ifindex, exact);
2324 /* Return the current value of the variable */
2328 return SNMP_IPADDRESS (nbr_addr);
2330 case OSPFNBRADDRESSLESSINDEX:
2331 return SNMP_INTEGER (ifindex);
2334 return SNMP_IPADDRESS (nbr->router_id);
2336 case OSPFNBROPTIONS:
2337 return SNMP_INTEGER (oi->nbr_self->options);
2339 case OSPFNBRPRIORITY:
2340 return SNMP_INTEGER (nbr->priority);
2343 return SNMP_INTEGER (ospf_snmp_neighbor_state(nbr->state));
2346 return SNMP_INTEGER (nbr->state_change);
2348 case OSPFNBRLSRETRANSQLEN:
2349 return SNMP_INTEGER (ospf_ls_retransmit_count (nbr));
2351 case OSPFNBMANBRSTATUS:
2352 return SNMP_INTEGER (SNMP_VALID);
2354 case OSPFNBMANBRPERMANENCE:
2355 return SNMP_INTEGER (2);
2357 case OSPFNBRHELLOSUPPRESSED:
2358 return SNMP_INTEGER (SNMP_FALSE);
2368 ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact,
2369 size_t *var_len, WriteMethod **write_method)
2371 struct ospf_vl_data *vl_data;
2372 struct in_addr area_id;
2373 struct in_addr neighbor;
2376 if (smux_header_table(v, name, length, exact, var_len, write_method)
2380 memset (&area_id, 0, sizeof (struct in_addr));
2381 memset (&neighbor, 0, sizeof (struct in_addr));
2383 /* Check OSPF instance. */
2384 ospf = ospf_lookup ();
2388 vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact);
2392 /* Return the current value of the variable */
2395 case OSPFVIRTNBRAREA:
2396 return (u_char *) NULL;
2398 case OSPFVIRTNBRRTRID:
2399 return (u_char *) NULL;
2401 case OSPFVIRTNBRIPADDR:
2402 return (u_char *) NULL;
2404 case OSPFVIRTNBROPTIONS:
2405 return (u_char *) NULL;
2407 case OSPFVIRTNBRSTATE:
2408 return (u_char *) NULL;
2410 case OSPFVIRTNBREVENTS:
2411 return (u_char *) NULL;
2413 case OSPFVIRTNBRLSRETRANSQLEN:
2414 return (u_char *) NULL;
2416 case OSPFVIRTNBRHELLOSUPPRESSED:
2417 return (u_char *) NULL;
2426 static struct ospf_lsa *
2427 ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type,
2428 struct in_addr *ls_id, struct in_addr *router_id, int exact)
2435 struct ospf_lsa *lsa;
2438 ospf = ospf_lookup ();
2441 if (*length != v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
2444 offset = name + v->namelen;
2446 /* Make it sure given value match to type. */
2450 if (lsa_type != *type)
2454 oid2in_addr (offset, IN_ADDR_SIZE, ls_id);
2455 offset += IN_ADDR_SIZE;
2458 oid2in_addr (offset, IN_ADDR_SIZE, router_id);
2460 return ospf_lsdb_lookup_by_id (ospf->lsdb, *type, *ls_id, *router_id);
2464 /* Get variable length. */
2466 offset = name + v->namelen;
2467 offsetlen = *length - v->namelen;
2469 /* LSA type value. */
2474 if (offsetlen <= 0 || lsa_type < OSPF_AS_EXTERNAL_LSA)
2479 if (len > IN_ADDR_SIZE)
2482 oid2in_addr (offset, len, ls_id);
2484 offset += IN_ADDR_SIZE;
2485 offsetlen -= IN_ADDR_SIZE;
2489 if (len > IN_ADDR_SIZE)
2492 oid2in_addr (offset, len, router_id);
2494 lsa = ospf_lsdb_lookup_by_id_next (ospf->lsdb, *type, *ls_id,
2499 /* Fill in length. */
2500 *length = v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE;
2502 /* Fill in value. */
2503 offset = name + v->namelen;
2505 *offset = OSPF_AS_EXTERNAL_LSA;
2507 oid_copy_addr (offset, &lsa->data->id, IN_ADDR_SIZE);
2508 offset += IN_ADDR_SIZE;
2509 oid_copy_addr (offset, &lsa->data->adv_router, IN_ADDR_SIZE);
2518 ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact,
2519 size_t *var_len, WriteMethod **write_method)
2521 struct ospf_lsa *lsa;
2522 struct lsa_header *lsah;
2524 struct in_addr ls_id;
2525 struct in_addr router_id;
2528 if (smux_header_table(v, name, length, exact, var_len, write_method)
2532 type = OSPF_AS_EXTERNAL_LSA;
2533 memset (&ls_id, 0, sizeof (struct in_addr));
2534 memset (&router_id, 0, sizeof (struct in_addr));
2536 /* Check OSPF instance. */
2537 ospf = ospf_lookup ();
2541 lsa = ospfExtLsdbLookup (v, name, length, &type, &ls_id, &router_id, exact);
2547 /* Return the current value of the variable */
2550 case OSPFEXTLSDBTYPE:
2551 return SNMP_INTEGER (OSPF_AS_EXTERNAL_LSA);
2553 case OSPFEXTLSDBLSID:
2554 return SNMP_IPADDRESS (lsah->id);
2556 case OSPFEXTLSDBROUTERID:
2557 return SNMP_IPADDRESS (lsah->adv_router);
2559 case OSPFEXTLSDBSEQUENCE:
2560 return SNMP_INTEGER (lsah->ls_seqnum);
2562 case OSPFEXTLSDBAGE:
2563 return SNMP_INTEGER (lsah->ls_age);
2565 case OSPFEXTLSDBCHECKSUM:
2566 return SNMP_INTEGER (lsah->checksum);
2568 case OSPFEXTLSDBADVERTISEMENT:
2569 *var_len = ntohs (lsah->length);
2570 return (u_char *) lsah;
2580 ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length,
2581 int exact, size_t *var_len, WriteMethod **write_method)
2583 if (smux_header_table(v, name, length, exact, var_len, write_method)
2587 /* Return the current value of the variable */
2590 case OSPFAREAAGGREGATEAREAID:
2591 return (u_char *) NULL;
2593 case OSPFAREAAGGREGATELSDBTYPE:
2594 return (u_char *) NULL;
2596 case OSPFAREAAGGREGATENET:
2597 return (u_char *) NULL;
2599 case OSPFAREAAGGREGATEMASK:
2600 return (u_char *) NULL;
2602 case OSPFAREAAGGREGATESTATUS:
2603 return (u_char *) NULL;
2605 case OSPFAREAAGGREGATEEFFECT:
2606 return (u_char *) NULL;
2616 #define IFSTATECHANGE 16
2617 #define VIRTIFSTATECHANGE 1
2618 #define NBRSTATECHANGE 2
2619 #define VIRTNBRSTATECHANGE 3
2621 struct trap_object ospfNbrTrapList[] =
2623 {-2, {1, OSPFROUTERID}},
2624 {3, {10, 1, OSPFNBRIPADDR}},
2625 {3, {10, 1, OSPFNBRRTRID}},
2626 {3, {10, 1, OSPFNBRSTATE}}
2630 struct trap_object ospfVirtNbrTrapList[] =
2633 {3, {11, 1, OSPFVIRTNBRAREA}},
2634 {3, {11, 1, OSPFVIRTNBRRTRID}},
2635 {3, {11, 1, OSPFVIRTNBRSTATE}}
2638 struct trap_object ospfIfTrapList[] =
2640 {-2, {1, OSPFROUTERID}},
2641 {3, {7, 1, OSPFIFIPADDRESS}},
2642 {3, {7, 1, OSPFADDRESSLESSIF}},
2643 {3, {7, 1, OSPFIFSTATE}}
2646 struct trap_object ospfVirtIfTrapList[] =
2648 {-2, {1, OSPFROUTERID}},
2649 {3, {9, 1, OSPFVIRTIFAREAID}},
2650 {3, {9, 1, OSPFVIRTIFNEIGHBOR}},
2651 {3, {9, 1, OSPFVIRTIFSTATE}}
2655 ospfTrapNbrStateChange (struct ospf_neighbor *on)
2657 oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
2660 ospf_nbr_state_message(on, msgbuf, sizeof(msgbuf));
2661 zlog (NULL, LOG_INFO, "ospfTrapNbrStateChange trap sent: %s now %s",
2662 inet_ntoa(on->address.u.prefix4), msgbuf);
2664 oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE);
2665 index[IN_ADDR_SIZE] = 0;
2667 smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable),
2668 ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid),
2669 ospf_oid, sizeof ospf_oid / sizeof (oid),
2670 index, IN_ADDR_SIZE + 1,
2672 sizeof ospfNbrTrapList / sizeof (struct trap_object),
2677 ospfTrapVirtNbrStateChange (struct ospf_neighbor *on)
2679 oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
2681 zlog (NULL, LOG_INFO, "ospfTrapVirtNbrStateChange trap sent");
2683 oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE);
2684 index[IN_ADDR_SIZE] = 0;
2686 smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable),
2687 ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid),
2688 ospf_oid, sizeof ospf_oid / sizeof (oid),
2689 index, IN_ADDR_SIZE + 1,
2690 ospfVirtNbrTrapList,
2691 sizeof ospfVirtNbrTrapList / sizeof (struct trap_object),
2692 VIRTNBRSTATECHANGE);
2696 ospfTrapIfStateChange (struct ospf_interface *oi)
2698 oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
2700 zlog (NULL, LOG_INFO, "ospfTrapIfStateChange trap sent: %s now %s",
2701 inet_ntoa(oi->address->u.prefix4),
2702 LOOKUP(ospf_ism_state_msg, oi->state));
2704 oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
2705 index[IN_ADDR_SIZE] = 0;
2707 smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable),
2708 ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid),
2709 ospf_oid, sizeof ospf_oid / sizeof (oid),
2710 index, IN_ADDR_SIZE + 1,
2712 sizeof ospfIfTrapList / sizeof (struct trap_object),
2717 ospfTrapVirtIfStateChange (struct ospf_interface *oi)
2719 oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)];
2721 zlog (NULL, LOG_INFO, "ospfTrapVirtIfStateChange trap sent");
2723 oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE);
2724 index[IN_ADDR_SIZE] = 0;
2726 smux_trap (ospf_variables, sizeof ospf_variables / sizeof (struct variable),
2727 ospf_trap_oid, sizeof ospf_trap_oid / sizeof (oid),
2728 ospf_oid, sizeof ospf_oid / sizeof (oid),
2729 index, IN_ADDR_SIZE + 1,
2731 sizeof ospfVirtIfTrapList / sizeof (struct trap_object),
2734 /* Register OSPF2-MIB. */
2738 ospf_snmp_iflist = list_new ();
2739 ospf_snmp_vl_table = route_table_init ();
2740 smux_init (om->master);
2741 REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid);
2743 #endif /* HAVE_SNMP */