blob: 95b4fc08cbf4f4c2bd344d1d3da883e75a6b7373 [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 **);
hassoef1bbf52004-10-08 12:04:21 +0000228
229struct variable ospfv3_variables[] =
230{
231 /* OSPF general variables */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200232 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000233 3, {1, 1, 1}},
234 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
235 3, {1, 1, 2}},
236 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
237 3, {1, 1, 3}},
238 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
239 3, {1, 1, 4}},
240 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
241 3, {1, 1, 5}},
242 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
243 3, {1, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200244 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000245 3, {1, 1, 7}},
246 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
247 3, {1, 1, 8}},
248 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
249 3, {1, 1, 9}},
250 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
251 3, {1, 1, 10}},
252 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
253 3, {1, 1, 11}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200254 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000255 3, {1, 1, 12}},
hassoef1bbf52004-10-08 12:04:21 +0000256 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200257 3, {1, 1, 13}},
258 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000259 3, {1, 1, 14}},
hassoef1bbf52004-10-08 12:04:21 +0000260 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200261 3, {1, 1, 15}},
262 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
263 3, {1, 1, 16}},
264 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000265 3, {1, 1, 17}},
hassoef1bbf52004-10-08 12:04:21 +0000266 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200267 3, {1, 1, 18}},
268 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000269 3, {1, 1, 19}},
hassoef1bbf52004-10-08 12:04:21 +0000270 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200271 3, {1, 1, 20}},
272 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000273 3, {1, 1, 21}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200274 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
275 3, {1, 1, 22}},
276 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
277 3, {1, 1, 23}},
278 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
279 3, {1, 1, 24}},
280 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
281 3, {1, 1, 25}},
hassoef1bbf52004-10-08 12:04:21 +0000282
283 /* OSPFv3 Area Data Structure */
hasso2680aa22004-11-25 20:54:46 +0000284 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
hassoef1bbf52004-10-08 12:04:21 +0000285 4, {1, 2, 1, 2}},
hasso2680aa22004-11-25 20:54:46 +0000286 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
287 4, {1, 2, 1, 3}},
288 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
289 4, {1, 2, 1, 4}},
290 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
291 4, {1, 2, 1, 5}},
292 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
293 4, {1, 2, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200294 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000295 4, {1, 2, 1, 7}},
296 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
297 4, {1, 2, 1, 8}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200298 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000299 4, {1, 2, 1, 9}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200300 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000301 4, {1, 2, 1, 10}},
302 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
303 4, {1, 2, 1, 11}},
304 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
305 4, {1, 2, 1, 12}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200306 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000307 4, {1, 2, 1, 13}},
308 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
309 4, {1, 2, 1, 14}},
310 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
311 4, {1, 2, 1, 15}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200312 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
313 4, {1, 2, 1, 16}},
hasso2680aa22004-11-25 20:54:46 +0000314
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200315 /* OSPFv3 Area LSDB */
hasso2680aa22004-11-25 20:54:46 +0000316 {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
317 4, {1, 4, 1, 5}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200318 {OSPFv3AREALSDBAGE, UNSIGNED, RONLY, ospfv3AreaLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000319 4, {1, 4, 1, 6}},
320 {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
321 4, {1, 4, 1, 7}},
322 {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
323 4, {1, 4, 1, 8}},
324 {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
325 4, {1, 4, 1, 9}},
326
hassoef1bbf52004-10-08 12:04:21 +0000327};
328
329static u_char *
330ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
331 int exact, size_t *var_len, WriteMethod **write_method)
332{
333 /* Check whether the instance identifier is valid */
334 if (smux_header_generic (v, name, length, exact, var_len, write_method)
335 == MATCH_FAILED)
336 return NULL;
337
338 /* Return the current value of the variable */
339 switch (v->magic)
340 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200341 case OSPFv3ROUTERID:
hassoef1bbf52004-10-08 12:04:21 +0000342 /* Router-ID of this OSPF instance. */
343 if (ospf6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200344 return SNMP_INTEGER (ntohl (ospf6->router_id));
345 return SNMP_INTEGER (0);
346 case OSPFv3ADMINSTAT:
347 case OSPFv3VERSIONNUMBER:
348 case OSPFv3AREABDRRTRSTATUS:
349 case OSPFv3ASBDRRTRSTATUS:
350 case OSPFv3ASSCOPELSACOUNT:
351 case OSPFv3ASSCOPELSACHECKSUMSUM:
352 case OSPFv3ORIGINATENEWLSAS:
353 case OSPFv3RXNEWLSAS:
354 case OSPFv3EXTLSACOUNT:
355 case OSPFv3EXTAREALSDBLIMIT:
356 case OSPFv3EXITOVERFLOWINTERVAL:
357 case OSPFv3DEMANDEXTENSIONS:
358 case OSPFv3REFERENCEBANDWIDTH:
359 case OSPFv3RESTARTSUPPORT:
360 case OSPFv3RESTARTINTERVAL:
361 case OSPFv3RESTARTSTRICTLSACHECKING:
362 case OSPFv3RESTARTSTATUS:
363 case OSPFv3RESTARTAGE:
364 case OSPFv3RESTARTEXITREASON:
365 case OSPFv3NOTIFICATIONENABLE:
366 case OSPFv3STUBROUTERSUPPORT:
367 case OSPFv3STUBROUTERADVERTISEMENT:
368 case OSPFv3DISCONTINUITYTIME:
369 case OSPFv3RESTARTTIME:
370 /* TODO: Not implemented */
hassoef1bbf52004-10-08 12:04:21 +0000371 return NULL;
372 }
373 return NULL;
374}
375
376static u_char *
377ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
378 int exact, size_t *var_len, WriteMethod **write_method)
379{
380 struct ospf6_area *oa, *area = NULL;
381 u_int32_t area_id = 0;
paul0c083ee2004-10-10 12:54:58 +0000382 struct listnode *node;
383 unsigned int len;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200384 char a[16];
hassoef1bbf52004-10-08 12:04:21 +0000385
386 if (ospf6 == NULL)
387 return NULL;
388
Vincent Bernat8046ba62012-05-31 13:30:28 +0200389 if (smux_header_table(v, name, length, exact, var_len, write_method)
390 == MATCH_FAILED)
391 return NULL;
392
hassoef1bbf52004-10-08 12:04:21 +0000393 len = *length - v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200394 len = (len >= 1 ? sizeof 1 : 0);
395 if (exact && len != 1)
hassoef1bbf52004-10-08 12:04:21 +0000396 return NULL;
397 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200398 area_id = htonl (name[v->namelen]);
hassoef1bbf52004-10-08 12:04:21 +0000399
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200400 inet_ntop (AF_INET, &area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000401 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200402 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000403
paul1eb8ef22005-04-07 07:30:20 +0000404 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000405 {
hassoef1bbf52004-10-08 12:04:21 +0000406 if (area == NULL)
407 {
408 if (len == 0) /* return first area entry */
409 area = oa;
410 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
411 area = oa;
412 else if (ntohl (oa->area_id) > ntohl (area_id))
413 area = oa;
414 }
415 }
416
417 if (area == NULL)
418 return NULL;
419
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200420 *length = v->namelen + 1;
421 name[v->namelen] = ntohl (area->area_id);
hassoef1bbf52004-10-08 12:04:21 +0000422
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200423 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000424 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200425 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000426
427 switch (v->magic)
428 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200429 case OSPFv3IMPORTASEXTERN:
hassoef1bbf52004-10-08 12:04:21 +0000430 return SNMP_INTEGER (ospf6->external_table->count);
431 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200432 case OSPFv3AREASPFRUNS:
433 case OSPFv3AREABDRRTRCOUNT:
434 case OSPFv3AREAASBDRRTRCOUNT:
435 case OSPFv3AREASCOPELSACOUNT:
436 case OSPFv3AREASCOPELSACKSUMSUM:
437 case OSPFv3AREASUMMARY:
438 case OSPFv3AREAROWSTATUS:
439 case OSPFv3AREASTUBMETRIC:
440 case OSPFv3AREANSSATRANSLATORROLE:
441 case OSPFv3AREANSSATRANSLATORSTATE:
442 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
443 case OSPFv3AREANSSATRANSLATOREVENTS:
444 case OSPFv3AREASTUBMETRICTYPE:
445 case OSPFv3AREATEENABLED:
446 /* Not implemented. */
hassoef1bbf52004-10-08 12:04:21 +0000447 return NULL;
hassoef1bbf52004-10-08 12:04:21 +0000448 }
449 return NULL;
450}
451
hasso2680aa22004-11-25 20:54:46 +0000452static u_char *
453ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
454 int exact, size_t *var_len, WriteMethod **write_method)
455{
456 struct ospf6_lsa *lsa = NULL;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200457 u_int32_t area_id, id, adv_router;
hasso2680aa22004-11-25 20:54:46 +0000458 u_int16_t type;
hasso2680aa22004-11-25 20:54:46 +0000459 int len;
460 oid *offset;
461 int offsetlen;
462 char a[16], b[16], c[16];
463 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000464 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000465
Vincent Bernat8046ba62012-05-31 13:30:28 +0200466 if (smux_header_table(v, name, length, exact, var_len, write_method)
467 == MATCH_FAILED)
468 return NULL;
469
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200470 area_id = type = id = adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000471
472 /* Check OSPFv3 instance. */
473 if (ospf6 == NULL)
474 return NULL;
475
476 /* Get variable length. */
477 offset = name + v->namelen;
478 offsetlen = *length - v->namelen;
479
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200480#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
hasso2680aa22004-11-25 20:54:46 +0000481
482 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
483 return NULL;
484
485 /* Parse area-id */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200486 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000487 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200488 area_id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000489 offset += len;
490 offsetlen -= len;
491
492 /* Parse type */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200493 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000494 if (len)
495 type = htons (*offset);
496 offset += len;
497 offsetlen -= len;
498
499 /* Parse Router-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200500 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000501 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200502 adv_router = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000503 offset += len;
504 offsetlen -= len;
505
506 /* Parse LS-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200507 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000508 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200509 id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000510 offset += len;
511 offsetlen -= len;
512
513 inet_ntop (AF_INET, &area_id, a, sizeof (a));
514 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
515 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000516 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000517 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000518 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000519
520 if (exact)
521 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200522 oa = ospf6_area_lookup (area_id, ospf6);
523 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
hasso2680aa22004-11-25 20:54:46 +0000524 }
525 else
526 {
paul1eb8ef22005-04-07 07:30:20 +0000527 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000528 {
hasso2680aa22004-11-25 20:54:46 +0000529 if (lsa)
530 continue;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200531 if (oa->area_id < area_id)
hasso2680aa22004-11-25 20:54:46 +0000532 continue;
533
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200534 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
hasso2680aa22004-11-25 20:54:46 +0000535 oa->lsdb);
536 if (! lsa)
537 {
538 type = 0;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200539 id = 0;
540 adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000541 }
542 }
543 }
544
545 if (! lsa)
546 {
hassoc6487d62004-12-24 06:00:11 +0000547 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000548 return NULL;
549 }
550 oa = OSPF6_AREA (lsa->lsdb->data);
551
hassoc6487d62004-12-24 06:00:11 +0000552 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000553
554 /* Add Index (AreaId, Type, RouterId, Lsid) */
555 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
556 offset = name + v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200557 *offset = ntohl (oa->area_id);
558 offset++;
hasso2680aa22004-11-25 20:54:46 +0000559 *offset = ntohs (lsa->header->type);
560 offset++;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200561 *offset = ntohl (lsa->header->adv_router);
562 offset++;
563 *offset = ntohl (lsa->header->id);
564 offset++;
hasso2680aa22004-11-25 20:54:46 +0000565
566 /* Return the current value of the variable */
567 switch (v->magic)
568 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200569 case OSPFv3AREALSDBSEQUENCE:
570 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
hasso2680aa22004-11-25 20:54:46 +0000571 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200572 case OSPFv3AREALSDBAGE:
hasso2680aa22004-11-25 20:54:46 +0000573 ospf6_lsa_age_current (lsa);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200574 return SNMP_INTEGER (ntohs (lsa->header->age));
hasso2680aa22004-11-25 20:54:46 +0000575 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200576 case OSPFv3AREALSDBCHECKSUM:
577 return SNMP_INTEGER (ntohs (lsa->header->checksum));
hasso2680aa22004-11-25 20:54:46 +0000578 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200579 case OSPFv3AREALSDBADVERTISEMENT:
hasso2680aa22004-11-25 20:54:46 +0000580 *var_len = ntohs (lsa->header->length);
581 return (u_char *) lsa->header;
582 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200583 case OSPFv3AREALSDBTYPEKNOWN:
hasso2680aa22004-11-25 20:54:46 +0000584 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
585 SNMP_TRUE : SNMP_FALSE);
586 break;
hasso2680aa22004-11-25 20:54:46 +0000587 }
588 return NULL;
589}
590
591
hassoef1bbf52004-10-08 12:04:21 +0000592/* Register OSPFv3-MIB. */
593void
paul0c083ee2004-10-10 12:54:58 +0000594ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +0000595{
hassoc75105a2004-10-13 10:33:26 +0000596 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +0000597 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +0000598}
599
600#endif /* HAVE_SNMP */
601