blob: 11b733b8cda0c6fb8126e3d1ad1467c2aaa2837a [file] [log] [blame]
hassoef1bbf52004-10-08 12:04:21 +00001/* 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
hassoef1bbf52004-10-08 12:04:21 +000026#include <net-snmp/net-snmp-config.h>
Joakim Tjernlundfb62a3c2008-05-13 20:03:32 +020027#include <net-snmp/net-snmp-includes.h>
hassoef1bbf52004-10-08 12:04:21 +000028
29#include "log.h"
30#include "vty.h"
31#include "linklist.h"
32#include "smux.h"
33
34#include "ospf6_proto.h"
35#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
37#include "ospf6_route.h"
38#include "ospf6_top.h"
39#include "ospf6_area.h"
40#include "ospf6_interface.h"
41#include "ospf6_message.h"
42#include "ospf6_neighbor.h"
43#include "ospf6d.h"
Chris Caputo0be8dfb2009-06-02 18:40:07 +010044#include "ospf6_snmp.h"
hassoef1bbf52004-10-08 12:04:21 +000045
46/* OSPFv3-MIB */
47#define OSPFv3MIB 1,3,6,1,3,102
48
hassoef1bbf52004-10-08 12:04:21 +000049/* OSPFv3 MIB General Group values. */
50#define OSPFv3ROUTERID 1
51#define OSPFv3ADMINSTAT 2
52#define OSPFv3VERSIONNUMBER 3
53#define OSPFv3AREABDRRTRSTATUS 4
54#define OSPFv3ASBDRRTRSTATUS 5
55#define OSPFv3ASSCOPELSACOUNT 6
56#define OSPFv3ASSCOPELSACHECKSUMSUM 7
57#define OSPFv3ORIGINATENEWLSAS 8
58#define OSPFv3RXNEWLSAS 9
59#define OSPFv3EXTLSACOUNT 10
60#define OSPFv3EXTAREALSDBLIMIT 11
61#define OSPFv3MULTICASTEXTENSIONS 12
62#define OSPFv3EXITOVERFLOWINTERVAL 13
63#define OSPFv3DEMANDEXTENSIONS 14
64#define OSPFv3TRAFFICENGINEERINGSUPPORT 15
65#define OSPFv3REFERENCEBANDWIDTH 16
66#define OSPFv3RESTARTSUPPORT 17
67#define OSPFv3RESTARTINTERVAL 18
68#define OSPFv3RESTARTSTATUS 19
69#define OSPFv3RESTARTAGE 20
70#define OSPFv3RESTARTEXITREASON 21
71
72/* OSPFv3 MIB Area Table values. */
73#define OSPFv3AREAID 1
74#define OSPFv3IMPORTASEXTERN 2
hasso2680aa22004-11-25 20:54:46 +000075#define OSPFv3AREASPFRUNS 3
76#define OSPFv3AREABDRRTRCOUNT 4
77#define OSPFv3AREAASBDRRTRCOUNT 5
78#define OSPFv3AREASCOPELSACOUNT 6
79#define OSPFv3AREASCOPELSACKSUMSUM 7
80#define OSPFv3AREASUMMARY 8
81#define OSPFv3AREASTATUS 9
82#define OSPFv3STUBMETRIC 10
83#define OSPFv3AREANSSATRANSLATORROLE 11
84#define OSPFv3AREANSSATRANSLATORSTATE 12
85#define OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL 13
86#define OSPFv3AREANSSATRANSLATOREVENTS 14
87#define OSPFv3AREASTUBMETRICTYPE 15
88
89/* OSPFv3 MIB Area Lsdb Table values. */
90#define OSPFv3AREALSDBAREAID 1
91#define OSPFv3AREALSDBTYPE 2
92#define OSPFv3AREALSDBROUTERID 3
93#define OSPFv3AREALSDBLSID 4
94#define OSPFv3AREALSDBSEQUENCE 5
95#define OSPFv3AREALSDBAGE 6
96#define OSPFv3AREALSDBCHECKSUM 7
97#define OSPFv3AREALSDBADVERTISEMENT 8
98#define OSPFv3AREALSDBTYPEKNOWN 9
hassoef1bbf52004-10-08 12:04:21 +000099
100/* SYNTAX Status from OSPF-MIB. */
101#define OSPF_STATUS_ENABLED 1
102#define OSPF_STATUS_DISABLED 2
103
104/* SNMP value hack. */
105#define COUNTER ASN_COUNTER
106#define INTEGER ASN_INTEGER
107#define GAUGE ASN_GAUGE
108#define TIMETICKS ASN_TIMETICKS
109#define IPADDRESS ASN_IPADDRESS
110#define STRING ASN_OCTET_STR
111
112/* For return values e.g. SNMP_INTEGER macro */
113SNMP_LOCAL_VARIABLES
114
115static struct in_addr tmp;
116#define INT32_INADDR(x) \
117 (tmp.s_addr = (x), tmp)
118
119/* OSPFv3-MIB instances. */
120oid ospfv3_oid [] = { OSPFv3MIB };
hassoef1bbf52004-10-08 12:04:21 +0000121
122/* empty ID 0.0.0.0 e.g. empty router-id */
123static struct in_addr ospf6_empty_id = {0};
124
125/* Hook functions. */
Chris Caputo0be8dfb2009-06-02 18:40:07 +0100126static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *,
127 int, size_t *, WriteMethod **);
128static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *,
129 int, size_t *, WriteMethod **);
130static u_char *ospfv3AreaLsdbEntry (struct variable *, oid *, size_t *,
131 int, size_t *, WriteMethod **);
hassoef1bbf52004-10-08 12:04:21 +0000132
133struct variable ospfv3_variables[] =
134{
135 /* OSPF general variables */
136 {OSPFv3ROUTERID, IPADDRESS, RWRITE, ospfv3GeneralGroup,
137 3, {1, 1, 1}},
138 {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup,
139 3, {1, 1, 2}},
140 {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup,
141 3, {1, 1, 3}},
142 {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
143 3, {1, 1, 4}},
144 {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup,
145 3, {1, 1, 5}},
146 {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
147 3, {1, 1, 6}},
148 {OSPFv3ASSCOPELSACHECKSUMSUM, INTEGER, RONLY, ospfv3GeneralGroup,
149 3, {1, 1, 7}},
150 {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
151 3, {1, 1, 8}},
152 {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup,
153 3, {1, 1, 9}},
154 {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup,
155 3, {1, 1, 10}},
156 {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup,
157 3, {1, 1, 11}},
158 {OSPFv3MULTICASTEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
159 3, {1, 1, 12}},
160 {OSPFv3EXITOVERFLOWINTERVAL, INTEGER, RWRITE, ospfv3GeneralGroup,
161 3, {1, 1, 13}},
162 {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup,
163 3, {1, 1, 14}},
164 {OSPFv3TRAFFICENGINEERINGSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
165 3, {1, 1, 15}},
166 {OSPFv3REFERENCEBANDWIDTH, INTEGER, RWRITE, ospfv3GeneralGroup,
167 3, {1, 1, 16}},
168 {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup,
169 3, {1, 1, 17}},
170 {OSPFv3RESTARTINTERVAL, INTEGER, RWRITE, ospfv3GeneralGroup,
171 3, {1, 1, 18}},
172 {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup,
173 3, {1, 1, 19}},
174 {OSPFv3RESTARTAGE, INTEGER, RONLY, ospfv3GeneralGroup,
175 3, {1, 1, 20}},
176 {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup,
177 3, {1, 1, 21}},
178
179 /* OSPFv3 Area Data Structure */
180 {OSPFv3AREAID, IPADDRESS, RONLY, ospfv3AreaEntry,
181 4, {1, 2, 1, 1}},
hasso2680aa22004-11-25 20:54:46 +0000182 {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry,
hassoef1bbf52004-10-08 12:04:21 +0000183 4, {1, 2, 1, 2}},
hasso2680aa22004-11-25 20:54:46 +0000184 {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry,
185 4, {1, 2, 1, 3}},
186 {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
187 4, {1, 2, 1, 4}},
188 {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry,
189 4, {1, 2, 1, 5}},
190 {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry,
191 4, {1, 2, 1, 6}},
192 {OSPFv3AREASCOPELSACKSUMSUM, INTEGER, RONLY, ospfv3AreaEntry,
193 4, {1, 2, 1, 7}},
194 {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry,
195 4, {1, 2, 1, 8}},
196 {OSPFv3AREASTATUS, INTEGER, RWRITE, ospfv3AreaEntry,
197 4, {1, 2, 1, 9}},
198 {OSPFv3STUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry,
199 4, {1, 2, 1, 10}},
200 {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry,
201 4, {1, 2, 1, 11}},
202 {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry,
203 4, {1, 2, 1, 12}},
204 {OSPFv3AREANSSATRANSLATORSTABILITYINTERVAL, INTEGER, RWRITE, ospfv3AreaEntry,
205 4, {1, 2, 1, 13}},
206 {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry,
207 4, {1, 2, 1, 14}},
208 {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry,
209 4, {1, 2, 1, 15}},
210
211 {OSPFv3AREALSDBAREAID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
212 4, {1, 4, 1, 1}},
213 {OSPFv3AREALSDBTYPE, GAUGE, RONLY, ospfv3AreaLsdbEntry,
214 4, {1, 4, 1, 2}},
215 {OSPFv3AREALSDBROUTERID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
216 4, {1, 4, 1, 3}},
217 {OSPFv3AREALSDBLSID, IPADDRESS, RONLY, ospfv3AreaLsdbEntry,
218 4, {1, 4, 1, 4}},
219 {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
220 4, {1, 4, 1, 5}},
221 {OSPFv3AREALSDBAGE, INTEGER, RONLY, ospfv3AreaLsdbEntry,
222 4, {1, 4, 1, 6}},
223 {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry,
224 4, {1, 4, 1, 7}},
225 {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry,
226 4, {1, 4, 1, 8}},
227 {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry,
228 4, {1, 4, 1, 9}},
229
hassoef1bbf52004-10-08 12:04:21 +0000230};
231
232static u_char *
233ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length,
234 int exact, size_t *var_len, WriteMethod **write_method)
235{
236 /* Check whether the instance identifier is valid */
237 if (smux_header_generic (v, name, length, exact, var_len, write_method)
238 == MATCH_FAILED)
239 return NULL;
240
241 /* Return the current value of the variable */
242 switch (v->magic)
243 {
244 case OSPFv3ROUTERID: /* 1*/
245 /* Router-ID of this OSPF instance. */
246 if (ospf6)
247 return SNMP_IPADDRESS (INT32_INADDR (ospf6->router_id));
248 else
249 return SNMP_IPADDRESS (ospf6_empty_id);
250 break;
251 case OSPFv3ADMINSTAT: /* 2*/
252 break;
253 case OSPFv3VERSIONNUMBER: /* 3*/
254 break;
255 case OSPFv3AREABDRRTRSTATUS: /* 4*/
256 break;
257 case OSPFv3ASBDRRTRSTATUS: /* 5*/
258 break;
259 case OSPFv3ASSCOPELSACOUNT: /* 6*/
260 break;
261 case OSPFv3ASSCOPELSACHECKSUMSUM: /* 7*/
262 break;
263 case OSPFv3ORIGINATENEWLSAS: /* 8*/
264 break;
265 case OSPFv3RXNEWLSAS: /* 9*/
266 break;
267 case OSPFv3EXTLSACOUNT: /*10*/
268 break;
269 case OSPFv3EXTAREALSDBLIMIT: /*11*/
270 break;
271 case OSPFv3MULTICASTEXTENSIONS: /*12*/
272 break;
273 case OSPFv3EXITOVERFLOWINTERVAL: /*13*/
274 break;
275 case OSPFv3DEMANDEXTENSIONS: /*14*/
276 break;
277 case OSPFv3TRAFFICENGINEERINGSUPPORT: /*15*/
278 break;
279 case OSPFv3REFERENCEBANDWIDTH: /*16*/
280 break;
281 case OSPFv3RESTARTSUPPORT: /*17*/
282 break;
283 case OSPFv3RESTARTINTERVAL: /*18*/
284 break;
285 case OSPFv3RESTARTSTATUS: /*19*/
286 break;
287 case OSPFv3RESTARTAGE: /*20*/
288 break;
289 case OSPFv3RESTARTEXITREASON: /*21*/
290 break;
291 default:
292 return NULL;
293 }
294 return NULL;
295}
296
297static u_char *
298ospfv3AreaEntry (struct variable *v, oid *name, size_t *length,
299 int exact, size_t *var_len, WriteMethod **write_method)
300{
301 struct ospf6_area *oa, *area = NULL;
302 u_int32_t area_id = 0;
paul0c083ee2004-10-10 12:54:58 +0000303 struct listnode *node;
304 unsigned int len;
hassoef1bbf52004-10-08 12:04:21 +0000305
306 if (ospf6 == NULL)
307 return NULL;
308
309 len = *length - v->namelen;
310 len = (len >= sizeof (u_int32_t) ? sizeof (u_int32_t) : 0);
311 if (exact && len != sizeof (u_int32_t))
312 return NULL;
313 if (len)
314 oid2in_addr (name + v->namelen, len, (struct in_addr *) &area_id);
315
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000316 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
hassoc6487d62004-12-24 06:00:11 +0000317 inet_ntoa (* (struct in_addr *) &area_id),
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000318 exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000319
paul1eb8ef22005-04-07 07:30:20 +0000320 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000321 {
hassoef1bbf52004-10-08 12:04:21 +0000322 if (area == NULL)
323 {
324 if (len == 0) /* return first area entry */
325 area = oa;
326 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
327 area = oa;
328 else if (ntohl (oa->area_id) > ntohl (area_id))
329 area = oa;
330 }
331 }
332
333 if (area == NULL)
334 return NULL;
335
336 *length = v->namelen + sizeof (u_int32_t);
337 oid_copy_addr (name + v->namelen, (struct in_addr *) &area->area_id,
338 sizeof (u_int32_t));
339
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000340 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
hassoc6487d62004-12-24 06:00:11 +0000341 inet_ntoa (* (struct in_addr *) &area->area_id),
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000342 exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000343
344 switch (v->magic)
345 {
346 case OSPFv3AREAID: /* 1*/
347 return SNMP_IPADDRESS (INT32_INADDR (area->area_id));
348 break;
349 case OSPFv3IMPORTASEXTERN: /* 2*/
350 return SNMP_INTEGER (ospf6->external_table->count);
351 break;
352 default:
353 return NULL;
354 break;
355 }
356 return NULL;
357}
358
hasso2680aa22004-11-25 20:54:46 +0000359static u_char *
360ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
361 int exact, size_t *var_len, WriteMethod **write_method)
362{
363 struct ospf6_lsa *lsa = NULL;
364 struct in_addr area_id;
365 u_int16_t type;
366 struct in_addr id;
367 struct in_addr adv_router;
368 int len;
369 oid *offset;
370 int offsetlen;
371 char a[16], b[16], c[16];
372 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000373 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000374
375 memset (&area_id, 0, sizeof (struct in_addr));
376 type = 0;
377 memset (&id, 0, sizeof (struct in_addr));
378 memset (&adv_router, 0, sizeof (struct in_addr));
379
380 /* Check OSPFv3 instance. */
381 if (ospf6 == NULL)
382 return NULL;
383
384 /* Get variable length. */
385 offset = name + v->namelen;
386 offsetlen = *length - v->namelen;
387
388#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET \
389 (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
390
391 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
392 return NULL;
393
394 /* Parse area-id */
395 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
396 if (len)
397 oid2in_addr (offset, len, &area_id);
398 offset += len;
399 offsetlen -= len;
400
401 /* Parse type */
402 len = (offsetlen < 1 ? offsetlen : 1);
403 if (len)
404 type = htons (*offset);
405 offset += len;
406 offsetlen -= len;
407
408 /* Parse Router-ID */
409 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
410 if (len)
411 oid2in_addr (offset, len, &adv_router);
412 offset += len;
413 offsetlen -= len;
414
415 /* Parse LS-ID */
416 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
417 if (len)
418 oid2in_addr (offset, len, &id);
419 offset += len;
420 offsetlen -= len;
421
422 inet_ntop (AF_INET, &area_id, a, sizeof (a));
423 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
424 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000425 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000426 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000427 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000428
429 if (exact)
430 {
431 oa = ospf6_area_lookup (area_id.s_addr, ospf6);
432 lsa = ospf6_lsdb_lookup (type, id.s_addr, adv_router.s_addr, oa->lsdb);
433 }
434 else
435 {
paul1eb8ef22005-04-07 07:30:20 +0000436 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000437 {
hasso2680aa22004-11-25 20:54:46 +0000438 if (lsa)
439 continue;
440 if (ntohl (oa->area_id) < ntohl (area_id.s_addr))
441 continue;
442
443 lsa = ospf6_lsdb_lookup_next (type, id.s_addr, adv_router.s_addr,
444 oa->lsdb);
445 if (! lsa)
446 {
447 type = 0;
448 memset (&id, 0, sizeof (struct in_addr));
449 memset (&adv_router, 0, sizeof (struct in_addr));
450 }
451 }
452 }
453
454 if (! lsa)
455 {
hassoc6487d62004-12-24 06:00:11 +0000456 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000457 return NULL;
458 }
459 oa = OSPF6_AREA (lsa->lsdb->data);
460
hassoc6487d62004-12-24 06:00:11 +0000461 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000462
463 /* Add Index (AreaId, Type, RouterId, Lsid) */
464 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
465 offset = name + v->namelen;
466 oid_copy_addr (offset, (struct in_addr *) &oa->area_id, IN_ADDR_SIZE);
467 offset += IN_ADDR_SIZE;
468 *offset = ntohs (lsa->header->type);
469 offset++;
470 oid_copy_addr (offset, (struct in_addr *) &lsa->header->adv_router,
471 IN_ADDR_SIZE);
472 offset += IN_ADDR_SIZE;
473 oid_copy_addr (offset, (struct in_addr *) &lsa->header->id, IN_ADDR_SIZE);
474 offset += IN_ADDR_SIZE;
475
476 /* Return the current value of the variable */
477 switch (v->magic)
478 {
479 case OSPFv3AREALSDBAREAID: /* 1 */
480 area_id.s_addr = OSPF6_AREA (lsa->lsdb->data)->area_id;
481 return SNMP_IPADDRESS (area_id);
482 break;
483 case OSPFv3AREALSDBTYPE: /* 2 */
484 return SNMP_INTEGER (ntohs (lsa->header->type));
485 break;
486 case OSPFv3AREALSDBROUTERID: /* 3 */
487 adv_router.s_addr = lsa->header->adv_router;
488 return SNMP_IPADDRESS (adv_router);
489 break;
490 case OSPFv3AREALSDBLSID: /* 4 */
491 id.s_addr = lsa->header->id;
492 return SNMP_IPADDRESS (id);
493 break;
494 case OSPFv3AREALSDBSEQUENCE: /* 5 */
495 return SNMP_INTEGER (lsa->header->seqnum);
496 break;
497 case OSPFv3AREALSDBAGE: /* 6 */
498 ospf6_lsa_age_current (lsa);
499 return SNMP_INTEGER (lsa->header->age);
500 break;
501 case OSPFv3AREALSDBCHECKSUM: /* 7 */
502 return SNMP_INTEGER (lsa->header->checksum);
503 break;
504 case OSPFv3AREALSDBADVERTISEMENT: /* 8 */
505 *var_len = ntohs (lsa->header->length);
506 return (u_char *) lsa->header;
507 break;
508 case OSPFv3AREALSDBTYPEKNOWN: /* 9 */
509 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
510 SNMP_TRUE : SNMP_FALSE);
511 break;
512 default:
513 return NULL;
514 break;
515 }
516 return NULL;
517}
518
519
hassoef1bbf52004-10-08 12:04:21 +0000520/* Register OSPFv3-MIB. */
521void
paul0c083ee2004-10-10 12:54:58 +0000522ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +0000523{
hassoc75105a2004-10-13 10:33:26 +0000524 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +0000525 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +0000526}
527
528#endif /* HAVE_SNMP */
529