]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_snmp.c
*: fix signedness mix-ups
[mirror_frr.git] / ospf6d / ospf6_snmp.c
CommitLineData
ef1bbf5c 1/* 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
ef1bbf5c 26#include <net-snmp/net-snmp-config.h>
fb62a3ce 27#include <net-snmp/net-snmp-includes.h>
ef1bbf5c 28
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"
0be8dfb2 44#include "ospf6_snmp.h"
ef1bbf5c 45
46/* OSPFv3-MIB */
0f0ab518 47#define OSPFv3MIB 1,3,6,1,2,1,191
ef1bbf5c 48
ef1bbf5c 49/* 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
0f0ab518
VB
61#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
75
76/* OSPFv3 MIB Area Table values: ospfv3AreaTable */
ef1bbf5c 77#define OSPFv3IMPORTASEXTERN 2
2680aa2b 78#define OSPFv3AREASPFRUNS 3
79#define OSPFv3AREABDRRTRCOUNT 4
80#define OSPFv3AREAASBDRRTRCOUNT 5
81#define OSPFv3AREASCOPELSACOUNT 6
82#define OSPFv3AREASCOPELSACKSUMSUM 7
83#define OSPFv3AREASUMMARY 8
0f0ab518
VB
84#define OSPFv3AREAROWSTATUS 9
85#define OSPFv3AREASTUBMETRIC 10
2680aa2b 86#define OSPFv3AREANSSATRANSLATORROLE 11
87#define OSPFv3AREANSSATRANSLATORSTATE 12
0f0ab518 88#define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13
2680aa2b 89#define OSPFv3AREANSSATRANSLATOREVENTS 14
90#define OSPFv3AREASTUBMETRICTYPE 15
0f0ab518 91#define OSPFv3AREATEENABLED 16
2680aa2b 92
c349bb86
VB
93/* 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
99
100/* 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)
0f0ab518
VB
107
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
ef1bbf5c 189/* 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
0f0ab518 197#define UNSIGNED ASN_UNSIGNED
ef1bbf5c 198#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
ef1bbf5c 205/* OSPFv3-MIB instances. */
206oid ospfv3_oid [] = { OSPFv3MIB };
bf836661 207oid ospfv3_trap_oid [] = { OSPFv3MIB, 0 };
ef1bbf5c 208
ef1bbf5c 209/* Hook functions. */
0be8dfb2
CC
210static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
211 int, size_t *, WriteMethod **);
212static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
213 int, size_t *, WriteMethod **);
c349bb86
VB
214static u_char *ospfv3WwLsdbEntry (struct variable *, oid *, size_t *,
215 int, size_t *, WriteMethod **);
061bc735
VB
216static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *,
217 int, size_t *, WriteMethod **);
3bc4f84e
VB
218static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *,
219 int, size_t *, WriteMethod **);
ef1bbf5c 220
221struct variable ospfv3_variables[] =
222{
223 /* OSPF general variables */
0f0ab518 224 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 225 3, {1, 1, 1}},
226 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
227 3, {1, 1, 2}},
228 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
229 3, {1, 1, 3}},
230 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
231 3, {1, 1, 4}},
232 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
233 3, {1, 1, 5}},
234 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
235 3, {1, 1, 6}},
0f0ab518 236 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
ef1bbf5c 237 3, {1, 1, 7}},
238 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
239 3, {1, 1, 8}},
240 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
241 3, {1, 1, 9}},
242 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
243 3, {1, 1, 10}},
244 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
245 3, {1, 1, 11}},
0f0ab518 246 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 247 3, {1, 1, 12}},
ef1bbf5c 248 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
0f0ab518
VB
249 3, {1, 1, 13}},
250 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 251 3, {1, 1, 14}},
0f0ab518 252 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 253 3, {1, 1, 15}},
0f0ab518 254 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 255 3, {1, 1, 16}},
0f0ab518 256 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 257 3, {1, 1, 17}},
ef1bbf5c 258 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
0f0ab518
VB
259 3, {1, 1, 18}},
260 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
ef1bbf5c 261 3, {1, 1, 19}},
ef1bbf5c 262 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
0f0ab518
VB
263 3, {1, 1, 20}},
264 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
ef1bbf5c 265 3, {1, 1, 21}},
0f0ab518
VB
266 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
267 3, {1, 1, 22}},
268 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
269 3, {1, 1, 23}},
270 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
271 3, {1, 1, 24}},
272 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
273 3, {1, 1, 25}},
ef1bbf5c 274
275 /* OSPFv3 Area Data Structure */
2680aa2b 276 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
ef1bbf5c 277 4, {1, 2, 1, 2}},
2680aa2b 278 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
279 4, {1, 2, 1, 3}},
280 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
281 4, {1, 2, 1, 4}},
282 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
283 4, {1, 2, 1, 5}},
284 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
285 4, {1, 2, 1, 6}},
0f0ab518 286 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
2680aa2b 287 4, {1, 2, 1, 7}},
288 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
289 4, {1, 2, 1, 8}},
0f0ab518 290 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
2680aa2b 291 4, {1, 2, 1, 9}},
0f0ab518 292 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
2680aa2b 293 4, {1, 2, 1, 10}},
294 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
295 4, {1, 2, 1, 11}},
296 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
297 4, {1, 2, 1, 12}},
0f0ab518 298 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
2680aa2b 299 4, {1, 2, 1, 13}},
300 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
301 4, {1, 2, 1, 14}},
302 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
303 4, {1, 2, 1, 15}},
0f0ab518
VB
304 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
305 4, {1, 2, 1, 16}},
2680aa2b 306
c349bb86
VB
307 /* OSPFv3 AS LSDB */
308 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
309 4, {1, 3, 1, 4}},
310 {OSPFv3WWLSDBAGE | OSPFv3WWASTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
311 4, {1, 3, 1, 5}},
312 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
313 4, {1, 3, 1, 6}},
314 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWASTABLE, STRING, RONLY, ospfv3WwLsdbEntry,
315 4, {1, 3, 1, 7}},
316 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
317 4, {1, 3, 1, 8}},
318
0f0ab518 319 /* OSPFv3 Area LSDB */
c349bb86 320 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
2680aa2b 321 4, {1, 4, 1, 5}},
c349bb86 322 {OSPFv3WWLSDBAGE | OSPFv3WWAREATABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
2680aa2b 323 4, {1, 4, 1, 6}},
c349bb86 324 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
2680aa2b 325 4, {1, 4, 1, 7}},
c349bb86 326 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWAREATABLE, STRING, RONLY, ospfv3WwLsdbEntry,
2680aa2b 327 4, {1, 4, 1, 8}},
c349bb86 328 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
2680aa2b 329 4, {1, 4, 1, 9}},
330
c349bb86
VB
331 /* OSPFv3 Link LSDB */
332 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
333 4, {1, 5, 1, 6}},
334 {OSPFv3WWLSDBAGE | OSPFv3WWLINKTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry,
335 4, {1, 5, 1, 7}},
336 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
337 4, {1, 5, 1, 8}},
338 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWLINKTABLE, STRING, RONLY, ospfv3WwLsdbEntry,
339 4, {1, 5, 1, 9}},
340 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry,
341 4, {1, 5, 1, 10}},
342
3bc4f84e
VB
343 /* OSPFv3 interfaces */
344 {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry,
345 4, {1, 7, 1, 3}},
346 {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry,
347 4, {1, 7, 1, 4}},
348 {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry,
349 4, {1, 7, 1, 5}},
350 {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry,
351 4, {1, 7, 1, 6}},
352 {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry,
353 4, {1, 7, 1, 7}},
354 {OSPFv3IFRETRANSINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
355 4, {1, 7, 1, 8}},
356 {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry,
357 4, {1, 7, 1, 9}},
358 {OSPFv3IFRTRDEADINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
359 4, {1, 7, 1, 10}},
360 {OSPFv3IFPOLLINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
361 4, {1, 7, 1, 11}},
362 {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry,
363 4, {1, 7, 1, 12}},
364 {OSPFv3IFDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
365 4, {1, 7, 1, 13}},
366 {OSPFv3IFBACKUPDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
367 4, {1, 7, 1, 14}},
368 {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry,
369 4, {1, 7, 1, 15}},
370 {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry,
371 4, {1, 7, 1, 16}},
372 {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry,
373 4, {1, 7, 1, 17}},
374 {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry,
375 4, {1, 7, 1, 18}},
376 {OSPFv3IFLINKSCOPELSACOUNT, GAUGE, RONLY, ospfv3IfEntry,
377 4, {1, 7, 1, 19}},
378 {OSPFv3IFLINKLSACKSUMSUM, UNSIGNED, RONLY, ospfv3IfEntry,
379 4, {1, 7, 1, 20}},
380 {OSPFv3IFDEMANDNBRPROBE, INTEGER, RONLY, ospfv3IfEntry,
381 4, {1, 7, 1, 21}},
382 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT, UNSIGNED, RONLY, ospfv3IfEntry,
383 4, {1, 7, 1, 22}},
384 {OSPFv3IFDEMANDNBRPROBEINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
385 4, {1, 7, 1, 23}},
386 {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry,
387 4, {1, 7, 1, 24}},
388 {OSPFv3IFLINKLSASUPPRESSION, INTEGER, RONLY, ospfv3IfEntry,
389 4, {1, 7, 1, 25}},
390
061bc735
VB
391 /* OSPFv3 neighbors */
392 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry,
393 4, {1, 9, 1, 4}},
394 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry,
395 4, {1, 9, 1, 5}},
396 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry,
397 4, {1, 9, 1, 6}},
398 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry,
399 4, {1, 9, 1, 7}},
400 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry,
401 4, {1, 9, 1, 8}},
402 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry,
403 4, {1, 9, 1, 9}},
404 {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry,
405 4, {1, 9, 1, 10}},
406 {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry,
407 4, {1, 9, 1, 11}},
408 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry,
409 4, {1, 9, 1, 12}},
410 {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry,
411 4, {1, 9, 1, 13}},
412 {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry,
413 4, {1, 9, 1, 14}},
414 {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry,
415 4, {1, 9, 1, 15}},
ef1bbf5c 416};
417
418static u_char *
419ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
420 int exact, size_t *var_len, WriteMethod **write_method)
421{
2c5f1480
VB
422 u_int16_t sum;
423 u_int32_t count;
424 struct ospf6_lsa *lsa = NULL;
425
ef1bbf5c 426 /* Check whether the instance identifier is valid */
427 if (smux_header_generic (v, name, length, exact, var_len, write_method)
428 == MATCH_FAILED)
429 return NULL;
430
431 /* Return the current value of the variable */
432 switch (v->magic)
433 {
0f0ab518 434 case OSPFv3ROUTERID:
ef1bbf5c 435 /* Router-ID of this OSPF instance. */
436 if (ospf6)
0f0ab518
VB
437 return SNMP_INTEGER (ntohl (ospf6->router_id));
438 return SNMP_INTEGER (0);
439 case OSPFv3ADMINSTAT:
2c5f1480
VB
440 if (ospf6)
441 return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)?
442 OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED);
443 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
0f0ab518 444 case OSPFv3VERSIONNUMBER:
2c5f1480 445 return SNMP_INTEGER (3);
0f0ab518 446 case OSPFv3AREABDRRTRSTATUS:
2c5f1480
VB
447 if (ospf6)
448 return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE);
449 return SNMP_INTEGER (SNMP_FALSE);
0f0ab518 450 case OSPFv3ASBDRRTRSTATUS:
2c5f1480
VB
451 if (ospf6)
452 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE);
453 return SNMP_INTEGER (SNMP_FALSE);
0f0ab518 454 case OSPFv3ASSCOPELSACOUNT:
2c5f1480
VB
455 if (ospf6)
456 return SNMP_INTEGER (ospf6->lsdb->count);
457 return SNMP_INTEGER (0);
0f0ab518 458 case OSPFv3ASSCOPELSACHECKSUMSUM:
2c5f1480
VB
459 if (ospf6)
460 {
461 for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb);
462 lsa;
463 lsa = ospf6_lsdb_next (lsa))
464 sum += ntohs (lsa->header->checksum);
465 return SNMP_INTEGER (sum);
466 }
467 return SNMP_INTEGER (0);
0f0ab518 468 case OSPFv3ORIGINATENEWLSAS:
2c5f1480 469 return SNMP_INTEGER (0); /* Don't know where to get this value... */
0f0ab518 470 case OSPFv3RXNEWLSAS:
2c5f1480 471 return SNMP_INTEGER (0); /* Don't know where to get this value... */
0f0ab518 472 case OSPFv3EXTLSACOUNT:
2c5f1480
VB
473 if (ospf6)
474 {
475 for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL),
476 ospf6->lsdb);
477 lsa;
478 lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
479 lsa))
480 count += 1;
481 return SNMP_INTEGER (count);
482 }
483 return SNMP_INTEGER (0);
0f0ab518 484 case OSPFv3EXTAREALSDBLIMIT:
2c5f1480 485 return SNMP_INTEGER (-1);
0f0ab518 486 case OSPFv3EXITOVERFLOWINTERVAL:
2c5f1480 487 return SNMP_INTEGER (0); /* Not supported */
0f0ab518 488 case OSPFv3DEMANDEXTENSIONS:
2c5f1480 489 return SNMP_INTEGER (0); /* Not supported */
0f0ab518 490 case OSPFv3REFERENCEBANDWIDTH:
fd500689
VB
491 if (ospf6)
492 return SNMP_INTEGER (ospf6->ref_bandwidth);
493 /* Otherwise, like for "not implemented". */
0f0ab518
VB
494 case OSPFv3RESTARTSUPPORT:
495 case OSPFv3RESTARTINTERVAL:
496 case OSPFv3RESTARTSTRICTLSACHECKING:
497 case OSPFv3RESTARTSTATUS:
498 case OSPFv3RESTARTAGE:
499 case OSPFv3RESTARTEXITREASON:
500 case OSPFv3NOTIFICATIONENABLE:
501 case OSPFv3STUBROUTERSUPPORT:
502 case OSPFv3STUBROUTERADVERTISEMENT:
503 case OSPFv3DISCONTINUITYTIME:
504 case OSPFv3RESTARTTIME:
505 /* TODO: Not implemented */
ef1bbf5c 506 return NULL;
507 }
508 return NULL;
509}
510
511static u_char *
512ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
513 int exact, size_t *var_len, WriteMethod **write_method)
514{
515 struct ospf6_area *oa, *area = NULL;
ea86e404 516 struct ospf6_lsa *lsa = NULL;
ef1bbf5c 517 u_int32_t area_id = 0;
ea86e404
VB
518 u_int32_t count;
519 u_int16_t sum;
0c083ee9 520 struct listnode *node;
521 unsigned int len;
0f0ab518 522 char a[16];
ea86e404 523 struct ospf6_route *ro;
ef1bbf5c 524
525 if (ospf6 == NULL)
526 return NULL;
527
8046ba6e
VB
528 if (smux_header_table(v, name, length, exact, var_len, write_method)
529 == MATCH_FAILED)
530 return NULL;
531
ef1bbf5c 532 len = *length - v->namelen;
a11e012e 533 len = (len >= 1 ? 1 : 0);
0f0ab518 534 if (exact && len != 1)
ef1bbf5c 535 return NULL;
536 if (len)
0f0ab518 537 area_id = htonl (name[v->namelen]);
ef1bbf5c 538
0f0ab518 539 inet_ntop (AF_INET, &area_id, a, sizeof (a));
eda9ba74 540 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
0f0ab518 541 a, exact, len, (u_long)*length);
ef1bbf5c 542
1eb8ef25 543 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
ef1bbf5c 544 {
ef1bbf5c 545 if (area == NULL)
546 {
547 if (len == 0) /* return first area entry */
548 area = oa;
549 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
550 area = oa;
551 else if (ntohl (oa->area_id) > ntohl (area_id))
552 area = oa;
553 }
554 }
555
556 if (area == NULL)
557 return NULL;
558
0f0ab518
VB
559 *length = v->namelen + 1;
560 name[v->namelen] = ntohl (area->area_id);
ef1bbf5c 561
0f0ab518 562 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
eda9ba74 563 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
0f0ab518 564 a, exact, len, (u_long)*length);
ef1bbf5c 565
566 switch (v->magic)
567 {
0f0ab518 568 case OSPFv3IMPORTASEXTERN:
ea86e404
VB
569 /* No NSSA support */
570 return SNMP_INTEGER (IS_AREA_STUB(area)?2:1);
0f0ab518 571 case OSPFv3AREASPFRUNS:
ea86e404 572 return SNMP_INTEGER (area->spf_calculation);
0f0ab518
VB
573 case OSPFv3AREABDRRTRCOUNT:
574 case OSPFv3AREAASBDRRTRCOUNT:
ea86e404
VB
575 count = 0;
576 for (ro = ospf6_route_head (ospf6->brouter_table); ro;
577 ro = ospf6_route_next (ro))
578 {
579 if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue;
580 if (v->magic == OSPFv3AREABDRRTRCOUNT &&
581 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B))
582 count++;
583 if (v->magic == OSPFv3AREAASBDRRTRCOUNT &&
584 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E))
585 count++;
586 }
587 return SNMP_INTEGER (count);
0f0ab518 588 case OSPFv3AREASCOPELSACOUNT:
ea86e404 589 return SNMP_INTEGER (area->lsdb->count);
0f0ab518 590 case OSPFv3AREASCOPELSACKSUMSUM:
ea86e404
VB
591 for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb);
592 lsa;
593 lsa = ospf6_lsdb_next (lsa))
594 sum += ntohs (lsa->header->checksum);
595 return SNMP_INTEGER (sum);
0f0ab518 596 case OSPFv3AREASUMMARY:
ea86e404 597 return SNMP_INTEGER (2); /* sendAreaSummary */
0f0ab518 598 case OSPFv3AREAROWSTATUS:
ea86e404 599 return SNMP_INTEGER (1); /* Active */
0f0ab518
VB
600 case OSPFv3AREASTUBMETRIC:
601 case OSPFv3AREANSSATRANSLATORROLE:
602 case OSPFv3AREANSSATRANSLATORSTATE:
603 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
604 case OSPFv3AREANSSATRANSLATOREVENTS:
605 case OSPFv3AREASTUBMETRICTYPE:
606 case OSPFv3AREATEENABLED:
607 /* Not implemented. */
ef1bbf5c 608 return NULL;
ef1bbf5c 609 }
610 return NULL;
611}
612
c349bb86
VB
613static int
614if_icmp_func (struct interface *ifp1, struct interface *ifp2)
615{
616 return (ifp1->ifindex - ifp2->ifindex);
617}
618
2680aa2b 619static u_char *
c349bb86 620ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length,
2680aa2b 621 int exact, size_t *var_len, WriteMethod **write_method)
622{
623 struct ospf6_lsa *lsa = NULL;
c349bb86 624 u_int32_t ifindex, area_id, id, instid, adv_router;
2680aa2b 625 u_int16_t type;
2680aa2b 626 int len;
627 oid *offset;
628 int offsetlen;
d8adbe09 629 struct ospf6_area *oa = NULL;
b3c8c465 630 struct listnode *node;
c349bb86
VB
631 struct interface *iif;
632 struct ospf6_interface *oi = NULL;
633 struct list *ifslist;
2680aa2b 634
8046ba6e
VB
635 if (smux_header_table(v, name, length, exact, var_len, write_method)
636 == MATCH_FAILED)
637 return NULL;
638
c349bb86 639 instid = ifindex = area_id = type = id = adv_router = 0;
2680aa2b 640
641 /* Check OSPFv3 instance. */
642 if (ospf6 == NULL)
643 return NULL;
644
645 /* Get variable length. */
646 offset = name + v->namelen;
647 offsetlen = *length - v->namelen;
648
c349bb86
VB
649 if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3)
650 return NULL;
651 if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4)
652 return NULL;
653 if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5)
2680aa2b 654 return NULL;
655
c349bb86
VB
656 if (v->magic & OSPFv3WWLINKTABLE)
657 {
658 /* Parse ifindex */
659 len = (offsetlen < 1 ? 0 : 1);
660 if (len)
661 ifindex = *offset;
662 offset += len;
663 offsetlen -= len;
664
665 /* Parse instance ID */
666 len = (offsetlen < 1 ? 0 : 1);
667 if (len)
668 instid = *offset;
669 offset += len;
670 offsetlen -= len;
671 }
672 else if (v->magic & OSPFv3WWAREATABLE)
673 {
674 /* Parse area-id */
675 len = (offsetlen < 1 ? 0 : 1);
676 if (len)
677 area_id = htonl (*offset);
678 offset += len;
679 offsetlen -= len;
680 }
2680aa2b 681
682 /* Parse type */
0f0ab518 683 len = (offsetlen < 1 ? 0 : 1);
2680aa2b 684 if (len)
685 type = htons (*offset);
686 offset += len;
687 offsetlen -= len;
688
689 /* Parse Router-ID */
0f0ab518 690 len = (offsetlen < 1 ? 0 : 1);
2680aa2b 691 if (len)
0f0ab518 692 adv_router = htonl (*offset);
2680aa2b 693 offset += len;
694 offsetlen -= len;
695
696 /* Parse LS-ID */
0f0ab518 697 len = (offsetlen < 1 ? 0 : 1);
2680aa2b 698 if (len)
0f0ab518 699 id = htonl (*offset);
2680aa2b 700 offset += len;
701 offsetlen -= len;
702
2680aa2b 703 if (exact)
704 {
c349bb86
VB
705 if (v->magic & OSPFv3WWASTABLE)
706 {
707 lsa = ospf6_lsdb_lookup (type, id, adv_router, ospf6->lsdb);
708 }
709 else if (v->magic & OSPFv3WWAREATABLE)
710 {
711 oa = ospf6_area_lookup (area_id, ospf6);
0402ca4e 712 if (!oa) return NULL;
c349bb86
VB
713 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
714 }
715 else if (v->magic & OSPFv3WWLINKTABLE)
716 {
717 oi = ospf6_interface_lookup_by_ifindex (ifindex);
0402ca4e 718 if (!oi || oi->instance_id != instid) return NULL;
c349bb86
VB
719 lsa = ospf6_lsdb_lookup (type, id, adv_router, oi->lsdb);
720 }
2680aa2b 721 }
722 else
723 {
c349bb86
VB
724 if (v->magic & OSPFv3WWASTABLE)
725 {
726 if (ospf6->lsdb->count)
727 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
728 ospf6->lsdb);
729 }
730 else if (v->magic & OSPFv3WWAREATABLE)
731 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
732 {
733 if (oa->area_id < area_id)
734 continue;
735
736 if (oa->lsdb->count)
737 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
738 oa->lsdb);
739 if (lsa) break;
740 type = 0;
741 id = 0;
742 adv_router = 0;
743 }
744 else if (v->magic & OSPFv3WWLINKTABLE)
2680aa2b 745 {
c349bb86
VB
746 /* We build a sorted list of interfaces */
747 ifslist = list_new ();
748 if (!ifslist) return NULL;
749 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
750 for (ALL_LIST_ELEMENTS_RO (iflist, node, iif))
751 listnode_add_sort (ifslist, iif);
752
753 for (ALL_LIST_ELEMENTS_RO (ifslist, node, iif))
2680aa2b 754 {
c349bb86
VB
755 if (!iif->ifindex) continue;
756 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
757 if (!oi) continue;
758 if (iif->ifindex < ifindex) continue;
759 if (oi->instance_id < instid) continue;
760
761 if (oi->lsdb->count)
762 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
763 oi->lsdb);
764 if (lsa) break;
2680aa2b 765 type = 0;
c349bb86
VB
766 id = 0;
767 adv_router = 0;
768 oi = NULL;
2680aa2b 769 }
c349bb86
VB
770
771 list_delete_all_node (ifslist);
2680aa2b 772 }
773 }
774
775 if (! lsa)
2680aa2b 776 return NULL;
2680aa2b 777
c349bb86
VB
778 /* Add indexes */
779 if (v->magic & OSPFv3WWASTABLE)
780 {
781 *length = v->namelen + 3;
782 offset = name + v->namelen;
783 }
784 else if (v->magic & OSPFv3WWAREATABLE)
785 {
786 *length = v->namelen + 4;
787 offset = name + v->namelen;
788 *offset = ntohl (oa->area_id);
789 offset++;
790 }
791 else if (v->magic & OSPFv3WWLINKTABLE)
792 {
793 *length = v->namelen + 5;
794 offset = name + v->namelen;
795 *offset = oi->interface->ifindex;
796 offset++;
797 *offset = oi->instance_id;
798 offset++;
799 }
2680aa2b 800 *offset = ntohs (lsa->header->type);
801 offset++;
0f0ab518
VB
802 *offset = ntohl (lsa->header->adv_router);
803 offset++;
804 *offset = ntohl (lsa->header->id);
805 offset++;
2680aa2b 806
807 /* Return the current value of the variable */
c349bb86 808 switch (v->magic & OSPFv3WWCOLUMN)
2680aa2b 809 {
c349bb86 810 case OSPFv3WWLSDBSEQUENCE:
0f0ab518 811 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
2680aa2b 812 break;
c349bb86 813 case OSPFv3WWLSDBAGE:
2680aa2b 814 ospf6_lsa_age_current (lsa);
0f0ab518 815 return SNMP_INTEGER (ntohs (lsa->header->age));
2680aa2b 816 break;
c349bb86 817 case OSPFv3WWLSDBCHECKSUM:
0f0ab518 818 return SNMP_INTEGER (ntohs (lsa->header->checksum));
2680aa2b 819 break;
c349bb86 820 case OSPFv3WWLSDBADVERTISEMENT:
2680aa2b 821 *var_len = ntohs (lsa->header->length);
822 return (u_char *) lsa->header;
823 break;
c349bb86 824 case OSPFv3WWLSDBTYPEKNOWN:
2680aa2b 825 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
826 SNMP_TRUE : SNMP_FALSE);
827 break;
2680aa2b 828 }
829 return NULL;
830}
831
3bc4f84e
VB
832static u_char *
833ospfv3IfEntry (struct variable *v, oid *name, size_t *length,
834 int exact, size_t *var_len, WriteMethod **write_method)
835{
836 unsigned int ifindex, instid;
837 struct ospf6_interface *oi = NULL;
838 struct ospf6_lsa *lsa = NULL;
839 struct interface *iif;
840 struct listnode *i;
841 struct list *ifslist;
842 oid *offset;
843 int offsetlen, len;
844 u_int32_t sum;
845
846 if (smux_header_table (v, name, length, exact, var_len, write_method)
847 == MATCH_FAILED)
848 return NULL;
849
850 ifindex = instid = 0;
851
852 /* Check OSPFv3 instance. */
853 if (ospf6 == NULL)
854 return NULL;
855
856 /* Get variable length. */
857 offset = name + v->namelen;
858 offsetlen = *length - v->namelen;
859
860 if (exact && offsetlen != 2)
861 return NULL;
862
863 /* Parse if index */
864 len = (offsetlen < 1 ? 0 : 1);
865 if (len)
866 ifindex = *offset;
867 offset += len;
868 offsetlen -= len;
869
870 /* Parse instance ID */
871 len = (offsetlen < 1 ? 0 : 1);
872 if (len)
873 instid = *offset;
874 offset += len;
875 offsetlen -= len;
876
877 if (exact)
878 {
879 oi = ospf6_interface_lookup_by_ifindex (ifindex);
0402ca4e 880 if (!oi || oi->instance_id != instid) return NULL;
3bc4f84e
VB
881 }
882 else
883 {
884 /* We build a sorted list of interfaces */
885 ifslist = list_new ();
886 if (!ifslist) return NULL;
887 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
888 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
889 listnode_add_sort (ifslist, iif);
890
891 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
892 {
893 if (!iif->ifindex) continue;
894 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
895 if (!oi) continue;
896 if (iif->ifindex > ifindex ||
897 (iif->ifindex == ifindex &&
898 (oi->instance_id > instid)))
899 break;
900 oi = NULL;
901 }
902
903 list_delete_all_node (ifslist);
904 }
905
906 if (!oi) return NULL;
907
908 /* Add Index (IfIndex, IfInstId) */
909 *length = v->namelen + 2;
910 offset = name + v->namelen;
911 *offset = oi->interface->ifindex;
912 offset++;
913 *offset = oi->instance_id;
914 offset++;
915
916 /* Return the current value of the variable */
917 switch (v->magic)
918 {
919 case OSPFv3IFAREAID:
920 if (oi->area)
921 return SNMP_INTEGER (ntohl (oi->area->area_id));
922 break;
923 case OSPFv3IFTYPE:
924 if (if_is_broadcast (oi->interface))
925 return SNMP_INTEGER (1);
926 else if (if_is_pointopoint (oi->interface))
927 return SNMP_INTEGER (3);
928 else break; /* Unknown, don't put anything */
929 case OSPFv3IFADMINSTATUS:
930 if (oi->area)
931 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
932 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
933 case OSPFv3IFRTRPRIORITY:
934 return SNMP_INTEGER (oi->priority);
935 case OSPFv3IFTRANSITDELAY:
936 return SNMP_INTEGER (oi->transdelay);
937 case OSPFv3IFRETRANSINTERVAL:
938 return SNMP_INTEGER (oi->rxmt_interval);
939 case OSPFv3IFHELLOINTERVAL:
940 return SNMP_INTEGER (oi->hello_interval);
941 case OSPFv3IFRTRDEADINTERVAL:
942 return SNMP_INTEGER (oi->dead_interval);
943 case OSPFv3IFPOLLINTERVAL:
944 /* No support for NBMA */
945 break;
946 case OSPFv3IFSTATE:
947 return SNMP_INTEGER (oi->state);
948 case OSPFv3IFDESIGNATEDROUTER:
949 return SNMP_INTEGER (ntohl (oi->drouter));
950 case OSPFv3IFBACKUPDESIGNATEDROUTER:
951 return SNMP_INTEGER (ntohl (oi->bdrouter));
952 case OSPFv3IFEVENTS:
953 return SNMP_INTEGER (oi->state_change);
954 case OSPFv3IFROWSTATUS:
955 return SNMP_INTEGER (1);
956 case OSPFv3IFDEMAND:
957 return SNMP_INTEGER (SNMP_FALSE);
958 case OSPFv3IFMETRICVALUE:
959 return SNMP_INTEGER (oi->cost);
960 case OSPFv3IFLINKSCOPELSACOUNT:
961 return SNMP_INTEGER (oi->lsdb->count);
962 case OSPFv3IFLINKLSACKSUMSUM:
963 for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb);
964 lsa;
965 lsa = ospf6_lsdb_next (lsa))
966 sum += ntohs (lsa->header->checksum);
967 return SNMP_INTEGER (sum);
968 case OSPFv3IFDEMANDNBRPROBE:
969 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT:
970 case OSPFv3IFDEMANDNBRPROBEINTERVAL:
971 case OSPFv3IFTEDISABLED:
972 case OSPFv3IFLINKLSASUPPRESSION:
973 /* Not implemented. Only works if all the last ones are not
974 implemented! */
975 return NULL;
976 }
977
978 /* Try an internal getnext. Some columns are missing in this table. */
979 if (!exact && (name[*length-1] < MAX_SUBID))
980 return ospfv3IfEntry(v, name, length,
981 exact, var_len, write_method);
982 return NULL;
983}
984
061bc735
VB
985static u_char *
986ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
987 int exact, size_t *var_len, WriteMethod **write_method)
988{
989 unsigned int ifindex, instid, rtrid;
990 struct ospf6_interface *oi = NULL;
991 struct ospf6_neighbor *on = NULL;
992 struct interface *iif;
993 struct listnode *i, *j;
994 struct list *ifslist;
995 oid *offset;
996 int offsetlen, len;
997
998 if (smux_header_table (v, name, length, exact, var_len, write_method)
999 == MATCH_FAILED)
1000 return NULL;
1001
1002 ifindex = instid = rtrid = 0;
1003
1004 /* Check OSPFv3 instance. */
1005 if (ospf6 == NULL)
1006 return NULL;
1007
1008 /* Get variable length. */
1009 offset = name + v->namelen;
1010 offsetlen = *length - v->namelen;
1011
1012 if (exact && offsetlen != 3)
1013 return NULL;
1014
1015 /* Parse if index */
1016 len = (offsetlen < 1 ? 0 : 1);
1017 if (len)
1018 ifindex = *offset;
1019 offset += len;
1020 offsetlen -= len;
1021
1022 /* Parse instance ID */
1023 len = (offsetlen < 1 ? 0 : 1);
1024 if (len)
1025 instid = *offset;
1026 offset += len;
1027 offsetlen -= len;
1028
1029 /* Parse router ID */
1030 len = (offsetlen < 1 ? 0 : 1);
1031 if (len)
1032 rtrid = htonl (*offset);
1033 offset += len;
1034 offsetlen -= len;
1035
1036 if (exact)
1037 {
1038 oi = ospf6_interface_lookup_by_ifindex (ifindex);
0402ca4e 1039 if (!oi || oi->instance_id != instid) return NULL;
061bc735 1040 on = ospf6_neighbor_lookup (rtrid, oi);
061bc735
VB
1041 }
1042 else
1043 {
1044 /* We build a sorted list of interfaces */
1045 ifslist = list_new ();
1046 if (!ifslist) return NULL;
1047 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
1048 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
1049 listnode_add_sort (ifslist, iif);
1050
1051 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
1052 {
1053 if (!iif->ifindex) continue;
1054 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
1055 if (!oi) continue;
1056 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
1057 if (iif->ifindex > ifindex ||
1058 (iif->ifindex == ifindex &&
1059 (oi->instance_id > instid ||
1060 (oi->instance_id == instid &&
1061 ntohl (on->router_id) > ntohl (rtrid)))))
1062 break;
1063 }
1064 if (on) break;
0402ca4e
VB
1065 oi = NULL;
1066 on = NULL;
061bc735
VB
1067 }
1068
1069 list_delete_all_node (ifslist);
1070 }
1071
1072 if (!oi || !on) return NULL;
1073
1074 /* Add Index (IfIndex, IfInstId, RtrId) */
1075 *length = v->namelen + 3;
1076 offset = name + v->namelen;
1077 *offset = oi->interface->ifindex;
1078 offset++;
1079 *offset = oi->instance_id;
1080 offset++;
1081 *offset = ntohl (on->router_id);
1082 offset++;
1083
1084 /* Return the current value of the variable */
1085 switch (v->magic)
1086 {
1087 case OSPFv3NBRADDRESSTYPE:
1088 return SNMP_INTEGER (2); /* IPv6 only */
1089 case OSPFv3NBRADDRESS:
1090 *var_len = sizeof (struct in6_addr);
1091 return (u_char *) &on->linklocal_addr;
1092 case OSPFv3NBROPTIONS:
1093 return SNMP_INTEGER (on->options[2]);
1094 case OSPFv3NBRPRIORITY:
1095 return SNMP_INTEGER (on->priority);
1096 case OSPFv3NBRSTATE:
1097 return SNMP_INTEGER (on->state);
1098 case OSPFv3NBREVENTS:
1099 return SNMP_INTEGER (on->state_change);
1100 case OSPFv3NBRLSRETRANSQLEN:
1101 return SNMP_INTEGER (on->retrans_list->count);
1102 case OSPFv3NBRHELLOSUPPRESSED:
1103 return SNMP_INTEGER (SNMP_FALSE);
1104 case OSPFv3NBRIFID:
1105 return SNMP_INTEGER (on->ifindex);
1106 case OSPFv3NBRRESTARTHELPERSTATUS:
1107 case OSPFv3NBRRESTARTHELPERAGE:
1108 case OSPFv3NBRRESTARTHELPEREXITREASON:
1109 /* Not implemented. Only works if all the last ones are not
1110 implemented! */
1111 return NULL;
1112 }
1113
1114 return NULL;
1115}
1116
bf836661
VB
1117/* OSPF Traps. */
1118#define NBRSTATECHANGE 2
1119#define IFSTATECHANGE 10
1120
1121static struct trap_object ospf6NbrTrapList[] =
1122{
1123 {-3, {1, 1, OSPFv3ROUTERID}},
1124 {4, {1, 9, 1, OSPFv3NBRADDRESSTYPE}},
1125 {4, {1, 9, 1, OSPFv3NBRADDRESS}},
1126 {4, {1, 9, 1, OSPFv3NBRSTATE}}
1127};
1128
1129static struct trap_object ospf6IfTrapList[] =
1130{
1131 {-3, {1, 1, OSPFv3ROUTERID}},
1132 {4, {1, 7, 1, OSPFv3IFSTATE}},
1133 {4, {1, 7, 1, OSPFv3IFADMINSTATUS}},
1134 {4, {1, 7, 1, OSPFv3IFAREAID}}
1135};
1136
1137void
1138ospf6TrapNbrStateChange (struct ospf6_neighbor *on)
1139{
1140 oid index[3];
1141
1142 index[0] = on->ospf6_if->interface->ifindex;
1143 index[1] = on->ospf6_if->instance_id;
1144 index[2] = ntohl (on->router_id);
1145
1146 smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable),
1147 ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid),
1148 ospfv3_oid, sizeof ospfv3_oid / sizeof (oid),
1149 index, 3,
1150 ospf6NbrTrapList,
1151 sizeof ospf6NbrTrapList / sizeof (struct trap_object),
1152 NBRSTATECHANGE);
1153}
1154
1155void
1156ospf6TrapIfStateChange (struct ospf6_interface *oi)
1157{
1158 oid index[2];
1159
1160 index[0] = oi->interface->ifindex;
1161 index[1] = oi->instance_id;
1162
1163 smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable),
1164 ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid),
1165 ospfv3_oid, sizeof ospfv3_oid / sizeof (oid),
1166 index, 2,
1167 ospf6IfTrapList,
1168 sizeof ospf6IfTrapList / sizeof (struct trap_object),
1169 IFSTATECHANGE);
1170}
1171
ef1bbf5c 1172/* Register OSPFv3-MIB. */
1173void
0c083ee9 1174ospf6_snmp_init (struct thread_master *master)
ef1bbf5c 1175{
c75105ab 1176 smux_init (master);
ef1bbf5c 1177 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
ef1bbf5c 1178}
1179
1180#endif /* HAVE_SNMP */
1181