]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_snmp.c
ospf6d: add SNMP implementation of ospfv3IfTable
[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 #ifdef HAVE_SNMP
25
26 #include <net-snmp/net-snmp-config.h>
27 #include <net-snmp/net-snmp-includes.h>
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"
44 #include "ospf6_snmp.h"
45
46 /* OSPFv3-MIB */
47 #define OSPFv3MIB 1,3,6,1,2,1,191
48
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
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 */
77 #define OSPFv3IMPORTASEXTERN 2
78 #define OSPFv3AREASPFRUNS 3
79 #define OSPFv3AREABDRRTRCOUNT 4
80 #define OSPFv3AREAASBDRRTRCOUNT 5
81 #define OSPFv3AREASCOPELSACOUNT 6
82 #define OSPFv3AREASCOPELSACKSUMSUM 7
83 #define OSPFv3AREASUMMARY 8
84 #define OSPFv3AREAROWSTATUS 9
85 #define OSPFv3AREASTUBMETRIC 10
86 #define OSPFv3AREANSSATRANSLATORROLE 11
87 #define OSPFv3AREANSSATRANSLATORSTATE 12
88 #define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13
89 #define OSPFv3AREANSSATRANSLATOREVENTS 14
90 #define OSPFv3AREASTUBMETRICTYPE 15
91 #define OSPFv3AREATEENABLED 16
92
93 /* OSPFv3 MIB AS Lsdb Table values: ospfv3AsLsdbTable */
94 #define OSPFv3ASLSDBSEQUENCE 4
95 #define OSPFv3ASLSDBAGE 5
96 #define OSPFv3ASLSDBCHECKSUM 6
97 #define OSPFv3ASLSDBADVERTISEMENT 7
98 #define OSPFv3ASLSDBTYPEKNOWN 8
99
100 /* OSPFv3 MIB Area Lsdb Table values: ospfv3AreaLsdbTable */
101 #define OSPFv3AREALSDBSEQUENCE 5
102 #define OSPFv3AREALSDBAGE 6
103 #define OSPFv3AREALSDBCHECKSUM 7
104 #define OSPFv3AREALSDBADVERTISEMENT 8
105 #define OSPFv3AREALSDBTYPEKNOWN 9
106
107 /* OSPFv3 MIB Link Lsdb Table values: ospfv3LinkLsdbTable */
108 #define OSPFv3LINKLSDBSEQUENCE 6
109 #define OSPFv3LINKLSDBAGE 7
110 #define OSPFv3LINKLSDBCHECKSUM 8
111 #define OSPFv3LINKLSDBADVERTISEMENT 9
112 #define OSPFv3LINKLSDBTYPEKNOWN 10
113
114 /* OSPFv3 MIB Host Table values: ospfv3HostTable */
115 #define OSPFv3HOSTMETRIC 3
116 #define OSPFv3HOSTROWSTATUS 4
117 #define OSPFv3HOSTAREAID 5
118
119 /* OSPFv3 MIB Interface Table values: ospfv3IfTable */
120 #define OSPFv3IFAREAID 3
121 #define OSPFv3IFTYPE 4
122 #define OSPFv3IFADMINSTATUS 5
123 #define OSPFv3IFRTRPRIORITY 6
124 #define OSPFv3IFTRANSITDELAY 7
125 #define OSPFv3IFRETRANSINTERVAL 8
126 #define OSPFv3IFHELLOINTERVAL 9
127 #define OSPFv3IFRTRDEADINTERVAL 10
128 #define OSPFv3IFPOLLINTERVAL 11
129 #define OSPFv3IFSTATE 12
130 #define OSPFv3IFDESIGNATEDROUTER 13
131 #define OSPFv3IFBACKUPDESIGNATEDROUTER 14
132 #define OSPFv3IFEVENTS 15
133 #define OSPFv3IFROWSTATUS 16
134 #define OSPFv3IFDEMAND 17
135 #define OSPFv3IFMETRICVALUE 18
136 #define OSPFv3IFLINKSCOPELSACOUNT 19
137 #define OSPFv3IFLINKLSACKSUMSUM 20
138 #define OSPFv3IFDEMANDNBRPROBE 21
139 #define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22
140 #define OSPFv3IFDEMANDNBRPROBEINTERVAL 23
141 #define OSPFv3IFTEDISABLED 24
142 #define OSPFv3IFLINKLSASUPPRESSION 25
143
144 /* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */
145 #define OSPFv3VIRTIFINDEX 3
146 #define OSPFv3VIRTIFINSTID 4
147 #define OSPFv3VIRTIFTRANSITDELAY 5
148 #define OSPFv3VIRTIFRETRANSINTERVAL 6
149 #define OSPFv3VIRTIFHELLOINTERVAL 7
150 #define OSPFv3VIRTIFRTRDEADINTERVAL 8
151 #define OSPFv3VIRTIFSTATE 9
152 #define OSPFv3VIRTIFEVENTS 10
153 #define OSPFv3VIRTIFROWSTATUS 11
154 #define OSPFv3VIRTIFLINKSCOPELSACOUNT 12
155 #define OSPFv3VIRTIFLINKLSACKSUMSUM 13
156
157 /* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */
158 #define OSPFv3NBRADDRESSTYPE 4
159 #define OSPFv3NBRADDRESS 5
160 #define OSPFv3NBROPTIONS 6
161 #define OSPFv3NBRPRIORITY 7
162 #define OSPFv3NBRSTATE 8
163 #define OSPFv3NBREVENTS 9
164 #define OSPFv3NBRLSRETRANSQLEN 10
165 #define OSPFv3NBRHELLOSUPPRESSED 11
166 #define OSPFv3NBRIFID 12
167 #define OSPFv3NBRRESTARTHELPERSTATUS 13
168 #define OSPFv3NBRRESTARTHELPERAGE 14
169 #define OSPFv3NBRRESTARTHELPEREXITREASON 15
170
171 /* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */
172 #define OSPFv3CFGNBRPRIORITY 5
173 #define OSPFv3CFGNBRROWSTATUS 6
174
175 /* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */
176 #define OSPFv3VIRTNBRIFINDEX 3
177 #define OSPFv3VIRTNBRIFINSTID 4
178 #define OSPFv3VIRTNBRADDRESSTYPE 5
179 #define OSPFv3VIRTNBRADDRESS 6
180 #define OSPFv3VIRTNBROPTIONS 7
181 #define OSPFv3VIRTNBRSTATE 8
182 #define OSPFv3VIRTNBREVENTS 9
183 #define OSPFv3VIRTNBRLSRETRANSQLEN 10
184 #define OSPFv3VIRTNBRHELLOSUPPRESSED 11
185 #define OSPFv3VIRTNBRIFID 12
186 #define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13
187 #define OSPFv3VIRTNBRRESTARTHELPERAGE 14
188 #define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15
189
190 /* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */
191 #define OSPFv3AREAAGGREGATEROWSTATUS 6
192 #define OSPFv3AREAAGGREGATEEFFECT 7
193 #define OSPFv3AREAAGGREGATEROUTETAG 8
194
195 /* OSPFv3 MIB Virtual Link Lsdb Table values: ospfv3VirtLinkLsdbTable */
196 #define OSPFv3VIRTLINKLSDBSEQUENCE 6
197 #define OSPFv3VIRTLINKLSDBAGE 7
198 #define OSPFv3VIRTLINKLSDBCHECKSUM 8
199 #define OSPFv3VIRTLINKLSDBADVERTISEMENT 9
200 #define OSPFv3VIRTLINKLSDBTYPEKNOWN 10
201
202 /* SYNTAX Status from OSPF-MIB. */
203 #define OSPF_STATUS_ENABLED 1
204 #define OSPF_STATUS_DISABLED 2
205
206 /* SNMP value hack. */
207 #define COUNTER ASN_COUNTER
208 #define INTEGER ASN_INTEGER
209 #define GAUGE ASN_GAUGE
210 #define UNSIGNED ASN_UNSIGNED
211 #define TIMETICKS ASN_TIMETICKS
212 #define IPADDRESS ASN_IPADDRESS
213 #define STRING ASN_OCTET_STR
214
215 /* For return values e.g. SNMP_INTEGER macro */
216 SNMP_LOCAL_VARIABLES
217
218 /* OSPFv3-MIB instances. */
219 oid ospfv3_oid [] = { OSPFv3MIB };
220
221 /* Hook functions. */
222 static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
223 int, size_t *, WriteMethod **);
224 static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
225 int, size_t *, WriteMethod **);
226 static u_char *ospfv3AreaLsdbEntry (struct variable *, oid *, size_t *,
227 int, size_t *, WriteMethod **);
228 static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *,
229 int, size_t *, WriteMethod **);
230 static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *,
231 int, size_t *, WriteMethod **);
232
233 struct variable ospfv3_variables[] =
234 {
235 /* OSPF general variables */
236 {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup,
237 3, {1, 1, 1}},
238 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
239 3, {1, 1, 2}},
240 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
241 3, {1, 1, 3}},
242 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
243 3, {1, 1, 4}},
244 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
245 3, {1, 1, 5}},
246 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
247 3, {1, 1, 6}},
248 {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup,
249 3, {1, 1, 7}},
250 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
251 3, {1, 1, 8}},
252 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
253 3, {1, 1, 9}},
254 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
255 3, {1, 1, 10}},
256 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
257 3, {1, 1, 11}},
258 {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
259 3, {1, 1, 12}},
260 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
261 3, {1, 1, 13}},
262 {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup,
263 3, {1, 1, 14}},
264 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
265 3, {1, 1, 15}},
266 {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup,
267 3, {1, 1, 16}},
268 {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup,
269 3, {1, 1, 17}},
270 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
271 3, {1, 1, 18}},
272 {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup,
273 3, {1, 1, 19}},
274 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
275 3, {1, 1, 20}},
276 {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup,
277 3, {1, 1, 21}},
278 {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup,
279 3, {1, 1, 22}},
280 {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup,
281 3, {1, 1, 23}},
282 {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
283 3, {1, 1, 24}},
284 {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup,
285 3, {1, 1, 25}},
286
287 /* OSPFv3 Area Data Structure */
288 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
289 4, {1, 2, 1, 2}},
290 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
291 4, {1, 2, 1, 3}},
292 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
293 4, {1, 2, 1, 4}},
294 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
295 4, {1, 2, 1, 5}},
296 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
297 4, {1, 2, 1, 6}},
298 {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry,
299 4, {1, 2, 1, 7}},
300 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
301 4, {1, 2, 1, 8}},
302 {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
303 4, {1, 2, 1, 9}},
304 {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
305 4, {1, 2, 1, 10}},
306 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
307 4, {1, 2, 1, 11}},
308 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
309 4, {1, 2, 1, 12}},
310 {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry,
311 4, {1, 2, 1, 13}},
312 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
313 4, {1, 2, 1, 14}},
314 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
315 4, {1, 2, 1, 15}},
316 {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry,
317 4, {1, 2, 1, 16}},
318
319 /* OSPFv3 Area LSDB */
320 {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
321 4, {1, 4, 1, 5}},
322 {OSPFv3AREALSDBAGE, UNSIGNED, RONLY, ospfv3AreaLsdbEntry,
323 4, {1, 4, 1, 6}},
324 {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
325 4, {1, 4, 1, 7}},
326 {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
327 4, {1, 4, 1, 8}},
328 {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
329 4, {1, 4, 1, 9}},
330
331 /* OSPFv3 interfaces */
332 {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry,
333 4, {1, 7, 1, 3}},
334 {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry,
335 4, {1, 7, 1, 4}},
336 {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry,
337 4, {1, 7, 1, 5}},
338 {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry,
339 4, {1, 7, 1, 6}},
340 {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry,
341 4, {1, 7, 1, 7}},
342 {OSPFv3IFRETRANSINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
343 4, {1, 7, 1, 8}},
344 {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry,
345 4, {1, 7, 1, 9}},
346 {OSPFv3IFRTRDEADINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
347 4, {1, 7, 1, 10}},
348 {OSPFv3IFPOLLINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
349 4, {1, 7, 1, 11}},
350 {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry,
351 4, {1, 7, 1, 12}},
352 {OSPFv3IFDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
353 4, {1, 7, 1, 13}},
354 {OSPFv3IFBACKUPDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry,
355 4, {1, 7, 1, 14}},
356 {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry,
357 4, {1, 7, 1, 15}},
358 {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry,
359 4, {1, 7, 1, 16}},
360 {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry,
361 4, {1, 7, 1, 17}},
362 {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry,
363 4, {1, 7, 1, 18}},
364 {OSPFv3IFLINKSCOPELSACOUNT, GAUGE, RONLY, ospfv3IfEntry,
365 4, {1, 7, 1, 19}},
366 {OSPFv3IFLINKLSACKSUMSUM, UNSIGNED, RONLY, ospfv3IfEntry,
367 4, {1, 7, 1, 20}},
368 {OSPFv3IFDEMANDNBRPROBE, INTEGER, RONLY, ospfv3IfEntry,
369 4, {1, 7, 1, 21}},
370 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT, UNSIGNED, RONLY, ospfv3IfEntry,
371 4, {1, 7, 1, 22}},
372 {OSPFv3IFDEMANDNBRPROBEINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry,
373 4, {1, 7, 1, 23}},
374 {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry,
375 4, {1, 7, 1, 24}},
376 {OSPFv3IFLINKLSASUPPRESSION, INTEGER, RONLY, ospfv3IfEntry,
377 4, {1, 7, 1, 25}},
378
379 /* OSPFv3 neighbors */
380 {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry,
381 4, {1, 9, 1, 4}},
382 {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry,
383 4, {1, 9, 1, 5}},
384 {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry,
385 4, {1, 9, 1, 6}},
386 {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry,
387 4, {1, 9, 1, 7}},
388 {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry,
389 4, {1, 9, 1, 8}},
390 {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry,
391 4, {1, 9, 1, 9}},
392 {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry,
393 4, {1, 9, 1, 10}},
394 {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry,
395 4, {1, 9, 1, 11}},
396 {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry,
397 4, {1, 9, 1, 12}},
398 {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry,
399 4, {1, 9, 1, 13}},
400 {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry,
401 4, {1, 9, 1, 14}},
402 {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry,
403 4, {1, 9, 1, 15}},
404 };
405
406 static u_char *
407 ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
408 int exact, size_t *var_len, WriteMethod **write_method)
409 {
410 u_int16_t sum;
411 u_int32_t count;
412 struct ospf6_lsa *lsa = NULL;
413
414 /* Check whether the instance identifier is valid */
415 if (smux_header_generic (v, name, length, exact, var_len, write_method)
416 == MATCH_FAILED)
417 return NULL;
418
419 /* Return the current value of the variable */
420 switch (v->magic)
421 {
422 case OSPFv3ROUTERID:
423 /* Router-ID of this OSPF instance. */
424 if (ospf6)
425 return SNMP_INTEGER (ntohl (ospf6->router_id));
426 return SNMP_INTEGER (0);
427 case OSPFv3ADMINSTAT:
428 if (ospf6)
429 return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)?
430 OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED);
431 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
432 case OSPFv3VERSIONNUMBER:
433 return SNMP_INTEGER (3);
434 case OSPFv3AREABDRRTRSTATUS:
435 if (ospf6)
436 return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE);
437 return SNMP_INTEGER (SNMP_FALSE);
438 case OSPFv3ASBDRRTRSTATUS:
439 if (ospf6)
440 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE);
441 return SNMP_INTEGER (SNMP_FALSE);
442 case OSPFv3ASSCOPELSACOUNT:
443 if (ospf6)
444 return SNMP_INTEGER (ospf6->lsdb->count);
445 return SNMP_INTEGER (0);
446 case OSPFv3ASSCOPELSACHECKSUMSUM:
447 if (ospf6)
448 {
449 for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb);
450 lsa;
451 lsa = ospf6_lsdb_next (lsa))
452 sum += ntohs (lsa->header->checksum);
453 return SNMP_INTEGER (sum);
454 }
455 return SNMP_INTEGER (0);
456 case OSPFv3ORIGINATENEWLSAS:
457 return SNMP_INTEGER (0); /* Don't know where to get this value... */
458 case OSPFv3RXNEWLSAS:
459 return SNMP_INTEGER (0); /* Don't know where to get this value... */
460 case OSPFv3EXTLSACOUNT:
461 if (ospf6)
462 {
463 for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL),
464 ospf6->lsdb);
465 lsa;
466 lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL),
467 lsa))
468 count += 1;
469 return SNMP_INTEGER (count);
470 }
471 return SNMP_INTEGER (0);
472 case OSPFv3EXTAREALSDBLIMIT:
473 return SNMP_INTEGER (-1);
474 case OSPFv3EXITOVERFLOWINTERVAL:
475 return SNMP_INTEGER (0); /* Not supported */
476 case OSPFv3DEMANDEXTENSIONS:
477 return SNMP_INTEGER (0); /* Not supported */
478 case OSPFv3REFERENCEBANDWIDTH:
479 return SNMP_INTEGER (100000);
480 case OSPFv3RESTARTSUPPORT:
481 case OSPFv3RESTARTINTERVAL:
482 case OSPFv3RESTARTSTRICTLSACHECKING:
483 case OSPFv3RESTARTSTATUS:
484 case OSPFv3RESTARTAGE:
485 case OSPFv3RESTARTEXITREASON:
486 case OSPFv3NOTIFICATIONENABLE:
487 case OSPFv3STUBROUTERSUPPORT:
488 case OSPFv3STUBROUTERADVERTISEMENT:
489 case OSPFv3DISCONTINUITYTIME:
490 case OSPFv3RESTARTTIME:
491 /* TODO: Not implemented */
492 return NULL;
493 }
494 return NULL;
495 }
496
497 static u_char *
498 ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
499 int exact, size_t *var_len, WriteMethod **write_method)
500 {
501 struct ospf6_area *oa, *area = NULL;
502 struct ospf6_lsa *lsa = NULL;
503 u_int32_t area_id = 0;
504 u_int32_t count;
505 u_int16_t sum;
506 struct listnode *node;
507 unsigned int len;
508 char a[16];
509 struct ospf6_route *ro;
510
511 if (ospf6 == NULL)
512 return NULL;
513
514 if (smux_header_table(v, name, length, exact, var_len, write_method)
515 == MATCH_FAILED)
516 return NULL;
517
518 len = *length - v->namelen;
519 len = (len >= 1 ? sizeof 1 : 0);
520 if (exact && len != 1)
521 return NULL;
522 if (len)
523 area_id = htonl (name[v->namelen]);
524
525 inet_ntop (AF_INET, &area_id, a, sizeof (a));
526 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
527 a, exact, len, (u_long)*length);
528
529 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
530 {
531 if (area == NULL)
532 {
533 if (len == 0) /* return first area entry */
534 area = oa;
535 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
536 area = oa;
537 else if (ntohl (oa->area_id) > ntohl (area_id))
538 area = oa;
539 }
540 }
541
542 if (area == NULL)
543 return NULL;
544
545 *length = v->namelen + 1;
546 name[v->namelen] = ntohl (area->area_id);
547
548 inet_ntop (AF_INET, &area->area_id, a, sizeof (a));
549 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
550 a, exact, len, (u_long)*length);
551
552 switch (v->magic)
553 {
554 case OSPFv3IMPORTASEXTERN:
555 /* No NSSA support */
556 return SNMP_INTEGER (IS_AREA_STUB(area)?2:1);
557 case OSPFv3AREASPFRUNS:
558 return SNMP_INTEGER (area->spf_calculation);
559 case OSPFv3AREABDRRTRCOUNT:
560 case OSPFv3AREAASBDRRTRCOUNT:
561 count = 0;
562 for (ro = ospf6_route_head (ospf6->brouter_table); ro;
563 ro = ospf6_route_next (ro))
564 {
565 if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue;
566 if (v->magic == OSPFv3AREABDRRTRCOUNT &&
567 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B))
568 count++;
569 if (v->magic == OSPFv3AREAASBDRRTRCOUNT &&
570 CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E))
571 count++;
572 }
573 return SNMP_INTEGER (count);
574 case OSPFv3AREASCOPELSACOUNT:
575 return SNMP_INTEGER (area->lsdb->count);
576 case OSPFv3AREASCOPELSACKSUMSUM:
577 for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb);
578 lsa;
579 lsa = ospf6_lsdb_next (lsa))
580 sum += ntohs (lsa->header->checksum);
581 return SNMP_INTEGER (sum);
582 case OSPFv3AREASUMMARY:
583 return SNMP_INTEGER (2); /* sendAreaSummary */
584 case OSPFv3AREAROWSTATUS:
585 return SNMP_INTEGER (1); /* Active */
586 case OSPFv3AREASTUBMETRIC:
587 case OSPFv3AREANSSATRANSLATORROLE:
588 case OSPFv3AREANSSATRANSLATORSTATE:
589 case OSPFv3AREANSSATRANSLATORSTABINTERVAL:
590 case OSPFv3AREANSSATRANSLATOREVENTS:
591 case OSPFv3AREASTUBMETRICTYPE:
592 case OSPFv3AREATEENABLED:
593 /* Not implemented. */
594 return NULL;
595 }
596 return NULL;
597 }
598
599 static u_char *
600 ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
601 int exact, size_t *var_len, WriteMethod **write_method)
602 {
603 struct ospf6_lsa *lsa = NULL;
604 u_int32_t area_id, id, adv_router;
605 u_int16_t type;
606 int len;
607 oid *offset;
608 int offsetlen;
609 char a[16], b[16], c[16];
610 struct ospf6_area *oa;
611 struct listnode *node;
612
613 if (smux_header_table(v, name, length, exact, var_len, write_method)
614 == MATCH_FAILED)
615 return NULL;
616
617 area_id = type = id = adv_router = 0;
618
619 /* Check OSPFv3 instance. */
620 if (ospf6 == NULL)
621 return NULL;
622
623 /* Get variable length. */
624 offset = name + v->namelen;
625 offsetlen = *length - v->namelen;
626
627 #define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
628
629 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
630 return NULL;
631
632 /* Parse area-id */
633 len = (offsetlen < 1 ? 0 : 1);
634 if (len)
635 area_id = htonl (*offset);
636 offset += len;
637 offsetlen -= len;
638
639 /* Parse type */
640 len = (offsetlen < 1 ? 0 : 1);
641 if (len)
642 type = htons (*offset);
643 offset += len;
644 offsetlen -= len;
645
646 /* Parse Router-ID */
647 len = (offsetlen < 1 ? 0 : 1);
648 if (len)
649 adv_router = htonl (*offset);
650 offset += len;
651 offsetlen -= len;
652
653 /* Parse LS-ID */
654 len = (offsetlen < 1 ? 0 : 1);
655 if (len)
656 id = htonl (*offset);
657 offset += len;
658 offsetlen -= len;
659
660 inet_ntop (AF_INET, &area_id, a, sizeof (a));
661 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
662 inet_ntop (AF_INET, &id, c, sizeof (c));
663 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
664 " type=%#x adv_router=%s id=%s",
665 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
666
667 if (exact)
668 {
669 oa = ospf6_area_lookup (area_id, ospf6);
670 lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb);
671 }
672 else
673 {
674 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
675 {
676 if (lsa)
677 continue;
678 if (oa->area_id < area_id)
679 continue;
680
681 lsa = ospf6_lsdb_lookup_next (type, id, adv_router,
682 oa->lsdb);
683 if (! lsa)
684 {
685 type = 0;
686 id = 0;
687 adv_router = 0;
688 }
689 }
690 }
691
692 if (! lsa)
693 {
694 zlog_debug ("SNMP respond: No LSA to return");
695 return NULL;
696 }
697 oa = OSPF6_AREA (lsa->lsdb->data);
698
699 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
700
701 /* Add Index (AreaId, Type, RouterId, Lsid) */
702 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
703 offset = name + v->namelen;
704 *offset = ntohl (oa->area_id);
705 offset++;
706 *offset = ntohs (lsa->header->type);
707 offset++;
708 *offset = ntohl (lsa->header->adv_router);
709 offset++;
710 *offset = ntohl (lsa->header->id);
711 offset++;
712
713 /* Return the current value of the variable */
714 switch (v->magic)
715 {
716 case OSPFv3AREALSDBSEQUENCE:
717 return SNMP_INTEGER (ntohl (lsa->header->seqnum));
718 break;
719 case OSPFv3AREALSDBAGE:
720 ospf6_lsa_age_current (lsa);
721 return SNMP_INTEGER (ntohs (lsa->header->age));
722 break;
723 case OSPFv3AREALSDBCHECKSUM:
724 return SNMP_INTEGER (ntohs (lsa->header->checksum));
725 break;
726 case OSPFv3AREALSDBADVERTISEMENT:
727 *var_len = ntohs (lsa->header->length);
728 return (u_char *) lsa->header;
729 break;
730 case OSPFv3AREALSDBTYPEKNOWN:
731 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
732 SNMP_TRUE : SNMP_FALSE);
733 break;
734 }
735 return NULL;
736 }
737
738 static int
739 if_icmp_func (struct interface *ifp1, struct interface *ifp2)
740 {
741 return (ifp1->ifindex - ifp2->ifindex);
742 }
743
744 static u_char *
745 ospfv3IfEntry (struct variable *v, oid *name, size_t *length,
746 int exact, size_t *var_len, WriteMethod **write_method)
747 {
748 unsigned int ifindex, instid;
749 struct ospf6_interface *oi = NULL;
750 struct ospf6_lsa *lsa = NULL;
751 struct interface *iif;
752 struct listnode *i;
753 struct list *ifslist;
754 oid *offset;
755 int offsetlen, len;
756 u_int32_t sum;
757
758 if (smux_header_table (v, name, length, exact, var_len, write_method)
759 == MATCH_FAILED)
760 return NULL;
761
762 ifindex = instid = 0;
763
764 /* Check OSPFv3 instance. */
765 if (ospf6 == NULL)
766 return NULL;
767
768 /* Get variable length. */
769 offset = name + v->namelen;
770 offsetlen = *length - v->namelen;
771
772 if (exact && offsetlen != 2)
773 return NULL;
774
775 /* Parse if index */
776 len = (offsetlen < 1 ? 0 : 1);
777 if (len)
778 ifindex = *offset;
779 offset += len;
780 offsetlen -= len;
781
782 /* Parse instance ID */
783 len = (offsetlen < 1 ? 0 : 1);
784 if (len)
785 instid = *offset;
786 offset += len;
787 offsetlen -= len;
788
789 if (exact)
790 {
791 oi = ospf6_interface_lookup_by_ifindex (ifindex);
792 if (oi->instance_id != instid) return NULL;
793 }
794 else
795 {
796 /* We build a sorted list of interfaces */
797 ifslist = list_new ();
798 if (!ifslist) return NULL;
799 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
800 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
801 listnode_add_sort (ifslist, iif);
802
803 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
804 {
805 if (!iif->ifindex) continue;
806 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
807 if (!oi) continue;
808 if (iif->ifindex > ifindex ||
809 (iif->ifindex == ifindex &&
810 (oi->instance_id > instid)))
811 break;
812 oi = NULL;
813 }
814
815 list_delete_all_node (ifslist);
816 }
817
818 if (!oi) return NULL;
819
820 /* Add Index (IfIndex, IfInstId) */
821 *length = v->namelen + 2;
822 offset = name + v->namelen;
823 *offset = oi->interface->ifindex;
824 offset++;
825 *offset = oi->instance_id;
826 offset++;
827
828 /* Return the current value of the variable */
829 switch (v->magic)
830 {
831 case OSPFv3IFAREAID:
832 if (oi->area)
833 return SNMP_INTEGER (ntohl (oi->area->area_id));
834 break;
835 case OSPFv3IFTYPE:
836 if (if_is_broadcast (oi->interface))
837 return SNMP_INTEGER (1);
838 else if (if_is_pointopoint (oi->interface))
839 return SNMP_INTEGER (3);
840 else break; /* Unknown, don't put anything */
841 case OSPFv3IFADMINSTATUS:
842 if (oi->area)
843 return SNMP_INTEGER (OSPF_STATUS_ENABLED);
844 return SNMP_INTEGER (OSPF_STATUS_DISABLED);
845 case OSPFv3IFRTRPRIORITY:
846 return SNMP_INTEGER (oi->priority);
847 case OSPFv3IFTRANSITDELAY:
848 return SNMP_INTEGER (oi->transdelay);
849 case OSPFv3IFRETRANSINTERVAL:
850 return SNMP_INTEGER (oi->rxmt_interval);
851 case OSPFv3IFHELLOINTERVAL:
852 return SNMP_INTEGER (oi->hello_interval);
853 case OSPFv3IFRTRDEADINTERVAL:
854 return SNMP_INTEGER (oi->dead_interval);
855 case OSPFv3IFPOLLINTERVAL:
856 /* No support for NBMA */
857 break;
858 case OSPFv3IFSTATE:
859 return SNMP_INTEGER (oi->state);
860 case OSPFv3IFDESIGNATEDROUTER:
861 return SNMP_INTEGER (ntohl (oi->drouter));
862 case OSPFv3IFBACKUPDESIGNATEDROUTER:
863 return SNMP_INTEGER (ntohl (oi->bdrouter));
864 case OSPFv3IFEVENTS:
865 return SNMP_INTEGER (oi->state_change);
866 case OSPFv3IFROWSTATUS:
867 return SNMP_INTEGER (1);
868 case OSPFv3IFDEMAND:
869 return SNMP_INTEGER (SNMP_FALSE);
870 case OSPFv3IFMETRICVALUE:
871 return SNMP_INTEGER (oi->cost);
872 case OSPFv3IFLINKSCOPELSACOUNT:
873 return SNMP_INTEGER (oi->lsdb->count);
874 case OSPFv3IFLINKLSACKSUMSUM:
875 for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb);
876 lsa;
877 lsa = ospf6_lsdb_next (lsa))
878 sum += ntohs (lsa->header->checksum);
879 return SNMP_INTEGER (sum);
880 case OSPFv3IFDEMANDNBRPROBE:
881 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT:
882 case OSPFv3IFDEMANDNBRPROBEINTERVAL:
883 case OSPFv3IFTEDISABLED:
884 case OSPFv3IFLINKLSASUPPRESSION:
885 /* Not implemented. Only works if all the last ones are not
886 implemented! */
887 return NULL;
888 }
889
890 /* Try an internal getnext. Some columns are missing in this table. */
891 if (!exact && (name[*length-1] < MAX_SUBID))
892 return ospfv3IfEntry(v, name, length,
893 exact, var_len, write_method);
894 return NULL;
895 }
896
897 static u_char *
898 ospfv3NbrEntry (struct variable *v, oid *name, size_t *length,
899 int exact, size_t *var_len, WriteMethod **write_method)
900 {
901 unsigned int ifindex, instid, rtrid;
902 struct ospf6_interface *oi = NULL;
903 struct ospf6_neighbor *on = NULL;
904 struct interface *iif;
905 struct listnode *i, *j;
906 struct list *ifslist;
907 oid *offset;
908 int offsetlen, len;
909
910 if (smux_header_table (v, name, length, exact, var_len, write_method)
911 == MATCH_FAILED)
912 return NULL;
913
914 ifindex = instid = rtrid = 0;
915
916 /* Check OSPFv3 instance. */
917 if (ospf6 == NULL)
918 return NULL;
919
920 /* Get variable length. */
921 offset = name + v->namelen;
922 offsetlen = *length - v->namelen;
923
924 if (exact && offsetlen != 3)
925 return NULL;
926
927 /* Parse if index */
928 len = (offsetlen < 1 ? 0 : 1);
929 if (len)
930 ifindex = *offset;
931 offset += len;
932 offsetlen -= len;
933
934 /* Parse instance ID */
935 len = (offsetlen < 1 ? 0 : 1);
936 if (len)
937 instid = *offset;
938 offset += len;
939 offsetlen -= len;
940
941 /* Parse router ID */
942 len = (offsetlen < 1 ? 0 : 1);
943 if (len)
944 rtrid = htonl (*offset);
945 offset += len;
946 offsetlen -= len;
947
948 if (exact)
949 {
950 oi = ospf6_interface_lookup_by_ifindex (ifindex);
951 on = ospf6_neighbor_lookup (rtrid, oi);
952 if (oi->instance_id != instid) return NULL;
953 }
954 else
955 {
956 /* We build a sorted list of interfaces */
957 ifslist = list_new ();
958 if (!ifslist) return NULL;
959 ifslist->cmp = (int (*)(void *, void *))if_icmp_func;
960 for (ALL_LIST_ELEMENTS_RO (iflist, i, iif))
961 listnode_add_sort (ifslist, iif);
962
963 for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif))
964 {
965 if (!iif->ifindex) continue;
966 oi = ospf6_interface_lookup_by_ifindex (iif->ifindex);
967 if (!oi) continue;
968 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) {
969 if (iif->ifindex > ifindex ||
970 (iif->ifindex == ifindex &&
971 (oi->instance_id > instid ||
972 (oi->instance_id == instid &&
973 ntohl (on->router_id) > ntohl (rtrid)))))
974 break;
975 }
976 if (on) break;
977 oi = on = NULL;
978 }
979
980 list_delete_all_node (ifslist);
981 }
982
983 if (!oi || !on) return NULL;
984
985 /* Add Index (IfIndex, IfInstId, RtrId) */
986 *length = v->namelen + 3;
987 offset = name + v->namelen;
988 *offset = oi->interface->ifindex;
989 offset++;
990 *offset = oi->instance_id;
991 offset++;
992 *offset = ntohl (on->router_id);
993 offset++;
994
995 /* Return the current value of the variable */
996 switch (v->magic)
997 {
998 case OSPFv3NBRADDRESSTYPE:
999 return SNMP_INTEGER (2); /* IPv6 only */
1000 case OSPFv3NBRADDRESS:
1001 *var_len = sizeof (struct in6_addr);
1002 return (u_char *) &on->linklocal_addr;
1003 case OSPFv3NBROPTIONS:
1004 return SNMP_INTEGER (on->options[2]);
1005 case OSPFv3NBRPRIORITY:
1006 return SNMP_INTEGER (on->priority);
1007 case OSPFv3NBRSTATE:
1008 return SNMP_INTEGER (on->state);
1009 case OSPFv3NBREVENTS:
1010 return SNMP_INTEGER (on->state_change);
1011 case OSPFv3NBRLSRETRANSQLEN:
1012 return SNMP_INTEGER (on->retrans_list->count);
1013 case OSPFv3NBRHELLOSUPPRESSED:
1014 return SNMP_INTEGER (SNMP_FALSE);
1015 case OSPFv3NBRIFID:
1016 return SNMP_INTEGER (on->ifindex);
1017 case OSPFv3NBRRESTARTHELPERSTATUS:
1018 case OSPFv3NBRRESTARTHELPERAGE:
1019 case OSPFv3NBRRESTARTHELPEREXITREASON:
1020 /* Not implemented. Only works if all the last ones are not
1021 implemented! */
1022 return NULL;
1023 }
1024
1025 return NULL;
1026 }
1027
1028 /* Register OSPFv3-MIB. */
1029 void
1030 ospf6_snmp_init (struct thread_master *master)
1031 {
1032 smux_init (master);
1033 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
1034 }
1035
1036 #endif /* HAVE_SNMP */
1037