2 * Copyright (C) 2004 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
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.
26 #include <net-snmp/net-snmp-config.h>
27 #include <net-snmp/net-snmp-includes.h>
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"
44 #include "ospf6_snmp.h"
47 #define OSPFv3MIB 1,3,6,1,2,1,191
49 /* 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 OSPFv3EXITOVERFLOWINTERVAL 12
62 #define OSPFv3DEMANDEXTENSIONS 13
63 #define OSPFv3REFERENCEBANDWIDTH 14
64 #define OSPFv3RESTARTSUPPORT 15
65 #define OSPFv3RESTARTINTERVAL 16
66 #define OSPFv3RESTARTSTRICTLSACHECKING 17
67 #define OSPFv3RESTARTSTATUS 18
68 #define OSPFv3RESTARTAGE 19
69 #define OSPFv3RESTARTEXITREASON 20
70 #define OSPFv3NOTIFICATIONENABLE 21
71 #define OSPFv3STUBROUTERSUPPORT 22
72 #define OSPFv3STUBROUTERADVERTISEMENT 23
73 #define OSPFv3DISCONTINUITYTIME 24
74 #define OSPFv3RESTARTTIME 25
76 /* OSPFv3 MIB Area Table values: ospfv3AreaTable */
77 #define OSPFv3IMPORTASEXTERN 2
78 #define OSPFv3AREASPFRUNS 3
79 #define OSPFv3AREABDRRTRCOUNT 4
80 #define OSPFv3AREAASBDRRTRCOUNT 5
81 #define OSPFv3AREASCOPELSACOUNT 6
82 #define OSPFv3AREASCOPELSACKSUMSUM 7
83 #define OSPFv3AREASUMMARY 8
84 #define OSPFv3AREAROWSTATUS 9
85 #define OSPFv3AREASTUBMETRIC 10
86 #define OSPFv3AREANSSATRANSLATORROLE 11
87 #define OSPFv3AREANSSATRANSLATORSTATE 12
88 #define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13
89 #define OSPFv3AREANSSATRANSLATOREVENTS 14
90 #define OSPFv3AREASTUBMETRICTYPE 15
91 #define OSPFv3AREATEENABLED 16
93 /* OSPFv3 MIB AS Lsdb Table values: ospfv3AsLsdbTable */
94 #define OSPFv3ASLSDBSEQUENCE 4
95 #define OSPFv3ASLSDBAGE 5
96 #define OSPFv3ASLSDBCHECKSUM 6
97 #define OSPFv3ASLSDBADVERTISEMENT 7
98 #define OSPFv3ASLSDBTYPEKNOWN 8
100 /* OSPFv3 MIB Area Lsdb Table values: ospfv3AreaLsdbTable */
101 #define OSPFv3AREALSDBSEQUENCE 5
102 #define OSPFv3AREALSDBAGE 6
103 #define OSPFv3AREALSDBCHECKSUM 7
104 #define OSPFv3AREALSDBADVERTISEMENT 8
105 #define OSPFv3AREALSDBTYPEKNOWN 9
107 /* OSPFv3 MIB Link Lsdb Table values: ospfv3LinkLsdbTable */
108 #define OSPFv3LINKLSDBSEQUENCE 6
109 #define OSPFv3LINKLSDBAGE 7
110 #define OSPFv3LINKLSDBCHECKSUM 8
111 #define OSPFv3LINKLSDBADVERTISEMENT 9
112 #define OSPFv3LINKLSDBTYPEKNOWN 10
114 /* OSPFv3 MIB Host Table values: ospfv3HostTable */
115 #define OSPFv3HOSTMETRIC 3
116 #define OSPFv3HOSTROWSTATUS 4
117 #define OSPFv3HOSTAREAID 5
119 /* OSPFv3 MIB Interface Table values: ospfv3IfTable */
120 #define OSPFv3IFAREAID 3
121 #define OSPFv3IFTYPE 4
122 #define OSPFv3IFADMINSTATUS 5
123 #define OSPFv3IFRTRPRIORITY 6
124 #define OSPFv3IFTRANSITDELAY 7
125 #define OSPFv3IFRETRANSINTERVAL 8
126 #define OSPFv3IFHELLOINTERVAL 9
127 #define OSPFv3IFRTRDEADINTERVAL 10
128 #define OSPFv3IFPOLLINTERVAL 11
129 #define OSPFv3IFSTATE 12
130 #define OSPFv3IFDESIGNATEDROUTER 13
131 #define OSPFv3IFBACKUPDESIGNATEDROUTER 14
132 #define OSPFv3IFEVENTS 15
133 #define OSPFv3IFROWSTATUS 16
134 #define OSPFv3IFDEMAND 17
135 #define OSPFv3IFMETRICVALUE 18
136 #define OSPFv3IFLINKSCOPELSACOUNT 19
137 #define OSPFv3IFLINKLSACKSUMSUM 20
138 #define OSPFv3IFDEMANDNBRPROBE 21
139 #define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22
140 #define OSPFv3IFDEMANDNBRPROBEINTERVAL 23
141 #define OSPFv3IFTEDISABLED 24
142 #define OSPFv3IFLINKLSASUPPRESSION 25
144 /* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */
145 #define OSPFv3VIRTIFINDEX 3
146 #define OSPFv3VIRTIFINSTID 4
147 #define OSPFv3VIRTIFTRANSITDELAY 5
148 #define OSPFv3VIRTIFRETRANSINTERVAL 6
149 #define OSPFv3VIRTIFHELLOINTERVAL 7
150 #define OSPFv3VIRTIFRTRDEADINTERVAL 8
151 #define OSPFv3VIRTIFSTATE 9
152 #define OSPFv3VIRTIFEVENTS 10
153 #define OSPFv3VIRTIFROWSTATUS 11
154 #define OSPFv3VIRTIFLINKSCOPELSACOUNT 12
155 #define OSPFv3VIRTIFLINKLSACKSUMSUM 13
157 /* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */
158 #define OSPFv3NBRADDRESSTYPE 4
159 #define OSPFv3NBRADDRESS 5
160 #define OSPFv3NBROPTIONS 6
161 #define OSPFv3NBRPRIORITY 7
162 #define OSPFv3NBRSTATE 8
163 #define OSPFv3NBREVENTS 9
164 #define OSPFv3NBRLSRETRANSQLEN 10
165 #define OSPFv3NBRHELLOSUPPRESSED 11
166 #define OSPFv3NBRIFID 12
167 #define OSPFv3NBRRESTARTHELPERSTATUS 13
168 #define OSPFv3NBRRESTARTHELPERAGE 14
169 #define OSPFv3NBRRESTARTHELPEREXITREASON 15
171 /* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */
172 #define OSPFv3CFGNBRPRIORITY 5
173 #define OSPFv3CFGNBRROWSTATUS 6
175 /* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */
176 #define OSPFv3VIRTNBRIFINDEX 3
177 #define OSPFv3VIRTNBRIFINSTID 4
178 #define OSPFv3VIRTNBRADDRESSTYPE 5
179 #define OSPFv3VIRTNBRADDRESS 6
180 #define OSPFv3VIRTNBROPTIONS 7
181 #define OSPFv3VIRTNBRSTATE 8
182 #define OSPFv3VIRTNBREVENTS 9
183 #define OSPFv3VIRTNBRLSRETRANSQLEN 10
184 #define OSPFv3VIRTNBRHELLOSUPPRESSED 11
185 #define OSPFv3VIRTNBRIFID 12
186 #define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13
187 #define OSPFv3VIRTNBRRESTARTHELPERAGE 14
188 #define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15
190 /* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */
191 #define OSPFv3AREAAGGREGATEROWSTATUS 6
192 #define OSPFv3AREAAGGREGATEEFFECT 7
193 #define OSPFv3AREAAGGREGATEROUTETAG 8
195 /* OSPFv3 MIB Virtual Link Lsdb Table values: ospfv3VirtLinkLsdbTable */
196 #define OSPFv3VIRTLINKLSDBSEQUENCE 6
197 #define OSPFv3VIRTLINKLSDBAGE 7
198 #define OSPFv3VIRTLINKLSDBCHECKSUM 8
199 #define OSPFv3VIRTLINKLSDBADVERTISEMENT 9
200 #define OSPFv3VIRTLINKLSDBTYPEKNOWN 10
202 /* SYNTAX Status from OSPF-MIB. */
203 #define OSPF_STATUS_ENABLED 1
204 #define OSPF_STATUS_DISABLED 2
206 /* SNMP value hack. */
207 #define COUNTER ASN_COUNTER
208 #define INTEGER ASN_INTEGER
209 #define GAUGE ASN_GAUGE
210 #define UNSIGNED ASN_UNSIGNED
211 #define TIMETICKS ASN_TIMETICKS
212 #define IPADDRESS ASN_IPADDRESS
213 #define STRING ASN_OCTET_STR
215 /* For return values e.g. SNMP_INTEGER macro */
218 /* OSPFv3-MIB instances. */
219 oid ospfv3_oid
[] = { OSPFv3MIB
};
221 /* Hook functions. */
222 static u_char
*ospfv3GeneralGroup (struct variable
*, oid
*, size_t *,
223 int, size_t *, WriteMethod
**);
224 static u_char
*ospfv3AreaEntry (struct variable
*, oid
*, size_t *,
225 int, size_t *, WriteMethod
**);
226 static u_char
*ospfv3AreaLsdbEntry (struct variable
*, oid
*, size_t *,
227 int, size_t *, WriteMethod
**);
228 static u_char
*ospfv3NbrEntry (struct variable
*, oid
*, size_t *,
229 int, size_t *, WriteMethod
**);
230 static u_char
*ospfv3IfEntry (struct variable
*, oid
*, size_t *,
231 int, size_t *, WriteMethod
**);
233 struct variable ospfv3_variables
[] =
235 /* OSPF general variables */
236 {OSPFv3ROUTERID
, UNSIGNED
, RWRITE
, ospfv3GeneralGroup
,
238 {OSPFv3ADMINSTAT
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
240 {OSPFv3VERSIONNUMBER
, INTEGER
, RONLY
, ospfv3GeneralGroup
,
242 {OSPFv3AREABDRRTRSTATUS
, INTEGER
, RONLY
, ospfv3GeneralGroup
,
244 {OSPFv3ASBDRRTRSTATUS
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
246 {OSPFv3ASSCOPELSACOUNT
, GAUGE
, RONLY
, ospfv3GeneralGroup
,
248 {OSPFv3ASSCOPELSACHECKSUMSUM
,UNSIGNED
, RONLY
, ospfv3GeneralGroup
,
250 {OSPFv3ORIGINATENEWLSAS
, COUNTER
, RONLY
, ospfv3GeneralGroup
,
252 {OSPFv3RXNEWLSAS
, COUNTER
, RONLY
, ospfv3GeneralGroup
,
254 {OSPFv3EXTLSACOUNT
, GAUGE
, RONLY
, ospfv3GeneralGroup
,
256 {OSPFv3EXTAREALSDBLIMIT
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
258 {OSPFv3EXITOVERFLOWINTERVAL
, UNSIGNED
, RWRITE
, ospfv3GeneralGroup
,
260 {OSPFv3DEMANDEXTENSIONS
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
262 {OSPFv3REFERENCEBANDWIDTH
, UNSIGNED
, RWRITE
, ospfv3GeneralGroup
,
264 {OSPFv3RESTARTSUPPORT
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
266 {OSPFv3RESTARTINTERVAL
, UNSIGNED
, RWRITE
, ospfv3GeneralGroup
,
268 {OSPFv3RESTARTSTRICTLSACHECKING
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
270 {OSPFv3RESTARTSTATUS
, INTEGER
, RONLY
, ospfv3GeneralGroup
,
272 {OSPFv3RESTARTAGE
, UNSIGNED
, RONLY
, ospfv3GeneralGroup
,
274 {OSPFv3RESTARTEXITREASON
, INTEGER
, RONLY
, ospfv3GeneralGroup
,
276 {OSPFv3NOTIFICATIONENABLE
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
278 {OSPFv3STUBROUTERSUPPORT
, INTEGER
, RONLY
, ospfv3GeneralGroup
,
280 {OSPFv3STUBROUTERADVERTISEMENT
, INTEGER
, RWRITE
, ospfv3GeneralGroup
,
282 {OSPFv3DISCONTINUITYTIME
, TIMETICKS
, RONLY
, ospfv3GeneralGroup
,
284 {OSPFv3RESTARTTIME
, TIMETICKS
, RONLY
, ospfv3GeneralGroup
,
287 /* OSPFv3 Area Data Structure */
288 {OSPFv3IMPORTASEXTERN
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
290 {OSPFv3AREASPFRUNS
, COUNTER
, RONLY
, ospfv3AreaEntry
,
292 {OSPFv3AREABDRRTRCOUNT
, GAUGE
, RONLY
, ospfv3AreaEntry
,
294 {OSPFv3AREAASBDRRTRCOUNT
, GAUGE
, RONLY
, ospfv3AreaEntry
,
296 {OSPFv3AREASCOPELSACOUNT
, GAUGE
, RONLY
, ospfv3AreaEntry
,
298 {OSPFv3AREASCOPELSACKSUMSUM
, UNSIGNED
, RONLY
, ospfv3AreaEntry
,
300 {OSPFv3AREASUMMARY
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
302 {OSPFv3AREAROWSTATUS
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
304 {OSPFv3AREASTUBMETRIC
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
306 {OSPFv3AREANSSATRANSLATORROLE
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
308 {OSPFv3AREANSSATRANSLATORSTATE
, INTEGER
, RONLY
, ospfv3AreaEntry
,
310 {OSPFv3AREANSSATRANSLATORSTABINTERVAL
, UNSIGNED
, RWRITE
, ospfv3AreaEntry
,
312 {OSPFv3AREANSSATRANSLATOREVENTS
, COUNTER
, RONLY
, ospfv3AreaEntry
,
314 {OSPFv3AREASTUBMETRICTYPE
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
316 {OSPFv3AREATEENABLED
, INTEGER
, RWRITE
, ospfv3AreaEntry
,
319 /* OSPFv3 Area LSDB */
320 {OSPFv3AREALSDBSEQUENCE
, INTEGER
, RONLY
, ospfv3AreaLsdbEntry
,
322 {OSPFv3AREALSDBAGE
, UNSIGNED
, RONLY
, ospfv3AreaLsdbEntry
,
324 {OSPFv3AREALSDBCHECKSUM
, INTEGER
, RONLY
, ospfv3AreaLsdbEntry
,
326 {OSPFv3AREALSDBADVERTISEMENT
, STRING
, RONLY
, ospfv3AreaLsdbEntry
,
328 {OSPFv3AREALSDBTYPEKNOWN
, INTEGER
, RONLY
, ospfv3AreaLsdbEntry
,
331 /* OSPFv3 interfaces */
332 {OSPFv3IFAREAID
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
334 {OSPFv3IFTYPE
, INTEGER
, RONLY
, ospfv3IfEntry
,
336 {OSPFv3IFADMINSTATUS
, INTEGER
, RONLY
, ospfv3IfEntry
,
338 {OSPFv3IFRTRPRIORITY
, INTEGER
, RONLY
, ospfv3IfEntry
,
340 {OSPFv3IFTRANSITDELAY
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
342 {OSPFv3IFRETRANSINTERVAL
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
344 {OSPFv3IFHELLOINTERVAL
, INTEGER
, RONLY
, ospfv3IfEntry
,
346 {OSPFv3IFRTRDEADINTERVAL
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
348 {OSPFv3IFPOLLINTERVAL
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
350 {OSPFv3IFSTATE
, INTEGER
, RONLY
, ospfv3IfEntry
,
352 {OSPFv3IFDESIGNATEDROUTER
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
354 {OSPFv3IFBACKUPDESIGNATEDROUTER
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
356 {OSPFv3IFEVENTS
, COUNTER
, RONLY
, ospfv3IfEntry
,
358 {OSPFv3IFROWSTATUS
, INTEGER
, RONLY
, ospfv3IfEntry
,
360 {OSPFv3IFDEMAND
, INTEGER
, RONLY
, ospfv3IfEntry
,
362 {OSPFv3IFMETRICVALUE
, INTEGER
, RONLY
, ospfv3IfEntry
,
364 {OSPFv3IFLINKSCOPELSACOUNT
, GAUGE
, RONLY
, ospfv3IfEntry
,
366 {OSPFv3IFLINKLSACKSUMSUM
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
368 {OSPFv3IFDEMANDNBRPROBE
, INTEGER
, RONLY
, ospfv3IfEntry
,
370 {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
372 {OSPFv3IFDEMANDNBRPROBEINTERVAL
, UNSIGNED
, RONLY
, ospfv3IfEntry
,
374 {OSPFv3IFTEDISABLED
, INTEGER
, RONLY
, ospfv3IfEntry
,
376 {OSPFv3IFLINKLSASUPPRESSION
, INTEGER
, RONLY
, ospfv3IfEntry
,
379 /* OSPFv3 neighbors */
380 {OSPFv3NBRADDRESSTYPE
, INTEGER
, RONLY
, ospfv3NbrEntry
,
382 {OSPFv3NBRADDRESS
, STRING
, RONLY
, ospfv3NbrEntry
,
384 {OSPFv3NBROPTIONS
, INTEGER
, RONLY
, ospfv3NbrEntry
,
386 {OSPFv3NBRPRIORITY
, INTEGER
, RONLY
, ospfv3NbrEntry
,
388 {OSPFv3NBRSTATE
, INTEGER
, RONLY
, ospfv3NbrEntry
,
390 {OSPFv3NBREVENTS
, COUNTER
, RONLY
, ospfv3NbrEntry
,
392 {OSPFv3NBRLSRETRANSQLEN
, GAUGE
, RONLY
, ospfv3NbrEntry
,
394 {OSPFv3NBRHELLOSUPPRESSED
, INTEGER
, RONLY
, ospfv3NbrEntry
,
396 {OSPFv3NBRIFID
, INTEGER
, RONLY
, ospfv3NbrEntry
,
398 {OSPFv3NBRRESTARTHELPERSTATUS
, INTEGER
, RONLY
, ospfv3NbrEntry
,
400 {OSPFv3NBRRESTARTHELPERAGE
, UNSIGNED
, RONLY
, ospfv3NbrEntry
,
402 {OSPFv3NBRRESTARTHELPEREXITREASON
, INTEGER
, RONLY
, ospfv3NbrEntry
,
407 ospfv3GeneralGroup (struct variable
*v
, oid
*name
, size_t *length
,
408 int exact
, size_t *var_len
, WriteMethod
**write_method
)
412 struct ospf6_lsa
*lsa
= NULL
;
414 /* Check whether the instance identifier is valid */
415 if (smux_header_generic (v
, name
, length
, exact
, var_len
, write_method
)
419 /* Return the current value of the variable */
423 /* Router-ID of this OSPF instance. */
425 return SNMP_INTEGER (ntohl (ospf6
->router_id
));
426 return SNMP_INTEGER (0);
427 case OSPFv3ADMINSTAT
:
429 return SNMP_INTEGER (CHECK_FLAG (ospf6
->flag
, OSPF6_DISABLED
)?
430 OSPF_STATUS_DISABLED
:OSPF_STATUS_ENABLED
);
431 return SNMP_INTEGER (OSPF_STATUS_DISABLED
);
432 case OSPFv3VERSIONNUMBER
:
433 return SNMP_INTEGER (3);
434 case OSPFv3AREABDRRTRSTATUS
:
436 return SNMP_INTEGER (ospf6_is_router_abr (ospf6
)?SNMP_TRUE
:SNMP_FALSE
);
437 return SNMP_INTEGER (SNMP_FALSE
);
438 case OSPFv3ASBDRRTRSTATUS
:
440 return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6
)?SNMP_TRUE
:SNMP_FALSE
);
441 return SNMP_INTEGER (SNMP_FALSE
);
442 case OSPFv3ASSCOPELSACOUNT
:
444 return SNMP_INTEGER (ospf6
->lsdb
->count
);
445 return SNMP_INTEGER (0);
446 case OSPFv3ASSCOPELSACHECKSUMSUM
:
449 for (sum
= 0, lsa
= ospf6_lsdb_head (ospf6
->lsdb
);
451 lsa
= ospf6_lsdb_next (lsa
))
452 sum
+= ntohs (lsa
->header
->checksum
);
453 return SNMP_INTEGER (sum
);
455 return SNMP_INTEGER (0);
456 case OSPFv3ORIGINATENEWLSAS
:
457 return SNMP_INTEGER (0); /* Don't know where to get this value... */
458 case OSPFv3RXNEWLSAS
:
459 return SNMP_INTEGER (0); /* Don't know where to get this value... */
460 case OSPFv3EXTLSACOUNT
:
463 for (count
= 0, lsa
= ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL
),
466 lsa
= ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL
),
469 return SNMP_INTEGER (count
);
471 return SNMP_INTEGER (0);
472 case OSPFv3EXTAREALSDBLIMIT
:
473 return SNMP_INTEGER (-1);
474 case OSPFv3EXITOVERFLOWINTERVAL
:
475 return SNMP_INTEGER (0); /* Not supported */
476 case OSPFv3DEMANDEXTENSIONS
:
477 return SNMP_INTEGER (0); /* Not supported */
478 case OSPFv3REFERENCEBANDWIDTH
:
479 return SNMP_INTEGER (100000);
480 case OSPFv3RESTARTSUPPORT
:
481 case OSPFv3RESTARTINTERVAL
:
482 case OSPFv3RESTARTSTRICTLSACHECKING
:
483 case OSPFv3RESTARTSTATUS
:
484 case OSPFv3RESTARTAGE
:
485 case OSPFv3RESTARTEXITREASON
:
486 case OSPFv3NOTIFICATIONENABLE
:
487 case OSPFv3STUBROUTERSUPPORT
:
488 case OSPFv3STUBROUTERADVERTISEMENT
:
489 case OSPFv3DISCONTINUITYTIME
:
490 case OSPFv3RESTARTTIME
:
491 /* TODO: Not implemented */
498 ospfv3AreaEntry (struct variable
*v
, oid
*name
, size_t *length
,
499 int exact
, size_t *var_len
, WriteMethod
**write_method
)
501 struct ospf6_area
*oa
, *area
= NULL
;
502 struct ospf6_lsa
*lsa
= NULL
;
503 u_int32_t area_id
= 0;
506 struct listnode
*node
;
509 struct ospf6_route
*ro
;
514 if (smux_header_table(v
, name
, length
, exact
, var_len
, write_method
)
518 len
= *length
- v
->namelen
;
519 len
= (len
>= 1 ? sizeof 1 : 0);
520 if (exact
&& len
!= 1)
523 area_id
= htonl (name
[v
->namelen
]);
525 inet_ntop (AF_INET
, &area_id
, a
, sizeof (a
));
526 zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu",
527 a
, exact
, len
, (u_long
)*length
);
529 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
533 if (len
== 0) /* return first area entry */
535 else if (exact
&& ntohl (oa
->area_id
) == ntohl (area_id
))
537 else if (ntohl (oa
->area_id
) > ntohl (area_id
))
545 *length
= v
->namelen
+ 1;
546 name
[v
->namelen
] = ntohl (area
->area_id
);
548 inet_ntop (AF_INET
, &area
->area_id
, a
, sizeof (a
));
549 zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu",
550 a
, exact
, len
, (u_long
)*length
);
554 case OSPFv3IMPORTASEXTERN
:
555 /* No NSSA support */
556 return SNMP_INTEGER (IS_AREA_STUB(area
)?2:1);
557 case OSPFv3AREASPFRUNS
:
558 return SNMP_INTEGER (area
->spf_calculation
);
559 case OSPFv3AREABDRRTRCOUNT
:
560 case OSPFv3AREAASBDRRTRCOUNT
:
562 for (ro
= ospf6_route_head (ospf6
->brouter_table
); ro
;
563 ro
= ospf6_route_next (ro
))
565 if (ntohl (ro
->path
.area_id
) != ntohl (area
->area_id
)) continue;
566 if (v
->magic
== OSPFv3AREABDRRTRCOUNT
&&
567 CHECK_FLAG (ro
->path
.router_bits
, OSPF6_ROUTER_BIT_B
))
569 if (v
->magic
== OSPFv3AREAASBDRRTRCOUNT
&&
570 CHECK_FLAG (ro
->path
.router_bits
, OSPF6_ROUTER_BIT_E
))
573 return SNMP_INTEGER (count
);
574 case OSPFv3AREASCOPELSACOUNT
:
575 return SNMP_INTEGER (area
->lsdb
->count
);
576 case OSPFv3AREASCOPELSACKSUMSUM
:
577 for (sum
= 0, lsa
= ospf6_lsdb_head (area
->lsdb
);
579 lsa
= ospf6_lsdb_next (lsa
))
580 sum
+= ntohs (lsa
->header
->checksum
);
581 return SNMP_INTEGER (sum
);
582 case OSPFv3AREASUMMARY
:
583 return SNMP_INTEGER (2); /* sendAreaSummary */
584 case OSPFv3AREAROWSTATUS
:
585 return SNMP_INTEGER (1); /* Active */
586 case OSPFv3AREASTUBMETRIC
:
587 case OSPFv3AREANSSATRANSLATORROLE
:
588 case OSPFv3AREANSSATRANSLATORSTATE
:
589 case OSPFv3AREANSSATRANSLATORSTABINTERVAL
:
590 case OSPFv3AREANSSATRANSLATOREVENTS
:
591 case OSPFv3AREASTUBMETRICTYPE
:
592 case OSPFv3AREATEENABLED
:
593 /* Not implemented. */
600 ospfv3AreaLsdbEntry (struct variable
*v
, oid
*name
, size_t *length
,
601 int exact
, size_t *var_len
, WriteMethod
**write_method
)
603 struct ospf6_lsa
*lsa
= NULL
;
604 u_int32_t area_id
, id
, adv_router
;
609 char a
[16], b
[16], c
[16];
610 struct ospf6_area
*oa
;
611 struct listnode
*node
;
613 if (smux_header_table(v
, name
, length
, exact
, var_len
, write_method
)
617 area_id
= type
= id
= adv_router
= 0;
619 /* Check OSPFv3 instance. */
623 /* Get variable length. */
624 offset
= name
+ v
->namelen
;
625 offsetlen
= *length
- v
->namelen
;
627 #define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4
629 if (exact
&& offsetlen
!= OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET
)
633 len
= (offsetlen
< 1 ? 0 : 1);
635 area_id
= htonl (*offset
);
640 len
= (offsetlen
< 1 ? 0 : 1);
642 type
= htons (*offset
);
646 /* Parse Router-ID */
647 len
= (offsetlen
< 1 ? 0 : 1);
649 adv_router
= htonl (*offset
);
654 len
= (offsetlen
< 1 ? 0 : 1);
656 id
= htonl (*offset
);
660 inet_ntop (AF_INET
, &area_id
, a
, sizeof (a
));
661 inet_ntop (AF_INET
, &adv_router
, b
, sizeof (b
));
662 inet_ntop (AF_INET
, &id
, c
, sizeof (c
));
663 zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d"
664 " type=%#x adv_router=%s id=%s",
665 a
, exact
, (u_long
)*length
, v
->magic
, ntohs (type
), b
, c
);
669 oa
= ospf6_area_lookup (area_id
, ospf6
);
670 lsa
= ospf6_lsdb_lookup (type
, id
, adv_router
, oa
->lsdb
);
674 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
678 if (oa
->area_id
< area_id
)
681 lsa
= ospf6_lsdb_lookup_next (type
, id
, adv_router
,
694 zlog_debug ("SNMP respond: No LSA to return");
697 oa
= OSPF6_AREA (lsa
->lsdb
->data
);
699 zlog_debug ("SNMP respond: area: %s lsa: %s", oa
->name
, lsa
->name
);
701 /* Add Index (AreaId, Type, RouterId, Lsid) */
702 *length
= v
->namelen
+ OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET
;
703 offset
= name
+ v
->namelen
;
704 *offset
= ntohl (oa
->area_id
);
706 *offset
= ntohs (lsa
->header
->type
);
708 *offset
= ntohl (lsa
->header
->adv_router
);
710 *offset
= ntohl (lsa
->header
->id
);
713 /* Return the current value of the variable */
716 case OSPFv3AREALSDBSEQUENCE
:
717 return SNMP_INTEGER (ntohl (lsa
->header
->seqnum
));
719 case OSPFv3AREALSDBAGE
:
720 ospf6_lsa_age_current (lsa
);
721 return SNMP_INTEGER (ntohs (lsa
->header
->age
));
723 case OSPFv3AREALSDBCHECKSUM
:
724 return SNMP_INTEGER (ntohs (lsa
->header
->checksum
));
726 case OSPFv3AREALSDBADVERTISEMENT
:
727 *var_len
= ntohs (lsa
->header
->length
);
728 return (u_char
*) lsa
->header
;
730 case OSPFv3AREALSDBTYPEKNOWN
:
731 return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa
->header
->type
) ?
732 SNMP_TRUE
: SNMP_FALSE
);
739 if_icmp_func (struct interface
*ifp1
, struct interface
*ifp2
)
741 return (ifp1
->ifindex
- ifp2
->ifindex
);
745 ospfv3IfEntry (struct variable
*v
, oid
*name
, size_t *length
,
746 int exact
, size_t *var_len
, WriteMethod
**write_method
)
748 unsigned int ifindex
, instid
;
749 struct ospf6_interface
*oi
= NULL
;
750 struct ospf6_lsa
*lsa
= NULL
;
751 struct interface
*iif
;
753 struct list
*ifslist
;
758 if (smux_header_table (v
, name
, length
, exact
, var_len
, write_method
)
762 ifindex
= instid
= 0;
764 /* Check OSPFv3 instance. */
768 /* Get variable length. */
769 offset
= name
+ v
->namelen
;
770 offsetlen
= *length
- v
->namelen
;
772 if (exact
&& offsetlen
!= 2)
776 len
= (offsetlen
< 1 ? 0 : 1);
782 /* Parse instance ID */
783 len
= (offsetlen
< 1 ? 0 : 1);
791 oi
= ospf6_interface_lookup_by_ifindex (ifindex
);
792 if (oi
->instance_id
!= instid
) return NULL
;
796 /* We build a sorted list of interfaces */
797 ifslist
= list_new ();
798 if (!ifslist
) return NULL
;
799 ifslist
->cmp
= (int (*)(void *, void *))if_icmp_func
;
800 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, iif
))
801 listnode_add_sort (ifslist
, iif
);
803 for (ALL_LIST_ELEMENTS_RO (ifslist
, i
, iif
))
805 if (!iif
->ifindex
) continue;
806 oi
= ospf6_interface_lookup_by_ifindex (iif
->ifindex
);
808 if (iif
->ifindex
> ifindex
||
809 (iif
->ifindex
== ifindex
&&
810 (oi
->instance_id
> instid
)))
815 list_delete_all_node (ifslist
);
818 if (!oi
) return NULL
;
820 /* Add Index (IfIndex, IfInstId) */
821 *length
= v
->namelen
+ 2;
822 offset
= name
+ v
->namelen
;
823 *offset
= oi
->interface
->ifindex
;
825 *offset
= oi
->instance_id
;
828 /* Return the current value of the variable */
833 return SNMP_INTEGER (ntohl (oi
->area
->area_id
));
836 if (if_is_broadcast (oi
->interface
))
837 return SNMP_INTEGER (1);
838 else if (if_is_pointopoint (oi
->interface
))
839 return SNMP_INTEGER (3);
840 else break; /* Unknown, don't put anything */
841 case OSPFv3IFADMINSTATUS
:
843 return SNMP_INTEGER (OSPF_STATUS_ENABLED
);
844 return SNMP_INTEGER (OSPF_STATUS_DISABLED
);
845 case OSPFv3IFRTRPRIORITY
:
846 return SNMP_INTEGER (oi
->priority
);
847 case OSPFv3IFTRANSITDELAY
:
848 return SNMP_INTEGER (oi
->transdelay
);
849 case OSPFv3IFRETRANSINTERVAL
:
850 return SNMP_INTEGER (oi
->rxmt_interval
);
851 case OSPFv3IFHELLOINTERVAL
:
852 return SNMP_INTEGER (oi
->hello_interval
);
853 case OSPFv3IFRTRDEADINTERVAL
:
854 return SNMP_INTEGER (oi
->dead_interval
);
855 case OSPFv3IFPOLLINTERVAL
:
856 /* No support for NBMA */
859 return SNMP_INTEGER (oi
->state
);
860 case OSPFv3IFDESIGNATEDROUTER
:
861 return SNMP_INTEGER (ntohl (oi
->drouter
));
862 case OSPFv3IFBACKUPDESIGNATEDROUTER
:
863 return SNMP_INTEGER (ntohl (oi
->bdrouter
));
865 return SNMP_INTEGER (oi
->state_change
);
866 case OSPFv3IFROWSTATUS
:
867 return SNMP_INTEGER (1);
869 return SNMP_INTEGER (SNMP_FALSE
);
870 case OSPFv3IFMETRICVALUE
:
871 return SNMP_INTEGER (oi
->cost
);
872 case OSPFv3IFLINKSCOPELSACOUNT
:
873 return SNMP_INTEGER (oi
->lsdb
->count
);
874 case OSPFv3IFLINKLSACKSUMSUM
:
875 for (sum
= 0, lsa
= ospf6_lsdb_head (oi
->lsdb
);
877 lsa
= ospf6_lsdb_next (lsa
))
878 sum
+= ntohs (lsa
->header
->checksum
);
879 return SNMP_INTEGER (sum
);
880 case OSPFv3IFDEMANDNBRPROBE
:
881 case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT
:
882 case OSPFv3IFDEMANDNBRPROBEINTERVAL
:
883 case OSPFv3IFTEDISABLED
:
884 case OSPFv3IFLINKLSASUPPRESSION
:
885 /* Not implemented. Only works if all the last ones are not
890 /* Try an internal getnext. Some columns are missing in this table. */
891 if (!exact
&& (name
[*length
-1] < MAX_SUBID
))
892 return ospfv3IfEntry(v
, name
, length
,
893 exact
, var_len
, write_method
);
898 ospfv3NbrEntry (struct variable
*v
, oid
*name
, size_t *length
,
899 int exact
, size_t *var_len
, WriteMethod
**write_method
)
901 unsigned int ifindex
, instid
, rtrid
;
902 struct ospf6_interface
*oi
= NULL
;
903 struct ospf6_neighbor
*on
= NULL
;
904 struct interface
*iif
;
905 struct listnode
*i
, *j
;
906 struct list
*ifslist
;
910 if (smux_header_table (v
, name
, length
, exact
, var_len
, write_method
)
914 ifindex
= instid
= rtrid
= 0;
916 /* Check OSPFv3 instance. */
920 /* Get variable length. */
921 offset
= name
+ v
->namelen
;
922 offsetlen
= *length
- v
->namelen
;
924 if (exact
&& offsetlen
!= 3)
928 len
= (offsetlen
< 1 ? 0 : 1);
934 /* Parse instance ID */
935 len
= (offsetlen
< 1 ? 0 : 1);
941 /* Parse router ID */
942 len
= (offsetlen
< 1 ? 0 : 1);
944 rtrid
= htonl (*offset
);
950 oi
= ospf6_interface_lookup_by_ifindex (ifindex
);
951 on
= ospf6_neighbor_lookup (rtrid
, oi
);
952 if (oi
->instance_id
!= instid
) return NULL
;
956 /* We build a sorted list of interfaces */
957 ifslist
= list_new ();
958 if (!ifslist
) return NULL
;
959 ifslist
->cmp
= (int (*)(void *, void *))if_icmp_func
;
960 for (ALL_LIST_ELEMENTS_RO (iflist
, i
, iif
))
961 listnode_add_sort (ifslist
, iif
);
963 for (ALL_LIST_ELEMENTS_RO (ifslist
, i
, iif
))
965 if (!iif
->ifindex
) continue;
966 oi
= ospf6_interface_lookup_by_ifindex (iif
->ifindex
);
968 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, j
, on
)) {
969 if (iif
->ifindex
> ifindex
||
970 (iif
->ifindex
== ifindex
&&
971 (oi
->instance_id
> instid
||
972 (oi
->instance_id
== instid
&&
973 ntohl (on
->router_id
) > ntohl (rtrid
)))))
980 list_delete_all_node (ifslist
);
983 if (!oi
|| !on
) return NULL
;
985 /* Add Index (IfIndex, IfInstId, RtrId) */
986 *length
= v
->namelen
+ 3;
987 offset
= name
+ v
->namelen
;
988 *offset
= oi
->interface
->ifindex
;
990 *offset
= oi
->instance_id
;
992 *offset
= ntohl (on
->router_id
);
995 /* Return the current value of the variable */
998 case OSPFv3NBRADDRESSTYPE
:
999 return SNMP_INTEGER (2); /* IPv6 only */
1000 case OSPFv3NBRADDRESS
:
1001 *var_len
= sizeof (struct in6_addr
);
1002 return (u_char
*) &on
->linklocal_addr
;
1003 case OSPFv3NBROPTIONS
:
1004 return SNMP_INTEGER (on
->options
[2]);
1005 case OSPFv3NBRPRIORITY
:
1006 return SNMP_INTEGER (on
->priority
);
1007 case OSPFv3NBRSTATE
:
1008 return SNMP_INTEGER (on
->state
);
1009 case OSPFv3NBREVENTS
:
1010 return SNMP_INTEGER (on
->state_change
);
1011 case OSPFv3NBRLSRETRANSQLEN
:
1012 return SNMP_INTEGER (on
->retrans_list
->count
);
1013 case OSPFv3NBRHELLOSUPPRESSED
:
1014 return SNMP_INTEGER (SNMP_FALSE
);
1016 return SNMP_INTEGER (on
->ifindex
);
1017 case OSPFv3NBRRESTARTHELPERSTATUS
:
1018 case OSPFv3NBRRESTARTHELPERAGE
:
1019 case OSPFv3NBRRESTARTHELPEREXITREASON
:
1020 /* Not implemented. Only works if all the last ones are not
1028 /* Register OSPFv3-MIB. */
1030 ospf6_snmp_init (struct thread_master
*master
)
1033 REGISTER_MIB ("OSPFv3MIB", ospfv3_variables
, variable
, ospfv3_oid
);
1036 #endif /* HAVE_SNMP */