]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* OSPFv2 SNMP support |
ba682537 | 2 | * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com> |
718e3744 | 3 | * Copyright (C) 2000 IP Infusion Inc. |
4 | * | |
5 | * Written by Kunihiro Ishiguro <kunihiro@zebra.org> | |
6 | * | |
7 | * This file is part of GNU Zebra. | |
8 | * | |
9 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2, or (at your option) any | |
12 | * later version. | |
13 | * | |
14 | * GNU Zebra is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with GNU Zebra; see the file COPYING. If not, write to the Free | |
21 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
22 | * 02111-1307, USA. | |
23 | */ | |
24 | ||
25 | #include <zebra.h> | |
26 | ||
27 | #ifdef HAVE_SNMP | |
07661cb5 | 28 | #ifdef HAVE_NETSNMP |
29 | #include <net-snmp/net-snmp-config.h> | |
30 | #endif | |
718e3744 | 31 | #include <asn1.h> |
32 | #include <snmp.h> | |
33 | #include <snmp_impl.h> | |
34 | ||
35 | #include "if.h" | |
36 | #include "log.h" | |
37 | #include "prefix.h" | |
38 | #include "table.h" | |
39 | #include "command.h" | |
40 | #include "memory.h" | |
41 | #include "smux.h" | |
42 | ||
43 | #include "ospfd/ospfd.h" | |
44 | #include "ospfd/ospf_interface.h" | |
45 | #include "ospfd/ospf_asbr.h" | |
46 | #include "ospfd/ospf_lsa.h" | |
47 | #include "ospfd/ospf_lsdb.h" | |
48 | #include "ospfd/ospf_abr.h" | |
49 | #include "ospfd/ospf_neighbor.h" | |
50 | #include "ospfd/ospf_nsm.h" | |
51 | #include "ospfd/ospf_flood.h" | |
e6217879 | 52 | #include "ospfd/ospf_ism.h" |
718e3744 | 53 | \f |
54 | /* OSPF2-MIB. */ | |
55 | #define OSPF2MIB 1,3,6,1,2,1,14 | |
56 | ||
718e3744 | 57 | /* OSPF MIB General Group values. */ |
58 | #define OSPFROUTERID 1 | |
59 | #define OSPFADMINSTAT 2 | |
60 | #define OSPFVERSIONNUMBER 3 | |
61 | #define OSPFAREABDRRTRSTATUS 4 | |
62 | #define OSPFASBDRRTRSTATUS 5 | |
63 | #define OSPFEXTERNLSACOUNT 6 | |
64 | #define OSPFEXTERNLSACKSUMSUM 7 | |
65 | #define OSPFTOSSUPPORT 8 | |
66 | #define OSPFORIGINATENEWLSAS 9 | |
67 | #define OSPFRXNEWLSAS 10 | |
68 | #define OSPFEXTLSDBLIMIT 11 | |
69 | #define OSPFMULTICASTEXTENSIONS 12 | |
70 | #define OSPFEXITOVERFLOWINTERVAL 13 | |
71 | #define OSPFDEMANDEXTENSIONS 14 | |
72 | ||
73 | /* OSPF MIB ospfAreaTable. */ | |
74 | #define OSPFAREAID 1 | |
75 | #define OSPFAUTHTYPE 2 | |
76 | #define OSPFIMPORTASEXTERN 3 | |
77 | #define OSPFSPFRUNS 4 | |
78 | #define OSPFAREABDRRTRCOUNT 5 | |
79 | #define OSPFASBDRRTRCOUNT 6 | |
80 | #define OSPFAREALSACOUNT 7 | |
81 | #define OSPFAREALSACKSUMSUM 8 | |
82 | #define OSPFAREASUMMARY 9 | |
83 | #define OSPFAREASTATUS 10 | |
84 | ||
85 | /* OSPF MIB ospfStubAreaTable. */ | |
86 | #define OSPFSTUBAREAID 1 | |
87 | #define OSPFSTUBTOS 2 | |
88 | #define OSPFSTUBMETRIC 3 | |
89 | #define OSPFSTUBSTATUS 4 | |
90 | #define OSPFSTUBMETRICTYPE 5 | |
91 | ||
92 | /* OSPF MIB ospfLsdbTable. */ | |
93 | #define OSPFLSDBAREAID 1 | |
94 | #define OSPFLSDBTYPE 2 | |
95 | #define OSPFLSDBLSID 3 | |
96 | #define OSPFLSDBROUTERID 4 | |
97 | #define OSPFLSDBSEQUENCE 5 | |
98 | #define OSPFLSDBAGE 6 | |
99 | #define OSPFLSDBCHECKSUM 7 | |
100 | #define OSPFLSDBADVERTISEMENT 8 | |
101 | ||
102 | /* OSPF MIB ospfAreaRangeTable. */ | |
103 | #define OSPFAREARANGEAREAID 1 | |
104 | #define OSPFAREARANGENET 2 | |
105 | #define OSPFAREARANGEMASK 3 | |
106 | #define OSPFAREARANGESTATUS 4 | |
107 | #define OSPFAREARANGEEFFECT 5 | |
108 | ||
109 | /* OSPF MIB ospfHostTable. */ | |
110 | #define OSPFHOSTIPADDRESS 1 | |
111 | #define OSPFHOSTTOS 2 | |
112 | #define OSPFHOSTMETRIC 3 | |
113 | #define OSPFHOSTSTATUS 4 | |
114 | #define OSPFHOSTAREAID 5 | |
115 | ||
116 | /* OSPF MIB ospfIfTable. */ | |
117 | #define OSPFIFIPADDRESS 1 | |
118 | #define OSPFADDRESSLESSIF 2 | |
119 | #define OSPFIFAREAID 3 | |
120 | #define OSPFIFTYPE 4 | |
121 | #define OSPFIFADMINSTAT 5 | |
122 | #define OSPFIFRTRPRIORITY 6 | |
123 | #define OSPFIFTRANSITDELAY 7 | |
124 | #define OSPFIFRETRANSINTERVAL 8 | |
125 | #define OSPFIFHELLOINTERVAL 9 | |
126 | #define OSPFIFRTRDEADINTERVAL 10 | |
127 | #define OSPFIFPOLLINTERVAL 11 | |
128 | #define OSPFIFSTATE 12 | |
129 | #define OSPFIFDESIGNATEDROUTER 13 | |
130 | #define OSPFIFBACKUPDESIGNATEDROUTER 14 | |
131 | #define OSPFIFEVENTS 15 | |
132 | #define OSPFIFAUTHKEY 16 | |
133 | #define OSPFIFSTATUS 17 | |
134 | #define OSPFIFMULTICASTFORWARDING 18 | |
135 | #define OSPFIFDEMAND 19 | |
136 | #define OSPFIFAUTHTYPE 20 | |
137 | ||
138 | /* OSPF MIB ospfIfMetricTable. */ | |
139 | #define OSPFIFMETRICIPADDRESS 1 | |
140 | #define OSPFIFMETRICADDRESSLESSIF 2 | |
141 | #define OSPFIFMETRICTOS 3 | |
142 | #define OSPFIFMETRICVALUE 4 | |
143 | #define OSPFIFMETRICSTATUS 5 | |
144 | ||
145 | /* OSPF MIB ospfVirtIfTable. */ | |
146 | #define OSPFVIRTIFAREAID 1 | |
147 | #define OSPFVIRTIFNEIGHBOR 2 | |
148 | #define OSPFVIRTIFTRANSITDELAY 3 | |
149 | #define OSPFVIRTIFRETRANSINTERVAL 4 | |
150 | #define OSPFVIRTIFHELLOINTERVAL 5 | |
151 | #define OSPFVIRTIFRTRDEADINTERVAL 6 | |
152 | #define OSPFVIRTIFSTATE 7 | |
153 | #define OSPFVIRTIFEVENTS 8 | |
154 | #define OSPFVIRTIFAUTHKEY 9 | |
155 | #define OSPFVIRTIFSTATUS 10 | |
156 | #define OSPFVIRTIFAUTHTYPE 11 | |
157 | ||
158 | /* OSPF MIB ospfNbrTable. */ | |
159 | #define OSPFNBRIPADDR 1 | |
160 | #define OSPFNBRADDRESSLESSINDEX 2 | |
161 | #define OSPFNBRRTRID 3 | |
162 | #define OSPFNBROPTIONS 4 | |
163 | #define OSPFNBRPRIORITY 5 | |
164 | #define OSPFNBRSTATE 6 | |
165 | #define OSPFNBREVENTS 7 | |
166 | #define OSPFNBRLSRETRANSQLEN 8 | |
167 | #define OSPFNBMANBRSTATUS 9 | |
168 | #define OSPFNBMANBRPERMANENCE 10 | |
169 | #define OSPFNBRHELLOSUPPRESSED 11 | |
170 | ||
171 | /* OSPF MIB ospfVirtNbrTable. */ | |
172 | #define OSPFVIRTNBRAREA 1 | |
173 | #define OSPFVIRTNBRRTRID 2 | |
174 | #define OSPFVIRTNBRIPADDR 3 | |
175 | #define OSPFVIRTNBROPTIONS 4 | |
176 | #define OSPFVIRTNBRSTATE 5 | |
177 | #define OSPFVIRTNBREVENTS 6 | |
178 | #define OSPFVIRTNBRLSRETRANSQLEN 7 | |
179 | #define OSPFVIRTNBRHELLOSUPPRESSED 8 | |
180 | ||
181 | /* OSPF MIB ospfExtLsdbTable. */ | |
182 | #define OSPFEXTLSDBTYPE 1 | |
183 | #define OSPFEXTLSDBLSID 2 | |
184 | #define OSPFEXTLSDBROUTERID 3 | |
185 | #define OSPFEXTLSDBSEQUENCE 4 | |
186 | #define OSPFEXTLSDBAGE 5 | |
187 | #define OSPFEXTLSDBCHECKSUM 6 | |
188 | #define OSPFEXTLSDBADVERTISEMENT 7 | |
189 | ||
190 | /* OSPF MIB ospfAreaAggregateTable. */ | |
191 | #define OSPFAREAAGGREGATEAREAID 1 | |
192 | #define OSPFAREAAGGREGATELSDBTYPE 2 | |
193 | #define OSPFAREAAGGREGATENET 3 | |
194 | #define OSPFAREAAGGREGATEMASK 4 | |
195 | #define OSPFAREAAGGREGATESTATUS 5 | |
196 | #define OSPFAREAAGGREGATEEFFECT 6 | |
197 | ||
198 | /* SYNTAX Status from OSPF-MIB. */ | |
199 | #define OSPF_STATUS_ENABLED 1 | |
200 | #define OSPF_STATUS_DISABLED 2 | |
201 | ||
202 | /* SNMP value hack. */ | |
203 | #define COUNTER ASN_COUNTER | |
204 | #define INTEGER ASN_INTEGER | |
205 | #define GAUGE ASN_GAUGE | |
206 | #define TIMETICKS ASN_TIMETICKS | |
207 | #define IPADDRESS ASN_IPADDRESS | |
208 | #define STRING ASN_OCTET_STR | |
209 | \f | |
210 | /* Declare static local variables for convenience. */ | |
211 | SNMP_LOCAL_VARIABLES | |
212 | ||
213 | /* OSPF-MIB instances. */ | |
214 | oid ospf_oid [] = { OSPF2MIB }; | |
718e3744 | 215 | |
216 | /* IP address 0.0.0.0. */ | |
217 | static struct in_addr ospf_empty_addr = {0}; | |
218 | ||
219 | /* Hook functions. */ | |
220 | static u_char *ospfGeneralGroup (); | |
221 | static u_char *ospfAreaEntry (); | |
222 | static u_char *ospfStubAreaEntry (); | |
223 | static u_char *ospfLsdbEntry (); | |
224 | static u_char *ospfAreaRangeEntry (); | |
225 | static u_char *ospfHostEntry (); | |
226 | static u_char *ospfIfEntry (); | |
227 | static u_char *ospfIfMetricEntry (); | |
228 | static u_char *ospfVirtIfEntry (); | |
229 | static u_char *ospfNbrEntry (); | |
230 | static u_char *ospfVirtNbrEntry (); | |
231 | static u_char *ospfExtLsdbEntry (); | |
232 | static u_char *ospfAreaAggregateEntry (); | |
233 | ||
234 | struct variable ospf_variables[] = | |
235 | { | |
236 | /* OSPF general variables */ | |
237 | {OSPFROUTERID, IPADDRESS, RWRITE, ospfGeneralGroup, | |
238 | 2, {1, 1}}, | |
239 | {OSPFADMINSTAT, INTEGER, RWRITE, ospfGeneralGroup, | |
240 | 2, {1, 2}}, | |
241 | {OSPFVERSIONNUMBER, INTEGER, RONLY, ospfGeneralGroup, | |
242 | 2, {1, 3}}, | |
243 | {OSPFAREABDRRTRSTATUS, INTEGER, RONLY, ospfGeneralGroup, | |
244 | 2, {1, 4}}, | |
245 | {OSPFASBDRRTRSTATUS, INTEGER, RWRITE, ospfGeneralGroup, | |
246 | 2, {1, 5}}, | |
247 | {OSPFEXTERNLSACOUNT, GAUGE, RONLY, ospfGeneralGroup, | |
248 | 2, {1, 6}}, | |
249 | {OSPFEXTERNLSACKSUMSUM, INTEGER, RONLY, ospfGeneralGroup, | |
250 | 2, {1, 7}}, | |
251 | {OSPFTOSSUPPORT, INTEGER, RWRITE, ospfGeneralGroup, | |
252 | 2, {1, 8}}, | |
253 | {OSPFORIGINATENEWLSAS, COUNTER, RONLY, ospfGeneralGroup, | |
254 | 2, {1, 9}}, | |
255 | {OSPFRXNEWLSAS, COUNTER, RONLY, ospfGeneralGroup, | |
256 | 2, {1, 10}}, | |
257 | {OSPFEXTLSDBLIMIT, INTEGER, RWRITE, ospfGeneralGroup, | |
258 | 2, {1, 11}}, | |
259 | {OSPFMULTICASTEXTENSIONS, INTEGER, RWRITE, ospfGeneralGroup, | |
260 | 2, {1, 12}}, | |
261 | {OSPFEXITOVERFLOWINTERVAL, INTEGER, RWRITE, ospfGeneralGroup, | |
262 | 2, {1, 13}}, | |
263 | {OSPFDEMANDEXTENSIONS, INTEGER, RWRITE, ospfGeneralGroup, | |
264 | 2, {1, 14}}, | |
265 | ||
266 | /* OSPF area data structure. */ | |
267 | {OSPFAREAID, IPADDRESS, RONLY, ospfAreaEntry, | |
268 | 3, {2, 1, 1}}, | |
269 | {OSPFAUTHTYPE, INTEGER, RWRITE, ospfAreaEntry, | |
270 | 3, {2, 1, 2}}, | |
271 | {OSPFIMPORTASEXTERN, INTEGER, RWRITE, ospfAreaEntry, | |
272 | 3, {2, 1, 3}}, | |
273 | {OSPFSPFRUNS, COUNTER, RONLY, ospfAreaEntry, | |
274 | 3, {2, 1, 4}}, | |
275 | {OSPFAREABDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry, | |
276 | 3, {2, 1, 5}}, | |
277 | {OSPFASBDRRTRCOUNT, GAUGE, RONLY, ospfAreaEntry, | |
278 | 3, {2, 1, 6}}, | |
279 | {OSPFAREALSACOUNT, GAUGE, RONLY, ospfAreaEntry, | |
280 | 3, {2, 1, 7}}, | |
281 | {OSPFAREALSACKSUMSUM, INTEGER, RONLY, ospfAreaEntry, | |
282 | 3, {2, 1, 8}}, | |
283 | {OSPFAREASUMMARY, INTEGER, RWRITE, ospfAreaEntry, | |
284 | 3, {2, 1, 9}}, | |
285 | {OSPFAREASTATUS, INTEGER, RWRITE, ospfAreaEntry, | |
286 | 3, {2, 1, 10}}, | |
287 | ||
288 | /* OSPF stub area information. */ | |
289 | {OSPFSTUBAREAID, IPADDRESS, RONLY, ospfStubAreaEntry, | |
290 | 3, {3, 1, 1}}, | |
291 | {OSPFSTUBTOS, INTEGER, RONLY, ospfStubAreaEntry, | |
292 | 3, {3, 1, 2}}, | |
293 | {OSPFSTUBMETRIC, INTEGER, RWRITE, ospfStubAreaEntry, | |
294 | 3, {3, 1, 3}}, | |
295 | {OSPFSTUBSTATUS, INTEGER, RWRITE, ospfStubAreaEntry, | |
296 | 3, {3, 1, 4}}, | |
297 | {OSPFSTUBMETRICTYPE, INTEGER, RWRITE, ospfStubAreaEntry, | |
298 | 3, {3, 1, 5}}, | |
299 | ||
300 | /* OSPF link state database. */ | |
301 | {OSPFLSDBAREAID, IPADDRESS, RONLY, ospfLsdbEntry, | |
302 | 3, {4, 1, 1}}, | |
303 | {OSPFLSDBTYPE, INTEGER, RONLY, ospfLsdbEntry, | |
304 | 3, {4, 1, 2}}, | |
305 | {OSPFLSDBLSID, IPADDRESS, RONLY, ospfLsdbEntry, | |
306 | 3, {4, 1, 3}}, | |
307 | {OSPFLSDBROUTERID, IPADDRESS, RONLY, ospfLsdbEntry, | |
308 | 3, {4, 1, 4}}, | |
309 | {OSPFLSDBSEQUENCE, INTEGER, RONLY, ospfLsdbEntry, | |
310 | 3, {4, 1, 5}}, | |
311 | {OSPFLSDBAGE, INTEGER, RONLY, ospfLsdbEntry, | |
312 | 3, {4, 1, 6}}, | |
313 | {OSPFLSDBCHECKSUM, INTEGER, RONLY, ospfLsdbEntry, | |
314 | 3, {4, 1, 7}}, | |
315 | {OSPFLSDBADVERTISEMENT, STRING, RONLY, ospfLsdbEntry, | |
316 | 3, {4, 1, 8}}, | |
317 | ||
318 | /* Area range table. */ | |
319 | {OSPFAREARANGEAREAID, IPADDRESS, RONLY, ospfAreaRangeEntry, | |
320 | 3, {5, 1, 1}}, | |
321 | {OSPFAREARANGENET, IPADDRESS, RONLY, ospfAreaRangeEntry, | |
322 | 3, {5, 1, 2}}, | |
323 | {OSPFAREARANGEMASK, IPADDRESS, RWRITE, ospfAreaRangeEntry, | |
324 | 3, {5, 1, 3}}, | |
325 | {OSPFAREARANGESTATUS, INTEGER, RWRITE, ospfAreaRangeEntry, | |
326 | 3, {5, 1, 4}}, | |
327 | {OSPFAREARANGEEFFECT, INTEGER, RWRITE, ospfAreaRangeEntry, | |
328 | 3, {5, 1, 5}}, | |
329 | ||
330 | /* OSPF host table. */ | |
331 | {OSPFHOSTIPADDRESS, IPADDRESS, RONLY, ospfHostEntry, | |
332 | 3, {6, 1, 1}}, | |
333 | {OSPFHOSTTOS, INTEGER, RONLY, ospfHostEntry, | |
334 | 3, {6, 1, 2}}, | |
335 | {OSPFHOSTMETRIC, INTEGER, RWRITE, ospfHostEntry, | |
336 | 3, {6, 1, 3}}, | |
337 | {OSPFHOSTSTATUS, INTEGER, RWRITE, ospfHostEntry, | |
338 | 3, {6, 1, 4}}, | |
339 | {OSPFHOSTAREAID, IPADDRESS, RONLY, ospfHostEntry, | |
340 | 3, {6, 1, 5}}, | |
341 | ||
342 | /* OSPF interface table. */ | |
343 | {OSPFIFIPADDRESS, IPADDRESS, RONLY, ospfIfEntry, | |
344 | 3, {7, 1, 1}}, | |
345 | {OSPFADDRESSLESSIF, INTEGER, RONLY, ospfIfEntry, | |
346 | 3, {7, 1, 2}}, | |
347 | {OSPFIFAREAID, IPADDRESS, RWRITE, ospfIfEntry, | |
348 | 3, {7, 1, 3}}, | |
349 | {OSPFIFTYPE, INTEGER, RWRITE, ospfIfEntry, | |
350 | 3, {7, 1, 4}}, | |
351 | {OSPFIFADMINSTAT, INTEGER, RWRITE, ospfIfEntry, | |
352 | 3, {7, 1, 5}}, | |
353 | {OSPFIFRTRPRIORITY, INTEGER, RWRITE, ospfIfEntry, | |
354 | 3, {7, 1, 6}}, | |
355 | {OSPFIFTRANSITDELAY, INTEGER, RWRITE, ospfIfEntry, | |
356 | 3, {7, 1, 7}}, | |
357 | {OSPFIFRETRANSINTERVAL, INTEGER, RWRITE, ospfIfEntry, | |
358 | 3, {7, 1, 8}}, | |
359 | {OSPFIFHELLOINTERVAL, INTEGER, RWRITE, ospfIfEntry, | |
360 | 3, {7, 1, 9}}, | |
361 | {OSPFIFRTRDEADINTERVAL, INTEGER, RWRITE, ospfIfEntry, | |
362 | 3, {7, 1, 10}}, | |
363 | {OSPFIFPOLLINTERVAL, INTEGER, RWRITE, ospfIfEntry, | |
364 | 3, {7, 1, 11}}, | |
365 | {OSPFIFSTATE, INTEGER, RONLY, ospfIfEntry, | |
366 | 3, {7, 1, 12}}, | |
367 | {OSPFIFDESIGNATEDROUTER, IPADDRESS, RONLY, ospfIfEntry, | |
368 | 3, {7, 1, 13}}, | |
369 | {OSPFIFBACKUPDESIGNATEDROUTER, IPADDRESS, RONLY, ospfIfEntry, | |
370 | 3, {7, 1, 14}}, | |
371 | {OSPFIFEVENTS, COUNTER, RONLY, ospfIfEntry, | |
372 | 3, {7, 1, 15}}, | |
373 | {OSPFIFAUTHKEY, STRING, RWRITE, ospfIfEntry, | |
374 | 3, {7, 1, 16}}, | |
375 | {OSPFIFSTATUS, INTEGER, RWRITE, ospfIfEntry, | |
376 | 3, {7, 1, 17}}, | |
377 | {OSPFIFMULTICASTFORWARDING, INTEGER, RWRITE, ospfIfEntry, | |
378 | 3, {7, 1, 18}}, | |
379 | {OSPFIFDEMAND, INTEGER, RWRITE, ospfIfEntry, | |
380 | 3, {7, 1, 19}}, | |
381 | {OSPFIFAUTHTYPE, INTEGER, RWRITE, ospfIfEntry, | |
382 | 3, {7, 1, 20}}, | |
383 | ||
384 | /* OSPF interface metric table. */ | |
385 | {OSPFIFMETRICIPADDRESS, IPADDRESS, RONLY, ospfIfMetricEntry, | |
386 | 3, {8, 1, 1}}, | |
387 | {OSPFIFMETRICADDRESSLESSIF, INTEGER, RONLY, ospfIfMetricEntry, | |
388 | 3, {8, 1, 2}}, | |
389 | {OSPFIFMETRICTOS, INTEGER, RONLY, ospfIfMetricEntry, | |
390 | 3, {8, 1, 3}}, | |
391 | {OSPFIFMETRICVALUE, INTEGER, RWRITE, ospfIfMetricEntry, | |
392 | 3, {8, 1, 4}}, | |
393 | {OSPFIFMETRICSTATUS, INTEGER, RWRITE, ospfIfMetricEntry, | |
394 | 3, {8, 1, 5}}, | |
395 | ||
396 | /* OSPF virtual interface table. */ | |
397 | {OSPFVIRTIFAREAID, IPADDRESS, RONLY, ospfVirtIfEntry, | |
398 | 3, {9, 1, 1}}, | |
399 | {OSPFVIRTIFNEIGHBOR, IPADDRESS, RONLY, ospfVirtIfEntry, | |
400 | 3, {9, 1, 2}}, | |
401 | {OSPFVIRTIFTRANSITDELAY, INTEGER, RWRITE, ospfVirtIfEntry, | |
402 | 3, {9, 1, 3}}, | |
403 | {OSPFVIRTIFRETRANSINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry, | |
404 | 3, {9, 1, 4}}, | |
405 | {OSPFVIRTIFHELLOINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry, | |
406 | 3, {9, 1, 5}}, | |
407 | {OSPFVIRTIFRTRDEADINTERVAL, INTEGER, RWRITE, ospfVirtIfEntry, | |
408 | 3, {9, 1, 6}}, | |
409 | {OSPFVIRTIFSTATE, INTEGER, RONLY, ospfVirtIfEntry, | |
410 | 3, {9, 1, 7}}, | |
411 | {OSPFVIRTIFEVENTS, COUNTER, RONLY, ospfVirtIfEntry, | |
412 | 3, {9, 1, 8}}, | |
413 | {OSPFVIRTIFAUTHKEY, STRING, RWRITE, ospfVirtIfEntry, | |
414 | 3, {9, 1, 9}}, | |
415 | {OSPFVIRTIFSTATUS, INTEGER, RWRITE, ospfVirtIfEntry, | |
416 | 3, {9, 1, 10}}, | |
417 | {OSPFVIRTIFAUTHTYPE, INTEGER, RWRITE, ospfVirtIfEntry, | |
418 | 3, {9, 1, 11}}, | |
419 | ||
420 | /* OSPF neighbor table. */ | |
421 | {OSPFNBRIPADDR, IPADDRESS, RONLY, ospfNbrEntry, | |
422 | 3, {10, 1, 1}}, | |
423 | {OSPFNBRADDRESSLESSINDEX, INTEGER, RONLY, ospfNbrEntry, | |
424 | 3, {10, 1, 2}}, | |
425 | {OSPFNBRRTRID, IPADDRESS, RONLY, ospfNbrEntry, | |
426 | 3, {10, 1, 3}}, | |
427 | {OSPFNBROPTIONS, INTEGER, RONLY, ospfNbrEntry, | |
428 | 3, {10, 1, 4}}, | |
429 | {OSPFNBRPRIORITY, INTEGER, RWRITE, ospfNbrEntry, | |
430 | 3, {10, 1, 5}}, | |
431 | {OSPFNBRSTATE, INTEGER, RONLY, ospfNbrEntry, | |
432 | 3, {10, 1, 6}}, | |
433 | {OSPFNBREVENTS, COUNTER, RONLY, ospfNbrEntry, | |
434 | 3, {10, 1, 7}}, | |
435 | {OSPFNBRLSRETRANSQLEN, GAUGE, RONLY, ospfNbrEntry, | |
436 | 3, {10, 1, 8}}, | |
437 | {OSPFNBMANBRSTATUS, INTEGER, RWRITE, ospfNbrEntry, | |
438 | 3, {10, 1, 9}}, | |
439 | {OSPFNBMANBRPERMANENCE, INTEGER, RONLY, ospfNbrEntry, | |
440 | 3, {10, 1, 10}}, | |
441 | {OSPFNBRHELLOSUPPRESSED, INTEGER, RONLY, ospfNbrEntry, | |
442 | 3, {10, 1, 11}}, | |
443 | ||
444 | /* OSPF virtual neighbor table. */ | |
445 | {OSPFVIRTNBRAREA, IPADDRESS, RONLY, ospfVirtNbrEntry, | |
446 | 3, {11, 1, 1}}, | |
447 | {OSPFVIRTNBRRTRID, IPADDRESS, RONLY, ospfVirtNbrEntry, | |
448 | 3, {11, 1, 2}}, | |
449 | {OSPFVIRTNBRIPADDR, IPADDRESS, RONLY, ospfVirtNbrEntry, | |
450 | 3, {11, 1, 3}}, | |
451 | {OSPFVIRTNBROPTIONS, INTEGER, RONLY, ospfVirtNbrEntry, | |
452 | 3, {11, 1, 4}}, | |
453 | {OSPFVIRTNBRSTATE, INTEGER, RONLY, ospfVirtNbrEntry, | |
454 | 3, {11, 1, 5}}, | |
455 | {OSPFVIRTNBREVENTS, COUNTER, RONLY, ospfVirtNbrEntry, | |
456 | 3, {11, 1, 6}}, | |
457 | {OSPFVIRTNBRLSRETRANSQLEN, INTEGER, RONLY, ospfVirtNbrEntry, | |
458 | 3, {11, 1, 7}}, | |
459 | {OSPFVIRTNBRHELLOSUPPRESSED, INTEGER, RONLY, ospfVirtNbrEntry, | |
460 | 3, {11, 1, 8}}, | |
461 | ||
462 | /* OSPF link state database, external. */ | |
463 | {OSPFEXTLSDBTYPE, INTEGER, RONLY, ospfExtLsdbEntry, | |
464 | 3, {12, 1, 1}}, | |
465 | {OSPFEXTLSDBLSID, IPADDRESS, RONLY, ospfExtLsdbEntry, | |
466 | 3, {12, 1, 2}}, | |
467 | {OSPFEXTLSDBROUTERID, IPADDRESS, RONLY, ospfExtLsdbEntry, | |
468 | 3, {12, 1, 3}}, | |
469 | {OSPFEXTLSDBSEQUENCE, INTEGER, RONLY, ospfExtLsdbEntry, | |
470 | 3, {12, 1, 4}}, | |
471 | {OSPFEXTLSDBAGE, INTEGER, RONLY, ospfExtLsdbEntry, | |
472 | 3, {12, 1, 5}}, | |
473 | {OSPFEXTLSDBCHECKSUM, INTEGER, RONLY, ospfExtLsdbEntry, | |
474 | 3, {12, 1, 6}}, | |
475 | {OSPFEXTLSDBADVERTISEMENT, STRING, RONLY, ospfExtLsdbEntry, | |
476 | 3, {12, 1, 7}}, | |
477 | ||
478 | /* OSPF area aggregate table. */ | |
479 | {OSPFAREAAGGREGATEAREAID, IPADDRESS, RONLY, ospfAreaAggregateEntry, | |
480 | 3, {14, 1, 1}}, | |
481 | {OSPFAREAAGGREGATELSDBTYPE, INTEGER, RONLY, ospfAreaAggregateEntry, | |
482 | 3, {14, 1, 2}}, | |
483 | {OSPFAREAAGGREGATENET, IPADDRESS, RONLY, ospfAreaAggregateEntry, | |
484 | 3, {14, 1, 3}}, | |
485 | {OSPFAREAAGGREGATEMASK, IPADDRESS, RONLY, ospfAreaAggregateEntry, | |
486 | 3, {14, 1, 4}}, | |
487 | {OSPFAREAAGGREGATESTATUS, INTEGER, RWRITE, ospfAreaAggregateEntry, | |
488 | 3, {14, 1, 5}}, | |
489 | {OSPFAREAAGGREGATEEFFECT, INTEGER, RWRITE, ospfAreaAggregateEntry, | |
490 | 3, {14, 1, 6}} | |
491 | }; | |
492 | \f | |
493 | /* The administrative status of OSPF. When OSPF is enbled on at least | |
494 | one interface return 1. */ | |
495 | int | |
68980084 | 496 | ospf_admin_stat (struct ospf *ospf) |
718e3744 | 497 | { |
aa20c6f1 | 498 | struct listnode *node; |
718e3744 | 499 | struct ospf_interface *oi; |
500 | ||
68980084 | 501 | if (ospf == NULL) |
718e3744 | 502 | return 0; |
503 | ||
1eb8ef25 | 504 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi)) |
505 | if (oi && oi->address) | |
506 | return 1; | |
718e3744 | 507 | |
718e3744 | 508 | return 0; |
509 | } | |
510 | ||
511 | static u_char * | |
512 | ospfGeneralGroup (struct variable *v, oid *name, size_t *length, | |
513 | int exact, size_t *var_len, WriteMethod **write_method) | |
514 | { | |
020709f9 | 515 | struct ospf *ospf; |
516 | ||
517 | ospf = ospf_lookup (); | |
68980084 | 518 | |
718e3744 | 519 | /* Check whether the instance identifier is valid */ |
520 | if (smux_header_generic (v, name, length, exact, var_len, write_method) | |
521 | == MATCH_FAILED) | |
522 | return NULL; | |
523 | ||
524 | /* Return the current value of the variable */ | |
525 | switch (v->magic) | |
526 | { | |
527 | case OSPFROUTERID: /* 1 */ | |
528 | /* Router-ID of this OSPF instance. */ | |
68980084 | 529 | if (ospf) |
530 | return SNMP_IPADDRESS (ospf->router_id); | |
718e3744 | 531 | else |
532 | return SNMP_IPADDRESS (ospf_empty_addr); | |
533 | break; | |
534 | case OSPFADMINSTAT: /* 2 */ | |
535 | /* The administrative status of OSPF in the router. */ | |
68980084 | 536 | if (ospf_admin_stat (ospf)) |
718e3744 | 537 | return SNMP_INTEGER (OSPF_STATUS_ENABLED); |
538 | else | |
539 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); | |
540 | break; | |
541 | case OSPFVERSIONNUMBER: /* 3 */ | |
542 | /* OSPF version 2. */ | |
543 | return SNMP_INTEGER (OSPF_VERSION); | |
544 | break; | |
545 | case OSPFAREABDRRTRSTATUS: /* 4 */ | |
546 | /* Area Border router status. */ | |
68980084 | 547 | if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR)) |
718e3744 | 548 | return SNMP_INTEGER (SNMP_TRUE); |
549 | else | |
550 | return SNMP_INTEGER (SNMP_FALSE); | |
551 | break; | |
552 | case OSPFASBDRRTRSTATUS: /* 5 */ | |
553 | /* AS Border router status. */ | |
68980084 | 554 | if (ospf && CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR)) |
718e3744 | 555 | return SNMP_INTEGER (SNMP_TRUE); |
556 | else | |
557 | return SNMP_INTEGER (SNMP_FALSE); | |
558 | break; | |
559 | case OSPFEXTERNLSACOUNT: /* 6 */ | |
560 | /* External LSA counts. */ | |
68980084 | 561 | if (ospf) |
562 | return SNMP_INTEGER (ospf_lsdb_count_all (ospf->lsdb)); | |
718e3744 | 563 | else |
564 | return SNMP_INTEGER (0); | |
565 | break; | |
566 | case OSPFEXTERNLSACKSUMSUM: /* 7 */ | |
567 | /* External LSA checksum. */ | |
568 | return SNMP_INTEGER (0); | |
569 | break; | |
570 | case OSPFTOSSUPPORT: /* 8 */ | |
571 | /* TOS is not supported. */ | |
572 | return SNMP_INTEGER (SNMP_FALSE); | |
573 | break; | |
574 | case OSPFORIGINATENEWLSAS: /* 9 */ | |
575 | /* The number of new link-state advertisements. */ | |
68980084 | 576 | if (ospf) |
577 | return SNMP_INTEGER (ospf->lsa_originate_count); | |
718e3744 | 578 | else |
579 | return SNMP_INTEGER (0); | |
580 | break; | |
581 | case OSPFRXNEWLSAS: /* 10 */ | |
582 | /* The number of link-state advertisements received determined | |
583 | to be new instantiations. */ | |
68980084 | 584 | if (ospf) |
585 | return SNMP_INTEGER (ospf->rx_lsa_count); | |
718e3744 | 586 | else |
587 | return SNMP_INTEGER (0); | |
588 | break; | |
589 | case OSPFEXTLSDBLIMIT: /* 11 */ | |
590 | /* There is no limit for the number of non-default | |
591 | AS-external-LSAs. */ | |
592 | return SNMP_INTEGER (-1); | |
593 | break; | |
594 | case OSPFMULTICASTEXTENSIONS: /* 12 */ | |
595 | /* Multicast Extensions to OSPF is not supported. */ | |
596 | return SNMP_INTEGER (0); | |
597 | break; | |
598 | case OSPFEXITOVERFLOWINTERVAL: /* 13 */ | |
599 | /* Overflow is not supported. */ | |
600 | return SNMP_INTEGER (0); | |
601 | break; | |
602 | case OSPFDEMANDEXTENSIONS: /* 14 */ | |
603 | /* Demand routing is not supported. */ | |
604 | return SNMP_INTEGER (SNMP_FALSE); | |
605 | break; | |
606 | default: | |
607 | return NULL; | |
608 | } | |
609 | return NULL; | |
610 | } | |
611 | ||
612 | struct ospf_area * | |
68980084 | 613 | ospf_area_lookup_next (struct ospf *ospf, struct in_addr *area_id, int first) |
718e3744 | 614 | { |
615 | struct ospf_area *area; | |
aa20c6f1 | 616 | struct listnode *node; |
718e3744 | 617 | |
020709f9 | 618 | if (ospf == NULL) |
718e3744 | 619 | return NULL; |
620 | ||
621 | if (first) | |
622 | { | |
68980084 | 623 | node = listhead (ospf->areas); |
718e3744 | 624 | if (node) |
625 | { | |
1eb8ef25 | 626 | area = listgetdata (node); |
718e3744 | 627 | *area_id = area->area_id; |
628 | return area; | |
629 | } | |
630 | return NULL; | |
631 | } | |
1eb8ef25 | 632 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 633 | { |
718e3744 | 634 | if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr)) |
635 | { | |
636 | *area_id = area->area_id; | |
637 | return area; | |
638 | } | |
639 | } | |
640 | return NULL; | |
641 | } | |
642 | ||
643 | struct ospf_area * | |
644 | ospfAreaLookup (struct variable *v, oid name[], size_t *length, | |
645 | struct in_addr *addr, int exact) | |
646 | { | |
020709f9 | 647 | struct ospf *ospf; |
718e3744 | 648 | struct ospf_area *area; |
68980084 | 649 | int len; |
718e3744 | 650 | |
020709f9 | 651 | ospf = ospf_lookup (); |
68980084 | 652 | if (ospf == NULL) |
718e3744 | 653 | return NULL; |
654 | ||
655 | if (exact) | |
656 | { | |
657 | /* Length is insufficient to lookup OSPF area. */ | |
658 | if (*length - v->namelen != sizeof (struct in_addr)) | |
659 | return NULL; | |
660 | ||
661 | oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr); | |
662 | ||
68980084 | 663 | area = ospf_area_lookup_by_area_id (ospf, *addr); |
718e3744 | 664 | |
665 | return area; | |
666 | } | |
667 | else | |
668 | { | |
669 | len = *length - v->namelen; | |
670 | if (len > 4) | |
671 | len = 4; | |
672 | ||
673 | oid2in_addr (name + v->namelen, len, addr); | |
674 | ||
68980084 | 675 | area = ospf_area_lookup_next (ospf, addr, len == 0 ? 1 : 0); |
718e3744 | 676 | |
677 | if (area == NULL) | |
678 | return NULL; | |
679 | ||
680 | oid_copy_addr (name + v->namelen, addr, sizeof (struct in_addr)); | |
681 | *length = sizeof (struct in_addr) + v->namelen; | |
682 | ||
683 | return area; | |
684 | } | |
685 | return NULL; | |
686 | } | |
687 | ||
688 | static u_char * | |
689 | ospfAreaEntry (struct variable *v, oid *name, size_t *length, int exact, | |
690 | size_t *var_len, WriteMethod **write_method) | |
691 | { | |
692 | struct ospf_area *area; | |
693 | struct in_addr addr; | |
694 | ||
695 | memset (&addr, 0, sizeof (struct in_addr)); | |
696 | ||
697 | area = ospfAreaLookup (v, name, length, &addr, exact); | |
698 | if (! area) | |
699 | return NULL; | |
700 | ||
701 | /* Return the current value of the variable */ | |
702 | switch (v->magic) | |
703 | { | |
704 | case OSPFAREAID: /* 1 */ | |
705 | return SNMP_IPADDRESS (area->area_id); | |
706 | break; | |
707 | case OSPFAUTHTYPE: /* 2 */ | |
708 | return SNMP_INTEGER (area->auth_type); | |
709 | break; | |
710 | case OSPFIMPORTASEXTERN: /* 3 */ | |
711 | return SNMP_INTEGER (area->external_routing + 1); | |
712 | break; | |
713 | case OSPFSPFRUNS: /* 4 */ | |
714 | return SNMP_INTEGER (area->spf_calculation); | |
715 | break; | |
716 | case OSPFAREABDRRTRCOUNT: /* 5 */ | |
717 | return SNMP_INTEGER (area->abr_count); | |
718 | break; | |
719 | case OSPFASBDRRTRCOUNT: /* 6 */ | |
720 | return SNMP_INTEGER (area->asbr_count); | |
721 | break; | |
722 | case OSPFAREALSACOUNT: /* 7 */ | |
723 | return SNMP_INTEGER (area->lsdb->total); | |
724 | break; | |
725 | case OSPFAREALSACKSUMSUM: /* 8 */ | |
726 | return SNMP_INTEGER (0); | |
727 | break; | |
728 | case OSPFAREASUMMARY: /* 9 */ | |
729 | #define OSPF_noAreaSummary 1 | |
730 | #define OSPF_sendAreaSummary 2 | |
731 | if (area->no_summary) | |
732 | return SNMP_INTEGER (OSPF_noAreaSummary); | |
733 | else | |
734 | return SNMP_INTEGER (OSPF_sendAreaSummary); | |
735 | break; | |
736 | case OSPFAREASTATUS: /* 10 */ | |
737 | return SNMP_INTEGER (SNMP_VALID); | |
738 | break; | |
739 | default: | |
740 | return NULL; | |
741 | break; | |
742 | } | |
743 | return NULL; | |
744 | } | |
745 | ||
746 | struct ospf_area * | |
747 | ospf_stub_area_lookup_next (struct in_addr *area_id, int first) | |
748 | { | |
749 | struct ospf_area *area; | |
aa20c6f1 | 750 | struct listnode *node; |
020709f9 | 751 | struct ospf *ospf; |
718e3744 | 752 | |
020709f9 | 753 | ospf = ospf_lookup (); |
754 | if (ospf == NULL) | |
718e3744 | 755 | return NULL; |
756 | ||
1eb8ef25 | 757 | for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area)) |
718e3744 | 758 | { |
718e3744 | 759 | if (area->external_routing == OSPF_AREA_STUB) |
760 | { | |
761 | if (first) | |
762 | { | |
763 | *area_id = area->area_id; | |
764 | return area; | |
765 | } | |
766 | else if (ntohl (area->area_id.s_addr) > ntohl (area_id->s_addr)) | |
767 | { | |
768 | *area_id = area->area_id; | |
769 | return area; | |
770 | } | |
771 | } | |
772 | } | |
773 | return NULL; | |
774 | } | |
775 | ||
776 | struct ospf_area * | |
777 | ospfStubAreaLookup (struct variable *v, oid name[], size_t *length, | |
778 | struct in_addr *addr, int exact) | |
779 | { | |
020709f9 | 780 | struct ospf *ospf; |
718e3744 | 781 | struct ospf_area *area; |
68980084 | 782 | int len; |
718e3744 | 783 | |
020709f9 | 784 | ospf = ospf_lookup (); |
785 | if (ospf == NULL) | |
718e3744 | 786 | return NULL; |
787 | ||
788 | /* Exact lookup. */ | |
789 | if (exact) | |
790 | { | |
791 | /* ospfStubAreaID + ospfStubTOS. */ | |
792 | if (*length != v->namelen + sizeof (struct in_addr) + 1) | |
793 | return NULL; | |
794 | ||
795 | /* Check ospfStubTOS is zero. */ | |
796 | if (name[*length - 1] != 0) | |
797 | return NULL; | |
798 | ||
799 | oid2in_addr (name + v->namelen, sizeof (struct in_addr), addr); | |
800 | ||
68980084 | 801 | area = ospf_area_lookup_by_area_id (ospf, *addr); |
718e3744 | 802 | |
803 | if (area->external_routing == OSPF_AREA_STUB) | |
804 | return area; | |
805 | else | |
806 | return NULL; | |
807 | } | |
808 | else | |
809 | { | |
810 | len = *length - v->namelen; | |
811 | if (len > 4) | |
812 | len = 4; | |
813 | ||
814 | oid2in_addr (name + v->namelen, len, addr); | |
815 | ||
816 | area = ospf_stub_area_lookup_next (addr, len == 0 ? 1 : 0); | |
817 | ||
818 | if (area == NULL) | |
819 | return NULL; | |
820 | ||
821 | oid_copy_addr (name + v->namelen, addr, sizeof (struct in_addr)); | |
822 | /* Set TOS 0. */ | |
823 | name[v->namelen + sizeof (struct in_addr)] = 0; | |
824 | *length = v->namelen + sizeof (struct in_addr) + 1; | |
825 | ||
826 | return area; | |
827 | } | |
828 | return NULL; | |
829 | } | |
830 | ||
831 | static u_char * | |
832 | ospfStubAreaEntry (struct variable *v, oid *name, size_t *length, | |
833 | int exact, size_t *var_len, WriteMethod **write_method) | |
834 | { | |
835 | struct ospf_area *area; | |
836 | struct in_addr addr; | |
837 | ||
838 | memset (&addr, 0, sizeof (struct in_addr)); | |
839 | ||
840 | area = ospfStubAreaLookup (v, name, length, &addr, exact); | |
841 | if (! area) | |
842 | return NULL; | |
843 | ||
844 | /* Return the current value of the variable */ | |
845 | switch (v->magic) | |
846 | { | |
847 | case OSPFSTUBAREAID: /* 1 */ | |
848 | /* OSPF stub area id. */ | |
849 | return SNMP_IPADDRESS (area->area_id); | |
850 | break; | |
851 | case OSPFSTUBTOS: /* 2 */ | |
852 | /* TOS value is not supported. */ | |
853 | return SNMP_INTEGER (0); | |
854 | break; | |
855 | case OSPFSTUBMETRIC: /* 3 */ | |
856 | /* Default cost to stub area. */ | |
857 | return SNMP_INTEGER (area->default_cost); | |
858 | break; | |
859 | case OSPFSTUBSTATUS: /* 4 */ | |
860 | /* Status of the stub area. */ | |
861 | return SNMP_INTEGER (SNMP_VALID); | |
862 | break; | |
863 | case OSPFSTUBMETRICTYPE: /* 5 */ | |
864 | /* OSPF Metric type. */ | |
865 | #define OSPF_ospfMetric 1 | |
866 | #define OSPF_comparableCost 2 | |
867 | #define OSPF_nonComparable 3 | |
868 | return SNMP_INTEGER (OSPF_ospfMetric); | |
869 | break; | |
870 | default: | |
871 | return NULL; | |
872 | break; | |
873 | } | |
874 | return NULL; | |
875 | } | |
876 | ||
877 | struct ospf_lsa * | |
878 | lsdb_lookup_next (struct ospf_area *area, u_char *type, int type_next, | |
879 | struct in_addr *ls_id, int ls_id_next, | |
880 | struct in_addr *router_id, int router_id_next) | |
881 | { | |
882 | struct ospf_lsa *lsa; | |
883 | int i; | |
884 | ||
885 | if (type_next) | |
886 | i = OSPF_MIN_LSA; | |
887 | else | |
888 | i = *type; | |
889 | ||
ba682537 | 890 | /* Sanity check, if LSA type unknwon |
891 | merley skip any LSA */ | |
892 | if ((i < OSPF_MIN_LSA) || (i >= OSPF_MAX_LSA)) | |
893 | { | |
894 | zlog_debug("Strange request with LSA type %d\n", i); | |
895 | return NULL; | |
896 | } | |
897 | ||
718e3744 | 898 | for (; i < OSPF_MAX_LSA; i++) |
899 | { | |
900 | *type = i; | |
901 | ||
902 | lsa = ospf_lsdb_lookup_by_id_next (area->lsdb, *type, *ls_id, *router_id, | |
903 | ls_id_next); | |
904 | if (lsa) | |
905 | return lsa; | |
906 | ||
907 | ls_id_next = 1; | |
908 | } | |
909 | return NULL; | |
910 | } | |
911 | ||
912 | struct ospf_lsa * | |
913 | ospfLsdbLookup (struct variable *v, oid *name, size_t *length, | |
914 | struct in_addr *area_id, u_char *type, | |
915 | struct in_addr *ls_id, struct in_addr *router_id, int exact) | |
916 | { | |
020709f9 | 917 | struct ospf *ospf; |
718e3744 | 918 | struct ospf_area *area; |
919 | struct ospf_lsa *lsa; | |
6c835671 | 920 | unsigned int len; |
718e3744 | 921 | int type_next; |
922 | int ls_id_next; | |
923 | int router_id_next; | |
924 | oid *offset; | |
925 | int offsetlen; | |
926 | ||
020709f9 | 927 | ospf = ospf_lookup (); |
928 | ||
718e3744 | 929 | #define OSPF_LSDB_ENTRY_OFFSET \ |
930 | (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE) | |
931 | ||
932 | if (exact) | |
933 | { | |
934 | /* Area ID + Type + LS ID + Router ID. */ | |
935 | if (*length - v->namelen != OSPF_LSDB_ENTRY_OFFSET) | |
936 | return NULL; | |
937 | ||
938 | /* Set OID offset for Area ID. */ | |
939 | offset = name + v->namelen; | |
940 | ||
941 | /* Lookup area first. */ | |
942 | oid2in_addr (offset, IN_ADDR_SIZE, area_id); | |
68980084 | 943 | area = ospf_area_lookup_by_area_id (ospf, *area_id); |
718e3744 | 944 | if (! area) |
945 | return NULL; | |
946 | offset += IN_ADDR_SIZE; | |
947 | ||
948 | /* Type. */ | |
949 | *type = *offset; | |
950 | offset++; | |
951 | ||
952 | /* LS ID. */ | |
953 | oid2in_addr (offset, IN_ADDR_SIZE, ls_id); | |
954 | offset += IN_ADDR_SIZE; | |
955 | ||
956 | /* Router ID. */ | |
957 | oid2in_addr (offset, IN_ADDR_SIZE, router_id); | |
958 | ||
959 | /* Lookup LSDB. */ | |
960 | return ospf_lsdb_lookup_by_id (area->lsdb, *type, *ls_id, *router_id); | |
961 | } | |
962 | else | |
963 | { | |
964 | /* Get variable length. */ | |
965 | offset = name + v->namelen; | |
966 | offsetlen = *length - v->namelen; | |
967 | len = offsetlen; | |
968 | ||
969 | if (len > IN_ADDR_SIZE) | |
970 | len = IN_ADDR_SIZE; | |
971 | ||
972 | oid2in_addr (offset, len, area_id); | |
973 | ||
974 | /* First we search area. */ | |
975 | if (len == IN_ADDR_SIZE) | |
68980084 | 976 | area = ospf_area_lookup_by_area_id (ospf, *area_id); |
718e3744 | 977 | else |
68980084 | 978 | area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0); |
718e3744 | 979 | |
980 | if (area == NULL) | |
981 | return NULL; | |
982 | ||
983 | do | |
984 | { | |
985 | /* Next we lookup type. */ | |
986 | offset += IN_ADDR_SIZE; | |
987 | offsetlen -= IN_ADDR_SIZE; | |
988 | len = offsetlen; | |
989 | ||
990 | if (len <= 0) | |
991 | type_next = 1; | |
992 | else | |
993 | { | |
994 | len = 1; | |
995 | type_next = 0; | |
996 | *type = *offset; | |
997 | } | |
998 | ||
999 | /* LS ID. */ | |
1000 | offset++; | |
1001 | offsetlen--; | |
1002 | len = offsetlen; | |
1003 | ||
1004 | if (len <= 0) | |
1005 | ls_id_next = 1; | |
1006 | else | |
1007 | { | |
1008 | ls_id_next = 0; | |
1009 | if (len > IN_ADDR_SIZE) | |
1010 | len = IN_ADDR_SIZE; | |
1011 | ||
1012 | oid2in_addr (offset, len, ls_id); | |
1013 | } | |
1014 | ||
1015 | /* Router ID. */ | |
1016 | offset += IN_ADDR_SIZE; | |
1017 | offsetlen -= IN_ADDR_SIZE; | |
1018 | len = offsetlen; | |
1019 | ||
1020 | if (len <= 0) | |
1021 | router_id_next = 1; | |
1022 | else | |
1023 | { | |
1024 | router_id_next = 0; | |
1025 | if (len > IN_ADDR_SIZE) | |
1026 | len = IN_ADDR_SIZE; | |
1027 | ||
1028 | oid2in_addr (offset, len, router_id); | |
1029 | } | |
1030 | ||
1031 | lsa = lsdb_lookup_next (area, type, type_next, ls_id, ls_id_next, | |
1032 | router_id, router_id_next); | |
1033 | ||
1034 | if (lsa) | |
1035 | { | |
1036 | /* Fill in length. */ | |
1037 | *length = v->namelen + OSPF_LSDB_ENTRY_OFFSET; | |
1038 | ||
1039 | /* Fill in value. */ | |
1040 | offset = name + v->namelen; | |
1041 | oid_copy_addr (offset, area_id, IN_ADDR_SIZE); | |
1042 | offset += IN_ADDR_SIZE; | |
1043 | *offset = lsa->data->type; | |
1044 | offset++; | |
1045 | oid_copy_addr (offset, &lsa->data->id, IN_ADDR_SIZE); | |
1046 | offset += IN_ADDR_SIZE; | |
1047 | oid_copy_addr (offset, &lsa->data->adv_router, IN_ADDR_SIZE); | |
1048 | ||
1049 | return lsa; | |
1050 | } | |
1051 | } | |
68980084 | 1052 | while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL); |
718e3744 | 1053 | } |
1054 | return NULL; | |
1055 | } | |
1056 | ||
1057 | static u_char * | |
1058 | ospfLsdbEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1059 | size_t *var_len, WriteMethod **write_method) | |
1060 | { | |
1061 | struct ospf_lsa *lsa; | |
1062 | struct lsa_header *lsah; | |
1063 | struct in_addr area_id; | |
1064 | u_char type; | |
1065 | struct in_addr ls_id; | |
1066 | struct in_addr router_id; | |
020709f9 | 1067 | struct ospf *ospf; |
718e3744 | 1068 | |
1069 | /* INDEX { ospfLsdbAreaId, ospfLsdbType, | |
1070 | ospfLsdbLsid, ospfLsdbRouterId } */ | |
1071 | ||
1072 | memset (&area_id, 0, sizeof (struct in_addr)); | |
1073 | type = 0; | |
1074 | memset (&ls_id, 0, sizeof (struct in_addr)); | |
1075 | memset (&router_id, 0, sizeof (struct in_addr)); | |
1076 | ||
1077 | /* Check OSPF instance. */ | |
020709f9 | 1078 | ospf = ospf_lookup (); |
1079 | if (ospf == NULL) | |
718e3744 | 1080 | return NULL; |
1081 | ||
1082 | lsa = ospfLsdbLookup (v, name, length, &area_id, &type, &ls_id, &router_id, | |
1083 | exact); | |
1084 | if (! lsa) | |
1085 | return NULL; | |
1086 | ||
1087 | lsah = lsa->data; | |
1088 | ||
1089 | /* Return the current value of the variable */ | |
1090 | switch (v->magic) | |
1091 | { | |
1092 | case OSPFLSDBAREAID: /* 1 */ | |
1093 | return SNMP_IPADDRESS (lsa->area->area_id); | |
1094 | break; | |
1095 | case OSPFLSDBTYPE: /* 2 */ | |
1096 | return SNMP_INTEGER (lsah->type); | |
1097 | break; | |
1098 | case OSPFLSDBLSID: /* 3 */ | |
1099 | return SNMP_IPADDRESS (lsah->id); | |
1100 | break; | |
1101 | case OSPFLSDBROUTERID: /* 4 */ | |
1102 | return SNMP_IPADDRESS (lsah->adv_router); | |
1103 | break; | |
1104 | case OSPFLSDBSEQUENCE: /* 5 */ | |
1105 | return SNMP_INTEGER (lsah->ls_seqnum); | |
1106 | break; | |
1107 | case OSPFLSDBAGE: /* 6 */ | |
1108 | return SNMP_INTEGER (lsah->ls_age); | |
1109 | break; | |
1110 | case OSPFLSDBCHECKSUM: /* 7 */ | |
1111 | return SNMP_INTEGER (lsah->checksum); | |
1112 | break; | |
1113 | case OSPFLSDBADVERTISEMENT: /* 8 */ | |
1114 | *var_len = ntohs (lsah->length); | |
1115 | return (u_char *) lsah; | |
1116 | break; | |
1117 | default: | |
1118 | return NULL; | |
1119 | break; | |
1120 | } | |
1121 | return NULL; | |
1122 | } | |
1123 | ||
1124 | struct ospf_area_range * | |
1125 | ospfAreaRangeLookup (struct variable *v, oid *name, size_t *length, | |
1126 | struct in_addr *area_id, struct in_addr *range_net, | |
1127 | int exact) | |
1128 | { | |
1129 | oid *offset; | |
1130 | int offsetlen; | |
6c835671 | 1131 | unsigned int len; |
020709f9 | 1132 | struct ospf *ospf; |
718e3744 | 1133 | struct ospf_area *area; |
1134 | struct ospf_area_range *range; | |
1135 | struct prefix_ipv4 p; | |
1136 | p.family = AF_INET; | |
1137 | p.prefixlen = IPV4_MAX_BITLEN; | |
1138 | ||
020709f9 | 1139 | ospf = ospf_lookup (); |
1140 | ||
718e3744 | 1141 | if (exact) |
1142 | { | |
1143 | /* Area ID + Range Network. */ | |
1144 | if (v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE != *length) | |
1145 | return NULL; | |
1146 | ||
1147 | /* Set OID offset for Area ID. */ | |
1148 | offset = name + v->namelen; | |
1149 | ||
1150 | /* Lookup area first. */ | |
1151 | oid2in_addr (offset, IN_ADDR_SIZE, area_id); | |
1152 | ||
68980084 | 1153 | area = ospf_area_lookup_by_area_id (ospf, *area_id); |
718e3744 | 1154 | if (! area) |
1155 | return NULL; | |
1156 | ||
1157 | offset += IN_ADDR_SIZE; | |
1158 | ||
1159 | /* Lookup area range. */ | |
1160 | oid2in_addr (offset, IN_ADDR_SIZE, range_net); | |
1161 | p.prefix = *range_net; | |
1162 | ||
1163 | return ospf_area_range_lookup (area, &p); | |
1164 | } | |
1165 | else | |
1166 | { | |
1167 | /* Set OID offset for Area ID. */ | |
1168 | offset = name + v->namelen; | |
1169 | offsetlen = *length - v->namelen; | |
1170 | ||
1171 | len = offsetlen; | |
1172 | if (len > IN_ADDR_SIZE) | |
1173 | len = IN_ADDR_SIZE; | |
1174 | ||
1175 | oid2in_addr (offset, len, area_id); | |
1176 | ||
1177 | /* First we search area. */ | |
1178 | if (len == IN_ADDR_SIZE) | |
68980084 | 1179 | area = ospf_area_lookup_by_area_id (ospf,*area_id); |
718e3744 | 1180 | else |
68980084 | 1181 | area = ospf_area_lookup_next (ospf, area_id, len == 0 ? 1 : 0); |
718e3744 | 1182 | |
1183 | if (area == NULL) | |
1184 | return NULL; | |
1185 | ||
1186 | do | |
1187 | { | |
1188 | offset += IN_ADDR_SIZE; | |
1189 | offsetlen -= IN_ADDR_SIZE; | |
1190 | len = offsetlen; | |
1191 | ||
1192 | if (len < 0) | |
1193 | len = 0; | |
1194 | if (len > IN_ADDR_SIZE) | |
1195 | len = IN_ADDR_SIZE; | |
1196 | ||
1197 | oid2in_addr (offset, len, range_net); | |
1198 | ||
1199 | range = ospf_area_range_lookup_next (area, range_net, | |
1200 | len == 0 ? 1 : 0); | |
1201 | ||
1202 | if (range) | |
1203 | { | |
1204 | /* Fill in length. */ | |
1205 | *length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE; | |
1206 | ||
1207 | /* Fill in value. */ | |
1208 | offset = name + v->namelen; | |
1209 | oid_copy_addr (offset, area_id, IN_ADDR_SIZE); | |
1210 | offset += IN_ADDR_SIZE; | |
1211 | oid_copy_addr (offset, range_net, IN_ADDR_SIZE); | |
1212 | ||
1213 | return range; | |
1214 | } | |
1215 | } | |
68980084 | 1216 | while ((area = ospf_area_lookup_next (ospf, area_id, 0)) != NULL); |
718e3744 | 1217 | } |
1218 | return NULL; | |
1219 | } | |
1220 | ||
1221 | static u_char * | |
1222 | ospfAreaRangeEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1223 | size_t *var_len, WriteMethod **write_method) | |
1224 | { | |
1225 | struct ospf_area_range *range; | |
1226 | struct in_addr area_id; | |
1227 | struct in_addr range_net; | |
1228 | struct in_addr mask; | |
020709f9 | 1229 | struct ospf *ospf; |
718e3744 | 1230 | |
1231 | /* Check OSPF instance. */ | |
020709f9 | 1232 | ospf = ospf_lookup (); |
68980084 | 1233 | if (ospf == NULL) |
718e3744 | 1234 | return NULL; |
1235 | ||
1236 | memset (&area_id, 0, IN_ADDR_SIZE); | |
1237 | memset (&range_net, 0, IN_ADDR_SIZE); | |
1238 | ||
1239 | range = ospfAreaRangeLookup (v, name, length, &area_id, &range_net, exact); | |
1240 | if (! range) | |
1241 | return NULL; | |
1242 | ||
1243 | /* Convert prefixlen to network mask format. */ | |
1244 | masklen2ip (range->subst_masklen, &mask); | |
1245 | ||
1246 | /* Return the current value of the variable */ | |
1247 | switch (v->magic) | |
1248 | { | |
1249 | case OSPFAREARANGEAREAID: /* 1 */ | |
1250 | return SNMP_IPADDRESS (area_id); | |
1251 | break; | |
1252 | case OSPFAREARANGENET: /* 2 */ | |
1253 | return SNMP_IPADDRESS (range_net); | |
1254 | break; | |
1255 | case OSPFAREARANGEMASK: /* 3 */ | |
1256 | return SNMP_IPADDRESS (mask); | |
1257 | break; | |
1258 | case OSPFAREARANGESTATUS: /* 4 */ | |
1259 | return SNMP_INTEGER (SNMP_VALID); | |
1260 | break; | |
1261 | case OSPFAREARANGEEFFECT: /* 5 */ | |
1262 | #define OSPF_advertiseMatching 1 | |
1263 | #define OSPF_doNotAdvertiseMatching 2 | |
1264 | return SNMP_INTEGER (OSPF_advertiseMatching); | |
1265 | break; | |
1266 | default: | |
1267 | return NULL; | |
1268 | break; | |
1269 | } | |
1270 | return NULL; | |
1271 | } | |
1272 | ||
1273 | struct ospf_nbr_nbma * | |
1274 | ospfHostLookup (struct variable *v, oid *name, size_t *length, | |
1275 | struct in_addr *addr, int exact) | |
1276 | { | |
1277 | int len; | |
1278 | struct ospf_nbr_nbma *nbr_nbma; | |
020709f9 | 1279 | struct ospf *ospf; |
718e3744 | 1280 | |
020709f9 | 1281 | ospf = ospf_lookup (); |
68980084 | 1282 | if (ospf == NULL) |
718e3744 | 1283 | return NULL; |
1284 | ||
1285 | if (exact) | |
1286 | { | |
1287 | /* INDEX { ospfHostIpAddress, ospfHostTOS } */ | |
1288 | if (*length != v->namelen + IN_ADDR_SIZE + 1) | |
1289 | return NULL; | |
1290 | ||
1291 | /* Check ospfHostTOS. */ | |
1292 | if (name[*length - 1] != 0) | |
1293 | return NULL; | |
1294 | ||
1295 | oid2in_addr (name + v->namelen, IN_ADDR_SIZE, addr); | |
1296 | ||
68980084 | 1297 | nbr_nbma = ospf_nbr_nbma_lookup (ospf, *addr); |
718e3744 | 1298 | |
1299 | return nbr_nbma; | |
1300 | } | |
1301 | else | |
1302 | { | |
1303 | len = *length - v->namelen; | |
1304 | if (len > 4) | |
1305 | len = 4; | |
1306 | ||
1307 | oid2in_addr (name + v->namelen, len, addr); | |
1308 | ||
68980084 | 1309 | nbr_nbma = ospf_nbr_nbma_lookup_next (ospf, addr, len == 0 ? 1 : 0); |
718e3744 | 1310 | |
1311 | if (nbr_nbma == NULL) | |
1312 | return NULL; | |
1313 | ||
1314 | oid_copy_addr (name + v->namelen, addr, IN_ADDR_SIZE); | |
1315 | ||
1316 | /* Set TOS 0. */ | |
1317 | name[v->namelen + IN_ADDR_SIZE] = 0; | |
1318 | ||
1319 | *length = v->namelen + IN_ADDR_SIZE + 1; | |
1320 | ||
1321 | return nbr_nbma; | |
1322 | } | |
1323 | return NULL; | |
1324 | } | |
1325 | ||
1326 | static u_char * | |
1327 | ospfHostEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1328 | size_t *var_len, WriteMethod **write_method) | |
1329 | { | |
1330 | struct ospf_nbr_nbma *nbr_nbma; | |
1331 | struct ospf_interface *oi; | |
1332 | struct in_addr addr; | |
020709f9 | 1333 | struct ospf *ospf; |
718e3744 | 1334 | |
1335 | /* Check OSPF instance. */ | |
020709f9 | 1336 | ospf = ospf_lookup (); |
68980084 | 1337 | if (ospf == NULL) |
718e3744 | 1338 | return NULL; |
1339 | ||
1340 | memset (&addr, 0, sizeof (struct in_addr)); | |
1341 | ||
1342 | nbr_nbma = ospfHostLookup (v, name, length, &addr, exact); | |
1343 | if (nbr_nbma == NULL) | |
1344 | return NULL; | |
1345 | ||
1346 | oi = nbr_nbma->oi; | |
1347 | ||
1348 | /* Return the current value of the variable */ | |
1349 | switch (v->magic) | |
1350 | { | |
1351 | case OSPFHOSTIPADDRESS: /* 1 */ | |
1352 | return SNMP_IPADDRESS (nbr_nbma->addr); | |
1353 | break; | |
1354 | case OSPFHOSTTOS: /* 2 */ | |
1355 | return SNMP_INTEGER (0); | |
1356 | break; | |
1357 | case OSPFHOSTMETRIC: /* 3 */ | |
1358 | if (oi) | |
1359 | return SNMP_INTEGER (oi->output_cost); | |
1360 | else | |
1361 | return SNMP_INTEGER (1); | |
1362 | break; | |
1363 | case OSPFHOSTSTATUS: /* 4 */ | |
1364 | return SNMP_INTEGER (SNMP_VALID); | |
1365 | break; | |
1366 | case OSPFHOSTAREAID: /* 5 */ | |
1367 | if (oi && oi->area) | |
1368 | return SNMP_IPADDRESS (oi->area->area_id); | |
1369 | else | |
1370 | return SNMP_IPADDRESS (ospf_empty_addr); | |
1371 | break; | |
1372 | default: | |
1373 | return NULL; | |
1374 | break; | |
1375 | } | |
1376 | return NULL; | |
1377 | } | |
1378 | \f | |
1379 | struct list *ospf_snmp_iflist; | |
1380 | ||
1381 | struct ospf_snmp_if | |
1382 | { | |
1383 | struct in_addr addr; | |
1384 | unsigned int ifindex; | |
1385 | struct interface *ifp; | |
1386 | }; | |
1387 | ||
1388 | struct ospf_snmp_if * | |
1389 | ospf_snmp_if_new () | |
1390 | { | |
1391 | struct ospf_snmp_if *osif; | |
1392 | ||
1393 | osif = XMALLOC (0, sizeof (struct ospf_snmp_if)); | |
1394 | memset (osif, 0, sizeof (struct ospf_snmp_if)); | |
1395 | return osif; | |
1396 | } | |
1397 | ||
1398 | void | |
1399 | ospf_snmp_if_free (struct ospf_snmp_if *osif) | |
1400 | { | |
1401 | XFREE (0, osif); | |
1402 | } | |
1403 | ||
1404 | void | |
1405 | ospf_snmp_if_delete (struct interface *ifp) | |
1406 | { | |
1eb8ef25 | 1407 | struct listnode *node, *nnode; |
718e3744 | 1408 | struct ospf_snmp_if *osif; |
1409 | ||
1eb8ef25 | 1410 | for (ALL_LIST_ELEMENTS (ospf_snmp_iflist, node, nnode, osif)) |
718e3744 | 1411 | { |
1412 | if (osif->ifp == ifp) | |
1413 | { | |
1eb8ef25 | 1414 | list_delete_node (ospf_snmp_iflist, node); |
718e3744 | 1415 | ospf_snmp_if_free (osif); |
1416 | return; | |
1417 | } | |
1418 | } | |
1419 | } | |
1420 | ||
1421 | void | |
1422 | ospf_snmp_if_update (struct interface *ifp) | |
1423 | { | |
1eb8ef25 | 1424 | struct listnode *node; |
718e3744 | 1425 | struct listnode *pn; |
1426 | struct connected *ifc; | |
1427 | struct prefix *p; | |
1428 | struct ospf_snmp_if *osif; | |
1429 | struct in_addr *addr; | |
1430 | unsigned int ifindex; | |
1431 | ||
1432 | ospf_snmp_if_delete (ifp); | |
1433 | ||
1434 | p = NULL; | |
1435 | addr = NULL; | |
1436 | ifindex = 0; | |
1437 | ||
1438 | /* Lookup first IPv4 address entry. */ | |
1eb8ef25 | 1439 | for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, ifc)) |
718e3744 | 1440 | { |
3fb9cd6e | 1441 | if (CONNECTED_POINTOPOINT_HOST(ifc)) |
718e3744 | 1442 | p = ifc->destination; |
1443 | else | |
1444 | p = ifc->address; | |
1445 | ||
1446 | if (p->family == AF_INET) | |
1447 | { | |
1448 | addr = &p->u.prefix4; | |
1449 | break; | |
1450 | } | |
1451 | } | |
1452 | if (! addr) | |
1453 | ifindex = ifp->ifindex; | |
1454 | ||
1455 | /* Add interface to the list. */ | |
1456 | pn = NULL; | |
1eb8ef25 | 1457 | for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif)) |
718e3744 | 1458 | { |
1459 | if (addr) | |
1460 | { | |
1461 | if (ntohl (osif->addr.s_addr) > ntohl (addr->s_addr)) | |
1462 | break; | |
1463 | } | |
1464 | else | |
1465 | { | |
1466 | /* Unnumbered interface. */ | |
1467 | if (osif->addr.s_addr != 0 || osif->ifindex > ifindex) | |
1468 | break; | |
1469 | } | |
1eb8ef25 | 1470 | pn = node; |
718e3744 | 1471 | } |
1472 | ||
1473 | osif = ospf_snmp_if_new (); | |
1474 | if (addr) | |
1475 | osif->addr = *addr; | |
1476 | else | |
1477 | osif->ifindex = ifindex; | |
1478 | osif->ifp = ifp; | |
1479 | ||
1480 | listnode_add_after (ospf_snmp_iflist, pn, osif); | |
1481 | } | |
1482 | ||
1483 | struct interface * | |
1484 | ospf_snmp_if_lookup (struct in_addr *ifaddr, unsigned int *ifindex) | |
1485 | { | |
1eb8ef25 | 1486 | struct listnode *node; |
718e3744 | 1487 | struct ospf_snmp_if *osif; |
1488 | ||
1eb8ef25 | 1489 | for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, node, osif)) |
718e3744 | 1490 | { |
1491 | if (ifaddr->s_addr) | |
1492 | { | |
1493 | if (IPV4_ADDR_SAME (&osif->addr, ifaddr)) | |
1494 | return osif->ifp; | |
1495 | } | |
1496 | else | |
1497 | { | |
1498 | if (osif->ifindex == *ifindex) | |
1499 | return osif->ifp; | |
1500 | } | |
1501 | } | |
1502 | return NULL; | |
1503 | } | |
1504 | ||
1505 | struct interface * | |
1506 | ospf_snmp_if_lookup_next (struct in_addr *ifaddr, unsigned int *ifindex, | |
1507 | int ifaddr_next, int ifindex_next) | |
1508 | { | |
1509 | struct ospf_snmp_if *osif; | |
1510 | struct listnode *nn; | |
1511 | ||
1512 | if (ifaddr_next) | |
1513 | { | |
1514 | nn = listhead (ospf_snmp_iflist); | |
1515 | if (nn) | |
1516 | { | |
1eb8ef25 | 1517 | osif = listgetdata (nn); |
718e3744 | 1518 | *ifaddr = osif->addr; |
1519 | *ifindex = osif->ifindex; | |
1520 | return osif->ifp; | |
1521 | } | |
1522 | return NULL; | |
1523 | } | |
1524 | ||
1eb8ef25 | 1525 | for (ALL_LIST_ELEMENTS_RO (ospf_snmp_iflist, nn, osif)) |
718e3744 | 1526 | { |
1527 | if (ifaddr->s_addr) | |
1528 | { | |
1529 | if (ntohl (osif->addr.s_addr) > ntohl (ifaddr->s_addr)) | |
1530 | { | |
1531 | *ifaddr = osif->addr; | |
1532 | *ifindex = osif->ifindex; | |
1533 | return osif->ifp; | |
1534 | } | |
1535 | } | |
1536 | else | |
1537 | { | |
1538 | if (osif->ifindex > *ifindex || osif->addr.s_addr) | |
1539 | { | |
1540 | *ifaddr = osif->addr; | |
1541 | *ifindex = osif->ifindex; | |
1542 | return osif->ifp; | |
1543 | } | |
1544 | } | |
1545 | } | |
1546 | return NULL; | |
1547 | } | |
1548 | ||
1549 | int | |
1550 | ospf_snmp_iftype (struct interface *ifp) | |
1551 | { | |
1552 | #define ospf_snmp_iftype_broadcast 1 | |
1553 | #define ospf_snmp_iftype_nbma 2 | |
1554 | #define ospf_snmp_iftype_pointToPoint 3 | |
1555 | #define ospf_snmp_iftype_pointToMultipoint 5 | |
1556 | if (if_is_broadcast (ifp)) | |
1557 | return ospf_snmp_iftype_broadcast; | |
1558 | if (if_is_pointopoint (ifp)) | |
1559 | return ospf_snmp_iftype_pointToPoint; | |
1560 | return ospf_snmp_iftype_broadcast; | |
1561 | } | |
1562 | ||
1563 | struct interface * | |
1564 | ospfIfLookup (struct variable *v, oid *name, size_t *length, | |
1565 | struct in_addr *ifaddr, unsigned int *ifindex, int exact) | |
1566 | { | |
6c835671 | 1567 | unsigned int len; |
718e3744 | 1568 | int ifaddr_next = 0; |
1569 | int ifindex_next = 0; | |
1570 | struct interface *ifp; | |
1571 | oid *offset; | |
1572 | ||
1573 | if (exact) | |
1574 | { | |
1575 | if (*length != v->namelen + IN_ADDR_SIZE + 1) | |
1576 | return NULL; | |
1577 | ||
1578 | oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr); | |
1579 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
1580 | ||
1581 | return ospf_snmp_if_lookup (ifaddr, ifindex); | |
1582 | } | |
1583 | else | |
1584 | { | |
1585 | len = *length - v->namelen; | |
1586 | if (len >= IN_ADDR_SIZE) | |
1587 | len = IN_ADDR_SIZE; | |
1588 | if (len <= 0) | |
1589 | ifaddr_next = 1; | |
1590 | ||
1591 | oid2in_addr (name + v->namelen, len, ifaddr); | |
1592 | ||
1593 | len = *length - v->namelen - IN_ADDR_SIZE; | |
1594 | if (len >= 1) | |
1595 | len = 1; | |
1596 | else | |
1597 | ifindex_next = 1; | |
1598 | ||
1599 | if (len == 1) | |
1600 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
1601 | ||
1602 | ifp = ospf_snmp_if_lookup_next (ifaddr, ifindex, ifaddr_next, | |
1603 | ifindex_next); | |
1604 | if (ifp) | |
1605 | { | |
1606 | *length = v->namelen + IN_ADDR_SIZE + 1; | |
1607 | offset = name + v->namelen; | |
1608 | oid_copy_addr (offset, ifaddr, IN_ADDR_SIZE); | |
1609 | offset += IN_ADDR_SIZE; | |
1610 | *offset = *ifindex; | |
1611 | return ifp; | |
1612 | } | |
1613 | } | |
1614 | return NULL; | |
1615 | } | |
1616 | ||
1617 | static u_char * | |
1618 | ospfIfEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1619 | size_t *var_len, WriteMethod **write_method) | |
1620 | { | |
1621 | struct interface *ifp; | |
1622 | unsigned int ifindex; | |
1623 | struct in_addr ifaddr; | |
1624 | struct ospf_interface *oi; | |
020709f9 | 1625 | struct ospf *ospf; |
718e3744 | 1626 | |
1627 | ifindex = 0; | |
1628 | memset (&ifaddr, 0, sizeof (struct in_addr)); | |
1629 | ||
1630 | /* Check OSPF instance. */ | |
020709f9 | 1631 | ospf = ospf_lookup (); |
68980084 | 1632 | if (ospf == NULL) |
718e3744 | 1633 | return NULL; |
1634 | ||
1635 | ifp = ospfIfLookup (v, name, length, &ifaddr, &ifindex, exact); | |
1636 | if (ifp == NULL) | |
1637 | return NULL; | |
1638 | ||
68980084 | 1639 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr); |
718e3744 | 1640 | if (oi == NULL) |
1641 | return NULL; | |
1642 | ||
1643 | /* Return the current value of the variable */ | |
1644 | switch (v->magic) | |
1645 | { | |
1646 | case OSPFIFIPADDRESS: /* 1 */ | |
1647 | return SNMP_IPADDRESS (ifaddr); | |
1648 | break; | |
1649 | case OSPFADDRESSLESSIF: /* 2 */ | |
1650 | return SNMP_INTEGER (ifindex); | |
1651 | break; | |
1652 | case OSPFIFAREAID: /* 3 */ | |
1653 | if (oi->area) | |
1654 | return SNMP_IPADDRESS (oi->area->area_id); | |
1655 | else | |
1656 | return SNMP_IPADDRESS (ospf_empty_addr); | |
1657 | break; | |
1658 | case OSPFIFTYPE: /* 4 */ | |
1659 | return SNMP_INTEGER (ospf_snmp_iftype (ifp)); | |
1660 | break; | |
1661 | case OSPFIFADMINSTAT: /* 5 */ | |
1662 | if (oi) | |
1663 | return SNMP_INTEGER (OSPF_STATUS_ENABLED); | |
1664 | else | |
1665 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); | |
1666 | break; | |
1667 | case OSPFIFRTRPRIORITY: /* 6 */ | |
1668 | return SNMP_INTEGER (PRIORITY (oi)); | |
1669 | break; | |
1670 | case OSPFIFTRANSITDELAY: /* 7 */ | |
1671 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, transmit_delay)); | |
1672 | break; | |
1673 | case OSPFIFRETRANSINTERVAL: /* 8 */ | |
1674 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, retransmit_interval)); | |
1675 | break; | |
1676 | case OSPFIFHELLOINTERVAL: /* 9 */ | |
1677 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_hello)); | |
1678 | break; | |
1679 | case OSPFIFRTRDEADINTERVAL: /* 10 */ | |
1680 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_wait)); | |
1681 | break; | |
1682 | case OSPFIFPOLLINTERVAL: /* 11 */ | |
1683 | return SNMP_INTEGER (OSPF_POLL_INTERVAL_DEFAULT); | |
1684 | break; | |
1685 | case OSPFIFSTATE: /* 12 */ | |
ba682537 | 1686 | return SNMP_INTEGER (ISM_SNMP(oi->state)); |
718e3744 | 1687 | break; |
1688 | case OSPFIFDESIGNATEDROUTER: /* 13 */ | |
1689 | return SNMP_IPADDRESS (DR (oi)); | |
1690 | break; | |
1691 | case OSPFIFBACKUPDESIGNATEDROUTER: /* 14 */ | |
1692 | return SNMP_IPADDRESS (BDR (oi)); | |
1693 | break; | |
1694 | case OSPFIFEVENTS: /* 15 */ | |
1695 | return SNMP_INTEGER (oi->state_change); | |
1696 | break; | |
1697 | case OSPFIFAUTHKEY: /* 16 */ | |
1698 | *var_len = 0; | |
1699 | return (u_char *) OSPF_IF_PARAM (oi, auth_simple); | |
1700 | break; | |
1701 | case OSPFIFSTATUS: /* 17 */ | |
1702 | return SNMP_INTEGER (SNMP_VALID); | |
1703 | break; | |
1704 | case OSPFIFMULTICASTFORWARDING: /* 18 */ | |
1705 | #define ospf_snmp_multiforward_blocked 1 | |
1706 | #define ospf_snmp_multiforward_multicast 2 | |
1707 | #define ospf_snmp_multiforward_unicast 3 | |
1708 | return SNMP_INTEGER (ospf_snmp_multiforward_blocked); | |
1709 | break; | |
1710 | case OSPFIFDEMAND: /* 19 */ | |
1711 | return SNMP_INTEGER (SNMP_FALSE); | |
1712 | break; | |
1713 | case OSPFIFAUTHTYPE: /* 20 */ | |
1714 | if (oi->area) | |
1715 | return SNMP_INTEGER (oi->area->auth_type); | |
1716 | else | |
1717 | return SNMP_INTEGER (0); | |
1718 | break; | |
1719 | default: | |
1720 | return NULL; | |
1721 | break; | |
1722 | } | |
1723 | return NULL; | |
1724 | } | |
1725 | ||
1726 | #define OSPF_SNMP_METRIC_VALUE 1 | |
1727 | ||
1728 | struct interface * | |
1729 | ospfIfMetricLookup (struct variable *v, oid *name, size_t *length, | |
1730 | struct in_addr *ifaddr, unsigned int *ifindex, int exact) | |
1731 | { | |
6c835671 | 1732 | unsigned int len; |
718e3744 | 1733 | int ifaddr_next = 0; |
1734 | int ifindex_next = 0; | |
1735 | struct interface *ifp; | |
1736 | oid *offset; | |
1737 | int metric; | |
1738 | ||
1739 | if (exact) | |
1740 | { | |
1741 | if (*length != v->namelen + IN_ADDR_SIZE + 1 + 1) | |
1742 | return NULL; | |
1743 | ||
1744 | oid2in_addr (name + v->namelen, IN_ADDR_SIZE, ifaddr); | |
1745 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
1746 | metric = name[v->namelen + IN_ADDR_SIZE + 1]; | |
1747 | ||
1748 | if (metric != OSPF_SNMP_METRIC_VALUE) | |
1749 | return NULL; | |
1750 | ||
1751 | return ospf_snmp_if_lookup (ifaddr, ifindex); | |
1752 | } | |
1753 | else | |
1754 | { | |
1755 | len = *length - v->namelen; | |
1756 | if (len >= IN_ADDR_SIZE) | |
1757 | len = IN_ADDR_SIZE; | |
1758 | else | |
1759 | ifaddr_next = 1; | |
1760 | ||
1761 | oid2in_addr (name + v->namelen, len, ifaddr); | |
1762 | ||
1763 | len = *length - v->namelen - IN_ADDR_SIZE; | |
1764 | if (len >= 1) | |
1765 | len = 1; | |
1766 | else | |
1767 | ifindex_next = 1; | |
1768 | ||
1769 | if (len == 1) | |
1770 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
1771 | ||
1772 | ifp = ospf_snmp_if_lookup_next (ifaddr, ifindex, ifaddr_next, | |
1773 | ifindex_next); | |
1774 | if (ifp) | |
1775 | { | |
1776 | *length = v->namelen + IN_ADDR_SIZE + 1 + 1; | |
1777 | offset = name + v->namelen; | |
1778 | oid_copy_addr (offset, ifaddr, IN_ADDR_SIZE); | |
1779 | offset += IN_ADDR_SIZE; | |
1780 | *offset = *ifindex; | |
1781 | offset++; | |
1782 | *offset = OSPF_SNMP_METRIC_VALUE; | |
1783 | return ifp; | |
1784 | } | |
1785 | } | |
1786 | return NULL; | |
1787 | } | |
1788 | ||
1789 | static u_char * | |
1790 | ospfIfMetricEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1791 | size_t *var_len, WriteMethod **write_method) | |
1792 | { | |
1793 | /* Currently we support metric 1 only. */ | |
1794 | struct interface *ifp; | |
1795 | unsigned int ifindex; | |
1796 | struct in_addr ifaddr; | |
1797 | struct ospf_interface *oi; | |
020709f9 | 1798 | struct ospf *ospf; |
718e3744 | 1799 | |
1800 | ifindex = 0; | |
1801 | memset (&ifaddr, 0, sizeof (struct in_addr)); | |
1802 | ||
1803 | /* Check OSPF instance. */ | |
020709f9 | 1804 | ospf = ospf_lookup (); |
68980084 | 1805 | if (ospf == NULL) |
718e3744 | 1806 | return NULL; |
1807 | ||
1808 | ifp = ospfIfMetricLookup (v, name, length, &ifaddr, &ifindex, exact); | |
1809 | if (ifp == NULL) | |
1810 | return NULL; | |
1811 | ||
68980084 | 1812 | oi = ospf_if_lookup_by_local_addr (ospf, ifp, ifaddr); |
718e3744 | 1813 | if (oi == NULL) |
1814 | return NULL; | |
1815 | ||
1816 | /* Return the current value of the variable */ | |
1817 | switch (v->magic) | |
1818 | { | |
1819 | case OSPFIFMETRICIPADDRESS: | |
1820 | return SNMP_IPADDRESS (ifaddr); | |
1821 | break; | |
1822 | case OSPFIFMETRICADDRESSLESSIF: | |
1823 | return SNMP_INTEGER (ifindex); | |
1824 | break; | |
1825 | case OSPFIFMETRICTOS: | |
1826 | return SNMP_INTEGER (0); | |
1827 | break; | |
1828 | case OSPFIFMETRICVALUE: | |
1829 | return SNMP_INTEGER (OSPF_SNMP_METRIC_VALUE); | |
1830 | break; | |
1831 | case OSPFIFMETRICSTATUS: | |
1832 | return SNMP_INTEGER (1); | |
1833 | break; | |
1834 | default: | |
1835 | return NULL; | |
1836 | break; | |
1837 | } | |
1838 | return NULL; | |
1839 | } | |
1840 | \f | |
1841 | struct route_table *ospf_snmp_vl_table; | |
1842 | ||
1843 | void | |
1844 | ospf_snmp_vl_add (struct ospf_vl_data *vl_data) | |
1845 | { | |
1846 | struct prefix_ls lp; | |
1847 | struct route_node *rn; | |
1848 | ||
1849 | memset (&lp, 0, sizeof (struct prefix_ls)); | |
1850 | lp.family = 0; | |
1851 | lp.prefixlen = 64; | |
1852 | lp.id = vl_data->vl_area_id; | |
1853 | lp.adv_router = vl_data->vl_peer; | |
1854 | ||
1855 | rn = route_node_get (ospf_snmp_vl_table, (struct prefix *) &lp); | |
1856 | rn->info = vl_data; | |
1857 | } | |
1858 | ||
1859 | void | |
1860 | ospf_snmp_vl_delete (struct ospf_vl_data *vl_data) | |
1861 | { | |
1862 | struct prefix_ls lp; | |
1863 | struct route_node *rn; | |
1864 | ||
1865 | memset (&lp, 0, sizeof (struct prefix_ls)); | |
1866 | lp.family = 0; | |
1867 | lp.prefixlen = 64; | |
1868 | lp.id = vl_data->vl_area_id; | |
1869 | lp.adv_router = vl_data->vl_peer; | |
1870 | ||
1871 | rn = route_node_lookup (ospf_snmp_vl_table, (struct prefix *) &lp); | |
1872 | if (! rn) | |
1873 | return; | |
1874 | rn->info = NULL; | |
1875 | route_unlock_node (rn); | |
1876 | route_unlock_node (rn); | |
1877 | } | |
1878 | ||
1879 | struct ospf_vl_data * | |
1880 | ospf_snmp_vl_lookup (struct in_addr *area_id, struct in_addr *neighbor) | |
1881 | { | |
1882 | struct prefix_ls lp; | |
1883 | struct route_node *rn; | |
1884 | struct ospf_vl_data *vl_data; | |
1885 | ||
1886 | memset (&lp, 0, sizeof (struct prefix_ls)); | |
1887 | lp.family = 0; | |
1888 | lp.prefixlen = 64; | |
1889 | lp.id = *area_id; | |
1890 | lp.adv_router = *neighbor; | |
1891 | ||
1892 | rn = route_node_lookup (ospf_snmp_vl_table, (struct prefix *) &lp); | |
1893 | if (rn) | |
1894 | { | |
1895 | vl_data = rn->info; | |
1896 | route_unlock_node (rn); | |
1897 | return vl_data; | |
1898 | } | |
1899 | return NULL; | |
1900 | } | |
1901 | ||
1902 | struct ospf_vl_data * | |
1903 | ospf_snmp_vl_lookup_next (struct in_addr *area_id, struct in_addr *neighbor, | |
1904 | int first) | |
1905 | { | |
1906 | struct prefix_ls lp; | |
1907 | struct route_node *rn; | |
1908 | struct ospf_vl_data *vl_data; | |
1909 | ||
1910 | memset (&lp, 0, sizeof (struct prefix_ls)); | |
1911 | lp.family = 0; | |
1912 | lp.prefixlen = 64; | |
1913 | lp.id = *area_id; | |
1914 | lp.adv_router = *neighbor; | |
1915 | ||
1916 | if (first) | |
1917 | rn = route_top (ospf_snmp_vl_table); | |
1918 | else | |
1919 | { | |
1920 | rn = route_node_get (ospf_snmp_vl_table, (struct prefix *) &lp); | |
1921 | rn = route_next (rn); | |
1922 | } | |
1923 | ||
1924 | for (; rn; rn = route_next (rn)) | |
1925 | if (rn->info) | |
1926 | break; | |
1927 | ||
1928 | if (rn && rn->info) | |
1929 | { | |
1930 | vl_data = rn->info; | |
1931 | *area_id = vl_data->vl_area_id; | |
1932 | *neighbor = vl_data->vl_peer; | |
1933 | route_unlock_node (rn); | |
1934 | return vl_data; | |
1935 | } | |
1936 | return NULL; | |
1937 | } | |
1938 | ||
1939 | struct ospf_vl_data * | |
1940 | ospfVirtIfLookup (struct variable *v, oid *name, size_t *length, | |
1941 | struct in_addr *area_id, struct in_addr *neighbor, int exact) | |
1942 | { | |
1943 | int first; | |
6c835671 | 1944 | unsigned int len; |
718e3744 | 1945 | struct ospf_vl_data *vl_data; |
1946 | ||
1947 | if (exact) | |
1948 | { | |
1949 | if (*length != v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE) | |
1950 | return NULL; | |
1951 | ||
1952 | oid2in_addr (name + v->namelen, IN_ADDR_SIZE, area_id); | |
1953 | oid2in_addr (name + v->namelen + IN_ADDR_SIZE, IN_ADDR_SIZE, neighbor); | |
1954 | ||
1955 | return ospf_snmp_vl_lookup (area_id, neighbor); | |
1956 | } | |
1957 | else | |
1958 | { | |
1959 | first = 0; | |
1960 | ||
1961 | len = *length - v->namelen; | |
1962 | if (len <= 0) | |
1963 | first = 1; | |
1964 | if (len > IN_ADDR_SIZE) | |
1965 | len = IN_ADDR_SIZE; | |
1966 | oid2in_addr (name + v->namelen, len, area_id); | |
1967 | ||
1968 | len = *length - v->namelen - IN_ADDR_SIZE; | |
1969 | if (len > IN_ADDR_SIZE) | |
1970 | len = IN_ADDR_SIZE; | |
1971 | oid2in_addr (name + v->namelen + IN_ADDR_SIZE, len, neighbor); | |
1972 | ||
1973 | vl_data = ospf_snmp_vl_lookup_next (area_id, neighbor, first); | |
1974 | ||
1975 | if (vl_data) | |
1976 | { | |
1977 | *length = v->namelen + IN_ADDR_SIZE + IN_ADDR_SIZE; | |
1978 | oid_copy_addr (name + v->namelen, area_id, IN_ADDR_SIZE); | |
1979 | oid_copy_addr (name + v->namelen + IN_ADDR_SIZE, neighbor, | |
1980 | IN_ADDR_SIZE); | |
1981 | return vl_data; | |
1982 | } | |
1983 | } | |
1984 | return NULL; | |
1985 | } | |
1986 | ||
1987 | static u_char * | |
1988 | ospfVirtIfEntry (struct variable *v, oid *name, size_t *length, int exact, | |
1989 | size_t *var_len, WriteMethod **write_method) | |
1990 | { | |
1991 | struct ospf_vl_data *vl_data; | |
1992 | struct ospf_interface *oi; | |
1993 | struct in_addr area_id; | |
1994 | struct in_addr neighbor; | |
1995 | ||
1996 | memset (&area_id, 0, sizeof (struct in_addr)); | |
1997 | memset (&neighbor, 0, sizeof (struct in_addr)); | |
1998 | ||
1999 | vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact); | |
2000 | if (! vl_data) | |
2001 | return NULL; | |
2002 | oi = vl_data->vl_oi; | |
2003 | if (! oi) | |
2004 | return NULL; | |
2005 | ||
2006 | /* Return the current value of the variable */ | |
2007 | switch (v->magic) | |
2008 | { | |
2009 | case OSPFVIRTIFAREAID: | |
2010 | return SNMP_IPADDRESS (area_id); | |
2011 | break; | |
2012 | case OSPFVIRTIFNEIGHBOR: | |
2013 | return SNMP_IPADDRESS (neighbor); | |
2014 | break; | |
2015 | case OSPFVIRTIFTRANSITDELAY: | |
2016 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, transmit_delay)); | |
2017 | break; | |
2018 | case OSPFVIRTIFRETRANSINTERVAL: | |
2019 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, retransmit_interval)); | |
2020 | break; | |
2021 | case OSPFVIRTIFHELLOINTERVAL: | |
2022 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_hello)); | |
2023 | break; | |
2024 | case OSPFVIRTIFRTRDEADINTERVAL: | |
2025 | return SNMP_INTEGER (OSPF_IF_PARAM (oi, v_wait)); | |
2026 | break; | |
2027 | case OSPFVIRTIFSTATE: | |
2028 | return SNMP_INTEGER (oi->state); | |
2029 | break; | |
2030 | case OSPFVIRTIFEVENTS: | |
2031 | return SNMP_INTEGER (oi->state_change); | |
2032 | break; | |
2033 | case OSPFVIRTIFAUTHKEY: | |
2034 | *var_len = 0; | |
2035 | return (u_char *) OSPF_IF_PARAM (oi, auth_simple); | |
2036 | break; | |
2037 | case OSPFVIRTIFSTATUS: | |
2038 | return SNMP_INTEGER (SNMP_VALID); | |
2039 | break; | |
2040 | case OSPFVIRTIFAUTHTYPE: | |
2041 | if (oi->area) | |
2042 | return SNMP_INTEGER (oi->area->auth_type); | |
2043 | else | |
2044 | return SNMP_INTEGER (0); | |
2045 | break; | |
2046 | default: | |
2047 | return NULL; | |
2048 | break; | |
2049 | } | |
2050 | return NULL; | |
2051 | } | |
2052 | \f | |
2053 | struct ospf_neighbor * | |
68980084 | 2054 | ospf_snmp_nbr_lookup (struct ospf *ospf, struct in_addr *nbr_addr, |
2055 | unsigned int *ifindex) | |
718e3744 | 2056 | { |
1eb8ef25 | 2057 | struct listnode *node, *nnode; |
718e3744 | 2058 | struct ospf_interface *oi; |
2059 | struct ospf_neighbor *nbr; | |
2060 | struct route_node *rn; | |
2061 | ||
1eb8ef25 | 2062 | for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi)) |
718e3744 | 2063 | { |
2064 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
2065 | if ((nbr = rn->info) != NULL | |
2066 | && nbr != oi->nbr_self | |
5e4914c3 | 2067 | /* If EXACT match is needed, provide ALL entry found |
718e3744 | 2068 | && nbr->state != NSM_Down |
5e4914c3 | 2069 | */ |
718e3744 | 2070 | && nbr->src.s_addr != 0) |
2071 | { | |
2072 | if (IPV4_ADDR_SAME (&nbr->src, nbr_addr)) | |
2073 | { | |
2074 | route_unlock_node (rn); | |
2075 | return nbr; | |
2076 | } | |
2077 | } | |
2078 | } | |
2079 | return NULL; | |
2080 | } | |
2081 | ||
2082 | struct ospf_neighbor * | |
2083 | ospf_snmp_nbr_lookup_next (struct in_addr *nbr_addr, unsigned int *ifindex, | |
2084 | int first) | |
2085 | { | |
2086 | struct listnode *nn; | |
2087 | struct ospf_interface *oi; | |
2088 | struct ospf_neighbor *nbr; | |
2089 | struct route_node *rn; | |
2090 | struct ospf_neighbor *min = NULL; | |
020709f9 | 2091 | struct ospf *ospf = ospf; |
718e3744 | 2092 | |
020709f9 | 2093 | ospf = ospf_lookup (); |
1eb8ef25 | 2094 | |
2095 | for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, nn, oi)) | |
718e3744 | 2096 | { |
2097 | for (rn = route_top (oi->nbrs); rn; rn = route_next (rn)) | |
2098 | if ((nbr = rn->info) != NULL | |
2099 | && nbr != oi->nbr_self | |
2100 | && nbr->state != NSM_Down | |
2101 | && nbr->src.s_addr != 0) | |
2102 | { | |
2103 | if (first) | |
2104 | { | |
2105 | if (! min) | |
2106 | min = nbr; | |
2107 | else if (ntohl (nbr->src.s_addr) < ntohl (min->src.s_addr)) | |
2108 | min = nbr; | |
2109 | } | |
2110 | else if (ntohl (nbr->src.s_addr) > ntohl (nbr_addr->s_addr)) | |
2111 | { | |
2112 | if (! min) | |
2113 | min = nbr; | |
2114 | else if (ntohl (nbr->src.s_addr) < ntohl (min->src.s_addr)) | |
2115 | min = nbr; | |
2116 | } | |
2117 | } | |
2118 | } | |
2119 | if (min) | |
2120 | { | |
2121 | *nbr_addr = min->src; | |
2122 | *ifindex = 0; | |
2123 | return min; | |
2124 | } | |
2125 | return NULL; | |
2126 | } | |
2127 | ||
2128 | struct ospf_neighbor * | |
2129 | ospfNbrLookup (struct variable *v, oid *name, size_t *length, | |
2130 | struct in_addr *nbr_addr, unsigned int *ifindex, int exact) | |
2131 | { | |
6c835671 | 2132 | unsigned int len; |
718e3744 | 2133 | int first; |
2134 | struct ospf_neighbor *nbr; | |
020709f9 | 2135 | struct ospf *ospf; |
2136 | ||
2137 | ospf = ospf_lookup (); | |
718e3744 | 2138 | |
1b639047 | 2139 | if (! ospf) |
2140 | return NULL; | |
2141 | ||
718e3744 | 2142 | if (exact) |
2143 | { | |
2144 | if (*length != v->namelen + IN_ADDR_SIZE + 1) | |
2145 | return NULL; | |
2146 | ||
2147 | oid2in_addr (name + v->namelen, IN_ADDR_SIZE, nbr_addr); | |
2148 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
2149 | ||
68980084 | 2150 | return ospf_snmp_nbr_lookup (ospf, nbr_addr, ifindex); |
718e3744 | 2151 | } |
2152 | else | |
2153 | { | |
2154 | first = 0; | |
2155 | len = *length - v->namelen; | |
2156 | ||
2157 | if (len <= 0) | |
2158 | first = 1; | |
2159 | ||
2160 | if (len > IN_ADDR_SIZE) | |
2161 | len = IN_ADDR_SIZE; | |
2162 | ||
2163 | oid2in_addr (name + v->namelen, len, nbr_addr); | |
2164 | ||
2165 | len = *length - v->namelen - IN_ADDR_SIZE; | |
2166 | if (len >= 1) | |
2167 | *ifindex = name[v->namelen + IN_ADDR_SIZE]; | |
2168 | ||
2169 | nbr = ospf_snmp_nbr_lookup_next (nbr_addr, ifindex, first); | |
2170 | ||
2171 | if (nbr) | |
2172 | { | |
2173 | *length = v->namelen + IN_ADDR_SIZE + 1; | |
2174 | oid_copy_addr (name + v->namelen, nbr_addr, IN_ADDR_SIZE); | |
2175 | name[v->namelen + IN_ADDR_SIZE] = *ifindex; | |
2176 | return nbr; | |
2177 | } | |
2178 | } | |
2179 | return NULL; | |
2180 | } | |
2181 | ||
2182 | static u_char * | |
2183 | ospfNbrEntry (struct variable *v, oid *name, size_t *length, int exact, | |
2184 | size_t *var_len, WriteMethod **write_method) | |
2185 | { | |
2186 | struct in_addr nbr_addr; | |
2187 | unsigned int ifindex; | |
2188 | struct ospf_neighbor *nbr; | |
2189 | struct ospf_interface *oi; | |
2190 | ||
2191 | memset (&nbr_addr, 0, sizeof (struct in_addr)); | |
2192 | ifindex = 0; | |
2193 | ||
2194 | nbr = ospfNbrLookup (v, name, length, &nbr_addr, &ifindex, exact); | |
2195 | if (! nbr) | |
2196 | return NULL; | |
2197 | oi = nbr->oi; | |
2198 | if (! oi) | |
2199 | return NULL; | |
2200 | ||
2201 | /* Return the current value of the variable */ | |
2202 | switch (v->magic) | |
2203 | { | |
2204 | case OSPFNBRIPADDR: | |
2205 | return SNMP_IPADDRESS (nbr_addr); | |
2206 | break; | |
2207 | case OSPFNBRADDRESSLESSINDEX: | |
2208 | return SNMP_INTEGER (ifindex); | |
2209 | break; | |
2210 | case OSPFNBRRTRID: | |
2211 | return SNMP_IPADDRESS (nbr->router_id); | |
2212 | break; | |
2213 | case OSPFNBROPTIONS: | |
2214 | return SNMP_INTEGER (oi->nbr_self->options); | |
2215 | break; | |
2216 | case OSPFNBRPRIORITY: | |
2217 | return SNMP_INTEGER (nbr->priority); | |
2218 | break; | |
2219 | case OSPFNBRSTATE: | |
2220 | return SNMP_INTEGER (nbr->state); | |
2221 | break; | |
2222 | case OSPFNBREVENTS: | |
2223 | return SNMP_INTEGER (nbr->state_change); | |
2224 | break; | |
2225 | case OSPFNBRLSRETRANSQLEN: | |
2226 | return SNMP_INTEGER (ospf_ls_retransmit_count (nbr)); | |
2227 | break; | |
2228 | case OSPFNBMANBRSTATUS: | |
2229 | return SNMP_INTEGER (SNMP_VALID); | |
2230 | break; | |
2231 | case OSPFNBMANBRPERMANENCE: | |
2232 | return SNMP_INTEGER (2); | |
2233 | break; | |
2234 | case OSPFNBRHELLOSUPPRESSED: | |
2235 | return SNMP_INTEGER (SNMP_FALSE); | |
2236 | break; | |
2237 | default: | |
2238 | return NULL; | |
2239 | break; | |
2240 | } | |
2241 | return NULL; | |
2242 | } | |
2243 | \f | |
2244 | static u_char * | |
2245 | ospfVirtNbrEntry (struct variable *v, oid *name, size_t *length, int exact, | |
2246 | size_t *var_len, WriteMethod **write_method) | |
2247 | { | |
2248 | struct ospf_vl_data *vl_data; | |
2249 | struct in_addr area_id; | |
2250 | struct in_addr neighbor; | |
020709f9 | 2251 | struct ospf *ospf; |
718e3744 | 2252 | |
2253 | memset (&area_id, 0, sizeof (struct in_addr)); | |
2254 | memset (&neighbor, 0, sizeof (struct in_addr)); | |
2255 | ||
2256 | /* Check OSPF instance. */ | |
020709f9 | 2257 | ospf = ospf_lookup (); |
68980084 | 2258 | if (ospf == NULL) |
718e3744 | 2259 | return NULL; |
2260 | ||
2261 | vl_data = ospfVirtIfLookup (v, name, length, &area_id, &neighbor, exact); | |
2262 | if (! vl_data) | |
2263 | return NULL; | |
2264 | ||
2265 | /* Return the current value of the variable */ | |
2266 | switch (v->magic) | |
2267 | { | |
2268 | case OSPFVIRTNBRAREA: | |
2269 | return (u_char *) NULL; | |
2270 | break; | |
2271 | case OSPFVIRTNBRRTRID: | |
2272 | return (u_char *) NULL; | |
2273 | break; | |
2274 | case OSPFVIRTNBRIPADDR: | |
2275 | return (u_char *) NULL; | |
2276 | break; | |
2277 | case OSPFVIRTNBROPTIONS: | |
2278 | return (u_char *) NULL; | |
2279 | break; | |
2280 | case OSPFVIRTNBRSTATE: | |
2281 | return (u_char *) NULL; | |
2282 | break; | |
2283 | case OSPFVIRTNBREVENTS: | |
2284 | return (u_char *) NULL; | |
2285 | break; | |
2286 | case OSPFVIRTNBRLSRETRANSQLEN: | |
2287 | return (u_char *) NULL; | |
2288 | break; | |
2289 | case OSPFVIRTNBRHELLOSUPPRESSED: | |
2290 | return (u_char *) NULL; | |
2291 | break; | |
2292 | default: | |
2293 | return NULL; | |
2294 | break; | |
2295 | } | |
2296 | return NULL; | |
2297 | } | |
2298 | \f | |
2299 | struct ospf_lsa * | |
2300 | ospfExtLsdbLookup (struct variable *v, oid *name, size_t *length, u_char *type, | |
2301 | struct in_addr *ls_id, struct in_addr *router_id, int exact) | |
2302 | { | |
2303 | int first; | |
2304 | oid *offset; | |
2305 | int offsetlen; | |
2306 | u_char lsa_type; | |
6c835671 | 2307 | unsigned int len; |
718e3744 | 2308 | struct ospf_lsa *lsa; |
020709f9 | 2309 | struct ospf *ospf; |
718e3744 | 2310 | |
020709f9 | 2311 | ospf = ospf_lookup (); |
718e3744 | 2312 | if (exact) |
2313 | { | |
2314 | if (*length != v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE) | |
2315 | return NULL; | |
2316 | ||
2317 | offset = name + v->namelen; | |
2318 | ||
2319 | /* Make it sure given value match to type. */ | |
2320 | lsa_type = *offset; | |
2321 | offset++; | |
2322 | ||
2323 | if (lsa_type != *type) | |
2324 | return NULL; | |
2325 | ||
2326 | /* LS ID. */ | |
2327 | oid2in_addr (offset, IN_ADDR_SIZE, ls_id); | |
2328 | offset += IN_ADDR_SIZE; | |
2329 | ||
2330 | /* Router ID. */ | |
2331 | oid2in_addr (offset, IN_ADDR_SIZE, router_id); | |
2332 | ||
68980084 | 2333 | return ospf_lsdb_lookup_by_id (ospf->lsdb, *type, *ls_id, *router_id); |
718e3744 | 2334 | } |
2335 | else | |
2336 | { | |
2337 | /* Get variable length. */ | |
2338 | first = 0; | |
2339 | offset = name + v->namelen; | |
2340 | offsetlen = *length - v->namelen; | |
2341 | ||
2342 | /* LSA type value. */ | |
2343 | lsa_type = *offset; | |
2344 | offset++; | |
2345 | offsetlen--; | |
2346 | ||
2347 | if (offsetlen <= 0 || lsa_type < OSPF_AS_EXTERNAL_LSA) | |
2348 | first = 1; | |
2349 | ||
2350 | /* LS ID. */ | |
2351 | len = offsetlen; | |
2352 | if (len > IN_ADDR_SIZE) | |
2353 | len = IN_ADDR_SIZE; | |
2354 | ||
2355 | oid2in_addr (offset, len, ls_id); | |
2356 | ||
2357 | offset += IN_ADDR_SIZE; | |
2358 | offsetlen -= IN_ADDR_SIZE; | |
2359 | ||
2360 | /* Router ID. */ | |
2361 | len = offsetlen; | |
2362 | if (len > IN_ADDR_SIZE) | |
2363 | len = IN_ADDR_SIZE; | |
2364 | ||
2365 | oid2in_addr (offset, len, router_id); | |
2366 | ||
68980084 | 2367 | lsa = ospf_lsdb_lookup_by_id_next (ospf->lsdb, *type, *ls_id, |
718e3744 | 2368 | *router_id, first); |
2369 | ||
2370 | if (lsa) | |
2371 | { | |
2372 | /* Fill in length. */ | |
2373 | *length = v->namelen + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE; | |
2374 | ||
2375 | /* Fill in value. */ | |
2376 | offset = name + v->namelen; | |
2377 | ||
2378 | *offset = OSPF_AS_EXTERNAL_LSA; | |
2379 | offset++; | |
2380 | oid_copy_addr (offset, &lsa->data->id, IN_ADDR_SIZE); | |
2381 | offset += IN_ADDR_SIZE; | |
2382 | oid_copy_addr (offset, &lsa->data->adv_router, IN_ADDR_SIZE); | |
2383 | ||
2384 | return lsa; | |
2385 | } | |
2386 | } | |
2387 | return NULL; | |
2388 | } | |
2389 | ||
2390 | static u_char * | |
2391 | ospfExtLsdbEntry (struct variable *v, oid *name, size_t *length, int exact, | |
2392 | size_t *var_len, WriteMethod **write_method) | |
2393 | { | |
2394 | struct ospf_lsa *lsa; | |
2395 | struct lsa_header *lsah; | |
2396 | u_char type; | |
2397 | struct in_addr ls_id; | |
2398 | struct in_addr router_id; | |
020709f9 | 2399 | struct ospf *ospf; |
718e3744 | 2400 | |
2401 | type = OSPF_AS_EXTERNAL_LSA; | |
2402 | memset (&ls_id, 0, sizeof (struct in_addr)); | |
2403 | memset (&router_id, 0, sizeof (struct in_addr)); | |
2404 | ||
2405 | /* Check OSPF instance. */ | |
020709f9 | 2406 | ospf = ospf_lookup (); |
68980084 | 2407 | if (ospf == NULL) |
718e3744 | 2408 | return NULL; |
2409 | ||
2410 | lsa = ospfExtLsdbLookup (v, name, length, &type, &ls_id, &router_id, exact); | |
2411 | if (! lsa) | |
2412 | return NULL; | |
2413 | ||
2414 | lsah = lsa->data; | |
2415 | ||
2416 | /* Return the current value of the variable */ | |
2417 | switch (v->magic) | |
2418 | { | |
2419 | case OSPFEXTLSDBTYPE: | |
2420 | return SNMP_INTEGER (OSPF_AS_EXTERNAL_LSA); | |
2421 | break; | |
2422 | case OSPFEXTLSDBLSID: | |
2423 | return SNMP_IPADDRESS (lsah->id); | |
2424 | break; | |
2425 | case OSPFEXTLSDBROUTERID: | |
2426 | return SNMP_IPADDRESS (lsah->adv_router); | |
2427 | break; | |
2428 | case OSPFEXTLSDBSEQUENCE: | |
2429 | return SNMP_INTEGER (lsah->ls_seqnum); | |
2430 | break; | |
2431 | case OSPFEXTLSDBAGE: | |
2432 | return SNMP_INTEGER (lsah->ls_age); | |
2433 | break; | |
2434 | case OSPFEXTLSDBCHECKSUM: | |
2435 | return SNMP_INTEGER (lsah->checksum); | |
2436 | break; | |
2437 | case OSPFEXTLSDBADVERTISEMENT: | |
2438 | *var_len = ntohs (lsah->length); | |
2439 | return (u_char *) lsah; | |
2440 | break; | |
2441 | default: | |
2442 | return NULL; | |
2443 | break; | |
2444 | } | |
2445 | return NULL; | |
2446 | } | |
2447 | \f | |
2448 | static u_char * | |
2449 | ospfAreaAggregateEntry (struct variable *v, oid *name, size_t *length, | |
2450 | int exact, size_t *var_len, WriteMethod **write_method) | |
2451 | { | |
2452 | /* Return the current value of the variable */ | |
2453 | switch (v->magic) | |
2454 | { | |
2455 | case OSPFAREAAGGREGATEAREAID: | |
2456 | return (u_char *) NULL; | |
2457 | break; | |
2458 | case OSPFAREAAGGREGATELSDBTYPE: | |
2459 | return (u_char *) NULL; | |
2460 | break; | |
2461 | case OSPFAREAAGGREGATENET: | |
2462 | return (u_char *) NULL; | |
2463 | break; | |
2464 | case OSPFAREAAGGREGATEMASK: | |
2465 | return (u_char *) NULL; | |
2466 | break; | |
2467 | case OSPFAREAAGGREGATESTATUS: | |
2468 | return (u_char *) NULL; | |
2469 | break; | |
2470 | case OSPFAREAAGGREGATEEFFECT: | |
2471 | return (u_char *) NULL; | |
2472 | break; | |
2473 | default: | |
2474 | return NULL; | |
2475 | break; | |
2476 | } | |
2477 | return NULL; | |
2478 | } | |
2479 | \f | |
5e4914c3 | 2480 | /* OSPF Traps. */ |
2481 | #define IFSTATECHANGE 16 | |
2482 | #define VIRTIFSTATECHANGE 1 | |
2483 | #define NBRSTATECHANGE 2 | |
2484 | #define VIRTNBRSTATECHANGE 3 | |
2485 | ||
2486 | struct trap_object ospfNbrTrapList[] = | |
2487 | { | |
2488 | {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | |
2489 | {ospfNbrEntry, 3, {10, 1, OSPFNBRIPADDR}}, | |
2490 | {ospfNbrEntry, 3, {10, 1, OSPFNBRRTRID}}, | |
2491 | {ospfNbrEntry, 3, {10, 1, OSPFNBRSTATE}} | |
2492 | }; | |
2493 | ||
2494 | ||
2495 | struct trap_object ospfVirtNbrTrapList[] = | |
2496 | { | |
2497 | {ospfGeneralGroup, -2, {1, 1}}, | |
2498 | {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRAREA}}, | |
2499 | {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRRTRID}}, | |
2500 | {ospfVirtNbrEntry, 3, {11, 1, OSPFVIRTNBRSTATE}} | |
2501 | }; | |
2502 | ||
2503 | struct trap_object ospfIfTrapList[] = | |
2504 | { | |
2505 | {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | |
2506 | {ospfIfEntry, 3, {7, 1, OSPFIFIPADDRESS}}, | |
2507 | {ospfIfEntry, 3, {7, 1, OSPFADDRESSLESSIF}}, | |
2508 | {ospfIfEntry, 3, {7, 1, OSPFIFSTATE}} | |
2509 | }; | |
2510 | ||
2511 | struct trap_object ospfVirtIfTrapList[] = | |
2512 | { | |
2513 | {ospfGeneralGroup, -2, {1, OSPFROUTERID}}, | |
2514 | {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFAREAID}}, | |
2515 | {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFNEIGHBOR}}, | |
2516 | {ospfVirtIfEntry, 3, {9, 1, OSPFVIRTIFSTATE}} | |
2517 | }; | |
2518 | ||
2519 | void | |
2520 | ospfTrapNbrStateChange (struct ospf_neighbor *on) | |
2521 | { | |
2522 | oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; | |
2523 | ||
2524 | zlog (NULL, LOG_INFO, "ospfTrapNbrStateChange trap sent"); | |
2525 | ||
2526 | oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); | |
2527 | index[IN_ADDR_SIZE] = 0; | |
2528 | ||
2529 | smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | |
2530 | index, IN_ADDR_SIZE + 1, | |
2531 | ospfNbrTrapList, | |
2532 | sizeof ospfNbrTrapList / sizeof (struct trap_object), | |
2533 | time (NULL), NBRSTATECHANGE); | |
2534 | } | |
2535 | ||
2536 | void | |
2537 | ospfTrapVirtNbrStateChange (struct ospf_neighbor *on) | |
2538 | { | |
2539 | oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; | |
2540 | ||
2541 | zlog (NULL, LOG_INFO, "ospfTrapVirtNbrStateChange trap sent"); | |
2542 | ||
2543 | oid_copy_addr (index, &(on->address.u.prefix4), IN_ADDR_SIZE); | |
2544 | index[IN_ADDR_SIZE] = 0; | |
2545 | ||
2546 | smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | |
2547 | index, IN_ADDR_SIZE + 1, | |
2548 | ospfVirtNbrTrapList, | |
2549 | sizeof ospfVirtNbrTrapList / sizeof (struct trap_object), | |
2550 | time (NULL), VIRTNBRSTATECHANGE); | |
2551 | } | |
2552 | ||
2553 | void | |
2554 | ospfTrapIfStateChange (struct ospf_interface *oi) | |
2555 | { | |
2556 | oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; | |
2557 | ||
2558 | zlog (NULL, LOG_INFO, "ospfTrapIfStateChange trap sent"); | |
2559 | ||
2560 | oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); | |
2561 | index[IN_ADDR_SIZE] = 0; | |
2562 | ||
2563 | smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | |
2564 | index, IN_ADDR_SIZE + 1, | |
2565 | ospfIfTrapList, | |
2566 | sizeof ospfIfTrapList / sizeof (struct trap_object), | |
2567 | time (NULL), IFSTATECHANGE); | |
2568 | } | |
2569 | ||
2570 | void | |
2571 | ospfTrapVirtIfStateChange (struct ospf_interface *oi) | |
2572 | { | |
2573 | oid index[sizeof (oid) * (IN_ADDR_SIZE + 1)]; | |
2574 | ||
2575 | zlog (NULL, LOG_INFO, "ospfTrapVirtIfStateChange trap sent"); | |
2576 | ||
2577 | oid_copy_addr (index, &(oi->address->u.prefix4), IN_ADDR_SIZE); | |
2578 | index[IN_ADDR_SIZE] = 0; | |
2579 | ||
2580 | smux_trap (ospf_oid, sizeof ospf_oid / sizeof (oid), | |
2581 | index, IN_ADDR_SIZE + 1, | |
2582 | ospfVirtIfTrapList, | |
2583 | sizeof ospfVirtIfTrapList / sizeof (struct trap_object), | |
2584 | time (NULL), VIRTIFSTATECHANGE); | |
2585 | } | |
718e3744 | 2586 | /* Register OSPF2-MIB. */ |
2587 | void | |
2588 | ospf_snmp_init () | |
2589 | { | |
2590 | ospf_snmp_iflist = list_new (); | |
2591 | ospf_snmp_vl_table = route_table_init (); | |
c75105ab | 2592 | smux_init (om->master); |
718e3744 | 2593 | REGISTER_MIB("mibII/ospf", ospf_variables, variable, ospf_oid); |
718e3744 | 2594 | } |
2595 | #endif /* HAVE_SNMP */ |