hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 1 | /* OSPFv3 SNMP support |
| 2 | * Copyright (C) 2004 Yasuhiro Ohara |
| 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
| 22 | #include <zebra.h> |
| 23 | |
| 24 | #ifdef HAVE_SNMP |
| 25 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 26 | #include <net-snmp/net-snmp-config.h> |
Joakim Tjernlund | fb62a3c | 2008-05-13 20:03:32 +0200 | [diff] [blame] | 27 | #include <net-snmp/net-snmp-includes.h> |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 28 | |
| 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 Caputo | 0be8dfb | 2009-06-02 18:40:07 +0100 | [diff] [blame] | 44 | #include "ospf6_snmp.h" |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 45 | |
| 46 | /* OSPFv3-MIB */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 47 | #define OSPFv3MIB 1,3,6,1,2,1,191 |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 48 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 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 |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 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 |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 75 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 76 | /* OSPFv3 MIB Area Table values: ospfv3AreaTable */ |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 77 | #define OSPFv3IMPORTASEXTERN 2 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 78 | #define OSPFv3AREASPFRUNS 3 |
| 79 | #define OSPFv3AREABDRRTRCOUNT 4 |
| 80 | #define OSPFv3AREAASBDRRTRCOUNT 5 |
| 81 | #define OSPFv3AREASCOPELSACOUNT 6 |
| 82 | #define OSPFv3AREASCOPELSACKSUMSUM 7 |
| 83 | #define OSPFv3AREASUMMARY 8 |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 84 | #define OSPFv3AREAROWSTATUS 9 |
| 85 | #define OSPFv3AREASTUBMETRIC 10 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 86 | #define OSPFv3AREANSSATRANSLATORROLE 11 |
| 87 | #define OSPFv3AREANSSATRANSLATORSTATE 12 |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 88 | #define OSPFv3AREANSSATRANSLATORSTABINTERVAL 13 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 89 | #define OSPFv3AREANSSATRANSLATOREVENTS 14 |
| 90 | #define OSPFv3AREASTUBMETRICTYPE 15 |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 91 | #define OSPFv3AREATEENABLED 16 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 92 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 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 |
| 99 | |
| 100 | /* OSPFv3 MIB Area Lsdb Table values: ospfv3AreaLsdbTable */ |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 101 | #define OSPFv3AREALSDBSEQUENCE 5 |
| 102 | #define OSPFv3AREALSDBAGE 6 |
| 103 | #define OSPFv3AREALSDBCHECKSUM 7 |
| 104 | #define OSPFv3AREALSDBADVERTISEMENT 8 |
| 105 | #define OSPFv3AREALSDBTYPEKNOWN 9 |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 106 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 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 |
| 113 | |
| 114 | /* OSPFv3 MIB Host Table values: ospfv3HostTable */ |
| 115 | #define OSPFv3HOSTMETRIC 3 |
| 116 | #define OSPFv3HOSTROWSTATUS 4 |
| 117 | #define OSPFv3HOSTAREAID 5 |
| 118 | |
| 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 |
| 143 | |
| 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 |
| 156 | |
| 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 |
| 170 | |
| 171 | /* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */ |
| 172 | #define OSPFv3CFGNBRPRIORITY 5 |
| 173 | #define OSPFv3CFGNBRROWSTATUS 6 |
| 174 | |
| 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 |
| 189 | |
| 190 | /* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */ |
| 191 | #define OSPFv3AREAAGGREGATEROWSTATUS 6 |
| 192 | #define OSPFv3AREAAGGREGATEEFFECT 7 |
| 193 | #define OSPFv3AREAAGGREGATEROUTETAG 8 |
| 194 | |
| 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 |
| 201 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 202 | /* SYNTAX Status from OSPF-MIB. */ |
| 203 | #define OSPF_STATUS_ENABLED 1 |
| 204 | #define OSPF_STATUS_DISABLED 2 |
| 205 | |
| 206 | /* SNMP value hack. */ |
| 207 | #define COUNTER ASN_COUNTER |
| 208 | #define INTEGER ASN_INTEGER |
| 209 | #define GAUGE ASN_GAUGE |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 210 | #define UNSIGNED ASN_UNSIGNED |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 211 | #define TIMETICKS ASN_TIMETICKS |
| 212 | #define IPADDRESS ASN_IPADDRESS |
| 213 | #define STRING ASN_OCTET_STR |
| 214 | |
| 215 | /* For return values e.g. SNMP_INTEGER macro */ |
| 216 | SNMP_LOCAL_VARIABLES |
| 217 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 218 | /* OSPFv3-MIB instances. */ |
| 219 | oid ospfv3_oid [] = { OSPFv3MIB }; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 220 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 221 | /* Hook functions. */ |
Chris Caputo | 0be8dfb | 2009-06-02 18:40:07 +0100 | [diff] [blame] | 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 **); |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 228 | static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *, |
| 229 | int, size_t *, WriteMethod **); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 230 | |
| 231 | struct variable ospfv3_variables[] = |
| 232 | { |
| 233 | /* OSPF general variables */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 234 | {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 235 | 3, {1, 1, 1}}, |
| 236 | {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 237 | 3, {1, 1, 2}}, |
| 238 | {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup, |
| 239 | 3, {1, 1, 3}}, |
| 240 | {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup, |
| 241 | 3, {1, 1, 4}}, |
| 242 | {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 243 | 3, {1, 1, 5}}, |
| 244 | {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, |
| 245 | 3, {1, 1, 6}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 246 | {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 247 | 3, {1, 1, 7}}, |
| 248 | {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup, |
| 249 | 3, {1, 1, 8}}, |
| 250 | {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup, |
| 251 | 3, {1, 1, 9}}, |
| 252 | {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, |
| 253 | 3, {1, 1, 10}}, |
| 254 | {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 255 | 3, {1, 1, 11}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 256 | {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 257 | 3, {1, 1, 12}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 258 | {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 259 | 3, {1, 1, 13}}, |
| 260 | {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 261 | 3, {1, 1, 14}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 262 | {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 263 | 3, {1, 1, 15}}, |
| 264 | {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
| 265 | 3, {1, 1, 16}}, |
| 266 | {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 267 | 3, {1, 1, 17}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 268 | {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 269 | 3, {1, 1, 18}}, |
| 270 | {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 271 | 3, {1, 1, 19}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 272 | {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 273 | 3, {1, 1, 20}}, |
| 274 | {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 275 | 3, {1, 1, 21}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 276 | {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup, |
| 277 | 3, {1, 1, 22}}, |
| 278 | {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 279 | 3, {1, 1, 23}}, |
| 280 | {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup, |
| 281 | 3, {1, 1, 24}}, |
| 282 | {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup, |
| 283 | 3, {1, 1, 25}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 284 | |
| 285 | /* OSPFv3 Area Data Structure */ |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 286 | {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 287 | 4, {1, 2, 1, 2}}, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 288 | {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry, |
| 289 | 4, {1, 2, 1, 3}}, |
| 290 | {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 291 | 4, {1, 2, 1, 4}}, |
| 292 | {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 293 | 4, {1, 2, 1, 5}}, |
| 294 | {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 295 | 4, {1, 2, 1, 6}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 296 | {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 297 | 4, {1, 2, 1, 7}}, |
| 298 | {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry, |
| 299 | 4, {1, 2, 1, 8}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 300 | {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 301 | 4, {1, 2, 1, 9}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 302 | {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 303 | 4, {1, 2, 1, 10}}, |
| 304 | {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry, |
| 305 | 4, {1, 2, 1, 11}}, |
| 306 | {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry, |
| 307 | 4, {1, 2, 1, 12}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 308 | {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 309 | 4, {1, 2, 1, 13}}, |
| 310 | {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry, |
| 311 | 4, {1, 2, 1, 14}}, |
| 312 | {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry, |
| 313 | 4, {1, 2, 1, 15}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 314 | {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry, |
| 315 | 4, {1, 2, 1, 16}}, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 316 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 317 | /* OSPFv3 Area LSDB */ |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 318 | {OSPFv3AREALSDBSEQUENCE, INTEGER, RONLY, ospfv3AreaLsdbEntry, |
| 319 | 4, {1, 4, 1, 5}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 320 | {OSPFv3AREALSDBAGE, UNSIGNED, RONLY, ospfv3AreaLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 321 | 4, {1, 4, 1, 6}}, |
| 322 | {OSPFv3AREALSDBCHECKSUM, INTEGER, RONLY, ospfv3AreaLsdbEntry, |
| 323 | 4, {1, 4, 1, 7}}, |
| 324 | {OSPFv3AREALSDBADVERTISEMENT, STRING, RONLY, ospfv3AreaLsdbEntry, |
| 325 | 4, {1, 4, 1, 8}}, |
| 326 | {OSPFv3AREALSDBTYPEKNOWN, INTEGER, RONLY, ospfv3AreaLsdbEntry, |
| 327 | 4, {1, 4, 1, 9}}, |
| 328 | |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 329 | /* OSPFv3 neighbors */ |
| 330 | {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry, |
| 331 | 4, {1, 9, 1, 4}}, |
| 332 | {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry, |
| 333 | 4, {1, 9, 1, 5}}, |
| 334 | {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry, |
| 335 | 4, {1, 9, 1, 6}}, |
| 336 | {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry, |
| 337 | 4, {1, 9, 1, 7}}, |
| 338 | {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry, |
| 339 | 4, {1, 9, 1, 8}}, |
| 340 | {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry, |
| 341 | 4, {1, 9, 1, 9}}, |
| 342 | {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry, |
| 343 | 4, {1, 9, 1, 10}}, |
| 344 | {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry, |
| 345 | 4, {1, 9, 1, 11}}, |
| 346 | {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry, |
| 347 | 4, {1, 9, 1, 12}}, |
| 348 | {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry, |
| 349 | 4, {1, 9, 1, 13}}, |
| 350 | {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry, |
| 351 | 4, {1, 9, 1, 14}}, |
| 352 | {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry, |
| 353 | 4, {1, 9, 1, 15}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 354 | }; |
| 355 | |
| 356 | static u_char * |
| 357 | ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length, |
| 358 | int exact, size_t *var_len, WriteMethod **write_method) |
| 359 | { |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 360 | u_int16_t sum; |
| 361 | u_int32_t count; |
| 362 | struct ospf6_lsa *lsa = NULL; |
| 363 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 364 | /* Check whether the instance identifier is valid */ |
| 365 | if (smux_header_generic (v, name, length, exact, var_len, write_method) |
| 366 | == MATCH_FAILED) |
| 367 | return NULL; |
| 368 | |
| 369 | /* Return the current value of the variable */ |
| 370 | switch (v->magic) |
| 371 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 372 | case OSPFv3ROUTERID: |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 373 | /* Router-ID of this OSPF instance. */ |
| 374 | if (ospf6) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 375 | return SNMP_INTEGER (ntohl (ospf6->router_id)); |
| 376 | return SNMP_INTEGER (0); |
| 377 | case OSPFv3ADMINSTAT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 378 | if (ospf6) |
| 379 | return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)? |
| 380 | OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED); |
| 381 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 382 | case OSPFv3VERSIONNUMBER: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 383 | return SNMP_INTEGER (3); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 384 | case OSPFv3AREABDRRTRSTATUS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 385 | if (ospf6) |
| 386 | return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE); |
| 387 | return SNMP_INTEGER (SNMP_FALSE); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 388 | case OSPFv3ASBDRRTRSTATUS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 389 | if (ospf6) |
| 390 | return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE); |
| 391 | return SNMP_INTEGER (SNMP_FALSE); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 392 | case OSPFv3ASSCOPELSACOUNT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 393 | if (ospf6) |
| 394 | return SNMP_INTEGER (ospf6->lsdb->count); |
| 395 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 396 | case OSPFv3ASSCOPELSACHECKSUMSUM: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 397 | if (ospf6) |
| 398 | { |
| 399 | for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb); |
| 400 | lsa; |
| 401 | lsa = ospf6_lsdb_next (lsa)) |
| 402 | sum += ntohs (lsa->header->checksum); |
| 403 | return SNMP_INTEGER (sum); |
| 404 | } |
| 405 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 406 | case OSPFv3ORIGINATENEWLSAS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 407 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 408 | case OSPFv3RXNEWLSAS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 409 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 410 | case OSPFv3EXTLSACOUNT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 411 | if (ospf6) |
| 412 | { |
| 413 | for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL), |
| 414 | ospf6->lsdb); |
| 415 | lsa; |
| 416 | lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL), |
| 417 | lsa)) |
| 418 | count += 1; |
| 419 | return SNMP_INTEGER (count); |
| 420 | } |
| 421 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 422 | case OSPFv3EXTAREALSDBLIMIT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 423 | return SNMP_INTEGER (-1); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 424 | case OSPFv3EXITOVERFLOWINTERVAL: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 425 | return SNMP_INTEGER (0); /* Not supported */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 426 | case OSPFv3DEMANDEXTENSIONS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 427 | return SNMP_INTEGER (0); /* Not supported */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 428 | case OSPFv3REFERENCEBANDWIDTH: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 429 | return SNMP_INTEGER (100000); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 430 | case OSPFv3RESTARTSUPPORT: |
| 431 | case OSPFv3RESTARTINTERVAL: |
| 432 | case OSPFv3RESTARTSTRICTLSACHECKING: |
| 433 | case OSPFv3RESTARTSTATUS: |
| 434 | case OSPFv3RESTARTAGE: |
| 435 | case OSPFv3RESTARTEXITREASON: |
| 436 | case OSPFv3NOTIFICATIONENABLE: |
| 437 | case OSPFv3STUBROUTERSUPPORT: |
| 438 | case OSPFv3STUBROUTERADVERTISEMENT: |
| 439 | case OSPFv3DISCONTINUITYTIME: |
| 440 | case OSPFv3RESTARTTIME: |
| 441 | /* TODO: Not implemented */ |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 442 | return NULL; |
| 443 | } |
| 444 | return NULL; |
| 445 | } |
| 446 | |
| 447 | static u_char * |
| 448 | ospfv3AreaEntry (struct variable *v, oid *name, size_t *length, |
| 449 | int exact, size_t *var_len, WriteMethod **write_method) |
| 450 | { |
| 451 | struct ospf6_area *oa, *area = NULL; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 452 | struct ospf6_lsa *lsa = NULL; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 453 | u_int32_t area_id = 0; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 454 | u_int32_t count; |
| 455 | u_int16_t sum; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 456 | struct listnode *node; |
| 457 | unsigned int len; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 458 | char a[16]; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 459 | struct ospf6_route *ro; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 460 | |
| 461 | if (ospf6 == NULL) |
| 462 | return NULL; |
| 463 | |
Vincent Bernat | 8046ba6 | 2012-05-31 13:30:28 +0200 | [diff] [blame] | 464 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
| 465 | == MATCH_FAILED) |
| 466 | return NULL; |
| 467 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 468 | len = *length - v->namelen; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 469 | len = (len >= 1 ? sizeof 1 : 0); |
| 470 | if (exact && len != 1) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 471 | return NULL; |
| 472 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 473 | area_id = htonl (name[v->namelen]); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 474 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 475 | inet_ntop (AF_INET, &area_id, a, sizeof (a)); |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 476 | zlog_debug ("SNMP access by area: %s, exact=%d len=%d length=%lu", |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 477 | a, exact, len, (u_long)*length); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 478 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 479 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 480 | { |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 481 | if (area == NULL) |
| 482 | { |
| 483 | if (len == 0) /* return first area entry */ |
| 484 | area = oa; |
| 485 | else if (exact && ntohl (oa->area_id) == ntohl (area_id)) |
| 486 | area = oa; |
| 487 | else if (ntohl (oa->area_id) > ntohl (area_id)) |
| 488 | area = oa; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | if (area == NULL) |
| 493 | return NULL; |
| 494 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 495 | *length = v->namelen + 1; |
| 496 | name[v->namelen] = ntohl (area->area_id); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 497 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 498 | inet_ntop (AF_INET, &area->area_id, a, sizeof (a)); |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 499 | zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu", |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 500 | a, exact, len, (u_long)*length); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 501 | |
| 502 | switch (v->magic) |
| 503 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 504 | case OSPFv3IMPORTASEXTERN: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 505 | /* No NSSA support */ |
| 506 | return SNMP_INTEGER (IS_AREA_STUB(area)?2:1); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 507 | case OSPFv3AREASPFRUNS: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 508 | return SNMP_INTEGER (area->spf_calculation); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 509 | case OSPFv3AREABDRRTRCOUNT: |
| 510 | case OSPFv3AREAASBDRRTRCOUNT: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 511 | count = 0; |
| 512 | for (ro = ospf6_route_head (ospf6->brouter_table); ro; |
| 513 | ro = ospf6_route_next (ro)) |
| 514 | { |
| 515 | if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue; |
| 516 | if (v->magic == OSPFv3AREABDRRTRCOUNT && |
| 517 | CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B)) |
| 518 | count++; |
| 519 | if (v->magic == OSPFv3AREAASBDRRTRCOUNT && |
| 520 | CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E)) |
| 521 | count++; |
| 522 | } |
| 523 | return SNMP_INTEGER (count); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 524 | case OSPFv3AREASCOPELSACOUNT: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 525 | return SNMP_INTEGER (area->lsdb->count); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 526 | case OSPFv3AREASCOPELSACKSUMSUM: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 527 | for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb); |
| 528 | lsa; |
| 529 | lsa = ospf6_lsdb_next (lsa)) |
| 530 | sum += ntohs (lsa->header->checksum); |
| 531 | return SNMP_INTEGER (sum); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 532 | case OSPFv3AREASUMMARY: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 533 | return SNMP_INTEGER (2); /* sendAreaSummary */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 534 | case OSPFv3AREAROWSTATUS: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame^] | 535 | return SNMP_INTEGER (1); /* Active */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 536 | case OSPFv3AREASTUBMETRIC: |
| 537 | case OSPFv3AREANSSATRANSLATORROLE: |
| 538 | case OSPFv3AREANSSATRANSLATORSTATE: |
| 539 | case OSPFv3AREANSSATRANSLATORSTABINTERVAL: |
| 540 | case OSPFv3AREANSSATRANSLATOREVENTS: |
| 541 | case OSPFv3AREASTUBMETRICTYPE: |
| 542 | case OSPFv3AREATEENABLED: |
| 543 | /* Not implemented. */ |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 544 | return NULL; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 545 | } |
| 546 | return NULL; |
| 547 | } |
| 548 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 549 | static u_char * |
| 550 | ospfv3AreaLsdbEntry (struct variable *v, oid *name, size_t *length, |
| 551 | int exact, size_t *var_len, WriteMethod **write_method) |
| 552 | { |
| 553 | struct ospf6_lsa *lsa = NULL; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 554 | u_int32_t area_id, id, adv_router; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 555 | u_int16_t type; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 556 | int len; |
| 557 | oid *offset; |
| 558 | int offsetlen; |
| 559 | char a[16], b[16], c[16]; |
| 560 | struct ospf6_area *oa; |
hasso | b3c8c46 | 2004-11-26 12:55:51 +0000 | [diff] [blame] | 561 | struct listnode *node; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 562 | |
Vincent Bernat | 8046ba6 | 2012-05-31 13:30:28 +0200 | [diff] [blame] | 563 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
| 564 | == MATCH_FAILED) |
| 565 | return NULL; |
| 566 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 567 | area_id = type = id = adv_router = 0; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 568 | |
| 569 | /* Check OSPFv3 instance. */ |
| 570 | if (ospf6 == NULL) |
| 571 | return NULL; |
| 572 | |
| 573 | /* Get variable length. */ |
| 574 | offset = name + v->namelen; |
| 575 | offsetlen = *length - v->namelen; |
| 576 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 577 | #define OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET 4 |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 578 | |
| 579 | if (exact && offsetlen != OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET) |
| 580 | return NULL; |
| 581 | |
| 582 | /* Parse area-id */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 583 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 584 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 585 | area_id = htonl (*offset); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 586 | offset += len; |
| 587 | offsetlen -= len; |
| 588 | |
| 589 | /* Parse type */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 590 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 591 | if (len) |
| 592 | type = htons (*offset); |
| 593 | offset += len; |
| 594 | offsetlen -= len; |
| 595 | |
| 596 | /* Parse Router-ID */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 597 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 598 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 599 | adv_router = htonl (*offset); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 600 | offset += len; |
| 601 | offsetlen -= len; |
| 602 | |
| 603 | /* Parse LS-ID */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 604 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 605 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 606 | id = htonl (*offset); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 607 | offset += len; |
| 608 | offsetlen -= len; |
| 609 | |
| 610 | inet_ntop (AF_INET, &area_id, a, sizeof (a)); |
| 611 | inet_ntop (AF_INET, &adv_router, b, sizeof (b)); |
| 612 | inet_ntop (AF_INET, &id, c, sizeof (c)); |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 613 | zlog_debug ("SNMP access by lsdb: area=%s exact=%d length=%lu magic=%d" |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 614 | " type=%#x adv_router=%s id=%s", |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 615 | a, exact, (u_long)*length, v->magic, ntohs (type), b, c); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 616 | |
| 617 | if (exact) |
| 618 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 619 | oa = ospf6_area_lookup (area_id, ospf6); |
| 620 | lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 621 | } |
| 622 | else |
| 623 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 624 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 625 | { |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 626 | if (lsa) |
| 627 | continue; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 628 | if (oa->area_id < area_id) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 629 | continue; |
| 630 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 631 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 632 | oa->lsdb); |
| 633 | if (! lsa) |
| 634 | { |
| 635 | type = 0; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 636 | id = 0; |
| 637 | adv_router = 0; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | if (! lsa) |
| 643 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 644 | zlog_debug ("SNMP respond: No LSA to return"); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 645 | return NULL; |
| 646 | } |
| 647 | oa = OSPF6_AREA (lsa->lsdb->data); |
| 648 | |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 649 | zlog_debug ("SNMP respond: area: %s lsa: %s", oa->name, lsa->name); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 650 | |
| 651 | /* Add Index (AreaId, Type, RouterId, Lsid) */ |
| 652 | *length = v->namelen + OSPFV3_AREA_LSDB_ENTRY_EXACT_OFFSET; |
| 653 | offset = name + v->namelen; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 654 | *offset = ntohl (oa->area_id); |
| 655 | offset++; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 656 | *offset = ntohs (lsa->header->type); |
| 657 | offset++; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 658 | *offset = ntohl (lsa->header->adv_router); |
| 659 | offset++; |
| 660 | *offset = ntohl (lsa->header->id); |
| 661 | offset++; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 662 | |
| 663 | /* Return the current value of the variable */ |
| 664 | switch (v->magic) |
| 665 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 666 | case OSPFv3AREALSDBSEQUENCE: |
| 667 | return SNMP_INTEGER (ntohl (lsa->header->seqnum)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 668 | break; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 669 | case OSPFv3AREALSDBAGE: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 670 | ospf6_lsa_age_current (lsa); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 671 | return SNMP_INTEGER (ntohs (lsa->header->age)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 672 | break; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 673 | case OSPFv3AREALSDBCHECKSUM: |
| 674 | return SNMP_INTEGER (ntohs (lsa->header->checksum)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 675 | break; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 676 | case OSPFv3AREALSDBADVERTISEMENT: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 677 | *var_len = ntohs (lsa->header->length); |
| 678 | return (u_char *) lsa->header; |
| 679 | break; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 680 | case OSPFv3AREALSDBTYPEKNOWN: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 681 | return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ? |
| 682 | SNMP_TRUE : SNMP_FALSE); |
| 683 | break; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 684 | } |
| 685 | return NULL; |
| 686 | } |
| 687 | |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 688 | static int |
| 689 | if_icmp_func (struct interface *ifp1, struct interface *ifp2) |
| 690 | { |
| 691 | return (ifp1->ifindex - ifp2->ifindex); |
| 692 | } |
| 693 | |
| 694 | static u_char * |
| 695 | ospfv3NbrEntry (struct variable *v, oid *name, size_t *length, |
| 696 | int exact, size_t *var_len, WriteMethod **write_method) |
| 697 | { |
| 698 | unsigned int ifindex, instid, rtrid; |
| 699 | struct ospf6_interface *oi = NULL; |
| 700 | struct ospf6_neighbor *on = NULL; |
| 701 | struct interface *iif; |
| 702 | struct listnode *i, *j; |
| 703 | struct list *ifslist; |
| 704 | oid *offset; |
| 705 | int offsetlen, len; |
| 706 | |
| 707 | if (smux_header_table (v, name, length, exact, var_len, write_method) |
| 708 | == MATCH_FAILED) |
| 709 | return NULL; |
| 710 | |
| 711 | ifindex = instid = rtrid = 0; |
| 712 | |
| 713 | /* Check OSPFv3 instance. */ |
| 714 | if (ospf6 == NULL) |
| 715 | return NULL; |
| 716 | |
| 717 | /* Get variable length. */ |
| 718 | offset = name + v->namelen; |
| 719 | offsetlen = *length - v->namelen; |
| 720 | |
| 721 | if (exact && offsetlen != 3) |
| 722 | return NULL; |
| 723 | |
| 724 | /* Parse if index */ |
| 725 | len = (offsetlen < 1 ? 0 : 1); |
| 726 | if (len) |
| 727 | ifindex = *offset; |
| 728 | offset += len; |
| 729 | offsetlen -= len; |
| 730 | |
| 731 | /* Parse instance ID */ |
| 732 | len = (offsetlen < 1 ? 0 : 1); |
| 733 | if (len) |
| 734 | instid = *offset; |
| 735 | offset += len; |
| 736 | offsetlen -= len; |
| 737 | |
| 738 | /* Parse router ID */ |
| 739 | len = (offsetlen < 1 ? 0 : 1); |
| 740 | if (len) |
| 741 | rtrid = htonl (*offset); |
| 742 | offset += len; |
| 743 | offsetlen -= len; |
| 744 | |
| 745 | if (exact) |
| 746 | { |
| 747 | oi = ospf6_interface_lookup_by_ifindex (ifindex); |
| 748 | on = ospf6_neighbor_lookup (rtrid, oi); |
| 749 | if (oi->instance_id != instid) return NULL; |
| 750 | } |
| 751 | else |
| 752 | { |
| 753 | /* We build a sorted list of interfaces */ |
| 754 | ifslist = list_new (); |
| 755 | if (!ifslist) return NULL; |
| 756 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; |
| 757 | for (ALL_LIST_ELEMENTS_RO (iflist, i, iif)) |
| 758 | listnode_add_sort (ifslist, iif); |
| 759 | |
| 760 | for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif)) |
| 761 | { |
| 762 | if (!iif->ifindex) continue; |
| 763 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); |
| 764 | if (!oi) continue; |
| 765 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) { |
| 766 | if (iif->ifindex > ifindex || |
| 767 | (iif->ifindex == ifindex && |
| 768 | (oi->instance_id > instid || |
| 769 | (oi->instance_id == instid && |
| 770 | ntohl (on->router_id) > ntohl (rtrid))))) |
| 771 | break; |
| 772 | } |
| 773 | if (on) break; |
| 774 | oi = on = NULL; |
| 775 | } |
| 776 | |
| 777 | list_delete_all_node (ifslist); |
| 778 | } |
| 779 | |
| 780 | if (!oi || !on) return NULL; |
| 781 | |
| 782 | /* Add Index (IfIndex, IfInstId, RtrId) */ |
| 783 | *length = v->namelen + 3; |
| 784 | offset = name + v->namelen; |
| 785 | *offset = oi->interface->ifindex; |
| 786 | offset++; |
| 787 | *offset = oi->instance_id; |
| 788 | offset++; |
| 789 | *offset = ntohl (on->router_id); |
| 790 | offset++; |
| 791 | |
| 792 | /* Return the current value of the variable */ |
| 793 | switch (v->magic) |
| 794 | { |
| 795 | case OSPFv3NBRADDRESSTYPE: |
| 796 | return SNMP_INTEGER (2); /* IPv6 only */ |
| 797 | case OSPFv3NBRADDRESS: |
| 798 | *var_len = sizeof (struct in6_addr); |
| 799 | return (u_char *) &on->linklocal_addr; |
| 800 | case OSPFv3NBROPTIONS: |
| 801 | return SNMP_INTEGER (on->options[2]); |
| 802 | case OSPFv3NBRPRIORITY: |
| 803 | return SNMP_INTEGER (on->priority); |
| 804 | case OSPFv3NBRSTATE: |
| 805 | return SNMP_INTEGER (on->state); |
| 806 | case OSPFv3NBREVENTS: |
| 807 | return SNMP_INTEGER (on->state_change); |
| 808 | case OSPFv3NBRLSRETRANSQLEN: |
| 809 | return SNMP_INTEGER (on->retrans_list->count); |
| 810 | case OSPFv3NBRHELLOSUPPRESSED: |
| 811 | return SNMP_INTEGER (SNMP_FALSE); |
| 812 | case OSPFv3NBRIFID: |
| 813 | return SNMP_INTEGER (on->ifindex); |
| 814 | case OSPFv3NBRRESTARTHELPERSTATUS: |
| 815 | case OSPFv3NBRRESTARTHELPERAGE: |
| 816 | case OSPFv3NBRRESTARTHELPEREXITREASON: |
| 817 | /* Not implemented. Only works if all the last ones are not |
| 818 | implemented! */ |
| 819 | return NULL; |
| 820 | } |
| 821 | |
| 822 | return NULL; |
| 823 | } |
| 824 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 825 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 826 | /* Register OSPFv3-MIB. */ |
| 827 | void |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 828 | ospf6_snmp_init (struct thread_master *master) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 829 | { |
hasso | c75105a | 2004-10-13 10:33:26 +0000 | [diff] [blame] | 830 | smux_init (master); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 831 | REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | #endif /* HAVE_SNMP */ |
| 835 | |