paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * OSPFd dump routine. |
| 3 | * Copyright (C) 1999, 2000 Toshiaki Takada |
| 4 | * |
| 5 | * This file is part of GNU Zebra. |
| 6 | * |
| 7 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2, or (at your option) any |
| 10 | * later version. |
| 11 | * |
| 12 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | * Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "linklist.h" |
| 26 | #include "thread.h" |
| 27 | #include "prefix.h" |
| 28 | #include "command.h" |
| 29 | #include "stream.h" |
| 30 | #include "log.h" |
| 31 | |
| 32 | #include "ospfd/ospfd.h" |
| 33 | #include "ospfd/ospf_interface.h" |
| 34 | #include "ospfd/ospf_ism.h" |
| 35 | #include "ospfd/ospf_asbr.h" |
| 36 | #include "ospfd/ospf_lsa.h" |
| 37 | #include "ospfd/ospf_lsdb.h" |
| 38 | #include "ospfd/ospf_neighbor.h" |
| 39 | #include "ospfd/ospf_nsm.h" |
| 40 | #include "ospfd/ospf_dump.h" |
| 41 | #include "ospfd/ospf_packet.h" |
| 42 | #include "ospfd/ospf_network.h" |
| 43 | |
| 44 | struct message ospf_ism_state_msg[] = |
| 45 | { |
| 46 | { ISM_DependUpon, "DependUpon" }, |
| 47 | { ISM_Down, "Down" }, |
| 48 | { ISM_Loopback, "Loopback" }, |
| 49 | { ISM_Waiting, "Waiting" }, |
| 50 | { ISM_PointToPoint, "Point-To-Point" }, |
| 51 | { ISM_DROther, "DROther" }, |
| 52 | { ISM_Backup, "Backup" }, |
| 53 | { ISM_DR, "DR" }, |
| 54 | }; |
| 55 | int ospf_ism_state_msg_max = OSPF_ISM_STATE_MAX; |
| 56 | |
| 57 | struct message ospf_nsm_state_msg[] = |
| 58 | { |
| 59 | { NSM_DependUpon, "DependUpon" }, |
| 60 | { NSM_Down, "Down" }, |
| 61 | { NSM_Attempt, "Attempt" }, |
| 62 | { NSM_Init, "Init" }, |
| 63 | { NSM_TwoWay, "2-Way" }, |
| 64 | { NSM_ExStart, "ExStart" }, |
| 65 | { NSM_Exchange, "Exchange" }, |
| 66 | { NSM_Loading, "Loading" }, |
| 67 | { NSM_Full, "Full" }, |
| 68 | }; |
| 69 | int ospf_nsm_state_msg_max = OSPF_NSM_STATE_MAX; |
| 70 | |
| 71 | struct message ospf_lsa_type_msg[] = |
| 72 | { |
| 73 | { OSPF_UNKNOWN_LSA, "unknown" }, |
| 74 | { OSPF_ROUTER_LSA, "router-LSA" }, |
| 75 | { OSPF_NETWORK_LSA, "network-LSA" }, |
| 76 | { OSPF_SUMMARY_LSA, "summary-LSA" }, |
| 77 | { OSPF_ASBR_SUMMARY_LSA, "summary-LSA" }, |
| 78 | { OSPF_AS_EXTERNAL_LSA, "AS-external-LSA" }, |
| 79 | { OSPF_GROUP_MEMBER_LSA, "GROUP MEMBER LSA" }, |
| 80 | { OSPF_AS_NSSA_LSA, "NSSA-LSA" }, |
| 81 | { 8, "Type-8 LSA" }, |
| 82 | { OSPF_OPAQUE_LINK_LSA, "Link-Local Opaque-LSA" }, |
| 83 | { OSPF_OPAQUE_AREA_LSA, "Area-Local Opaque-LSA" }, |
| 84 | { OSPF_OPAQUE_AS_LSA, "AS-external Opaque-LSA" }, |
| 85 | }; |
| 86 | int ospf_lsa_type_msg_max = OSPF_MAX_LSA; |
| 87 | |
| 88 | struct message ospf_link_state_id_type_msg[] = |
| 89 | { |
| 90 | { OSPF_UNKNOWN_LSA, "(unknown)" }, |
| 91 | { OSPF_ROUTER_LSA, "" }, |
| 92 | { OSPF_NETWORK_LSA, "(address of Designated Router)" }, |
| 93 | { OSPF_SUMMARY_LSA, "(summary Network Number)" }, |
| 94 | { OSPF_ASBR_SUMMARY_LSA, "(AS Boundary Router address)" }, |
| 95 | { OSPF_AS_EXTERNAL_LSA, "(External Network Number)" }, |
| 96 | { OSPF_GROUP_MEMBER_LSA, "(Group membership information)" }, |
| 97 | { OSPF_AS_NSSA_LSA, "(External Network Number for NSSA)" }, |
| 98 | { 8, "(Type-8 LSID)" }, |
| 99 | { OSPF_OPAQUE_LINK_LSA, "(Link-Local Opaque-Type/ID)" }, |
| 100 | { OSPF_OPAQUE_AREA_LSA, "(Area-Local Opaque-Type/ID)" }, |
| 101 | { OSPF_OPAQUE_AS_LSA, "(AS-external Opaque-Type/ID)" }, |
| 102 | }; |
| 103 | int ospf_link_state_id_type_msg_max = OSPF_MAX_LSA; |
| 104 | |
| 105 | struct message ospf_redistributed_proto[] = |
| 106 | { |
| 107 | { ZEBRA_ROUTE_SYSTEM, "System" }, |
| 108 | { ZEBRA_ROUTE_KERNEL, "Kernel" }, |
| 109 | { ZEBRA_ROUTE_CONNECT, "Connected" }, |
| 110 | { ZEBRA_ROUTE_STATIC, "Static" }, |
| 111 | { ZEBRA_ROUTE_RIP, "RIP" }, |
| 112 | { ZEBRA_ROUTE_RIPNG, "RIPng" }, |
| 113 | { ZEBRA_ROUTE_OSPF, "OSPF" }, |
| 114 | { ZEBRA_ROUTE_OSPF6, "OSPFv3" }, |
| 115 | { ZEBRA_ROUTE_BGP, "BGP" }, |
| 116 | { ZEBRA_ROUTE_MAX, "Default" }, |
| 117 | }; |
| 118 | int ospf_redistributed_proto_max = ZEBRA_ROUTE_MAX + 1; |
| 119 | |
| 120 | struct message ospf_network_type_msg[] = |
| 121 | { |
| 122 | { OSPF_IFTYPE_NONE, "NONE" }, |
| 123 | { OSPF_IFTYPE_POINTOPOINT, "Point-to-Point" }, |
| 124 | { OSPF_IFTYPE_BROADCAST, "Broadcast" }, |
| 125 | { OSPF_IFTYPE_NBMA, "NBMA" }, |
| 126 | { OSPF_IFTYPE_POINTOMULTIPOINT, "Point-to-MultiPoint" }, |
| 127 | { OSPF_IFTYPE_VIRTUALLINK, "Virtual-Link" }, |
| 128 | }; |
| 129 | int ospf_network_type_msg_max = OSPF_IFTYPE_MAX; |
| 130 | |
| 131 | /* Configuration debug option variables. */ |
| 132 | unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0}; |
| 133 | unsigned long conf_debug_ospf_event = 0; |
| 134 | unsigned long conf_debug_ospf_ism = 0; |
| 135 | unsigned long conf_debug_ospf_nsm = 0; |
| 136 | unsigned long conf_debug_ospf_lsa = 0; |
| 137 | unsigned long conf_debug_ospf_zebra = 0; |
| 138 | unsigned long conf_debug_ospf_nssa = 0; |
| 139 | |
| 140 | /* Enable debug option variables -- valid only session. */ |
| 141 | unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0}; |
| 142 | unsigned long term_debug_ospf_event = 0; |
| 143 | unsigned long term_debug_ospf_ism = 0; |
| 144 | unsigned long term_debug_ospf_nsm = 0; |
| 145 | unsigned long term_debug_ospf_lsa = 0; |
| 146 | unsigned long term_debug_ospf_zebra = 0; |
| 147 | unsigned long term_debug_ospf_nssa = 0; |
| 148 | |
| 149 | |
| 150 | #define OSPF_AREA_STRING_MAXLEN 16 |
| 151 | char * |
| 152 | ospf_area_name_string (struct ospf_area *area) |
| 153 | { |
| 154 | static char buf[OSPF_AREA_STRING_MAXLEN] = ""; |
| 155 | u_int32_t area_id; |
| 156 | |
| 157 | if (!area) |
| 158 | return "-"; |
| 159 | |
| 160 | area_id = ntohl (area->area_id.s_addr); |
| 161 | snprintf (buf, OSPF_AREA_STRING_MAXLEN, "%d.%d.%d.%d", |
| 162 | (area_id >> 24) & 0xff, (area_id >> 16) & 0xff, |
| 163 | (area_id >> 8) & 0xff, area_id & 0xff); |
| 164 | return buf; |
| 165 | } |
| 166 | |
| 167 | #define OSPF_AREA_DESC_STRING_MAXLEN 23 |
| 168 | char * |
| 169 | ospf_area_desc_string (struct ospf_area *area) |
| 170 | { |
| 171 | static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = ""; |
| 172 | u_char type; |
| 173 | |
| 174 | if (!area) |
| 175 | return "(incomplete)"; |
| 176 | |
| 177 | type = area->external_routing; |
| 178 | switch (type) |
| 179 | { |
| 180 | case OSPF_AREA_NSSA: |
| 181 | snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [NSSA]", |
| 182 | ospf_area_name_string (area)); |
| 183 | break; |
| 184 | case OSPF_AREA_STUB: |
| 185 | snprintf (buf, OSPF_AREA_DESC_STRING_MAXLEN, "%s [Stub]", |
| 186 | ospf_area_name_string (area)); |
| 187 | break; |
| 188 | default: |
| 189 | return ospf_area_name_string (area); |
| 190 | break; |
| 191 | } |
| 192 | |
| 193 | return buf; |
| 194 | } |
| 195 | |
| 196 | #define OSPF_IF_STRING_MAXLEN 40 |
| 197 | char * |
| 198 | ospf_if_name_string (struct ospf_interface *oi) |
| 199 | { |
| 200 | static char buf[OSPF_IF_STRING_MAXLEN] = ""; |
| 201 | u_int32_t ifaddr; |
| 202 | |
| 203 | if (!oi) |
| 204 | return "inactive"; |
| 205 | |
| 206 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
| 207 | return oi->ifp->name; |
| 208 | |
| 209 | ifaddr = ntohl (oi->address->u.prefix4.s_addr); |
| 210 | snprintf (buf, OSPF_IF_STRING_MAXLEN, |
| 211 | "%s:%d.%d.%d.%d", oi->ifp->name, |
| 212 | (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff, |
| 213 | (ifaddr >> 8) & 0xff, ifaddr & 0xff); |
| 214 | return buf; |
| 215 | } |
| 216 | |
| 217 | |
| 218 | void |
| 219 | ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size) |
| 220 | { |
| 221 | int state; |
| 222 | struct ospf_interface *oi = nbr->oi; |
| 223 | |
| 224 | if (IPV4_ADDR_SAME (&DR (oi), &nbr->address.u.prefix4)) |
| 225 | state = ISM_DR; |
| 226 | else if (IPV4_ADDR_SAME (&BDR (oi), &nbr->address.u.prefix4)) |
| 227 | state = ISM_Backup; |
| 228 | else |
| 229 | state = ISM_DROther; |
| 230 | |
| 231 | memset (buf, 0, size); |
| 232 | |
| 233 | snprintf (buf, size, "%s/%s", |
| 234 | LOOKUP (ospf_nsm_state_msg, nbr->state), |
| 235 | LOOKUP (ospf_ism_state_msg, state)); |
| 236 | } |
| 237 | |
| 238 | char * |
| 239 | ospf_timer_dump (struct thread *t, char *buf, size_t size) |
| 240 | { |
| 241 | struct timeval now; |
| 242 | unsigned long h, m, s; |
| 243 | |
| 244 | if (!t) |
| 245 | return "inactive"; |
| 246 | |
| 247 | h = m = s = 0; |
| 248 | memset (buf, 0, size); |
| 249 | |
| 250 | gettimeofday (&now, NULL); |
| 251 | |
| 252 | s = t->u.sands.tv_sec - now.tv_sec; |
| 253 | if (s >= 3600) |
| 254 | { |
| 255 | h = s / 3600; |
| 256 | s -= h * 3600; |
| 257 | } |
| 258 | |
| 259 | if (s >= 60) |
| 260 | { |
| 261 | m = s / 60; |
| 262 | s -= m * 60; |
| 263 | } |
| 264 | |
| 265 | snprintf (buf, size, "%02ld:%02ld:%02ld", h, m, s); |
| 266 | |
| 267 | return buf; |
| 268 | } |
| 269 | |
| 270 | #define OSPF_OPTION_STR_MAXLEN 24 |
| 271 | |
| 272 | char * |
| 273 | ospf_options_dump (u_char options) |
| 274 | { |
| 275 | static char buf[OSPF_OPTION_STR_MAXLEN]; |
| 276 | |
| 277 | snprintf (buf, OSPF_OPTION_STR_MAXLEN, "*|%s|%s|%s|%s|%s|%s|*", |
| 278 | (options & OSPF_OPTION_O) ? "O" : "-", |
| 279 | (options & OSPF_OPTION_DC) ? "DC" : "-", |
| 280 | (options & OSPF_OPTION_EA) ? "EA" : "-", |
| 281 | (options & OSPF_OPTION_NP) ? "N/P" : "-", |
| 282 | (options & OSPF_OPTION_MC) ? "MC" : "-", |
| 283 | (options & OSPF_OPTION_E) ? "E" : "-"); |
| 284 | |
| 285 | return buf; |
| 286 | } |
| 287 | |
| 288 | void |
| 289 | ospf_packet_hello_dump (struct stream *s, u_int16_t length) |
| 290 | { |
| 291 | struct ospf_hello *hello; |
| 292 | int i; |
| 293 | |
| 294 | hello = (struct ospf_hello *) STREAM_PNT (s); |
| 295 | |
| 296 | zlog_info ("Hello"); |
| 297 | zlog_info (" NetworkMask %s", inet_ntoa (hello->network_mask)); |
| 298 | zlog_info (" HelloInterval %d", ntohs (hello->hello_interval)); |
| 299 | zlog_info (" Options %d (%s)", hello->options, |
| 300 | ospf_options_dump (hello->options)); |
| 301 | zlog_info (" RtrPriority %d", hello->priority); |
| 302 | zlog_info (" RtrDeadInterval %ld", (u_long)ntohl (hello->dead_interval)); |
| 303 | zlog_info (" DRouter %s", inet_ntoa (hello->d_router)); |
| 304 | zlog_info (" BDRouter %s", inet_ntoa (hello->bd_router)); |
| 305 | |
| 306 | length -= OSPF_HEADER_SIZE + OSPF_HELLO_MIN_SIZE; |
| 307 | zlog_info (" # Neighbors %d", length / 4); |
| 308 | for (i = 0; length > 0; i++, length -= sizeof (struct in_addr)) |
| 309 | zlog_info (" Neighbor %s", inet_ntoa (hello->neighbors[i])); |
| 310 | } |
| 311 | |
| 312 | char * |
| 313 | ospf_dd_flags_dump (u_char flags, char *buf, size_t size) |
| 314 | { |
| 315 | memset (buf, 0, size); |
| 316 | |
| 317 | snprintf (buf, size, "%s|%s|%s", |
| 318 | (flags & OSPF_DD_FLAG_I) ? "I" : "-", |
| 319 | (flags & OSPF_DD_FLAG_M) ? "M" : "-", |
| 320 | (flags & OSPF_DD_FLAG_MS) ? "MS" : "-"); |
| 321 | |
| 322 | return buf; |
| 323 | } |
| 324 | |
| 325 | void |
| 326 | ospf_lsa_header_dump (struct lsa_header *lsah) |
| 327 | { |
paul | 0c2be26 | 2004-05-31 14:16:54 +0000 | [diff] [blame] | 328 | char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type); |
| 329 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 330 | zlog_info (" LSA Header"); |
| 331 | zlog_info (" LS age %d", ntohs (lsah->ls_age)); |
| 332 | zlog_info (" Options %d (%s)", lsah->options, |
| 333 | ospf_options_dump (lsah->options)); |
| 334 | zlog_info (" LS type %d (%s)", lsah->type, |
paul | 553ff11 | 2004-06-06 09:41:00 +0000 | [diff] [blame^] | 335 | (lsah->type ? lsah_type : "unknown type")); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 336 | zlog_info (" Link State ID %s", inet_ntoa (lsah->id)); |
| 337 | zlog_info (" Advertising Router %s", inet_ntoa (lsah->adv_router)); |
| 338 | zlog_info (" LS sequence number 0x%lx", (u_long)ntohl (lsah->ls_seqnum)); |
| 339 | zlog_info (" LS checksum 0x%x", ntohs (lsah->checksum)); |
| 340 | zlog_info (" length %d", ntohs (lsah->length)); |
| 341 | } |
| 342 | |
| 343 | char * |
| 344 | ospf_router_lsa_flags_dump (u_char flags, char *buf, size_t size) |
| 345 | { |
| 346 | memset (buf, 0, size); |
| 347 | |
| 348 | snprintf (buf, size, "%s|%s|%s", |
| 349 | (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-", |
| 350 | (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-", |
| 351 | (flags & ROUTER_LSA_BORDER) ? "B" : "-"); |
| 352 | |
| 353 | return buf; |
| 354 | } |
| 355 | |
| 356 | void |
| 357 | ospf_router_lsa_dump (struct stream *s, u_int16_t length) |
| 358 | { |
| 359 | char buf[BUFSIZ]; |
| 360 | struct router_lsa *rl; |
| 361 | int i, len; |
| 362 | |
| 363 | rl = (struct router_lsa *) STREAM_PNT (s); |
| 364 | |
| 365 | zlog_info (" Router-LSA"); |
| 366 | zlog_info (" flags %s", |
| 367 | ospf_router_lsa_flags_dump (rl->flags, buf, BUFSIZ)); |
| 368 | zlog_info (" # links %d", ntohs (rl->links)); |
| 369 | |
| 370 | len = ntohs (rl->header.length) - OSPF_LSA_HEADER_SIZE - 4; |
| 371 | for (i = 0; len > 0; i++) |
| 372 | { |
| 373 | zlog_info (" Link ID %s", inet_ntoa (rl->link[i].link_id)); |
| 374 | zlog_info (" Link Data %s", inet_ntoa (rl->link[i].link_data)); |
| 375 | zlog_info (" Type %d", (u_char) rl->link[i].type); |
| 376 | zlog_info (" TOS %d", (u_char) rl->link[i].tos); |
| 377 | zlog_info (" metric %d", ntohs (rl->link[i].metric)); |
| 378 | |
| 379 | len -= 12; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | void |
| 384 | ospf_network_lsa_dump (struct stream *s, u_int16_t length) |
| 385 | { |
| 386 | struct network_lsa *nl; |
| 387 | int i, cnt; |
| 388 | |
| 389 | nl = (struct network_lsa *) STREAM_PNT (s); |
| 390 | cnt = (ntohs (nl->header.length) - (OSPF_LSA_HEADER_SIZE + 4)) / 4; |
| 391 | |
| 392 | zlog_info (" Network-LSA"); |
| 393 | /* |
| 394 | zlog_info ("LSA total size %d", ntohs (nl->header.length)); |
| 395 | zlog_info ("Network-LSA size %d", |
| 396 | ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE); |
| 397 | */ |
| 398 | zlog_info (" Network Mask %s", inet_ntoa (nl->mask)); |
| 399 | zlog_info (" # Attached Routers %d", cnt); |
| 400 | for (i = 0; i < cnt; i++) |
| 401 | zlog_info (" Attached Router %s", inet_ntoa (nl->routers[i])); |
| 402 | } |
| 403 | |
| 404 | void |
| 405 | ospf_summary_lsa_dump (struct stream *s, u_int16_t length) |
| 406 | { |
| 407 | struct summary_lsa *sl; |
| 408 | int size; |
| 409 | int i; |
| 410 | |
| 411 | sl = (struct summary_lsa *) STREAM_PNT (s); |
| 412 | |
| 413 | zlog_info (" Summary-LSA"); |
| 414 | zlog_info (" Network Mask %s", inet_ntoa (sl->mask)); |
| 415 | |
| 416 | size = ntohs (sl->header.length) - OSPF_LSA_HEADER_SIZE - 4; |
| 417 | for (i = 0; size > 0; size -= 4, i++) |
| 418 | zlog_info (" TOS=%d metric %d", sl->tos, |
| 419 | GET_METRIC (sl->metric)); |
| 420 | } |
| 421 | |
| 422 | void |
| 423 | ospf_as_external_lsa_dump (struct stream *s, u_int16_t length) |
| 424 | { |
| 425 | struct as_external_lsa *al; |
| 426 | int size; |
| 427 | int i; |
| 428 | |
| 429 | al = (struct as_external_lsa *) STREAM_PNT (s); |
paul | d4a53d5 | 2003-07-12 21:30:57 +0000 | [diff] [blame] | 430 | zlog_info (" %s", ospf_lsa_type_msg[al->header.type].str); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 431 | zlog_info (" Network Mask %s", inet_ntoa (al->mask)); |
| 432 | |
| 433 | size = ntohs (al->header.length) - OSPF_LSA_HEADER_SIZE -4; |
| 434 | for (i = 0; size > 0; size -= 12, i++) |
| 435 | { |
| 436 | zlog_info (" bit %s TOS=%d metric %d", |
| 437 | IS_EXTERNAL_METRIC (al->e[i].tos) ? "E" : "-", |
| 438 | al->e[i].tos & 0x7f, GET_METRIC (al->e[i].metric)); |
| 439 | zlog_info (" Forwarding address %s", inet_ntoa (al->e[i].fwd_addr)); |
| 440 | zlog_info (" External Route Tag %d", al->e[i].route_tag); |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void |
| 445 | ospf_lsa_header_list_dump (struct stream *s, u_int16_t length) |
| 446 | { |
| 447 | struct lsa_header *lsa; |
| 448 | |
| 449 | zlog_info (" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE); |
| 450 | |
| 451 | /* LSA Headers. */ |
| 452 | while (length > 0) |
| 453 | { |
| 454 | lsa = (struct lsa_header *) STREAM_PNT (s); |
| 455 | ospf_lsa_header_dump (lsa); |
| 456 | |
| 457 | stream_forward (s, OSPF_LSA_HEADER_SIZE); |
| 458 | length -= OSPF_LSA_HEADER_SIZE; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | void |
| 463 | ospf_packet_db_desc_dump (struct stream *s, u_int16_t length) |
| 464 | { |
| 465 | struct ospf_db_desc *dd; |
| 466 | char dd_flags[8]; |
| 467 | |
| 468 | u_int32_t gp; |
| 469 | |
| 470 | gp = stream_get_getp (s); |
| 471 | dd = (struct ospf_db_desc *) STREAM_PNT (s); |
| 472 | |
| 473 | zlog_info ("Database Description"); |
| 474 | zlog_info (" Interface MTU %d", ntohs (dd->mtu)); |
| 475 | zlog_info (" Options %d (%s)", dd->options, |
| 476 | ospf_options_dump (dd->options)); |
| 477 | zlog_info (" Flags %d (%s)", dd->flags, |
| 478 | ospf_dd_flags_dump (dd->flags, dd_flags, sizeof dd_flags)); |
| 479 | zlog_info (" Sequence Number 0x%08lx", (u_long)ntohl (dd->dd_seqnum)); |
| 480 | |
| 481 | length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE; |
| 482 | |
| 483 | stream_forward (s, OSPF_DB_DESC_MIN_SIZE); |
| 484 | |
| 485 | ospf_lsa_header_list_dump (s, length); |
| 486 | |
| 487 | stream_set_getp (s, gp); |
| 488 | } |
| 489 | |
| 490 | void |
| 491 | ospf_packet_ls_req_dump (struct stream *s, u_int16_t length) |
| 492 | { |
| 493 | u_int32_t sp; |
| 494 | u_int32_t ls_type; |
| 495 | struct in_addr ls_id; |
| 496 | struct in_addr adv_router; |
| 497 | |
| 498 | sp = stream_get_getp (s); |
| 499 | |
| 500 | length -= OSPF_HEADER_SIZE; |
| 501 | |
| 502 | zlog_info ("Link State Request"); |
| 503 | zlog_info (" # Requests %d", length / 12); |
| 504 | |
| 505 | for (; length > 0; length -= 12) |
| 506 | { |
| 507 | ls_type = stream_getl (s); |
| 508 | ls_id.s_addr = stream_get_ipv4 (s); |
| 509 | adv_router.s_addr = stream_get_ipv4 (s); |
| 510 | |
| 511 | zlog_info (" LS type %d", ls_type); |
| 512 | zlog_info (" Link State ID %s", inet_ntoa (ls_id)); |
| 513 | zlog_info (" Advertising Router %s", |
| 514 | inet_ntoa (adv_router)); |
| 515 | } |
| 516 | |
| 517 | stream_set_getp (s, sp); |
| 518 | } |
| 519 | |
| 520 | void |
| 521 | ospf_packet_ls_upd_dump (struct stream *s, u_int16_t length) |
| 522 | { |
| 523 | u_int32_t sp; |
| 524 | struct lsa_header *lsa; |
| 525 | int lsa_len; |
| 526 | u_int32_t count; |
| 527 | |
| 528 | length -= OSPF_HEADER_SIZE; |
| 529 | |
| 530 | sp = stream_get_getp (s); |
| 531 | |
| 532 | count = stream_getl (s); |
| 533 | length -= 4; |
| 534 | |
| 535 | zlog_info ("Link State Update"); |
| 536 | zlog_info (" # LSAs %d", count); |
| 537 | |
| 538 | while (length > 0 && count > 0) |
| 539 | { |
| 540 | if (length < OSPF_HEADER_SIZE || length % 4 != 0) |
| 541 | { |
| 542 | zlog_info (" Remaining %d bytes; Incorrect length.", length); |
| 543 | break; |
| 544 | } |
| 545 | |
| 546 | lsa = (struct lsa_header *) STREAM_PNT (s); |
| 547 | lsa_len = ntohs (lsa->length); |
| 548 | ospf_lsa_header_dump (lsa); |
| 549 | |
| 550 | switch (lsa->type) |
| 551 | { |
| 552 | case OSPF_ROUTER_LSA: |
| 553 | ospf_router_lsa_dump (s, length); |
| 554 | break; |
| 555 | case OSPF_NETWORK_LSA: |
| 556 | ospf_network_lsa_dump (s, length); |
| 557 | break; |
| 558 | case OSPF_SUMMARY_LSA: |
| 559 | case OSPF_ASBR_SUMMARY_LSA: |
| 560 | ospf_summary_lsa_dump (s, length); |
| 561 | break; |
| 562 | case OSPF_AS_EXTERNAL_LSA: |
| 563 | ospf_as_external_lsa_dump (s, length); |
| 564 | break; |
| 565 | #ifdef HAVE_NSSA |
| 566 | case OSPF_AS_NSSA_LSA: |
paul | d4a53d5 | 2003-07-12 21:30:57 +0000 | [diff] [blame] | 567 | ospf_as_external_lsa_dump (s, length); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 568 | break; |
| 569 | #endif /* HAVE_NSSA */ |
| 570 | #ifdef HAVE_OPAQUE_LSA |
| 571 | case OSPF_OPAQUE_LINK_LSA: |
| 572 | case OSPF_OPAQUE_AREA_LSA: |
| 573 | case OSPF_OPAQUE_AS_LSA: |
| 574 | ospf_opaque_lsa_dump (s, length); |
| 575 | break; |
| 576 | #endif /* HAVE_OPAQUE_LSA */ |
| 577 | default: |
| 578 | break; |
| 579 | } |
| 580 | |
| 581 | stream_forward (s, lsa_len); |
| 582 | length -= lsa_len; |
| 583 | count--; |
| 584 | } |
| 585 | |
| 586 | stream_set_getp (s, sp); |
| 587 | } |
| 588 | |
| 589 | void |
| 590 | ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length) |
| 591 | { |
| 592 | u_int32_t sp; |
| 593 | |
| 594 | length -= OSPF_HEADER_SIZE; |
| 595 | sp = stream_get_getp (s); |
| 596 | |
| 597 | zlog_info ("Link State Acknowledgment"); |
| 598 | ospf_lsa_header_list_dump (s, length); |
| 599 | |
| 600 | stream_set_getp (s, sp); |
| 601 | } |
| 602 | |
| 603 | void |
| 604 | ospf_ip_header_dump (struct stream *s) |
| 605 | { |
| 606 | u_int16_t length; |
| 607 | struct ip *iph; |
| 608 | |
| 609 | iph = (struct ip *) STREAM_PNT (s); |
| 610 | |
| 611 | #ifdef GNU_LINUX |
| 612 | length = ntohs (iph->ip_len); |
| 613 | #else /* GNU_LINUX */ |
| 614 | length = iph->ip_len; |
| 615 | #endif /* GNU_LINUX */ |
| 616 | |
| 617 | /* IP Header dump. */ |
| 618 | zlog_info ("ip_v %d", iph->ip_v); |
| 619 | zlog_info ("ip_hl %d", iph->ip_hl); |
| 620 | zlog_info ("ip_tos %d", iph->ip_tos); |
| 621 | zlog_info ("ip_len %d", length); |
| 622 | zlog_info ("ip_id %u", (u_int32_t) iph->ip_id); |
| 623 | zlog_info ("ip_off %u", (u_int32_t) iph->ip_off); |
| 624 | zlog_info ("ip_ttl %d", iph->ip_ttl); |
| 625 | zlog_info ("ip_p %d", iph->ip_p); |
| 626 | /* There is a report that Linux 2.0.37 does not have ip_sum. But |
| 627 | I'm not sure. Temporary commented out by kunihiro. */ |
| 628 | /* zlog_info ("ip_sum 0x%x", (u_int32_t) ntohs (iph->ip_sum)); */ |
| 629 | zlog_info ("ip_src %s", inet_ntoa (iph->ip_src)); |
| 630 | zlog_info ("ip_dst %s", inet_ntoa (iph->ip_dst)); |
| 631 | } |
| 632 | |
| 633 | void |
| 634 | ospf_header_dump (struct ospf_header *ospfh) |
| 635 | { |
| 636 | char buf[9]; |
| 637 | |
| 638 | zlog_info ("Header"); |
| 639 | zlog_info (" Version %d", ospfh->version); |
| 640 | zlog_info (" Type %d (%s)", ospfh->type, |
| 641 | ospf_packet_type_str[ospfh->type]); |
| 642 | zlog_info (" Packet Len %d", ntohs (ospfh->length)); |
| 643 | zlog_info (" Router ID %s", inet_ntoa (ospfh->router_id)); |
| 644 | zlog_info (" Area ID %s", inet_ntoa (ospfh->area_id)); |
| 645 | zlog_info (" Checksum 0x%x", ntohs (ospfh->checksum)); |
| 646 | zlog_info (" AuType %d", ntohs (ospfh->auth_type)); |
| 647 | |
| 648 | switch (ntohs (ospfh->auth_type)) |
| 649 | { |
| 650 | case OSPF_AUTH_NULL: |
| 651 | break; |
| 652 | case OSPF_AUTH_SIMPLE: |
| 653 | memset (buf, 0, 9); |
| 654 | strncpy (buf, ospfh->u.auth_data, 8); |
| 655 | zlog_info (" Simple Password %s", buf); |
| 656 | break; |
| 657 | case OSPF_AUTH_CRYPTOGRAPHIC: |
| 658 | zlog_info (" Cryptographic Authentication"); |
| 659 | zlog_info (" Key ID %d", ospfh->u.crypt.key_id); |
| 660 | zlog_info (" Auth Data Len %d", ospfh->u.crypt.auth_data_len); |
| 661 | zlog_info (" Sequence number %ld", |
| 662 | (u_long)ntohl (ospfh->u.crypt.crypt_seqnum)); |
| 663 | break; |
| 664 | default: |
| 665 | zlog_info ("* This is not supported authentication type"); |
| 666 | break; |
| 667 | } |
| 668 | |
| 669 | } |
| 670 | |
| 671 | void |
| 672 | ospf_packet_dump (struct stream *s) |
| 673 | { |
| 674 | struct ospf_header *ospfh; |
| 675 | unsigned long gp; |
| 676 | |
| 677 | /* Preserve pointer. */ |
| 678 | gp = stream_get_getp (s); |
| 679 | |
| 680 | /* OSPF Header dump. */ |
| 681 | ospfh = (struct ospf_header *) STREAM_PNT (s); |
| 682 | |
| 683 | /* Until detail flag is set, return. */ |
| 684 | if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL)) |
| 685 | return; |
| 686 | |
| 687 | /* Show OSPF header detail. */ |
| 688 | ospf_header_dump (ospfh); |
| 689 | stream_forward (s, OSPF_HEADER_SIZE); |
| 690 | |
| 691 | switch (ospfh->type) |
| 692 | { |
| 693 | case OSPF_MSG_HELLO: |
| 694 | ospf_packet_hello_dump (s, ntohs (ospfh->length)); |
| 695 | break; |
| 696 | case OSPF_MSG_DB_DESC: |
| 697 | ospf_packet_db_desc_dump (s, ntohs (ospfh->length)); |
| 698 | break; |
| 699 | case OSPF_MSG_LS_REQ: |
| 700 | ospf_packet_ls_req_dump (s, ntohs (ospfh->length)); |
| 701 | break; |
| 702 | case OSPF_MSG_LS_UPD: |
| 703 | ospf_packet_ls_upd_dump (s, ntohs (ospfh->length)); |
| 704 | break; |
| 705 | case OSPF_MSG_LS_ACK: |
| 706 | ospf_packet_ls_ack_dump (s, ntohs (ospfh->length)); |
| 707 | break; |
| 708 | default: |
| 709 | break; |
| 710 | } |
| 711 | |
| 712 | stream_set_getp (s, gp); |
| 713 | } |
| 714 | |
| 715 | |
| 716 | /* |
| 717 | [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) |
| 718 | [send|recv [detail]] |
| 719 | */ |
| 720 | DEFUN (debug_ospf_packet, |
| 721 | debug_ospf_packet_all_cmd, |
| 722 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", |
| 723 | DEBUG_STR |
| 724 | OSPF_STR |
| 725 | "OSPF packets\n" |
| 726 | "OSPF Hello\n" |
| 727 | "OSPF Database Description\n" |
| 728 | "OSPF Link State Request\n" |
| 729 | "OSPF Link State Update\n" |
| 730 | "OSPF Link State Acknowledgment\n" |
| 731 | "OSPF all packets\n") |
| 732 | { |
| 733 | int type = 0; |
| 734 | int flag = 0; |
| 735 | int i; |
| 736 | |
| 737 | assert (argc > 0); |
| 738 | |
| 739 | /* Check packet type. */ |
| 740 | if (strncmp (argv[0], "h", 1) == 0) |
| 741 | type = OSPF_DEBUG_HELLO; |
| 742 | else if (strncmp (argv[0], "d", 1) == 0) |
| 743 | type = OSPF_DEBUG_DB_DESC; |
| 744 | else if (strncmp (argv[0], "ls-r", 4) == 0) |
| 745 | type = OSPF_DEBUG_LS_REQ; |
| 746 | else if (strncmp (argv[0], "ls-u", 4) == 0) |
| 747 | type = OSPF_DEBUG_LS_UPD; |
| 748 | else if (strncmp (argv[0], "ls-a", 4) == 0) |
| 749 | type = OSPF_DEBUG_LS_ACK; |
| 750 | else if (strncmp (argv[0], "a", 1) == 0) |
| 751 | type = OSPF_DEBUG_ALL; |
| 752 | |
| 753 | /* Default, both send and recv. */ |
| 754 | if (argc == 1) |
| 755 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV; |
| 756 | |
| 757 | /* send or recv. */ |
| 758 | if (argc >= 2) |
| 759 | { |
| 760 | if (strncmp (argv[1], "s", 1) == 0) |
| 761 | flag = OSPF_DEBUG_SEND; |
| 762 | else if (strncmp (argv[1], "r", 1) == 0) |
| 763 | flag = OSPF_DEBUG_RECV; |
| 764 | else if (strncmp (argv[1], "d", 1) == 0) |
| 765 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
| 766 | } |
| 767 | |
| 768 | /* detail. */ |
| 769 | if (argc == 3) |
| 770 | if (strncmp (argv[2], "d", 1) == 0) |
| 771 | flag |= OSPF_DEBUG_DETAIL; |
| 772 | |
| 773 | for (i = 0; i < 5; i++) |
| 774 | if (type & (0x01 << i)) |
| 775 | { |
| 776 | if (vty->node == CONFIG_NODE) |
| 777 | DEBUG_PACKET_ON (i, flag); |
| 778 | else |
| 779 | TERM_DEBUG_PACKET_ON (i, flag); |
| 780 | } |
| 781 | |
| 782 | return CMD_SUCCESS; |
| 783 | } |
| 784 | |
| 785 | ALIAS (debug_ospf_packet, |
| 786 | debug_ospf_packet_send_recv_cmd, |
| 787 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", |
| 788 | "Debugging functions\n" |
| 789 | "OSPF information\n" |
| 790 | "OSPF packets\n" |
| 791 | "OSPF Hello\n" |
| 792 | "OSPF Database Description\n" |
| 793 | "OSPF Link State Request\n" |
| 794 | "OSPF Link State Update\n" |
| 795 | "OSPF Link State Acknowledgment\n" |
| 796 | "OSPF all packets\n" |
| 797 | "Packet sent\n" |
| 798 | "Packet received\n" |
| 799 | "Detail information\n") |
| 800 | |
| 801 | ALIAS (debug_ospf_packet, |
| 802 | debug_ospf_packet_send_recv_detail_cmd, |
| 803 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", |
| 804 | "Debugging functions\n" |
| 805 | "OSPF information\n" |
| 806 | "OSPF packets\n" |
| 807 | "OSPF Hello\n" |
| 808 | "OSPF Database Description\n" |
| 809 | "OSPF Link State Request\n" |
| 810 | "OSPF Link State Update\n" |
| 811 | "OSPF Link State Acknowledgment\n" |
| 812 | "OSPF all packets\n" |
| 813 | "Packet sent\n" |
| 814 | "Packet received\n" |
| 815 | "Detail Information\n") |
| 816 | |
| 817 | |
| 818 | DEFUN (no_debug_ospf_packet, |
| 819 | no_debug_ospf_packet_all_cmd, |
| 820 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", |
| 821 | NO_STR |
| 822 | DEBUG_STR |
| 823 | OSPF_STR |
| 824 | "OSPF packets\n" |
| 825 | "OSPF Hello\n" |
| 826 | "OSPF Database Description\n" |
| 827 | "OSPF Link State Request\n" |
| 828 | "OSPF Link State Update\n" |
| 829 | "OSPF Link State Acknowledgment\n" |
| 830 | "OSPF all packets\n") |
| 831 | { |
| 832 | int type = 0; |
| 833 | int flag = 0; |
| 834 | int i; |
| 835 | |
| 836 | assert (argc > 0); |
| 837 | |
| 838 | /* Check packet type. */ |
| 839 | if (strncmp (argv[0], "h", 1) == 0) |
| 840 | type = OSPF_DEBUG_HELLO; |
| 841 | else if (strncmp (argv[0], "d", 1) == 0) |
| 842 | type = OSPF_DEBUG_DB_DESC; |
| 843 | else if (strncmp (argv[0], "ls-r", 4) == 0) |
| 844 | type = OSPF_DEBUG_LS_REQ; |
| 845 | else if (strncmp (argv[0], "ls-u", 4) == 0) |
| 846 | type = OSPF_DEBUG_LS_UPD; |
| 847 | else if (strncmp (argv[0], "ls-a", 4) == 0) |
| 848 | type = OSPF_DEBUG_LS_ACK; |
| 849 | else if (strncmp (argv[0], "a", 1) == 0) |
| 850 | type = OSPF_DEBUG_ALL; |
| 851 | |
| 852 | /* Default, both send and recv. */ |
| 853 | if (argc == 1) |
| 854 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ; |
| 855 | |
| 856 | /* send or recv. */ |
| 857 | if (argc == 2) |
| 858 | { |
| 859 | if (strncmp (argv[1], "s", 1) == 0) |
| 860 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL; |
| 861 | else if (strncmp (argv[1], "r", 1) == 0) |
| 862 | flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
| 863 | else if (strncmp (argv[1], "d", 1) == 0) |
| 864 | flag = OSPF_DEBUG_DETAIL; |
| 865 | } |
| 866 | |
| 867 | /* detail. */ |
| 868 | if (argc == 3) |
| 869 | if (strncmp (argv[2], "d", 1) == 0) |
| 870 | flag = OSPF_DEBUG_DETAIL; |
| 871 | |
| 872 | for (i = 0; i < 5; i++) |
| 873 | if (type & (0x01 << i)) |
| 874 | { |
| 875 | if (vty->node == CONFIG_NODE) |
| 876 | DEBUG_PACKET_OFF (i, flag); |
| 877 | else |
| 878 | TERM_DEBUG_PACKET_OFF (i, flag); |
| 879 | } |
| 880 | |
| 881 | #ifdef DEBUG |
| 882 | for (i = 0; i < 5; i++) |
| 883 | zlog_info ("flag[%d] = %d", i, ospf_debug_packet[i]); |
| 884 | #endif /* DEBUG */ |
| 885 | |
| 886 | return CMD_SUCCESS; |
| 887 | } |
| 888 | |
| 889 | ALIAS (no_debug_ospf_packet, |
| 890 | no_debug_ospf_packet_send_recv_cmd, |
| 891 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", |
| 892 | NO_STR |
| 893 | "Debugging functions\n" |
| 894 | "OSPF information\n" |
| 895 | "OSPF packets\n" |
| 896 | "OSPF Hello\n" |
| 897 | "OSPF Database Description\n" |
| 898 | "OSPF Link State Request\n" |
| 899 | "OSPF Link State Update\n" |
| 900 | "OSPF Link State Acknowledgment\n" |
| 901 | "OSPF all packets\n" |
| 902 | "Packet sent\n" |
| 903 | "Packet received\n" |
| 904 | "Detail Information\n") |
| 905 | |
| 906 | ALIAS (no_debug_ospf_packet, |
| 907 | no_debug_ospf_packet_send_recv_detail_cmd, |
| 908 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", |
| 909 | NO_STR |
| 910 | "Debugging functions\n" |
| 911 | "OSPF information\n" |
| 912 | "OSPF packets\n" |
| 913 | "OSPF Hello\n" |
| 914 | "OSPF Database Description\n" |
| 915 | "OSPF Link State Request\n" |
| 916 | "OSPF Link State Update\n" |
| 917 | "OSPF Link State Acknowledgment\n" |
| 918 | "OSPF all packets\n" |
| 919 | "Packet sent\n" |
| 920 | "Packet received\n" |
| 921 | "Detail Information\n") |
| 922 | |
| 923 | |
| 924 | DEFUN (debug_ospf_ism, |
| 925 | debug_ospf_ism_cmd, |
| 926 | "debug ospf ism", |
| 927 | DEBUG_STR |
| 928 | OSPF_STR |
| 929 | "OSPF Interface State Machine\n") |
| 930 | { |
| 931 | if (vty->node == CONFIG_NODE) |
| 932 | { |
| 933 | if (argc == 0) |
| 934 | DEBUG_ON (ism, ISM); |
| 935 | else if (argc == 1) |
| 936 | { |
| 937 | if (strncmp (argv[0], "s", 1) == 0) |
| 938 | DEBUG_ON (ism, ISM_STATUS); |
| 939 | else if (strncmp (argv[0], "e", 1) == 0) |
| 940 | DEBUG_ON (ism, ISM_EVENTS); |
| 941 | else if (strncmp (argv[0], "t", 1) == 0) |
| 942 | DEBUG_ON (ism, ISM_TIMERS); |
| 943 | } |
| 944 | |
| 945 | return CMD_SUCCESS; |
| 946 | } |
| 947 | |
| 948 | /* ENABLE_NODE. */ |
| 949 | if (argc == 0) |
| 950 | TERM_DEBUG_ON (ism, ISM); |
| 951 | else if (argc == 1) |
| 952 | { |
| 953 | if (strncmp (argv[0], "s", 1) == 0) |
| 954 | TERM_DEBUG_ON (ism, ISM_STATUS); |
| 955 | else if (strncmp (argv[0], "e", 1) == 0) |
| 956 | TERM_DEBUG_ON (ism, ISM_EVENTS); |
| 957 | else if (strncmp (argv[0], "t", 1) == 0) |
| 958 | TERM_DEBUG_ON (ism, ISM_TIMERS); |
| 959 | } |
| 960 | |
| 961 | return CMD_SUCCESS; |
| 962 | } |
| 963 | |
| 964 | ALIAS (debug_ospf_ism, |
| 965 | debug_ospf_ism_sub_cmd, |
| 966 | "debug ospf ism (status|events|timers)", |
| 967 | DEBUG_STR |
| 968 | OSPF_STR |
| 969 | "OSPF Interface State Machine\n" |
| 970 | "ISM Status Information\n" |
| 971 | "ISM Event Information\n" |
| 972 | "ISM TImer Information\n") |
| 973 | |
| 974 | DEFUN (no_debug_ospf_ism, |
| 975 | no_debug_ospf_ism_cmd, |
| 976 | "no debug ospf ism", |
| 977 | NO_STR |
| 978 | DEBUG_STR |
| 979 | OSPF_STR |
| 980 | "OSPF Interface State Machine") |
| 981 | { |
| 982 | if (vty->node == CONFIG_NODE) |
| 983 | { |
| 984 | if (argc == 0) |
| 985 | DEBUG_OFF (ism, ISM); |
| 986 | else if (argc == 1) |
| 987 | { |
| 988 | if (strncmp (argv[0], "s", 1) == 0) |
| 989 | DEBUG_OFF (ism, ISM_STATUS); |
| 990 | else if (strncmp (argv[0], "e", 1) == 0) |
| 991 | DEBUG_OFF (ism, ISM_EVENTS); |
| 992 | else if (strncmp (argv[0], "t", 1) == 0) |
| 993 | DEBUG_OFF (ism, ISM_TIMERS); |
| 994 | } |
| 995 | return CMD_SUCCESS; |
| 996 | } |
| 997 | |
| 998 | /* ENABLE_NODE. */ |
| 999 | if (argc == 0) |
| 1000 | TERM_DEBUG_OFF (ism, ISM); |
| 1001 | else if (argc == 1) |
| 1002 | { |
| 1003 | if (strncmp (argv[0], "s", 1) == 0) |
| 1004 | TERM_DEBUG_OFF (ism, ISM_STATUS); |
| 1005 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1006 | TERM_DEBUG_OFF (ism, ISM_EVENTS); |
| 1007 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1008 | TERM_DEBUG_OFF (ism, ISM_TIMERS); |
| 1009 | } |
| 1010 | |
| 1011 | return CMD_SUCCESS; |
| 1012 | } |
| 1013 | |
| 1014 | ALIAS (no_debug_ospf_ism, |
| 1015 | no_debug_ospf_ism_sub_cmd, |
| 1016 | "no debug ospf ism (status|events|timers)", |
| 1017 | NO_STR |
| 1018 | "Debugging functions\n" |
| 1019 | "OSPF information\n" |
| 1020 | "OSPF Interface State Machine\n" |
| 1021 | "ISM Status Information\n" |
| 1022 | "ISM Event Information\n" |
| 1023 | "ISM Timer Information\n") |
| 1024 | |
| 1025 | |
| 1026 | DEFUN (debug_ospf_nsm, |
| 1027 | debug_ospf_nsm_cmd, |
| 1028 | "debug ospf nsm", |
| 1029 | DEBUG_STR |
| 1030 | OSPF_STR |
| 1031 | "OSPF Neighbor State Machine\n") |
| 1032 | { |
| 1033 | if (vty->node == CONFIG_NODE) |
| 1034 | { |
| 1035 | if (argc == 0) |
| 1036 | DEBUG_ON (nsm, NSM); |
| 1037 | else if (argc == 1) |
| 1038 | { |
| 1039 | if (strncmp (argv[0], "s", 1) == 0) |
| 1040 | DEBUG_ON (nsm, NSM_STATUS); |
| 1041 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1042 | DEBUG_ON (nsm, NSM_EVENTS); |
| 1043 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1044 | DEBUG_ON (nsm, NSM_TIMERS); |
| 1045 | } |
| 1046 | |
| 1047 | return CMD_SUCCESS; |
| 1048 | } |
| 1049 | |
| 1050 | /* ENABLE_NODE. */ |
| 1051 | if (argc == 0) |
| 1052 | TERM_DEBUG_ON (nsm, NSM); |
| 1053 | else if (argc == 1) |
| 1054 | { |
| 1055 | if (strncmp (argv[0], "s", 1) == 0) |
| 1056 | TERM_DEBUG_ON (nsm, NSM_STATUS); |
| 1057 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1058 | TERM_DEBUG_ON (nsm, NSM_EVENTS); |
| 1059 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1060 | TERM_DEBUG_ON (nsm, NSM_TIMERS); |
| 1061 | } |
| 1062 | |
| 1063 | return CMD_SUCCESS; |
| 1064 | } |
| 1065 | |
| 1066 | ALIAS (debug_ospf_nsm, |
| 1067 | debug_ospf_nsm_sub_cmd, |
| 1068 | "debug ospf nsm (status|events|timers)", |
| 1069 | DEBUG_STR |
| 1070 | OSPF_STR |
| 1071 | "OSPF Neighbor State Machine\n" |
| 1072 | "NSM Status Information\n" |
| 1073 | "NSM Event Information\n" |
| 1074 | "NSM Timer Information\n") |
| 1075 | |
| 1076 | DEFUN (no_debug_ospf_nsm, |
| 1077 | no_debug_ospf_nsm_cmd, |
| 1078 | "no debug ospf nsm", |
| 1079 | NO_STR |
| 1080 | DEBUG_STR |
| 1081 | OSPF_STR |
| 1082 | "OSPF Neighbor State Machine") |
| 1083 | { |
| 1084 | if (vty->node == CONFIG_NODE) |
| 1085 | { |
| 1086 | if (argc == 0) |
| 1087 | DEBUG_OFF (nsm, NSM); |
| 1088 | else if (argc == 1) |
| 1089 | { |
| 1090 | if (strncmp (argv[0], "s", 1) == 0) |
| 1091 | DEBUG_OFF (nsm, NSM_STATUS); |
| 1092 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1093 | DEBUG_OFF (nsm, NSM_EVENTS); |
| 1094 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1095 | DEBUG_OFF (nsm, NSM_TIMERS); |
| 1096 | } |
| 1097 | |
| 1098 | return CMD_SUCCESS; |
| 1099 | } |
| 1100 | |
| 1101 | /* ENABLE_NODE. */ |
| 1102 | if (argc == 0) |
| 1103 | TERM_DEBUG_OFF (nsm, NSM); |
| 1104 | else if (argc == 1) |
| 1105 | { |
| 1106 | if (strncmp (argv[0], "s", 1) == 0) |
| 1107 | TERM_DEBUG_OFF (nsm, NSM_STATUS); |
| 1108 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1109 | TERM_DEBUG_OFF (nsm, NSM_EVENTS); |
| 1110 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1111 | TERM_DEBUG_OFF (nsm, NSM_TIMERS); |
| 1112 | } |
| 1113 | |
| 1114 | return CMD_SUCCESS; |
| 1115 | } |
| 1116 | |
| 1117 | ALIAS (no_debug_ospf_nsm, |
| 1118 | no_debug_ospf_nsm_sub_cmd, |
| 1119 | "no debug ospf nsm (status|events|timers)", |
| 1120 | NO_STR |
| 1121 | "Debugging functions\n" |
| 1122 | "OSPF information\n" |
| 1123 | "OSPF Interface State Machine\n" |
| 1124 | "NSM Status Information\n" |
| 1125 | "NSM Event Information\n" |
| 1126 | "NSM Timer Information\n") |
| 1127 | |
| 1128 | |
| 1129 | DEFUN (debug_ospf_lsa, |
| 1130 | debug_ospf_lsa_cmd, |
| 1131 | "debug ospf lsa", |
| 1132 | DEBUG_STR |
| 1133 | OSPF_STR |
| 1134 | "OSPF Link State Advertisement\n") |
| 1135 | { |
| 1136 | if (vty->node == CONFIG_NODE) |
| 1137 | { |
| 1138 | if (argc == 0) |
| 1139 | DEBUG_ON (lsa, LSA); |
| 1140 | else if (argc == 1) |
| 1141 | { |
| 1142 | if (strncmp (argv[0], "g", 1) == 0) |
| 1143 | DEBUG_ON (lsa, LSA_GENERATE); |
| 1144 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1145 | DEBUG_ON (lsa, LSA_FLOODING); |
| 1146 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1147 | DEBUG_ON (lsa, LSA_INSTALL); |
| 1148 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1149 | DEBUG_ON (lsa, LSA_REFRESH); |
| 1150 | } |
| 1151 | |
| 1152 | return CMD_SUCCESS; |
| 1153 | } |
| 1154 | |
| 1155 | /* ENABLE_NODE. */ |
| 1156 | if (argc == 0) |
| 1157 | TERM_DEBUG_ON (lsa, LSA); |
| 1158 | else if (argc == 1) |
| 1159 | { |
| 1160 | if (strncmp (argv[0], "g", 1) == 0) |
| 1161 | TERM_DEBUG_ON (lsa, LSA_GENERATE); |
| 1162 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1163 | TERM_DEBUG_ON (lsa, LSA_FLOODING); |
| 1164 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1165 | TERM_DEBUG_ON (lsa, LSA_INSTALL); |
| 1166 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1167 | TERM_DEBUG_ON (lsa, LSA_REFRESH); |
| 1168 | } |
| 1169 | |
| 1170 | return CMD_SUCCESS; |
| 1171 | } |
| 1172 | |
| 1173 | ALIAS (debug_ospf_lsa, |
| 1174 | debug_ospf_lsa_sub_cmd, |
| 1175 | "debug ospf lsa (generate|flooding|install|refresh)", |
| 1176 | DEBUG_STR |
| 1177 | OSPF_STR |
| 1178 | "OSPF Link State Advertisement\n" |
| 1179 | "LSA Generation\n" |
| 1180 | "LSA Flooding\n" |
| 1181 | "LSA Install/Delete\n" |
| 1182 | "LSA Refresh\n") |
| 1183 | |
| 1184 | DEFUN (no_debug_ospf_lsa, |
| 1185 | no_debug_ospf_lsa_cmd, |
| 1186 | "no debug ospf lsa", |
| 1187 | NO_STR |
| 1188 | DEBUG_STR |
| 1189 | OSPF_STR |
| 1190 | "OSPF Link State Advertisement\n") |
| 1191 | { |
| 1192 | if (vty->node == CONFIG_NODE) |
| 1193 | { |
| 1194 | if (argc == 0) |
| 1195 | DEBUG_OFF (lsa, LSA); |
| 1196 | else if (argc == 1) |
| 1197 | { |
| 1198 | if (strncmp (argv[0], "g", 1) == 0) |
| 1199 | DEBUG_OFF (lsa, LSA_GENERATE); |
| 1200 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1201 | DEBUG_OFF (lsa, LSA_FLOODING); |
| 1202 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1203 | DEBUG_OFF (lsa, LSA_INSTALL); |
| 1204 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1205 | DEBUG_OFF (lsa, LSA_REFRESH); |
| 1206 | } |
| 1207 | |
| 1208 | return CMD_SUCCESS; |
| 1209 | } |
| 1210 | |
| 1211 | /* ENABLE_NODE. */ |
| 1212 | if (argc == 0) |
| 1213 | TERM_DEBUG_OFF (lsa, LSA); |
| 1214 | else if (argc == 1) |
| 1215 | { |
| 1216 | if (strncmp (argv[0], "g", 1) == 0) |
| 1217 | TERM_DEBUG_OFF (lsa, LSA_GENERATE); |
| 1218 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1219 | TERM_DEBUG_OFF (lsa, LSA_FLOODING); |
| 1220 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1221 | TERM_DEBUG_OFF (lsa, LSA_INSTALL); |
| 1222 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1223 | TERM_DEBUG_OFF (lsa, LSA_REFRESH); |
| 1224 | } |
| 1225 | |
| 1226 | return CMD_SUCCESS; |
| 1227 | } |
| 1228 | |
| 1229 | ALIAS (no_debug_ospf_lsa, |
| 1230 | no_debug_ospf_lsa_sub_cmd, |
| 1231 | "no debug ospf lsa (generate|flooding|install|refresh)", |
| 1232 | NO_STR |
| 1233 | DEBUG_STR |
| 1234 | OSPF_STR |
| 1235 | "OSPF Link State Advertisement\n" |
| 1236 | "LSA Generation\n" |
| 1237 | "LSA Flooding\n" |
| 1238 | "LSA Install/Delete\n" |
| 1239 | "LSA Refres\n") |
| 1240 | |
| 1241 | |
| 1242 | DEFUN (debug_ospf_zebra, |
| 1243 | debug_ospf_zebra_cmd, |
| 1244 | "debug ospf zebra", |
| 1245 | DEBUG_STR |
| 1246 | OSPF_STR |
| 1247 | "OSPF Zebra information\n") |
| 1248 | { |
| 1249 | if (vty->node == CONFIG_NODE) |
| 1250 | { |
| 1251 | if (argc == 0) |
| 1252 | DEBUG_ON (zebra, ZEBRA); |
| 1253 | else if (argc == 1) |
| 1254 | { |
| 1255 | if (strncmp (argv[0], "i", 1) == 0) |
| 1256 | DEBUG_ON (zebra, ZEBRA_INTERFACE); |
| 1257 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1258 | DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); |
| 1259 | } |
| 1260 | |
| 1261 | return CMD_SUCCESS; |
| 1262 | } |
| 1263 | |
| 1264 | /* ENABLE_NODE. */ |
| 1265 | if (argc == 0) |
| 1266 | TERM_DEBUG_ON (zebra, ZEBRA); |
| 1267 | else if (argc == 1) |
| 1268 | { |
| 1269 | if (strncmp (argv[0], "i", 1) == 0) |
| 1270 | TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE); |
| 1271 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1272 | TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); |
| 1273 | } |
| 1274 | |
| 1275 | return CMD_SUCCESS; |
| 1276 | } |
| 1277 | |
| 1278 | ALIAS (debug_ospf_zebra, |
| 1279 | debug_ospf_zebra_sub_cmd, |
| 1280 | "debug ospf zebra (interface|redistribute)", |
| 1281 | DEBUG_STR |
| 1282 | OSPF_STR |
| 1283 | "OSPF Zebra information\n" |
| 1284 | "Zebra interface\n" |
| 1285 | "Zebra redistribute\n") |
| 1286 | |
| 1287 | DEFUN (no_debug_ospf_zebra, |
| 1288 | no_debug_ospf_zebra_cmd, |
| 1289 | "no debug ospf zebra", |
| 1290 | NO_STR |
| 1291 | DEBUG_STR |
| 1292 | OSPF_STR |
| 1293 | "OSPF Zebra information\n") |
| 1294 | { |
| 1295 | if (vty->node == CONFIG_NODE) |
| 1296 | { |
| 1297 | if (argc == 0) |
| 1298 | DEBUG_OFF (zebra, ZEBRA); |
| 1299 | else if (argc == 1) |
| 1300 | { |
| 1301 | if (strncmp (argv[0], "i", 1) == 0) |
| 1302 | DEBUG_OFF (zebra, ZEBRA_INTERFACE); |
| 1303 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1304 | DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); |
| 1305 | } |
| 1306 | |
| 1307 | return CMD_SUCCESS; |
| 1308 | } |
| 1309 | |
| 1310 | /* ENABLE_NODE. */ |
| 1311 | if (argc == 0) |
| 1312 | TERM_DEBUG_OFF (zebra, ZEBRA); |
| 1313 | else if (argc == 1) |
| 1314 | { |
| 1315 | if (strncmp (argv[0], "i", 1) == 0) |
| 1316 | TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE); |
| 1317 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1318 | TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); |
| 1319 | } |
| 1320 | |
| 1321 | return CMD_SUCCESS; |
| 1322 | } |
| 1323 | |
| 1324 | ALIAS (no_debug_ospf_zebra, |
| 1325 | no_debug_ospf_zebra_sub_cmd, |
| 1326 | "no debug ospf zebra (interface|redistribute)", |
| 1327 | NO_STR |
| 1328 | DEBUG_STR |
| 1329 | OSPF_STR |
| 1330 | "OSPF Zebra information\n" |
| 1331 | "Zebra interface\n" |
| 1332 | "Zebra redistribute\n") |
| 1333 | |
| 1334 | DEFUN (debug_ospf_event, |
| 1335 | debug_ospf_event_cmd, |
| 1336 | "debug ospf event", |
| 1337 | DEBUG_STR |
| 1338 | OSPF_STR |
| 1339 | "OSPF event information\n") |
| 1340 | { |
| 1341 | if (vty->node == CONFIG_NODE) |
| 1342 | CONF_DEBUG_ON (event, EVENT); |
| 1343 | TERM_DEBUG_ON (event, EVENT); |
| 1344 | return CMD_SUCCESS; |
| 1345 | } |
| 1346 | |
| 1347 | DEFUN (no_debug_ospf_event, |
| 1348 | no_debug_ospf_event_cmd, |
| 1349 | "no debug ospf event", |
| 1350 | NO_STR |
| 1351 | DEBUG_STR |
| 1352 | OSPF_STR |
| 1353 | "OSPF event information\n") |
| 1354 | { |
| 1355 | if (vty->node == CONFIG_NODE) |
| 1356 | CONF_DEBUG_OFF (event, EVENT); |
| 1357 | TERM_DEBUG_OFF (event, EVENT); |
| 1358 | return CMD_SUCCESS; |
| 1359 | } |
| 1360 | |
| 1361 | DEFUN (debug_ospf_nssa, |
| 1362 | debug_ospf_nssa_cmd, |
| 1363 | "debug ospf nssa", |
| 1364 | DEBUG_STR |
| 1365 | OSPF_STR |
| 1366 | "OSPF nssa information\n") |
| 1367 | { |
| 1368 | if (vty->node == CONFIG_NODE) |
| 1369 | CONF_DEBUG_ON (nssa, NSSA); |
| 1370 | TERM_DEBUG_ON (nssa, NSSA); |
| 1371 | return CMD_SUCCESS; |
| 1372 | } |
| 1373 | |
| 1374 | DEFUN (no_debug_ospf_nssa, |
| 1375 | no_debug_ospf_nssa_cmd, |
| 1376 | "no debug ospf nssa", |
| 1377 | NO_STR |
| 1378 | DEBUG_STR |
| 1379 | OSPF_STR |
| 1380 | "OSPF nssa information\n") |
| 1381 | { |
| 1382 | if (vty->node == CONFIG_NODE) |
| 1383 | CONF_DEBUG_OFF (nssa, NSSA); |
| 1384 | TERM_DEBUG_OFF (nssa, NSSA); |
| 1385 | return CMD_SUCCESS; |
| 1386 | } |
| 1387 | |
| 1388 | |
| 1389 | DEFUN (show_debugging_ospf, |
| 1390 | show_debugging_ospf_cmd, |
| 1391 | "show debugging ospf", |
| 1392 | SHOW_STR |
| 1393 | DEBUG_STR |
| 1394 | OSPF_STR) |
| 1395 | { |
| 1396 | int i; |
| 1397 | |
| 1398 | vty_out (vty, "Zebra debugging status:%s", VTY_NEWLINE); |
| 1399 | |
| 1400 | /* Show debug status for ISM. */ |
| 1401 | if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) |
| 1402 | vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE); |
| 1403 | else |
| 1404 | { |
| 1405 | if (IS_DEBUG_OSPF (ism, ISM_STATUS)) |
| 1406 | vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE); |
| 1407 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) |
| 1408 | vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE); |
| 1409 | if (IS_DEBUG_OSPF (ism, ISM_TIMERS)) |
| 1410 | vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE); |
| 1411 | } |
| 1412 | |
| 1413 | /* Show debug status for NSM. */ |
| 1414 | if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) |
| 1415 | vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE); |
| 1416 | else |
| 1417 | { |
| 1418 | if (IS_DEBUG_OSPF (nsm, NSM_STATUS)) |
| 1419 | vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE); |
| 1420 | if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) |
| 1421 | vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE); |
| 1422 | if (IS_DEBUG_OSPF (nsm, NSM_TIMERS)) |
| 1423 | vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE); |
| 1424 | } |
| 1425 | |
| 1426 | /* Show debug status for OSPF Packets. */ |
| 1427 | for (i = 0; i < 5; i++) |
| 1428 | if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV)) |
| 1429 | { |
| 1430 | vty_out (vty, " OSPF packet %s%s debugging is on%s", |
| 1431 | ospf_packet_type_str[i + 1], |
| 1432 | IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "", |
| 1433 | VTY_NEWLINE); |
| 1434 | } |
| 1435 | else |
| 1436 | { |
| 1437 | if (IS_DEBUG_OSPF_PACKET (i, SEND)) |
| 1438 | vty_out (vty, " OSPF packet %s send%s debugging is on%s", |
| 1439 | ospf_packet_type_str[i + 1], |
| 1440 | IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "", |
| 1441 | VTY_NEWLINE); |
| 1442 | if (IS_DEBUG_OSPF_PACKET (i, RECV)) |
| 1443 | vty_out (vty, " OSPF packet %s receive%s debugging is on%s", |
| 1444 | ospf_packet_type_str[i + 1], |
| 1445 | IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "", |
| 1446 | VTY_NEWLINE); |
| 1447 | } |
| 1448 | |
| 1449 | /* Show debug status for OSPF LSAs. */ |
| 1450 | if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) |
| 1451 | vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE); |
| 1452 | else |
| 1453 | { |
| 1454 | if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) |
| 1455 | vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE); |
| 1456 | if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
| 1457 | vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE); |
| 1458 | if (IS_DEBUG_OSPF (lsa, LSA_INSTALL)) |
| 1459 | vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE); |
| 1460 | if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) |
| 1461 | vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE); |
| 1462 | } |
| 1463 | |
| 1464 | /* Show debug status for Zebra. */ |
| 1465 | if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) |
| 1466 | vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE); |
| 1467 | else |
| 1468 | { |
| 1469 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
| 1470 | vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE); |
| 1471 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
| 1472 | vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE); |
| 1473 | } |
paul | ead687e | 2003-04-07 17:12:12 +0000 | [diff] [blame] | 1474 | if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) |
| 1475 | vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1476 | |
| 1477 | return CMD_SUCCESS; |
| 1478 | } |
| 1479 | |
| 1480 | /* Debug node. */ |
| 1481 | struct cmd_node debug_node = |
| 1482 | { |
| 1483 | DEBUG_NODE, |
| 1484 | "" |
| 1485 | }; |
| 1486 | |
| 1487 | int |
| 1488 | config_write_debug (struct vty *vty) |
| 1489 | { |
| 1490 | int write = 0; |
| 1491 | int i, r; |
| 1492 | |
| 1493 | char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"}; |
| 1494 | char *detail_str[] = {"", " send", " recv", "", " detail", |
| 1495 | " send detail", " recv detail", " detail"}; |
| 1496 | |
| 1497 | /* debug ospf ism (status|events|timers). */ |
| 1498 | if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) |
| 1499 | vty_out (vty, "debug ospf ism%s", VTY_NEWLINE); |
| 1500 | else |
| 1501 | { |
| 1502 | if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS)) |
| 1503 | vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE); |
| 1504 | if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS)) |
| 1505 | vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE); |
| 1506 | if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS)) |
| 1507 | vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE); |
| 1508 | } |
| 1509 | |
| 1510 | /* debug ospf nsm (status|events|timers). */ |
| 1511 | if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) |
| 1512 | vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE); |
| 1513 | else |
| 1514 | { |
| 1515 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS)) |
| 1516 | vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE); |
| 1517 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS)) |
| 1518 | vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE); |
| 1519 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS)) |
| 1520 | vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE); |
| 1521 | } |
| 1522 | |
| 1523 | /* debug ospf lsa (generate|flooding|install|refresh). */ |
| 1524 | if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) |
| 1525 | vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE); |
| 1526 | else |
| 1527 | { |
| 1528 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE)) |
| 1529 | vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE); |
| 1530 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING)) |
| 1531 | vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE); |
| 1532 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL)) |
| 1533 | vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE); |
| 1534 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH)) |
| 1535 | vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE); |
| 1536 | |
| 1537 | write = 1; |
| 1538 | } |
| 1539 | |
| 1540 | /* debug ospf zebra (interface|redistribute). */ |
| 1541 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) |
| 1542 | vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE); |
| 1543 | else |
| 1544 | { |
| 1545 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
| 1546 | vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE); |
| 1547 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
| 1548 | vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE); |
| 1549 | |
| 1550 | write = 1; |
| 1551 | } |
| 1552 | |
| 1553 | /* debug ospf event. */ |
| 1554 | if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT) |
| 1555 | { |
| 1556 | vty_out (vty, "debug ospf event%s", VTY_NEWLINE); |
| 1557 | write = 1; |
| 1558 | } |
| 1559 | |
| 1560 | /* debug ospf nssa. */ |
| 1561 | if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) |
| 1562 | { |
| 1563 | vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE); |
| 1564 | write = 1; |
| 1565 | } |
| 1566 | |
| 1567 | /* debug ospf packet all detail. */ |
| 1568 | r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL; |
| 1569 | for (i = 0; i < 5; i++) |
| 1570 | r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL); |
| 1571 | if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL)) |
| 1572 | { |
| 1573 | vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE); |
| 1574 | return 1; |
| 1575 | } |
| 1576 | |
| 1577 | /* debug ospf packet all. */ |
| 1578 | r = OSPF_DEBUG_SEND_RECV; |
| 1579 | for (i = 0; i < 5; i++) |
| 1580 | r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV; |
| 1581 | if (r == OSPF_DEBUG_SEND_RECV) |
| 1582 | { |
| 1583 | vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE); |
| 1584 | for (i = 0; i < 5; i++) |
| 1585 | if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL) |
| 1586 | vty_out (vty, "debug ospf packet %s detail%s", |
| 1587 | type_str[i], |
| 1588 | VTY_NEWLINE); |
| 1589 | return 1; |
| 1590 | } |
| 1591 | |
| 1592 | /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack) |
| 1593 | (send|recv) (detail). */ |
| 1594 | for (i = 0; i < 5; i++) |
| 1595 | { |
| 1596 | if (conf_debug_ospf_packet[i] == 0) |
| 1597 | continue; |
| 1598 | |
| 1599 | vty_out (vty, "debug ospf packet %s%s%s", |
| 1600 | type_str[i], detail_str[conf_debug_ospf_packet[i]], |
| 1601 | VTY_NEWLINE); |
| 1602 | write = 1; |
| 1603 | } |
| 1604 | |
| 1605 | return write; |
| 1606 | } |
| 1607 | |
| 1608 | /* Initialize debug commands. */ |
| 1609 | void |
| 1610 | debug_init () |
| 1611 | { |
| 1612 | install_node (&debug_node, config_write_debug); |
| 1613 | |
| 1614 | install_element (ENABLE_NODE, &show_debugging_ospf_cmd); |
| 1615 | install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd); |
| 1616 | install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd); |
| 1617 | install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd); |
| 1618 | install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd); |
| 1619 | install_element (ENABLE_NODE, &debug_ospf_ism_cmd); |
| 1620 | install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd); |
| 1621 | install_element (ENABLE_NODE, &debug_ospf_nsm_cmd); |
| 1622 | install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd); |
| 1623 | install_element (ENABLE_NODE, &debug_ospf_lsa_cmd); |
| 1624 | install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd); |
| 1625 | install_element (ENABLE_NODE, &debug_ospf_zebra_cmd); |
| 1626 | install_element (ENABLE_NODE, &debug_ospf_event_cmd); |
| 1627 | #ifdef HAVE_NSSA |
| 1628 | install_element (ENABLE_NODE, &debug_ospf_nssa_cmd); |
| 1629 | #endif /* HAVE_NSSA */ |
| 1630 | install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); |
| 1631 | install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd); |
| 1632 | install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd); |
| 1633 | install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd); |
| 1634 | install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd); |
| 1635 | install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd); |
| 1636 | install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd); |
| 1637 | install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd); |
| 1638 | install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd); |
| 1639 | install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd); |
| 1640 | install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd); |
| 1641 | install_element (ENABLE_NODE, &no_debug_ospf_event_cmd); |
| 1642 | #ifdef HAVE_NSSA |
| 1643 | install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd); |
| 1644 | #endif /* HAVE_NSSA */ |
| 1645 | |
| 1646 | install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd); |
| 1647 | install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd); |
| 1648 | install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd); |
| 1649 | install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd); |
| 1650 | install_element (CONFIG_NODE, &debug_ospf_ism_cmd); |
| 1651 | install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd); |
| 1652 | install_element (CONFIG_NODE, &debug_ospf_nsm_cmd); |
| 1653 | install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd); |
| 1654 | install_element (CONFIG_NODE, &debug_ospf_lsa_cmd); |
| 1655 | install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd); |
| 1656 | install_element (CONFIG_NODE, &debug_ospf_zebra_cmd); |
| 1657 | install_element (CONFIG_NODE, &debug_ospf_event_cmd); |
| 1658 | #ifdef HAVE_NSSA |
| 1659 | install_element (CONFIG_NODE, &debug_ospf_nssa_cmd); |
| 1660 | #endif /* HAVE_NSSA */ |
| 1661 | install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); |
| 1662 | install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd); |
| 1663 | install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd); |
| 1664 | install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd); |
| 1665 | install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd); |
| 1666 | install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd); |
| 1667 | install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd); |
| 1668 | install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd); |
| 1669 | install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd); |
| 1670 | install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd); |
| 1671 | install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd); |
| 1672 | install_element (CONFIG_NODE, &no_debug_ospf_event_cmd); |
| 1673 | #ifdef HAVE_NSSA |
| 1674 | install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd); |
| 1675 | #endif /* HAVE_NSSA */ |
| 1676 | } |