blob: 293d66a12a9d4f2f1d3af21c2294527a06689da5 [file] [log] [blame]
hassoef1bbf52004-10-08 12:04:21 +00001/* OSPFv3 SNMP support
2 * Copyright (C) 2004 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <zebra.h>
23
24#ifdef HAVE_SNMP
25
hassoef1bbf52004-10-08 12:04:21 +000026#include <net-snmp/net-snmp-config.h>
Joakim Tjernlundfb62a3c2008-05-13 20:03:32 +020027#include <net-snmp/net-snmp-includes.h>
hassoef1bbf52004-10-08 12:04:21 +000028
29#include "log.h"
30#include "vty.h"
31#include "linklist.h"
32#include "smux.h"
33
34#include "ospf6_proto.h"
35#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
37#include "ospf6_route.h"
38#include "ospf6_top.h"
39#include "ospf6_area.h"
40#include "ospf6_interface.h"
41#include "ospf6_message.h"
42#include "ospf6_neighbor.h"
43#include "ospf6d.h"
Chris Caputo0be8dfb2009-06-02 18:40:07 +010044#include "ospf6_snmp.h"
hassoef1bbf52004-10-08 12:04:21 +000045
46/* OSPFv3-MIB */
Vincent Bernat0f0ab512012-05-22 13:34:24 +020047#define OSPFv3MIB 1,3,6,1,2,1,191
hassoef1bbf52004-10-08 12:04:21 +000048
hassoef1bbf52004-10-08 12:04:21 +000049/* OSPFv3 MIB General Group values. */
50#define OSPFv3ROUTERID 1
51#define OSPFv3ADMINSTAT 2
52#define OSPFv3VERSIONNUMBER 3
53#define OSPFv3AREABDRRTRSTATUS 4
54#define OSPFv3ASBDRRTRSTATUS 5
55#define OSPFv3ASSCOPELSACOUNT 6
56#define OSPFv3ASSCOPELSACHECKSUMSUM 7
57#define OSPFv3ORIGINATENEWLSAS 8
58#define OSPFv3RXNEWLSAS 9
59#define OSPFv3EXTLSACOUNT 10
60#define OSPFv3EXTAREALSDBLIMIT 11
Vincent Bernat0f0ab512012-05-22 13:34:24 +020061#define OSPFv3EXITOVERFLOWINTERVAL 12
62#define OSPFv3DEMANDEXTENSIONS 13
63#define OSPFv3REFERENCEBANDWIDTH 14
64#define OSPFv3RESTARTSUPPORT 15
65#define OSPFv3RESTARTINTERVAL 16
66#define OSPFv3RESTARTSTRICTLSACHECKING 17
67#define OSPFv3RESTARTSTATUS 18
68#define OSPFv3RESTARTAGE 19
69#define OSPFv3RESTARTEXITREASON 20
70#define OSPFv3NOTIFICATIONENABLE 21
71#define OSPFv3STUBROUTERSUPPORT 22
72#define OSPFv3STUBROUTERADVERTISEMENT 23
73#define OSPFv3DISCONTINUITYTIME 24
74#define OSPFv3RESTARTTIME 25
hassoef1bbf52004-10-08 12:04:21 +000075
Vincent Bernat0f0ab512012-05-22 13:34:24 +020076/* OSPFv3 MIB Area Table values: ospfv3AreaTable */
hassoef1bbf52004-10-08 12:04:21 +000077#define OSPFv3IMPORTASEXTERN 2
hasso2680aa22004-11-25 20:54:46 +000078#define OSPFv3AREASPFRUNS 3
79#define OSPFv3AREABDRRTRCOUNT 4
80#define OSPFv3AREAASBDRRTRCOUNT 5
81#define OSPFv3AREASCOPELSACOUNT 6
82#define OSPFv3AREASCOPELSACKSUMSUM 7
83#define OSPFv3AREASUMMARY 8
Vincent Bernat0f0ab512012-05-22 13:34:24 +020084#define OSPFv3AREAROWSTATUS 9
85#define OSPFv3AREASTUBMETRIC 10
hasso2680aa22004-11-25 20:54:46 +000086#define OSPFv3AREANSSATRANSLATORROLE 11
87#define OSPFv3AREANSSATRANSLATORSTATE 12
Vincent Bernat0f0ab512012-05-22 13:34:24 +020088#define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13
hasso2680aa22004-11-25 20:54:46 +000089#define OSPFv3AREANSSATRANSLATOREVENTS 14
90#define OSPFv3AREASTUBMETRICTYPE 15
Vincent Bernat0f0ab512012-05-22 13:34:24 +020091#define OSPFv3AREATEENABLED 16
hasso2680aa22004-11-25 20:54:46 +000092
Vincent Bernat0f0ab512012-05-22 13:34:24 +020093/* OSPFv3 MIB AS Lsdb Table values: ospfv3AsLsdbTable */
94#define OSPFv3ASLSDBSEQUENCE 4
95#define OSPFv3ASLSDBAGE 5
96#define OSPFv3ASLSDBCHECKSUM 6
97#define OSPFv3ASLSDBADVERTISEMENT 7
98#define OSPFv3ASLSDBTYPEKNOWN 8
99
100/* OSPFv3 MIB Area Lsdb Table values: ospfv3AreaLsdbTable */
hasso2680aa22004-11-25 20:54:46 +0000101#define OSPFv3AREALSDBSEQUENCE 5
102#define OSPFv3AREALSDBAGE 6
103#define OSPFv3AREALSDBCHECKSUM 7
104#define OSPFv3AREALSDBADVERTISEMENT 8
105#define OSPFv3AREALSDBTYPEKNOWN 9
hassoef1bbf52004-10-08 12:04:21 +0000106
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200107/* OSPFv3 MIB Link Lsdb Table values: ospfv3LinkLsdbTable */
108#define OSPFv3LINKLSDBSEQUENCE 6
109#define OSPFv3LINKLSDBAGE 7
110#define OSPFv3LINKLSDBCHECKSUM 8
111#define OSPFv3LINKLSDBADVERTISEMENT 9
112#define OSPFv3LINKLSDBTYPEKNOWN 10
113
114/* OSPFv3 MIB Host Table values: ospfv3HostTable */
115#define OSPFv3HOSTMETRIC 3
116#define OSPFv3HOSTROWSTATUS 4
117#define OSPFv3HOSTAREAID 5
118
119/* OSPFv3 MIB Interface Table values: ospfv3IfTable */
120#define OSPFv3IFAREAID 3
121#define OSPFv3IFTYPE 4
122#define OSPFv3IFADMINSTATUS 5
123#define OSPFv3IFRTRPRIORITY 6
124#define OSPFv3IFTRANSITDELAY 7
125#define OSPFv3IFRETRANSINTERVAL 8
126#define OSPFv3IFHELLOINTERVAL 9
127#define OSPFv3IFRTRDEADINTERVAL 10
128#define OSPFv3IFPOLLINTERVAL 11
129#define OSPFv3IFSTATE 12
130#define OSPFv3IFDESIGNATEDROUTER 13
131#define OSPFv3IFBACKUPDESIGNATEDROUTER 14
132#define OSPFv3IFEVENTS 15
133#define OSPFv3IFROWSTATUS 16
134#define OSPFv3IFDEMAND 17
135#define OSPFv3IFMETRICVALUE 18
136#define OSPFv3IFLINKSCOPELSACOUNT 19
137#define OSPFv3IFLINKLSACKSUMSUM 20
138#define OSPFv3IFDEMANDNBRPROBE 21
139#define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22
140#define OSPFv3IFDEMANDNBRPROBEINTERVAL 23
141#define OSPFv3IFTEDISABLED 24
142#define OSPFv3IFLINKLSASUPPRESSION 25
143
144/* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */
145#define OSPFv3VIRTIFINDEX 3
146#define OSPFv3VIRTIFINSTID 4
147#define OSPFv3VIRTIFTRANSITDELAY 5
148#define OSPFv3VIRTIFRETRANSINTERVAL 6
149#define OSPFv3VIRTIFHELLOINTERVAL 7
150#define OSPFv3VIRTIFRTRDEADINTERVAL 8
151#define OSPFv3VIRTIFSTATE 9
152#define OSPFv3VIRTIFEVENTS 10
153#define OSPFv3VIRTIFROWSTATUS 11
154#define OSPFv3VIRTIFLINKSCOPELSACOUNT 12
155#define OSPFv3VIRTIFLINKLSACKSUMSUM 13
156
157/* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */
158#define OSPFv3NBRADDRESSTYPE 4
159#define OSPFv3NBRADDRESS 5
160#define OSPFv3NBROPTIONS 6
161#define OSPFv3NBRPRIORITY 7
162#define OSPFv3NBRSTATE 8
163#define OSPFv3NBREVENTS 9
164#define OSPFv3NBRLSRETRANSQLEN 10
165#define OSPFv3NBRHELLOSUPPRESSED 11
166#define OSPFv3NBRIFID 12
167#define OSPFv3NBRRESTARTHELPERSTATUS 13
168#define OSPFv3NBRRESTARTHELPERAGE 14
169#define OSPFv3NBRRESTARTHELPEREXITREASON 15
170
171/* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */
172#define OSPFv3CFGNBRPRIORITY 5
173#define OSPFv3CFGNBRROWSTATUS 6
174
175/* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */
176#define OSPFv3VIRTNBRIFINDEX 3
177#define OSPFv3VIRTNBRIFINSTID 4
178#define OSPFv3VIRTNBRADDRESSTYPE 5
179#define OSPFv3VIRTNBRADDRESS 6
180#define OSPFv3VIRTNBROPTIONS 7
181#define OSPFv3VIRTNBRSTATE 8
182#define OSPFv3VIRTNBREVENTS 9
183#define OSPFv3VIRTNBRLSRETRANSQLEN 10
184#define OSPFv3VIRTNBRHELLOSUPPRESSED 11
185#define OSPFv3VIRTNBRIFID 12
186#define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13
187#define OSPFv3VIRTNBRRESTARTHELPERAGE 14
188#define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15
189
190/* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */
191#define OSPFv3AREAAGGREGATEROWSTATUS 6
192#define OSPFv3AREAAGGREGATEEFFECT 7
193#define OSPFv3AREAAGGREGATEROUTETAG 8
194
195/* OSPFv3 MIB Virtual Link Lsdb Table values: ospfv3VirtLinkLsdbTable */
196#define OSPFv3VIRTLINKLSDBSEQUENCE 6
197#define OSPFv3VIRTLINKLSDBAGE 7
198#define OSPFv3VIRTLINKLSDBCHECKSUM 8
199#define OSPFv3VIRTLINKLSDBADVERTISEMENT 9
200#define OSPFv3VIRTLINKLSDBTYPEKNOWN 10
201
hassoef1bbf52004-10-08 12:04:21 +0000202/* SYNTAX Status from OSPF-MIB. */
203#define OSPF_STATUS_ENABLED 1
204#define OSPF_STATUS_DISABLED 2
205
206/* SNMP value hack. */
207#define COUNTER ASN_COUNTER
208#define INTEGER ASN_INTEGER
209#define GAUGE ASN_GAUGE
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200210#define UNSIGNED ASN_UNSIGNED
hassoef1bbf52004-10-08 12:04:21 +0000211#define TIMETICKS ASN_TIMETICKS
212#define IPADDRESS ASN_IPADDRESS
213#define STRING ASN_OCTET_STR
214
215/* For return values e.g. SNMP_INTEGER macro */
216SNMP_LOCAL_VARIABLES
217
hassoef1bbf52004-10-08 12:04:21 +0000218/* OSPFv3-MIB instances. */
219oid ospfv3_oid [] = { OSPFv3MIB };
hassoef1bbf52004-10-08 12:04:21 +0000220
hassoef1bbf52004-10-08 12:04:21 +0000221/* Hook functions. */
Chris Caputo0be8dfb2009-06-02 18:40:07 +0100222static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
223 int, size_t *, WriteMethod **);
224static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
225 int, size_t *, WriteMethod **);
226static u_char *ospfv3AreaLsdbEntry (struct variable *, oid *, size_t *,
227 int, size_t *, WriteMethod **);
Vincent Bernat061bc732012-05-31 20:21:15 +0200228static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *,
229 int, size_t *, WriteMethod **);
hassoef1bbf52004-10-08 12:04:21 +0000230
231struct variable ospfv3_variables[] =
232{
233 /* OSPF general variables */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200234 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000235 3, {1, 1, 1}},
236 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
237 3, {1, 1, 2}},
238 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
239 3, {1, 1, 3}},
240 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
241 3, {1, 1, 4}},
242 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
243 3, {1, 1, 5}},
244 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
245 3, {1, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200246 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000247 3, {1, 1, 7}},
248 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
249 3, {1, 1, 8}},
250 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
251 3, {1, 1, 9}},
252 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
253 3, {1, 1, 10}},
254 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
255 3, {1, 1, 11}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200256 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000257 3, {1, 1, 12}},
hassoef1bbf52004-10-08 12:04:21 +0000258 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200259 3, {1, 1, 13}},
260 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000261 3, {1, 1, 14}},
hassoef1bbf52004-10-08 12:04:21 +0000262 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200263 3, {1, 1, 15}},
264 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
265 3, {1, 1, 16}},
266 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000267 3, {1, 1, 17}},
hassoef1bbf52004-10-08 12:04:21 +0000268 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200269 3, {1, 1, 18}},
270 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000271 3, {1, 1, 19}},
hassoef1bbf52004-10-08 12:04:21 +0000272 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200273 3, {1, 1, 20}},
274 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000275 3, {1, 1, 21}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200276 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
277 3, {1, 1, 22}},
278 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
279 3, {1, 1, 23}},
280 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
281 3, {1, 1, 24}},
282 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
283 3, {1, 1, 25}},
hassoef1bbf52004-10-08 12:04:21 +0000284
285 /* OSPFv3 Area Data Structure */
hasso2680aa22004-11-25 20:54:46 +0000286 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
hassoef1bbf52004-10-08 12:04:21 +0000287 4, {1, 2, 1, 2}},
hasso2680aa22004-11-25 20:54:46 +0000288 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
289 4, {1, 2, 1, 3}},
290 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
291 4, {1, 2, 1, 4}},
292 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
293 4, {1, 2, 1, 5}},
294 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
295 4, {1, 2, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200296 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000297 4, {1, 2, 1, 7}},
298 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
299 4, {1, 2, 1, 8}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200300 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000301 4, {1, 2, 1, 9}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200302 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000303 4, {1, 2, 1, 10}},
304 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
305 4, {1, 2, 1, 11}},
306 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
307 4, {1, 2, 1, 12}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200308 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000309 4, {1, 2, 1, 13}},
310 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
311 4, {1, 2, 1, 14}},
312 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
313 4, {1, 2, 1, 15}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200314 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
315 4, {1, 2, 1, 16}},
hasso2680aa22004-11-25 20:54:46 +0000316
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200317 /* OSPFv3 Area LSDB */
hasso2680aa22004-11-25 20:54:46 +0000318 {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
319 4, {1, 4, 1, 5}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200320 {OSPFv3AREALSDBAGE, UNSIGNED, RONLY, ospfv3AreaLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000321 4, {1, 4, 1, 6}},
322 {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
323 4, {1, 4, 1, 7}},
324 {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
325 4, {1, 4, 1, 8}},
326 {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
327 4, {1, 4, 1, 9}},
328
Vincent Bernat061bc732012-05-31 20:21:15 +0200329 /* OSPFv3 neighbors */
330 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry,
331 4, {1, 9, 1, 4}},
332 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry,
333 4, {1, 9, 1, 5}},
334 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry,
335 4, {1, 9, 1, 6}},
336 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry,
337 4, {1, 9, 1, 7}},
338 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry,
339 4, {1, 9, 1, 8}},
340 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry,
341 4, {1, 9, 1, 9}},
342 {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry,
343 4, {1, 9, 1, 10}},
344 {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry,
345 4, {1, 9, 1, 11}},
346 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry,
347 4, {1, 9, 1, 12}},
348 {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry,
349 4, {1, 9, 1, 13}},
350 {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry,
351 4, {1, 9, 1, 14}},
352 {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry,
353 4, {1, 9, 1, 15}},
hassoef1bbf52004-10-08 12:04:21 +0000354};
355
356static u_char *
357ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
358 int exact, size_t *var_len, WriteMethod **write_method)
359{
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200360 u_int16_t sum;
361 u_int32_t count;
362 struct ospf6_lsa *lsa = NULL;
363
hassoef1bbf52004-10-08 12:04:21 +0000364 /* Check whether the instance identifier is valid */
365 if (smux_header_generic (v, name, length, exact, var_len, write_method)
366 == MATCH_FAILED)
367 return NULL;
368
369 /* Return the current value of the variable */
370 switch (v->magic)
371 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200372 case OSPFv3ROUTERID:
hassoef1bbf52004-10-08 12:04:21 +0000373 /* Router-ID of this OSPF instance. */
374 if (ospf6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200375 return SNMP_INTEGER (ntohl (ospf6->router_id));
376 return SNMP_INTEGER (0);
377 case OSPFv3ADMINSTAT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200378 if (ospf6)
379 return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)?
380 OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED);
381 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200382 case OSPFv3VERSIONNUMBER:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200383 return SNMP_INTEGER (3);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200384 case OSPFv3AREABDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200385 if (ospf6)
386 return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE);
387 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200388 case OSPFv3ASBDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200389 if (ospf6)
390 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE);
391 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200392 case OSPFv3ASSCOPELSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200393 if (ospf6)
394 return SNMP_INTEGER (ospf6->lsdb->count);
395 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200396 case OSPFv3ASSCOPELSACHECKSUMSUM:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200397 if (ospf6)
398 {
399 for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb);
400 lsa;
401 lsa = ospf6_lsdb_next (lsa))
402 sum += ntohs (lsa->header->checksum);
403 return SNMP_INTEGER (sum);
404 }
405 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200406 case OSPFv3ORIGINATENEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200407 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200408 case OSPFv3RXNEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200409 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200410 case OSPFv3EXTLSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200411 if (ospf6)
412 {
413 for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL),
414 ospf6->lsdb);
415 lsa;
416 lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
417 lsa))
418 count += 1;
419 return SNMP_INTEGER (count);
420 }
421 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200422 case OSPFv3EXTAREALSDBLIMIT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200423 return SNMP_INTEGER (-1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200424 case OSPFv3EXITOVERFLOWINTERVAL:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200425 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200426 case OSPFv3DEMANDEXTENSIONS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200427 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200428 case OSPFv3REFERENCEBANDWIDTH:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200429 return SNMP_INTEGER (100000);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200430 case OSPFv3RESTARTSUPPORT:
431 case OSPFv3RESTARTINTERVAL:
432 case OSPFv3RESTARTSTRICTLSACHECKING:
433 case OSPFv3RESTARTSTATUS:
434 case OSPFv3RESTARTAGE:
435 case OSPFv3RESTARTEXITREASON:
436 case OSPFv3NOTIFICATIONENABLE:
437 case OSPFv3STUBROUTERSUPPORT:
438 case OSPFv3STUBROUTERADVERTISEMENT:
439 case OSPFv3DISCONTINUITYTIME:
440 case OSPFv3RESTARTTIME:
441 /* TODO: Not implemented */
hassoef1bbf52004-10-08 12:04:21 +0000442 return NULL;
443 }
444 return NULL;
445}
446
447static u_char *
448ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
449 int exact, size_t *var_len, WriteMethod **write_method)
450{
451 struct ospf6_area *oa, *area = NULL;
Vincent Bernatea86e402012-06-04 10:29:49 +0200452 struct ospf6_lsa *lsa = NULL;
hassoef1bbf52004-10-08 12:04:21 +0000453 u_int32_t area_id = 0;
Vincent Bernatea86e402012-06-04 10:29:49 +0200454 u_int32_t count;
455 u_int16_t sum;
paul0c083ee2004-10-10 12:54:58 +0000456 struct listnode *node;
457 unsigned int len;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200458 char a[16];
Vincent Bernatea86e402012-06-04 10:29:49 +0200459 struct ospf6_route *ro;
hassoef1bbf52004-10-08 12:04:21 +0000460
461 if (ospf6 == NULL)
462 return NULL;
463
Vincent Bernat8046ba62012-05-31 13:30:28 +0200464 if (smux_header_table(v, name, length, exact, var_len, write_method)
465 == MATCH_FAILED)
466 return NULL;
467
hassoef1bbf52004-10-08 12:04:21 +0000468 len = *length - v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200469 len = (len >= 1 ? sizeof 1 : 0);
470 if (exact && len != 1)
hassoef1bbf52004-10-08 12:04:21 +0000471 return NULL;
472 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200473 area_id = htonl (name[v->namelen]);
hassoef1bbf52004-10-08 12:04:21 +0000474
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200475 inet_ntop (AF_INET, &area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000476 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200477 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000478
paul1eb8ef22005-04-07 07:30:20 +0000479 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000480 {
hassoef1bbf52004-10-08 12:04:21 +0000481 if (area == NULL)
482 {
483 if (len == 0) /* return first area entry */
484 area = oa;
485 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
486 area = oa;
487 else if (ntohl (oa->area_id) > ntohl (area_id))
488 area = oa;
489 }
490 }
491
492 if (area == NULL)
493 return NULL;
494
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200495 *length = v->namelen + 1;
496 name[v->namelen] = ntohl (area->area_id);
hassoef1bbf52004-10-08 12:04:21 +0000497
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200498 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000499 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200500 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000501
502 switch (v->magic)
503 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200504 case OSPFv3IMPORTASEXTERN:
Vincent Bernatea86e402012-06-04 10:29:49 +0200505 /* No NSSA support */
506 return SNMP_INTEGER (IS_AREA_STUB(area)?2:1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200507 case OSPFv3AREASPFRUNS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200508 return SNMP_INTEGER (area->spf_calculation);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200509 case OSPFv3AREABDRRTRCOUNT:
510 case OSPFv3AREAASBDRRTRCOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200511 count = 0;
512 for (ro = ospf6_route_head (ospf6->brouter_table); ro;
513 ro = ospf6_route_next (ro))
514 {
515 if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue;
516 if (v->magic == OSPFv3AREABDRRTRCOUNT &&
517 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B))
518 count++;
519 if (v->magic == OSPFv3AREAASBDRRTRCOUNT &&
520 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E))
521 count++;
522 }
523 return SNMP_INTEGER (count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200524 case OSPFv3AREASCOPELSACOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200525 return SNMP_INTEGER (area->lsdb->count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200526 case OSPFv3AREASCOPELSACKSUMSUM:
Vincent Bernatea86e402012-06-04 10:29:49 +0200527 for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb);
528 lsa;
529 lsa = ospf6_lsdb_next (lsa))
530 sum += ntohs (lsa->header->checksum);
531 return SNMP_INTEGER (sum);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200532 case OSPFv3AREASUMMARY:
Vincent Bernatea86e402012-06-04 10:29:49 +0200533 return SNMP_INTEGER (2); /* sendAreaSummary */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200534 case OSPFv3AREAROWSTATUS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200535 return SNMP_INTEGER (1); /* Active */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200536 case OSPFv3AREASTUBMETRIC:
537 case OSPFv3AREANSSATRANSLATORROLE:
538 case OSPFv3AREANSSATRANSLATORSTATE:
539 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
540 case OSPFv3AREANSSATRANSLATOREVENTS:
541 case OSPFv3AREASTUBMETRICTYPE:
542 case OSPFv3AREATEENABLED:
543 /* Not implemented. */
hassoef1bbf52004-10-08 12:04:21 +0000544 return NULL;
hassoef1bbf52004-10-08 12:04:21 +0000545 }
546 return NULL;
547}
548
hasso2680aa22004-11-25 20:54:46 +0000549static u_char *
550ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
551 int exact, size_t *var_len, WriteMethod **write_method)
552{
553 struct ospf6_lsa *lsa = NULL;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200554 u_int32_t area_id, id, adv_router;
hasso2680aa22004-11-25 20:54:46 +0000555 u_int16_t type;
hasso2680aa22004-11-25 20:54:46 +0000556 int len;
557 oid *offset;
558 int offsetlen;
559 char a[16], b[16], c[16];
560 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000561 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000562
Vincent Bernat8046ba62012-05-31 13:30:28 +0200563 if (smux_header_table(v, name, length, exact, var_len, write_method)
564 == MATCH_FAILED)
565 return NULL;
566
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200567 area_id = type = id = adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000568
569 /* Check OSPFv3 instance. */
570 if (ospf6 == NULL)
571 return NULL;
572
573 /* Get variable length. */
574 offset = name + v->namelen;
575 offsetlen = *length - v->namelen;
576
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200577#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
hasso2680aa22004-11-25 20:54:46 +0000578
579 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
580 return NULL;
581
582 /* Parse area-id */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200583 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000584 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200585 area_id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000586 offset += len;
587 offsetlen -= len;
588
589 /* Parse type */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200590 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000591 if (len)
592 type = htons (*offset);
593 offset += len;
594 offsetlen -= len;
595
596 /* Parse Router-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200597 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000598 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200599 adv_router = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000600 offset += len;
601 offsetlen -= len;
602
603 /* Parse LS-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200604 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000605 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200606 id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000607 offset += len;
608 offsetlen -= len;
609
610 inet_ntop (AF_INET, &area_id, a, sizeof (a));
611 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
612 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000613 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000614 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000615 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000616
617 if (exact)
618 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200619 oa = ospf6_area_lookup (area_id, ospf6);
620 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
hasso2680aa22004-11-25 20:54:46 +0000621 }
622 else
623 {
paul1eb8ef22005-04-07 07:30:20 +0000624 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000625 {
hasso2680aa22004-11-25 20:54:46 +0000626 if (lsa)
627 continue;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200628 if (oa->area_id < area_id)
hasso2680aa22004-11-25 20:54:46 +0000629 continue;
630
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200631 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
hasso2680aa22004-11-25 20:54:46 +0000632 oa->lsdb);
633 if (! lsa)
634 {
635 type = 0;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200636 id = 0;
637 adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000638 }
639 }
640 }
641
642 if (! lsa)
643 {
hassoc6487d62004-12-24 06:00:11 +0000644 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000645 return NULL;
646 }
647 oa = OSPF6_AREA (lsa->lsdb->data);
648
hassoc6487d62004-12-24 06:00:11 +0000649 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000650
651 /* Add Index (AreaId, Type, RouterId, Lsid) */
652 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
653 offset = name + v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200654 *offset = ntohl (oa->area_id);
655 offset++;
hasso2680aa22004-11-25 20:54:46 +0000656 *offset = ntohs (lsa->header->type);
657 offset++;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200658 *offset = ntohl (lsa->header->adv_router);
659 offset++;
660 *offset = ntohl (lsa->header->id);
661 offset++;
hasso2680aa22004-11-25 20:54:46 +0000662
663 /* Return the current value of the variable */
664 switch (v->magic)
665 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200666 case OSPFv3AREALSDBSEQUENCE:
667 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
hasso2680aa22004-11-25 20:54:46 +0000668 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200669 case OSPFv3AREALSDBAGE:
hasso2680aa22004-11-25 20:54:46 +0000670 ospf6_lsa_age_current (lsa);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200671 return SNMP_INTEGER (ntohs (lsa->header->age));
hasso2680aa22004-11-25 20:54:46 +0000672 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200673 case OSPFv3AREALSDBCHECKSUM:
674 return SNMP_INTEGER (ntohs (lsa->header->checksum));
hasso2680aa22004-11-25 20:54:46 +0000675 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200676 case OSPFv3AREALSDBADVERTISEMENT:
hasso2680aa22004-11-25 20:54:46 +0000677 *var_len = ntohs (lsa->header->length);
678 return (u_char *) lsa->header;
679 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200680 case OSPFv3AREALSDBTYPEKNOWN:
hasso2680aa22004-11-25 20:54:46 +0000681 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
682 SNMP_TRUE : SNMP_FALSE);
683 break;
hasso2680aa22004-11-25 20:54:46 +0000684 }
685 return NULL;
686}
687
Vincent Bernat061bc732012-05-31 20:21:15 +0200688static int
689if_icmp_func (struct interface *ifp1, struct interface *ifp2)
690{
691 return (ifp1->ifindex - ifp2->ifindex);
692}
693
694static u_char *
695ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
696 int exact, size_t *var_len, WriteMethod **write_method)
697{
698 unsigned int ifindex, instid, rtrid;
699 struct ospf6_interface *oi = NULL;
700 struct ospf6_neighbor *on = NULL;
701 struct interface *iif;
702 struct listnode *i, *j;
703 struct list *ifslist;
704 oid *offset;
705 int offsetlen, len;
706
707 if (smux_header_table (v, name, length, exact, var_len, write_method)
708 == MATCH_FAILED)
709 return NULL;
710
711 ifindex = instid = rtrid = 0;
712
713 /* Check OSPFv3 instance. */
714 if (ospf6 == NULL)
715 return NULL;
716
717 /* Get variable length. */
718 offset = name + v->namelen;
719 offsetlen = *length - v->namelen;
720
721 if (exact && offsetlen != 3)
722 return NULL;
723
724 /* Parse if index */
725 len = (offsetlen < 1 ? 0 : 1);
726 if (len)
727 ifindex = *offset;
728 offset += len;
729 offsetlen -= len;
730
731 /* Parse instance ID */
732 len = (offsetlen < 1 ? 0 : 1);
733 if (len)
734 instid = *offset;
735 offset += len;
736 offsetlen -= len;
737
738 /* Parse router ID */
739 len = (offsetlen < 1 ? 0 : 1);
740 if (len)
741 rtrid = htonl (*offset);
742 offset += len;
743 offsetlen -= len;
744
745 if (exact)
746 {
747 oi = ospf6_interface_lookup_by_ifindex (ifindex);
748 on = ospf6_neighbor_lookup (rtrid, oi);
749 if (oi->instance_id != instid) return NULL;
750 }
751 else
752 {
753 /* We build a sorted list of interfaces */
754 ifslist = list_new ();
755 if (!ifslist) return NULL;
756 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
757 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
758 listnode_add_sort (ifslist, iif);
759
760 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
761 {
762 if (!iif->ifindex) continue;
763 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
764 if (!oi) continue;
765 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
766 if (iif->ifindex > ifindex ||
767 (iif->ifindex == ifindex &&
768 (oi->instance_id > instid ||
769 (oi->instance_id == instid &&
770 ntohl (on->router_id) > ntohl (rtrid)))))
771 break;
772 }
773 if (on) break;
774 oi = on = NULL;
775 }
776
777 list_delete_all_node (ifslist);
778 }
779
780 if (!oi || !on) return NULL;
781
782 /* Add Index (IfIndex, IfInstId, RtrId) */
783 *length = v->namelen + 3;
784 offset = name + v->namelen;
785 *offset = oi->interface->ifindex;
786 offset++;
787 *offset = oi->instance_id;
788 offset++;
789 *offset = ntohl (on->router_id);
790 offset++;
791
792 /* Return the current value of the variable */
793 switch (v->magic)
794 {
795 case OSPFv3NBRADDRESSTYPE:
796 return SNMP_INTEGER (2); /* IPv6 only */
797 case OSPFv3NBRADDRESS:
798 *var_len = sizeof (struct in6_addr);
799 return (u_char *) &on->linklocal_addr;
800 case OSPFv3NBROPTIONS:
801 return SNMP_INTEGER (on->options[2]);
802 case OSPFv3NBRPRIORITY:
803 return SNMP_INTEGER (on->priority);
804 case OSPFv3NBRSTATE:
805 return SNMP_INTEGER (on->state);
806 case OSPFv3NBREVENTS:
807 return SNMP_INTEGER (on->state_change);
808 case OSPFv3NBRLSRETRANSQLEN:
809 return SNMP_INTEGER (on->retrans_list->count);
810 case OSPFv3NBRHELLOSUPPRESSED:
811 return SNMP_INTEGER (SNMP_FALSE);
812 case OSPFv3NBRIFID:
813 return SNMP_INTEGER (on->ifindex);
814 case OSPFv3NBRRESTARTHELPERSTATUS:
815 case OSPFv3NBRRESTARTHELPERAGE:
816 case OSPFv3NBRRESTARTHELPEREXITREASON:
817 /* Not implemented. Only works if all the last ones are not
818 implemented! */
819 return NULL;
820 }
821
822 return NULL;
823}
824
hasso2680aa22004-11-25 20:54:46 +0000825
hassoef1bbf52004-10-08 12:04:21 +0000826/* Register OSPFv3-MIB. */
827void
paul0c083ee2004-10-10 12:54:58 +0000828ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +0000829{
hassoc75105a2004-10-13 10:33:26 +0000830 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +0000831 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +0000832}
833
834#endif /* HAVE_SNMP */
835