blob: d252f549f09c7b54388019cb2fbc5ab231926960 [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
Vincent Bernat8046ba62012-05-31 13:30:28 +0200309 if (smux_header_table(v, name, length, exact, var_len, write_method)
310 == MATCH_FAILED)
311 return NULL;
312
hassoef1bbf52004-10-08 12:04:21 +0000313 len = *length - v->namelen;
314 len = (len >= sizeof (u_int32_t) ? sizeof (u_int32_t) : 0);
315 if (exact && len != sizeof (u_int32_t))
316 return NULL;
317 if (len)
318 oid2in_addr (name + v->namelen, len, (struct in_addr *) &area_id);
319
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000320 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
hassoc6487d62004-12-24 06:00:11 +0000321 inet_ntoa (* (struct in_addr *) &area_id),
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000322 exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000323
paul1eb8ef22005-04-07 07:30:20 +0000324 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hassoef1bbf52004-10-08 12:04:21 +0000325 {
hassoef1bbf52004-10-08 12:04:21 +0000326 if (area == NULL)
327 {
328 if (len == 0) /* return first area entry */
329 area = oa;
330 else if (exact && ntohl (oa->area_id) == ntohl (area_id))
331 area = oa;
332 else if (ntohl (oa->area_id) > ntohl (area_id))
333 area = oa;
334 }
335 }
336
337 if (area == NULL)
338 return NULL;
339
340 *length = v->namelen + sizeof (u_int32_t);
341 oid_copy_addr (name + v->namelen, (struct in_addr *) &area->area_id,
342 sizeof (u_int32_t));
343
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000344 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
hassoc6487d62004-12-24 06:00:11 +0000345 inet_ntoa (* (struct in_addr *) &area->area_id),
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000346 exact, len, (u_long)*length);
hassoef1bbf52004-10-08 12:04:21 +0000347
348 switch (v->magic)
349 {
350 case OSPFv3AREAID: /* 1*/
351 return SNMP_IPADDRESS (INT32_INADDR (area->area_id));
352 break;
353 case OSPFv3IMPORTASEXTERN: /* 2*/
354 return SNMP_INTEGER (ospf6->external_table->count);
355 break;
356 default:
357 return NULL;
358 break;
359 }
360 return NULL;
361}
362
hasso2680aa22004-11-25 20:54:46 +0000363static u_char *
364ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length,
365 int exact, size_t *var_len, WriteMethod **write_method)
366{
367 struct ospf6_lsa *lsa = NULL;
368 struct in_addr area_id;
369 u_int16_t type;
370 struct in_addr id;
371 struct in_addr adv_router;
372 int len;
373 oid *offset;
374 int offsetlen;
375 char a[16], b[16], c[16];
376 struct ospf6_area *oa;
hassob3c8c462004-11-26 12:55:51 +0000377 struct listnode *node;
hasso2680aa22004-11-25 20:54:46 +0000378
Vincent Bernat8046ba62012-05-31 13:30:28 +0200379 if (smux_header_table(v, name, length, exact, var_len, write_method)
380 == MATCH_FAILED)
381 return NULL;
382
hasso2680aa22004-11-25 20:54:46 +0000383 memset (&area_id, 0, sizeof (struct in_addr));
384 type = 0;
385 memset (&id, 0, sizeof (struct in_addr));
386 memset (&adv_router, 0, sizeof (struct in_addr));
387
388 /* Check OSPFv3 instance. */
389 if (ospf6 == NULL)
390 return NULL;
391
392 /* Get variable length. */
393 offset = name + v->namelen;
394 offsetlen = *length - v->namelen;
395
396#define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET \
397 (IN_ADDR_SIZE + 1 + IN_ADDR_SIZE + IN_ADDR_SIZE)
398
399 if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET)
400 return NULL;
401
402 /* Parse area-id */
403 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
404 if (len)
405 oid2in_addr (offset, len, &area_id);
406 offset += len;
407 offsetlen -= len;
408
409 /* Parse type */
410 len = (offsetlen < 1 ? offsetlen : 1);
411 if (len)
412 type = htons (*offset);
413 offset += len;
414 offsetlen -= len;
415
416 /* Parse Router-ID */
417 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
418 if (len)
419 oid2in_addr (offset, len, &adv_router);
420 offset += len;
421 offsetlen -= len;
422
423 /* Parse LS-ID */
424 len = (offsetlen < IN_ADDR_SIZE ? offsetlen : IN_ADDR_SIZE);
425 if (len)
426 oid2in_addr (offset, len, &id);
427 offset += len;
428 offsetlen -= len;
429
430 inet_ntop (AF_INET, &area_id, a, sizeof (a));
431 inet_ntop (AF_INET, &adv_router, b, sizeof (b));
432 inet_ntop (AF_INET, &id, c, sizeof (c));
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000433 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
hassoc6487d62004-12-24 06:00:11 +0000434 " type=%#x adv_router=%s id=%s",
Andrew J. Schorreda9ba72007-04-27 18:13:15 +0000435 a, exact, (u_long)*length, v->magic, ntohs (type), b, c);
hasso2680aa22004-11-25 20:54:46 +0000436
437 if (exact)
438 {
439 oa = ospf6_area_lookup (area_id.s_addr, ospf6);
440 lsa = ospf6_lsdb_lookup (type, id.s_addr, adv_router.s_addr, oa->lsdb);
441 }
442 else
443 {
paul1eb8ef22005-04-07 07:30:20 +0000444 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso2680aa22004-11-25 20:54:46 +0000445 {
hasso2680aa22004-11-25 20:54:46 +0000446 if (lsa)
447 continue;
448 if (ntohl (oa->area_id) < ntohl (area_id.s_addr))
449 continue;
450
451 lsa = ospf6_lsdb_lookup_next (type, id.s_addr, adv_router.s_addr,
452 oa->lsdb);
453 if (! lsa)
454 {
455 type = 0;
456 memset (&id, 0, sizeof (struct in_addr));
457 memset (&adv_router, 0, sizeof (struct in_addr));
458 }
459 }
460 }
461
462 if (! lsa)
463 {
hassoc6487d62004-12-24 06:00:11 +0000464 zlog_debug ("SNMP respond: No LSA to return");
hasso2680aa22004-11-25 20:54:46 +0000465 return NULL;
466 }
467 oa = OSPF6_AREA (lsa->lsdb->data);
468
hassoc6487d62004-12-24 06:00:11 +0000469 zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name);
hasso2680aa22004-11-25 20:54:46 +0000470
471 /* Add Index (AreaId, Type, RouterId, Lsid) */
472 *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET;
473 offset = name + v->namelen;
474 oid_copy_addr (offset, (struct in_addr *) &oa->area_id, IN_ADDR_SIZE);
475 offset += IN_ADDR_SIZE;
476 *offset = ntohs (lsa->header->type);
477 offset++;
478 oid_copy_addr (offset, (struct in_addr *) &lsa->header->adv_router,
479 IN_ADDR_SIZE);
480 offset += IN_ADDR_SIZE;
481 oid_copy_addr (offset, (struct in_addr *) &lsa->header->id, IN_ADDR_SIZE);
482 offset += IN_ADDR_SIZE;
483
484 /* Return the current value of the variable */
485 switch (v->magic)
486 {
487 case OSPFv3AREALSDBAREAID: /* 1 */
488 area_id.s_addr = OSPF6_AREA (lsa->lsdb->data)->area_id;
489 return SNMP_IPADDRESS (area_id);
490 break;
491 case OSPFv3AREALSDBTYPE: /* 2 */
492 return SNMP_INTEGER (ntohs (lsa->header->type));
493 break;
494 case OSPFv3AREALSDBROUTERID: /* 3 */
495 adv_router.s_addr = lsa->header->adv_router;
496 return SNMP_IPADDRESS (adv_router);
497 break;
498 case OSPFv3AREALSDBLSID: /* 4 */
499 id.s_addr = lsa->header->id;
500 return SNMP_IPADDRESS (id);
501 break;
502 case OSPFv3AREALSDBSEQUENCE: /* 5 */
503 return SNMP_INTEGER (lsa->header->seqnum);
504 break;
505 case OSPFv3AREALSDBAGE: /* 6 */
506 ospf6_lsa_age_current (lsa);
507 return SNMP_INTEGER (lsa->header->age);
508 break;
509 case OSPFv3AREALSDBCHECKSUM: /* 7 */
510 return SNMP_INTEGER (lsa->header->checksum);
511 break;
512 case OSPFv3AREALSDBADVERTISEMENT: /* 8 */
513 *var_len = ntohs (lsa->header->length);
514 return (u_char *) lsa->header;
515 break;
516 case OSPFv3AREALSDBTYPEKNOWN: /* 9 */
517 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ?
518 SNMP_TRUE : SNMP_FALSE);
519 break;
520 default:
521 return NULL;
522 break;
523 }
524 return NULL;
525}
526
527
hassoef1bbf52004-10-08 12:04:21 +0000528/* Register OSPFv3-MIB. */
529void
paul0c083ee2004-10-10 12:54:58 +0000530ospf6_snmp_init (struct thread_master *master)
hassoef1bbf52004-10-08 12:04:21 +0000531{
hassoc75105a2004-10-13 10:33:26 +0000532 smux_init (master);
hassoef1bbf52004-10-08 12:04:21 +0000533 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid);
hassoef1bbf52004-10-08 12:04:21 +0000534}
535
536#endif /* HAVE_SNMP */
537