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 | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 93 | /* OSPFv3 MIB * Lsdb Table values: ospfv3*LsdbTable */ |
| 94 | #define OSPFv3WWLSDBSEQUENCE 1 |
| 95 | #define OSPFv3WWLSDBAGE 2 |
| 96 | #define OSPFv3WWLSDBCHECKSUM 3 |
| 97 | #define OSPFv3WWLSDBADVERTISEMENT 4 |
| 98 | #define OSPFv3WWLSDBTYPEKNOWN 5 |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 99 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 100 | /* Three first bits are to identify column */ |
| 101 | #define OSPFv3WWCOLUMN 0x7 |
| 102 | /* Then we use other bits to identify table */ |
| 103 | #define OSPFv3WWASTABLE (1 << 3) |
| 104 | #define OSPFv3WWAREATABLE (1 << 4) |
| 105 | #define OSPFv3WWLINKTABLE (1 << 5) |
| 106 | #define OSPFv3WWVIRTLINKTABLE (1 << 6) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 107 | |
| 108 | /* OSPFv3 MIB Host Table values: ospfv3HostTable */ |
| 109 | #define OSPFv3HOSTMETRIC 3 |
| 110 | #define OSPFv3HOSTROWSTATUS 4 |
| 111 | #define OSPFv3HOSTAREAID 5 |
| 112 | |
| 113 | /* OSPFv3 MIB Interface Table values: ospfv3IfTable */ |
| 114 | #define OSPFv3IFAREAID 3 |
| 115 | #define OSPFv3IFTYPE 4 |
| 116 | #define OSPFv3IFADMINSTATUS 5 |
| 117 | #define OSPFv3IFRTRPRIORITY 6 |
| 118 | #define OSPFv3IFTRANSITDELAY 7 |
| 119 | #define OSPFv3IFRETRANSINTERVAL 8 |
| 120 | #define OSPFv3IFHELLOINTERVAL 9 |
| 121 | #define OSPFv3IFRTRDEADINTERVAL 10 |
| 122 | #define OSPFv3IFPOLLINTERVAL 11 |
| 123 | #define OSPFv3IFSTATE 12 |
| 124 | #define OSPFv3IFDESIGNATEDROUTER 13 |
| 125 | #define OSPFv3IFBACKUPDESIGNATEDROUTER 14 |
| 126 | #define OSPFv3IFEVENTS 15 |
| 127 | #define OSPFv3IFROWSTATUS 16 |
| 128 | #define OSPFv3IFDEMAND 17 |
| 129 | #define OSPFv3IFMETRICVALUE 18 |
| 130 | #define OSPFv3IFLINKSCOPELSACOUNT 19 |
| 131 | #define OSPFv3IFLINKLSACKSUMSUM 20 |
| 132 | #define OSPFv3IFDEMANDNBRPROBE 21 |
| 133 | #define OSPFv3IFDEMANDNBRPROBERETRANSLIMIT 22 |
| 134 | #define OSPFv3IFDEMANDNBRPROBEINTERVAL 23 |
| 135 | #define OSPFv3IFTEDISABLED 24 |
| 136 | #define OSPFv3IFLINKLSASUPPRESSION 25 |
| 137 | |
| 138 | /* OSPFv3 MIB Virtual Interface Table values: ospfv3VirtIfTable */ |
| 139 | #define OSPFv3VIRTIFINDEX 3 |
| 140 | #define OSPFv3VIRTIFINSTID 4 |
| 141 | #define OSPFv3VIRTIFTRANSITDELAY 5 |
| 142 | #define OSPFv3VIRTIFRETRANSINTERVAL 6 |
| 143 | #define OSPFv3VIRTIFHELLOINTERVAL 7 |
| 144 | #define OSPFv3VIRTIFRTRDEADINTERVAL 8 |
| 145 | #define OSPFv3VIRTIFSTATE 9 |
| 146 | #define OSPFv3VIRTIFEVENTS 10 |
| 147 | #define OSPFv3VIRTIFROWSTATUS 11 |
| 148 | #define OSPFv3VIRTIFLINKSCOPELSACOUNT 12 |
| 149 | #define OSPFv3VIRTIFLINKLSACKSUMSUM 13 |
| 150 | |
| 151 | /* OSPFv3 MIB Neighbors Table values: ospfv3NbrTable */ |
| 152 | #define OSPFv3NBRADDRESSTYPE 4 |
| 153 | #define OSPFv3NBRADDRESS 5 |
| 154 | #define OSPFv3NBROPTIONS 6 |
| 155 | #define OSPFv3NBRPRIORITY 7 |
| 156 | #define OSPFv3NBRSTATE 8 |
| 157 | #define OSPFv3NBREVENTS 9 |
| 158 | #define OSPFv3NBRLSRETRANSQLEN 10 |
| 159 | #define OSPFv3NBRHELLOSUPPRESSED 11 |
| 160 | #define OSPFv3NBRIFID 12 |
| 161 | #define OSPFv3NBRRESTARTHELPERSTATUS 13 |
| 162 | #define OSPFv3NBRRESTARTHELPERAGE 14 |
| 163 | #define OSPFv3NBRRESTARTHELPEREXITREASON 15 |
| 164 | |
| 165 | /* OSPFv3 MIB Configured Neighbors Table values: ospfv3CfgNbrTable */ |
| 166 | #define OSPFv3CFGNBRPRIORITY 5 |
| 167 | #define OSPFv3CFGNBRROWSTATUS 6 |
| 168 | |
| 169 | /* OSPFv3 MIB Virtual Neighbors Table values: ospfv3VirtNbrTable */ |
| 170 | #define OSPFv3VIRTNBRIFINDEX 3 |
| 171 | #define OSPFv3VIRTNBRIFINSTID 4 |
| 172 | #define OSPFv3VIRTNBRADDRESSTYPE 5 |
| 173 | #define OSPFv3VIRTNBRADDRESS 6 |
| 174 | #define OSPFv3VIRTNBROPTIONS 7 |
| 175 | #define OSPFv3VIRTNBRSTATE 8 |
| 176 | #define OSPFv3VIRTNBREVENTS 9 |
| 177 | #define OSPFv3VIRTNBRLSRETRANSQLEN 10 |
| 178 | #define OSPFv3VIRTNBRHELLOSUPPRESSED 11 |
| 179 | #define OSPFv3VIRTNBRIFID 12 |
| 180 | #define OSPFv3VIRTNBRRESTARTHELPERSTATUS 13 |
| 181 | #define OSPFv3VIRTNBRRESTARTHELPERAGE 14 |
| 182 | #define OSPFv3VIRTNBRRESTARTHELPEREXITREASON 15 |
| 183 | |
| 184 | /* OSPFv3 MIB Area Aggregate Table values: ospfv3AreaAggregateTable */ |
| 185 | #define OSPFv3AREAAGGREGATEROWSTATUS 6 |
| 186 | #define OSPFv3AREAAGGREGATEEFFECT 7 |
| 187 | #define OSPFv3AREAAGGREGATEROUTETAG 8 |
| 188 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 189 | /* SYNTAX Status from OSPF-MIB. */ |
| 190 | #define OSPF_STATUS_ENABLED 1 |
| 191 | #define OSPF_STATUS_DISABLED 2 |
| 192 | |
| 193 | /* SNMP value hack. */ |
| 194 | #define COUNTER ASN_COUNTER |
| 195 | #define INTEGER ASN_INTEGER |
| 196 | #define GAUGE ASN_GAUGE |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 197 | #define UNSIGNED ASN_UNSIGNED |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 198 | #define TIMETICKS ASN_TIMETICKS |
| 199 | #define IPADDRESS ASN_IPADDRESS |
| 200 | #define STRING ASN_OCTET_STR |
| 201 | |
| 202 | /* For return values e.g. SNMP_INTEGER macro */ |
| 203 | SNMP_LOCAL_VARIABLES |
| 204 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 205 | /* OSPFv3-MIB instances. */ |
| 206 | oid ospfv3_oid [] = { OSPFv3MIB }; |
Vincent Bernat | bf83666 | 2012-06-04 14:36:12 +0200 | [diff] [blame] | 207 | oid ospfv3_trap_oid [] = { OSPFv3MIB, 0 }; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 208 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 209 | /* Hook functions. */ |
Chris Caputo | 0be8dfb | 2009-06-02 18:40:07 +0100 | [diff] [blame] | 210 | static u_char *ospfv3GeneralGroup (struct variable *, oid *, size_t *, |
| 211 | int, size_t *, WriteMethod **); |
| 212 | static u_char *ospfv3AreaEntry (struct variable *, oid *, size_t *, |
| 213 | int, size_t *, WriteMethod **); |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 214 | static u_char *ospfv3WwLsdbEntry (struct variable *, oid *, size_t *, |
| 215 | int, size_t *, WriteMethod **); |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 216 | static u_char *ospfv3NbrEntry (struct variable *, oid *, size_t *, |
| 217 | int, size_t *, WriteMethod **); |
Vincent Bernat | 3bc4f84 | 2012-06-04 11:40:04 +0200 | [diff] [blame] | 218 | static u_char *ospfv3IfEntry (struct variable *, oid *, size_t *, |
| 219 | int, size_t *, WriteMethod **); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 220 | |
| 221 | struct variable ospfv3_variables[] = |
| 222 | { |
| 223 | /* OSPF general variables */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 224 | {OSPFv3ROUTERID, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 225 | 3, {1, 1, 1}}, |
| 226 | {OSPFv3ADMINSTAT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 227 | 3, {1, 1, 2}}, |
| 228 | {OSPFv3VERSIONNUMBER, INTEGER, RONLY, ospfv3GeneralGroup, |
| 229 | 3, {1, 1, 3}}, |
| 230 | {OSPFv3AREABDRRTRSTATUS, INTEGER, RONLY, ospfv3GeneralGroup, |
| 231 | 3, {1, 1, 4}}, |
| 232 | {OSPFv3ASBDRRTRSTATUS, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 233 | 3, {1, 1, 5}}, |
| 234 | {OSPFv3ASSCOPELSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, |
| 235 | 3, {1, 1, 6}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 236 | {OSPFv3ASSCOPELSACHECKSUMSUM,UNSIGNED, RONLY, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 237 | 3, {1, 1, 7}}, |
| 238 | {OSPFv3ORIGINATENEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup, |
| 239 | 3, {1, 1, 8}}, |
| 240 | {OSPFv3RXNEWLSAS, COUNTER, RONLY, ospfv3GeneralGroup, |
| 241 | 3, {1, 1, 9}}, |
| 242 | {OSPFv3EXTLSACOUNT, GAUGE, RONLY, ospfv3GeneralGroup, |
| 243 | 3, {1, 1, 10}}, |
| 244 | {OSPFv3EXTAREALSDBLIMIT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 245 | 3, {1, 1, 11}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 246 | {OSPFv3EXITOVERFLOWINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 247 | 3, {1, 1, 12}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 248 | {OSPFv3DEMANDEXTENSIONS, INTEGER, RWRITE, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 249 | 3, {1, 1, 13}}, |
| 250 | {OSPFv3REFERENCEBANDWIDTH, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 251 | 3, {1, 1, 14}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 252 | {OSPFv3RESTARTSUPPORT, INTEGER, RWRITE, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 253 | 3, {1, 1, 15}}, |
| 254 | {OSPFv3RESTARTINTERVAL, UNSIGNED, RWRITE, ospfv3GeneralGroup, |
| 255 | 3, {1, 1, 16}}, |
| 256 | {OSPFv3RESTARTSTRICTLSACHECKING, INTEGER, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 257 | 3, {1, 1, 17}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 258 | {OSPFv3RESTARTSTATUS, INTEGER, RONLY, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 259 | 3, {1, 1, 18}}, |
| 260 | {OSPFv3RESTARTAGE, UNSIGNED, RONLY, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 261 | 3, {1, 1, 19}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 262 | {OSPFv3RESTARTEXITREASON, INTEGER, RONLY, ospfv3GeneralGroup, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 263 | 3, {1, 1, 20}}, |
| 264 | {OSPFv3NOTIFICATIONENABLE, INTEGER, RWRITE, ospfv3GeneralGroup, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 265 | 3, {1, 1, 21}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 266 | {OSPFv3STUBROUTERSUPPORT, INTEGER, RONLY, ospfv3GeneralGroup, |
| 267 | 3, {1, 1, 22}}, |
| 268 | {OSPFv3STUBROUTERADVERTISEMENT, INTEGER, RWRITE, ospfv3GeneralGroup, |
| 269 | 3, {1, 1, 23}}, |
| 270 | {OSPFv3DISCONTINUITYTIME, TIMETICKS, RONLY, ospfv3GeneralGroup, |
| 271 | 3, {1, 1, 24}}, |
| 272 | {OSPFv3RESTARTTIME, TIMETICKS, RONLY, ospfv3GeneralGroup, |
| 273 | 3, {1, 1, 25}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 274 | |
| 275 | /* OSPFv3 Area Data Structure */ |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 276 | {OSPFv3IMPORTASEXTERN, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 277 | 4, {1, 2, 1, 2}}, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 278 | {OSPFv3AREASPFRUNS, COUNTER, RONLY, ospfv3AreaEntry, |
| 279 | 4, {1, 2, 1, 3}}, |
| 280 | {OSPFv3AREABDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 281 | 4, {1, 2, 1, 4}}, |
| 282 | {OSPFv3AREAASBDRRTRCOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 283 | 4, {1, 2, 1, 5}}, |
| 284 | {OSPFv3AREASCOPELSACOUNT, GAUGE, RONLY, ospfv3AreaEntry, |
| 285 | 4, {1, 2, 1, 6}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 286 | {OSPFv3AREASCOPELSACKSUMSUM, UNSIGNED, RONLY, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 287 | 4, {1, 2, 1, 7}}, |
| 288 | {OSPFv3AREASUMMARY, INTEGER, RWRITE, ospfv3AreaEntry, |
| 289 | 4, {1, 2, 1, 8}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 290 | {OSPFv3AREAROWSTATUS, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 291 | 4, {1, 2, 1, 9}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 292 | {OSPFv3AREASTUBMETRIC, INTEGER, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 293 | 4, {1, 2, 1, 10}}, |
| 294 | {OSPFv3AREANSSATRANSLATORROLE, INTEGER, RWRITE, ospfv3AreaEntry, |
| 295 | 4, {1, 2, 1, 11}}, |
| 296 | {OSPFv3AREANSSATRANSLATORSTATE, INTEGER, RONLY, ospfv3AreaEntry, |
| 297 | 4, {1, 2, 1, 12}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 298 | {OSPFv3AREANSSATRANSLATORSTABINTERVAL, UNSIGNED, RWRITE, ospfv3AreaEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 299 | 4, {1, 2, 1, 13}}, |
| 300 | {OSPFv3AREANSSATRANSLATOREVENTS, COUNTER, RONLY, ospfv3AreaEntry, |
| 301 | 4, {1, 2, 1, 14}}, |
| 302 | {OSPFv3AREASTUBMETRICTYPE, INTEGER, RWRITE, ospfv3AreaEntry, |
| 303 | 4, {1, 2, 1, 15}}, |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 304 | {OSPFv3AREATEENABLED, INTEGER, RWRITE, ospfv3AreaEntry, |
| 305 | 4, {1, 2, 1, 16}}, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 306 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 307 | /* OSPFv3 AS LSDB */ |
| 308 | {OSPFv3WWLSDBSEQUENCE | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 309 | 4, {1, 3, 1, 4}}, |
| 310 | {OSPFv3WWLSDBAGE | OSPFv3WWASTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry, |
| 311 | 4, {1, 3, 1, 5}}, |
| 312 | {OSPFv3WWLSDBCHECKSUM | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 313 | 4, {1, 3, 1, 6}}, |
| 314 | {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWASTABLE, STRING, RONLY, ospfv3WwLsdbEntry, |
| 315 | 4, {1, 3, 1, 7}}, |
| 316 | {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWASTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 317 | 4, {1, 3, 1, 8}}, |
| 318 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 319 | /* OSPFv3 Area LSDB */ |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 320 | {OSPFv3WWLSDBSEQUENCE | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 321 | 4, {1, 4, 1, 5}}, |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 322 | {OSPFv3WWLSDBAGE | OSPFv3WWAREATABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 323 | 4, {1, 4, 1, 6}}, |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 324 | {OSPFv3WWLSDBCHECKSUM | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 325 | 4, {1, 4, 1, 7}}, |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 326 | {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWAREATABLE, STRING, RONLY, ospfv3WwLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 327 | 4, {1, 4, 1, 8}}, |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 328 | {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWAREATABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 329 | 4, {1, 4, 1, 9}}, |
| 330 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 331 | /* OSPFv3 Link LSDB */ |
| 332 | {OSPFv3WWLSDBSEQUENCE | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 333 | 4, {1, 5, 1, 6}}, |
| 334 | {OSPFv3WWLSDBAGE | OSPFv3WWLINKTABLE, UNSIGNED, RONLY, ospfv3WwLsdbEntry, |
| 335 | 4, {1, 5, 1, 7}}, |
| 336 | {OSPFv3WWLSDBCHECKSUM | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 337 | 4, {1, 5, 1, 8}}, |
| 338 | {OSPFv3WWLSDBADVERTISEMENT | OSPFv3WWLINKTABLE, STRING, RONLY, ospfv3WwLsdbEntry, |
| 339 | 4, {1, 5, 1, 9}}, |
| 340 | {OSPFv3WWLSDBTYPEKNOWN | OSPFv3WWLINKTABLE, INTEGER, RONLY, ospfv3WwLsdbEntry, |
| 341 | 4, {1, 5, 1, 10}}, |
| 342 | |
Vincent Bernat | 3bc4f84 | 2012-06-04 11:40:04 +0200 | [diff] [blame] | 343 | /* OSPFv3 interfaces */ |
| 344 | {OSPFv3IFAREAID, UNSIGNED, RONLY, ospfv3IfEntry, |
| 345 | 4, {1, 7, 1, 3}}, |
| 346 | {OSPFv3IFTYPE, INTEGER, RONLY, ospfv3IfEntry, |
| 347 | 4, {1, 7, 1, 4}}, |
| 348 | {OSPFv3IFADMINSTATUS, INTEGER, RONLY, ospfv3IfEntry, |
| 349 | 4, {1, 7, 1, 5}}, |
| 350 | {OSPFv3IFRTRPRIORITY, INTEGER, RONLY, ospfv3IfEntry, |
| 351 | 4, {1, 7, 1, 6}}, |
| 352 | {OSPFv3IFTRANSITDELAY, UNSIGNED, RONLY, ospfv3IfEntry, |
| 353 | 4, {1, 7, 1, 7}}, |
| 354 | {OSPFv3IFRETRANSINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry, |
| 355 | 4, {1, 7, 1, 8}}, |
| 356 | {OSPFv3IFHELLOINTERVAL, INTEGER, RONLY, ospfv3IfEntry, |
| 357 | 4, {1, 7, 1, 9}}, |
| 358 | {OSPFv3IFRTRDEADINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry, |
| 359 | 4, {1, 7, 1, 10}}, |
| 360 | {OSPFv3IFPOLLINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry, |
| 361 | 4, {1, 7, 1, 11}}, |
| 362 | {OSPFv3IFSTATE, INTEGER, RONLY, ospfv3IfEntry, |
| 363 | 4, {1, 7, 1, 12}}, |
| 364 | {OSPFv3IFDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry, |
| 365 | 4, {1, 7, 1, 13}}, |
| 366 | {OSPFv3IFBACKUPDESIGNATEDROUTER, UNSIGNED, RONLY, ospfv3IfEntry, |
| 367 | 4, {1, 7, 1, 14}}, |
| 368 | {OSPFv3IFEVENTS, COUNTER, RONLY, ospfv3IfEntry, |
| 369 | 4, {1, 7, 1, 15}}, |
| 370 | {OSPFv3IFROWSTATUS, INTEGER, RONLY, ospfv3IfEntry, |
| 371 | 4, {1, 7, 1, 16}}, |
| 372 | {OSPFv3IFDEMAND, INTEGER, RONLY, ospfv3IfEntry, |
| 373 | 4, {1, 7, 1, 17}}, |
| 374 | {OSPFv3IFMETRICVALUE, INTEGER, RONLY, ospfv3IfEntry, |
| 375 | 4, {1, 7, 1, 18}}, |
| 376 | {OSPFv3IFLINKSCOPELSACOUNT, GAUGE, RONLY, ospfv3IfEntry, |
| 377 | 4, {1, 7, 1, 19}}, |
| 378 | {OSPFv3IFLINKLSACKSUMSUM, UNSIGNED, RONLY, ospfv3IfEntry, |
| 379 | 4, {1, 7, 1, 20}}, |
| 380 | {OSPFv3IFDEMANDNBRPROBE, INTEGER, RONLY, ospfv3IfEntry, |
| 381 | 4, {1, 7, 1, 21}}, |
| 382 | {OSPFv3IFDEMANDNBRPROBERETRANSLIMIT, UNSIGNED, RONLY, ospfv3IfEntry, |
| 383 | 4, {1, 7, 1, 22}}, |
| 384 | {OSPFv3IFDEMANDNBRPROBEINTERVAL, UNSIGNED, RONLY, ospfv3IfEntry, |
| 385 | 4, {1, 7, 1, 23}}, |
| 386 | {OSPFv3IFTEDISABLED, INTEGER, RONLY, ospfv3IfEntry, |
| 387 | 4, {1, 7, 1, 24}}, |
| 388 | {OSPFv3IFLINKLSASUPPRESSION, INTEGER, RONLY, ospfv3IfEntry, |
| 389 | 4, {1, 7, 1, 25}}, |
| 390 | |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 391 | /* OSPFv3 neighbors */ |
| 392 | {OSPFv3NBRADDRESSTYPE, INTEGER, RONLY, ospfv3NbrEntry, |
| 393 | 4, {1, 9, 1, 4}}, |
| 394 | {OSPFv3NBRADDRESS, STRING, RONLY, ospfv3NbrEntry, |
| 395 | 4, {1, 9, 1, 5}}, |
| 396 | {OSPFv3NBROPTIONS, INTEGER, RONLY, ospfv3NbrEntry, |
| 397 | 4, {1, 9, 1, 6}}, |
| 398 | {OSPFv3NBRPRIORITY, INTEGER, RONLY, ospfv3NbrEntry, |
| 399 | 4, {1, 9, 1, 7}}, |
| 400 | {OSPFv3NBRSTATE, INTEGER, RONLY, ospfv3NbrEntry, |
| 401 | 4, {1, 9, 1, 8}}, |
| 402 | {OSPFv3NBREVENTS, COUNTER, RONLY, ospfv3NbrEntry, |
| 403 | 4, {1, 9, 1, 9}}, |
| 404 | {OSPFv3NBRLSRETRANSQLEN, GAUGE, RONLY, ospfv3NbrEntry, |
| 405 | 4, {1, 9, 1, 10}}, |
| 406 | {OSPFv3NBRHELLOSUPPRESSED, INTEGER, RONLY, ospfv3NbrEntry, |
| 407 | 4, {1, 9, 1, 11}}, |
| 408 | {OSPFv3NBRIFID, INTEGER, RONLY, ospfv3NbrEntry, |
| 409 | 4, {1, 9, 1, 12}}, |
| 410 | {OSPFv3NBRRESTARTHELPERSTATUS, INTEGER, RONLY, ospfv3NbrEntry, |
| 411 | 4, {1, 9, 1, 13}}, |
| 412 | {OSPFv3NBRRESTARTHELPERAGE, UNSIGNED, RONLY, ospfv3NbrEntry, |
| 413 | 4, {1, 9, 1, 14}}, |
| 414 | {OSPFv3NBRRESTARTHELPEREXITREASON, INTEGER, RONLY, ospfv3NbrEntry, |
| 415 | 4, {1, 9, 1, 15}}, |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 416 | }; |
| 417 | |
| 418 | static u_char * |
| 419 | ospfv3GeneralGroup (struct variable *v, oid *name, size_t *length, |
| 420 | int exact, size_t *var_len, WriteMethod **write_method) |
| 421 | { |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 422 | u_int16_t sum; |
| 423 | u_int32_t count; |
| 424 | struct ospf6_lsa *lsa = NULL; |
| 425 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 426 | /* Check whether the instance identifier is valid */ |
| 427 | if (smux_header_generic (v, name, length, exact, var_len, write_method) |
| 428 | == MATCH_FAILED) |
| 429 | return NULL; |
| 430 | |
| 431 | /* Return the current value of the variable */ |
| 432 | switch (v->magic) |
| 433 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 434 | case OSPFv3ROUTERID: |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 435 | /* Router-ID of this OSPF instance. */ |
| 436 | if (ospf6) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 437 | return SNMP_INTEGER (ntohl (ospf6->router_id)); |
| 438 | return SNMP_INTEGER (0); |
| 439 | case OSPFv3ADMINSTAT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 440 | if (ospf6) |
| 441 | return SNMP_INTEGER (CHECK_FLAG (ospf6->flag, OSPF6_DISABLED)? |
| 442 | OSPF_STATUS_DISABLED:OSPF_STATUS_ENABLED); |
| 443 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 444 | case OSPFv3VERSIONNUMBER: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 445 | return SNMP_INTEGER (3); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 446 | case OSPFv3AREABDRRTRSTATUS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 447 | if (ospf6) |
| 448 | return SNMP_INTEGER (ospf6_is_router_abr (ospf6)?SNMP_TRUE:SNMP_FALSE); |
| 449 | return SNMP_INTEGER (SNMP_FALSE); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 450 | case OSPFv3ASBDRRTRSTATUS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 451 | if (ospf6) |
| 452 | return SNMP_INTEGER (ospf6_asbr_is_asbr (ospf6)?SNMP_TRUE:SNMP_FALSE); |
| 453 | return SNMP_INTEGER (SNMP_FALSE); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 454 | case OSPFv3ASSCOPELSACOUNT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 455 | if (ospf6) |
| 456 | return SNMP_INTEGER (ospf6->lsdb->count); |
| 457 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 458 | case OSPFv3ASSCOPELSACHECKSUMSUM: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 459 | if (ospf6) |
| 460 | { |
| 461 | for (sum = 0, lsa = ospf6_lsdb_head (ospf6->lsdb); |
| 462 | lsa; |
| 463 | lsa = ospf6_lsdb_next (lsa)) |
| 464 | sum += ntohs (lsa->header->checksum); |
| 465 | return SNMP_INTEGER (sum); |
| 466 | } |
| 467 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 468 | case OSPFv3ORIGINATENEWLSAS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 469 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 470 | case OSPFv3RXNEWLSAS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 471 | return SNMP_INTEGER (0); /* Don't know where to get this value... */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 472 | case OSPFv3EXTLSACOUNT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 473 | if (ospf6) |
| 474 | { |
| 475 | for (count = 0, lsa = ospf6_lsdb_type_head (htons (OSPF6_LSTYPE_AS_EXTERNAL), |
| 476 | ospf6->lsdb); |
| 477 | lsa; |
| 478 | lsa = ospf6_lsdb_type_next (htons (OSPF6_LSTYPE_AS_EXTERNAL), |
| 479 | lsa)) |
| 480 | count += 1; |
| 481 | return SNMP_INTEGER (count); |
| 482 | } |
| 483 | return SNMP_INTEGER (0); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 484 | case OSPFv3EXTAREALSDBLIMIT: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 485 | return SNMP_INTEGER (-1); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 486 | case OSPFv3EXITOVERFLOWINTERVAL: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 487 | return SNMP_INTEGER (0); /* Not supported */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 488 | case OSPFv3DEMANDEXTENSIONS: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 489 | return SNMP_INTEGER (0); /* Not supported */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 490 | case OSPFv3REFERENCEBANDWIDTH: |
Vincent Bernat | 2c5f148 | 2012-06-01 11:38:34 +0200 | [diff] [blame] | 491 | return SNMP_INTEGER (100000); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 492 | case OSPFv3RESTARTSUPPORT: |
| 493 | case OSPFv3RESTARTINTERVAL: |
| 494 | case OSPFv3RESTARTSTRICTLSACHECKING: |
| 495 | case OSPFv3RESTARTSTATUS: |
| 496 | case OSPFv3RESTARTAGE: |
| 497 | case OSPFv3RESTARTEXITREASON: |
| 498 | case OSPFv3NOTIFICATIONENABLE: |
| 499 | case OSPFv3STUBROUTERSUPPORT: |
| 500 | case OSPFv3STUBROUTERADVERTISEMENT: |
| 501 | case OSPFv3DISCONTINUITYTIME: |
| 502 | case OSPFv3RESTARTTIME: |
| 503 | /* TODO: Not implemented */ |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 504 | return NULL; |
| 505 | } |
| 506 | return NULL; |
| 507 | } |
| 508 | |
| 509 | static u_char * |
| 510 | ospfv3AreaEntry (struct variable *v, oid *name, size_t *length, |
| 511 | int exact, size_t *var_len, WriteMethod **write_method) |
| 512 | { |
| 513 | struct ospf6_area *oa, *area = NULL; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 514 | struct ospf6_lsa *lsa = NULL; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 515 | u_int32_t area_id = 0; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 516 | u_int32_t count; |
| 517 | u_int16_t sum; |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 518 | struct listnode *node; |
| 519 | unsigned int len; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 520 | char a[16]; |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 521 | struct ospf6_route *ro; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 522 | |
| 523 | if (ospf6 == NULL) |
| 524 | return NULL; |
| 525 | |
Vincent Bernat | 8046ba6 | 2012-05-31 13:30:28 +0200 | [diff] [blame] | 526 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
| 527 | == MATCH_FAILED) |
| 528 | return NULL; |
| 529 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 530 | len = *length - v->namelen; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 531 | len = (len >= 1 ? sizeof 1 : 0); |
| 532 | if (exact && len != 1) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 533 | return NULL; |
| 534 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 535 | area_id = htonl (name[v->namelen]); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 536 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 537 | inet_ntop (AF_INET, &area_id, a, sizeof (a)); |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 538 | 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] | 539 | a, exact, len, (u_long)*length); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 540 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 541 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 542 | { |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 543 | if (area == NULL) |
| 544 | { |
| 545 | if (len == 0) /* return first area entry */ |
| 546 | area = oa; |
| 547 | else if (exact && ntohl (oa->area_id) == ntohl (area_id)) |
| 548 | area = oa; |
| 549 | else if (ntohl (oa->area_id) > ntohl (area_id)) |
| 550 | area = oa; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | if (area == NULL) |
| 555 | return NULL; |
| 556 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 557 | *length = v->namelen + 1; |
| 558 | name[v->namelen] = ntohl (area->area_id); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 559 | |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 560 | inet_ntop (AF_INET, &area->area_id, a, sizeof (a)); |
Andrew J. Schorr | eda9ba7 | 2007-04-27 18:13:15 +0000 | [diff] [blame] | 561 | zlog_debug ("SNMP found area: %s, exact=%d len=%d length=%lu", |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 562 | a, exact, len, (u_long)*length); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 563 | |
| 564 | switch (v->magic) |
| 565 | { |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 566 | case OSPFv3IMPORTASEXTERN: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 567 | /* No NSSA support */ |
| 568 | return SNMP_INTEGER (IS_AREA_STUB(area)?2:1); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 569 | case OSPFv3AREASPFRUNS: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 570 | return SNMP_INTEGER (area->spf_calculation); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 571 | case OSPFv3AREABDRRTRCOUNT: |
| 572 | case OSPFv3AREAASBDRRTRCOUNT: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 573 | count = 0; |
| 574 | for (ro = ospf6_route_head (ospf6->brouter_table); ro; |
| 575 | ro = ospf6_route_next (ro)) |
| 576 | { |
| 577 | if (ntohl (ro->path.area_id) != ntohl (area->area_id)) continue; |
| 578 | if (v->magic == OSPFv3AREABDRRTRCOUNT && |
| 579 | CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_B)) |
| 580 | count++; |
| 581 | if (v->magic == OSPFv3AREAASBDRRTRCOUNT && |
| 582 | CHECK_FLAG (ro->path.router_bits, OSPF6_ROUTER_BIT_E)) |
| 583 | count++; |
| 584 | } |
| 585 | return SNMP_INTEGER (count); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 586 | case OSPFv3AREASCOPELSACOUNT: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 587 | return SNMP_INTEGER (area->lsdb->count); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 588 | case OSPFv3AREASCOPELSACKSUMSUM: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 589 | for (sum = 0, lsa = ospf6_lsdb_head (area->lsdb); |
| 590 | lsa; |
| 591 | lsa = ospf6_lsdb_next (lsa)) |
| 592 | sum += ntohs (lsa->header->checksum); |
| 593 | return SNMP_INTEGER (sum); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 594 | case OSPFv3AREASUMMARY: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 595 | return SNMP_INTEGER (2); /* sendAreaSummary */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 596 | case OSPFv3AREAROWSTATUS: |
Vincent Bernat | ea86e40 | 2012-06-04 10:29:49 +0200 | [diff] [blame] | 597 | return SNMP_INTEGER (1); /* Active */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 598 | case OSPFv3AREASTUBMETRIC: |
| 599 | case OSPFv3AREANSSATRANSLATORROLE: |
| 600 | case OSPFv3AREANSSATRANSLATORSTATE: |
| 601 | case OSPFv3AREANSSATRANSLATORSTABINTERVAL: |
| 602 | case OSPFv3AREANSSATRANSLATOREVENTS: |
| 603 | case OSPFv3AREASTUBMETRICTYPE: |
| 604 | case OSPFv3AREATEENABLED: |
| 605 | /* Not implemented. */ |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 606 | return NULL; |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 607 | } |
| 608 | return NULL; |
| 609 | } |
| 610 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 611 | static int |
| 612 | if_icmp_func (struct interface *ifp1, struct interface *ifp2) |
| 613 | { |
| 614 | return (ifp1->ifindex - ifp2->ifindex); |
| 615 | } |
| 616 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 617 | static u_char * |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 618 | ospfv3WwLsdbEntry (struct variable *v, oid *name, size_t *length, |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 619 | int exact, size_t *var_len, WriteMethod **write_method) |
| 620 | { |
| 621 | struct ospf6_lsa *lsa = NULL; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 622 | u_int32_t ifindex, area_id, id, instid, adv_router; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 623 | u_int16_t type; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 624 | int len; |
| 625 | oid *offset; |
| 626 | int offsetlen; |
| 627 | char a[16], b[16], c[16]; |
| 628 | struct ospf6_area *oa; |
hasso | b3c8c46 | 2004-11-26 12:55:51 +0000 | [diff] [blame] | 629 | struct listnode *node; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 630 | struct interface *iif; |
| 631 | struct ospf6_interface *oi = NULL; |
| 632 | struct list *ifslist; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 633 | |
Vincent Bernat | 8046ba6 | 2012-05-31 13:30:28 +0200 | [diff] [blame] | 634 | if (smux_header_table(v, name, length, exact, var_len, write_method) |
| 635 | == MATCH_FAILED) |
| 636 | return NULL; |
| 637 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 638 | instid = ifindex = area_id = type = id = adv_router = 0; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 639 | |
| 640 | /* Check OSPFv3 instance. */ |
| 641 | if (ospf6 == NULL) |
| 642 | return NULL; |
| 643 | |
| 644 | /* Get variable length. */ |
| 645 | offset = name + v->namelen; |
| 646 | offsetlen = *length - v->namelen; |
| 647 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 648 | if (exact && (v->magic & OSPFv3WWASTABLE) && offsetlen != 3) |
| 649 | return NULL; |
| 650 | if (exact && (v->magic & OSPFv3WWAREATABLE) && offsetlen != 4) |
| 651 | return NULL; |
| 652 | if (exact && (v->magic & OSPFv3WWLINKTABLE) && offsetlen != 5) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 653 | return NULL; |
| 654 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 655 | if (v->magic & OSPFv3WWLINKTABLE) |
| 656 | { |
| 657 | /* Parse ifindex */ |
| 658 | len = (offsetlen < 1 ? 0 : 1); |
| 659 | if (len) |
| 660 | ifindex = *offset; |
| 661 | offset += len; |
| 662 | offsetlen -= len; |
| 663 | |
| 664 | /* Parse instance ID */ |
| 665 | len = (offsetlen < 1 ? 0 : 1); |
| 666 | if (len) |
| 667 | instid = *offset; |
| 668 | offset += len; |
| 669 | offsetlen -= len; |
| 670 | } |
| 671 | else if (v->magic & OSPFv3WWAREATABLE) |
| 672 | { |
| 673 | /* Parse area-id */ |
| 674 | len = (offsetlen < 1 ? 0 : 1); |
| 675 | if (len) |
| 676 | area_id = htonl (*offset); |
| 677 | offset += len; |
| 678 | offsetlen -= len; |
| 679 | } |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 680 | |
| 681 | /* Parse type */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 682 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 683 | if (len) |
| 684 | type = htons (*offset); |
| 685 | offset += len; |
| 686 | offsetlen -= len; |
| 687 | |
| 688 | /* Parse Router-ID */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 689 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 690 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 691 | adv_router = htonl (*offset); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 692 | offset += len; |
| 693 | offsetlen -= len; |
| 694 | |
| 695 | /* Parse LS-ID */ |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 696 | len = (offsetlen < 1 ? 0 : 1); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 697 | if (len) |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 698 | id = htonl (*offset); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 699 | offset += len; |
| 700 | offsetlen -= len; |
| 701 | |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 702 | if (exact) |
| 703 | { |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 704 | if (v->magic & OSPFv3WWASTABLE) |
| 705 | { |
| 706 | lsa = ospf6_lsdb_lookup (type, id, adv_router, ospf6->lsdb); |
| 707 | } |
| 708 | else if (v->magic & OSPFv3WWAREATABLE) |
| 709 | { |
| 710 | oa = ospf6_area_lookup (area_id, ospf6); |
Vincent Bernat | 0402ca4 | 2012-07-10 09:27:57 +0200 | [diff] [blame^] | 711 | if (!oa) return NULL; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 712 | lsa = ospf6_lsdb_lookup (type, id, adv_router, oa->lsdb); |
| 713 | } |
| 714 | else if (v->magic & OSPFv3WWLINKTABLE) |
| 715 | { |
| 716 | oi = ospf6_interface_lookup_by_ifindex (ifindex); |
Vincent Bernat | 0402ca4 | 2012-07-10 09:27:57 +0200 | [diff] [blame^] | 717 | if (!oi || oi->instance_id != instid) return NULL; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 718 | lsa = ospf6_lsdb_lookup (type, id, adv_router, oi->lsdb); |
| 719 | } |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 720 | } |
| 721 | else |
| 722 | { |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 723 | if (v->magic & OSPFv3WWASTABLE) |
| 724 | { |
| 725 | if (ospf6->lsdb->count) |
| 726 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, |
| 727 | ospf6->lsdb); |
| 728 | } |
| 729 | else if (v->magic & OSPFv3WWAREATABLE) |
| 730 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
| 731 | { |
| 732 | if (oa->area_id < area_id) |
| 733 | continue; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 734 | |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 735 | if (oa->lsdb->count) |
| 736 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, |
| 737 | oa->lsdb); |
| 738 | if (lsa) break; |
| 739 | type = 0; |
| 740 | id = 0; |
| 741 | adv_router = 0; |
| 742 | } |
| 743 | else if (v->magic & OSPFv3WWLINKTABLE) |
| 744 | { |
| 745 | /* We build a sorted list of interfaces */ |
| 746 | ifslist = list_new (); |
| 747 | if (!ifslist) return NULL; |
| 748 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; |
| 749 | for (ALL_LIST_ELEMENTS_RO (iflist, node, iif)) |
| 750 | listnode_add_sort (ifslist, iif); |
| 751 | |
| 752 | for (ALL_LIST_ELEMENTS_RO (ifslist, node, iif)) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 753 | { |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 754 | if (!iif->ifindex) continue; |
| 755 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); |
| 756 | if (!oi) continue; |
| 757 | if (iif->ifindex < ifindex) continue; |
| 758 | if (oi->instance_id < instid) continue; |
| 759 | |
| 760 | if (oi->lsdb->count) |
| 761 | lsa = ospf6_lsdb_lookup_next (type, id, adv_router, |
| 762 | oi->lsdb); |
| 763 | if (lsa) break; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 764 | type = 0; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 765 | id = 0; |
| 766 | adv_router = 0; |
| 767 | oi = NULL; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 768 | } |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 769 | |
| 770 | list_delete_all_node (ifslist); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 771 | } |
| 772 | } |
| 773 | |
| 774 | if (! lsa) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 775 | return NULL; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 776 | |
| 777 | /* Add indexes */ |
| 778 | if (v->magic & OSPFv3WWASTABLE) |
| 779 | { |
| 780 | *length = v->namelen + 3; |
| 781 | offset = name + v->namelen; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 782 | } |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 783 | else if (v->magic & OSPFv3WWAREATABLE) |
| 784 | { |
| 785 | *length = v->namelen + 4; |
| 786 | offset = name + v->namelen; |
| 787 | *offset = ntohl (oa->area_id); |
| 788 | offset++; |
| 789 | } |
| 790 | else if (v->magic & OSPFv3WWLINKTABLE) |
| 791 | { |
| 792 | *length = v->namelen + 5; |
| 793 | offset = name + v->namelen; |
| 794 | *offset = oi->interface->ifindex; |
| 795 | offset++; |
| 796 | *offset = oi->instance_id; |
| 797 | offset++; |
| 798 | } |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 799 | *offset = ntohs (lsa->header->type); |
| 800 | offset++; |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 801 | *offset = ntohl (lsa->header->adv_router); |
| 802 | offset++; |
| 803 | *offset = ntohl (lsa->header->id); |
| 804 | offset++; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 805 | |
| 806 | /* Return the current value of the variable */ |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 807 | switch (v->magic & OSPFv3WWCOLUMN) |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 808 | { |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 809 | case OSPFv3WWLSDBSEQUENCE: |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 810 | return SNMP_INTEGER (ntohl (lsa->header->seqnum)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 811 | break; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 812 | case OSPFv3WWLSDBAGE: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 813 | ospf6_lsa_age_current (lsa); |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 814 | return SNMP_INTEGER (ntohs (lsa->header->age)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 815 | break; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 816 | case OSPFv3WWLSDBCHECKSUM: |
Vincent Bernat | 0f0ab51 | 2012-05-22 13:34:24 +0200 | [diff] [blame] | 817 | return SNMP_INTEGER (ntohs (lsa->header->checksum)); |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 818 | break; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 819 | case OSPFv3WWLSDBADVERTISEMENT: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 820 | *var_len = ntohs (lsa->header->length); |
| 821 | return (u_char *) lsa->header; |
| 822 | break; |
Vincent Bernat | c349bb8 | 2012-06-04 12:59:20 +0200 | [diff] [blame] | 823 | case OSPFv3WWLSDBTYPEKNOWN: |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 824 | return SNMP_INTEGER (OSPF6_LSA_IS_KNOWN (lsa->header->type) ? |
| 825 | SNMP_TRUE : SNMP_FALSE); |
| 826 | break; |
hasso | 2680aa2 | 2004-11-25 20:54:46 +0000 | [diff] [blame] | 827 | } |
| 828 | return NULL; |
| 829 | } |
| 830 | |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 831 | static u_char * |
Vincent Bernat | 3bc4f84 | 2012-06-04 11:40:04 +0200 | [diff] [blame] | 832 | ospfv3IfEntry (struct variable *v, oid *name, size_t *length, |
| 833 | int exact, size_t *var_len, WriteMethod **write_method) |
| 834 | { |
| 835 | unsigned int ifindex, instid; |
| 836 | struct ospf6_interface *oi = NULL; |
| 837 | struct ospf6_lsa *lsa = NULL; |
| 838 | struct interface *iif; |
| 839 | struct listnode *i; |
| 840 | struct list *ifslist; |
| 841 | oid *offset; |
| 842 | int offsetlen, len; |
| 843 | u_int32_t sum; |
| 844 | |
| 845 | if (smux_header_table (v, name, length, exact, var_len, write_method) |
| 846 | == MATCH_FAILED) |
| 847 | return NULL; |
| 848 | |
| 849 | ifindex = instid = 0; |
| 850 | |
| 851 | /* Check OSPFv3 instance. */ |
| 852 | if (ospf6 == NULL) |
| 853 | return NULL; |
| 854 | |
| 855 | /* Get variable length. */ |
| 856 | offset = name + v->namelen; |
| 857 | offsetlen = *length - v->namelen; |
| 858 | |
| 859 | if (exact && offsetlen != 2) |
| 860 | return NULL; |
| 861 | |
| 862 | /* Parse if index */ |
| 863 | len = (offsetlen < 1 ? 0 : 1); |
| 864 | if (len) |
| 865 | ifindex = *offset; |
| 866 | offset += len; |
| 867 | offsetlen -= len; |
| 868 | |
| 869 | /* Parse instance ID */ |
| 870 | len = (offsetlen < 1 ? 0 : 1); |
| 871 | if (len) |
| 872 | instid = *offset; |
| 873 | offset += len; |
| 874 | offsetlen -= len; |
| 875 | |
| 876 | if (exact) |
| 877 | { |
| 878 | oi = ospf6_interface_lookup_by_ifindex (ifindex); |
Vincent Bernat | 0402ca4 | 2012-07-10 09:27:57 +0200 | [diff] [blame^] | 879 | if (!oi || oi->instance_id != instid) return NULL; |
Vincent Bernat | 3bc4f84 | 2012-06-04 11:40:04 +0200 | [diff] [blame] | 880 | } |
| 881 | else |
| 882 | { |
| 883 | /* We build a sorted list of interfaces */ |
| 884 | ifslist = list_new (); |
| 885 | if (!ifslist) return NULL; |
| 886 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; |
| 887 | for (ALL_LIST_ELEMENTS_RO (iflist, i, iif)) |
| 888 | listnode_add_sort (ifslist, iif); |
| 889 | |
| 890 | for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif)) |
| 891 | { |
| 892 | if (!iif->ifindex) continue; |
| 893 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); |
| 894 | if (!oi) continue; |
| 895 | if (iif->ifindex > ifindex || |
| 896 | (iif->ifindex == ifindex && |
| 897 | (oi->instance_id > instid))) |
| 898 | break; |
| 899 | oi = NULL; |
| 900 | } |
| 901 | |
| 902 | list_delete_all_node (ifslist); |
| 903 | } |
| 904 | |
| 905 | if (!oi) return NULL; |
| 906 | |
| 907 | /* Add Index (IfIndex, IfInstId) */ |
| 908 | *length = v->namelen + 2; |
| 909 | offset = name + v->namelen; |
| 910 | *offset = oi->interface->ifindex; |
| 911 | offset++; |
| 912 | *offset = oi->instance_id; |
| 913 | offset++; |
| 914 | |
| 915 | /* Return the current value of the variable */ |
| 916 | switch (v->magic) |
| 917 | { |
| 918 | case OSPFv3IFAREAID: |
| 919 | if (oi->area) |
| 920 | return SNMP_INTEGER (ntohl (oi->area->area_id)); |
| 921 | break; |
| 922 | case OSPFv3IFTYPE: |
| 923 | if (if_is_broadcast (oi->interface)) |
| 924 | return SNMP_INTEGER (1); |
| 925 | else if (if_is_pointopoint (oi->interface)) |
| 926 | return SNMP_INTEGER (3); |
| 927 | else break; /* Unknown, don't put anything */ |
| 928 | case OSPFv3IFADMINSTATUS: |
| 929 | if (oi->area) |
| 930 | return SNMP_INTEGER (OSPF_STATUS_ENABLED); |
| 931 | return SNMP_INTEGER (OSPF_STATUS_DISABLED); |
| 932 | case OSPFv3IFRTRPRIORITY: |
| 933 | return SNMP_INTEGER (oi->priority); |
| 934 | case OSPFv3IFTRANSITDELAY: |
| 935 | return SNMP_INTEGER (oi->transdelay); |
| 936 | case OSPFv3IFRETRANSINTERVAL: |
| 937 | return SNMP_INTEGER (oi->rxmt_interval); |
| 938 | case OSPFv3IFHELLOINTERVAL: |
| 939 | return SNMP_INTEGER (oi->hello_interval); |
| 940 | case OSPFv3IFRTRDEADINTERVAL: |
| 941 | return SNMP_INTEGER (oi->dead_interval); |
| 942 | case OSPFv3IFPOLLINTERVAL: |
| 943 | /* No support for NBMA */ |
| 944 | break; |
| 945 | case OSPFv3IFSTATE: |
| 946 | return SNMP_INTEGER (oi->state); |
| 947 | case OSPFv3IFDESIGNATEDROUTER: |
| 948 | return SNMP_INTEGER (ntohl (oi->drouter)); |
| 949 | case OSPFv3IFBACKUPDESIGNATEDROUTER: |
| 950 | return SNMP_INTEGER (ntohl (oi->bdrouter)); |
| 951 | case OSPFv3IFEVENTS: |
| 952 | return SNMP_INTEGER (oi->state_change); |
| 953 | case OSPFv3IFROWSTATUS: |
| 954 | return SNMP_INTEGER (1); |
| 955 | case OSPFv3IFDEMAND: |
| 956 | return SNMP_INTEGER (SNMP_FALSE); |
| 957 | case OSPFv3IFMETRICVALUE: |
| 958 | return SNMP_INTEGER (oi->cost); |
| 959 | case OSPFv3IFLINKSCOPELSACOUNT: |
| 960 | return SNMP_INTEGER (oi->lsdb->count); |
| 961 | case OSPFv3IFLINKLSACKSUMSUM: |
| 962 | for (sum = 0, lsa = ospf6_lsdb_head (oi->lsdb); |
| 963 | lsa; |
| 964 | lsa = ospf6_lsdb_next (lsa)) |
| 965 | sum += ntohs (lsa->header->checksum); |
| 966 | return SNMP_INTEGER (sum); |
| 967 | case OSPFv3IFDEMANDNBRPROBE: |
| 968 | case OSPFv3IFDEMANDNBRPROBERETRANSLIMIT: |
| 969 | case OSPFv3IFDEMANDNBRPROBEINTERVAL: |
| 970 | case OSPFv3IFTEDISABLED: |
| 971 | case OSPFv3IFLINKLSASUPPRESSION: |
| 972 | /* Not implemented. Only works if all the last ones are not |
| 973 | implemented! */ |
| 974 | return NULL; |
| 975 | } |
| 976 | |
| 977 | /* Try an internal getnext. Some columns are missing in this table. */ |
| 978 | if (!exact && (name[*length-1] < MAX_SUBID)) |
| 979 | return ospfv3IfEntry(v, name, length, |
| 980 | exact, var_len, write_method); |
| 981 | return NULL; |
| 982 | } |
| 983 | |
| 984 | static u_char * |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 985 | ospfv3NbrEntry (struct variable *v, oid *name, size_t *length, |
| 986 | int exact, size_t *var_len, WriteMethod **write_method) |
| 987 | { |
| 988 | unsigned int ifindex, instid, rtrid; |
| 989 | struct ospf6_interface *oi = NULL; |
| 990 | struct ospf6_neighbor *on = NULL; |
| 991 | struct interface *iif; |
| 992 | struct listnode *i, *j; |
| 993 | struct list *ifslist; |
| 994 | oid *offset; |
| 995 | int offsetlen, len; |
| 996 | |
| 997 | if (smux_header_table (v, name, length, exact, var_len, write_method) |
| 998 | == MATCH_FAILED) |
| 999 | return NULL; |
| 1000 | |
| 1001 | ifindex = instid = rtrid = 0; |
| 1002 | |
| 1003 | /* Check OSPFv3 instance. */ |
| 1004 | if (ospf6 == NULL) |
| 1005 | return NULL; |
| 1006 | |
| 1007 | /* Get variable length. */ |
| 1008 | offset = name + v->namelen; |
| 1009 | offsetlen = *length - v->namelen; |
| 1010 | |
| 1011 | if (exact && offsetlen != 3) |
| 1012 | return NULL; |
| 1013 | |
| 1014 | /* Parse if index */ |
| 1015 | len = (offsetlen < 1 ? 0 : 1); |
| 1016 | if (len) |
| 1017 | ifindex = *offset; |
| 1018 | offset += len; |
| 1019 | offsetlen -= len; |
| 1020 | |
| 1021 | /* Parse instance ID */ |
| 1022 | len = (offsetlen < 1 ? 0 : 1); |
| 1023 | if (len) |
| 1024 | instid = *offset; |
| 1025 | offset += len; |
| 1026 | offsetlen -= len; |
| 1027 | |
| 1028 | /* Parse router ID */ |
| 1029 | len = (offsetlen < 1 ? 0 : 1); |
| 1030 | if (len) |
| 1031 | rtrid = htonl (*offset); |
| 1032 | offset += len; |
| 1033 | offsetlen -= len; |
| 1034 | |
| 1035 | if (exact) |
| 1036 | { |
| 1037 | oi = ospf6_interface_lookup_by_ifindex (ifindex); |
Vincent Bernat | 0402ca4 | 2012-07-10 09:27:57 +0200 | [diff] [blame^] | 1038 | if (!oi || oi->instance_id != instid) return NULL; |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 1039 | on = ospf6_neighbor_lookup (rtrid, oi); |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 1040 | } |
| 1041 | else |
| 1042 | { |
| 1043 | /* We build a sorted list of interfaces */ |
| 1044 | ifslist = list_new (); |
| 1045 | if (!ifslist) return NULL; |
| 1046 | ifslist->cmp = (int (*)(void *, void *))if_icmp_func; |
| 1047 | for (ALL_LIST_ELEMENTS_RO (iflist, i, iif)) |
| 1048 | listnode_add_sort (ifslist, iif); |
| 1049 | |
| 1050 | for (ALL_LIST_ELEMENTS_RO (ifslist, i, iif)) |
| 1051 | { |
| 1052 | if (!iif->ifindex) continue; |
| 1053 | oi = ospf6_interface_lookup_by_ifindex (iif->ifindex); |
| 1054 | if (!oi) continue; |
| 1055 | for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, j, on)) { |
| 1056 | if (iif->ifindex > ifindex || |
| 1057 | (iif->ifindex == ifindex && |
| 1058 | (oi->instance_id > instid || |
| 1059 | (oi->instance_id == instid && |
| 1060 | ntohl (on->router_id) > ntohl (rtrid))))) |
| 1061 | break; |
| 1062 | } |
| 1063 | if (on) break; |
Vincent Bernat | 0402ca4 | 2012-07-10 09:27:57 +0200 | [diff] [blame^] | 1064 | oi = NULL; |
| 1065 | on = NULL; |
Vincent Bernat | 061bc73 | 2012-05-31 20:21:15 +0200 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | list_delete_all_node (ifslist); |
| 1069 | } |
| 1070 | |
| 1071 | if (!oi || !on) return NULL; |
| 1072 | |
| 1073 | /* Add Index (IfIndex, IfInstId, RtrId) */ |
| 1074 | *length = v->namelen + 3; |
| 1075 | offset = name + v->namelen; |
| 1076 | *offset = oi->interface->ifindex; |
| 1077 | offset++; |
| 1078 | *offset = oi->instance_id; |
| 1079 | offset++; |
| 1080 | *offset = ntohl (on->router_id); |
| 1081 | offset++; |
| 1082 | |
| 1083 | /* Return the current value of the variable */ |
| 1084 | switch (v->magic) |
| 1085 | { |
| 1086 | case OSPFv3NBRADDRESSTYPE: |
| 1087 | return SNMP_INTEGER (2); /* IPv6 only */ |
| 1088 | case OSPFv3NBRADDRESS: |
| 1089 | *var_len = sizeof (struct in6_addr); |
| 1090 | return (u_char *) &on->linklocal_addr; |
| 1091 | case OSPFv3NBROPTIONS: |
| 1092 | return SNMP_INTEGER (on->options[2]); |
| 1093 | case OSPFv3NBRPRIORITY: |
| 1094 | return SNMP_INTEGER (on->priority); |
| 1095 | case OSPFv3NBRSTATE: |
| 1096 | return SNMP_INTEGER (on->state); |
| 1097 | case OSPFv3NBREVENTS: |
| 1098 | return SNMP_INTEGER (on->state_change); |
| 1099 | case OSPFv3NBRLSRETRANSQLEN: |
| 1100 | return SNMP_INTEGER (on->retrans_list->count); |
| 1101 | case OSPFv3NBRHELLOSUPPRESSED: |
| 1102 | return SNMP_INTEGER (SNMP_FALSE); |
| 1103 | case OSPFv3NBRIFID: |
| 1104 | return SNMP_INTEGER (on->ifindex); |
| 1105 | case OSPFv3NBRRESTARTHELPERSTATUS: |
| 1106 | case OSPFv3NBRRESTARTHELPERAGE: |
| 1107 | case OSPFv3NBRRESTARTHELPEREXITREASON: |
| 1108 | /* Not implemented. Only works if all the last ones are not |
| 1109 | implemented! */ |
| 1110 | return NULL; |
| 1111 | } |
| 1112 | |
| 1113 | return NULL; |
| 1114 | } |
| 1115 | |
Vincent Bernat | bf83666 | 2012-06-04 14:36:12 +0200 | [diff] [blame] | 1116 | /* OSPF Traps. */ |
| 1117 | #define NBRSTATECHANGE 2 |
| 1118 | #define IFSTATECHANGE 10 |
| 1119 | |
| 1120 | static struct trap_object ospf6NbrTrapList[] = |
| 1121 | { |
| 1122 | {-3, {1, 1, OSPFv3ROUTERID}}, |
| 1123 | {4, {1, 9, 1, OSPFv3NBRADDRESSTYPE}}, |
| 1124 | {4, {1, 9, 1, OSPFv3NBRADDRESS}}, |
| 1125 | {4, {1, 9, 1, OSPFv3NBRSTATE}} |
| 1126 | }; |
| 1127 | |
| 1128 | static struct trap_object ospf6IfTrapList[] = |
| 1129 | { |
| 1130 | {-3, {1, 1, OSPFv3ROUTERID}}, |
| 1131 | {4, {1, 7, 1, OSPFv3IFSTATE}}, |
| 1132 | {4, {1, 7, 1, OSPFv3IFADMINSTATUS}}, |
| 1133 | {4, {1, 7, 1, OSPFv3IFAREAID}} |
| 1134 | }; |
| 1135 | |
| 1136 | void |
| 1137 | ospf6TrapNbrStateChange (struct ospf6_neighbor *on) |
| 1138 | { |
| 1139 | oid index[3]; |
| 1140 | |
| 1141 | index[0] = on->ospf6_if->interface->ifindex; |
| 1142 | index[1] = on->ospf6_if->instance_id; |
| 1143 | index[2] = ntohl (on->router_id); |
| 1144 | |
| 1145 | smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable), |
| 1146 | ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid), |
| 1147 | ospfv3_oid, sizeof ospfv3_oid / sizeof (oid), |
| 1148 | index, 3, |
| 1149 | ospf6NbrTrapList, |
| 1150 | sizeof ospf6NbrTrapList / sizeof (struct trap_object), |
| 1151 | NBRSTATECHANGE); |
| 1152 | } |
| 1153 | |
| 1154 | void |
| 1155 | ospf6TrapIfStateChange (struct ospf6_interface *oi) |
| 1156 | { |
| 1157 | oid index[2]; |
| 1158 | |
| 1159 | index[0] = oi->interface->ifindex; |
| 1160 | index[1] = oi->instance_id; |
| 1161 | |
| 1162 | smux_trap (ospfv3_variables, sizeof ospfv3_variables / sizeof (struct variable), |
| 1163 | ospfv3_trap_oid, sizeof ospfv3_trap_oid / sizeof (oid), |
| 1164 | ospfv3_oid, sizeof ospfv3_oid / sizeof (oid), |
| 1165 | index, 2, |
| 1166 | ospf6IfTrapList, |
| 1167 | sizeof ospf6IfTrapList / sizeof (struct trap_object), |
| 1168 | IFSTATECHANGE); |
| 1169 | } |
| 1170 | |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 1171 | /* Register OSPFv3-MIB. */ |
| 1172 | void |
paul | 0c083ee | 2004-10-10 12:54:58 +0000 | [diff] [blame] | 1173 | ospf6_snmp_init (struct thread_master *master) |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 1174 | { |
hasso | c75105a | 2004-10-13 10:33:26 +0000 | [diff] [blame] | 1175 | smux_init (master); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 1176 | REGISTER_MIB ("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); |
hasso | ef1bbf5 | 2004-10-08 12:04:21 +0000 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | #endif /* HAVE_SNMP */ |
| 1180 | |