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