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