blob: ce49331c335020f3abbcf81c4acdf4c1722ef921 [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 Bernatc349bb82012-06-04 12:59:20 +020093/* OSPFv3 MIB * Lsdb Table values: ospfv3*LsdbTable */
94#define OSPFv3WWLSDBSEQUENCE 1
95#define OSPFv3WWLSDBAGE 2
96#define OSPFv3WWLSDBCHECKSUM 3
97#define OSPFv3WWLSDBADVERTISEMENT 4
98#define OSPFv3WWLSDBTYPEKNOWN 5
Vincent Bernat0f0ab512012-05-22 13:34:24 +020099
Vincent Bernatc349bb82012-06-04 12:59:20 +0200100/* Three first bits are to identify column */
101#define OSPFv3WWCOLUMN 0x7
102/* Then we use other bits to identify table */
103#define OSPFv3WWASTABLE (1 << 3)
104#define OSPFv3WWAREATABLE (1 << 4)
105#define OSPFv3WWLINKTABLE (1 << 5)
106#define OSPFv3WWVIRTLINKTABLE (1 << 6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200107
108/* OSPFv3 MIB Host Table values: ospfv3HostTable */
109#define OSPFv3HOSTMETRIC 3
110#define OSPFv3HOSTROWSTATUS 4
111#define OSPFv3HOSTAREAID 5
112
113/* OSPFv3 MIB Interface Table values: ospfv3IfTable */
114#define OSPFv3IFAREAID 3
115#define OSPFv3IFTYPE 4
116#define OSPFv3IFADMINSTATUS 5
117#define OSPFv3IFRTRPRIORITY 6
118#define OSPFv3IFTRANSITDELAY 7
119#define OSPFv3IFRETRANSINTERVAL 8
120#define OSPFv3IFHELLOINTERVAL 9
121#define OSPFv3IFRTRDEADINTERVAL 10
122#define OSPFv3IFPOLLINTERVAL 11
123#define OSPFv3IFSTATE 12
124#define OSPFv3IFDESIGNATEDROUTER 13
125#define OSPFv3IFBACKUPDESIGNATEDROUTER 14
126#define OSPFv3IFEVENTS 15
127#define OSPFv3IFROWSTATUS 16
128#define OSPFv3IFDEMAND 17
129#define OSPFv3IFMETRICVALUE 18
130#define OSPFv3IFLINKSCOPELSACOUNT 19
131#define OSPFv3IFLINKLSACKSUMSUM 20
132#define OSPFv3IFDEMANDNBRPROBE 21
133#define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22
134#define OSPFv3IFDEMANDNBRPROBEINTERVAL 23
135#define OSPFv3IFTEDISABLED 24
136#define OSPFv3IFLINKLSASUPPRESSION 25
137
138/* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */
139#define OSPFv3VIRTIFINDEX 3
140#define OSPFv3VIRTIFINSTID 4
141#define OSPFv3VIRTIFTRANSITDELAY 5
142#define OSPFv3VIRTIFRETRANSINTERVAL 6
143#define OSPFv3VIRTIFHELLOINTERVAL 7
144#define OSPFv3VIRTIFRTRDEADINTERVAL 8
145#define OSPFv3VIRTIFSTATE 9
146#define OSPFv3VIRTIFEVENTS 10
147#define OSPFv3VIRTIFROWSTATUS 11
148#define OSPFv3VIRTIFLINKSCOPELSACOUNT 12
149#define OSPFv3VIRTIFLINKLSACKSUMSUM 13
150
151/* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */
152#define OSPFv3NBRADDRESSTYPE 4
153#define OSPFv3NBRADDRESS 5
154#define OSPFv3NBROPTIONS 6
155#define OSPFv3NBRPRIORITY 7
156#define OSPFv3NBRSTATE 8
157#define OSPFv3NBREVENTS 9
158#define OSPFv3NBRLSRETRANSQLEN 10
159#define OSPFv3NBRHELLOSUPPRESSED 11
160#define OSPFv3NBRIFID 12
161#define OSPFv3NBRRESTARTHELPERSTATUS 13
162#define OSPFv3NBRRESTARTHELPERAGE 14
163#define OSPFv3NBRRESTARTHELPEREXITREASON 15
164
165/* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */
166#define OSPFv3CFGNBRPRIORITY 5
167#define OSPFv3CFGNBRROWSTATUS 6
168
169/* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */
170#define OSPFv3VIRTNBRIFINDEX 3
171#define OSPFv3VIRTNBRIFINSTID 4
172#define OSPFv3VIRTNBRADDRESSTYPE 5
173#define OSPFv3VIRTNBRADDRESS 6
174#define OSPFv3VIRTNBROPTIONS 7
175#define OSPFv3VIRTNBRSTATE 8
176#define OSPFv3VIRTNBREVENTS 9
177#define OSPFv3VIRTNBRLSRETRANSQLEN 10
178#define OSPFv3VIRTNBRHELLOSUPPRESSED 11
179#define OSPFv3VIRTNBRIFID 12
180#define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13
181#define OSPFv3VIRTNBRRESTARTHELPERAGE 14
182#define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15
183
184/* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */
185#define OSPFv3AREAAGGREGATEROWSTATUS 6
186#define OSPFv3AREAAGGREGATEEFFECT 7
187#define OSPFv3AREAAGGREGATEROUTETAG 8
188
hassoef1bbf52004-10-08 12:04:21 +0000189/* SYNTAX Status from OSPF-MIB. */
190#define OSPF_STATUS_ENABLED 1
191#define OSPF_STATUS_DISABLED 2
192
193/* SNMP value hack. */
194#define COUNTER ASN_COUNTER
195#define INTEGER ASN_INTEGER
196#define GAUGE ASN_GAUGE
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200197#define UNSIGNED ASN_UNSIGNED
hassoef1bbf52004-10-08 12:04:21 +0000198#define TIMETICKS ASN_TIMETICKS
199#define IPADDRESS ASN_IPADDRESS
200#define STRING ASN_OCTET_STR
201
202/* For return values e.g. SNMP_INTEGER macro */
203SNMP_LOCAL_VARIABLES
204
hassoef1bbf52004-10-08 12:04:21 +0000205/* OSPFv3-MIB instances. */
206oid ospfv3_oid [] = { OSPFv3MIB };
hassoef1bbf52004-10-08 12:04:21 +0000207
hassoef1bbf52004-10-08 12:04:21 +0000208/* Hook functions. */
Chris Caputo0be8dfb2009-06-02 18:40:07 +0100209static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
210 int, size_t *, WriteMethod **);
211static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
212 int, size_t *, WriteMethod **);
Vincent Bernatc349bb82012-06-04 12:59:20 +0200213static u_char *ospfv3WwLsdbEntry (struct variable *, oid *, size_t *,
214 int, size_t *, WriteMethod **);
Vincent Bernat061bc732012-05-31 20:21:15 +0200215static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *,
216 int, size_t *, WriteMethod **);
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200217static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *,
218 int, size_t *, WriteMethod **);
hassoef1bbf52004-10-08 12:04:21 +0000219
220struct variable ospfv3_variables[] =
221{
222 /* OSPF general variables */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200223 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000224 3, {1, 1, 1}},
225 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
226 3, {1, 1, 2}},
227 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
228 3, {1, 1, 3}},
229 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
230 3, {1, 1, 4}},
231 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
232 3, {1, 1, 5}},
233 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
234 3, {1, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200235 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000236 3, {1, 1, 7}},
237 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
238 3, {1, 1, 8}},
239 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
240 3, {1, 1, 9}},
241 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
242 3, {1, 1, 10}},
243 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
244 3, {1, 1, 11}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200245 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000246 3, {1, 1, 12}},
hassoef1bbf52004-10-08 12:04:21 +0000247 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200248 3, {1, 1, 13}},
249 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000250 3, {1, 1, 14}},
hassoef1bbf52004-10-08 12:04:21 +0000251 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200252 3, {1, 1, 15}},
253 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
254 3, {1, 1, 16}},
255 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000256 3, {1, 1, 17}},
hassoef1bbf52004-10-08 12:04:21 +0000257 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200258 3, {1, 1, 18}},
259 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000260 3, {1, 1, 19}},
hassoef1bbf52004-10-08 12:04:21 +0000261 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200262 3, {1, 1, 20}},
263 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
hassoef1bbf52004-10-08 12:04:21 +0000264 3, {1, 1, 21}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200265 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
266 3, {1, 1, 22}},
267 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
268 3, {1, 1, 23}},
269 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
270 3, {1, 1, 24}},
271 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
272 3, {1, 1, 25}},
hassoef1bbf52004-10-08 12:04:21 +0000273
274 /* OSPFv3 Area Data Structure */
hasso2680aa22004-11-25 20:54:46 +0000275 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
hassoef1bbf52004-10-08 12:04:21 +0000276 4, {1, 2, 1, 2}},
hasso2680aa22004-11-25 20:54:46 +0000277 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
278 4, {1, 2, 1, 3}},
279 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
280 4, {1, 2, 1, 4}},
281 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
282 4, {1, 2, 1, 5}},
283 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
284 4, {1, 2, 1, 6}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200285 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000286 4, {1, 2, 1, 7}},
287 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
288 4, {1, 2, 1, 8}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200289 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000290 4, {1, 2, 1, 9}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200291 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000292 4, {1, 2, 1, 10}},
293 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
294 4, {1, 2, 1, 11}},
295 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
296 4, {1, 2, 1, 12}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200297 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
hasso2680aa22004-11-25 20:54:46 +0000298 4, {1, 2, 1, 13}},
299 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
300 4, {1, 2, 1, 14}},
301 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
302 4, {1, 2, 1, 15}},
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200303 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
304 4, {1, 2, 1, 16}},
hasso2680aa22004-11-25 20:54:46 +0000305
Vincent Bernatc349bb82012-06-04 12:59:20 +0200306 /* OSPFv3 AS LSDB */
307 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
308 4, {1, 3, 1, 4}},
309 {OSPFv3WWLSDBAGE | OSPFv3WWASTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
310 4, {1, 3, 1, 5}},
311 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
312 4, {1, 3, 1, 6}},
313 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWASTABLE, STRING, RONLY, ospfv3WwLsdbEntry,
314 4, {1, 3, 1, 7}},
315 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
316 4, {1, 3, 1, 8}},
317
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200318 /* OSPFv3 Area LSDB */
Vincent Bernatc349bb82012-06-04 12:59:20 +0200319 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000320 4, {1, 4, 1, 5}},
Vincent Bernatc349bb82012-06-04 12:59:20 +0200321 {OSPFv3WWLSDBAGE | OSPFv3WWAREATABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000322 4, {1, 4, 1, 6}},
Vincent Bernatc349bb82012-06-04 12:59:20 +0200323 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000324 4, {1, 4, 1, 7}},
Vincent Bernatc349bb82012-06-04 12:59:20 +0200325 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWAREATABLE, STRING, RONLY, ospfv3WwLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000326 4, {1, 4, 1, 8}},
Vincent Bernatc349bb82012-06-04 12:59:20 +0200327 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
hasso2680aa22004-11-25 20:54:46 +0000328 4, {1, 4, 1, 9}},
329
Vincent Bernatc349bb82012-06-04 12:59:20 +0200330 /* OSPFv3 Link LSDB */
331 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
332 4, {1, 5, 1, 6}},
333 {OSPFv3WWLSDBAGE | OSPFv3WWLINKTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
334 4, {1, 5, 1, 7}},
335 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
336 4, {1, 5, 1, 8}},
337 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWLINKTABLE, STRING, RONLY, ospfv3WwLsdbEntry,
338 4, {1, 5, 1, 9}},
339 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
340 4, {1, 5, 1, 10}},
341
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200342 /* OSPFv3 interfaces */
343 {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry,
344 4, {1, 7, 1, 3}},
345 {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry,
346 4, {1, 7, 1, 4}},
347 {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry,
348 4, {1, 7, 1, 5}},
349 {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry,
350 4, {1, 7, 1, 6}},
351 {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry,
352 4, {1, 7, 1, 7}},
353 {OSPFv3IFRETRANSINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
354 4, {1, 7, 1, 8}},
355 {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry,
356 4, {1, 7, 1, 9}},
357 {OSPFv3IFRTRDEADINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
358 4, {1, 7, 1, 10}},
359 {OSPFv3IFPOLLINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
360 4, {1, 7, 1, 11}},
361 {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry,
362 4, {1, 7, 1, 12}},
363 {OSPFv3IFDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
364 4, {1, 7, 1, 13}},
365 {OSPFv3IFBACKUPDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
366 4, {1, 7, 1, 14}},
367 {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry,
368 4, {1, 7, 1, 15}},
369 {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry,
370 4, {1, 7, 1, 16}},
371 {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry,
372 4, {1, 7, 1, 17}},
373 {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry,
374 4, {1, 7, 1, 18}},
375 {OSPFv3IFLINKSCOPELSACOUNT, GAUGE, RONLY, ospfv3IfEntry,
376 4, {1, 7, 1, 19}},
377 {OSPFv3IFLINKLSACKSUMSUM, UNSIGNED, RONLY, ospfv3IfEntry,
378 4, {1, 7, 1, 20}},
379 {OSPFv3IFDEMANDNBRPROBE, INTEGER, RONLY, ospfv3IfEntry,
380 4, {1, 7, 1, 21}},
381 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT, UNSIGNED, RONLY, ospfv3IfEntry,
382 4, {1, 7, 1, 22}},
383 {OSPFv3IFDEMANDNBRPROBEINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
384 4, {1, 7, 1, 23}},
385 {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry,
386 4, {1, 7, 1, 24}},
387 {OSPFv3IFLINKLSASUPPRESSION, INTEGER, RONLY, ospfv3IfEntry,
388 4, {1, 7, 1, 25}},
389
Vincent Bernat061bc732012-05-31 20:21:15 +0200390 /* OSPFv3 neighbors */
391 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry,
392 4, {1, 9, 1, 4}},
393 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry,
394 4, {1, 9, 1, 5}},
395 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry,
396 4, {1, 9, 1, 6}},
397 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry,
398 4, {1, 9, 1, 7}},
399 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry,
400 4, {1, 9, 1, 8}},
401 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry,
402 4, {1, 9, 1, 9}},
403 {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry,
404 4, {1, 9, 1, 10}},
405 {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry,
406 4, {1, 9, 1, 11}},
407 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry,
408 4, {1, 9, 1, 12}},
409 {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry,
410 4, {1, 9, 1, 13}},
411 {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry,
412 4, {1, 9, 1, 14}},
413 {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry,
414 4, {1, 9, 1, 15}},
hassoef1bbf52004-10-08 12:04:21 +0000415};
416
417static u_char *
418ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
419 int exact, size_t *var_len, WriteMethod **write_method)
420{
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200421 u_int16_t sum;
422 u_int32_t count;
423 struct ospf6_lsa *lsa = NULL;
424
hassoef1bbf52004-10-08 12:04:21 +0000425 /* Check whether the instance identifier is valid */
426 if (smux_header_generic (v, name, length, exact, var_len, write_method)
427 == MATCH_FAILED)
428 return NULL;
429
430 /* Return the current value of the variable */
431 switch (v->magic)
432 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200433 case OSPFv3ROUTERID:
hassoef1bbf52004-10-08 12:04:21 +0000434 /* Router-ID of this OSPF instance. */
435 if (ospf6)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200436 return SNMP_INTEGER (ntohl (ospf6->router_id));
437 return SNMP_INTEGER (0);
438 case OSPFv3ADMINSTAT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200439 if (ospf6)
440 return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)?
441 OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED);
442 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200443 case OSPFv3VERSIONNUMBER:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200444 return SNMP_INTEGER (3);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200445 case OSPFv3AREABDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200446 if (ospf6)
447 return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE);
448 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200449 case OSPFv3ASBDRRTRSTATUS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200450 if (ospf6)
451 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE);
452 return SNMP_INTEGER (SNMP_FALSE);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200453 case OSPFv3ASSCOPELSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200454 if (ospf6)
455 return SNMP_INTEGER (ospf6->lsdb->count);
456 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200457 case OSPFv3ASSCOPELSACHECKSUMSUM:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200458 if (ospf6)
459 {
460 for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb);
461 lsa;
462 lsa = ospf6_lsdb_next (lsa))
463 sum += ntohs (lsa->header->checksum);
464 return SNMP_INTEGER (sum);
465 }
466 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200467 case OSPFv3ORIGINATENEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200468 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200469 case OSPFv3RXNEWLSAS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200470 return SNMP_INTEGER (0); /* Don't know where to get this value... */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200471 case OSPFv3EXTLSACOUNT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200472 if (ospf6)
473 {
474 for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL),
475 ospf6->lsdb);
476 lsa;
477 lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
478 lsa))
479 count += 1;
480 return SNMP_INTEGER (count);
481 }
482 return SNMP_INTEGER (0);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200483 case OSPFv3EXTAREALSDBLIMIT:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200484 return SNMP_INTEGER (-1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200485 case OSPFv3EXITOVERFLOWINTERVAL:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200486 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200487 case OSPFv3DEMANDEXTENSIONS:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200488 return SNMP_INTEGER (0); /* Not supported */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200489 case OSPFv3REFERENCEBANDWIDTH:
Vincent Bernat2c5f1482012-06-01 11:38:34 +0200490 return SNMP_INTEGER (100000);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200491 case OSPFv3RESTARTSUPPORT:
492 case OSPFv3RESTARTINTERVAL:
493 case OSPFv3RESTARTSTRICTLSACHECKING:
494 case OSPFv3RESTARTSTATUS:
495 case OSPFv3RESTARTAGE:
496 case OSPFv3RESTARTEXITREASON:
497 case OSPFv3NOTIFICATIONENABLE:
498 case OSPFv3STUBROUTERSUPPORT:
499 case OSPFv3STUBROUTERADVERTISEMENT:
500 case OSPFv3DISCONTINUITYTIME:
501 case OSPFv3RESTARTTIME:
502 /* TODO: Not implemented */
hassoef1bbf52004-10-08 12:04:21 +0000503 return NULL;
504 }
505 return NULL;
506}
507
508static u_char *
509ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
510 int exact, size_t *var_len, WriteMethod **write_method)
511{
512 struct ospf6_area *oa, *area = NULL;
Vincent Bernatea86e402012-06-04 10:29:49 +0200513 struct ospf6_lsa *lsa = NULL;
hassoef1bbf52004-10-08 12:04:21 +0000514 u_int32_t area_id = 0;
Vincent Bernatea86e402012-06-04 10:29:49 +0200515 u_int32_t count;
516 u_int16_t sum;
paul0c083ee2004-10-10 12:54:58 +0000517 struct listnode *node;
518 unsigned int len;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200519 char a[16];
Vincent Bernatea86e402012-06-04 10:29:49 +0200520 struct ospf6_route *ro;
hassoef1bbf52004-10-08 12:04:21 +0000521
522 if (ospf6 == NULL)
523 return NULL;
524
Vincent Bernat8046ba62012-05-31 13:30:28 +0200525 if (smux_header_table(v, name, length, exact, var_len, write_method)
526 == MATCH_FAILED)
527 return NULL;
528
hassoef1bbf52004-10-08 12:04:21 +0000529 len = *length - v->namelen;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200530 len = (len >= 1 ? sizeof 1 : 0);
531 if (exact && len != 1)
hassoef1bbf52004-10-08 12:04:21 +0000532 return NULL;
533 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200534 area_id = htonl (name[v->namelen]);
hassoef1bbf52004-10-08 12:04:21 +0000535
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200536 inet_ntop (AF_INET, &area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000537 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200538 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000539
paul1eb8ef22005-04-07 07:30:20 +0000540 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000541 {
hassoef1bbf52004-10-08 12:04:21 +0000542 if (area == NULL)
543 {
544 if (len == 0) /* return first area entry */
545 area = oa;
546 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
547 area = oa;
548 else if (ntohl (oa->area_id) > ntohl (area_id))
549 area = oa;
550 }
551 }
552
553 if (area == NULL)
554 return NULL;
555
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200556 *length = v->namelen + 1;
557 name[v->namelen] = ntohl (area->area_id);
hassoef1bbf52004-10-08 12:04:21 +0000558
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200559 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000560 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200561 a, exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000562
563 switch (v->magic)
564 {
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200565 case OSPFv3IMPORTASEXTERN:
Vincent Bernatea86e402012-06-04 10:29:49 +0200566 /* No NSSA support */
567 return SNMP_INTEGER (IS_AREA_STUB(area)?2:1);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200568 case OSPFv3AREASPFRUNS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200569 return SNMP_INTEGER (area->spf_calculation);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200570 case OSPFv3AREABDRRTRCOUNT:
571 case OSPFv3AREAASBDRRTRCOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200572 count = 0;
573 for (ro = ospf6_route_head (ospf6->brouter_table); ro;
574 ro = ospf6_route_next (ro))
575 {
576 if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue;
577 if (v->magic == OSPFv3AREABDRRTRCOUNT &&
578 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B))
579 count++;
580 if (v->magic == OSPFv3AREAASBDRRTRCOUNT &&
581 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E))
582 count++;
583 }
584 return SNMP_INTEGER (count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200585 case OSPFv3AREASCOPELSACOUNT:
Vincent Bernatea86e402012-06-04 10:29:49 +0200586 return SNMP_INTEGER (area->lsdb->count);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200587 case OSPFv3AREASCOPELSACKSUMSUM:
Vincent Bernatea86e402012-06-04 10:29:49 +0200588 for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb);
589 lsa;
590 lsa = ospf6_lsdb_next (lsa))
591 sum += ntohs (lsa->header->checksum);
592 return SNMP_INTEGER (sum);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200593 case OSPFv3AREASUMMARY:
Vincent Bernatea86e402012-06-04 10:29:49 +0200594 return SNMP_INTEGER (2); /* sendAreaSummary */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200595 case OSPFv3AREAROWSTATUS:
Vincent Bernatea86e402012-06-04 10:29:49 +0200596 return SNMP_INTEGER (1); /* Active */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200597 case OSPFv3AREASTUBMETRIC:
598 case OSPFv3AREANSSATRANSLATORROLE:
599 case OSPFv3AREANSSATRANSLATORSTATE:
600 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
601 case OSPFv3AREANSSATRANSLATOREVENTS:
602 case OSPFv3AREASTUBMETRICTYPE:
603 case OSPFv3AREATEENABLED:
604 /* Not implemented. */
hassoef1bbf52004-10-08 12:04:21 +0000605 return NULL;
hassoef1bbf52004-10-08 12:04:21 +0000606 }
607 return NULL;
608}
609
Vincent Bernatc349bb82012-06-04 12:59:20 +0200610static int
611if_icmp_func (struct interface *ifp1, struct interface *ifp2)
612{
613 return (ifp1->ifindex - ifp2->ifindex);
614}
615
hasso2680aa22004-11-25 20:54:46 +0000616static u_char *
Vincent Bernatc349bb82012-06-04 12:59:20 +0200617ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length,
hasso2680aa22004-11-25 20:54:46 +0000618 int exact, size_t *var_len, WriteMethod **write_method)
619{
620 struct ospf6_lsa *lsa = NULL;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200621 u_int32_t ifindex, area_id, id, instid, adv_router;
hasso2680aa22004-11-25 20:54:46 +0000622 u_int16_t type;
hasso2680aa22004-11-25 20:54:46 +0000623 int len;
624 oid *offset;
625 int offsetlen;
626 char a[16], b[16], c[16];
627 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000628 struct listnode *node;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200629 struct interface *iif;
630 struct ospf6_interface *oi = NULL;
631 struct list *ifslist;
hasso2680aa22004-11-25 20:54:46 +0000632
Vincent Bernat8046ba62012-05-31 13:30:28 +0200633 if (smux_header_table(v, name, length, exact, var_len, write_method)
634 == MATCH_FAILED)
635 return NULL;
636
Vincent Bernatc349bb82012-06-04 12:59:20 +0200637 instid = ifindex = area_id = type = id = adv_router = 0;
hasso2680aa22004-11-25 20:54:46 +0000638
639 /* Check OSPFv3 instance. */
640 if (ospf6 == NULL)
641 return NULL;
642
643 /* Get variable length. */
644 offset = name + v->namelen;
645 offsetlen = *length - v->namelen;
646
Vincent Bernatc349bb82012-06-04 12:59:20 +0200647 if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3)
648 return NULL;
649 if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4)
650 return NULL;
651 if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5)
hasso2680aa22004-11-25 20:54:46 +0000652 return NULL;
653
Vincent Bernatc349bb82012-06-04 12:59:20 +0200654 if (v->magic & OSPFv3WWLINKTABLE)
655 {
656 /* Parse ifindex */
657 len = (offsetlen < 1 ? 0 : 1);
658 if (len)
659 ifindex = *offset;
660 offset += len;
661 offsetlen -= len;
662
663 /* Parse instance ID */
664 len = (offsetlen < 1 ? 0 : 1);
665 if (len)
666 instid = *offset;
667 offset += len;
668 offsetlen -= len;
669 }
670 else if (v->magic & OSPFv3WWAREATABLE)
671 {
672 /* Parse area-id */
673 len = (offsetlen < 1 ? 0 : 1);
674 if (len)
675 area_id = htonl (*offset);
676 offset += len;
677 offsetlen -= len;
678 }
hasso2680aa22004-11-25 20:54:46 +0000679
680 /* Parse type */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200681 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000682 if (len)
683 type = htons (*offset);
684 offset += len;
685 offsetlen -= len;
686
687 /* Parse Router-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200688 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000689 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200690 adv_router = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000691 offset += len;
692 offsetlen -= len;
693
694 /* Parse LS-ID */
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200695 len = (offsetlen < 1 ? 0 : 1);
hasso2680aa22004-11-25 20:54:46 +0000696 if (len)
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200697 id = htonl (*offset);
hasso2680aa22004-11-25 20:54:46 +0000698 offset += len;
699 offsetlen -= len;
700
hasso2680aa22004-11-25 20:54:46 +0000701 if (exact)
702 {
Vincent Bernatc349bb82012-06-04 12:59:20 +0200703 if (v->magic & OSPFv3WWASTABLE)
704 {
705 lsa = ospf6_lsdb_lookup (type, id, adv_router, ospf6->lsdb);
706 }
707 else if (v->magic & OSPFv3WWAREATABLE)
708 {
709 oa = ospf6_area_lookup (area_id, ospf6);
710 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
711 }
712 else if (v->magic & OSPFv3WWLINKTABLE)
713 {
714 oi = ospf6_interface_lookup_by_ifindex (ifindex);
715 if (oi->instance_id != instid) return NULL;
716 lsa = ospf6_lsdb_lookup (type, id, adv_router, oi->lsdb);
717 }
hasso2680aa22004-11-25 20:54:46 +0000718 }
719 else
720 {
Vincent Bernatc349bb82012-06-04 12:59:20 +0200721 if (v->magic & OSPFv3WWASTABLE)
722 {
723 if (ospf6->lsdb->count)
724 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
725 ospf6->lsdb);
726 }
727 else if (v->magic & OSPFv3WWAREATABLE)
728 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
729 {
730 if (oa->area_id < area_id)
731 continue;
hasso2680aa22004-11-25 20:54:46 +0000732
Vincent Bernatc349bb82012-06-04 12:59:20 +0200733 if (oa->lsdb->count)
734 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
735 oa->lsdb);
736 if (lsa) break;
737 type = 0;
738 id = 0;
739 adv_router = 0;
740 }
741 else if (v->magic & OSPFv3WWLINKTABLE)
742 {
743 /* We build a sorted list of interfaces */
744 ifslist = list_new ();
745 if (!ifslist) return NULL;
746 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
747 for (ALL_LIST_ELEMENTS_RO (iflist, node, iif))
748 listnode_add_sort (ifslist, iif);
749
750 for (ALL_LIST_ELEMENTS_RO (ifslist, node, iif))
hasso2680aa22004-11-25 20:54:46 +0000751 {
Vincent Bernatc349bb82012-06-04 12:59:20 +0200752 if (!iif->ifindex) continue;
753 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
754 if (!oi) continue;
755 if (iif->ifindex < ifindex) continue;
756 if (oi->instance_id < instid) continue;
757
758 if (oi->lsdb->count)
759 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
760 oi->lsdb);
761 if (lsa) break;
hasso2680aa22004-11-25 20:54:46 +0000762 type = 0;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200763 id = 0;
764 adv_router = 0;
765 oi = NULL;
hasso2680aa22004-11-25 20:54:46 +0000766 }
Vincent Bernatc349bb82012-06-04 12:59:20 +0200767
768 list_delete_all_node (ifslist);
hasso2680aa22004-11-25 20:54:46 +0000769 }
770 }
771
772 if (! lsa)
hasso2680aa22004-11-25 20:54:46 +0000773 return NULL;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200774
775 /* Add indexes */
776 if (v->magic & OSPFv3WWASTABLE)
777 {
778 *length = v->namelen + 3;
779 offset = name + v->namelen;
hasso2680aa22004-11-25 20:54:46 +0000780 }
Vincent Bernatc349bb82012-06-04 12:59:20 +0200781 else if (v->magic & OSPFv3WWAREATABLE)
782 {
783 *length = v->namelen + 4;
784 offset = name + v->namelen;
785 *offset = ntohl (oa->area_id);
786 offset++;
787 }
788 else if (v->magic & OSPFv3WWLINKTABLE)
789 {
790 *length = v->namelen + 5;
791 offset = name + v->namelen;
792 *offset = oi->interface->ifindex;
793 offset++;
794 *offset = oi->instance_id;
795 offset++;
796 }
hasso2680aa22004-11-25 20:54:46 +0000797 *offset = ntohs (lsa->header->type);
798 offset++;
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200799 *offset = ntohl (lsa->header->adv_router);
800 offset++;
801 *offset = ntohl (lsa->header->id);
802 offset++;
hasso2680aa22004-11-25 20:54:46 +0000803
804 /* Return the current value of the variable */
Vincent Bernatc349bb82012-06-04 12:59:20 +0200805 switch (v->magic & OSPFv3WWCOLUMN)
hasso2680aa22004-11-25 20:54:46 +0000806 {
Vincent Bernatc349bb82012-06-04 12:59:20 +0200807 case OSPFv3WWLSDBSEQUENCE:
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200808 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
hasso2680aa22004-11-25 20:54:46 +0000809 break;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200810 case OSPFv3WWLSDBAGE:
hasso2680aa22004-11-25 20:54:46 +0000811 ospf6_lsa_age_current (lsa);
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200812 return SNMP_INTEGER (ntohs (lsa->header->age));
hasso2680aa22004-11-25 20:54:46 +0000813 break;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200814 case OSPFv3WWLSDBCHECKSUM:
Vincent Bernat0f0ab512012-05-22 13:34:24 +0200815 return SNMP_INTEGER (ntohs (lsa->header->checksum));
hasso2680aa22004-11-25 20:54:46 +0000816 break;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200817 case OSPFv3WWLSDBADVERTISEMENT:
hasso2680aa22004-11-25 20:54:46 +0000818 *var_len = ntohs (lsa->header->length);
819 return (u_char *) lsa->header;
820 break;
Vincent Bernatc349bb82012-06-04 12:59:20 +0200821 case OSPFv3WWLSDBTYPEKNOWN:
hasso2680aa22004-11-25 20:54:46 +0000822 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
823 SNMP_TRUE : SNMP_FALSE);
824 break;
hasso2680aa22004-11-25 20:54:46 +0000825 }
826 return NULL;
827}
828
Vincent Bernat061bc732012-05-31 20:21:15 +0200829static u_char *
Vincent Bernat3bc4f842012-06-04 11:40:04 +0200830ospfv3IfEntry (struct variable *v, oid *name, size_t *length,
831 int exact, size_t *var_len, WriteMethod **write_method)
832{
833 unsigned int ifindex, instid;
834 struct ospf6_interface *oi = NULL;
835 struct ospf6_lsa *lsa = NULL;
836 struct interface *iif;
837 struct listnode *i;
838 struct list *ifslist;
839 oid *offset;
840 int offsetlen, len;
841 u_int32_t sum;
842
843 if (smux_header_table (v, name, length, exact, var_len, write_method)
844 == MATCH_FAILED)
845 return NULL;
846
847 ifindex = instid = 0;
848
849 /* Check OSPFv3 instance. */
850 if (ospf6 == NULL)
851 return NULL;
852
853 /* Get variable length. */
854 offset = name + v->namelen;
855 offsetlen = *length - v->namelen;
856
857 if (exact && offsetlen != 2)
858 return NULL;
859
860 /* Parse if index */
861 len = (offsetlen < 1 ? 0 : 1);
862 if (len)
863 ifindex = *offset;
864 offset += len;
865 offsetlen -= len;
866
867 /* Parse instance ID */
868 len = (offsetlen < 1 ? 0 : 1);
869 if (len)
870 instid = *offset;
871 offset += len;
872 offsetlen -= len;
873
874 if (exact)
875 {
876 oi = ospf6_interface_lookup_by_ifindex (ifindex);
877 if (oi->instance_id != instid) return NULL;
878 }
879 else
880 {
881 /* We build a sorted list of interfaces */
882 ifslist = list_new ();
883 if (!ifslist) return NULL;
884 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
885 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
886 listnode_add_sort (ifslist, iif);
887
888 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
889 {
890 if (!iif->ifindex) continue;
891 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
892 if (!oi) continue;
893 if (iif->ifindex > ifindex ||
894 (iif->ifindex == ifindex &&
895 (oi->instance_id > instid)))
896 break;
897 oi = NULL;
898 }
899
900 list_delete_all_node (ifslist);
901 }
902
903 if (!oi) return NULL;
904
905 /* Add Index (IfIndex, IfInstId) */
906 *length = v->namelen + 2;
907 offset = name + v->namelen;
908 *offset = oi->interface->ifindex;
909 offset++;
910 *offset = oi->instance_id;
911 offset++;
912
913 /* Return the current value of the variable */
914 switch (v->magic)
915 {
916 case OSPFv3IFAREAID:
917 if (oi->area)
918 return SNMP_INTEGER (ntohl (oi->area->area_id));
919 break;
920 case OSPFv3IFTYPE:
921 if (if_is_broadcast (oi->interface))
922 return SNMP_INTEGER (1);
923 else if (if_is_pointopoint (oi->interface))
924 return SNMP_INTEGER (3);
925 else break; /* Unknown, don't put anything */
926 case OSPFv3IFADMINSTATUS:
927 if (oi->area)
928 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
929 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
930 case OSPFv3IFRTRPRIORITY:
931 return SNMP_INTEGER (oi->priority);
932 case OSPFv3IFTRANSITDELAY:
933 return SNMP_INTEGER (oi->transdelay);
934 case OSPFv3IFRETRANSINTERVAL:
935 return SNMP_INTEGER (oi->rxmt_interval);
936 case OSPFv3IFHELLOINTERVAL:
937 return SNMP_INTEGER (oi->hello_interval);
938 case OSPFv3IFRTRDEADINTERVAL:
939 return SNMP_INTEGER (oi->dead_interval);
940 case OSPFv3IFPOLLINTERVAL:
941 /* No support for NBMA */
942 break;
943 case OSPFv3IFSTATE:
944 return SNMP_INTEGER (oi->state);
945 case OSPFv3IFDESIGNATEDROUTER:
946 return SNMP_INTEGER (ntohl (oi->drouter));
947 case OSPFv3IFBACKUPDESIGNATEDROUTER:
948 return SNMP_INTEGER (ntohl (oi->bdrouter));
949 case OSPFv3IFEVENTS:
950 return SNMP_INTEGER (oi->state_change);
951 case OSPFv3IFROWSTATUS:
952 return SNMP_INTEGER (1);
953 case OSPFv3IFDEMAND:
954 return SNMP_INTEGER (SNMP_FALSE);
955 case OSPFv3IFMETRICVALUE:
956 return SNMP_INTEGER (oi->cost);
957 case OSPFv3IFLINKSCOPELSACOUNT:
958 return SNMP_INTEGER (oi->lsdb->count);
959 case OSPFv3IFLINKLSACKSUMSUM:
960 for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb);
961 lsa;
962 lsa = ospf6_lsdb_next (lsa))
963 sum += ntohs (lsa->header->checksum);
964 return SNMP_INTEGER (sum);
965 case OSPFv3IFDEMANDNBRPROBE:
966 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT:
967 case OSPFv3IFDEMANDNBRPROBEINTERVAL:
968 case OSPFv3IFTEDISABLED:
969 case OSPFv3IFLINKLSASUPPRESSION:
970 /* Not implemented. Only works if all the last ones are not
971 implemented! */
972 return NULL;
973 }
974
975 /* Try an internal getnext. Some columns are missing in this table. */
976 if (!exact && (name[*length-1] < MAX_SUBID))
977 return ospfv3IfEntry(v, name, length,
978 exact, var_len, write_method);
979 return NULL;
980}
981
982static u_char *
Vincent Bernat061bc732012-05-31 20:21:15 +0200983ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
984 int exact, size_t *var_len, WriteMethod **write_method)
985{
986 unsigned int ifindex, instid, rtrid;
987 struct ospf6_interface *oi = NULL;
988 struct ospf6_neighbor *on = NULL;
989 struct interface *iif;
990 struct listnode *i, *j;
991 struct list *ifslist;
992 oid *offset;
993 int offsetlen, len;
994
995 if (smux_header_table (v, name, length, exact, var_len, write_method)
996 == MATCH_FAILED)
997 return NULL;
998
999 ifindex = instid = rtrid = 0;
1000
1001 /* Check OSPFv3 instance. */
1002 if (ospf6 == NULL)
1003 return NULL;
1004
1005 /* Get variable length. */
1006 offset = name + v->namelen;
1007 offsetlen = *length - v->namelen;
1008
1009 if (exact && offsetlen != 3)
1010 return NULL;
1011
1012 /* Parse if index */
1013 len = (offsetlen < 1 ? 0 : 1);
1014 if (len)
1015 ifindex = *offset;
1016 offset += len;
1017 offsetlen -= len;
1018
1019 /* Parse instance ID */
1020 len = (offsetlen < 1 ? 0 : 1);
1021 if (len)
1022 instid = *offset;
1023 offset += len;
1024 offsetlen -= len;
1025
1026 /* Parse router ID */
1027 len = (offsetlen < 1 ? 0 : 1);
1028 if (len)
1029 rtrid = htonl (*offset);
1030 offset += len;
1031 offsetlen -= len;
1032
1033 if (exact)
1034 {
1035 oi = ospf6_interface_lookup_by_ifindex (ifindex);
1036 on = ospf6_neighbor_lookup (rtrid, oi);
1037 if (oi->instance_id != instid) return NULL;
1038 }
1039 else
1040 {
1041 /* We build a sorted list of interfaces */
1042 ifslist = list_new ();
1043 if (!ifslist) return NULL;
1044 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
1045 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
1046 listnode_add_sort (ifslist, iif);
1047
1048 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
1049 {
1050 if (!iif->ifindex) continue;
1051 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
1052 if (!oi) continue;
1053 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
1054 if (iif->ifindex > ifindex ||
1055 (iif->ifindex == ifindex &&
1056 (oi->instance_id > instid ||
1057 (oi->instance_id == instid &&
1058 ntohl (on->router_id) > ntohl (rtrid)))))
1059 break;
1060 }
1061 if (on) break;
1062 oi = on = NULL;
1063 }
1064
1065 list_delete_all_node (ifslist);
1066 }
1067
1068 if (!oi || !on) return NULL;
1069
1070 /* Add Index (IfIndex, IfInstId, RtrId) */
1071 *length = v->namelen + 3;
1072 offset = name + v->namelen;
1073 *offset = oi->interface->ifindex;
1074 offset++;
1075 *offset = oi->instance_id;
1076 offset++;
1077 *offset = ntohl (on->router_id);
1078 offset++;
1079
1080 /* Return the current value of the variable */
1081 switch (v->magic)
1082 {
1083 case OSPFv3NBRADDRESSTYPE:
1084 return SNMP_INTEGER (2); /* IPv6 only */
1085 case OSPFv3NBRADDRESS:
1086 *var_len = sizeof (struct in6_addr);
1087 return (u_char *) &on->linklocal_addr;
1088 case OSPFv3NBROPTIONS:
1089 return SNMP_INTEGER (on->options[2]);
1090 case OSPFv3NBRPRIORITY:
1091 return SNMP_INTEGER (on->priority);
1092 case OSPFv3NBRSTATE:
1093 return SNMP_INTEGER (on->state);
1094 case OSPFv3NBREVENTS:
1095 return SNMP_INTEGER (on->state_change);
1096 case OSPFv3NBRLSRETRANSQLEN:
1097 return SNMP_INTEGER (on->retrans_list->count);
1098 case OSPFv3NBRHELLOSUPPRESSED:
1099 return SNMP_INTEGER (SNMP_FALSE);
1100 case OSPFv3NBRIFID:
1101 return SNMP_INTEGER (on->ifindex);
1102 case OSPFv3NBRRESTARTHELPERSTATUS:
1103 case OSPFv3NBRRESTARTHELPERAGE:
1104 case OSPFv3NBRRESTARTHELPEREXITREASON:
1105 /* Not implemented. Only works if all the last ones are not
1106 implemented! */
1107 return NULL;
1108 }
1109
1110 return NULL;
1111}
1112
hassoef1bbf52004-10-08 12:04:21 +00001113/* Register OSPFv3-MIB. */
1114void
paul0c083ee2004-10-10 12:54:58 +00001115ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +00001116{
hassoc75105a2004-10-13 10:33:26 +00001117 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +00001118 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +00001119}
1120
1121#endif /* HAVE_SNMP */
1122