blob: 5e4ca0f665ba7bd64514e48c0195481285676a5c [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{
360 /* Check whether the instance identifier is valid */
361 if (smux_header_generic (v, name, length, exact, var_len, write_method)
362 == MATCH_FAILED)
363 return NULL;
364
365 /* Return the current value of the variable */
366 switch (v->magic)
367 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200368 case OSPFv3ROUTERID:
hassoef1bbf52004-10-08 12:04:21 +0000369 /* Router-ID of this OSPF instance. */
370 if (ospf6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200371 return SNMP_INTEGER (ntohl (ospf6->router_id));
372 return SNMP_INTEGER (0);
373 case OSPFv3ADMINSTAT:
374 case OSPFv3VERSIONNUMBER:
375 case OSPFv3AREABDRRTRSTATUS:
376 case OSPFv3ASBDRRTRSTATUS:
377 case OSPFv3ASSCOPELSACOUNT:
378 case OSPFv3ASSCOPELSACHECKSUMSUM:
379 case OSPFv3ORIGINATENEWLSAS:
380 case OSPFv3RXNEWLSAS:
381 case OSPFv3EXTLSACOUNT:
382 case OSPFv3EXTAREALSDBLIMIT:
383 case OSPFv3EXITOVERFLOWINTERVAL:
384 case OSPFv3DEMANDEXTENSIONS:
385 case OSPFv3REFERENCEBANDWIDTH:
386 case OSPFv3RESTARTSUPPORT:
387 case OSPFv3RESTARTINTERVAL:
388 case OSPFv3RESTARTSTRICTLSACHECKING:
389 case OSPFv3RESTARTSTATUS:
390 case OSPFv3RESTARTAGE:
391 case OSPFv3RESTARTEXITREASON:
392 case OSPFv3NOTIFICATIONENABLE:
393 case OSPFv3STUBROUTERSUPPORT:
394 case OSPFv3STUBROUTERADVERTISEMENT:
395 case OSPFv3DISCONTINUITYTIME:
396 case OSPFv3RESTARTTIME:
397 /* TODO: Not implemented */
hassoef1bbf52004-10-08 12:04:21 +0000398 return NULL;
399 }
400 return NULL;
401}
402
403static u_char *
404ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
405 int exact, size_t *var_len, WriteMethod **write_method)
406{
407 struct ospf6_area *oa, *area = NULL;
408 u_int32_t area_id = 0;
paul0c083ee2004-10-10 12:54:58 +0000409 struct listnode *node;
410 unsigned int len;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200411 char a[16];
hassoef1bbf52004-10-08 12:04:21 +0000412
413 if (ospf6 == NULL)
414 return NULL;
415
Vincent Bernat8046ba62012-05-31 13:30:28 +0200416 if (smux_header_table(v, name, length, exact, var_len, write_method)
417 == MATCH_FAILED)
418 return NULL;
419
hassoef1bbf52004-10-08 12:04:21 +0000420 len = *length - v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200421 len = (len >= 1 ? sizeof 1 : 0);
422 if (exact && len != 1)
hassoef1bbf52004-10-08 12:04:21 +0000423 return NULL;
424 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200425 area_id = htonl (name[v->namelen]);
hassoef1bbf52004-10-08 12:04:21 +0000426
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200427 inet_ntop (AF_INET, &area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000428 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200429 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000430
paul1eb8ef22005-04-07 07:30:20 +0000431 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000432 {
hassoef1bbf52004-10-08 12:04:21 +0000433 if (area == NULL)
434 {
435 if (len == 0) /* return first area entry */
436 area = oa;
437 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
438 area = oa;
439 else if (ntohl (oa->area_id) > ntohl (area_id))
440 area = oa;
441 }
442 }
443
444 if (area == NULL)
445 return NULL;
446
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200447 *length = v->namelen + 1;
448 name[v->namelen] = ntohl (area->area_id);
hassoef1bbf52004-10-08 12:04:21 +0000449
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200450 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000451 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200452 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000453
454 switch (v->magic)
455 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200456 case OSPFv3IMPORTASEXTERN:
hassoef1bbf52004-10-08 12:04:21 +0000457 return SNMP_INTEGER (ospf6->external_table->count);
458 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200459 case OSPFv3AREASPFRUNS:
460 case OSPFv3AREABDRRTRCOUNT:
461 case OSPFv3AREAASBDRRTRCOUNT:
462 case OSPFv3AREASCOPELSACOUNT:
463 case OSPFv3AREASCOPELSACKSUMSUM:
464 case OSPFv3AREASUMMARY:
465 case OSPFv3AREAROWSTATUS:
466 case OSPFv3AREASTUBMETRIC:
467 case OSPFv3AREANSSATRANSLATORROLE:
468 case OSPFv3AREANSSATRANSLATORSTATE:
469 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
470 case OSPFv3AREANSSATRANSLATOREVENTS:
471 case OSPFv3AREASTUBMETRICTYPE:
472 case OSPFv3AREATEENABLED:
473 /* Not implemented. */
hassoef1bbf52004-10-08 12:04:21 +0000474 return NULL;
hassoef1bbf52004-10-08 12:04:21 +0000475 }
476 return NULL;
477}
478
hasso2680aa22004-11-25 20:54:46 +0000479static u_char *
480ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
481 int exact, size_t *var_len, WriteMethod **write_method)
482{
483 struct ospf6_lsa *lsa = NULL;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200484 u_int32_t area_id, id, adv_router;
hasso2680aa22004-11-25 20:54:46 +0000485 u_int16_t type;
hasso2680aa22004-11-25 20:54:46 +0000486 int len;
487 oid *offset;
488 int offsetlen;
489 char a[16], b[16], c[16];
490 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000491 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000492
Vincent Bernat8046ba62012-05-31 13:30:28 +0200493 if (smux_header_table(v, name, length, exact, var_len, write_method)
494 == MATCH_FAILED)
495 return NULL;
496
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200497 area_id = type = id = adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000498
499 /* Check OSPFv3 instance. */
500 if (ospf6 == NULL)
501 return NULL;
502
503 /* Get variable length. */
504 offset = name + v->namelen;
505 offsetlen = *length - v->namelen;
506
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200507#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
hasso2680aa22004-11-25 20:54:46 +0000508
509 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
510 return NULL;
511
512 /* Parse area-id */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200513 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000514 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200515 area_id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000516 offset += len;
517 offsetlen -= len;
518
519 /* Parse type */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200520 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000521 if (len)
522 type = htons (*offset);
523 offset += len;
524 offsetlen -= len;
525
526 /* Parse Router-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200527 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000528 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200529 adv_router = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000530 offset += len;
531 offsetlen -= len;
532
533 /* Parse LS-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200534 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000535 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200536 id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000537 offset += len;
538 offsetlen -= len;
539
540 inet_ntop (AF_INET, &area_id, a, sizeof (a));
541 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
542 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000543 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000544 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000545 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000546
547 if (exact)
548 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200549 oa = ospf6_area_lookup (area_id, ospf6);
550 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
hasso2680aa22004-11-25 20:54:46 +0000551 }
552 else
553 {
paul1eb8ef22005-04-07 07:30:20 +0000554 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000555 {
hasso2680aa22004-11-25 20:54:46 +0000556 if (lsa)
557 continue;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200558 if (oa->area_id < area_id)
hasso2680aa22004-11-25 20:54:46 +0000559 continue;
560
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200561 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
hasso2680aa22004-11-25 20:54:46 +0000562 oa->lsdb);
563 if (! lsa)
564 {
565 type = 0;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200566 id = 0;
567 adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000568 }
569 }
570 }
571
572 if (! lsa)
573 {
hassoc6487d62004-12-24 06:00:11 +0000574 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000575 return NULL;
576 }
577 oa = OSPF6_AREA (lsa->lsdb->data);
578
hassoc6487d62004-12-24 06:00:11 +0000579 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000580
581 /* Add Index (AreaId, Type, RouterId, Lsid) */
582 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
583 offset = name + v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200584 *offset = ntohl (oa->area_id);
585 offset++;
hasso2680aa22004-11-25 20:54:46 +0000586 *offset = ntohs (lsa->header->type);
587 offset++;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200588 *offset = ntohl (lsa->header->adv_router);
589 offset++;
590 *offset = ntohl (lsa->header->id);
591 offset++;
hasso2680aa22004-11-25 20:54:46 +0000592
593 /* Return the current value of the variable */
594 switch (v->magic)
595 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200596 case OSPFv3AREALSDBSEQUENCE:
597 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
hasso2680aa22004-11-25 20:54:46 +0000598 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200599 case OSPFv3AREALSDBAGE:
hasso2680aa22004-11-25 20:54:46 +0000600 ospf6_lsa_age_current (lsa);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200601 return SNMP_INTEGER (ntohs (lsa->header->age));
hasso2680aa22004-11-25 20:54:46 +0000602 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200603 case OSPFv3AREALSDBCHECKSUM:
604 return SNMP_INTEGER (ntohs (lsa->header->checksum));
hasso2680aa22004-11-25 20:54:46 +0000605 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200606 case OSPFv3AREALSDBADVERTISEMENT:
hasso2680aa22004-11-25 20:54:46 +0000607 *var_len = ntohs (lsa->header->length);
608 return (u_char *) lsa->header;
609 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200610 case OSPFv3AREALSDBTYPEKNOWN:
hasso2680aa22004-11-25 20:54:46 +0000611 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
612 SNMP_TRUE : SNMP_FALSE);
613 break;
hasso2680aa22004-11-25 20:54:46 +0000614 }
615 return NULL;
616}
617
Vincent Bernat061bc732012-05-31 20:21:15 +0200618static int
619if_icmp_func (struct interface *ifp1, struct interface *ifp2)
620{
621 return (ifp1->ifindex - ifp2->ifindex);
622}
623
624static u_char *
625ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
626 int exact, size_t *var_len, WriteMethod **write_method)
627{
628 unsigned int ifindex, instid, rtrid;
629 struct ospf6_interface *oi = NULL;
630 struct ospf6_neighbor *on = NULL;
631 struct interface *iif;
632 struct listnode *i, *j;
633 struct list *ifslist;
634 oid *offset;
635 int offsetlen, len;
636
637 if (smux_header_table (v, name, length, exact, var_len, write_method)
638 == MATCH_FAILED)
639 return NULL;
640
641 ifindex = instid = rtrid = 0;
642
643 /* Check OSPFv3 instance. */
644 if (ospf6 == NULL)
645 return NULL;
646
647 /* Get variable length. */
648 offset = name + v->namelen;
649 offsetlen = *length - v->namelen;
650
651 if (exact && offsetlen != 3)
652 return NULL;
653
654 /* Parse if index */
655 len = (offsetlen < 1 ? 0 : 1);
656 if (len)
657 ifindex = *offset;
658 offset += len;
659 offsetlen -= len;
660
661 /* Parse instance ID */
662 len = (offsetlen < 1 ? 0 : 1);
663 if (len)
664 instid = *offset;
665 offset += len;
666 offsetlen -= len;
667
668 /* Parse router ID */
669 len = (offsetlen < 1 ? 0 : 1);
670 if (len)
671 rtrid = htonl (*offset);
672 offset += len;
673 offsetlen -= len;
674
675 if (exact)
676 {
677 oi = ospf6_interface_lookup_by_ifindex (ifindex);
678 on = ospf6_neighbor_lookup (rtrid, oi);
679 if (oi->instance_id != instid) return NULL;
680 }
681 else
682 {
683 /* We build a sorted list of interfaces */
684 ifslist = list_new ();
685 if (!ifslist) return NULL;
686 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
687 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
688 listnode_add_sort (ifslist, iif);
689
690 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
691 {
692 if (!iif->ifindex) continue;
693 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
694 if (!oi) continue;
695 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
696 if (iif->ifindex > ifindex ||
697 (iif->ifindex == ifindex &&
698 (oi->instance_id > instid ||
699 (oi->instance_id == instid &&
700 ntohl (on->router_id) > ntohl (rtrid)))))
701 break;
702 }
703 if (on) break;
704 oi = on = NULL;
705 }
706
707 list_delete_all_node (ifslist);
708 }
709
710 if (!oi || !on) return NULL;
711
712 /* Add Index (IfIndex, IfInstId, RtrId) */
713 *length = v->namelen + 3;
714 offset = name + v->namelen;
715 *offset = oi->interface->ifindex;
716 offset++;
717 *offset = oi->instance_id;
718 offset++;
719 *offset = ntohl (on->router_id);
720 offset++;
721
722 /* Return the current value of the variable */
723 switch (v->magic)
724 {
725 case OSPFv3NBRADDRESSTYPE:
726 return SNMP_INTEGER (2); /* IPv6 only */
727 case OSPFv3NBRADDRESS:
728 *var_len = sizeof (struct in6_addr);
729 return (u_char *) &on->linklocal_addr;
730 case OSPFv3NBROPTIONS:
731 return SNMP_INTEGER (on->options[2]);
732 case OSPFv3NBRPRIORITY:
733 return SNMP_INTEGER (on->priority);
734 case OSPFv3NBRSTATE:
735 return SNMP_INTEGER (on->state);
736 case OSPFv3NBREVENTS:
737 return SNMP_INTEGER (on->state_change);
738 case OSPFv3NBRLSRETRANSQLEN:
739 return SNMP_INTEGER (on->retrans_list->count);
740 case OSPFv3NBRHELLOSUPPRESSED:
741 return SNMP_INTEGER (SNMP_FALSE);
742 case OSPFv3NBRIFID:
743 return SNMP_INTEGER (on->ifindex);
744 case OSPFv3NBRRESTARTHELPERSTATUS:
745 case OSPFv3NBRRESTARTHELPERAGE:
746 case OSPFv3NBRRESTARTHELPEREXITREASON:
747 /* Not implemented. Only works if all the last ones are not
748 implemented! */
749 return NULL;
750 }
751
752 return NULL;
753}
754
hasso2680aa22004-11-25 20:54:46 +0000755
hassoef1bbf52004-10-08 12:04:21 +0000756/* Register OSPFv3-MIB. */
757void
paul0c083ee2004-10-10 12:54:58 +0000758ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +0000759{
hassoc75105a2004-10-13 10:33:26 +0000760 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +0000761 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +0000762}
763
764#endif /* HAVE_SNMP */
765