]>
Commit | Line | Data |
---|---|---|
ef1bbf5c | 1 | /* OSPFv3 SNMP support |
2 | * Copyright (C) 2004 Yasuhiro Ohara | |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with GNU Zebra; see the file COPYING. If not, write to the | |
18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | * Boston, MA 02111-1307, USA. | |
20 | */ | |
21 | ||
22 | #include <zebra.h> | |
23 | ||
24 | #ifdef HAVE_SNMP | |
25 | ||
ef1bbf5c | 26 | #include <net-snmp/net-snmp-config.h> |
fb62a3ce | 27 | #include <net-snmp/net-snmp-includes.h> |
ef1bbf5c | 28 | |
29 | #include "log.h" | |
30 | #include "vty.h" | |
31 | #include "linklist.h" | |
d11f748b DL |
32 | #include "vector.h" |
33 | #include "vrf.h" | |
ef1bbf5c | 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" | |
1cc5e682 DL |
45 | #include "ospf6_abr.h" |
46 | #include "ospf6_asbr.h" | |
ef1bbf5c | 47 | #include "ospf6d.h" |
0be8dfb2 | 48 | #include "ospf6_snmp.h" |
ef1bbf5c | 49 | |
50 | /* OSPFv3-MIB */ | |
0f0ab518 | 51 | #define OSPFv3MIB 1,3,6,1,2,1,191 |
ef1bbf5c | 52 | |
ef1bbf5c | 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 | |
0f0ab518 VB |
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 */ | |
ef1bbf5c | 81 | #define OSPFv3IMPORTASEXTERN 2 |
2680aa2b | 82 | #define OSPFv3AREASPFRUNS 3 |
83 | #define OSPFv3AREABDRRTRCOUNT 4 | |
84 | #define OSPFv3AREAASBDRRTRCOUNT 5 | |
85 | #define OSPFv3AREASCOPELSACOUNT 6 | |
86 | #define OSPFv3AREASCOPELSACKSUMSUM 7 | |
87 | #define OSPFv3AREASUMMARY 8 | |
0f0ab518 VB |
88 | #define OSPFv3AREAROWSTATUS 9 |
89 | #define OSPFv3AREASTUBMETRIC 10 | |
2680aa2b | 90 | #define OSPFv3AREANSSATRANSLATORROLE 11 |
91 | #define OSPFv3AREANSSATRANSLATORSTATE 12 | |
0f0ab518 | 92 | #define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13 |
2680aa2b | 93 | #define OSPFv3AREANSSATRANSLATOREVENTS 14 |
94 | #define OSPFv3AREASTUBMETRICTYPE 15 | |
0f0ab518 | 95 | #define OSPFv3AREATEENABLED 16 |
2680aa2b | 96 | |
c349bb86 VB |
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) | |
0f0ab518 VB |
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 | ||
ef1bbf5c | 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 | |
0f0ab518 | 201 | #define UNSIGNED ASN_UNSIGNED |
ef1bbf5c | 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 | ||
ef1bbf5c | 209 | /* OSPFv3-MIB instances. */ |
1c6f50bf DL |
210 | static oid ospfv3_oid [] = { OSPFv3MIB }; |
211 | static oid ospfv3_trap_oid [] = { OSPFv3MIB, 0 }; | |
ef1bbf5c | 212 | |
ef1bbf5c | 213 | /* Hook functions. */ |
0be8dfb2 CC |
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 **); | |
c349bb86 VB |
218 | static u_char *ospfv3WwLsdbEntry (struct variable *, oid *, size_t *, |
219 | int, size_t *, WriteMethod **); | |
061bc735 VB |
220 | static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *, |
221 | int, size_t *, WriteMethod **); | |
3bc4f84e VB |
222 | static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *, |
223 | int, size_t *, WriteMethod **); | |
ef1bbf5c | 224 | |
1c6f50bf | 225 | static struct variable ospfv3_variables[] = |
ef1bbf5c | 226 | { |
227 | /* OSPF general variables */ | |
0f0ab518 | 228 | {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
ef1bbf5c | 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}}, | |
0f0ab518 | 240 | {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup, |
ef1bbf5c | 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}}, | |
0f0ab518 | 250 | {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
ef1bbf5c | 251 | 3, {1, 1, 12}}, |
ef1bbf5c | 252 | {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup, |
0f0ab518 VB |
253 | 3, {1, 1, 13}}, |
254 | {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup, | |
ef1bbf5c | 255 | 3, {1, 1, 14}}, |
0f0ab518 | 256 | {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup, |
ef1bbf5c | 257 | 3, {1, 1, 15}}, |
0f0ab518 | 258 | {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
ef1bbf5c | 259 | 3, {1, 1, 16}}, |
0f0ab518 | 260 | {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup, |
ef1bbf5c | 261 | 3, {1, 1, 17}}, |
ef1bbf5c | 262 | {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup, |
0f0ab518 VB |
263 | 3, {1, 1, 18}}, |
264 | {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup, | |
ef1bbf5c | 265 | 3, {1, 1, 19}}, |
ef1bbf5c | 266 | {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup, |
0f0ab518 VB |
267 | 3, {1, 1, 20}}, |
268 | {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup, | |
ef1bbf5c | 269 | 3, {1, 1, 21}}, |
0f0ab518 VB |
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}}, | |
ef1bbf5c | 278 | |
279 | /* OSPFv3 Area Data Structure */ | |
2680aa2b | 280 | {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry, |
ef1bbf5c | 281 | 4, {1, 2, 1, 2}}, |
2680aa2b | 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}}, | |
0f0ab518 | 290 | {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry, |
2680aa2b | 291 | 4, {1, 2, 1, 7}}, |
292 | {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry, | |
293 | 4, {1, 2, 1, 8}}, | |
0f0ab518 | 294 | {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry, |
2680aa2b | 295 | 4, {1, 2, 1, 9}}, |
0f0ab518 | 296 | {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry, |
2680aa2b | 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}}, | |
0f0ab518 | 302 | {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry, |
2680aa2b | 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}}, | |
0f0ab518 VB |
308 | {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry, |
309 | 4, {1, 2, 1, 16}}, | |
2680aa2b | 310 | |
c349bb86 VB |
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 | ||
0f0ab518 | 323 | /* OSPFv3 Area LSDB */ |
c349bb86 | 324 | {OSPFv3WWLSDBSEQUENCE | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
2680aa2b | 325 | 4, {1, 4, 1, 5}}, |
c349bb86 | 326 | {OSPFv3WWLSDBAGE | OSPFv3WWAREATABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry, |
2680aa2b | 327 | 4, {1, 4, 1, 6}}, |
c349bb86 | 328 | {OSPFv3WWLSDBCHECKSUM | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
2680aa2b | 329 | 4, {1, 4, 1, 7}}, |
c349bb86 | 330 | {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWAREATABLE, STRING, RONLY, ospfv3WwLsdbEntry, |
2680aa2b | 331 | 4, {1, 4, 1, 8}}, |
c349bb86 | 332 | {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
2680aa2b | 333 | 4, {1, 4, 1, 9}}, |
334 | ||
c349bb86 VB |
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 | ||
3bc4f84e VB |
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 | ||
061bc735 VB |
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}}, | |
ef1bbf5c | 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 | { | |
2c5f1480 VB |
426 | u_int16_t sum; |
427 | u_int32_t count; | |
428 | struct ospf6_lsa *lsa = NULL; | |
429 | ||
ef1bbf5c | 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 | { | |
0f0ab518 | 438 | case OSPFv3ROUTERID: |
ef1bbf5c | 439 | /* Router-ID of this OSPF instance. */ |
440 | if (ospf6) | |
0f0ab518 VB |
441 | return SNMP_INTEGER (ntohl (ospf6->router_id)); |
442 | return SNMP_INTEGER (0); | |
443 | case OSPFv3ADMINSTAT: | |
2c5f1480 VB |
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); | |
0f0ab518 | 448 | case OSPFv3VERSIONNUMBER: |
2c5f1480 | 449 | return SNMP_INTEGER (3); |
0f0ab518 | 450 | case OSPFv3AREABDRRTRSTATUS: |
2c5f1480 VB |
451 | if (ospf6) |
452 | return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE); | |
453 | return SNMP_INTEGER (SNMP_FALSE); | |
0f0ab518 | 454 | case OSPFv3ASBDRRTRSTATUS: |
2c5f1480 VB |
455 | if (ospf6) |
456 | return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE); | |
457 | return SNMP_INTEGER (SNMP_FALSE); | |
0f0ab518 | 458 | case OSPFv3ASSCOPELSACOUNT: |
2c5f1480 VB |
459 | if (ospf6) |
460 | return SNMP_INTEGER (ospf6->lsdb->count); | |
461 | return SNMP_INTEGER (0); | |
0f0ab518 | 462 | case OSPFv3ASSCOPELSACHECKSUMSUM: |
2c5f1480 VB |
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); | |
0f0ab518 | 472 | case OSPFv3ORIGINATENEWLSAS: |
2c5f1480 | 473 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
0f0ab518 | 474 | case OSPFv3RXNEWLSAS: |
2c5f1480 | 475 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
0f0ab518 | 476 | case OSPFv3EXTLSACOUNT: |
2c5f1480 VB |
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); | |
0f0ab518 | 488 | case OSPFv3EXTAREALSDBLIMIT: |
2c5f1480 | 489 | return SNMP_INTEGER (-1); |
0f0ab518 | 490 | case OSPFv3EXITOVERFLOWINTERVAL: |
2c5f1480 | 491 | return SNMP_INTEGER (0); /* Not supported */ |
0f0ab518 | 492 | case OSPFv3DEMANDEXTENSIONS: |
2c5f1480 | 493 | return SNMP_INTEGER (0); /* Not supported */ |
0f0ab518 | 494 | case OSPFv3REFERENCEBANDWIDTH: |
fd500689 VB |
495 | if (ospf6) |
496 | return SNMP_INTEGER (ospf6->ref_bandwidth); | |
497 | /* Otherwise, like for "not implemented". */ | |
0f0ab518 VB |
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 */ | |
ef1bbf5c | 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; | |
ea86e404 | 520 | struct ospf6_lsa *lsa = NULL; |
ef1bbf5c | 521 | u_int32_t area_id = 0; |
ea86e404 VB |
522 | u_int32_t count; |
523 | u_int16_t sum; | |
0c083ee9 | 524 | struct listnode *node; |
525 | unsigned int len; | |
0f0ab518 | 526 | char a[16]; |
ea86e404 | 527 | struct ospf6_route *ro; |
ef1bbf5c | 528 | |
529 | if (ospf6 == NULL) | |
530 | return NULL; | |
531 | ||
8046ba6e VB |
532 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
533 | == MATCH_FAILED) | |
534 | return NULL; | |
535 | ||
ef1bbf5c | 536 | len = *length - v->namelen; |
a11e012e | 537 | len = (len >= 1 ? 1 : 0); |
0f0ab518 | 538 | if (exact && len != 1) |
ef1bbf5c | 539 | return NULL; |
540 | if (len) | |
0f0ab518 | 541 | area_id = htonl (name[v->namelen]); |
ef1bbf5c | 542 | |
0f0ab518 | 543 | inet_ntop (AF_INET, &area_id, a, sizeof (a)); |
eda9ba74 | 544 | zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu", |
0f0ab518 | 545 | a, exact, len, (u_long)*length); |
ef1bbf5c | 546 | |
1eb8ef25 | 547 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
ef1bbf5c | 548 | { |
ef1bbf5c | 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 | ||
0f0ab518 VB |
563 | *length = v->namelen + 1; |
564 | name[v->namelen] = ntohl (area->area_id); | |
ef1bbf5c | 565 | |
0f0ab518 | 566 | inet_ntop (AF_INET, &area->area_id, a, sizeof (a)); |
eda9ba74 | 567 | zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu", |
0f0ab518 | 568 | a, exact, len, (u_long)*length); |
ef1bbf5c | 569 | |
570 | switch (v->magic) | |
571 | { | |
0f0ab518 | 572 | case OSPFv3IMPORTASEXTERN: |
ea86e404 VB |
573 | /* No NSSA support */ |
574 | return SNMP_INTEGER (IS_AREA_STUB(area)?2:1); | |
0f0ab518 | 575 | case OSPFv3AREASPFRUNS: |
ea86e404 | 576 | return SNMP_INTEGER (area->spf_calculation); |
0f0ab518 VB |
577 | case OSPFv3AREABDRRTRCOUNT: |
578 | case OSPFv3AREAASBDRRTRCOUNT: | |
ea86e404 VB |
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); | |
0f0ab518 | 592 | case OSPFv3AREASCOPELSACOUNT: |
ea86e404 | 593 | return SNMP_INTEGER (area->lsdb->count); |
0f0ab518 | 594 | case OSPFv3AREASCOPELSACKSUMSUM: |
ea86e404 VB |
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); | |
0f0ab518 | 600 | case OSPFv3AREASUMMARY: |
ea86e404 | 601 | return SNMP_INTEGER (2); /* sendAreaSummary */ |
0f0ab518 | 602 | case OSPFv3AREAROWSTATUS: |
ea86e404 | 603 | return SNMP_INTEGER (1); /* Active */ |
0f0ab518 VB |
604 | case OSPFv3AREASTUBMETRIC: |
605 | case OSPFv3AREANSSATRANSLATORROLE: | |
606 | case OSPFv3AREANSSATRANSLATORSTATE: | |
607 | case OSPFv3AREANSSATRANSLATORSTABINTERVAL: | |
608 | case OSPFv3AREANSSATRANSLATOREVENTS: | |
609 | case OSPFv3AREASTUBMETRICTYPE: | |
610 | case OSPFv3AREATEENABLED: | |
611 | /* Not implemented. */ | |
ef1bbf5c | 612 | return NULL; |
ef1bbf5c | 613 | } |
614 | return NULL; | |
615 | } | |
616 | ||
c349bb86 VB |
617 | static int |
618 | if_icmp_func (struct interface *ifp1, struct interface *ifp2) | |
619 | { | |
620 | return (ifp1->ifindex - ifp2->ifindex); | |
621 | } | |
622 | ||
2680aa2b | 623 | static u_char * |
c349bb86 | 624 | ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length, |
2680aa2b | 625 | int exact, size_t *var_len, WriteMethod **write_method) |
626 | { | |
627 | struct ospf6_lsa *lsa = NULL; | |
b892f1dd | 628 | ifindex_t ifindex, area_id, id, instid, adv_router; |
2680aa2b | 629 | u_int16_t type; |
2680aa2b | 630 | int len; |
631 | oid *offset; | |
632 | int offsetlen; | |
d8adbe09 | 633 | struct ospf6_area *oa = NULL; |
b3c8c465 | 634 | struct listnode *node; |
c349bb86 VB |
635 | struct interface *iif; |
636 | struct ospf6_interface *oi = NULL; | |
637 | struct list *ifslist; | |
2680aa2b | 638 | |
8046ba6e VB |
639 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
640 | == MATCH_FAILED) | |
641 | return NULL; | |
642 | ||
c349bb86 | 643 | instid = ifindex = area_id = type = id = adv_router = 0; |
2680aa2b | 644 | |
645 | /* Check OSPFv3 instance. */ | |
646 | if (ospf6 == NULL) | |
647 | return NULL; | |
648 | ||
649 | /* Get variable length. */ | |
650 | offset = name + v->namelen; | |
651 | offsetlen = *length - v->namelen; | |
652 | ||
c349bb86 VB |
653 | if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3) |
654 | return NULL; | |
655 | if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4) | |
656 | return NULL; | |
657 | if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5) | |
2680aa2b | 658 | return NULL; |
659 | ||
c349bb86 VB |
660 | if (v->magic & OSPFv3WWLINKTABLE) |
661 | { | |
662 | /* Parse ifindex */ | |
663 | len = (offsetlen < 1 ? 0 : 1); | |
664 | if (len) | |
665 | ifindex = *offset; | |
666 | offset += len; | |
667 | offsetlen -= len; | |
668 | ||
669 | /* Parse instance ID */ | |
670 | len = (offsetlen < 1 ? 0 : 1); | |
671 | if (len) | |
672 | instid = *offset; | |
673 | offset += len; | |
674 | offsetlen -= len; | |
675 | } | |
676 | else if (v->magic & OSPFv3WWAREATABLE) | |
677 | { | |
678 | /* Parse area-id */ | |
679 | len = (offsetlen < 1 ? 0 : 1); | |
680 | if (len) | |
681 | area_id = htonl (*offset); | |
682 | offset += len; | |
683 | offsetlen -= len; | |
684 | } | |
2680aa2b | 685 | |
686 | /* Parse type */ | |
0f0ab518 | 687 | len = (offsetlen < 1 ? 0 : 1); |
2680aa2b | 688 | if (len) |
689 | type = htons (*offset); | |
690 | offset += len; | |
691 | offsetlen -= len; | |
692 | ||
693 | /* Parse Router-ID */ | |
0f0ab518 | 694 | len = (offsetlen < 1 ? 0 : 1); |
2680aa2b | 695 | if (len) |
0f0ab518 | 696 | adv_router = htonl (*offset); |
2680aa2b | 697 | offset += len; |
698 | offsetlen -= len; | |
699 | ||
700 | /* Parse LS-ID */ | |
0f0ab518 | 701 | len = (offsetlen < 1 ? 0 : 1); |
2680aa2b | 702 | if (len) |
0f0ab518 | 703 | id = htonl (*offset); |
2680aa2b | 704 | offset += len; |
705 | offsetlen -= len; | |
706 | ||
2680aa2b | 707 | if (exact) |
708 | { | |
c349bb86 VB |
709 | if (v->magic & OSPFv3WWASTABLE) |
710 | { | |
711 | lsa = ospf6_lsdb_lookup (type, id, adv_router, ospf6->lsdb); | |
712 | } | |
713 | else if (v->magic & OSPFv3WWAREATABLE) | |
714 | { | |
715 | oa = ospf6_area_lookup (area_id, ospf6); | |
0402ca4e | 716 | if (!oa) return NULL; |
c349bb86 VB |
717 | lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb); |
718 | } | |
719 | else if (v->magic & OSPFv3WWLINKTABLE) | |
720 | { | |
721 | oi = ospf6_interface_lookup_by_ifindex (ifindex); | |
0402ca4e | 722 | if (!oi || oi->instance_id != instid) return NULL; |
c349bb86 VB |
723 | lsa = ospf6_lsdb_lookup (type, id, adv_router, oi->lsdb); |
724 | } | |
2680aa2b | 725 | } |
726 | else | |
727 | { | |
c349bb86 VB |
728 | if (v->magic & OSPFv3WWASTABLE) |
729 | { | |
730 | if (ospf6->lsdb->count) | |
731 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, | |
732 | ospf6->lsdb); | |
733 | } | |
734 | else if (v->magic & OSPFv3WWAREATABLE) | |
735 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) | |
736 | { | |
737 | if (oa->area_id < area_id) | |
738 | continue; | |
739 | ||
740 | if (oa->lsdb->count) | |
741 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, | |
742 | oa->lsdb); | |
743 | if (lsa) break; | |
744 | type = 0; | |
745 | id = 0; | |
746 | adv_router = 0; | |
747 | } | |
748 | else if (v->magic & OSPFv3WWLINKTABLE) | |
2680aa2b | 749 | { |
c349bb86 VB |
750 | /* We build a sorted list of interfaces */ |
751 | ifslist = list_new (); | |
752 | if (!ifslist) return NULL; | |
753 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; | |
d11f748b | 754 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, iif)) |
c349bb86 VB |
755 | listnode_add_sort (ifslist, iif); |
756 | ||
757 | for (ALL_LIST_ELEMENTS_RO (ifslist, node, iif)) | |
2680aa2b | 758 | { |
c349bb86 VB |
759 | if (!iif->ifindex) continue; |
760 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); | |
761 | if (!oi) continue; | |
762 | if (iif->ifindex < ifindex) continue; | |
763 | if (oi->instance_id < instid) continue; | |
764 | ||
765 | if (oi->lsdb->count) | |
766 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, | |
767 | oi->lsdb); | |
768 | if (lsa) break; | |
2680aa2b | 769 | type = 0; |
c349bb86 VB |
770 | id = 0; |
771 | adv_router = 0; | |
772 | oi = NULL; | |
2680aa2b | 773 | } |
c349bb86 VB |
774 | |
775 | list_delete_all_node (ifslist); | |
2680aa2b | 776 | } |
777 | } | |
778 | ||
779 | if (! lsa) | |
2680aa2b | 780 | return NULL; |
2680aa2b | 781 | |
c349bb86 VB |
782 | /* Add indexes */ |
783 | if (v->magic & OSPFv3WWASTABLE) | |
784 | { | |
785 | *length = v->namelen + 3; | |
786 | offset = name + v->namelen; | |
787 | } | |
788 | else if (v->magic & OSPFv3WWAREATABLE) | |
789 | { | |
790 | *length = v->namelen + 4; | |
791 | offset = name + v->namelen; | |
792 | *offset = ntohl (oa->area_id); | |
793 | offset++; | |
794 | } | |
795 | else if (v->magic & OSPFv3WWLINKTABLE) | |
796 | { | |
797 | *length = v->namelen + 5; | |
798 | offset = name + v->namelen; | |
799 | *offset = oi->interface->ifindex; | |
800 | offset++; | |
801 | *offset = oi->instance_id; | |
802 | offset++; | |
803 | } | |
2680aa2b | 804 | *offset = ntohs (lsa->header->type); |
805 | offset++; | |
0f0ab518 VB |
806 | *offset = ntohl (lsa->header->adv_router); |
807 | offset++; | |
808 | *offset = ntohl (lsa->header->id); | |
809 | offset++; | |
2680aa2b | 810 | |
811 | /* Return the current value of the variable */ | |
c349bb86 | 812 | switch (v->magic & OSPFv3WWCOLUMN) |
2680aa2b | 813 | { |
c349bb86 | 814 | case OSPFv3WWLSDBSEQUENCE: |
0f0ab518 | 815 | return SNMP_INTEGER (ntohl (lsa->header->seqnum)); |
2680aa2b | 816 | break; |
c349bb86 | 817 | case OSPFv3WWLSDBAGE: |
2680aa2b | 818 | ospf6_lsa_age_current (lsa); |
0f0ab518 | 819 | return SNMP_INTEGER (ntohs (lsa->header->age)); |
2680aa2b | 820 | break; |
c349bb86 | 821 | case OSPFv3WWLSDBCHECKSUM: |
0f0ab518 | 822 | return SNMP_INTEGER (ntohs (lsa->header->checksum)); |
2680aa2b | 823 | break; |
c349bb86 | 824 | case OSPFv3WWLSDBADVERTISEMENT: |
2680aa2b | 825 | *var_len = ntohs (lsa->header->length); |
826 | return (u_char *) lsa->header; | |
827 | break; | |
c349bb86 | 828 | case OSPFv3WWLSDBTYPEKNOWN: |
2680aa2b | 829 | return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ? |
830 | SNMP_TRUE : SNMP_FALSE); | |
831 | break; | |
2680aa2b | 832 | } |
833 | return NULL; | |
834 | } | |
835 | ||
3bc4f84e VB |
836 | static u_char * |
837 | ospfv3IfEntry (struct variable *v, oid *name, size_t *length, | |
838 | int exact, size_t *var_len, WriteMethod **write_method) | |
839 | { | |
b892f1dd PJ |
840 | ifindex_t ifindex = 0; |
841 | unsigned int instid = 0; | |
3bc4f84e VB |
842 | struct ospf6_interface *oi = NULL; |
843 | struct ospf6_lsa *lsa = NULL; | |
844 | struct interface *iif; | |
845 | struct listnode *i; | |
846 | struct list *ifslist; | |
847 | oid *offset; | |
848 | int offsetlen, len; | |
849 | u_int32_t sum; | |
850 | ||
851 | if (smux_header_table (v, name, length, exact, var_len, write_method) | |
852 | == MATCH_FAILED) | |
853 | return NULL; | |
854 | ||
3bc4f84e VB |
855 | /* Check OSPFv3 instance. */ |
856 | if (ospf6 == NULL) | |
857 | return NULL; | |
858 | ||
859 | /* Get variable length. */ | |
860 | offset = name + v->namelen; | |
861 | offsetlen = *length - v->namelen; | |
862 | ||
863 | if (exact && offsetlen != 2) | |
864 | return NULL; | |
865 | ||
866 | /* Parse if index */ | |
867 | len = (offsetlen < 1 ? 0 : 1); | |
868 | if (len) | |
869 | ifindex = *offset; | |
870 | offset += len; | |
871 | offsetlen -= len; | |
872 | ||
873 | /* Parse instance ID */ | |
874 | len = (offsetlen < 1 ? 0 : 1); | |
875 | if (len) | |
876 | instid = *offset; | |
877 | offset += len; | |
878 | offsetlen -= len; | |
879 | ||
880 | if (exact) | |
881 | { | |
882 | oi = ospf6_interface_lookup_by_ifindex (ifindex); | |
0402ca4e | 883 | if (!oi || oi->instance_id != instid) return NULL; |
3bc4f84e VB |
884 | } |
885 | else | |
886 | { | |
887 | /* We build a sorted list of interfaces */ | |
888 | ifslist = list_new (); | |
889 | if (!ifslist) return NULL; | |
890 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; | |
d11f748b | 891 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), i, iif)) |
3bc4f84e VB |
892 | listnode_add_sort (ifslist, iif); |
893 | ||
894 | for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif)) | |
895 | { | |
896 | if (!iif->ifindex) continue; | |
897 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); | |
898 | if (!oi) continue; | |
899 | if (iif->ifindex > ifindex || | |
900 | (iif->ifindex == ifindex && | |
901 | (oi->instance_id > instid))) | |
902 | break; | |
903 | oi = NULL; | |
904 | } | |
905 | ||
906 | list_delete_all_node (ifslist); | |
907 | } | |
908 | ||
909 | if (!oi) return NULL; | |
910 | ||
911 | /* Add Index (IfIndex, IfInstId) */ | |
912 | *length = v->namelen + 2; | |
913 | offset = name + v->namelen; | |
914 | *offset = oi->interface->ifindex; | |
915 | offset++; | |
916 | *offset = oi->instance_id; | |
917 | offset++; | |
918 | ||
919 | /* Return the current value of the variable */ | |
920 | switch (v->magic) | |
921 | { | |
922 | case OSPFv3IFAREAID: | |
923 | if (oi->area) | |
924 | return SNMP_INTEGER (ntohl (oi->area->area_id)); | |
925 | break; | |
926 | case OSPFv3IFTYPE: | |
927 | if (if_is_broadcast (oi->interface)) | |
928 | return SNMP_INTEGER (1); | |
929 | else if (if_is_pointopoint (oi->interface)) | |
930 | return SNMP_INTEGER (3); | |
931 | else break; /* Unknown, don't put anything */ | |
932 | case OSPFv3IFADMINSTATUS: | |
933 | if (oi->area) | |
934 | return SNMP_INTEGER (OSPF_STATUS_ENABLED); | |
935 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); | |
936 | case OSPFv3IFRTRPRIORITY: | |
937 | return SNMP_INTEGER (oi->priority); | |
938 | case OSPFv3IFTRANSITDELAY: | |
939 | return SNMP_INTEGER (oi->transdelay); | |
940 | case OSPFv3IFRETRANSINTERVAL: | |
941 | return SNMP_INTEGER (oi->rxmt_interval); | |
942 | case OSPFv3IFHELLOINTERVAL: | |
943 | return SNMP_INTEGER (oi->hello_interval); | |
944 | case OSPFv3IFRTRDEADINTERVAL: | |
945 | return SNMP_INTEGER (oi->dead_interval); | |
946 | case OSPFv3IFPOLLINTERVAL: | |
947 | /* No support for NBMA */ | |
948 | break; | |
949 | case OSPFv3IFSTATE: | |
950 | return SNMP_INTEGER (oi->state); | |
951 | case OSPFv3IFDESIGNATEDROUTER: | |
952 | return SNMP_INTEGER (ntohl (oi->drouter)); | |
953 | case OSPFv3IFBACKUPDESIGNATEDROUTER: | |
954 | return SNMP_INTEGER (ntohl (oi->bdrouter)); | |
955 | case OSPFv3IFEVENTS: | |
956 | return SNMP_INTEGER (oi->state_change); | |
957 | case OSPFv3IFROWSTATUS: | |
958 | return SNMP_INTEGER (1); | |
959 | case OSPFv3IFDEMAND: | |
960 | return SNMP_INTEGER (SNMP_FALSE); | |
961 | case OSPFv3IFMETRICVALUE: | |
962 | return SNMP_INTEGER (oi->cost); | |
963 | case OSPFv3IFLINKSCOPELSACOUNT: | |
964 | return SNMP_INTEGER (oi->lsdb->count); | |
965 | case OSPFv3IFLINKLSACKSUMSUM: | |
966 | for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb); | |
967 | lsa; | |
968 | lsa = ospf6_lsdb_next (lsa)) | |
969 | sum += ntohs (lsa->header->checksum); | |
970 | return SNMP_INTEGER (sum); | |
971 | case OSPFv3IFDEMANDNBRPROBE: | |
972 | case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT: | |
973 | case OSPFv3IFDEMANDNBRPROBEINTERVAL: | |
974 | case OSPFv3IFTEDISABLED: | |
975 | case OSPFv3IFLINKLSASUPPRESSION: | |
976 | /* Not implemented. Only works if all the last ones are not | |
977 | implemented! */ | |
978 | return NULL; | |
979 | } | |
980 | ||
981 | /* Try an internal getnext. Some columns are missing in this table. */ | |
982 | if (!exact && (name[*length-1] < MAX_SUBID)) | |
983 | return ospfv3IfEntry(v, name, length, | |
984 | exact, var_len, write_method); | |
985 | return NULL; | |
986 | } | |
987 | ||
061bc735 VB |
988 | static u_char * |
989 | ospfv3NbrEntry (struct variable *v, oid *name, size_t *length, | |
990 | int exact, size_t *var_len, WriteMethod **write_method) | |
991 | { | |
b892f1dd PJ |
992 | ifindex_t ifindex = 0; |
993 | unsigned int instid, rtrid; | |
061bc735 VB |
994 | struct ospf6_interface *oi = NULL; |
995 | struct ospf6_neighbor *on = NULL; | |
996 | struct interface *iif; | |
997 | struct listnode *i, *j; | |
998 | struct list *ifslist; | |
999 | oid *offset; | |
1000 | int offsetlen, len; | |
1001 | ||
1002 | if (smux_header_table (v, name, length, exact, var_len, write_method) | |
1003 | == MATCH_FAILED) | |
1004 | return NULL; | |
1005 | ||
b892f1dd | 1006 | instid = rtrid = 0; |
061bc735 VB |
1007 | |
1008 | /* Check OSPFv3 instance. */ | |
1009 | if (ospf6 == NULL) | |
1010 | return NULL; | |
1011 | ||
1012 | /* Get variable length. */ | |
1013 | offset = name + v->namelen; | |
1014 | offsetlen = *length - v->namelen; | |
1015 | ||
1016 | if (exact && offsetlen != 3) | |
1017 | return NULL; | |
1018 | ||
1019 | /* Parse if index */ | |
1020 | len = (offsetlen < 1 ? 0 : 1); | |
1021 | if (len) | |
1022 | ifindex = *offset; | |
1023 | offset += len; | |
1024 | offsetlen -= len; | |
1025 | ||
1026 | /* Parse instance ID */ | |
1027 | len = (offsetlen < 1 ? 0 : 1); | |
1028 | if (len) | |
1029 | instid = *offset; | |
1030 | offset += len; | |
1031 | offsetlen -= len; | |
1032 | ||
1033 | /* Parse router ID */ | |
1034 | len = (offsetlen < 1 ? 0 : 1); | |
1035 | if (len) | |
1036 | rtrid = htonl (*offset); | |
1037 | offset += len; | |
1038 | offsetlen -= len; | |
1039 | ||
1040 | if (exact) | |
1041 | { | |
1042 | oi = ospf6_interface_lookup_by_ifindex (ifindex); | |
0402ca4e | 1043 | if (!oi || oi->instance_id != instid) return NULL; |
061bc735 | 1044 | on = ospf6_neighbor_lookup (rtrid, oi); |
061bc735 VB |
1045 | } |
1046 | else | |
1047 | { | |
1048 | /* We build a sorted list of interfaces */ | |
1049 | ifslist = list_new (); | |
1050 | if (!ifslist) return NULL; | |
1051 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; | |
d11f748b | 1052 | for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), i, iif)) |
061bc735 VB |
1053 | listnode_add_sort (ifslist, iif); |
1054 | ||
1055 | for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif)) | |
1056 | { | |
1057 | if (!iif->ifindex) continue; | |
1058 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); | |
1059 | if (!oi) continue; | |
1060 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) { | |
1061 | if (iif->ifindex > ifindex || | |
1062 | (iif->ifindex == ifindex && | |
1063 | (oi->instance_id > instid || | |
1064 | (oi->instance_id == instid && | |
1065 | ntohl (on->router_id) > ntohl (rtrid))))) | |
1066 | break; | |
1067 | } | |
1068 | if (on) break; | |
0402ca4e VB |
1069 | oi = NULL; |
1070 | on = NULL; | |
061bc735 VB |
1071 | } |
1072 | ||
1073 | list_delete_all_node (ifslist); | |
1074 | } | |
1075 | ||
1076 | if (!oi || !on) return NULL; | |
1077 | ||
1078 | /* Add Index (IfIndex, IfInstId, RtrId) */ | |
1079 | *length = v->namelen + 3; | |
1080 | offset = name + v->namelen; | |
1081 | *offset = oi->interface->ifindex; | |
1082 | offset++; | |
1083 | *offset = oi->instance_id; | |
1084 | offset++; | |
1085 | *offset = ntohl (on->router_id); | |
1086 | offset++; | |
1087 | ||
1088 | /* Return the current value of the variable */ | |
1089 | switch (v->magic) | |
1090 | { | |
1091 | case OSPFv3NBRADDRESSTYPE: | |
1092 | return SNMP_INTEGER (2); /* IPv6 only */ | |
1093 | case OSPFv3NBRADDRESS: | |
1094 | *var_len = sizeof (struct in6_addr); | |
1095 | return (u_char *) &on->linklocal_addr; | |
1096 | case OSPFv3NBROPTIONS: | |
1097 | return SNMP_INTEGER (on->options[2]); | |
1098 | case OSPFv3NBRPRIORITY: | |
1099 | return SNMP_INTEGER (on->priority); | |
1100 | case OSPFv3NBRSTATE: | |
1101 | return SNMP_INTEGER (on->state); | |
1102 | case OSPFv3NBREVENTS: | |
1103 | return SNMP_INTEGER (on->state_change); | |
1104 | case OSPFv3NBRLSRETRANSQLEN: | |
1105 | return SNMP_INTEGER (on->retrans_list->count); | |
1106 | case OSPFv3NBRHELLOSUPPRESSED: | |
1107 | return SNMP_INTEGER (SNMP_FALSE); | |
1108 | case OSPFv3NBRIFID: | |
1109 | return SNMP_INTEGER (on->ifindex); | |
1110 | case OSPFv3NBRRESTARTHELPERSTATUS: | |
1111 | case OSPFv3NBRRESTARTHELPERAGE: | |
1112 | case OSPFv3NBRRESTARTHELPEREXITREASON: | |
1113 | /* Not implemented. Only works if all the last ones are not | |
1114 | implemented! */ | |
1115 | return NULL; | |
1116 | } | |
1117 | ||
1118 | return NULL; | |
1119 | } | |
1120 | ||
bf836661 VB |
1121 | /* OSPF Traps. */ |
1122 | #define NBRSTATECHANGE 2 | |
1123 | #define IFSTATECHANGE 10 | |
1124 | ||
1125 | static struct trap_object ospf6NbrTrapList[] = | |
1126 | { | |
1127 | {-3, {1, 1, OSPFv3ROUTERID}}, | |
1128 | {4, {1, 9, 1, OSPFv3NBRADDRESSTYPE}}, | |
1129 | {4, {1, 9, 1, OSPFv3NBRADDRESS}}, | |
1130 | {4, {1, 9, 1, OSPFv3NBRSTATE}} | |
1131 | }; | |
1132 | ||
1133 | static struct trap_object ospf6IfTrapList[] = | |
1134 | { | |
1135 | {-3, {1, 1, OSPFv3ROUTERID}}, | |
1136 | {4, {1, 7, 1, OSPFv3IFSTATE}}, | |
1137 | {4, {1, 7, 1, OSPFv3IFADMINSTATUS}}, | |
1138 | {4, {1, 7, 1, OSPFv3IFAREAID}} | |
1139 | }; | |
1140 | ||
1141 | void | |
1142 | ospf6TrapNbrStateChange (struct ospf6_neighbor *on) | |
1143 | { | |
1144 | oid index[3]; | |
1145 | ||
1146 | index[0] = on->ospf6_if->interface->ifindex; | |
1147 | index[1] = on->ospf6_if->instance_id; | |
1148 | index[2] = ntohl (on->router_id); | |
1149 | ||
1150 | smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable), | |
1151 | ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid), | |
1152 | ospfv3_oid, sizeof ospfv3_oid / sizeof (oid), | |
1153 | index, 3, | |
1154 | ospf6NbrTrapList, | |
1155 | sizeof ospf6NbrTrapList / sizeof (struct trap_object), | |
1156 | NBRSTATECHANGE); | |
1157 | } | |
1158 | ||
1159 | void | |
1160 | ospf6TrapIfStateChange (struct ospf6_interface *oi) | |
1161 | { | |
1162 | oid index[2]; | |
1163 | ||
1164 | index[0] = oi->interface->ifindex; | |
1165 | index[1] = oi->instance_id; | |
1166 | ||
1167 | smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable), | |
1168 | ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid), | |
1169 | ospfv3_oid, sizeof ospfv3_oid / sizeof (oid), | |
1170 | index, 2, | |
1171 | ospf6IfTrapList, | |
1172 | sizeof ospf6IfTrapList / sizeof (struct trap_object), | |
1173 | IFSTATECHANGE); | |
1174 | } | |
1175 | ||
ef1bbf5c | 1176 | /* Register OSPFv3-MIB. */ |
1177 | void | |
0c083ee9 | 1178 | ospf6_snmp_init (struct thread_master *master) |
ef1bbf5c | 1179 | { |
c75105ab | 1180 | smux_init (master); |
ef1bbf5c | 1181 | REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); |
ef1bbf5c | 1182 | } |
1183 | ||
1184 | #endif /* HAVE_SNMP */ | |
1185 |