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