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