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 | case OSPF_OPAQUE_LINK_LSA: |
| 623 | case OSPF_OPAQUE_AREA_LSA: |
| 624 | case OSPF_OPAQUE_AS_LSA: |
| 625 | ospf_opaque_lsa_dump (s, length); |
| 626 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 627 | default: |
| 628 | break; |
| 629 | } |
| 630 | |
paul | 9985f83 | 2005-02-09 15:51:56 +0000 | [diff] [blame] | 631 | stream_forward_getp (s, lsa_len); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 632 | length -= lsa_len; |
| 633 | count--; |
| 634 | } |
| 635 | |
| 636 | stream_set_getp (s, sp); |
| 637 | } |
| 638 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 639 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 640 | ospf_packet_ls_ack_dump (struct stream *s, u_int16_t length) |
| 641 | { |
| 642 | u_int32_t sp; |
| 643 | |
| 644 | length -= OSPF_HEADER_SIZE; |
| 645 | sp = stream_get_getp (s); |
| 646 | |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 647 | zlog_debug ("Link State Acknowledgment"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 648 | ospf_lsa_header_list_dump (s, length); |
| 649 | |
| 650 | stream_set_getp (s, sp); |
| 651 | } |
| 652 | |
paul | 6b33361 | 2004-10-11 10:11:25 +0000 | [diff] [blame] | 653 | /* Expects header to be in host order */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 654 | void |
paul | 6b33361 | 2004-10-11 10:11:25 +0000 | [diff] [blame] | 655 | ospf_ip_header_dump (struct ip *iph) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 656 | { |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 657 | /* IP Header dump. */ |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 658 | zlog_debug ("ip_v %d", iph->ip_v); |
| 659 | zlog_debug ("ip_hl %d", iph->ip_hl); |
| 660 | zlog_debug ("ip_tos %d", iph->ip_tos); |
| 661 | zlog_debug ("ip_len %d", iph->ip_len); |
| 662 | zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id); |
| 663 | zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off); |
| 664 | zlog_debug ("ip_ttl %d", iph->ip_ttl); |
| 665 | zlog_debug ("ip_p %d", iph->ip_p); |
| 666 | zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum); |
| 667 | zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src)); |
| 668 | zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 669 | } |
| 670 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 671 | static void |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 672 | ospf_header_dump (struct ospf_header *ospfh) |
| 673 | { |
| 674 | char buf[9]; |
Denis Ovsienko | ef1b78c | 2012-02-26 17:00:57 +0400 | [diff] [blame] | 675 | u_int16_t auth_type = ntohs (ospfh->auth_type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 676 | |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 677 | zlog_debug ("Header"); |
| 678 | zlog_debug (" Version %d", ospfh->version); |
| 679 | zlog_debug (" Type %d (%s)", ospfh->type, |
Denis Ovsienko | 272ca1e | 2012-01-15 19:12:19 +0400 | [diff] [blame] | 680 | LOOKUP (ospf_packet_type_str, ospfh->type)); |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 681 | zlog_debug (" Packet Len %d", ntohs (ospfh->length)); |
| 682 | zlog_debug (" Router ID %s", inet_ntoa (ospfh->router_id)); |
| 683 | zlog_debug (" Area ID %s", inet_ntoa (ospfh->area_id)); |
| 684 | zlog_debug (" Checksum 0x%x", ntohs (ospfh->checksum)); |
Denis Ovsienko | ef1b78c | 2012-02-26 17:00:57 +0400 | [diff] [blame] | 685 | zlog_debug (" AuType %s", LOOKUP (ospf_auth_type_str, auth_type)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 686 | |
Denis Ovsienko | ef1b78c | 2012-02-26 17:00:57 +0400 | [diff] [blame] | 687 | switch (auth_type) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 688 | { |
| 689 | case OSPF_AUTH_NULL: |
| 690 | break; |
| 691 | case OSPF_AUTH_SIMPLE: |
| 692 | memset (buf, 0, 9); |
hasso | c9e52be | 2004-09-26 16:09:34 +0000 | [diff] [blame] | 693 | strncpy (buf, (char *) ospfh->u.auth_data, 8); |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 694 | zlog_debug (" Simple Password %s", buf); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 695 | break; |
| 696 | case OSPF_AUTH_CRYPTOGRAPHIC: |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 697 | zlog_debug (" Cryptographic Authentication"); |
| 698 | zlog_debug (" Key ID %d", ospfh->u.crypt.key_id); |
| 699 | zlog_debug (" Auth Data Len %d", ospfh->u.crypt.auth_data_len); |
| 700 | zlog_debug (" Sequence number %ld", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 701 | (u_long)ntohl (ospfh->u.crypt.crypt_seqnum)); |
| 702 | break; |
| 703 | default: |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 704 | zlog_debug ("* This is not supported authentication type"); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 705 | break; |
| 706 | } |
| 707 | |
| 708 | } |
| 709 | |
| 710 | void |
| 711 | ospf_packet_dump (struct stream *s) |
| 712 | { |
| 713 | struct ospf_header *ospfh; |
| 714 | unsigned long gp; |
| 715 | |
| 716 | /* Preserve pointer. */ |
| 717 | gp = stream_get_getp (s); |
| 718 | |
| 719 | /* OSPF Header dump. */ |
| 720 | ospfh = (struct ospf_header *) STREAM_PNT (s); |
| 721 | |
| 722 | /* Until detail flag is set, return. */ |
| 723 | if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL)) |
| 724 | return; |
| 725 | |
| 726 | /* Show OSPF header detail. */ |
| 727 | ospf_header_dump (ospfh); |
paul | 9985f83 | 2005-02-09 15:51:56 +0000 | [diff] [blame] | 728 | stream_forward_getp (s, OSPF_HEADER_SIZE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 729 | |
| 730 | switch (ospfh->type) |
| 731 | { |
| 732 | case OSPF_MSG_HELLO: |
| 733 | ospf_packet_hello_dump (s, ntohs (ospfh->length)); |
| 734 | break; |
| 735 | case OSPF_MSG_DB_DESC: |
| 736 | ospf_packet_db_desc_dump (s, ntohs (ospfh->length)); |
| 737 | break; |
| 738 | case OSPF_MSG_LS_REQ: |
| 739 | ospf_packet_ls_req_dump (s, ntohs (ospfh->length)); |
| 740 | break; |
| 741 | case OSPF_MSG_LS_UPD: |
| 742 | ospf_packet_ls_upd_dump (s, ntohs (ospfh->length)); |
| 743 | break; |
| 744 | case OSPF_MSG_LS_ACK: |
| 745 | ospf_packet_ls_ack_dump (s, ntohs (ospfh->length)); |
| 746 | break; |
| 747 | default: |
| 748 | break; |
| 749 | } |
| 750 | |
| 751 | stream_set_getp (s, gp); |
| 752 | } |
| 753 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 754 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 755 | /* |
| 756 | [no] debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) |
| 757 | [send|recv [detail]] |
| 758 | */ |
| 759 | DEFUN (debug_ospf_packet, |
| 760 | debug_ospf_packet_all_cmd, |
| 761 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", |
| 762 | DEBUG_STR |
| 763 | OSPF_STR |
| 764 | "OSPF packets\n" |
| 765 | "OSPF Hello\n" |
| 766 | "OSPF Database Description\n" |
| 767 | "OSPF Link State Request\n" |
| 768 | "OSPF Link State Update\n" |
| 769 | "OSPF Link State Acknowledgment\n" |
| 770 | "OSPF all packets\n") |
| 771 | { |
| 772 | int type = 0; |
| 773 | int flag = 0; |
| 774 | int i; |
| 775 | |
| 776 | assert (argc > 0); |
| 777 | |
| 778 | /* Check packet type. */ |
| 779 | if (strncmp (argv[0], "h", 1) == 0) |
| 780 | type = OSPF_DEBUG_HELLO; |
| 781 | else if (strncmp (argv[0], "d", 1) == 0) |
| 782 | type = OSPF_DEBUG_DB_DESC; |
| 783 | else if (strncmp (argv[0], "ls-r", 4) == 0) |
| 784 | type = OSPF_DEBUG_LS_REQ; |
| 785 | else if (strncmp (argv[0], "ls-u", 4) == 0) |
| 786 | type = OSPF_DEBUG_LS_UPD; |
| 787 | else if (strncmp (argv[0], "ls-a", 4) == 0) |
| 788 | type = OSPF_DEBUG_LS_ACK; |
| 789 | else if (strncmp (argv[0], "a", 1) == 0) |
| 790 | type = OSPF_DEBUG_ALL; |
| 791 | |
| 792 | /* Default, both send and recv. */ |
| 793 | if (argc == 1) |
| 794 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV; |
| 795 | |
| 796 | /* send or recv. */ |
| 797 | if (argc >= 2) |
| 798 | { |
| 799 | if (strncmp (argv[1], "s", 1) == 0) |
| 800 | flag = OSPF_DEBUG_SEND; |
| 801 | else if (strncmp (argv[1], "r", 1) == 0) |
| 802 | flag = OSPF_DEBUG_RECV; |
| 803 | else if (strncmp (argv[1], "d", 1) == 0) |
| 804 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
| 805 | } |
| 806 | |
| 807 | /* detail. */ |
| 808 | if (argc == 3) |
| 809 | if (strncmp (argv[2], "d", 1) == 0) |
| 810 | flag |= OSPF_DEBUG_DETAIL; |
| 811 | |
| 812 | for (i = 0; i < 5; i++) |
| 813 | if (type & (0x01 << i)) |
| 814 | { |
| 815 | if (vty->node == CONFIG_NODE) |
| 816 | DEBUG_PACKET_ON (i, flag); |
| 817 | else |
| 818 | TERM_DEBUG_PACKET_ON (i, flag); |
| 819 | } |
| 820 | |
| 821 | return CMD_SUCCESS; |
| 822 | } |
| 823 | |
| 824 | ALIAS (debug_ospf_packet, |
| 825 | debug_ospf_packet_send_recv_cmd, |
| 826 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", |
| 827 | "Debugging functions\n" |
| 828 | "OSPF information\n" |
| 829 | "OSPF packets\n" |
| 830 | "OSPF Hello\n" |
| 831 | "OSPF Database Description\n" |
| 832 | "OSPF Link State Request\n" |
| 833 | "OSPF Link State Update\n" |
| 834 | "OSPF Link State Acknowledgment\n" |
| 835 | "OSPF all packets\n" |
| 836 | "Packet sent\n" |
| 837 | "Packet received\n" |
| 838 | "Detail information\n") |
| 839 | |
| 840 | ALIAS (debug_ospf_packet, |
| 841 | debug_ospf_packet_send_recv_detail_cmd, |
| 842 | "debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", |
| 843 | "Debugging functions\n" |
| 844 | "OSPF information\n" |
| 845 | "OSPF packets\n" |
| 846 | "OSPF Hello\n" |
| 847 | "OSPF Database Description\n" |
| 848 | "OSPF Link State Request\n" |
| 849 | "OSPF Link State Update\n" |
| 850 | "OSPF Link State Acknowledgment\n" |
| 851 | "OSPF all packets\n" |
| 852 | "Packet sent\n" |
| 853 | "Packet received\n" |
| 854 | "Detail Information\n") |
| 855 | |
| 856 | |
| 857 | DEFUN (no_debug_ospf_packet, |
| 858 | no_debug_ospf_packet_all_cmd, |
| 859 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all)", |
| 860 | NO_STR |
| 861 | DEBUG_STR |
| 862 | OSPF_STR |
| 863 | "OSPF packets\n" |
| 864 | "OSPF Hello\n" |
| 865 | "OSPF Database Description\n" |
| 866 | "OSPF Link State Request\n" |
| 867 | "OSPF Link State Update\n" |
| 868 | "OSPF Link State Acknowledgment\n" |
| 869 | "OSPF all packets\n") |
| 870 | { |
| 871 | int type = 0; |
| 872 | int flag = 0; |
| 873 | int i; |
| 874 | |
| 875 | assert (argc > 0); |
| 876 | |
| 877 | /* Check packet type. */ |
| 878 | if (strncmp (argv[0], "h", 1) == 0) |
| 879 | type = OSPF_DEBUG_HELLO; |
| 880 | else if (strncmp (argv[0], "d", 1) == 0) |
| 881 | type = OSPF_DEBUG_DB_DESC; |
| 882 | else if (strncmp (argv[0], "ls-r", 4) == 0) |
| 883 | type = OSPF_DEBUG_LS_REQ; |
| 884 | else if (strncmp (argv[0], "ls-u", 4) == 0) |
| 885 | type = OSPF_DEBUG_LS_UPD; |
| 886 | else if (strncmp (argv[0], "ls-a", 4) == 0) |
| 887 | type = OSPF_DEBUG_LS_ACK; |
| 888 | else if (strncmp (argv[0], "a", 1) == 0) |
| 889 | type = OSPF_DEBUG_ALL; |
| 890 | |
| 891 | /* Default, both send and recv. */ |
| 892 | if (argc == 1) |
| 893 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL ; |
| 894 | |
| 895 | /* send or recv. */ |
| 896 | if (argc == 2) |
| 897 | { |
| 898 | if (strncmp (argv[1], "s", 1) == 0) |
| 899 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_DETAIL; |
| 900 | else if (strncmp (argv[1], "r", 1) == 0) |
| 901 | flag = OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
| 902 | else if (strncmp (argv[1], "d", 1) == 0) |
Vystoropskyi, Sergii | b075e87 | 2015-08-16 13:25:36 +0000 | [diff] [blame] | 903 | flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | /* detail. */ |
| 907 | if (argc == 3) |
| 908 | if (strncmp (argv[2], "d", 1) == 0) |
| 909 | flag = OSPF_DEBUG_DETAIL; |
| 910 | |
| 911 | for (i = 0; i < 5; i++) |
| 912 | if (type & (0x01 << i)) |
| 913 | { |
| 914 | if (vty->node == CONFIG_NODE) |
| 915 | DEBUG_PACKET_OFF (i, flag); |
| 916 | else |
| 917 | TERM_DEBUG_PACKET_OFF (i, flag); |
| 918 | } |
| 919 | |
| 920 | #ifdef DEBUG |
jardin | 6638c1a | 2005-10-01 00:08:54 +0000 | [diff] [blame] | 921 | /* |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 922 | for (i = 0; i < 5; i++) |
ajs | 6092530 | 2004-12-08 17:45:02 +0000 | [diff] [blame] | 923 | zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]); |
jardin | 6638c1a | 2005-10-01 00:08:54 +0000 | [diff] [blame] | 924 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 925 | #endif /* DEBUG */ |
| 926 | |
| 927 | return CMD_SUCCESS; |
| 928 | } |
| 929 | |
| 930 | ALIAS (no_debug_ospf_packet, |
| 931 | no_debug_ospf_packet_send_recv_cmd, |
| 932 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv|detail)", |
| 933 | NO_STR |
| 934 | "Debugging functions\n" |
| 935 | "OSPF information\n" |
| 936 | "OSPF packets\n" |
| 937 | "OSPF Hello\n" |
| 938 | "OSPF Database Description\n" |
| 939 | "OSPF Link State Request\n" |
| 940 | "OSPF Link State Update\n" |
| 941 | "OSPF Link State Acknowledgment\n" |
| 942 | "OSPF all packets\n" |
| 943 | "Packet sent\n" |
| 944 | "Packet received\n" |
| 945 | "Detail Information\n") |
| 946 | |
| 947 | ALIAS (no_debug_ospf_packet, |
| 948 | no_debug_ospf_packet_send_recv_detail_cmd, |
| 949 | "no debug ospf packet (hello|dd|ls-request|ls-update|ls-ack|all) (send|recv) (detail|)", |
| 950 | NO_STR |
| 951 | "Debugging functions\n" |
| 952 | "OSPF information\n" |
| 953 | "OSPF packets\n" |
| 954 | "OSPF Hello\n" |
| 955 | "OSPF Database Description\n" |
| 956 | "OSPF Link State Request\n" |
| 957 | "OSPF Link State Update\n" |
| 958 | "OSPF Link State Acknowledgment\n" |
| 959 | "OSPF all packets\n" |
| 960 | "Packet sent\n" |
| 961 | "Packet received\n" |
| 962 | "Detail Information\n") |
| 963 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 964 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 965 | DEFUN (debug_ospf_ism, |
| 966 | debug_ospf_ism_cmd, |
| 967 | "debug ospf ism", |
| 968 | DEBUG_STR |
| 969 | OSPF_STR |
| 970 | "OSPF Interface State Machine\n") |
| 971 | { |
| 972 | if (vty->node == CONFIG_NODE) |
| 973 | { |
| 974 | if (argc == 0) |
| 975 | DEBUG_ON (ism, ISM); |
| 976 | else if (argc == 1) |
| 977 | { |
| 978 | if (strncmp (argv[0], "s", 1) == 0) |
| 979 | DEBUG_ON (ism, ISM_STATUS); |
| 980 | else if (strncmp (argv[0], "e", 1) == 0) |
| 981 | DEBUG_ON (ism, ISM_EVENTS); |
| 982 | else if (strncmp (argv[0], "t", 1) == 0) |
| 983 | DEBUG_ON (ism, ISM_TIMERS); |
| 984 | } |
| 985 | |
| 986 | return CMD_SUCCESS; |
| 987 | } |
| 988 | |
| 989 | /* ENABLE_NODE. */ |
| 990 | if (argc == 0) |
| 991 | TERM_DEBUG_ON (ism, ISM); |
| 992 | else if (argc == 1) |
| 993 | { |
| 994 | if (strncmp (argv[0], "s", 1) == 0) |
| 995 | TERM_DEBUG_ON (ism, ISM_STATUS); |
| 996 | else if (strncmp (argv[0], "e", 1) == 0) |
| 997 | TERM_DEBUG_ON (ism, ISM_EVENTS); |
| 998 | else if (strncmp (argv[0], "t", 1) == 0) |
| 999 | TERM_DEBUG_ON (ism, ISM_TIMERS); |
| 1000 | } |
| 1001 | |
| 1002 | return CMD_SUCCESS; |
| 1003 | } |
| 1004 | |
| 1005 | ALIAS (debug_ospf_ism, |
| 1006 | debug_ospf_ism_sub_cmd, |
| 1007 | "debug ospf ism (status|events|timers)", |
| 1008 | DEBUG_STR |
| 1009 | OSPF_STR |
| 1010 | "OSPF Interface State Machine\n" |
| 1011 | "ISM Status Information\n" |
| 1012 | "ISM Event Information\n" |
| 1013 | "ISM TImer Information\n") |
| 1014 | |
| 1015 | DEFUN (no_debug_ospf_ism, |
| 1016 | no_debug_ospf_ism_cmd, |
| 1017 | "no debug ospf ism", |
| 1018 | NO_STR |
| 1019 | DEBUG_STR |
| 1020 | OSPF_STR |
| 1021 | "OSPF Interface State Machine") |
| 1022 | { |
| 1023 | if (vty->node == CONFIG_NODE) |
| 1024 | { |
| 1025 | if (argc == 0) |
| 1026 | DEBUG_OFF (ism, ISM); |
| 1027 | else if (argc == 1) |
| 1028 | { |
| 1029 | if (strncmp (argv[0], "s", 1) == 0) |
| 1030 | DEBUG_OFF (ism, ISM_STATUS); |
| 1031 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1032 | DEBUG_OFF (ism, ISM_EVENTS); |
| 1033 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1034 | DEBUG_OFF (ism, ISM_TIMERS); |
| 1035 | } |
| 1036 | return CMD_SUCCESS; |
| 1037 | } |
| 1038 | |
| 1039 | /* ENABLE_NODE. */ |
| 1040 | if (argc == 0) |
| 1041 | TERM_DEBUG_OFF (ism, ISM); |
| 1042 | else if (argc == 1) |
| 1043 | { |
| 1044 | if (strncmp (argv[0], "s", 1) == 0) |
| 1045 | TERM_DEBUG_OFF (ism, ISM_STATUS); |
| 1046 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1047 | TERM_DEBUG_OFF (ism, ISM_EVENTS); |
| 1048 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1049 | TERM_DEBUG_OFF (ism, ISM_TIMERS); |
| 1050 | } |
| 1051 | |
| 1052 | return CMD_SUCCESS; |
| 1053 | } |
| 1054 | |
| 1055 | ALIAS (no_debug_ospf_ism, |
| 1056 | no_debug_ospf_ism_sub_cmd, |
| 1057 | "no debug ospf ism (status|events|timers)", |
| 1058 | NO_STR |
| 1059 | "Debugging functions\n" |
| 1060 | "OSPF information\n" |
| 1061 | "OSPF Interface State Machine\n" |
| 1062 | "ISM Status Information\n" |
| 1063 | "ISM Event Information\n" |
| 1064 | "ISM Timer Information\n") |
| 1065 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1066 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1067 | DEFUN (debug_ospf_nsm, |
| 1068 | debug_ospf_nsm_cmd, |
| 1069 | "debug ospf nsm", |
| 1070 | DEBUG_STR |
| 1071 | OSPF_STR |
| 1072 | "OSPF Neighbor State Machine\n") |
| 1073 | { |
| 1074 | if (vty->node == CONFIG_NODE) |
| 1075 | { |
| 1076 | if (argc == 0) |
| 1077 | DEBUG_ON (nsm, NSM); |
| 1078 | else if (argc == 1) |
| 1079 | { |
| 1080 | if (strncmp (argv[0], "s", 1) == 0) |
| 1081 | DEBUG_ON (nsm, NSM_STATUS); |
| 1082 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1083 | DEBUG_ON (nsm, NSM_EVENTS); |
| 1084 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1085 | DEBUG_ON (nsm, NSM_TIMERS); |
| 1086 | } |
| 1087 | |
| 1088 | return CMD_SUCCESS; |
| 1089 | } |
| 1090 | |
| 1091 | /* ENABLE_NODE. */ |
| 1092 | if (argc == 0) |
| 1093 | TERM_DEBUG_ON (nsm, NSM); |
| 1094 | else if (argc == 1) |
| 1095 | { |
| 1096 | if (strncmp (argv[0], "s", 1) == 0) |
| 1097 | TERM_DEBUG_ON (nsm, NSM_STATUS); |
| 1098 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1099 | TERM_DEBUG_ON (nsm, NSM_EVENTS); |
| 1100 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1101 | TERM_DEBUG_ON (nsm, NSM_TIMERS); |
| 1102 | } |
| 1103 | |
| 1104 | return CMD_SUCCESS; |
| 1105 | } |
| 1106 | |
| 1107 | ALIAS (debug_ospf_nsm, |
| 1108 | debug_ospf_nsm_sub_cmd, |
| 1109 | "debug ospf nsm (status|events|timers)", |
| 1110 | DEBUG_STR |
| 1111 | OSPF_STR |
| 1112 | "OSPF Neighbor State Machine\n" |
| 1113 | "NSM Status Information\n" |
| 1114 | "NSM Event Information\n" |
| 1115 | "NSM Timer Information\n") |
| 1116 | |
| 1117 | DEFUN (no_debug_ospf_nsm, |
| 1118 | no_debug_ospf_nsm_cmd, |
| 1119 | "no debug ospf nsm", |
| 1120 | NO_STR |
| 1121 | DEBUG_STR |
| 1122 | OSPF_STR |
| 1123 | "OSPF Neighbor State Machine") |
| 1124 | { |
| 1125 | if (vty->node == CONFIG_NODE) |
| 1126 | { |
| 1127 | if (argc == 0) |
| 1128 | DEBUG_OFF (nsm, NSM); |
| 1129 | else if (argc == 1) |
| 1130 | { |
| 1131 | if (strncmp (argv[0], "s", 1) == 0) |
| 1132 | DEBUG_OFF (nsm, NSM_STATUS); |
| 1133 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1134 | DEBUG_OFF (nsm, NSM_EVENTS); |
| 1135 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1136 | DEBUG_OFF (nsm, NSM_TIMERS); |
| 1137 | } |
| 1138 | |
| 1139 | return CMD_SUCCESS; |
| 1140 | } |
| 1141 | |
| 1142 | /* ENABLE_NODE. */ |
| 1143 | if (argc == 0) |
| 1144 | TERM_DEBUG_OFF (nsm, NSM); |
| 1145 | else if (argc == 1) |
| 1146 | { |
| 1147 | if (strncmp (argv[0], "s", 1) == 0) |
| 1148 | TERM_DEBUG_OFF (nsm, NSM_STATUS); |
| 1149 | else if (strncmp (argv[0], "e", 1) == 0) |
| 1150 | TERM_DEBUG_OFF (nsm, NSM_EVENTS); |
| 1151 | else if (strncmp (argv[0], "t", 1) == 0) |
| 1152 | TERM_DEBUG_OFF (nsm, NSM_TIMERS); |
| 1153 | } |
| 1154 | |
| 1155 | return CMD_SUCCESS; |
| 1156 | } |
| 1157 | |
| 1158 | ALIAS (no_debug_ospf_nsm, |
| 1159 | no_debug_ospf_nsm_sub_cmd, |
| 1160 | "no debug ospf nsm (status|events|timers)", |
| 1161 | NO_STR |
| 1162 | "Debugging functions\n" |
| 1163 | "OSPF information\n" |
| 1164 | "OSPF Interface State Machine\n" |
| 1165 | "NSM Status Information\n" |
| 1166 | "NSM Event Information\n" |
| 1167 | "NSM Timer Information\n") |
| 1168 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1169 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1170 | DEFUN (debug_ospf_lsa, |
| 1171 | debug_ospf_lsa_cmd, |
| 1172 | "debug ospf lsa", |
| 1173 | DEBUG_STR |
| 1174 | OSPF_STR |
| 1175 | "OSPF Link State Advertisement\n") |
| 1176 | { |
| 1177 | if (vty->node == CONFIG_NODE) |
| 1178 | { |
| 1179 | if (argc == 0) |
| 1180 | DEBUG_ON (lsa, LSA); |
| 1181 | else if (argc == 1) |
| 1182 | { |
| 1183 | if (strncmp (argv[0], "g", 1) == 0) |
| 1184 | DEBUG_ON (lsa, LSA_GENERATE); |
| 1185 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1186 | DEBUG_ON (lsa, LSA_FLOODING); |
| 1187 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1188 | DEBUG_ON (lsa, LSA_INSTALL); |
| 1189 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1190 | DEBUG_ON (lsa, LSA_REFRESH); |
| 1191 | } |
| 1192 | |
| 1193 | return CMD_SUCCESS; |
| 1194 | } |
| 1195 | |
| 1196 | /* ENABLE_NODE. */ |
| 1197 | if (argc == 0) |
| 1198 | TERM_DEBUG_ON (lsa, LSA); |
| 1199 | else if (argc == 1) |
| 1200 | { |
| 1201 | if (strncmp (argv[0], "g", 1) == 0) |
| 1202 | TERM_DEBUG_ON (lsa, LSA_GENERATE); |
| 1203 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1204 | TERM_DEBUG_ON (lsa, LSA_FLOODING); |
| 1205 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1206 | TERM_DEBUG_ON (lsa, LSA_INSTALL); |
| 1207 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1208 | TERM_DEBUG_ON (lsa, LSA_REFRESH); |
| 1209 | } |
| 1210 | |
| 1211 | return CMD_SUCCESS; |
| 1212 | } |
| 1213 | |
| 1214 | ALIAS (debug_ospf_lsa, |
| 1215 | debug_ospf_lsa_sub_cmd, |
| 1216 | "debug ospf lsa (generate|flooding|install|refresh)", |
| 1217 | DEBUG_STR |
| 1218 | OSPF_STR |
| 1219 | "OSPF Link State Advertisement\n" |
| 1220 | "LSA Generation\n" |
| 1221 | "LSA Flooding\n" |
| 1222 | "LSA Install/Delete\n" |
| 1223 | "LSA Refresh\n") |
| 1224 | |
| 1225 | DEFUN (no_debug_ospf_lsa, |
| 1226 | no_debug_ospf_lsa_cmd, |
| 1227 | "no debug ospf lsa", |
| 1228 | NO_STR |
| 1229 | DEBUG_STR |
| 1230 | OSPF_STR |
| 1231 | "OSPF Link State Advertisement\n") |
| 1232 | { |
| 1233 | if (vty->node == CONFIG_NODE) |
| 1234 | { |
| 1235 | if (argc == 0) |
| 1236 | DEBUG_OFF (lsa, LSA); |
| 1237 | else if (argc == 1) |
| 1238 | { |
| 1239 | if (strncmp (argv[0], "g", 1) == 0) |
| 1240 | DEBUG_OFF (lsa, LSA_GENERATE); |
| 1241 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1242 | DEBUG_OFF (lsa, LSA_FLOODING); |
| 1243 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1244 | DEBUG_OFF (lsa, LSA_INSTALL); |
| 1245 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1246 | DEBUG_OFF (lsa, LSA_REFRESH); |
| 1247 | } |
| 1248 | |
| 1249 | return CMD_SUCCESS; |
| 1250 | } |
| 1251 | |
| 1252 | /* ENABLE_NODE. */ |
| 1253 | if (argc == 0) |
| 1254 | TERM_DEBUG_OFF (lsa, LSA); |
| 1255 | else if (argc == 1) |
| 1256 | { |
| 1257 | if (strncmp (argv[0], "g", 1) == 0) |
| 1258 | TERM_DEBUG_OFF (lsa, LSA_GENERATE); |
| 1259 | else if (strncmp (argv[0], "f", 1) == 0) |
| 1260 | TERM_DEBUG_OFF (lsa, LSA_FLOODING); |
| 1261 | else if (strncmp (argv[0], "i", 1) == 0) |
| 1262 | TERM_DEBUG_OFF (lsa, LSA_INSTALL); |
| 1263 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1264 | TERM_DEBUG_OFF (lsa, LSA_REFRESH); |
| 1265 | } |
| 1266 | |
| 1267 | return CMD_SUCCESS; |
| 1268 | } |
| 1269 | |
| 1270 | ALIAS (no_debug_ospf_lsa, |
| 1271 | no_debug_ospf_lsa_sub_cmd, |
| 1272 | "no debug ospf lsa (generate|flooding|install|refresh)", |
| 1273 | NO_STR |
| 1274 | DEBUG_STR |
| 1275 | OSPF_STR |
| 1276 | "OSPF Link State Advertisement\n" |
| 1277 | "LSA Generation\n" |
| 1278 | "LSA Flooding\n" |
| 1279 | "LSA Install/Delete\n" |
| 1280 | "LSA Refres\n") |
| 1281 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1282 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1283 | DEFUN (debug_ospf_zebra, |
| 1284 | debug_ospf_zebra_cmd, |
| 1285 | "debug ospf zebra", |
| 1286 | DEBUG_STR |
| 1287 | OSPF_STR |
| 1288 | "OSPF Zebra information\n") |
| 1289 | { |
| 1290 | if (vty->node == CONFIG_NODE) |
| 1291 | { |
| 1292 | if (argc == 0) |
| 1293 | DEBUG_ON (zebra, ZEBRA); |
| 1294 | else if (argc == 1) |
| 1295 | { |
| 1296 | if (strncmp (argv[0], "i", 1) == 0) |
| 1297 | DEBUG_ON (zebra, ZEBRA_INTERFACE); |
| 1298 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1299 | DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); |
| 1300 | } |
| 1301 | |
| 1302 | return CMD_SUCCESS; |
| 1303 | } |
| 1304 | |
| 1305 | /* ENABLE_NODE. */ |
| 1306 | if (argc == 0) |
| 1307 | TERM_DEBUG_ON (zebra, ZEBRA); |
| 1308 | else if (argc == 1) |
| 1309 | { |
| 1310 | if (strncmp (argv[0], "i", 1) == 0) |
| 1311 | TERM_DEBUG_ON (zebra, ZEBRA_INTERFACE); |
| 1312 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1313 | TERM_DEBUG_ON (zebra, ZEBRA_REDISTRIBUTE); |
| 1314 | } |
| 1315 | |
| 1316 | return CMD_SUCCESS; |
| 1317 | } |
| 1318 | |
| 1319 | ALIAS (debug_ospf_zebra, |
| 1320 | debug_ospf_zebra_sub_cmd, |
| 1321 | "debug ospf zebra (interface|redistribute)", |
| 1322 | DEBUG_STR |
| 1323 | OSPF_STR |
| 1324 | "OSPF Zebra information\n" |
| 1325 | "Zebra interface\n" |
| 1326 | "Zebra redistribute\n") |
| 1327 | |
| 1328 | DEFUN (no_debug_ospf_zebra, |
| 1329 | no_debug_ospf_zebra_cmd, |
| 1330 | "no debug ospf zebra", |
| 1331 | NO_STR |
| 1332 | DEBUG_STR |
| 1333 | OSPF_STR |
| 1334 | "OSPF Zebra information\n") |
| 1335 | { |
| 1336 | if (vty->node == CONFIG_NODE) |
| 1337 | { |
| 1338 | if (argc == 0) |
| 1339 | DEBUG_OFF (zebra, ZEBRA); |
| 1340 | else if (argc == 1) |
| 1341 | { |
| 1342 | if (strncmp (argv[0], "i", 1) == 0) |
| 1343 | DEBUG_OFF (zebra, ZEBRA_INTERFACE); |
| 1344 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1345 | DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); |
| 1346 | } |
| 1347 | |
| 1348 | return CMD_SUCCESS; |
| 1349 | } |
| 1350 | |
| 1351 | /* ENABLE_NODE. */ |
| 1352 | if (argc == 0) |
| 1353 | TERM_DEBUG_OFF (zebra, ZEBRA); |
| 1354 | else if (argc == 1) |
| 1355 | { |
| 1356 | if (strncmp (argv[0], "i", 1) == 0) |
| 1357 | TERM_DEBUG_OFF (zebra, ZEBRA_INTERFACE); |
| 1358 | else if (strncmp (argv[0], "r", 1) == 0) |
| 1359 | TERM_DEBUG_OFF (zebra, ZEBRA_REDISTRIBUTE); |
| 1360 | } |
| 1361 | |
| 1362 | return CMD_SUCCESS; |
| 1363 | } |
| 1364 | |
| 1365 | ALIAS (no_debug_ospf_zebra, |
| 1366 | no_debug_ospf_zebra_sub_cmd, |
| 1367 | "no debug ospf zebra (interface|redistribute)", |
| 1368 | NO_STR |
| 1369 | DEBUG_STR |
| 1370 | OSPF_STR |
| 1371 | "OSPF Zebra information\n" |
| 1372 | "Zebra interface\n" |
| 1373 | "Zebra redistribute\n") |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1374 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1375 | DEFUN (debug_ospf_event, |
| 1376 | debug_ospf_event_cmd, |
| 1377 | "debug ospf event", |
| 1378 | DEBUG_STR |
| 1379 | OSPF_STR |
| 1380 | "OSPF event information\n") |
| 1381 | { |
| 1382 | if (vty->node == CONFIG_NODE) |
| 1383 | CONF_DEBUG_ON (event, EVENT); |
| 1384 | TERM_DEBUG_ON (event, EVENT); |
| 1385 | return CMD_SUCCESS; |
| 1386 | } |
| 1387 | |
| 1388 | DEFUN (no_debug_ospf_event, |
| 1389 | no_debug_ospf_event_cmd, |
| 1390 | "no debug ospf event", |
| 1391 | NO_STR |
| 1392 | DEBUG_STR |
| 1393 | OSPF_STR |
| 1394 | "OSPF event information\n") |
| 1395 | { |
| 1396 | if (vty->node == CONFIG_NODE) |
| 1397 | CONF_DEBUG_OFF (event, EVENT); |
| 1398 | TERM_DEBUG_OFF (event, EVENT); |
| 1399 | return CMD_SUCCESS; |
| 1400 | } |
| 1401 | |
| 1402 | DEFUN (debug_ospf_nssa, |
| 1403 | debug_ospf_nssa_cmd, |
| 1404 | "debug ospf nssa", |
| 1405 | DEBUG_STR |
| 1406 | OSPF_STR |
| 1407 | "OSPF nssa information\n") |
| 1408 | { |
| 1409 | if (vty->node == CONFIG_NODE) |
| 1410 | CONF_DEBUG_ON (nssa, NSSA); |
| 1411 | TERM_DEBUG_ON (nssa, NSSA); |
| 1412 | return CMD_SUCCESS; |
| 1413 | } |
| 1414 | |
| 1415 | DEFUN (no_debug_ospf_nssa, |
| 1416 | no_debug_ospf_nssa_cmd, |
| 1417 | "no debug ospf nssa", |
| 1418 | NO_STR |
| 1419 | DEBUG_STR |
| 1420 | OSPF_STR |
| 1421 | "OSPF nssa information\n") |
| 1422 | { |
| 1423 | if (vty->node == CONFIG_NODE) |
| 1424 | CONF_DEBUG_OFF (nssa, NSSA); |
| 1425 | TERM_DEBUG_OFF (nssa, NSSA); |
| 1426 | return CMD_SUCCESS; |
| 1427 | } |
| 1428 | |
David Lamparter | 6b0655a | 2014-06-04 06:53:35 +0200 | [diff] [blame] | 1429 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1430 | DEFUN (show_debugging_ospf, |
| 1431 | show_debugging_ospf_cmd, |
| 1432 | "show debugging ospf", |
| 1433 | SHOW_STR |
| 1434 | DEBUG_STR |
| 1435 | OSPF_STR) |
| 1436 | { |
| 1437 | int i; |
| 1438 | |
hasso | df43a13 | 2004-08-31 12:04:33 +0000 | [diff] [blame] | 1439 | vty_out (vty, "OSPF debugging status:%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1440 | |
ajs | aca72fd | 2005-03-31 15:18:21 +0000 | [diff] [blame] | 1441 | /* Show debug status for events. */ |
| 1442 | if (IS_DEBUG_OSPF(event,EVENT)) |
| 1443 | vty_out (vty, " OSPF event debugging is on%s", VTY_NEWLINE); |
| 1444 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1445 | /* Show debug status for ISM. */ |
| 1446 | if (IS_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) |
| 1447 | vty_out (vty, " OSPF ISM debugging is on%s", VTY_NEWLINE); |
| 1448 | else |
| 1449 | { |
| 1450 | if (IS_DEBUG_OSPF (ism, ISM_STATUS)) |
| 1451 | vty_out (vty, " OSPF ISM status debugging is on%s", VTY_NEWLINE); |
| 1452 | if (IS_DEBUG_OSPF (ism, ISM_EVENTS)) |
| 1453 | vty_out (vty, " OSPF ISM event debugging is on%s", VTY_NEWLINE); |
| 1454 | if (IS_DEBUG_OSPF (ism, ISM_TIMERS)) |
| 1455 | vty_out (vty, " OSPF ISM timer debugging is on%s", VTY_NEWLINE); |
| 1456 | } |
| 1457 | |
| 1458 | /* Show debug status for NSM. */ |
| 1459 | if (IS_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) |
| 1460 | vty_out (vty, " OSPF NSM debugging is on%s", VTY_NEWLINE); |
| 1461 | else |
| 1462 | { |
| 1463 | if (IS_DEBUG_OSPF (nsm, NSM_STATUS)) |
| 1464 | vty_out (vty, " OSPF NSM status debugging is on%s", VTY_NEWLINE); |
| 1465 | if (IS_DEBUG_OSPF (nsm, NSM_EVENTS)) |
| 1466 | vty_out (vty, " OSPF NSM event debugging is on%s", VTY_NEWLINE); |
| 1467 | if (IS_DEBUG_OSPF (nsm, NSM_TIMERS)) |
| 1468 | vty_out (vty, " OSPF NSM timer debugging is on%s", VTY_NEWLINE); |
| 1469 | } |
| 1470 | |
| 1471 | /* Show debug status for OSPF Packets. */ |
| 1472 | for (i = 0; i < 5; i++) |
| 1473 | if (IS_DEBUG_OSPF_PACKET (i, SEND) && IS_DEBUG_OSPF_PACKET (i, RECV)) |
| 1474 | { |
| 1475 | vty_out (vty, " OSPF packet %s%s debugging is on%s", |
Denis Ovsienko | 272ca1e | 2012-01-15 19:12:19 +0400 | [diff] [blame] | 1476 | LOOKUP (ospf_packet_type_str, i + 1), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1477 | IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "", |
| 1478 | VTY_NEWLINE); |
| 1479 | } |
| 1480 | else |
| 1481 | { |
| 1482 | if (IS_DEBUG_OSPF_PACKET (i, SEND)) |
| 1483 | vty_out (vty, " OSPF packet %s send%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 | if (IS_DEBUG_OSPF_PACKET (i, RECV)) |
| 1488 | vty_out (vty, " OSPF packet %s receive%s debugging is on%s", |
Denis Ovsienko | 272ca1e | 2012-01-15 19:12:19 +0400 | [diff] [blame] | 1489 | LOOKUP (ospf_packet_type_str, i + 1), |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1490 | IS_DEBUG_OSPF_PACKET (i, DETAIL) ? " detail" : "", |
| 1491 | VTY_NEWLINE); |
| 1492 | } |
| 1493 | |
| 1494 | /* Show debug status for OSPF LSAs. */ |
| 1495 | if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) |
| 1496 | vty_out (vty, " OSPF LSA debugging is on%s", VTY_NEWLINE); |
| 1497 | else |
| 1498 | { |
| 1499 | if (IS_DEBUG_OSPF (lsa, LSA_GENERATE)) |
| 1500 | vty_out (vty, " OSPF LSA generation debugging is on%s", VTY_NEWLINE); |
| 1501 | if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) |
| 1502 | vty_out (vty, " OSPF LSA flooding debugging is on%s", VTY_NEWLINE); |
| 1503 | if (IS_DEBUG_OSPF (lsa, LSA_INSTALL)) |
| 1504 | vty_out (vty, " OSPF LSA install debugging is on%s", VTY_NEWLINE); |
| 1505 | if (IS_DEBUG_OSPF (lsa, LSA_REFRESH)) |
| 1506 | vty_out (vty, " OSPF LSA refresh debugging is on%s", VTY_NEWLINE); |
| 1507 | } |
| 1508 | |
| 1509 | /* Show debug status for Zebra. */ |
| 1510 | if (IS_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) |
| 1511 | vty_out (vty, " OSPF Zebra debugging is on%s", VTY_NEWLINE); |
| 1512 | else |
| 1513 | { |
| 1514 | if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
| 1515 | vty_out (vty, " OSPF Zebra interface debugging is on%s", VTY_NEWLINE); |
| 1516 | if (IS_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
| 1517 | vty_out (vty, " OSPF Zebra redistribute debugging is on%s", VTY_NEWLINE); |
| 1518 | } |
ajs | aca72fd | 2005-03-31 15:18:21 +0000 | [diff] [blame] | 1519 | |
| 1520 | /* Show debug status for NSSA. */ |
paul | ead687e | 2003-04-07 17:12:12 +0000 | [diff] [blame] | 1521 | if (IS_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) |
| 1522 | vty_out (vty, " OSPF NSSA debugging is on%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1523 | |
| 1524 | return CMD_SUCCESS; |
| 1525 | } |
| 1526 | |
| 1527 | /* Debug node. */ |
Stephen Hemminger | 7fc626d | 2008-12-01 11:10:34 -0800 | [diff] [blame] | 1528 | static struct cmd_node debug_node = |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1529 | { |
| 1530 | DEBUG_NODE, |
hasso | 1d80628 | 2004-12-22 09:43:20 +0000 | [diff] [blame] | 1531 | "", |
| 1532 | 1 /* VTYSH */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1533 | }; |
| 1534 | |
paul | 4dadc29 | 2005-05-06 21:37:42 +0000 | [diff] [blame] | 1535 | static int |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1536 | config_write_debug (struct vty *vty) |
| 1537 | { |
| 1538 | int write = 0; |
| 1539 | int i, r; |
| 1540 | |
hasso | eb1ce60 | 2004-10-08 08:17:22 +0000 | [diff] [blame] | 1541 | const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"}; |
| 1542 | const char *detail_str[] = {"", " send", " recv", "", " detail", |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1543 | " send detail", " recv detail", " detail"}; |
| 1544 | |
| 1545 | /* debug ospf ism (status|events|timers). */ |
| 1546 | if (IS_CONF_DEBUG_OSPF (ism, ISM) == OSPF_DEBUG_ISM) |
| 1547 | vty_out (vty, "debug ospf ism%s", VTY_NEWLINE); |
| 1548 | else |
| 1549 | { |
| 1550 | if (IS_CONF_DEBUG_OSPF (ism, ISM_STATUS)) |
| 1551 | vty_out (vty, "debug ospf ism status%s", VTY_NEWLINE); |
| 1552 | if (IS_CONF_DEBUG_OSPF (ism, ISM_EVENTS)) |
| 1553 | vty_out (vty, "debug ospf ism event%s", VTY_NEWLINE); |
| 1554 | if (IS_CONF_DEBUG_OSPF (ism, ISM_TIMERS)) |
| 1555 | vty_out (vty, "debug ospf ism timer%s", VTY_NEWLINE); |
| 1556 | } |
| 1557 | |
| 1558 | /* debug ospf nsm (status|events|timers). */ |
| 1559 | if (IS_CONF_DEBUG_OSPF (nsm, NSM) == OSPF_DEBUG_NSM) |
| 1560 | vty_out (vty, "debug ospf nsm%s", VTY_NEWLINE); |
| 1561 | else |
| 1562 | { |
| 1563 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_STATUS)) |
Andrew J. Schorr | 0ffb709 | 2006-06-24 19:40:13 +0000 | [diff] [blame] | 1564 | vty_out (vty, "debug ospf nsm status%s", VTY_NEWLINE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1565 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_EVENTS)) |
| 1566 | vty_out (vty, "debug ospf nsm event%s", VTY_NEWLINE); |
| 1567 | if (IS_CONF_DEBUG_OSPF (nsm, NSM_TIMERS)) |
| 1568 | vty_out (vty, "debug ospf nsm timer%s", VTY_NEWLINE); |
| 1569 | } |
| 1570 | |
| 1571 | /* debug ospf lsa (generate|flooding|install|refresh). */ |
| 1572 | if (IS_CONF_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA) |
| 1573 | vty_out (vty, "debug ospf lsa%s", VTY_NEWLINE); |
| 1574 | else |
| 1575 | { |
| 1576 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_GENERATE)) |
| 1577 | vty_out (vty, "debug ospf lsa generate%s", VTY_NEWLINE); |
| 1578 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_FLOODING)) |
| 1579 | vty_out (vty, "debug ospf lsa flooding%s", VTY_NEWLINE); |
| 1580 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_INSTALL)) |
| 1581 | vty_out (vty, "debug ospf lsa install%s", VTY_NEWLINE); |
| 1582 | if (IS_CONF_DEBUG_OSPF (lsa, LSA_REFRESH)) |
| 1583 | vty_out (vty, "debug ospf lsa refresh%s", VTY_NEWLINE); |
| 1584 | |
| 1585 | write = 1; |
| 1586 | } |
| 1587 | |
| 1588 | /* debug ospf zebra (interface|redistribute). */ |
| 1589 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) |
| 1590 | vty_out (vty, "debug ospf zebra%s", VTY_NEWLINE); |
| 1591 | else |
| 1592 | { |
| 1593 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) |
| 1594 | vty_out (vty, "debug ospf zebra interface%s", VTY_NEWLINE); |
| 1595 | if (IS_CONF_DEBUG_OSPF (zebra, ZEBRA_REDISTRIBUTE)) |
| 1596 | vty_out (vty, "debug ospf zebra redistribute%s", VTY_NEWLINE); |
| 1597 | |
| 1598 | write = 1; |
| 1599 | } |
| 1600 | |
| 1601 | /* debug ospf event. */ |
| 1602 | if (IS_CONF_DEBUG_OSPF (event, EVENT) == OSPF_DEBUG_EVENT) |
| 1603 | { |
| 1604 | vty_out (vty, "debug ospf event%s", VTY_NEWLINE); |
| 1605 | write = 1; |
| 1606 | } |
| 1607 | |
| 1608 | /* debug ospf nssa. */ |
| 1609 | if (IS_CONF_DEBUG_OSPF (nssa, NSSA) == OSPF_DEBUG_NSSA) |
| 1610 | { |
| 1611 | vty_out (vty, "debug ospf nssa%s", VTY_NEWLINE); |
| 1612 | write = 1; |
| 1613 | } |
| 1614 | |
| 1615 | /* debug ospf packet all detail. */ |
| 1616 | r = OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL; |
| 1617 | for (i = 0; i < 5; i++) |
| 1618 | r &= conf_debug_ospf_packet[i] & (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL); |
| 1619 | if (r == (OSPF_DEBUG_SEND_RECV|OSPF_DEBUG_DETAIL)) |
| 1620 | { |
| 1621 | vty_out (vty, "debug ospf packet all detail%s", VTY_NEWLINE); |
| 1622 | return 1; |
| 1623 | } |
| 1624 | |
| 1625 | /* debug ospf packet all. */ |
| 1626 | r = OSPF_DEBUG_SEND_RECV; |
| 1627 | for (i = 0; i < 5; i++) |
| 1628 | r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV; |
| 1629 | if (r == OSPF_DEBUG_SEND_RECV) |
| 1630 | { |
| 1631 | vty_out (vty, "debug ospf packet all%s", VTY_NEWLINE); |
| 1632 | for (i = 0; i < 5; i++) |
| 1633 | if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL) |
| 1634 | vty_out (vty, "debug ospf packet %s detail%s", |
| 1635 | type_str[i], |
| 1636 | VTY_NEWLINE); |
| 1637 | return 1; |
| 1638 | } |
| 1639 | |
| 1640 | /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack) |
| 1641 | (send|recv) (detail). */ |
| 1642 | for (i = 0; i < 5; i++) |
| 1643 | { |
| 1644 | if (conf_debug_ospf_packet[i] == 0) |
| 1645 | continue; |
| 1646 | |
| 1647 | vty_out (vty, "debug ospf packet %s%s%s", |
| 1648 | type_str[i], detail_str[conf_debug_ospf_packet[i]], |
| 1649 | VTY_NEWLINE); |
| 1650 | write = 1; |
| 1651 | } |
| 1652 | |
| 1653 | return write; |
| 1654 | } |
| 1655 | |
| 1656 | /* Initialize debug commands. */ |
| 1657 | void |
| 1658 | debug_init () |
| 1659 | { |
| 1660 | install_node (&debug_node, config_write_debug); |
| 1661 | |
| 1662 | install_element (ENABLE_NODE, &show_debugging_ospf_cmd); |
| 1663 | install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_detail_cmd); |
| 1664 | install_element (ENABLE_NODE, &debug_ospf_packet_send_recv_cmd); |
| 1665 | install_element (ENABLE_NODE, &debug_ospf_packet_all_cmd); |
| 1666 | install_element (ENABLE_NODE, &debug_ospf_ism_sub_cmd); |
| 1667 | install_element (ENABLE_NODE, &debug_ospf_ism_cmd); |
| 1668 | install_element (ENABLE_NODE, &debug_ospf_nsm_sub_cmd); |
| 1669 | install_element (ENABLE_NODE, &debug_ospf_nsm_cmd); |
| 1670 | install_element (ENABLE_NODE, &debug_ospf_lsa_sub_cmd); |
| 1671 | install_element (ENABLE_NODE, &debug_ospf_lsa_cmd); |
| 1672 | install_element (ENABLE_NODE, &debug_ospf_zebra_sub_cmd); |
| 1673 | install_element (ENABLE_NODE, &debug_ospf_zebra_cmd); |
| 1674 | install_element (ENABLE_NODE, &debug_ospf_event_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1675 | install_element (ENABLE_NODE, &debug_ospf_nssa_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1676 | install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); |
| 1677 | install_element (ENABLE_NODE, &no_debug_ospf_packet_send_recv_cmd); |
| 1678 | install_element (ENABLE_NODE, &no_debug_ospf_packet_all_cmd); |
| 1679 | install_element (ENABLE_NODE, &no_debug_ospf_ism_sub_cmd); |
| 1680 | install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd); |
| 1681 | install_element (ENABLE_NODE, &no_debug_ospf_nsm_sub_cmd); |
| 1682 | install_element (ENABLE_NODE, &no_debug_ospf_nsm_cmd); |
| 1683 | install_element (ENABLE_NODE, &no_debug_ospf_lsa_sub_cmd); |
| 1684 | install_element (ENABLE_NODE, &no_debug_ospf_lsa_cmd); |
| 1685 | install_element (ENABLE_NODE, &no_debug_ospf_zebra_sub_cmd); |
| 1686 | install_element (ENABLE_NODE, &no_debug_ospf_zebra_cmd); |
| 1687 | install_element (ENABLE_NODE, &no_debug_ospf_event_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1688 | install_element (ENABLE_NODE, &no_debug_ospf_nssa_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1689 | |
| 1690 | install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_detail_cmd); |
| 1691 | install_element (CONFIG_NODE, &debug_ospf_packet_send_recv_cmd); |
| 1692 | install_element (CONFIG_NODE, &debug_ospf_packet_all_cmd); |
| 1693 | install_element (CONFIG_NODE, &debug_ospf_ism_sub_cmd); |
| 1694 | install_element (CONFIG_NODE, &debug_ospf_ism_cmd); |
| 1695 | install_element (CONFIG_NODE, &debug_ospf_nsm_sub_cmd); |
| 1696 | install_element (CONFIG_NODE, &debug_ospf_nsm_cmd); |
| 1697 | install_element (CONFIG_NODE, &debug_ospf_lsa_sub_cmd); |
| 1698 | install_element (CONFIG_NODE, &debug_ospf_lsa_cmd); |
| 1699 | install_element (CONFIG_NODE, &debug_ospf_zebra_sub_cmd); |
| 1700 | install_element (CONFIG_NODE, &debug_ospf_zebra_cmd); |
| 1701 | install_element (CONFIG_NODE, &debug_ospf_event_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1702 | install_element (CONFIG_NODE, &debug_ospf_nssa_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1703 | install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_detail_cmd); |
| 1704 | install_element (CONFIG_NODE, &no_debug_ospf_packet_send_recv_cmd); |
| 1705 | install_element (CONFIG_NODE, &no_debug_ospf_packet_all_cmd); |
| 1706 | install_element (CONFIG_NODE, &no_debug_ospf_ism_sub_cmd); |
| 1707 | install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd); |
| 1708 | install_element (CONFIG_NODE, &no_debug_ospf_nsm_sub_cmd); |
| 1709 | install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd); |
| 1710 | install_element (CONFIG_NODE, &no_debug_ospf_lsa_sub_cmd); |
| 1711 | install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd); |
| 1712 | install_element (CONFIG_NODE, &no_debug_ospf_zebra_sub_cmd); |
| 1713 | install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd); |
| 1714 | install_element (CONFIG_NODE, &no_debug_ospf_event_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1715 | install_element (CONFIG_NODE, &no_debug_ospf_nssa_cmd); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1716 | } |