]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_snmp.c
debian: add pkg-config to build-depends
[mirror_frr.git] / ospf6d / ospf6_snmp.c
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 #include <net-snmp/net-snmp-config.h>
25 #include <net-snmp/net-snmp-includes.h>
26
27 #include "log.h"
28 #include "vty.h"
29 #include "linklist.h"
30 #include "vector.h"
31 #include "vrf.h"
32 #include "smux.h"
33 #include "libfrr.h"
34 #include "version.h"
35
36 #include "ospf6_proto.h"
37 #include "ospf6_lsa.h"
38 #include "ospf6_lsdb.h"
39 #include "ospf6_route.h"
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_message.h"
44 #include "ospf6_neighbor.h"
45 #include "ospf6_abr.h"
46 #include "ospf6_asbr.h"
47 #include "ospf6d.h"
48
49 /* OSPFv3-MIB */
50 #define OSPFv3MIB 1,3,6,1,2,1,191
51
52 /* OSPFv3 MIB General Group values. */
53 #define OSPFv3ROUTERID 1
54 #define OSPFv3ADMINSTAT 2
55 #define OSPFv3VERSIONNUMBER 3
56 #define OSPFv3AREABDRRTRSTATUS 4
57 #define OSPFv3ASBDRRTRSTATUS 5
58 #define OSPFv3ASSCOPELSACOUNT 6
59 #define OSPFv3ASSCOPELSACHECKSUMSUM 7
60 #define OSPFv3ORIGINATENEWLSAS 8
61 #define OSPFv3RXNEWLSAS 9
62 #define OSPFv3EXTLSACOUNT 10
63 #define OSPFv3EXTAREALSDBLIMIT 11
64 #define OSPFv3EXITOVERFLOWINTERVAL 12
65 #define OSPFv3DEMANDEXTENSIONS 13
66 #define OSPFv3REFERENCEBANDWIDTH 14
67 #define OSPFv3RESTARTSUPPORT 15
68 #define OSPFv3RESTARTINTERVAL 16
69 #define OSPFv3RESTARTSTRICTLSACHECKING 17
70 #define OSPFv3RESTARTSTATUS 18
71 #define OSPFv3RESTARTAGE 19
72 #define OSPFv3RESTARTEXITREASON 20
73 #define OSPFv3NOTIFICATIONENABLE 21
74 #define OSPFv3STUBROUTERSUPPORT 22
75 #define OSPFv3STUBROUTERADVERTISEMENT 23
76 #define OSPFv3DISCONTINUITYTIME 24
77 #define OSPFv3RESTARTTIME 25
78
79 /* OSPFv3 MIB Area Table values: ospfv3AreaTable */
80 #define OSPFv3IMPORTASEXTERN 2
81 #define OSPFv3AREASPFRUNS 3
82 #define OSPFv3AREABDRRTRCOUNT 4
83 #define OSPFv3AREAASBDRRTRCOUNT 5
84 #define OSPFv3AREASCOPELSACOUNT 6
85 #define OSPFv3AREASCOPELSACKSUMSUM 7
86 #define OSPFv3AREASUMMARY 8
87 #define OSPFv3AREAROWSTATUS 9
88 #define OSPFv3AREASTUBMETRIC 10
89 #define OSPFv3AREANSSATRANSLATORROLE 11
90 #define OSPFv3AREANSSATRANSLATORSTATE 12
91 #define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13
92 #define OSPFv3AREANSSATRANSLATOREVENTS 14
93 #define OSPFv3AREASTUBMETRICTYPE 15
94 #define OSPFv3AREATEENABLED 16
95
96 /* OSPFv3 MIB * Lsdb Table values: ospfv3*LsdbTable */
97 #define OSPFv3WWLSDBSEQUENCE 1
98 #define OSPFv3WWLSDBAGE 2
99 #define OSPFv3WWLSDBCHECKSUM 3
100 #define OSPFv3WWLSDBADVERTISEMENT 4
101 #define OSPFv3WWLSDBTYPEKNOWN 5
102
103 /* Three first bits are to identify column */
104 #define OSPFv3WWCOLUMN 0x7
105 /* Then we use other bits to identify table */
106 #define OSPFv3WWASTABLE (1 << 3)
107 #define OSPFv3WWAREATABLE (1 << 4)
108 #define OSPFv3WWLINKTABLE (1 << 5)
109 #define OSPFv3WWVIRTLINKTABLE (1 << 6)
110
111 /* OSPFv3 MIB Host Table values: ospfv3HostTable */
112 #define OSPFv3HOSTMETRIC 3
113 #define OSPFv3HOSTROWSTATUS 4
114 #define OSPFv3HOSTAREAID 5
115
116 /* OSPFv3 MIB Interface Table values: ospfv3IfTable */
117 #define OSPFv3IFAREAID 3
118 #define OSPFv3IFTYPE 4
119 #define OSPFv3IFADMINSTATUS 5
120 #define OSPFv3IFRTRPRIORITY 6
121 #define OSPFv3IFTRANSITDELAY 7
122 #define OSPFv3IFRETRANSINTERVAL 8
123 #define OSPFv3IFHELLOINTERVAL 9
124 #define OSPFv3IFRTRDEADINTERVAL 10
125 #define OSPFv3IFPOLLINTERVAL 11
126 #define OSPFv3IFSTATE 12
127 #define OSPFv3IFDESIGNATEDROUTER 13
128 #define OSPFv3IFBACKUPDESIGNATEDROUTER 14
129 #define OSPFv3IFEVENTS 15
130 #define OSPFv3IFROWSTATUS 16
131 #define OSPFv3IFDEMAND 17
132 #define OSPFv3IFMETRICVALUE 18
133 #define OSPFv3IFLINKSCOPELSACOUNT 19
134 #define OSPFv3IFLINKLSACKSUMSUM 20
135 #define OSPFv3IFDEMANDNBRPROBE 21
136 #define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22
137 #define OSPFv3IFDEMANDNBRPROBEINTERVAL 23
138 #define OSPFv3IFTEDISABLED 24
139 #define OSPFv3IFLINKLSASUPPRESSION 25
140
141 /* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */
142 #define OSPFv3VIRTIFINDEX 3
143 #define OSPFv3VIRTIFINSTID 4
144 #define OSPFv3VIRTIFTRANSITDELAY 5
145 #define OSPFv3VIRTIFRETRANSINTERVAL 6
146 #define OSPFv3VIRTIFHELLOINTERVAL 7
147 #define OSPFv3VIRTIFRTRDEADINTERVAL 8
148 #define OSPFv3VIRTIFSTATE 9
149 #define OSPFv3VIRTIFEVENTS 10
150 #define OSPFv3VIRTIFROWSTATUS 11
151 #define OSPFv3VIRTIFLINKSCOPELSACOUNT 12
152 #define OSPFv3VIRTIFLINKLSACKSUMSUM 13
153
154 /* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */
155 #define OSPFv3NBRADDRESSTYPE 4
156 #define OSPFv3NBRADDRESS 5
157 #define OSPFv3NBROPTIONS 6
158 #define OSPFv3NBRPRIORITY 7
159 #define OSPFv3NBRSTATE 8
160 #define OSPFv3NBREVENTS 9
161 #define OSPFv3NBRLSRETRANSQLEN 10
162 #define OSPFv3NBRHELLOSUPPRESSED 11
163 #define OSPFv3NBRIFID 12
164 #define OSPFv3NBRRESTARTHELPERSTATUS 13
165 #define OSPFv3NBRRESTARTHELPERAGE 14
166 #define OSPFv3NBRRESTARTHELPEREXITREASON 15
167
168 /* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */
169 #define OSPFv3CFGNBRPRIORITY 5
170 #define OSPFv3CFGNBRROWSTATUS 6
171
172 /* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */
173 #define OSPFv3VIRTNBRIFINDEX 3
174 #define OSPFv3VIRTNBRIFINSTID 4
175 #define OSPFv3VIRTNBRADDRESSTYPE 5
176 #define OSPFv3VIRTNBRADDRESS 6
177 #define OSPFv3VIRTNBROPTIONS 7
178 #define OSPFv3VIRTNBRSTATE 8
179 #define OSPFv3VIRTNBREVENTS 9
180 #define OSPFv3VIRTNBRLSRETRANSQLEN 10
181 #define OSPFv3VIRTNBRHELLOSUPPRESSED 11
182 #define OSPFv3VIRTNBRIFID 12
183 #define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13
184 #define OSPFv3VIRTNBRRESTARTHELPERAGE 14
185 #define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15
186
187 /* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */
188 #define OSPFv3AREAAGGREGATEROWSTATUS 6
189 #define OSPFv3AREAAGGREGATEEFFECT 7
190 #define OSPFv3AREAAGGREGATEROUTETAG 8
191
192 /* SYNTAX Status from OSPF-MIB. */
193 #define OSPF_STATUS_ENABLED 1
194 #define OSPF_STATUS_DISABLED 2
195
196 /* SNMP value hack. */
197 #define COUNTER ASN_COUNTER
198 #define INTEGER ASN_INTEGER
199 #define GAUGE ASN_GAUGE
200 #define UNSIGNED ASN_UNSIGNED
201 #define TIMETICKS ASN_TIMETICKS
202 #define IPADDRESS ASN_IPADDRESS
203 #define STRING ASN_OCTET_STR
204
205 /* For return values e.g. SNMP_INTEGER macro */
206 SNMP_LOCAL_VARIABLES
207
208 /* OSPFv3-MIB instances. */
209 static oid ospfv3_oid[] = {OSPFv3MIB};
210 static oid ospfv3_trap_oid[] = {OSPFv3MIB, 0};
211
212 /* Hook functions. */
213 static u_char *ospfv3GeneralGroup(struct variable *, oid *, size_t *, int,
214 size_t *, WriteMethod **);
215 static u_char *ospfv3AreaEntry(struct variable *, oid *, size_t *, int,
216 size_t *, WriteMethod **);
217 static u_char *ospfv3WwLsdbEntry(struct variable *, oid *, size_t *, int,
218 size_t *, WriteMethod **);
219 static u_char *ospfv3NbrEntry(struct variable *, oid *, size_t *, int, size_t *,
220 WriteMethod **);
221 static u_char *ospfv3IfEntry(struct variable *, oid *, size_t *, int, size_t *,
222 WriteMethod **);
223
224 static struct variable ospfv3_variables[] = {
225 /* OSPF general variables */
226 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup, 3, {1, 1, 1}},
227 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup, 3, {1, 1, 2}},
228 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup, 3, {1, 1, 3}},
229 {OSPFv3AREABDRRTRSTATUS,
230 INTEGER,
231 RONLY,
232 ospfv3GeneralGroup,
233 3,
234 {1, 1, 4}},
235 {OSPFv3ASBDRRTRSTATUS,
236 INTEGER,
237 RWRITE,
238 ospfv3GeneralGroup,
239 3,
240 {1, 1, 5}},
241 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, 3, {1, 1, 6}},
242 {OSPFv3ASSCOPELSACHECKSUMSUM,
243 UNSIGNED,
244 RONLY,
245 ospfv3GeneralGroup,
246 3,
247 {1, 1, 7}},
248 {OSPFv3ORIGINATENEWLSAS,
249 COUNTER,
250 RONLY,
251 ospfv3GeneralGroup,
252 3,
253 {1, 1, 8}},
254 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup, 3, {1, 1, 9}},
255 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, 3, {1, 1, 10}},
256 {OSPFv3EXTAREALSDBLIMIT,
257 INTEGER,
258 RWRITE,
259 ospfv3GeneralGroup,
260 3,
261 {1, 1, 11}},
262 {OSPFv3EXITOVERFLOWINTERVAL,
263 UNSIGNED,
264 RWRITE,
265 ospfv3GeneralGroup,
266 3,
267 {1, 1, 12}},
268 {OSPFv3DEMANDEXTENSIONS,
269 INTEGER,
270 RWRITE,
271 ospfv3GeneralGroup,
272 3,
273 {1, 1, 13}},
274 {OSPFv3REFERENCEBANDWIDTH,
275 UNSIGNED,
276 RWRITE,
277 ospfv3GeneralGroup,
278 3,
279 {1, 1, 14}},
280 {OSPFv3RESTARTSUPPORT,
281 INTEGER,
282 RWRITE,
283 ospfv3GeneralGroup,
284 3,
285 {1, 1, 15}},
286 {OSPFv3RESTARTINTERVAL,
287 UNSIGNED,
288 RWRITE,
289 ospfv3GeneralGroup,
290 3,
291 {1, 1, 16}},
292 {OSPFv3RESTARTSTRICTLSACHECKING,
293 INTEGER,
294 RWRITE,
295 ospfv3GeneralGroup,
296 3,
297 {1, 1, 17}},
298 {OSPFv3RESTARTSTATUS,
299 INTEGER,
300 RONLY,
301 ospfv3GeneralGroup,
302 3,
303 {1, 1, 18}},
304 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup, 3, {1, 1, 19}},
305 {OSPFv3RESTARTEXITREASON,
306 INTEGER,
307 RONLY,
308 ospfv3GeneralGroup,
309 3,
310 {1, 1, 20}},
311 {OSPFv3NOTIFICATIONENABLE,
312 INTEGER,
313 RWRITE,
314 ospfv3GeneralGroup,
315 3,
316 {1, 1, 21}},
317 {OSPFv3STUBROUTERSUPPORT,
318 INTEGER,
319 RONLY,
320 ospfv3GeneralGroup,
321 3,
322 {1, 1, 22}},
323 {OSPFv3STUBROUTERADVERTISEMENT,
324 INTEGER,
325 RWRITE,
326 ospfv3GeneralGroup,
327 3,
328 {1, 1, 23}},
329 {OSPFv3DISCONTINUITYTIME,
330 TIMETICKS,
331 RONLY,
332 ospfv3GeneralGroup,
333 3,
334 {1, 1, 24}},
335 {OSPFv3RESTARTTIME,
336 TIMETICKS,
337 RONLY,
338 ospfv3GeneralGroup,
339 3,
340 {1, 1, 25}},
341
342 /* OSPFv3 Area Data Structure */
343 {OSPFv3IMPORTASEXTERN,
344 INTEGER,
345 RWRITE,
346 ospfv3AreaEntry,
347 4,
348 {1, 2, 1, 2}},
349 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry, 4, {1, 2, 1, 3}},
350 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry, 4, {1, 2, 1, 4}},
351 {OSPFv3AREAASBDRRTRCOUNT,
352 GAUGE,
353 RONLY,
354 ospfv3AreaEntry,
355 4,
356 {1, 2, 1, 5}},
357 {OSPFv3AREASCOPELSACOUNT,
358 GAUGE,
359 RONLY,
360 ospfv3AreaEntry,
361 4,
362 {1, 2, 1, 6}},
363 {OSPFv3AREASCOPELSACKSUMSUM,
364 UNSIGNED,
365 RONLY,
366 ospfv3AreaEntry,
367 4,
368 {1, 2, 1, 7}},
369 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry, 4, {1, 2, 1, 8}},
370 {OSPFv3AREAROWSTATUS,
371 INTEGER,
372 RWRITE,
373 ospfv3AreaEntry,
374 4,
375 {1, 2, 1, 9}},
376 {OSPFv3AREASTUBMETRIC,
377 INTEGER,
378 RWRITE,
379 ospfv3AreaEntry,
380 4,
381 {1, 2, 1, 10}},
382 {OSPFv3AREANSSATRANSLATORROLE,
383 INTEGER,
384 RWRITE,
385 ospfv3AreaEntry,
386 4,
387 {1, 2, 1, 11}},
388 {OSPFv3AREANSSATRANSLATORSTATE,
389 INTEGER,
390 RONLY,
391 ospfv3AreaEntry,
392 4,
393 {1, 2, 1, 12}},
394 {OSPFv3AREANSSATRANSLATORSTABINTERVAL,
395 UNSIGNED,
396 RWRITE,
397 ospfv3AreaEntry,
398 4,
399 {1, 2, 1, 13}},
400 {OSPFv3AREANSSATRANSLATOREVENTS,
401 COUNTER,
402 RONLY,
403 ospfv3AreaEntry,
404 4,
405 {1, 2, 1, 14}},
406 {OSPFv3AREASTUBMETRICTYPE,
407 INTEGER,
408 RWRITE,
409 ospfv3AreaEntry,
410 4,
411 {1, 2, 1, 15}},
412 {OSPFv3AREATEENABLED,
413 INTEGER,
414 RWRITE,
415 ospfv3AreaEntry,
416 4,
417 {1, 2, 1, 16}},
418
419 /* OSPFv3 AS LSDB */
420 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWASTABLE,
421 INTEGER,
422 RONLY,
423 ospfv3WwLsdbEntry,
424 4,
425 {1, 3, 1, 4}},
426 {OSPFv3WWLSDBAGE | OSPFv3WWASTABLE,
427 UNSIGNED,
428 RONLY,
429 ospfv3WwLsdbEntry,
430 4,
431 {1, 3, 1, 5}},
432 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWASTABLE,
433 INTEGER,
434 RONLY,
435 ospfv3WwLsdbEntry,
436 4,
437 {1, 3, 1, 6}},
438 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWASTABLE,
439 STRING,
440 RONLY,
441 ospfv3WwLsdbEntry,
442 4,
443 {1, 3, 1, 7}},
444 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWASTABLE,
445 INTEGER,
446 RONLY,
447 ospfv3WwLsdbEntry,
448 4,
449 {1, 3, 1, 8}},
450
451 /* OSPFv3 Area LSDB */
452 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWAREATABLE,
453 INTEGER,
454 RONLY,
455 ospfv3WwLsdbEntry,
456 4,
457 {1, 4, 1, 5}},
458 {OSPFv3WWLSDBAGE | OSPFv3WWAREATABLE,
459 UNSIGNED,
460 RONLY,
461 ospfv3WwLsdbEntry,
462 4,
463 {1, 4, 1, 6}},
464 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWAREATABLE,
465 INTEGER,
466 RONLY,
467 ospfv3WwLsdbEntry,
468 4,
469 {1, 4, 1, 7}},
470 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWAREATABLE,
471 STRING,
472 RONLY,
473 ospfv3WwLsdbEntry,
474 4,
475 {1, 4, 1, 8}},
476 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWAREATABLE,
477 INTEGER,
478 RONLY,
479 ospfv3WwLsdbEntry,
480 4,
481 {1, 4, 1, 9}},
482
483 /* OSPFv3 Link LSDB */
484 {OSPFv3WWLSDBSEQUENCE | OSPFv3WWLINKTABLE,
485 INTEGER,
486 RONLY,
487 ospfv3WwLsdbEntry,
488 4,
489 {1, 5, 1, 6}},
490 {OSPFv3WWLSDBAGE | OSPFv3WWLINKTABLE,
491 UNSIGNED,
492 RONLY,
493 ospfv3WwLsdbEntry,
494 4,
495 {1, 5, 1, 7}},
496 {OSPFv3WWLSDBCHECKSUM | OSPFv3WWLINKTABLE,
497 INTEGER,
498 RONLY,
499 ospfv3WwLsdbEntry,
500 4,
501 {1, 5, 1, 8}},
502 {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWLINKTABLE,
503 STRING,
504 RONLY,
505 ospfv3WwLsdbEntry,
506 4,
507 {1, 5, 1, 9}},
508 {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWLINKTABLE,
509 INTEGER,
510 RONLY,
511 ospfv3WwLsdbEntry,
512 4,
513 {1, 5, 1, 10}},
514
515 /* OSPFv3 interfaces */
516 {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 3}},
517 {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 4}},
518 {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 5}},
519 {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 6}},
520 {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 7}},
521 {OSPFv3IFRETRANSINTERVAL,
522 UNSIGNED,
523 RONLY,
524 ospfv3IfEntry,
525 4,
526 {1, 7, 1, 8}},
527 {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 9}},
528 {OSPFv3IFRTRDEADINTERVAL,
529 UNSIGNED,
530 RONLY,
531 ospfv3IfEntry,
532 4,
533 {1, 7, 1, 10}},
534 {OSPFv3IFPOLLINTERVAL,
535 UNSIGNED,
536 RONLY,
537 ospfv3IfEntry,
538 4,
539 {1, 7, 1, 11}},
540 {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 12}},
541 {OSPFv3IFDESIGNATEDROUTER,
542 UNSIGNED,
543 RONLY,
544 ospfv3IfEntry,
545 4,
546 {1, 7, 1, 13}},
547 {OSPFv3IFBACKUPDESIGNATEDROUTER,
548 UNSIGNED,
549 RONLY,
550 ospfv3IfEntry,
551 4,
552 {1, 7, 1, 14}},
553 {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 15}},
554 {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 16}},
555 {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 17}},
556 {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 18}},
557 {OSPFv3IFLINKSCOPELSACOUNT,
558 GAUGE,
559 RONLY,
560 ospfv3IfEntry,
561 4,
562 {1, 7, 1, 19}},
563 {OSPFv3IFLINKLSACKSUMSUM,
564 UNSIGNED,
565 RONLY,
566 ospfv3IfEntry,
567 4,
568 {1, 7, 1, 20}},
569 {OSPFv3IFDEMANDNBRPROBE,
570 INTEGER,
571 RONLY,
572 ospfv3IfEntry,
573 4,
574 {1, 7, 1, 21}},
575 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT,
576 UNSIGNED,
577 RONLY,
578 ospfv3IfEntry,
579 4,
580 {1, 7, 1, 22}},
581 {OSPFv3IFDEMANDNBRPROBEINTERVAL,
582 UNSIGNED,
583 RONLY,
584 ospfv3IfEntry,
585 4,
586 {1, 7, 1, 23}},
587 {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry, 4, {1, 7, 1, 24}},
588 {OSPFv3IFLINKLSASUPPRESSION,
589 INTEGER,
590 RONLY,
591 ospfv3IfEntry,
592 4,
593 {1, 7, 1, 25}},
594
595 /* OSPFv3 neighbors */
596 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 4}},
597 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 5}},
598 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 6}},
599 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 7}},
600 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 8}},
601 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 9}},
602 {OSPFv3NBRLSRETRANSQLEN,
603 GAUGE,
604 RONLY,
605 ospfv3NbrEntry,
606 4,
607 {1, 9, 1, 10}},
608 {OSPFv3NBRHELLOSUPPRESSED,
609 INTEGER,
610 RONLY,
611 ospfv3NbrEntry,
612 4,
613 {1, 9, 1, 11}},
614 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry, 4, {1, 9, 1, 12}},
615 {OSPFv3NBRRESTARTHELPERSTATUS,
616 INTEGER,
617 RONLY,
618 ospfv3NbrEntry,
619 4,
620 {1, 9, 1, 13}},
621 {OSPFv3NBRRESTARTHELPERAGE,
622 UNSIGNED,
623 RONLY,
624 ospfv3NbrEntry,
625 4,
626 {1, 9, 1, 14}},
627 {OSPFv3NBRRESTARTHELPEREXITREASON,
628 INTEGER,
629 RONLY,
630 ospfv3NbrEntry,
631 4,
632 {1, 9, 1, 15}},
633 };
634
635 static u_char *ospfv3GeneralGroup(struct variable *v, oid *name, size_t *length,
636 int exact, size_t *var_len,
637 WriteMethod **write_method)
638 {
639 u_int16_t sum;
640 u_int32_t count;
641 struct ospf6_lsa *lsa = NULL;
642
643 /* Check whether the instance identifier is valid */
644 if (smux_header_generic(v, name, length, exact, var_len, write_method)
645 == MATCH_FAILED)
646 return NULL;
647
648 /* Return the current value of the variable */
649 switch (v->magic) {
650 case OSPFv3ROUTERID:
651 /* Router-ID of this OSPF instance. */
652 if (ospf6)
653 return SNMP_INTEGER(ntohl(ospf6->router_id));
654 return SNMP_INTEGER(0);
655 case OSPFv3ADMINSTAT:
656 if (ospf6)
657 return SNMP_INTEGER(
658 CHECK_FLAG(ospf6->flag, OSPF6_DISABLED)
659 ? OSPF_STATUS_DISABLED
660 : OSPF_STATUS_ENABLED);
661 return SNMP_INTEGER(OSPF_STATUS_DISABLED);
662 case OSPFv3VERSIONNUMBER:
663 return SNMP_INTEGER(3);
664 case OSPFv3AREABDRRTRSTATUS:
665 if (ospf6)
666 return SNMP_INTEGER(ospf6_is_router_abr(ospf6)
667 ? SNMP_TRUE
668 : SNMP_FALSE);
669 return SNMP_INTEGER(SNMP_FALSE);
670 case OSPFv3ASBDRRTRSTATUS:
671 if (ospf6)
672 return SNMP_INTEGER(ospf6_asbr_is_asbr(ospf6)
673 ? SNMP_TRUE
674 : SNMP_FALSE);
675 return SNMP_INTEGER(SNMP_FALSE);
676 case OSPFv3ASSCOPELSACOUNT:
677 if (ospf6)
678 return SNMP_INTEGER(ospf6->lsdb->count);
679 return SNMP_INTEGER(0);
680 case OSPFv3ASSCOPELSACHECKSUMSUM:
681 if (ospf6) {
682 for (sum = 0, lsa = ospf6_lsdb_head(ospf6->lsdb); lsa;
683 lsa = ospf6_lsdb_next(lsa))
684 sum += ntohs(lsa->header->checksum);
685 return SNMP_INTEGER(sum);
686 }
687 return SNMP_INTEGER(0);
688 case OSPFv3ORIGINATENEWLSAS:
689 return SNMP_INTEGER(
690 0); /* Don't know where to get this value... */
691 case OSPFv3RXNEWLSAS:
692 return SNMP_INTEGER(
693 0); /* Don't know where to get this value... */
694 case OSPFv3EXTLSACOUNT:
695 if (ospf6) {
696 for (count = 0,
697 lsa = ospf6_lsdb_type_head(
698 htons(OSPF6_LSTYPE_AS_EXTERNAL),
699 ospf6->lsdb);
700 lsa; lsa = ospf6_lsdb_type_next(
701 htons(OSPF6_LSTYPE_AS_EXTERNAL), lsa))
702 count += 1;
703 return SNMP_INTEGER(count);
704 }
705 return SNMP_INTEGER(0);
706 case OSPFv3EXTAREALSDBLIMIT:
707 return SNMP_INTEGER(-1);
708 case OSPFv3EXITOVERFLOWINTERVAL:
709 return SNMP_INTEGER(0); /* Not supported */
710 case OSPFv3DEMANDEXTENSIONS:
711 return SNMP_INTEGER(0); /* Not supported */
712 case OSPFv3REFERENCEBANDWIDTH:
713 if (ospf6)
714 return SNMP_INTEGER(ospf6->ref_bandwidth);
715 /* Otherwise, like for "not implemented". */
716 case OSPFv3RESTARTSUPPORT:
717 case OSPFv3RESTARTINTERVAL:
718 case OSPFv3RESTARTSTRICTLSACHECKING:
719 case OSPFv3RESTARTSTATUS:
720 case OSPFv3RESTARTAGE:
721 case OSPFv3RESTARTEXITREASON:
722 case OSPFv3NOTIFICATIONENABLE:
723 case OSPFv3STUBROUTERSUPPORT:
724 case OSPFv3STUBROUTERADVERTISEMENT:
725 case OSPFv3DISCONTINUITYTIME:
726 case OSPFv3RESTARTTIME:
727 /* TODO: Not implemented */
728 return NULL;
729 }
730 return NULL;
731 }
732
733 static u_char *ospfv3AreaEntry(struct variable *v, oid *name, size_t *length,
734 int exact, size_t *var_len,
735 WriteMethod **write_method)
736 {
737 struct ospf6_area *oa, *area = NULL;
738 struct ospf6_lsa *lsa = NULL;
739 u_int32_t area_id = 0;
740 u_int32_t count;
741 u_int16_t sum;
742 struct listnode *node;
743 unsigned int len;
744 char a[16];
745 struct ospf6_route *ro;
746
747 if (ospf6 == NULL)
748 return NULL;
749
750 if (smux_header_table(v, name, length, exact, var_len, write_method)
751 == MATCH_FAILED)
752 return NULL;
753
754 len = *length - v->namelen;
755 len = (len >= 1 ? 1 : 0);
756 if (exact && len != 1)
757 return NULL;
758 if (len)
759 area_id = htonl(name[v->namelen]);
760
761 inet_ntop(AF_INET, &area_id, a, sizeof(a));
762 zlog_debug("SNMP access by area: %s, exact=%d len=%d length=%lu", a,
763 exact, len, (u_long)*length);
764
765 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
766 if (area == NULL) {
767 if (len == 0) /* return first area entry */
768 area = oa;
769 else if (exact && ntohl(oa->area_id) == ntohl(area_id))
770 area = oa;
771 else if (ntohl(oa->area_id) > ntohl(area_id))
772 area = oa;
773 }
774 }
775
776 if (area == NULL)
777 return NULL;
778
779 *length = v->namelen + 1;
780 name[v->namelen] = ntohl(area->area_id);
781
782 inet_ntop(AF_INET, &area->area_id, a, sizeof(a));
783 zlog_debug("SNMP found area: %s, exact=%d len=%d length=%lu", a, exact,
784 len, (u_long)*length);
785
786 switch (v->magic) {
787 case OSPFv3IMPORTASEXTERN:
788 /* No NSSA support */
789 return SNMP_INTEGER(IS_AREA_STUB(area) ? 2 : 1);
790 case OSPFv3AREASPFRUNS:
791 return SNMP_INTEGER(area->spf_calculation);
792 case OSPFv3AREABDRRTRCOUNT:
793 case OSPFv3AREAASBDRRTRCOUNT:
794 count = 0;
795 for (ro = ospf6_route_head(ospf6->brouter_table); ro;
796 ro = ospf6_route_next(ro)) {
797 if (ntohl(ro->path.area_id) != ntohl(area->area_id))
798 continue;
799 if (v->magic == OSPFv3AREABDRRTRCOUNT
800 && CHECK_FLAG(ro->path.router_bits,
801 OSPF6_ROUTER_BIT_B))
802 count++;
803 if (v->magic == OSPFv3AREAASBDRRTRCOUNT
804 && CHECK_FLAG(ro->path.router_bits,
805 OSPF6_ROUTER_BIT_E))
806 count++;
807 }
808 return SNMP_INTEGER(count);
809 case OSPFv3AREASCOPELSACOUNT:
810 return SNMP_INTEGER(area->lsdb->count);
811 case OSPFv3AREASCOPELSACKSUMSUM:
812 for (sum = 0, lsa = ospf6_lsdb_head(area->lsdb); lsa;
813 lsa = ospf6_lsdb_next(lsa))
814 sum += ntohs(lsa->header->checksum);
815 return SNMP_INTEGER(sum);
816 case OSPFv3AREASUMMARY:
817 return SNMP_INTEGER(2); /* sendAreaSummary */
818 case OSPFv3AREAROWSTATUS:
819 return SNMP_INTEGER(1); /* Active */
820 case OSPFv3AREASTUBMETRIC:
821 case OSPFv3AREANSSATRANSLATORROLE:
822 case OSPFv3AREANSSATRANSLATORSTATE:
823 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
824 case OSPFv3AREANSSATRANSLATOREVENTS:
825 case OSPFv3AREASTUBMETRICTYPE:
826 case OSPFv3AREATEENABLED:
827 /* Not implemented. */
828 return NULL;
829 }
830 return NULL;
831 }
832
833 static int if_icmp_func(struct interface *ifp1, struct interface *ifp2)
834 {
835 return (ifp1->ifindex - ifp2->ifindex);
836 }
837
838 static u_char *ospfv3WwLsdbEntry(struct variable *v, oid *name, size_t *length,
839 int exact, size_t *var_len,
840 WriteMethod **write_method)
841 {
842 struct ospf6_lsa *lsa = NULL;
843 ifindex_t ifindex;
844 uint32_t area_id, id, instid, adv_router;
845 u_int16_t type;
846 int len;
847 oid *offset;
848 int offsetlen;
849 struct ospf6_area *oa = NULL;
850 struct listnode *node;
851 struct interface *iif;
852 struct ospf6_interface *oi = NULL;
853 struct list *ifslist;
854
855 if (smux_header_table(v, name, length, exact, var_len, write_method)
856 == MATCH_FAILED)
857 return NULL;
858
859 instid = ifindex = area_id = type = id = adv_router = 0;
860
861 /* Check OSPFv3 instance. */
862 if (ospf6 == NULL)
863 return NULL;
864
865 /* Get variable length. */
866 offset = name + v->namelen;
867 offsetlen = *length - v->namelen;
868
869 if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3)
870 return NULL;
871 if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4)
872 return NULL;
873 if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5)
874 return NULL;
875
876 if (v->magic & OSPFv3WWLINKTABLE) {
877 /* Parse ifindex */
878 len = (offsetlen < 1 ? 0 : 1);
879 if (len)
880 ifindex = *offset;
881 offset += len;
882 offsetlen -= len;
883
884 /* Parse instance ID */
885 len = (offsetlen < 1 ? 0 : 1);
886 if (len)
887 instid = *offset;
888 offset += len;
889 offsetlen -= len;
890 } else if (v->magic & OSPFv3WWAREATABLE) {
891 /* Parse area-id */
892 len = (offsetlen < 1 ? 0 : 1);
893 if (len)
894 area_id = htonl(*offset);
895 offset += len;
896 offsetlen -= len;
897 }
898
899 /* Parse type */
900 len = (offsetlen < 1 ? 0 : 1);
901 if (len)
902 type = htons(*offset);
903 offset += len;
904 offsetlen -= len;
905
906 /* Parse Router-ID */
907 len = (offsetlen < 1 ? 0 : 1);
908 if (len)
909 adv_router = htonl(*offset);
910 offset += len;
911 offsetlen -= len;
912
913 /* Parse LS-ID */
914 len = (offsetlen < 1 ? 0 : 1);
915 if (len)
916 id = htonl(*offset);
917 offset += len;
918 offsetlen -= len;
919
920 if (exact) {
921 if (v->magic & OSPFv3WWASTABLE) {
922 lsa = ospf6_lsdb_lookup(type, id, adv_router,
923 ospf6->lsdb);
924 } else if (v->magic & OSPFv3WWAREATABLE) {
925 oa = ospf6_area_lookup(area_id, ospf6);
926 if (!oa)
927 return NULL;
928 lsa = ospf6_lsdb_lookup(type, id, adv_router, oa->lsdb);
929 } else if (v->magic & OSPFv3WWLINKTABLE) {
930 oi = ospf6_interface_lookup_by_ifindex(ifindex);
931 if (!oi || oi->instance_id != instid)
932 return NULL;
933 lsa = ospf6_lsdb_lookup(type, id, adv_router, oi->lsdb);
934 }
935 } else {
936 if (v->magic & OSPFv3WWASTABLE) {
937 if (ospf6->lsdb->count)
938 lsa = ospf6_lsdb_lookup_next(
939 type, id, adv_router, ospf6->lsdb);
940 } else if (v->magic & OSPFv3WWAREATABLE)
941 for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, node, oa)) {
942 if (oa->area_id < area_id)
943 continue;
944
945 if (oa->lsdb->count)
946 lsa = ospf6_lsdb_lookup_next(
947 type, id, adv_router, oa->lsdb);
948 if (lsa)
949 break;
950 type = 0;
951 id = 0;
952 adv_router = 0;
953 }
954 else if (v->magic & OSPFv3WWLINKTABLE) {
955 /* We build a sorted list of interfaces */
956 ifslist = list_new();
957 if (!ifslist)
958 return NULL;
959 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
960 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node,
961 iif))
962 listnode_add_sort(ifslist, iif);
963
964 for (ALL_LIST_ELEMENTS_RO(ifslist, node, iif)) {
965 if (!iif->ifindex)
966 continue;
967 oi = ospf6_interface_lookup_by_ifindex(
968 iif->ifindex);
969 if (!oi)
970 continue;
971 if (iif->ifindex < ifindex)
972 continue;
973 if (oi->instance_id < instid)
974 continue;
975
976 if (oi->lsdb->count)
977 lsa = ospf6_lsdb_lookup_next(
978 type, id, adv_router, oi->lsdb);
979 if (lsa)
980 break;
981 type = 0;
982 id = 0;
983 adv_router = 0;
984 oi = NULL;
985 }
986
987 list_delete_all_node(ifslist);
988 }
989 }
990
991 if (!lsa)
992 return NULL;
993
994 /* Add indexes */
995 if (v->magic & OSPFv3WWASTABLE) {
996 *length = v->namelen + 3;
997 offset = name + v->namelen;
998 } else if (v->magic & OSPFv3WWAREATABLE) {
999 *length = v->namelen + 4;
1000 offset = name + v->namelen;
1001 *offset = ntohl(oa->area_id);
1002 offset++;
1003 } else if (v->magic & OSPFv3WWLINKTABLE) {
1004 *length = v->namelen + 5;
1005 offset = name + v->namelen;
1006 *offset = oi->interface->ifindex;
1007 offset++;
1008 *offset = oi->instance_id;
1009 offset++;
1010 }
1011 *offset = ntohs(lsa->header->type);
1012 offset++;
1013 *offset = ntohl(lsa->header->adv_router);
1014 offset++;
1015 *offset = ntohl(lsa->header->id);
1016 offset++;
1017
1018 /* Return the current value of the variable */
1019 switch (v->magic & OSPFv3WWCOLUMN) {
1020 case OSPFv3WWLSDBSEQUENCE:
1021 return SNMP_INTEGER(ntohl(lsa->header->seqnum));
1022 break;
1023 case OSPFv3WWLSDBAGE:
1024 ospf6_lsa_age_current(lsa);
1025 return SNMP_INTEGER(ntohs(lsa->header->age));
1026 break;
1027 case OSPFv3WWLSDBCHECKSUM:
1028 return SNMP_INTEGER(ntohs(lsa->header->checksum));
1029 break;
1030 case OSPFv3WWLSDBADVERTISEMENT:
1031 *var_len = ntohs(lsa->header->length);
1032 return (u_char *)lsa->header;
1033 break;
1034 case OSPFv3WWLSDBTYPEKNOWN:
1035 return SNMP_INTEGER(OSPF6_LSA_IS_KNOWN(lsa->header->type)
1036 ? SNMP_TRUE
1037 : SNMP_FALSE);
1038 break;
1039 }
1040 return NULL;
1041 }
1042
1043 static u_char *ospfv3IfEntry(struct variable *v, oid *name, size_t *length,
1044 int exact, size_t *var_len,
1045 WriteMethod **write_method)
1046 {
1047 ifindex_t ifindex = 0;
1048 unsigned int instid = 0;
1049 struct ospf6_interface *oi = NULL;
1050 struct ospf6_lsa *lsa = NULL;
1051 struct interface *iif;
1052 struct listnode *i;
1053 struct list *ifslist;
1054 oid *offset;
1055 int offsetlen, len;
1056 u_int32_t sum;
1057
1058 if (smux_header_table(v, name, length, exact, var_len, write_method)
1059 == MATCH_FAILED)
1060 return NULL;
1061
1062 /* Check OSPFv3 instance. */
1063 if (ospf6 == NULL)
1064 return NULL;
1065
1066 /* Get variable length. */
1067 offset = name + v->namelen;
1068 offsetlen = *length - v->namelen;
1069
1070 if (exact && offsetlen != 2)
1071 return NULL;
1072
1073 /* Parse if index */
1074 len = (offsetlen < 1 ? 0 : 1);
1075 if (len)
1076 ifindex = *offset;
1077 offset += len;
1078 offsetlen -= len;
1079
1080 /* Parse instance ID */
1081 len = (offsetlen < 1 ? 0 : 1);
1082 if (len)
1083 instid = *offset;
1084 offset += len;
1085 offsetlen -= len;
1086
1087 if (exact) {
1088 oi = ospf6_interface_lookup_by_ifindex(ifindex);
1089 if (!oi || oi->instance_id != instid)
1090 return NULL;
1091 } else {
1092 /* We build a sorted list of interfaces */
1093 ifslist = list_new();
1094 if (!ifslist)
1095 return NULL;
1096 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
1097 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
1098 listnode_add_sort(ifslist, iif);
1099
1100 for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
1101 if (!iif->ifindex)
1102 continue;
1103 oi = ospf6_interface_lookup_by_ifindex(iif->ifindex);
1104 if (!oi)
1105 continue;
1106 if (iif->ifindex > ifindex
1107 || (iif->ifindex == ifindex
1108 && (oi->instance_id > instid)))
1109 break;
1110 oi = NULL;
1111 }
1112
1113 list_delete_all_node(ifslist);
1114 }
1115
1116 if (!oi)
1117 return NULL;
1118
1119 /* Add Index (IfIndex, IfInstId) */
1120 *length = v->namelen + 2;
1121 offset = name + v->namelen;
1122 *offset = oi->interface->ifindex;
1123 offset++;
1124 *offset = oi->instance_id;
1125 offset++;
1126
1127 /* Return the current value of the variable */
1128 switch (v->magic) {
1129 case OSPFv3IFAREAID:
1130 if (oi->area)
1131 return SNMP_INTEGER(ntohl(oi->area->area_id));
1132 break;
1133 case OSPFv3IFTYPE:
1134 if (if_is_broadcast(oi->interface))
1135 return SNMP_INTEGER(1);
1136 else if (if_is_pointopoint(oi->interface))
1137 return SNMP_INTEGER(3);
1138 else
1139 break; /* Unknown, don't put anything */
1140 case OSPFv3IFADMINSTATUS:
1141 if (oi->area)
1142 return SNMP_INTEGER(OSPF_STATUS_ENABLED);
1143 return SNMP_INTEGER(OSPF_STATUS_DISABLED);
1144 case OSPFv3IFRTRPRIORITY:
1145 return SNMP_INTEGER(oi->priority);
1146 case OSPFv3IFTRANSITDELAY:
1147 return SNMP_INTEGER(oi->transdelay);
1148 case OSPFv3IFRETRANSINTERVAL:
1149 return SNMP_INTEGER(oi->rxmt_interval);
1150 case OSPFv3IFHELLOINTERVAL:
1151 return SNMP_INTEGER(oi->hello_interval);
1152 case OSPFv3IFRTRDEADINTERVAL:
1153 return SNMP_INTEGER(oi->dead_interval);
1154 case OSPFv3IFPOLLINTERVAL:
1155 /* No support for NBMA */
1156 break;
1157 case OSPFv3IFSTATE:
1158 return SNMP_INTEGER(oi->state);
1159 case OSPFv3IFDESIGNATEDROUTER:
1160 return SNMP_INTEGER(ntohl(oi->drouter));
1161 case OSPFv3IFBACKUPDESIGNATEDROUTER:
1162 return SNMP_INTEGER(ntohl(oi->bdrouter));
1163 case OSPFv3IFEVENTS:
1164 return SNMP_INTEGER(oi->state_change);
1165 case OSPFv3IFROWSTATUS:
1166 return SNMP_INTEGER(1);
1167 case OSPFv3IFDEMAND:
1168 return SNMP_INTEGER(SNMP_FALSE);
1169 case OSPFv3IFMETRICVALUE:
1170 return SNMP_INTEGER(oi->cost);
1171 case OSPFv3IFLINKSCOPELSACOUNT:
1172 return SNMP_INTEGER(oi->lsdb->count);
1173 case OSPFv3IFLINKLSACKSUMSUM:
1174 for (sum = 0, lsa = ospf6_lsdb_head(oi->lsdb); lsa;
1175 lsa = ospf6_lsdb_next(lsa))
1176 sum += ntohs(lsa->header->checksum);
1177 return SNMP_INTEGER(sum);
1178 case OSPFv3IFDEMANDNBRPROBE:
1179 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT:
1180 case OSPFv3IFDEMANDNBRPROBEINTERVAL:
1181 case OSPFv3IFTEDISABLED:
1182 case OSPFv3IFLINKLSASUPPRESSION:
1183 /* Not implemented. Only works if all the last ones are not
1184 implemented! */
1185 return NULL;
1186 }
1187
1188 /* Try an internal getnext. Some columns are missing in this table. */
1189 if (!exact && (name[*length - 1] < MAX_SUBID))
1190 return ospfv3IfEntry(v, name, length, exact, var_len,
1191 write_method);
1192 return NULL;
1193 }
1194
1195 static u_char *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length,
1196 int exact, size_t *var_len,
1197 WriteMethod **write_method)
1198 {
1199 ifindex_t ifindex = 0;
1200 unsigned int instid, rtrid;
1201 struct ospf6_interface *oi = NULL;
1202 struct ospf6_neighbor *on = NULL;
1203 struct interface *iif;
1204 struct listnode *i, *j;
1205 struct list *ifslist;
1206 oid *offset;
1207 int offsetlen, len;
1208
1209 if (smux_header_table(v, name, length, exact, var_len, write_method)
1210 == MATCH_FAILED)
1211 return NULL;
1212
1213 instid = rtrid = 0;
1214
1215 /* Check OSPFv3 instance. */
1216 if (ospf6 == NULL)
1217 return NULL;
1218
1219 /* Get variable length. */
1220 offset = name + v->namelen;
1221 offsetlen = *length - v->namelen;
1222
1223 if (exact && offsetlen != 3)
1224 return NULL;
1225
1226 /* Parse if index */
1227 len = (offsetlen < 1 ? 0 : 1);
1228 if (len)
1229 ifindex = *offset;
1230 offset += len;
1231 offsetlen -= len;
1232
1233 /* Parse instance ID */
1234 len = (offsetlen < 1 ? 0 : 1);
1235 if (len)
1236 instid = *offset;
1237 offset += len;
1238 offsetlen -= len;
1239
1240 /* Parse router ID */
1241 len = (offsetlen < 1 ? 0 : 1);
1242 if (len)
1243 rtrid = htonl(*offset);
1244 offset += len;
1245 offsetlen -= len;
1246
1247 if (exact) {
1248 oi = ospf6_interface_lookup_by_ifindex(ifindex);
1249 if (!oi || oi->instance_id != instid)
1250 return NULL;
1251 on = ospf6_neighbor_lookup(rtrid, oi);
1252 } else {
1253 /* We build a sorted list of interfaces */
1254 ifslist = list_new();
1255 if (!ifslist)
1256 return NULL;
1257 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
1258 for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), i, iif))
1259 listnode_add_sort(ifslist, iif);
1260
1261 for (ALL_LIST_ELEMENTS_RO(ifslist, i, iif)) {
1262 if (!iif->ifindex)
1263 continue;
1264 oi = ospf6_interface_lookup_by_ifindex(iif->ifindex);
1265 if (!oi)
1266 continue;
1267 for (ALL_LIST_ELEMENTS_RO(oi->neighbor_list, j, on)) {
1268 if (iif->ifindex > ifindex
1269 || (iif->ifindex == ifindex
1270 && (oi->instance_id > instid
1271 || (oi->instance_id == instid
1272 && ntohl(on->router_id)
1273 > ntohl(rtrid)))))
1274 break;
1275 }
1276 if (on)
1277 break;
1278 oi = NULL;
1279 on = NULL;
1280 }
1281
1282 list_delete_all_node(ifslist);
1283 }
1284
1285 if (!oi || !on)
1286 return NULL;
1287
1288 /* Add Index (IfIndex, IfInstId, RtrId) */
1289 *length = v->namelen + 3;
1290 offset = name + v->namelen;
1291 *offset = oi->interface->ifindex;
1292 offset++;
1293 *offset = oi->instance_id;
1294 offset++;
1295 *offset = ntohl(on->router_id);
1296 offset++;
1297
1298 /* Return the current value of the variable */
1299 switch (v->magic) {
1300 case OSPFv3NBRADDRESSTYPE:
1301 return SNMP_INTEGER(2); /* IPv6 only */
1302 case OSPFv3NBRADDRESS:
1303 *var_len = sizeof(struct in6_addr);
1304 return (u_char *)&on->linklocal_addr;
1305 case OSPFv3NBROPTIONS:
1306 return SNMP_INTEGER(on->options[2]);
1307 case OSPFv3NBRPRIORITY:
1308 return SNMP_INTEGER(on->priority);
1309 case OSPFv3NBRSTATE:
1310 return SNMP_INTEGER(on->state);
1311 case OSPFv3NBREVENTS:
1312 return SNMP_INTEGER(on->state_change);
1313 case OSPFv3NBRLSRETRANSQLEN:
1314 return SNMP_INTEGER(on->retrans_list->count);
1315 case OSPFv3NBRHELLOSUPPRESSED:
1316 return SNMP_INTEGER(SNMP_FALSE);
1317 case OSPFv3NBRIFID:
1318 return SNMP_INTEGER(on->ifindex);
1319 case OSPFv3NBRRESTARTHELPERSTATUS:
1320 case OSPFv3NBRRESTARTHELPERAGE:
1321 case OSPFv3NBRRESTARTHELPEREXITREASON:
1322 /* Not implemented. Only works if all the last ones are not
1323 implemented! */
1324 return NULL;
1325 }
1326
1327 return NULL;
1328 }
1329
1330 /* OSPF Traps. */
1331 #define NBRSTATECHANGE 2
1332 #define IFSTATECHANGE 10
1333
1334 static struct trap_object ospf6NbrTrapList[] = {
1335 {-3, {1, 1, OSPFv3ROUTERID}},
1336 {4, {1, 9, 1, OSPFv3NBRADDRESSTYPE}},
1337 {4, {1, 9, 1, OSPFv3NBRADDRESS}},
1338 {4, {1, 9, 1, OSPFv3NBRSTATE}}};
1339
1340 static struct trap_object ospf6IfTrapList[] = {
1341 {-3, {1, 1, OSPFv3ROUTERID}},
1342 {4, {1, 7, 1, OSPFv3IFSTATE}},
1343 {4, {1, 7, 1, OSPFv3IFADMINSTATUS}},
1344 {4, {1, 7, 1, OSPFv3IFAREAID}}};
1345
1346 static int ospf6TrapNbrStateChange(struct ospf6_neighbor *on, int next_state,
1347 int prev_state)
1348 {
1349 oid index[3];
1350
1351 /* Terminal state or regression */
1352 if ((next_state != OSPF6_NEIGHBOR_FULL)
1353 && (next_state != OSPF6_NEIGHBOR_TWOWAY)
1354 && (next_state >= prev_state))
1355 return 0;
1356
1357 index[0] = on->ospf6_if->interface->ifindex;
1358 index[1] = on->ospf6_if->instance_id;
1359 index[2] = ntohl(on->router_id);
1360
1361 smux_trap(ospfv3_variables,
1362 sizeof ospfv3_variables / sizeof(struct variable),
1363 ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
1364 ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 3,
1365 ospf6NbrTrapList,
1366 sizeof ospf6NbrTrapList / sizeof(struct trap_object),
1367 NBRSTATECHANGE);
1368 return 0;
1369 }
1370
1371 static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state,
1372 int prev_state)
1373 {
1374 oid index[2];
1375
1376 /* Terminal state or regression */
1377 if ((next_state != OSPF6_INTERFACE_POINTTOPOINT)
1378 && (next_state != OSPF6_INTERFACE_DROTHER)
1379 && (next_state != OSPF6_INTERFACE_BDR)
1380 && (next_state != OSPF6_INTERFACE_DR) && (next_state >= prev_state))
1381 return 0;
1382
1383 index[0] = oi->interface->ifindex;
1384 index[1] = oi->instance_id;
1385
1386 smux_trap(ospfv3_variables,
1387 sizeof ospfv3_variables / sizeof(struct variable),
1388 ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof(oid),
1389 ospfv3_oid, sizeof ospfv3_oid / sizeof(oid), index, 2,
1390 ospf6IfTrapList,
1391 sizeof ospf6IfTrapList / sizeof(struct trap_object),
1392 IFSTATECHANGE);
1393 return 0;
1394 }
1395
1396 /* Register OSPFv3-MIB. */
1397 static int ospf6_snmp_init(struct thread_master *master)
1398 {
1399 smux_init(master);
1400 REGISTER_MIB("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
1401 return 0;
1402 }
1403
1404 static int ospf6_snmp_module_init(void)
1405 {
1406 hook_register(ospf6_interface_change, ospf6TrapIfStateChange);
1407 hook_register(ospf6_neighbor_change, ospf6TrapNbrStateChange);
1408 hook_register(frr_late_init, ospf6_snmp_init);
1409 return 0;
1410 }
1411
1412 FRR_MODULE_SETUP(.name = "ospf6d_snmp", .version = FRR_VERSION,
1413 .description = "ospf6d AgentX SNMP module",
1414 .init = ospf6_snmp_module_init, )