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