2 * Copyright (C) 2000 IP Infusion Inc.
4 * Written by Kunihiro Ishiguro <kunihiro@zebra.org>
6 * This file is part of GNU Zebra.
8 * GNU Zebra is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Zebra; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 #include <net-snmp/net-snmp-config.h>
30 #endif /* HAVE_NETSNMP */
34 #include <snmp_impl.h>
44 #include "ospfd/ospfd.h"
45 #include "ospfd/ospf_interface.h"
46 #include "ospfd/ospf_asbr.h"
47 #include "ospfd/ospf_lsa.h"
48 #include "ospfd/ospf_lsdb.h"
49 #include "ospfd/ospf_abr.h"
50 #include "ospfd/ospf_neighbor.h"
51 #include "ospfd/ospf_nsm.h"
52 #include "ospfd/ospf_flood.h"
55 #define OSPF2MIB 1,3,6,1,2,1,14
57 /* Zebra enterprise OSPF MIB. This variable is used for register
58 OSPF MIB to SNMP agent under SMUX protocol. */
59 #define OSPFDOID 1,3,6,1,4,1,3317,1,2,5
61 /* OSPF MIB General Group values. */
62 #define OSPFROUTERID 1
63 #define OSPFADMINSTAT 2
64 #define OSPFVERSIONNUMBER 3
65 #define OSPFAREABDRRTRSTATUS 4
66 #define OSPFASBDRRTRSTATUS 5
67 #define OSPFEXTERNLSACOUNT 6
68 #define OSPFEXTERNLSACKSUMSUM 7
69 #define OSPFTOSSUPPORT 8
70 #define OSPFORIGINATENEWLSAS 9
71 #define OSPFRXNEWLSAS 10
72 #define OSPFEXTLSDBLIMIT 11
73 #define OSPFMULTICASTEXTENSIONS 12
74 #define OSPFEXITOVERFLOWINTERVAL 13
75 #define OSPFDEMANDEXTENSIONS 14
77 /* OSPF MIB ospfAreaTable. */
79 #define OSPFAUTHTYPE 2
80 #define OSPFIMPORTASEXTERN 3
82 #define OSPFAREABDRRTRCOUNT 5
83 #define OSPFASBDRRTRCOUNT 6
84 #define OSPFAREALSACOUNT 7
85 #define OSPFAREALSACKSUMSUM 8
86 #define OSPFAREASUMMARY 9
87 #define OSPFAREASTATUS 10
89 /* OSPF MIB ospfStubAreaTable. */
90 #define OSPFSTUBAREAID 1
92 #define OSPFSTUBMETRIC 3
93 #define OSPFSTUBSTATUS 4
94 #define OSPFSTUBMETRICTYPE 5
96 /* OSPF MIB ospfLsdbTable. */
97 #define OSPFLSDBAREAID 1
98 #define OSPFLSDBTYPE 2
99 #define OSPFLSDBLSID 3
100 #define OSPFLSDBROUTERID 4
101 #define OSPFLSDBSEQUENCE 5
102 #define OSPFLSDBAGE 6
103 #define OSPFLSDBCHECKSUM 7
104 #define OSPFLSDBADVERTISEMENT 8
106 /* OSPF MIB ospfAreaRangeTable. */
107 #define OSPFAREARANGEAREAID 1
108 #define OSPFAREARANGENET 2
109 #define OSPFAREARANGEMASK 3
110 #define OSPFAREARANGESTATUS 4
111 #define OSPFAREARANGEEFFECT 5
113 /* OSPF MIB ospfHostTable. */
114 #define OSPFHOSTIPADDRESS 1
115 #define OSPFHOSTTOS 2
116 #define OSPFHOSTMETRIC 3
117 #define OSPFHOSTSTATUS 4
118 #define OSPFHOSTAREAID 5
120 /* OSPF MIB ospfIfTable. */
121 #define OSPFIFIPADDRESS 1
122 #define OSPFADDRESSLESSIF 2
123 #define OSPFIFAREAID 3
125 #define OSPFIFADMINSTAT 5
126 #define OSPFIFRTRPRIORITY 6
127 #define OSPFIFTRANSITDELAY 7
128 #define OSPFIFRETRANSINTERVAL 8
129 #define OSPFIFHELLOINTERVAL 9
130 #define OSPFIFRTRDEADINTERVAL 10
131 #define OSPFIFPOLLINTERVAL 11
132 #define OSPFIFSTATE 12
133 #define OSPFIFDESIGNATEDROUTER 13
134 #define OSPFIFBACKUPDESIGNATEDROUTER 14
135 #define OSPFIFEVENTS 15
136 #define OSPFIFAUTHKEY 16
137 #define OSPFIFSTATUS 17
138 #define OSPFIFMULTICASTFORWARDING 18
139 #define OSPFIFDEMAND 19
140 #define OSPFIFAUTHTYPE 20
142 /* OSPF MIB ospfIfMetricTable. */
143 #define OSPFIFMETRICIPADDRESS 1
144 #define OSPFIFMETRICADDRESSLESSIF 2
145 #define OSPFIFMETRICTOS 3
146 #define OSPFIFMETRICVALUE 4
147 #define OSPFIFMETRICSTATUS 5
149 /* OSPF MIB ospfVirtIfTable. */
150 #define OSPFVIRTIFAREAID 1
151 #define OSPFVIRTIFNEIGHBOR 2
152 #define OSPFVIRTIFTRANSITDELAY 3
153 #define OSPFVIRTIFRETRANSINTERVAL 4
154 #define OSPFVIRTIFHELLOINTERVAL 5
155 #define OSPFVIRTIFRTRDEADINTERVAL 6
156 #define OSPFVIRTIFSTATE 7
157 #define OSPFVIRTIFEVENTS 8
158 #define OSPFVIRTIFAUTHKEY 9
159 #define OSPFVIRTIFSTATUS 10
160 #define OSPFVIRTIFAUTHTYPE 11
162 /* OSPF MIB ospfNbrTable. */
163 #define OSPFNBRIPADDR 1
164 #define OSPFNBRADDRESSLESSINDEX 2
165 #define OSPFNBRRTRID 3
166 #define OSPFNBROPTIONS 4
167 #define OSPFNBRPRIORITY 5
168 #define OSPFNBRSTATE 6
169 #define OSPFNBREVENTS 7
170 #define OSPFNBRLSRETRANSQLEN 8
171 #define OSPFNBMANBRSTATUS 9
172 #define OSPFNBMANBRPERMANENCE 10
173 #define OSPFNBRHELLOSUPPRESSED 11
175 /* OSPF MIB ospfVirtNbrTable. */
176 #define OSPFVIRTNBRAREA 1
177 #define OSPFVIRTNBRRTRID 2
178 #define OSPFVIRTNBRIPADDR 3
179 #define OSPFVIRTNBROPTIONS 4
180 #define OSPFVIRTNBRSTATE 5
181 #define OSPFVIRTNBREVENTS 6
182 #define OSPFVIRTNBRLSRETRANSQLEN 7
183 #define OSPFVIRTNBRHELLOSUPPRESSED 8
185 /* OSPF MIB ospfExtLsdbTable. */
186 #define OSPFEXTLSDBTYPE 1
187 #define OSPFEXTLSDBLSID 2
188 #define OSPFEXTLSDBROUTERID 3
189 #define OSPFEXTLSDBSEQUENCE 4
190 #define OSPFEXTLSDBAGE 5
191 #define OSPFEXTLSDBCHECKSUM 6
192 #define OSPFEXTLSDBADVERTISEMENT 7
194 /* OSPF MIB ospfAreaAggregateTable. */
195 #define OSPFAREAAGGREGATEAREAID 1
196 #define OSPFAREAAGGREGATELSDBTYPE 2
197 #define OSPFAREAAGGREGATENET 3
198 #define OSPFAREAAGGREGATEMASK 4
199 #define OSPFAREAAGGREGATESTATUS 5
200 #define OSPFAREAAGGREGATEEFFECT 6
202 /* SYNTAX Status from OSPF-MIB. */
203 #define OSPF_STATUS_ENABLED 1
204 #define OSPF_STATUS_DISABLED 2
206 /* SNMP value hack. */
207 #define COUNTER ASN_COUNTER
208 #define INTEGER ASN_INTEGER
209 #define GAUGE ASN_GAUGE
210 #define TIMETICKS ASN_TIMETICKS
211 #define IPADDRESS ASN_IPADDRESS
212 #define STRING ASN_OCTET_STR
214 /* Declare static local variables for convenience. */
217 /* OSPF-MIB instances. */
218 oid ospf_oid
[] = { OSPF2MIB
};
219 oid ospfd_oid
[] = { OSPFDOID
};
221 /* IP address 0.0.0.0. */
222 static struct in_addr ospf_empty_addr
= {0};
224 /* Hook functions. */
225 static u_char
*ospfGeneralGroup ();
226 static u_char
*ospfAreaEntry ();
227 static u_char
*ospfStubAreaEntry ();
228 static u_char
*ospfLsdbEntry ();
229 static u_char
*ospfAreaRangeEntry ();
230 static u_char
*ospfHostEntry ();
231 static u_char
*ospfIfEntry ();
232 static u_char
*ospfIfMetricEntry ();
233 static u_char
*ospfVirtIfEntry ();
234 static u_char
*ospfNbrEntry ();
235 static u_char
*ospfVirtNbrEntry ();
236 static u_char
*ospfExtLsdbEntry ();
237 static u_char
*ospfAreaAggregateEntry ();
239 struct variable ospf_variables
[] =
241 /* OSPF general variables */
242 {OSPFROUTERID
, IPADDRESS
, RWRITE
, ospfGeneralGroup
,
244 {OSPFADMINSTAT
, INTEGER
, RWRITE
, ospfGeneralGroup
,
246 {OSPFVERSIONNUMBER
, INTEGER
, RONLY
, ospfGeneralGroup
,
248 {OSPFAREABDRRTRSTATUS
, INTEGER
, RONLY
, ospfGeneralGroup
,
250 {OSPFASBDRRTRSTATUS
, INTEGER
, RWRITE
, ospfGeneralGroup
,
252 {OSPFEXTERNLSACOUNT
, GAUGE
, RONLY
, ospfGeneralGroup
,
254 {OSPFEXTERNLSACKSUMSUM
, INTEGER
, RONLY
, ospfGeneralGroup
,
256 {OSPFTOSSUPPORT
, INTEGER
, RWRITE
, ospfGeneralGroup
,
258 {OSPFORIGINATENEWLSAS
, COUNTER
, RONLY
, ospfGeneralGroup
,
260 {OSPFRXNEWLSAS
, COUNTER
, RONLY
, ospfGeneralGroup
,
262 {OSPFEXTLSDBLIMIT
, INTEGER
, RWRITE
, ospfGeneralGroup
,
264 {OSPFMULTICASTEXTENSIONS
, INTEGER
, RWRITE
, ospfGeneralGroup
,
266 {OSPFEXITOVERFLOWINTERVAL
, INTEGER
, RWRITE
, ospfGeneralGroup
,
268 {OSPFDEMANDEXTENSIONS
, INTEGER
, RWRITE
, ospfGeneralGroup
,
271 /* OSPF area data structure. */
272 {OSPFAREAID
, IPADDRESS
, RONLY
, ospfAreaEntry
,
274 {OSPFAUTHTYPE
, INTEGER
, RWRITE
, ospfAreaEntry
,
276 {OSPFIMPORTASEXTERN
, INTEGER
, RWRITE
, ospfAreaEntry
,
278 {OSPFSPFRUNS
, COUNTER
, RONLY
, ospfAreaEntry
,
280 {OSPFAREABDRRTRCOUNT
, GAUGE
, RONLY
, ospfAreaEntry
,
282 {OSPFASBDRRTRCOUNT
, GAUGE
, RONLY
, ospfAreaEntry
,
284 {OSPFAREALSACOUNT
, GAUGE
, RONLY
, ospfAreaEntry
,
286 {OSPFAREALSACKSUMSUM
, INTEGER
, RONLY
, ospfAreaEntry
,
288 {OSPFAREASUMMARY
, INTEGER
, RWRITE
, ospfAreaEntry
,
290 {OSPFAREASTATUS
, INTEGER
, RWRITE
, ospfAreaEntry
,
293 /* OSPF stub area information. */
294 {OSPFSTUBAREAID
, IPADDRESS
, RONLY
, ospfStubAreaEntry
,
296 {OSPFSTUBTOS
, INTEGER
, RONLY
, ospfStubAreaEntry
,
298 {OSPFSTUBMETRIC
, INTEGER
, RWRITE
, ospfStubAreaEntry
,
300 {OSPFSTUBSTATUS
, INTEGER
, RWRITE
, ospfStubAreaEntry
,
302 {OSPFSTUBMETRICTYPE
, INTEGER
, RWRITE
, ospfStubAreaEntry
,
305 /* OSPF link state database. */
306 {OSPFLSDBAREAID
, IPADDRESS
, RONLY
, ospfLsdbEntry
,
308 {OSPFLSDBTYPE
, INTEGER
, RONLY
, ospfLsdbEntry
,
310 {OSPFLSDBLSID
, IPADDRESS
, RONLY
, ospfLsdbEntry
,
312 {OSPFLSDBROUTERID
, IPADDRESS
, RONLY
, ospfLsdbEntry
,
314 {OSPFLSDBSEQUENCE
, INTEGER
, RONLY
, ospfLsdbEntry
,
316 {OSPFLSDBAGE
, INTEGER
, RONLY
, ospfLsdbEntry
,
318 {OSPFLSDBCHECKSUM
, INTEGER
, RONLY
, ospfLsdbEntry
,
320 {OSPFLSDBADVERTISEMENT
, STRING
, RONLY
, ospfLsdbEntry
,
323 /* Area range table. */
324 {OSPFAREARANGEAREAID
, IPADDRESS
, RONLY
, ospfAreaRangeEntry
,
326 {OSPFAREARANGENET
, IPADDRESS
, RONLY
, ospfAreaRangeEntry
,
328 {OSPFAREARANGEMASK
, IPADDRESS
, RWRITE
, ospfAreaRangeEntry
,
330 {OSPFAREARANGESTATUS
, INTEGER
, RWRITE
, ospfAreaRangeEntry
,
332 {OSPFAREARANGEEFFECT
, INTEGER
, RWRITE
, ospfAreaRangeEntry
,
335 /* OSPF host table. */
336 {OSPFHOSTIPADDRESS
, IPADDRESS
, RONLY
, ospfHostEntry
,
338 {OSPFHOSTTOS
, INTEGER
, RONLY
, ospfHostEntry
,
340 {OSPFHOSTMETRIC
, INTEGER
, RWRITE
, ospfHostEntry
,
342 {OSPFHOSTSTATUS
, INTEGER
, RWRITE
, ospfHostEntry
,
344 {OSPFHOSTAREAID
, IPADDRESS
, RONLY
, ospfHostEntry
,
347 /* OSPF interface table. */
348 {OSPFIFIPADDRESS
, IPADDRESS
, RONLY
, ospfIfEntry
,
350 {OSPFADDRESSLESSIF
, INTEGER
, RONLY
, ospfIfEntry
,
352 {OSPFIFAREAID
, IPADDRESS
, RWRITE
, ospfIfEntry
,
354 {OSPFIFTYPE
, INTEGER
, RWRITE
, ospfIfEntry
,
356 {OSPFIFADMINSTAT
, INTEGER
, RWRITE
, ospfIfEntry
,
358 {OSPFIFRTRPRIORITY
, INTEGER
, RWRITE
, ospfIfEntry
,
360 {OSPFIFTRANSITDELAY
, INTEGER
, RWRITE
, ospfIfEntry
,
362 {OSPFIFRETRANSINTERVAL
, INTEGER
, RWRITE
, ospfIfEntry
,
364 {OSPFIFHELLOINTERVAL
, INTEGER
, RWRITE
, ospfIfEntry
,
366 {OSPFIFRTRDEADINTERVAL
, INTEGER
, RWRITE
, ospfIfEntry
,
368 {OSPFIFPOLLINTERVAL
, INTEGER
, RWRITE
, ospfIfEntry
,
370 {OSPFIFSTATE
, INTEGER
, RONLY
, ospfIfEntry
,
372 {OSPFIFDESIGNATEDROUTER
, IPADDRESS
, RONLY
, ospfIfEntry
,
374 {OSPFIFBACKUPDESIGNATEDROUTER
, IPADDRESS
, RONLY
, ospfIfEntry
,
376 {OSPFIFEVENTS
, COUNTER
, RONLY
, ospfIfEntry
,
378 {OSPFIFAUTHKEY
, STRING
, RWRITE
, ospfIfEntry
,
380 {OSPFIFSTATUS
, INTEGER
, RWRITE
, ospfIfEntry
,
382 {OSPFIFMULTICASTFORWARDING
, INTEGER
, RWRITE
, ospfIfEntry
,
384 {OSPFIFDEMAND
, INTEGER
, RWRITE
, ospfIfEntry
,
386 {OSPFIFAUTHTYPE
, INTEGER
, RWRITE
, ospfIfEntry
,
389 /* OSPF interface metric table. */
390 {OSPFIFMETRICIPADDRESS
, IPADDRESS
, RONLY
, ospfIfMetricEntry
,
392 {OSPFIFMETRICADDRESSLESSIF
, INTEGER
, RONLY
, ospfIfMetricEntry
,
394 {OSPFIFMETRICTOS
, INTEGER
, RONLY
, ospfIfMetricEntry
,
396 {OSPFIFMETRICVALUE
, INTEGER
, RWRITE
, ospfIfMetricEntry
,
398 {OSPFIFMETRICSTATUS
, INTEGER
, RWRITE
, ospfIfMetricEntry
,
401 /* OSPF virtual interface table. */
402 {OSPFVIRTIFAREAID
, IPADDRESS
, RONLY
, ospfVirtIfEntry
,
404 {OSPFVIRTIFNEIGHBOR
, IPADDRESS
, RONLY
, ospfVirtIfEntry
,
406 {OSPFVIRTIFTRANSITDELAY
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
408 {OSPFVIRTIFRETRANSINTERVAL
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
410 {OSPFVIRTIFHELLOINTERVAL
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
412 {OSPFVIRTIFRTRDEADINTERVAL
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
414 {OSPFVIRTIFSTATE
, INTEGER
, RONLY
, ospfVirtIfEntry
,
416 {OSPFVIRTIFEVENTS
, COUNTER
, RONLY
, ospfVirtIfEntry
,
418 {OSPFVIRTIFAUTHKEY
, STRING
, RWRITE
, ospfVirtIfEntry
,
420 {OSPFVIRTIFSTATUS
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
422 {OSPFVIRTIFAUTHTYPE
, INTEGER
, RWRITE
, ospfVirtIfEntry
,
425 /* OSPF neighbor table. */
426 {OSPFNBRIPADDR
, IPADDRESS
, RONLY
, ospfNbrEntry
,
428 {OSPFNBRADDRESSLESSINDEX
, INTEGER
, RONLY
, ospfNbrEntry
,
430 {OSPFNBRRTRID
, IPADDRESS
, RONLY
, ospfNbrEntry
,
432 {OSPFNBROPTIONS
, INTEGER
, RONLY
, ospfNbrEntry
,
434 {OSPFNBRPRIORITY
, INTEGER
, RWRITE
, ospfNbrEntry
,
436 {OSPFNBRSTATE
, INTEGER
, RONLY
, ospfNbrEntry
,
438 {OSPFNBREVENTS
, COUNTER
, RONLY
, ospfNbrEntry
,
440 {OSPFNBRLSRETRANSQLEN
, GAUGE
, RONLY
, ospfNbrEntry
,
442 {OSPFNBMANBRSTATUS
, INTEGER
, RWRITE
, ospfNbrEntry
,
444 {OSPFNBMANBRPERMANENCE
, INTEGER
, RONLY
, ospfNbrEntry
,
446 {OSPFNBRHELLOSUPPRESSED
, INTEGER
, RONLY
, ospfNbrEntry
,
449 /* OSPF virtual neighbor table. */
450 {OSPFVIRTNBRAREA
, IPADDRESS
, RONLY
, ospfVirtNbrEntry
,
452 {OSPFVIRTNBRRTRID
, IPADDRESS
, RONLY
, ospfVirtNbrEntry
,
454 {OSPFVIRTNBRIPADDR
, IPADDRESS
, RONLY
, ospfVirtNbrEntry
,
456 {OSPFVIRTNBROPTIONS
, INTEGER
, RONLY
, ospfVirtNbrEntry
,
458 {OSPFVIRTNBRSTATE
, INTEGER
, RONLY
, ospfVirtNbrEntry
,
460 {OSPFVIRTNBREVENTS
, COUNTER
, RONLY
, ospfVirtNbrEntry
,
462 {OSPFVIRTNBRLSRETRANSQLEN
, INTEGER
, RONLY
, ospfVirtNbrEntry
,
464 {OSPFVIRTNBRHELLOSUPPRESSED
, INTEGER
, RONLY
, ospfVirtNbrEntry
,
467 /* OSPF link state database, external. */
468 {OSPFEXTLSDBTYPE
, INTEGER
, RONLY
, ospfExtLsdbEntry
,
470 {OSPFEXTLSDBLSID
, IPADDRESS
, RONLY
, ospfExtLsdbEntry
,
472 {OSPFEXTLSDBROUTERID
, IPADDRESS
, RONLY
, ospfExtLsdbEntry
,
474 {OSPFEXTLSDBSEQUENCE
, INTEGER
, RONLY
, ospfExtLsdbEntry
,
476 {OSPFEXTLSDBAGE
, INTEGER
, RONLY
, ospfExtLsdbEntry
,
478 {OSPFEXTLSDBCHECKSUM
, INTEGER
, RONLY
, ospfExtLsdbEntry
,
480 {OSPFEXTLSDBADVERTISEMENT
, STRING
, RONLY
, ospfExtLsdbEntry
,
483 /* OSPF area aggregate table. */
484 {OSPFAREAAGGREGATEAREAID
, IPADDRESS
, RONLY
, ospfAreaAggregateEntry
,
486 {OSPFAREAAGGREGATELSDBTYPE
, INTEGER
, RONLY
, ospfAreaAggregateEntry
,
488 {OSPFAREAAGGREGATENET
, IPADDRESS
, RONLY
, ospfAreaAggregateEntry
,
490 {OSPFAREAAGGREGATEMASK
, IPADDRESS
, RONLY
, ospfAreaAggregateEntry
,
492 {OSPFAREAAGGREGATESTATUS
, INTEGER
, RWRITE
, ospfAreaAggregateEntry
,
494 {OSPFAREAAGGREGATEEFFECT
, INTEGER
, RWRITE
, ospfAreaAggregateEntry
,
498 /* The administrative status of OSPF. When OSPF is enbled on at least
499 one interface return 1. */
501 ospf_admin_stat (struct ospf
*ospf
)
504 struct ospf_interface
*oi
;
509 for (node
= listhead (ospf
->oiflist
); node
; nextnode (node
))
513 if (oi
&& oi
->address
)
520 ospfGeneralGroup (struct variable
*v
, oid
*name
, size_t *length
,
521 int exact
, size_t *var_len
, WriteMethod
**write_method
)
525 ospf
= ospf_lookup ();
527 /* Check whether the instance identifier is valid */
528 if (smux_header_generic (v
, name
, length
, exact
, var_len
, write_method
)
532 /* Return the current value of the variable */
535 case OSPFROUTERID
: /* 1 */
536 /* Router-ID of this OSPF instance. */
538 return SNMP_IPADDRESS (ospf
->router_id
);
540 return SNMP_IPADDRESS (ospf_empty_addr
);
542 case OSPFADMINSTAT
: /* 2 */
543 /* The administrative status of OSPF in the router. */
544 if (ospf_admin_stat (ospf
))
545 return SNMP_INTEGER (OSPF_STATUS_ENABLED
);
547 return SNMP_INTEGER (OSPF_STATUS_DISABLED
);
549 case OSPFVERSIONNUMBER
: /* 3 */
550 /* OSPF version 2. */
551 return SNMP_INTEGER (OSPF_VERSION
);
553 case OSPFAREABDRRTRSTATUS
: /* 4 */
554 /* Area Border router status. */
555 if (ospf
&& CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
556 return SNMP_INTEGER (SNMP_TRUE
);
558 return SNMP_INTEGER (SNMP_FALSE
);
560 case OSPFASBDRRTRSTATUS
: /* 5 */
561 /* AS Border router status. */
562 if (ospf
&& CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
563 return SNMP_INTEGER (SNMP_TRUE
);
565 return SNMP_INTEGER (SNMP_FALSE
);
567 case OSPFEXTERNLSACOUNT
: /* 6 */
568 /* External LSA counts. */
570 return SNMP_INTEGER (ospf_lsdb_count_all (ospf
->lsdb
));
572 return SNMP_INTEGER (0);
574 case OSPFEXTERNLSACKSUMSUM
: /* 7 */
575 /* External LSA checksum. */
576 return SNMP_INTEGER (0);
578 case OSPFTOSSUPPORT
: /* 8 */
579 /* TOS is not supported. */
580 return SNMP_INTEGER (SNMP_FALSE
);
582 case OSPFORIGINATENEWLSAS
: /* 9 */
583 /* The number of new link-state advertisements. */
585 return SNMP_INTEGER (ospf
->lsa_originate_count
);
587 return SNMP_INTEGER (0);
589 case OSPFRXNEWLSAS
: /* 10 */
590 /* The number of link-state advertisements received determined
591 to be new instantiations. */
593 return SNMP_INTEGER (ospf
->rx_lsa_count
);
595 return SNMP_INTEGER (0);
597 case OSPFEXTLSDBLIMIT
: /* 11 */
598 /* There is no limit for the number of non-default
600 return SNMP_INTEGER (-1);
602 case OSPFMULTICASTEXTENSIONS
: /* 12 */
603 /* Multicast Extensions to OSPF is not supported. */
604 return SNMP_INTEGER (0);
606 case OSPFEXITOVERFLOWINTERVAL
: /* 13 */
607 /* Overflow is not supported. */
608 return SNMP_INTEGER (0);
610 case OSPFDEMANDEXTENSIONS
: /* 14 */
611 /* Demand routing is not supported. */
612 return SNMP_INTEGER (SNMP_FALSE
);
621 ospf_area_lookup_next (struct ospf
*ospf
, struct in_addr
*area_id
, int first
)
623 struct ospf_area
*area
;
631 node
= listhead (ospf
->areas
);
634 area
= getdata (node
);
635 *area_id
= area
->area_id
;
640 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
642 area
= getdata (node
);
644 if (ntohl (area
->area_id
.s_addr
) > ntohl (area_id
->s_addr
))
646 *area_id
= area
->area_id
;
654 ospfAreaLookup (struct variable
*v
, oid name
[], size_t *length
,
655 struct in_addr
*addr
, int exact
)
658 struct ospf_area
*area
;
661 ospf
= ospf_lookup ();
667 /* Length is insufficient to lookup OSPF area. */
668 if (*length
- v
->namelen
!= sizeof (struct in_addr
))
671 oid2in_addr (name
+ v
->namelen
, sizeof (struct in_addr
), addr
);
673 area
= ospf_area_lookup_by_area_id (ospf
, *addr
);
679 len
= *length
- v
->namelen
;
683 oid2in_addr (name
+ v
->namelen
, len
, addr
);
685 area
= ospf_area_lookup_next (ospf
, addr
, len
== 0 ? 1 : 0);
690 oid_copy_addr (name
+ v
->namelen
, addr
, sizeof (struct in_addr
));
691 *length
= sizeof (struct in_addr
) + v
->namelen
;
699 ospfAreaEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
700 size_t *var_len
, WriteMethod
**write_method
)
702 struct ospf_area
*area
;
705 memset (&addr
, 0, sizeof (struct in_addr
));
707 area
= ospfAreaLookup (v
, name
, length
, &addr
, exact
);
711 /* Return the current value of the variable */
714 case OSPFAREAID
: /* 1 */
715 return SNMP_IPADDRESS (area
->area_id
);
717 case OSPFAUTHTYPE
: /* 2 */
718 return SNMP_INTEGER (area
->auth_type
);
720 case OSPFIMPORTASEXTERN
: /* 3 */
721 return SNMP_INTEGER (area
->external_routing
+ 1);
723 case OSPFSPFRUNS
: /* 4 */
724 return SNMP_INTEGER (area
->spf_calculation
);
726 case OSPFAREABDRRTRCOUNT
: /* 5 */
727 return SNMP_INTEGER (area
->abr_count
);
729 case OSPFASBDRRTRCOUNT
: /* 6 */
730 return SNMP_INTEGER (area
->asbr_count
);
732 case OSPFAREALSACOUNT
: /* 7 */
733 return SNMP_INTEGER (area
->lsdb
->total
);
735 case OSPFAREALSACKSUMSUM
: /* 8 */
736 return SNMP_INTEGER (0);
738 case OSPFAREASUMMARY
: /* 9 */
739 #define OSPF_noAreaSummary 1
740 #define OSPF_sendAreaSummary 2
741 if (area
->no_summary
)
742 return SNMP_INTEGER (OSPF_noAreaSummary
);
744 return SNMP_INTEGER (OSPF_sendAreaSummary
);
746 case OSPFAREASTATUS
: /* 10 */
747 return SNMP_INTEGER (SNMP_VALID
);
757 ospf_stub_area_lookup_next (struct in_addr
*area_id
, int first
)
759 struct ospf_area
*area
;
763 ospf
= ospf_lookup ();
767 for (node
= listhead (ospf
->areas
); node
; nextnode (node
))
769 area
= getdata (node
);
771 if (area
->external_routing
== OSPF_AREA_STUB
)
775 *area_id
= area
->area_id
;
778 else if (ntohl (area
->area_id
.s_addr
) > ntohl (area_id
->s_addr
))
780 *area_id
= area
->area_id
;
789 ospfStubAreaLookup (struct variable
*v
, oid name
[], size_t *length
,
790 struct in_addr
*addr
, int exact
)
793 struct ospf_area
*area
;
796 ospf
= ospf_lookup ();
803 /* ospfStubAreaID + ospfStubTOS. */
804 if (*length
!= v
->namelen
+ sizeof (struct in_addr
) + 1)
807 /* Check ospfStubTOS is zero. */
808 if (name
[*length
- 1] != 0)
811 oid2in_addr (name
+ v
->namelen
, sizeof (struct in_addr
), addr
);
813 area
= ospf_area_lookup_by_area_id (ospf
, *addr
);
815 if (area
->external_routing
== OSPF_AREA_STUB
)
822 len
= *length
- v
->namelen
;
826 oid2in_addr (name
+ v
->namelen
, len
, addr
);
828 area
= ospf_stub_area_lookup_next (addr
, len
== 0 ? 1 : 0);
833 oid_copy_addr (name
+ v
->namelen
, addr
, sizeof (struct in_addr
));
835 name
[v
->namelen
+ sizeof (struct in_addr
)] = 0;
836 *length
= v
->namelen
+ sizeof (struct in_addr
) + 1;
844 ospfStubAreaEntry (struct variable
*v
, oid
*name
, size_t *length
,
845 int exact
, size_t *var_len
, WriteMethod
**write_method
)
847 struct ospf_area
*area
;
850 memset (&addr
, 0, sizeof (struct in_addr
));
852 area
= ospfStubAreaLookup (v
, name
, length
, &addr
, exact
);
856 /* Return the current value of the variable */
859 case OSPFSTUBAREAID
: /* 1 */
860 /* OSPF stub area id. */
861 return SNMP_IPADDRESS (area
->area_id
);
863 case OSPFSTUBTOS
: /* 2 */
864 /* TOS value is not supported. */
865 return SNMP_INTEGER (0);
867 case OSPFSTUBMETRIC
: /* 3 */
868 /* Default cost to stub area. */
869 return SNMP_INTEGER (area
->default_cost
);
871 case OSPFSTUBSTATUS
: /* 4 */
872 /* Status of the stub area. */
873 return SNMP_INTEGER (SNMP_VALID
);
875 case OSPFSTUBMETRICTYPE
: /* 5 */
876 /* OSPF Metric type. */
877 #define OSPF_ospfMetric 1
878 #define OSPF_comparableCost 2
879 #define OSPF_nonComparable 3
880 return SNMP_INTEGER (OSPF_ospfMetric
);
890 lsdb_lookup_next (struct ospf_area
*area
, u_char
*type
, int type_next
,
891 struct in_addr
*ls_id
, int ls_id_next
,
892 struct in_addr
*router_id
, int router_id_next
)
894 struct ospf_lsa
*lsa
;
902 for (; i
< OSPF_MAX_LSA
; i
++)
906 lsa
= ospf_lsdb_lookup_by_id_next (area
->lsdb
, *type
, *ls_id
, *router_id
,
917 ospfLsdbLookup (struct variable
*v
, oid
*name
, size_t *length
,
918 struct in_addr
*area_id
, u_char
*type
,
919 struct in_addr
*ls_id
, struct in_addr
*router_id
, int exact
)
922 struct ospf_area
*area
;
923 struct ospf_lsa
*lsa
;
931 ospf
= ospf_lookup ();
933 #define OSPF_LSDB_ENTRY_OFFSET \
934 (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
938 /* Area ID + Type + LS ID + Router ID. */
939 if (*length
- v
->namelen
!= OSPF_LSDB_ENTRY_OFFSET
)
942 /* Set OID offset for Area ID. */
943 offset
= name
+ v
->namelen
;
945 /* Lookup area first. */
946 oid2in_addr (offset
, IN_ADDR_SIZE
, area_id
);
947 area
= ospf_area_lookup_by_area_id (ospf
, *area_id
);
950 offset
+= IN_ADDR_SIZE
;
957 oid2in_addr (offset
, IN_ADDR_SIZE
, ls_id
);
958 offset
+= IN_ADDR_SIZE
;
961 oid2in_addr (offset
, IN_ADDR_SIZE
, router_id
);
964 return ospf_lsdb_lookup_by_id (area
->lsdb
, *type
, *ls_id
, *router_id
);
968 /* Get variable length. */
969 offset
= name
+ v
->namelen
;
970 offsetlen
= *length
- v
->namelen
;
973 if (len
> IN_ADDR_SIZE
)
976 oid2in_addr (offset
, len
, area_id
);
978 /* First we search area. */
979 if (len
== IN_ADDR_SIZE
)
980 area
= ospf_area_lookup_by_area_id (ospf
, *area_id
);
982 area
= ospf_area_lookup_next (ospf
, area_id
, len
== 0 ? 1 : 0);
989 /* Next we lookup type. */
990 offset
+= IN_ADDR_SIZE
;
991 offsetlen
-= IN_ADDR_SIZE
;
1013 if (len
> IN_ADDR_SIZE
)
1016 oid2in_addr (offset
, len
, ls_id
);
1020 offset
+= IN_ADDR_SIZE
;
1021 offsetlen
-= IN_ADDR_SIZE
;
1029 if (len
> IN_ADDR_SIZE
)
1032 oid2in_addr (offset
, len
, router_id
);
1035 lsa
= lsdb_lookup_next (area
, type
, type_next
, ls_id
, ls_id_next
,
1036 router_id
, router_id_next
);
1040 /* Fill in length. */
1041 *length
= v
->namelen
+ OSPF_LSDB_ENTRY_OFFSET
;
1043 /* Fill in value. */
1044 offset
= name
+ v
->namelen
;
1045 oid_copy_addr (offset
, area_id
, IN_ADDR_SIZE
);
1046 offset
+= IN_ADDR_SIZE
;
1047 *offset
= lsa
->data
->type
;
1049 oid_copy_addr (offset
, &lsa
->data
->id
, IN_ADDR_SIZE
);
1050 offset
+= IN_ADDR_SIZE
;
1051 oid_copy_addr (offset
, &lsa
->data
->adv_router
, IN_ADDR_SIZE
);
1056 while ((area
= ospf_area_lookup_next (ospf
, area_id
, 0)) != NULL
);
1062 ospfLsdbEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
1063 size_t *var_len
, WriteMethod
**write_method
)
1065 struct ospf_lsa
*lsa
;
1066 struct lsa_header
*lsah
;
1067 struct in_addr area_id
;
1069 struct in_addr ls_id
;
1070 struct in_addr router_id
;
1073 /* INDEX { ospfLsdbAreaId, ospfLsdbType,
1074 ospfLsdbLsid, ospfLsdbRouterId } */
1076 memset (&area_id
, 0, sizeof (struct in_addr
));
1078 memset (&ls_id
, 0, sizeof (struct in_addr
));
1079 memset (&router_id
, 0, sizeof (struct in_addr
));
1081 /* Check OSPF instance. */
1082 ospf
= ospf_lookup ();
1086 lsa
= ospfLsdbLookup (v
, name
, length
, &area_id
, &type
, &ls_id
, &router_id
,
1093 /* Return the current value of the variable */
1096 case OSPFLSDBAREAID
: /* 1 */
1097 return SNMP_IPADDRESS (lsa
->area
->area_id
);
1099 case OSPFLSDBTYPE
: /* 2 */
1100 return SNMP_INTEGER (lsah
->type
);
1102 case OSPFLSDBLSID
: /* 3 */
1103 return SNMP_IPADDRESS (lsah
->id
);
1105 case OSPFLSDBROUTERID
: /* 4 */
1106 return SNMP_IPADDRESS (lsah
->adv_router
);
1108 case OSPFLSDBSEQUENCE
: /* 5 */
1109 return SNMP_INTEGER (lsah
->ls_seqnum
);
1111 case OSPFLSDBAGE
: /* 6 */
1112 return SNMP_INTEGER (lsah
->ls_age
);
1114 case OSPFLSDBCHECKSUM
: /* 7 */
1115 return SNMP_INTEGER (lsah
->checksum
);
1117 case OSPFLSDBADVERTISEMENT
: /* 8 */
1118 *var_len
= ntohs (lsah
->length
);
1119 return (u_char
*) lsah
;
1128 struct ospf_area_range
*
1129 ospfAreaRangeLookup (struct variable
*v
, oid
*name
, size_t *length
,
1130 struct in_addr
*area_id
, struct in_addr
*range_net
,
1137 struct ospf_area
*area
;
1138 struct ospf_area_range
*range
;
1139 struct prefix_ipv4 p
;
1141 p
.prefixlen
= IPV4_MAX_BITLEN
;
1143 ospf
= ospf_lookup ();
1147 /* Area ID + Range Network. */
1148 if (v
->namelen
+ IN_ADDR_SIZE
+ IN_ADDR_SIZE
!= *length
)
1151 /* Set OID offset for Area ID. */
1152 offset
= name
+ v
->namelen
;
1154 /* Lookup area first. */
1155 oid2in_addr (offset
, IN_ADDR_SIZE
, area_id
);
1157 area
= ospf_area_lookup_by_area_id (ospf
, *area_id
);
1161 offset
+= IN_ADDR_SIZE
;
1163 /* Lookup area range. */
1164 oid2in_addr (offset
, IN_ADDR_SIZE
, range_net
);
1165 p
.prefix
= *range_net
;
1167 return ospf_area_range_lookup (area
, &p
);
1171 /* Set OID offset for Area ID. */
1172 offset
= name
+ v
->namelen
;
1173 offsetlen
= *length
- v
->namelen
;
1176 if (len
> IN_ADDR_SIZE
)
1179 oid2in_addr (offset
, len
, area_id
);
1181 /* First we search area. */
1182 if (len
== IN_ADDR_SIZE
)
1183 area
= ospf_area_lookup_by_area_id (ospf
,*area_id
);
1185 area
= ospf_area_lookup_next (ospf
, area_id
, len
== 0 ? 1 : 0);
1192 offset
+= IN_ADDR_SIZE
;
1193 offsetlen
-= IN_ADDR_SIZE
;
1198 if (len
> IN_ADDR_SIZE
)
1201 oid2in_addr (offset
, len
, range_net
);
1203 range
= ospf_area_range_lookup_next (area
, range_net
,
1208 /* Fill in length. */
1209 *length
= v
->namelen
+ IN_ADDR_SIZE
+ IN_ADDR_SIZE
;
1211 /* Fill in value. */
1212 offset
= name
+ v
->namelen
;
1213 oid_copy_addr (offset
, area_id
, IN_ADDR_SIZE
);
1214 offset
+= IN_ADDR_SIZE
;
1215 oid_copy_addr (offset
, range_net
, IN_ADDR_SIZE
);
1220 while ((area
= ospf_area_lookup_next (ospf
, area_id
, 0)) != NULL
);
1226 ospfAreaRangeEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
1227 size_t *var_len
, WriteMethod
**write_method
)
1229 struct ospf_area_range
*range
;
1230 struct in_addr area_id
;
1231 struct in_addr range_net
;
1232 struct in_addr mask
;
1235 /* Check OSPF instance. */
1236 ospf
= ospf_lookup ();
1240 memset (&area_id
, 0, IN_ADDR_SIZE
);
1241 memset (&range_net
, 0, IN_ADDR_SIZE
);
1243 range
= ospfAreaRangeLookup (v
, name
, length
, &area_id
, &range_net
, exact
);
1247 /* Convert prefixlen to network mask format. */
1248 masklen2ip (range
->subst_masklen
, &mask
);
1250 /* Return the current value of the variable */
1253 case OSPFAREARANGEAREAID
: /* 1 */
1254 return SNMP_IPADDRESS (area_id
);
1256 case OSPFAREARANGENET
: /* 2 */
1257 return SNMP_IPADDRESS (range_net
);
1259 case OSPFAREARANGEMASK
: /* 3 */
1260 return SNMP_IPADDRESS (mask
);
1262 case OSPFAREARANGESTATUS
: /* 4 */
1263 return SNMP_INTEGER (SNMP_VALID
);
1265 case OSPFAREARANGEEFFECT
: /* 5 */
1266 #define OSPF_advertiseMatching 1
1267 #define OSPF_doNotAdvertiseMatching 2
1268 return SNMP_INTEGER (OSPF_advertiseMatching
);
1277 struct ospf_nbr_nbma
*
1278 ospf_nbr_nbma_lookup_next (struct ospf
*ospf
, struct in_addr
*nbr_addr
,
1281 struct route_node
*rn
;
1282 struct ospf_nbr_nbma
*nbr_nbma
;
1283 struct ospf_nbr_nbma
*min
= NULL
;
1285 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
1286 if ((nbr_nbma
= rn
->info
) != NULL
1287 && nbr_nbma
->nbr
!= nbr_nbma
->oi
->nbr_self
/* just make sure */
1288 && nbr_nbma
->nbr
->state
!= NSM_Down
/* xxx */
1289 && nbr_nbma
->addr
.s_addr
!= 0)
1295 else if (ntohl (nbr_nbma
->addr
.s_addr
) < ntohl (min
->addr
.s_addr
))
1298 else if (ntohl (nbr_nbma
->addr
.s_addr
) > ntohl (nbr_addr
->s_addr
))
1302 else if (ntohl (nbr_nbma
->addr
.s_addr
) < ntohl (min
->addr
.s_addr
))
1309 *nbr_addr
= min
->addr
;
1316 struct ospf_nbr_nbma
*
1317 ospfHostLookup (struct variable
*v
, oid
*name
, size_t *length
,
1318 struct in_addr
*addr
, int exact
)
1321 struct ospf_nbr_nbma
*nbr_nbma
;
1324 ospf
= ospf_lookup ();
1330 /* INDEX { ospfHostIpAddress, ospfHostTOS } */
1331 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ 1)
1334 /* Check ospfHostTOS. */
1335 if (name
[*length
- 1] != 0)
1338 oid2in_addr (name
+ v
->namelen
, IN_ADDR_SIZE
, addr
);
1340 nbr_nbma
= ospf_nbr_nbma_lookup (ospf
, *addr
);
1346 len
= *length
- v
->namelen
;
1350 oid2in_addr (name
+ v
->namelen
, len
, addr
);
1352 nbr_nbma
= ospf_nbr_nbma_lookup_next (ospf
, addr
, len
== 0 ? 1 : 0);
1354 if (nbr_nbma
== NULL
)
1357 oid_copy_addr (name
+ v
->namelen
, addr
, IN_ADDR_SIZE
);
1360 name
[v
->namelen
+ IN_ADDR_SIZE
] = 0;
1362 *length
= v
->namelen
+ IN_ADDR_SIZE
+ 1;
1370 ospfHostEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
1371 size_t *var_len
, WriteMethod
**write_method
)
1373 struct ospf_nbr_nbma
*nbr_nbma
;
1374 struct ospf_interface
*oi
;
1375 struct in_addr addr
;
1378 /* Check OSPF instance. */
1379 ospf
= ospf_lookup ();
1383 memset (&addr
, 0, sizeof (struct in_addr
));
1385 nbr_nbma
= ospfHostLookup (v
, name
, length
, &addr
, exact
);
1386 if (nbr_nbma
== NULL
)
1391 /* Return the current value of the variable */
1394 case OSPFHOSTIPADDRESS
: /* 1 */
1395 return SNMP_IPADDRESS (nbr_nbma
->addr
);
1397 case OSPFHOSTTOS
: /* 2 */
1398 return SNMP_INTEGER (0);
1400 case OSPFHOSTMETRIC
: /* 3 */
1402 return SNMP_INTEGER (oi
->output_cost
);
1404 return SNMP_INTEGER (1);
1406 case OSPFHOSTSTATUS
: /* 4 */
1407 return SNMP_INTEGER (SNMP_VALID
);
1409 case OSPFHOSTAREAID
: /* 5 */
1411 return SNMP_IPADDRESS (oi
->area
->area_id
);
1413 return SNMP_IPADDRESS (ospf_empty_addr
);
1422 struct list
*ospf_snmp_iflist
;
1426 struct in_addr addr
;
1427 unsigned int ifindex
;
1428 struct interface
*ifp
;
1431 struct ospf_snmp_if
*
1434 struct ospf_snmp_if
*osif
;
1436 osif
= XMALLOC (0, sizeof (struct ospf_snmp_if
));
1437 memset (osif
, 0, sizeof (struct ospf_snmp_if
));
1442 ospf_snmp_if_free (struct ospf_snmp_if
*osif
)
1448 ospf_snmp_if_delete (struct interface
*ifp
)
1450 struct listnode
*nn
;
1451 struct ospf_snmp_if
*osif
;
1453 LIST_LOOP (ospf_snmp_iflist
, osif
, nn
)
1455 if (osif
->ifp
== ifp
)
1457 list_delete_node (ospf_snmp_iflist
, nn
);
1458 ospf_snmp_if_free (osif
);
1465 ospf_snmp_if_update (struct interface
*ifp
)
1467 struct listnode
*nn
;
1468 struct listnode
*pn
;
1469 struct connected
*ifc
;
1471 struct ospf_snmp_if
*osif
;
1472 struct in_addr
*addr
;
1473 unsigned int ifindex
;
1475 ospf_snmp_if_delete (ifp
);
1481 /* Lookup first IPv4 address entry. */
1482 LIST_LOOP (ifp
->connected
, ifc
, nn
)
1484 if (if_is_pointopoint (ifp
))
1485 p
= ifc
->destination
;
1489 if (p
->family
== AF_INET
)
1491 addr
= &p
->u
.prefix4
;
1496 ifindex
= ifp
->ifindex
;
1498 /* Add interface to the list. */
1500 LIST_LOOP (ospf_snmp_iflist
, osif
, nn
)
1504 if (ntohl (osif
->addr
.s_addr
) > ntohl (addr
->s_addr
))
1509 /* Unnumbered interface. */
1510 if (osif
->addr
.s_addr
!= 0 || osif
->ifindex
> ifindex
)
1516 osif
= ospf_snmp_if_new ();
1520 osif
->ifindex
= ifindex
;
1523 listnode_add_after (ospf_snmp_iflist
, pn
, osif
);
1527 ospf_snmp_if_lookup (struct in_addr
*ifaddr
, unsigned int *ifindex
)
1529 struct listnode
*nn
;
1530 struct ospf_snmp_if
*osif
;
1532 LIST_LOOP (ospf_snmp_iflist
, osif
, nn
)
1536 if (IPV4_ADDR_SAME (&osif
->addr
, ifaddr
))
1541 if (osif
->ifindex
== *ifindex
)
1549 ospf_snmp_if_lookup_next (struct in_addr
*ifaddr
, unsigned int *ifindex
,
1550 int ifaddr_next
, int ifindex_next
)
1552 struct ospf_snmp_if
*osif
;
1553 struct listnode
*nn
;
1557 nn
= listhead (ospf_snmp_iflist
);
1560 osif
= getdata (nn
);
1561 *ifaddr
= osif
->addr
;
1562 *ifindex
= osif
->ifindex
;
1568 LIST_LOOP (ospf_snmp_iflist
, osif
, nn
)
1572 if (ntohl (osif
->addr
.s_addr
) > ntohl (ifaddr
->s_addr
))
1574 *ifaddr
= osif
->addr
;
1575 *ifindex
= osif
->ifindex
;
1581 if (osif
->ifindex
> *ifindex
|| osif
->addr
.s_addr
)
1583 *ifaddr
= osif
->addr
;
1584 *ifindex
= osif
->ifindex
;
1593 ospf_snmp_iftype (struct interface
*ifp
)
1595 #define ospf_snmp_iftype_broadcast 1
1596 #define ospf_snmp_iftype_nbma 2
1597 #define ospf_snmp_iftype_pointToPoint 3
1598 #define ospf_snmp_iftype_pointToMultipoint 5
1599 if (if_is_broadcast (ifp
))
1600 return ospf_snmp_iftype_broadcast
;
1601 if (if_is_pointopoint (ifp
))
1602 return ospf_snmp_iftype_pointToPoint
;
1603 return ospf_snmp_iftype_broadcast
;
1607 ospfIfLookup (struct variable
*v
, oid
*name
, size_t *length
,
1608 struct in_addr
*ifaddr
, unsigned int *ifindex
, int exact
)
1611 int ifaddr_next
= 0;
1612 int ifindex_next
= 0;
1613 struct interface
*ifp
;
1618 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ 1)
1621 oid2in_addr (name
+ v
->namelen
, IN_ADDR_SIZE
, ifaddr
);
1622 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
1624 return ospf_snmp_if_lookup (ifaddr
, ifindex
);
1628 len
= *length
- v
->namelen
;
1629 if (len
>= IN_ADDR_SIZE
)
1634 oid2in_addr (name
+ v
->namelen
, len
, ifaddr
);
1636 len
= *length
- v
->namelen
- IN_ADDR_SIZE
;
1643 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
1645 ifp
= ospf_snmp_if_lookup_next (ifaddr
, ifindex
, ifaddr_next
,
1649 *length
= v
->namelen
+ IN_ADDR_SIZE
+ 1;
1650 offset
= name
+ v
->namelen
;
1651 oid_copy_addr (offset
, ifaddr
, IN_ADDR_SIZE
);
1652 offset
+= IN_ADDR_SIZE
;
1661 ospfIfEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
1662 size_t *var_len
, WriteMethod
**write_method
)
1664 struct interface
*ifp
;
1665 unsigned int ifindex
;
1666 struct in_addr ifaddr
;
1667 struct ospf_interface
*oi
;
1671 memset (&ifaddr
, 0, sizeof (struct in_addr
));
1673 /* Check OSPF instance. */
1674 ospf
= ospf_lookup ();
1678 ifp
= ospfIfLookup (v
, name
, length
, &ifaddr
, &ifindex
, exact
);
1682 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, ifaddr
);
1686 /* Return the current value of the variable */
1689 case OSPFIFIPADDRESS
: /* 1 */
1690 return SNMP_IPADDRESS (ifaddr
);
1692 case OSPFADDRESSLESSIF
: /* 2 */
1693 return SNMP_INTEGER (ifindex
);
1695 case OSPFIFAREAID
: /* 3 */
1697 return SNMP_IPADDRESS (oi
->area
->area_id
);
1699 return SNMP_IPADDRESS (ospf_empty_addr
);
1701 case OSPFIFTYPE
: /* 4 */
1702 return SNMP_INTEGER (ospf_snmp_iftype (ifp
));
1704 case OSPFIFADMINSTAT
: /* 5 */
1706 return SNMP_INTEGER (OSPF_STATUS_ENABLED
);
1708 return SNMP_INTEGER (OSPF_STATUS_DISABLED
);
1710 case OSPFIFRTRPRIORITY
: /* 6 */
1711 return SNMP_INTEGER (PRIORITY (oi
));
1713 case OSPFIFTRANSITDELAY
: /* 7 */
1714 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, transmit_delay
));
1716 case OSPFIFRETRANSINTERVAL
: /* 8 */
1717 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, retransmit_interval
));
1719 case OSPFIFHELLOINTERVAL
: /* 9 */
1720 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, v_hello
));
1722 case OSPFIFRTRDEADINTERVAL
: /* 10 */
1723 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, v_wait
));
1725 case OSPFIFPOLLINTERVAL
: /* 11 */
1726 return SNMP_INTEGER (OSPF_POLL_INTERVAL_DEFAULT
);
1728 case OSPFIFSTATE
: /* 12 */
1729 return SNMP_INTEGER (oi
->state
);
1731 case OSPFIFDESIGNATEDROUTER
: /* 13 */
1732 return SNMP_IPADDRESS (DR (oi
));
1734 case OSPFIFBACKUPDESIGNATEDROUTER
: /* 14 */
1735 return SNMP_IPADDRESS (BDR (oi
));
1737 case OSPFIFEVENTS
: /* 15 */
1738 return SNMP_INTEGER (oi
->state_change
);
1740 case OSPFIFAUTHKEY
: /* 16 */
1742 return (u_char
*) OSPF_IF_PARAM (oi
, auth_simple
);
1744 case OSPFIFSTATUS
: /* 17 */
1745 return SNMP_INTEGER (SNMP_VALID
);
1747 case OSPFIFMULTICASTFORWARDING
: /* 18 */
1748 #define ospf_snmp_multiforward_blocked 1
1749 #define ospf_snmp_multiforward_multicast 2
1750 #define ospf_snmp_multiforward_unicast 3
1751 return SNMP_INTEGER (ospf_snmp_multiforward_blocked
);
1753 case OSPFIFDEMAND
: /* 19 */
1754 return SNMP_INTEGER (SNMP_FALSE
);
1756 case OSPFIFAUTHTYPE
: /* 20 */
1758 return SNMP_INTEGER (oi
->area
->auth_type
);
1760 return SNMP_INTEGER (0);
1769 #define OSPF_SNMP_METRIC_VALUE 1
1772 ospfIfMetricLookup (struct variable
*v
, oid
*name
, size_t *length
,
1773 struct in_addr
*ifaddr
, unsigned int *ifindex
, int exact
)
1776 int ifaddr_next
= 0;
1777 int ifindex_next
= 0;
1778 struct interface
*ifp
;
1784 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ 1 + 1)
1787 oid2in_addr (name
+ v
->namelen
, IN_ADDR_SIZE
, ifaddr
);
1788 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
1789 metric
= name
[v
->namelen
+ IN_ADDR_SIZE
+ 1];
1791 if (metric
!= OSPF_SNMP_METRIC_VALUE
)
1794 return ospf_snmp_if_lookup (ifaddr
, ifindex
);
1798 len
= *length
- v
->namelen
;
1799 if (len
>= IN_ADDR_SIZE
)
1804 oid2in_addr (name
+ v
->namelen
, len
, ifaddr
);
1806 len
= *length
- v
->namelen
- IN_ADDR_SIZE
;
1813 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
1815 ifp
= ospf_snmp_if_lookup_next (ifaddr
, ifindex
, ifaddr_next
,
1819 *length
= v
->namelen
+ IN_ADDR_SIZE
+ 1 + 1;
1820 offset
= name
+ v
->namelen
;
1821 oid_copy_addr (offset
, ifaddr
, IN_ADDR_SIZE
);
1822 offset
+= IN_ADDR_SIZE
;
1825 *offset
= OSPF_SNMP_METRIC_VALUE
;
1833 ospfIfMetricEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
1834 size_t *var_len
, WriteMethod
**write_method
)
1836 /* Currently we support metric 1 only. */
1837 struct interface
*ifp
;
1838 unsigned int ifindex
;
1839 struct in_addr ifaddr
;
1840 struct ospf_interface
*oi
;
1844 memset (&ifaddr
, 0, sizeof (struct in_addr
));
1846 /* Check OSPF instance. */
1847 ospf
= ospf_lookup ();
1851 ifp
= ospfIfMetricLookup (v
, name
, length
, &ifaddr
, &ifindex
, exact
);
1855 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, ifaddr
);
1859 /* Return the current value of the variable */
1862 case OSPFIFMETRICIPADDRESS
:
1863 return SNMP_IPADDRESS (ifaddr
);
1865 case OSPFIFMETRICADDRESSLESSIF
:
1866 return SNMP_INTEGER (ifindex
);
1868 case OSPFIFMETRICTOS
:
1869 return SNMP_INTEGER (0);
1871 case OSPFIFMETRICVALUE
:
1872 return SNMP_INTEGER (OSPF_SNMP_METRIC_VALUE
);
1874 case OSPFIFMETRICSTATUS
:
1875 return SNMP_INTEGER (1);
1884 struct route_table
*ospf_snmp_vl_table
;
1887 ospf_snmp_vl_add (struct ospf_vl_data
*vl_data
)
1889 struct prefix_ls lp
;
1890 struct route_node
*rn
;
1892 memset (&lp
, 0, sizeof (struct prefix_ls
));
1895 lp
.id
= vl_data
->vl_area_id
;
1896 lp
.adv_router
= vl_data
->vl_peer
;
1898 rn
= route_node_get (ospf_snmp_vl_table
, (struct prefix
*) &lp
);
1903 ospf_snmp_vl_delete (struct ospf_vl_data
*vl_data
)
1905 struct prefix_ls lp
;
1906 struct route_node
*rn
;
1908 memset (&lp
, 0, sizeof (struct prefix_ls
));
1911 lp
.id
= vl_data
->vl_area_id
;
1912 lp
.adv_router
= vl_data
->vl_peer
;
1914 rn
= route_node_lookup (ospf_snmp_vl_table
, (struct prefix
*) &lp
);
1918 route_unlock_node (rn
);
1919 route_unlock_node (rn
);
1922 struct ospf_vl_data
*
1923 ospf_snmp_vl_lookup (struct in_addr
*area_id
, struct in_addr
*neighbor
)
1925 struct prefix_ls lp
;
1926 struct route_node
*rn
;
1927 struct ospf_vl_data
*vl_data
;
1929 memset (&lp
, 0, sizeof (struct prefix_ls
));
1933 lp
.adv_router
= *neighbor
;
1935 rn
= route_node_lookup (ospf_snmp_vl_table
, (struct prefix
*) &lp
);
1939 route_unlock_node (rn
);
1945 struct ospf_vl_data
*
1946 ospf_snmp_vl_lookup_next (struct in_addr
*area_id
, struct in_addr
*neighbor
,
1949 struct prefix_ls lp
;
1950 struct route_node
*rn
;
1951 struct ospf_vl_data
*vl_data
;
1953 memset (&lp
, 0, sizeof (struct prefix_ls
));
1957 lp
.adv_router
= *neighbor
;
1960 rn
= route_top (ospf_snmp_vl_table
);
1963 rn
= route_node_get (ospf_snmp_vl_table
, (struct prefix
*) &lp
);
1964 rn
= route_next (rn
);
1967 for (; rn
; rn
= route_next (rn
))
1974 *area_id
= vl_data
->vl_area_id
;
1975 *neighbor
= vl_data
->vl_peer
;
1976 route_unlock_node (rn
);
1982 struct ospf_vl_data
*
1983 ospfVirtIfLookup (struct variable
*v
, oid
*name
, size_t *length
,
1984 struct in_addr
*area_id
, struct in_addr
*neighbor
, int exact
)
1988 struct ospf_vl_data
*vl_data
;
1992 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ IN_ADDR_SIZE
)
1995 oid2in_addr (name
+ v
->namelen
, IN_ADDR_SIZE
, area_id
);
1996 oid2in_addr (name
+ v
->namelen
+ IN_ADDR_SIZE
, IN_ADDR_SIZE
, neighbor
);
1998 return ospf_snmp_vl_lookup (area_id
, neighbor
);
2004 len
= *length
- v
->namelen
;
2007 if (len
> IN_ADDR_SIZE
)
2009 oid2in_addr (name
+ v
->namelen
, len
, area_id
);
2011 len
= *length
- v
->namelen
- IN_ADDR_SIZE
;
2012 if (len
> IN_ADDR_SIZE
)
2014 oid2in_addr (name
+ v
->namelen
+ IN_ADDR_SIZE
, len
, neighbor
);
2016 vl_data
= ospf_snmp_vl_lookup_next (area_id
, neighbor
, first
);
2020 *length
= v
->namelen
+ IN_ADDR_SIZE
+ IN_ADDR_SIZE
;
2021 oid_copy_addr (name
+ v
->namelen
, area_id
, IN_ADDR_SIZE
);
2022 oid_copy_addr (name
+ v
->namelen
+ IN_ADDR_SIZE
, neighbor
,
2031 ospfVirtIfEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
2032 size_t *var_len
, WriteMethod
**write_method
)
2034 struct ospf_vl_data
*vl_data
;
2035 struct ospf_interface
*oi
;
2036 struct in_addr area_id
;
2037 struct in_addr neighbor
;
2039 memset (&area_id
, 0, sizeof (struct in_addr
));
2040 memset (&neighbor
, 0, sizeof (struct in_addr
));
2042 vl_data
= ospfVirtIfLookup (v
, name
, length
, &area_id
, &neighbor
, exact
);
2045 oi
= vl_data
->vl_oi
;
2049 /* Return the current value of the variable */
2052 case OSPFVIRTIFAREAID
:
2053 return SNMP_IPADDRESS (area_id
);
2055 case OSPFVIRTIFNEIGHBOR
:
2056 return SNMP_IPADDRESS (neighbor
);
2058 case OSPFVIRTIFTRANSITDELAY
:
2059 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, transmit_delay
));
2061 case OSPFVIRTIFRETRANSINTERVAL
:
2062 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, retransmit_interval
));
2064 case OSPFVIRTIFHELLOINTERVAL
:
2065 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, v_hello
));
2067 case OSPFVIRTIFRTRDEADINTERVAL
:
2068 return SNMP_INTEGER (OSPF_IF_PARAM (oi
, v_wait
));
2070 case OSPFVIRTIFSTATE
:
2071 return SNMP_INTEGER (oi
->state
);
2073 case OSPFVIRTIFEVENTS
:
2074 return SNMP_INTEGER (oi
->state_change
);
2076 case OSPFVIRTIFAUTHKEY
:
2078 return (u_char
*) OSPF_IF_PARAM (oi
, auth_simple
);
2080 case OSPFVIRTIFSTATUS
:
2081 return SNMP_INTEGER (SNMP_VALID
);
2083 case OSPFVIRTIFAUTHTYPE
:
2085 return SNMP_INTEGER (oi
->area
->auth_type
);
2087 return SNMP_INTEGER (0);
2096 struct ospf_neighbor
*
2097 ospf_snmp_nbr_lookup (struct ospf
*ospf
, struct in_addr
*nbr_addr
,
2098 unsigned int *ifindex
)
2100 struct listnode
*nn
;
2101 struct ospf_interface
*oi
;
2102 struct ospf_neighbor
*nbr
;
2103 struct route_node
*rn
;
2105 LIST_LOOP (ospf
->oiflist
, oi
, nn
)
2107 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
2108 if ((nbr
= rn
->info
) != NULL
2109 && nbr
!= oi
->nbr_self
2110 && nbr
->state
!= NSM_Down
2111 && nbr
->src
.s_addr
!= 0)
2113 if (IPV4_ADDR_SAME (&nbr
->src
, nbr_addr
))
2115 route_unlock_node (rn
);
2123 struct ospf_neighbor
*
2124 ospf_snmp_nbr_lookup_next (struct in_addr
*nbr_addr
, unsigned int *ifindex
,
2127 struct listnode
*nn
;
2128 struct ospf_interface
*oi
;
2129 struct ospf_neighbor
*nbr
;
2130 struct route_node
*rn
;
2131 struct ospf_neighbor
*min
= NULL
;
2132 struct ospf
*ospf
= ospf
;
2134 ospf
= ospf_lookup ();
2135 LIST_LOOP (ospf
->oiflist
, oi
, nn
)
2137 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
2138 if ((nbr
= rn
->info
) != NULL
2139 && nbr
!= oi
->nbr_self
2140 && nbr
->state
!= NSM_Down
2141 && nbr
->src
.s_addr
!= 0)
2147 else if (ntohl (nbr
->src
.s_addr
) < ntohl (min
->src
.s_addr
))
2150 else if (ntohl (nbr
->src
.s_addr
) > ntohl (nbr_addr
->s_addr
))
2154 else if (ntohl (nbr
->src
.s_addr
) < ntohl (min
->src
.s_addr
))
2161 *nbr_addr
= min
->src
;
2168 struct ospf_neighbor
*
2169 ospfNbrLookup (struct variable
*v
, oid
*name
, size_t *length
,
2170 struct in_addr
*nbr_addr
, unsigned int *ifindex
, int exact
)
2174 struct ospf_neighbor
*nbr
;
2177 ospf
= ospf_lookup ();
2181 if (*length
!= v
->namelen
+ IN_ADDR_SIZE
+ 1)
2184 oid2in_addr (name
+ v
->namelen
, IN_ADDR_SIZE
, nbr_addr
);
2185 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
2187 return ospf_snmp_nbr_lookup (ospf
, nbr_addr
, ifindex
);
2192 len
= *length
- v
->namelen
;
2197 if (len
> IN_ADDR_SIZE
)
2200 oid2in_addr (name
+ v
->namelen
, len
, nbr_addr
);
2202 len
= *length
- v
->namelen
- IN_ADDR_SIZE
;
2204 *ifindex
= name
[v
->namelen
+ IN_ADDR_SIZE
];
2206 nbr
= ospf_snmp_nbr_lookup_next (nbr_addr
, ifindex
, first
);
2210 *length
= v
->namelen
+ IN_ADDR_SIZE
+ 1;
2211 oid_copy_addr (name
+ v
->namelen
, nbr_addr
, IN_ADDR_SIZE
);
2212 name
[v
->namelen
+ IN_ADDR_SIZE
] = *ifindex
;
2220 ospfNbrEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
2221 size_t *var_len
, WriteMethod
**write_method
)
2223 struct in_addr nbr_addr
;
2224 unsigned int ifindex
;
2225 struct ospf_neighbor
*nbr
;
2226 struct ospf_interface
*oi
;
2228 memset (&nbr_addr
, 0, sizeof (struct in_addr
));
2231 nbr
= ospfNbrLookup (v
, name
, length
, &nbr_addr
, &ifindex
, exact
);
2238 /* Return the current value of the variable */
2242 return SNMP_IPADDRESS (nbr_addr
);
2244 case OSPFNBRADDRESSLESSINDEX
:
2245 return SNMP_INTEGER (ifindex
);
2248 return SNMP_IPADDRESS (nbr
->router_id
);
2250 case OSPFNBROPTIONS
:
2251 return SNMP_INTEGER (oi
->nbr_self
->options
);
2253 case OSPFNBRPRIORITY
:
2254 return SNMP_INTEGER (nbr
->priority
);
2257 return SNMP_INTEGER (nbr
->state
);
2260 return SNMP_INTEGER (nbr
->state_change
);
2262 case OSPFNBRLSRETRANSQLEN
:
2263 return SNMP_INTEGER (ospf_ls_retransmit_count (nbr
));
2265 case OSPFNBMANBRSTATUS
:
2266 return SNMP_INTEGER (SNMP_VALID
);
2268 case OSPFNBMANBRPERMANENCE
:
2269 return SNMP_INTEGER (2);
2271 case OSPFNBRHELLOSUPPRESSED
:
2272 return SNMP_INTEGER (SNMP_FALSE
);
2282 ospfVirtNbrEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
2283 size_t *var_len
, WriteMethod
**write_method
)
2285 struct ospf_vl_data
*vl_data
;
2286 struct in_addr area_id
;
2287 struct in_addr neighbor
;
2290 memset (&area_id
, 0, sizeof (struct in_addr
));
2291 memset (&neighbor
, 0, sizeof (struct in_addr
));
2293 /* Check OSPF instance. */
2294 ospf
= ospf_lookup ();
2298 vl_data
= ospfVirtIfLookup (v
, name
, length
, &area_id
, &neighbor
, exact
);
2302 /* Return the current value of the variable */
2305 case OSPFVIRTNBRAREA
:
2306 return (u_char
*) NULL
;
2308 case OSPFVIRTNBRRTRID
:
2309 return (u_char
*) NULL
;
2311 case OSPFVIRTNBRIPADDR
:
2312 return (u_char
*) NULL
;
2314 case OSPFVIRTNBROPTIONS
:
2315 return (u_char
*) NULL
;
2317 case OSPFVIRTNBRSTATE
:
2318 return (u_char
*) NULL
;
2320 case OSPFVIRTNBREVENTS
:
2321 return (u_char
*) NULL
;
2323 case OSPFVIRTNBRLSRETRANSQLEN
:
2324 return (u_char
*) NULL
;
2326 case OSPFVIRTNBRHELLOSUPPRESSED
:
2327 return (u_char
*) NULL
;
2337 ospfExtLsdbLookup (struct variable
*v
, oid
*name
, size_t *length
, u_char
*type
,
2338 struct in_addr
*ls_id
, struct in_addr
*router_id
, int exact
)
2345 struct ospf_lsa
*lsa
;
2348 ospf
= ospf_lookup ();
2351 if (*length
!= v
->namelen
+ 1 + IN_ADDR_SIZE
+ IN_ADDR_SIZE
)
2354 offset
= name
+ v
->namelen
;
2356 /* Make it sure given value match to type. */
2360 if (lsa_type
!= *type
)
2364 oid2in_addr (offset
, IN_ADDR_SIZE
, ls_id
);
2365 offset
+= IN_ADDR_SIZE
;
2368 oid2in_addr (offset
, IN_ADDR_SIZE
, router_id
);
2370 return ospf_lsdb_lookup_by_id (ospf
->lsdb
, *type
, *ls_id
, *router_id
);
2374 /* Get variable length. */
2376 offset
= name
+ v
->namelen
;
2377 offsetlen
= *length
- v
->namelen
;
2379 /* LSA type value. */
2384 if (offsetlen
<= 0 || lsa_type
< OSPF_AS_EXTERNAL_LSA
)
2389 if (len
> IN_ADDR_SIZE
)
2392 oid2in_addr (offset
, len
, ls_id
);
2394 offset
+= IN_ADDR_SIZE
;
2395 offsetlen
-= IN_ADDR_SIZE
;
2399 if (len
> IN_ADDR_SIZE
)
2402 oid2in_addr (offset
, len
, router_id
);
2404 lsa
= ospf_lsdb_lookup_by_id_next (ospf
->lsdb
, *type
, *ls_id
,
2409 /* Fill in length. */
2410 *length
= v
->namelen
+ 1 + IN_ADDR_SIZE
+ IN_ADDR_SIZE
;
2412 /* Fill in value. */
2413 offset
= name
+ v
->namelen
;
2415 *offset
= OSPF_AS_EXTERNAL_LSA
;
2417 oid_copy_addr (offset
, &lsa
->data
->id
, IN_ADDR_SIZE
);
2418 offset
+= IN_ADDR_SIZE
;
2419 oid_copy_addr (offset
, &lsa
->data
->adv_router
, IN_ADDR_SIZE
);
2428 ospfExtLsdbEntry (struct variable
*v
, oid
*name
, size_t *length
, int exact
,
2429 size_t *var_len
, WriteMethod
**write_method
)
2431 struct ospf_lsa
*lsa
;
2432 struct lsa_header
*lsah
;
2434 struct in_addr ls_id
;
2435 struct in_addr router_id
;
2438 type
= OSPF_AS_EXTERNAL_LSA
;
2439 memset (&ls_id
, 0, sizeof (struct in_addr
));
2440 memset (&router_id
, 0, sizeof (struct in_addr
));
2442 /* Check OSPF instance. */
2443 ospf
= ospf_lookup ();
2447 lsa
= ospfExtLsdbLookup (v
, name
, length
, &type
, &ls_id
, &router_id
, exact
);
2453 /* Return the current value of the variable */
2456 case OSPFEXTLSDBTYPE
:
2457 return SNMP_INTEGER (OSPF_AS_EXTERNAL_LSA
);
2459 case OSPFEXTLSDBLSID
:
2460 return SNMP_IPADDRESS (lsah
->id
);
2462 case OSPFEXTLSDBROUTERID
:
2463 return SNMP_IPADDRESS (lsah
->adv_router
);
2465 case OSPFEXTLSDBSEQUENCE
:
2466 return SNMP_INTEGER (lsah
->ls_seqnum
);
2468 case OSPFEXTLSDBAGE
:
2469 return SNMP_INTEGER (lsah
->ls_age
);
2471 case OSPFEXTLSDBCHECKSUM
:
2472 return SNMP_INTEGER (lsah
->checksum
);
2474 case OSPFEXTLSDBADVERTISEMENT
:
2475 *var_len
= ntohs (lsah
->length
);
2476 return (u_char
*) lsah
;
2486 ospfAreaAggregateEntry (struct variable
*v
, oid
*name
, size_t *length
,
2487 int exact
, size_t *var_len
, WriteMethod
**write_method
)
2489 /* Return the current value of the variable */
2492 case OSPFAREAAGGREGATEAREAID
:
2493 return (u_char
*) NULL
;
2495 case OSPFAREAAGGREGATELSDBTYPE
:
2496 return (u_char
*) NULL
;
2498 case OSPFAREAAGGREGATENET
:
2499 return (u_char
*) NULL
;
2501 case OSPFAREAAGGREGATEMASK
:
2502 return (u_char
*) NULL
;
2504 case OSPFAREAAGGREGATESTATUS
:
2505 return (u_char
*) NULL
;
2507 case OSPFAREAAGGREGATEEFFECT
:
2508 return (u_char
*) NULL
;
2517 /* Register OSPF2-MIB. */
2521 ospf_snmp_iflist
= list_new ();
2522 ospf_snmp_vl_table
= route_table_init ();
2523 smux_init (ospfd_oid
, sizeof (ospfd_oid
) / sizeof (oid
));
2524 REGISTER_MIB("mibII/ospf", ospf_variables
, variable
, ospf_oid
);
2527 #endif /* HAVE_SNMP */