blob: 1880fc0a3a3342d25b8cfbd5cb21f9306cc5c5d5 [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 **);
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200230static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *,
231 int, size_t *, WriteMethod **);
hassoef1bbf52004-10-08 12:04:21 +0000232
233struct variable ospfv3_variables[] =
234{
235 /* OSPF general variables */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200236 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000237 3, {1, 1, 1}},
238 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
239 3, {1, 1, 2}},
240 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
241 3, {1, 1, 3}},
242 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
243 3, {1, 1, 4}},
244 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
245 3, {1, 1, 5}},
246 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
247 3, {1, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200248 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000249 3, {1, 1, 7}},
250 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
251 3, {1, 1, 8}},
252 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
253 3, {1, 1, 9}},
254 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
255 3, {1, 1, 10}},
256 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
257 3, {1, 1, 11}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200258 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000259 3, {1, 1, 12}},
hassoef1bbf52004-10-08 12:04:21 +0000260 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200261 3, {1, 1, 13}},
262 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000263 3, {1, 1, 14}},
hassoef1bbf52004-10-08 12:04:21 +0000264 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200265 3, {1, 1, 15}},
266 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
267 3, {1, 1, 16}},
268 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000269 3, {1, 1, 17}},
hassoef1bbf52004-10-08 12:04:21 +0000270 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200271 3, {1, 1, 18}},
272 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000273 3, {1, 1, 19}},
hassoef1bbf52004-10-08 12:04:21 +0000274 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200275 3, {1, 1, 20}},
276 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000277 3, {1, 1, 21}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200278 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
279 3, {1, 1, 22}},
280 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
281 3, {1, 1, 23}},
282 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
283 3, {1, 1, 24}},
284 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
285 3, {1, 1, 25}},
hassoef1bbf52004-10-08 12:04:21 +0000286
287 /* OSPFv3 Area Data Structure */
hasso2680aa22004-11-25 20:54:46 +0000288 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
hassoef1bbf52004-10-08 12:04:21 +0000289 4, {1, 2, 1, 2}},
hasso2680aa22004-11-25 20:54:46 +0000290 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
291 4, {1, 2, 1, 3}},
292 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
293 4, {1, 2, 1, 4}},
294 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
295 4, {1, 2, 1, 5}},
296 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
297 4, {1, 2, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200298 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000299 4, {1, 2, 1, 7}},
300 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
301 4, {1, 2, 1, 8}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200302 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000303 4, {1, 2, 1, 9}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200304 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000305 4, {1, 2, 1, 10}},
306 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
307 4, {1, 2, 1, 11}},
308 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
309 4, {1, 2, 1, 12}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200310 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000311 4, {1, 2, 1, 13}},
312 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
313 4, {1, 2, 1, 14}},
314 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
315 4, {1, 2, 1, 15}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200316 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
317 4, {1, 2, 1, 16}},
hasso2680aa22004-11-25 20:54:46 +0000318
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200319 /* OSPFv3 Area LSDB */
hasso2680aa22004-11-25 20:54:46 +0000320 {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
321 4, {1, 4, 1, 5}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200322 {OSPFv3AREALSDBAGE, UNSIGNED, RONLY, ospfv3AreaLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000323 4, {1, 4, 1, 6}},
324 {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
325 4, {1, 4, 1, 7}},
326 {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
327 4, {1, 4, 1, 8}},
328 {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
329 4, {1, 4, 1, 9}},
330
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200331 /* OSPFv3 interfaces */
332 {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry,
333 4, {1, 7, 1, 3}},
334 {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry,
335 4, {1, 7, 1, 4}},
336 {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry,
337 4, {1, 7, 1, 5}},
338 {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry,
339 4, {1, 7, 1, 6}},
340 {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry,
341 4, {1, 7, 1, 7}},
342 {OSPFv3IFRETRANSINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
343 4, {1, 7, 1, 8}},
344 {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry,
345 4, {1, 7, 1, 9}},
346 {OSPFv3IFRTRDEADINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
347 4, {1, 7, 1, 10}},
348 {OSPFv3IFPOLLINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
349 4, {1, 7, 1, 11}},
350 {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry,
351 4, {1, 7, 1, 12}},
352 {OSPFv3IFDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
353 4, {1, 7, 1, 13}},
354 {OSPFv3IFBACKUPDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
355 4, {1, 7, 1, 14}},
356 {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry,
357 4, {1, 7, 1, 15}},
358 {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry,
359 4, {1, 7, 1, 16}},
360 {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry,
361 4, {1, 7, 1, 17}},
362 {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry,
363 4, {1, 7, 1, 18}},
364 {OSPFv3IFLINKSCOPELSACOUNT, GAUGE, RONLY, ospfv3IfEntry,
365 4, {1, 7, 1, 19}},
366 {OSPFv3IFLINKLSACKSUMSUM, UNSIGNED, RONLY, ospfv3IfEntry,
367 4, {1, 7, 1, 20}},
368 {OSPFv3IFDEMANDNBRPROBE, INTEGER, RONLY, ospfv3IfEntry,
369 4, {1, 7, 1, 21}},
370 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT, UNSIGNED, RONLY, ospfv3IfEntry,
371 4, {1, 7, 1, 22}},
372 {OSPFv3IFDEMANDNBRPROBEINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
373 4, {1, 7, 1, 23}},
374 {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry,
375 4, {1, 7, 1, 24}},
376 {OSPFv3IFLINKLSASUPPRESSION, INTEGER, RONLY, ospfv3IfEntry,
377 4, {1, 7, 1, 25}},
378
Vincent Bernat061bc732012-05-31 20:21:15 +0200379 /* OSPFv3 neighbors */
380 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry,
381 4, {1, 9, 1, 4}},
382 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry,
383 4, {1, 9, 1, 5}},
384 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry,
385 4, {1, 9, 1, 6}},
386 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry,
387 4, {1, 9, 1, 7}},
388 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry,
389 4, {1, 9, 1, 8}},
390 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry,
391 4, {1, 9, 1, 9}},
392 {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry,
393 4, {1, 9, 1, 10}},
394 {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry,
395 4, {1, 9, 1, 11}},
396 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry,
397 4, {1, 9, 1, 12}},
398 {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry,
399 4, {1, 9, 1, 13}},
400 {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry,
401 4, {1, 9, 1, 14}},
402 {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry,
403 4, {1, 9, 1, 15}},
hassoef1bbf52004-10-08 12:04:21 +0000404};
405
406static u_char *
407ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
408 int exact, size_t *var_len, WriteMethod **write_method)
409{
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200410 u_int16_t sum;
411 u_int32_t count;
412 struct ospf6_lsa *lsa = NULL;
413
hassoef1bbf52004-10-08 12:04:21 +0000414 /* Check whether the instance identifier is valid */
415 if (smux_header_generic (v, name, length, exact, var_len, write_method)
416 == MATCH_FAILED)
417 return NULL;
418
419 /* Return the current value of the variable */
420 switch (v->magic)
421 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200422 case OSPFv3ROUTERID:
hassoef1bbf52004-10-08 12:04:21 +0000423 /* Router-ID of this OSPF instance. */
424 if (ospf6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200425 return SNMP_INTEGER (ntohl (ospf6->router_id));
426 return SNMP_INTEGER (0);
427 case OSPFv3ADMINSTAT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200428 if (ospf6)
429 return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)?
430 OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED);
431 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200432 case OSPFv3VERSIONNUMBER:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200433 return SNMP_INTEGER (3);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200434 case OSPFv3AREABDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200435 if (ospf6)
436 return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE);
437 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200438 case OSPFv3ASBDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200439 if (ospf6)
440 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE);
441 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200442 case OSPFv3ASSCOPELSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200443 if (ospf6)
444 return SNMP_INTEGER (ospf6->lsdb->count);
445 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200446 case OSPFv3ASSCOPELSACHECKSUMSUM:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200447 if (ospf6)
448 {
449 for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb);
450 lsa;
451 lsa = ospf6_lsdb_next (lsa))
452 sum += ntohs (lsa->header->checksum);
453 return SNMP_INTEGER (sum);
454 }
455 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200456 case OSPFv3ORIGINATENEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200457 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200458 case OSPFv3RXNEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200459 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200460 case OSPFv3EXTLSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200461 if (ospf6)
462 {
463 for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL),
464 ospf6->lsdb);
465 lsa;
466 lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
467 lsa))
468 count += 1;
469 return SNMP_INTEGER (count);
470 }
471 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200472 case OSPFv3EXTAREALSDBLIMIT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200473 return SNMP_INTEGER (-1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200474 case OSPFv3EXITOVERFLOWINTERVAL:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200475 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200476 case OSPFv3DEMANDEXTENSIONS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200477 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200478 case OSPFv3REFERENCEBANDWIDTH:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200479 return SNMP_INTEGER (100000);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200480 case OSPFv3RESTARTSUPPORT:
481 case OSPFv3RESTARTINTERVAL:
482 case OSPFv3RESTARTSTRICTLSACHECKING:
483 case OSPFv3RESTARTSTATUS:
484 case OSPFv3RESTARTAGE:
485 case OSPFv3RESTARTEXITREASON:
486 case OSPFv3NOTIFICATIONENABLE:
487 case OSPFv3STUBROUTERSUPPORT:
488 case OSPFv3STUBROUTERADVERTISEMENT:
489 case OSPFv3DISCONTINUITYTIME:
490 case OSPFv3RESTARTTIME:
491 /* TODO: Not implemented */
hassoef1bbf52004-10-08 12:04:21 +0000492 return NULL;
493 }
494 return NULL;
495}
496
497static u_char *
498ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
499 int exact, size_t *var_len, WriteMethod **write_method)
500{
501 struct ospf6_area *oa, *area = NULL;
Vincent Bernatea86e402012-06-04 10:29:49 +0200502 struct ospf6_lsa *lsa = NULL;
hassoef1bbf52004-10-08 12:04:21 +0000503 u_int32_t area_id = 0;
Vincent Bernatea86e402012-06-04 10:29:49 +0200504 u_int32_t count;
505 u_int16_t sum;
paul0c083ee2004-10-10 12:54:58 +0000506 struct listnode *node;
507 unsigned int len;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200508 char a[16];
Vincent Bernatea86e402012-06-04 10:29:49 +0200509 struct ospf6_route *ro;
hassoef1bbf52004-10-08 12:04:21 +0000510
511 if (ospf6 == NULL)
512 return NULL;
513
Vincent Bernat8046ba62012-05-31 13:30:28 +0200514 if (smux_header_table(v, name, length, exact, var_len, write_method)
515 == MATCH_FAILED)
516 return NULL;
517
hassoef1bbf52004-10-08 12:04:21 +0000518 len = *length - v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200519 len = (len >= 1 ? sizeof 1 : 0);
520 if (exact && len != 1)
hassoef1bbf52004-10-08 12:04:21 +0000521 return NULL;
522 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200523 area_id = htonl (name[v->namelen]);
hassoef1bbf52004-10-08 12:04:21 +0000524
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200525 inet_ntop (AF_INET, &area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000526 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200527 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000528
paul1eb8ef22005-04-07 07:30:20 +0000529 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000530 {
hassoef1bbf52004-10-08 12:04:21 +0000531 if (area == NULL)
532 {
533 if (len == 0) /* return first area entry */
534 area = oa;
535 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
536 area = oa;
537 else if (ntohl (oa->area_id) > ntohl (area_id))
538 area = oa;
539 }
540 }
541
542 if (area == NULL)
543 return NULL;
544
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200545 *length = v->namelen + 1;
546 name[v->namelen] = ntohl (area->area_id);
hassoef1bbf52004-10-08 12:04:21 +0000547
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200548 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000549 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200550 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000551
552 switch (v->magic)
553 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200554 case OSPFv3IMPORTASEXTERN:
Vincent Bernatea86e402012-06-04 10:29:49 +0200555 /* No NSSA support */
556 return SNMP_INTEGER (IS_AREA_STUB(area)?2:1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200557 case OSPFv3AREASPFRUNS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200558 return SNMP_INTEGER (area->spf_calculation);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200559 case OSPFv3AREABDRRTRCOUNT:
560 case OSPFv3AREAASBDRRTRCOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200561 count = 0;
562 for (ro = ospf6_route_head (ospf6->brouter_table); ro;
563 ro = ospf6_route_next (ro))
564 {
565 if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue;
566 if (v->magic == OSPFv3AREABDRRTRCOUNT &&
567 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B))
568 count++;
569 if (v->magic == OSPFv3AREAASBDRRTRCOUNT &&
570 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E))
571 count++;
572 }
573 return SNMP_INTEGER (count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200574 case OSPFv3AREASCOPELSACOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200575 return SNMP_INTEGER (area->lsdb->count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200576 case OSPFv3AREASCOPELSACKSUMSUM:
Vincent Bernatea86e402012-06-04 10:29:49 +0200577 for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb);
578 lsa;
579 lsa = ospf6_lsdb_next (lsa))
580 sum += ntohs (lsa->header->checksum);
581 return SNMP_INTEGER (sum);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200582 case OSPFv3AREASUMMARY:
Vincent Bernatea86e402012-06-04 10:29:49 +0200583 return SNMP_INTEGER (2); /* sendAreaSummary */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200584 case OSPFv3AREAROWSTATUS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200585 return SNMP_INTEGER (1); /* Active */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200586 case OSPFv3AREASTUBMETRIC:
587 case OSPFv3AREANSSATRANSLATORROLE:
588 case OSPFv3AREANSSATRANSLATORSTATE:
589 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
590 case OSPFv3AREANSSATRANSLATOREVENTS:
591 case OSPFv3AREASTUBMETRICTYPE:
592 case OSPFv3AREATEENABLED:
593 /* Not implemented. */
hassoef1bbf52004-10-08 12:04:21 +0000594 return NULL;
hassoef1bbf52004-10-08 12:04:21 +0000595 }
596 return NULL;
597}
598
hasso2680aa22004-11-25 20:54:46 +0000599static u_char *
600ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
601 int exact, size_t *var_len, WriteMethod **write_method)
602{
603 struct ospf6_lsa *lsa = NULL;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200604 u_int32_t area_id, id, adv_router;
hasso2680aa22004-11-25 20:54:46 +0000605 u_int16_t type;
hasso2680aa22004-11-25 20:54:46 +0000606 int len;
607 oid *offset;
608 int offsetlen;
609 char a[16], b[16], c[16];
610 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000611 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000612
Vincent Bernat8046ba62012-05-31 13:30:28 +0200613 if (smux_header_table(v, name, length, exact, var_len, write_method)
614 == MATCH_FAILED)
615 return NULL;
616
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200617 area_id = type = id = adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000618
619 /* Check OSPFv3 instance. */
620 if (ospf6 == NULL)
621 return NULL;
622
623 /* Get variable length. */
624 offset = name + v->namelen;
625 offsetlen = *length - v->namelen;
626
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200627#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
hasso2680aa22004-11-25 20:54:46 +0000628
629 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
630 return NULL;
631
632 /* Parse area-id */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200633 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000634 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200635 area_id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000636 offset += len;
637 offsetlen -= len;
638
639 /* Parse type */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200640 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000641 if (len)
642 type = htons (*offset);
643 offset += len;
644 offsetlen -= len;
645
646 /* Parse Router-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200647 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000648 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200649 adv_router = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000650 offset += len;
651 offsetlen -= len;
652
653 /* Parse LS-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200654 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000655 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200656 id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000657 offset += len;
658 offsetlen -= len;
659
660 inet_ntop (AF_INET, &area_id, a, sizeof (a));
661 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
662 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000663 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000664 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000665 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000666
667 if (exact)
668 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200669 oa = ospf6_area_lookup (area_id, ospf6);
670 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
hasso2680aa22004-11-25 20:54:46 +0000671 }
672 else
673 {
paul1eb8ef22005-04-07 07:30:20 +0000674 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000675 {
hasso2680aa22004-11-25 20:54:46 +0000676 if (lsa)
677 continue;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200678 if (oa->area_id < area_id)
hasso2680aa22004-11-25 20:54:46 +0000679 continue;
680
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200681 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
hasso2680aa22004-11-25 20:54:46 +0000682 oa->lsdb);
683 if (! lsa)
684 {
685 type = 0;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200686 id = 0;
687 adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000688 }
689 }
690 }
691
692 if (! lsa)
693 {
hassoc6487d62004-12-24 06:00:11 +0000694 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000695 return NULL;
696 }
697 oa = OSPF6_AREA (lsa->lsdb->data);
698
hassoc6487d62004-12-24 06:00:11 +0000699 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000700
701 /* Add Index (AreaId, Type, RouterId, Lsid) */
702 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
703 offset = name + v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200704 *offset = ntohl (oa->area_id);
705 offset++;
hasso2680aa22004-11-25 20:54:46 +0000706 *offset = ntohs (lsa->header->type);
707 offset++;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200708 *offset = ntohl (lsa->header->adv_router);
709 offset++;
710 *offset = ntohl (lsa->header->id);
711 offset++;
hasso2680aa22004-11-25 20:54:46 +0000712
713 /* Return the current value of the variable */
714 switch (v->magic)
715 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200716 case OSPFv3AREALSDBSEQUENCE:
717 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
hasso2680aa22004-11-25 20:54:46 +0000718 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200719 case OSPFv3AREALSDBAGE:
hasso2680aa22004-11-25 20:54:46 +0000720 ospf6_lsa_age_current (lsa);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200721 return SNMP_INTEGER (ntohs (lsa->header->age));
hasso2680aa22004-11-25 20:54:46 +0000722 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200723 case OSPFv3AREALSDBCHECKSUM:
724 return SNMP_INTEGER (ntohs (lsa->header->checksum));
hasso2680aa22004-11-25 20:54:46 +0000725 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200726 case OSPFv3AREALSDBADVERTISEMENT:
hasso2680aa22004-11-25 20:54:46 +0000727 *var_len = ntohs (lsa->header->length);
728 return (u_char *) lsa->header;
729 break;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200730 case OSPFv3AREALSDBTYPEKNOWN:
hasso2680aa22004-11-25 20:54:46 +0000731 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
732 SNMP_TRUE : SNMP_FALSE);
733 break;
hasso2680aa22004-11-25 20:54:46 +0000734 }
735 return NULL;
736}
737
Vincent Bernat061bc732012-05-31 20:21:15 +0200738static int
739if_icmp_func (struct interface *ifp1, struct interface *ifp2)
740{
741 return (ifp1->ifindex - ifp2->ifindex);
742}
743
744static u_char *
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200745ospfv3IfEntry (struct variable *v, oid *name, size_t *length,
746 int exact, size_t *var_len, WriteMethod **write_method)
747{
748 unsigned int ifindex, instid;
749 struct ospf6_interface *oi = NULL;
750 struct ospf6_lsa *lsa = NULL;
751 struct interface *iif;
752 struct listnode *i;
753 struct list *ifslist;
754 oid *offset;
755 int offsetlen, len;
756 u_int32_t sum;
757
758 if (smux_header_table (v, name, length, exact, var_len, write_method)
759 == MATCH_FAILED)
760 return NULL;
761
762 ifindex = instid = 0;
763
764 /* Check OSPFv3 instance. */
765 if (ospf6 == NULL)
766 return NULL;
767
768 /* Get variable length. */
769 offset = name + v->namelen;
770 offsetlen = *length - v->namelen;
771
772 if (exact && offsetlen != 2)
773 return NULL;
774
775 /* Parse if index */
776 len = (offsetlen < 1 ? 0 : 1);
777 if (len)
778 ifindex = *offset;
779 offset += len;
780 offsetlen -= len;
781
782 /* Parse instance ID */
783 len = (offsetlen < 1 ? 0 : 1);
784 if (len)
785 instid = *offset;
786 offset += len;
787 offsetlen -= len;
788
789 if (exact)
790 {
791 oi = ospf6_interface_lookup_by_ifindex (ifindex);
792 if (oi->instance_id != instid) return NULL;
793 }
794 else
795 {
796 /* We build a sorted list of interfaces */
797 ifslist = list_new ();
798 if (!ifslist) return NULL;
799 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
800 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
801 listnode_add_sort (ifslist, iif);
802
803 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
804 {
805 if (!iif->ifindex) continue;
806 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
807 if (!oi) continue;
808 if (iif->ifindex > ifindex ||
809 (iif->ifindex == ifindex &&
810 (oi->instance_id > instid)))
811 break;
812 oi = NULL;
813 }
814
815 list_delete_all_node (ifslist);
816 }
817
818 if (!oi) return NULL;
819
820 /* Add Index (IfIndex, IfInstId) */
821 *length = v->namelen + 2;
822 offset = name + v->namelen;
823 *offset = oi->interface->ifindex;
824 offset++;
825 *offset = oi->instance_id;
826 offset++;
827
828 /* Return the current value of the variable */
829 switch (v->magic)
830 {
831 case OSPFv3IFAREAID:
832 if (oi->area)
833 return SNMP_INTEGER (ntohl (oi->area->area_id));
834 break;
835 case OSPFv3IFTYPE:
836 if (if_is_broadcast (oi->interface))
837 return SNMP_INTEGER (1);
838 else if (if_is_pointopoint (oi->interface))
839 return SNMP_INTEGER (3);
840 else break; /* Unknown, don't put anything */
841 case OSPFv3IFADMINSTATUS:
842 if (oi->area)
843 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
844 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
845 case OSPFv3IFRTRPRIORITY:
846 return SNMP_INTEGER (oi->priority);
847 case OSPFv3IFTRANSITDELAY:
848 return SNMP_INTEGER (oi->transdelay);
849 case OSPFv3IFRETRANSINTERVAL:
850 return SNMP_INTEGER (oi->rxmt_interval);
851 case OSPFv3IFHELLOINTERVAL:
852 return SNMP_INTEGER (oi->hello_interval);
853 case OSPFv3IFRTRDEADINTERVAL:
854 return SNMP_INTEGER (oi->dead_interval);
855 case OSPFv3IFPOLLINTERVAL:
856 /* No support for NBMA */
857 break;
858 case OSPFv3IFSTATE:
859 return SNMP_INTEGER (oi->state);
860 case OSPFv3IFDESIGNATEDROUTER:
861 return SNMP_INTEGER (ntohl (oi->drouter));
862 case OSPFv3IFBACKUPDESIGNATEDROUTER:
863 return SNMP_INTEGER (ntohl (oi->bdrouter));
864 case OSPFv3IFEVENTS:
865 return SNMP_INTEGER (oi->state_change);
866 case OSPFv3IFROWSTATUS:
867 return SNMP_INTEGER (1);
868 case OSPFv3IFDEMAND:
869 return SNMP_INTEGER (SNMP_FALSE);
870 case OSPFv3IFMETRICVALUE:
871 return SNMP_INTEGER (oi->cost);
872 case OSPFv3IFLINKSCOPELSACOUNT:
873 return SNMP_INTEGER (oi->lsdb->count);
874 case OSPFv3IFLINKLSACKSUMSUM:
875 for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb);
876 lsa;
877 lsa = ospf6_lsdb_next (lsa))
878 sum += ntohs (lsa->header->checksum);
879 return SNMP_INTEGER (sum);
880 case OSPFv3IFDEMANDNBRPROBE:
881 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT:
882 case OSPFv3IFDEMANDNBRPROBEINTERVAL:
883 case OSPFv3IFTEDISABLED:
884 case OSPFv3IFLINKLSASUPPRESSION:
885 /* Not implemented. Only works if all the last ones are not
886 implemented! */
887 return NULL;
888 }
889
890 /* Try an internal getnext. Some columns are missing in this table. */
891 if (!exact && (name[*length-1] < MAX_SUBID))
892 return ospfv3IfEntry(v, name, length,
893 exact, var_len, write_method);
894 return NULL;
895}
896
897static u_char *
Vincent Bernat061bc732012-05-31 20:21:15 +0200898ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
899 int exact, size_t *var_len, WriteMethod **write_method)
900{
901 unsigned int ifindex, instid, rtrid;
902 struct ospf6_interface *oi = NULL;
903 struct ospf6_neighbor *on = NULL;
904 struct interface *iif;
905 struct listnode *i, *j;
906 struct list *ifslist;
907 oid *offset;
908 int offsetlen, len;
909
910 if (smux_header_table (v, name, length, exact, var_len, write_method)
911 == MATCH_FAILED)
912 return NULL;
913
914 ifindex = instid = rtrid = 0;
915
916 /* Check OSPFv3 instance. */
917 if (ospf6 == NULL)
918 return NULL;
919
920 /* Get variable length. */
921 offset = name + v->namelen;
922 offsetlen = *length - v->namelen;
923
924 if (exact && offsetlen != 3)
925 return NULL;
926
927 /* Parse if index */
928 len = (offsetlen < 1 ? 0 : 1);
929 if (len)
930 ifindex = *offset;
931 offset += len;
932 offsetlen -= len;
933
934 /* Parse instance ID */
935 len = (offsetlen < 1 ? 0 : 1);
936 if (len)
937 instid = *offset;
938 offset += len;
939 offsetlen -= len;
940
941 /* Parse router ID */
942 len = (offsetlen < 1 ? 0 : 1);
943 if (len)
944 rtrid = htonl (*offset);
945 offset += len;
946 offsetlen -= len;
947
948 if (exact)
949 {
950 oi = ospf6_interface_lookup_by_ifindex (ifindex);
951 on = ospf6_neighbor_lookup (rtrid, oi);
952 if (oi->instance_id != instid) return NULL;
953 }
954 else
955 {
956 /* We build a sorted list of interfaces */
957 ifslist = list_new ();
958 if (!ifslist) return NULL;
959 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
960 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
961 listnode_add_sort (ifslist, iif);
962
963 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
964 {
965 if (!iif->ifindex) continue;
966 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
967 if (!oi) continue;
968 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
969 if (iif->ifindex > ifindex ||
970 (iif->ifindex == ifindex &&
971 (oi->instance_id > instid ||
972 (oi->instance_id == instid &&
973 ntohl (on->router_id) > ntohl (rtrid)))))
974 break;
975 }
976 if (on) break;
977 oi = on = NULL;
978 }
979
980 list_delete_all_node (ifslist);
981 }
982
983 if (!oi || !on) return NULL;
984
985 /* Add Index (IfIndex, IfInstId, RtrId) */
986 *length = v->namelen + 3;
987 offset = name + v->namelen;
988 *offset = oi->interface->ifindex;
989 offset++;
990 *offset = oi->instance_id;
991 offset++;
992 *offset = ntohl (on->router_id);
993 offset++;
994
995 /* Return the current value of the variable */
996 switch (v->magic)
997 {
998 case OSPFv3NBRADDRESSTYPE:
999 return SNMP_INTEGER (2); /* IPv6 only */
1000 case OSPFv3NBRADDRESS:
1001 *var_len = sizeof (struct in6_addr);
1002 return (u_char *) &on->linklocal_addr;
1003 case OSPFv3NBROPTIONS:
1004 return SNMP_INTEGER (on->options[2]);
1005 case OSPFv3NBRPRIORITY:
1006 return SNMP_INTEGER (on->priority);
1007 case OSPFv3NBRSTATE:
1008 return SNMP_INTEGER (on->state);
1009 case OSPFv3NBREVENTS:
1010 return SNMP_INTEGER (on->state_change);
1011 case OSPFv3NBRLSRETRANSQLEN:
1012 return SNMP_INTEGER (on->retrans_list->count);
1013 case OSPFv3NBRHELLOSUPPRESSED:
1014 return SNMP_INTEGER (SNMP_FALSE);
1015 case OSPFv3NBRIFID:
1016 return SNMP_INTEGER (on->ifindex);
1017 case OSPFv3NBRRESTARTHELPERSTATUS:
1018 case OSPFv3NBRRESTARTHELPERAGE:
1019 case OSPFv3NBRRESTARTHELPEREXITREASON:
1020 /* Not implemented. Only works if all the last ones are not
1021 implemented! */
1022 return NULL;
1023 }
1024
1025 return NULL;
1026}
1027
hassoef1bbf52004-10-08 12:04:21 +00001028/* Register OSPFv3-MIB. */
1029void
paul0c083ee2004-10-10 12:54:58 +00001030ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +00001031{
hassoc75105a2004-10-13 10:33:26 +00001032 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +00001033 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +00001034}
1035
1036#endif /* HAVE_SNMP */
1037