]>
Commit | Line | Data |
---|---|---|
718e3744 | 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 | * | |
896014f4 DL |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; see the file COPYING; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
718e3744 | 20 | */ |
21 | ||
22 | #include <zebra.h> | |
23 | ||
e4505a2e | 24 | #include "lib/bfd.h" |
cbf3e3eb | 25 | #include "monotime.h" |
718e3744 | 26 | #include "linklist.h" |
27 | #include "thread.h" | |
28 | #include "prefix.h" | |
29 | #include "command.h" | |
30 | #include "stream.h" | |
31 | #include "log.h" | |
aa20c6f1 | 32 | #include "sockopt.h" |
718e3744 | 33 | |
34 | #include "ospfd/ospfd.h" | |
35 | #include "ospfd/ospf_interface.h" | |
36 | #include "ospfd/ospf_ism.h" | |
37 | #include "ospfd/ospf_asbr.h" | |
38 | #include "ospfd/ospf_lsa.h" | |
39 | #include "ospfd/ospf_lsdb.h" | |
40 | #include "ospfd/ospf_neighbor.h" | |
41 | #include "ospfd/ospf_nsm.h" | |
42 | #include "ospfd/ospf_dump.h" | |
43 | #include "ospfd/ospf_packet.h" | |
44 | #include "ospfd/ospf_network.h" | |
caa1cd9e | 45 | #ifndef VTYSH_EXTRACT_PL |
46 | #include "ospfd/ospf_dump_clippy.c" | |
47 | #endif | |
718e3744 | 48 | |
718e3744 | 49 | /* Configuration debug option variables. */ |
50 | unsigned long conf_debug_ospf_packet[5] = {0, 0, 0, 0, 0}; | |
51 | unsigned long conf_debug_ospf_event = 0; | |
52 | unsigned long conf_debug_ospf_ism = 0; | |
53 | unsigned long conf_debug_ospf_nsm = 0; | |
54 | unsigned long conf_debug_ospf_lsa = 0; | |
55 | unsigned long conf_debug_ospf_zebra = 0; | |
56 | unsigned long conf_debug_ospf_nssa = 0; | |
16f1b9ee | 57 | unsigned long conf_debug_ospf_te = 0; |
cf9b9f77 OD |
58 | unsigned long conf_debug_ospf_ext = 0; |
59 | unsigned long conf_debug_ospf_sr = 0; | |
a4553b5b | 60 | unsigned long conf_debug_ospf_ti_lfa = 0; |
1febb13d | 61 | unsigned long conf_debug_ospf_defaultinfo = 0; |
132a782e | 62 | unsigned long conf_debug_ospf_ldp_sync = 0; |
06bc3110 | 63 | unsigned long conf_debug_ospf_gr = 0; |
b5b3078b | 64 | unsigned long conf_debug_ospf_bfd; |
718e3744 | 65 | |
66 | /* Enable debug option variables -- valid only session. */ | |
67 | unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0}; | |
1febb13d | 68 | unsigned long term_debug_ospf_event; |
718e3744 | 69 | unsigned long term_debug_ospf_ism = 0; |
70 | unsigned long term_debug_ospf_nsm = 0; | |
71 | unsigned long term_debug_ospf_lsa = 0; | |
72 | unsigned long term_debug_ospf_zebra = 0; | |
73 | unsigned long term_debug_ospf_nssa = 0; | |
16f1b9ee | 74 | unsigned long term_debug_ospf_te = 0; |
cf9b9f77 OD |
75 | unsigned long term_debug_ospf_ext = 0; |
76 | unsigned long term_debug_ospf_sr = 0; | |
a4553b5b | 77 | unsigned long term_debug_ospf_ti_lfa = 0; |
1febb13d | 78 | unsigned long term_debug_ospf_defaultinfo; |
132a782e | 79 | unsigned long term_debug_ospf_ldp_sync; |
06bc3110 | 80 | unsigned long term_debug_ospf_gr = 0; |
b5b3078b | 81 | unsigned long term_debug_ospf_bfd; |
f52d13cb | 82 | |
d7c0a89a | 83 | const char *ospf_redist_string(unsigned int route_type) |
f52d13cb | 84 | { |
d62a17ae | 85 | return (route_type == ZEBRA_ROUTE_MAX) ? "Default" |
86 | : zebra_route_string(route_type); | |
f52d13cb | 87 | } |
88 | ||
718e3744 | 89 | #define OSPF_AREA_STRING_MAXLEN 16 |
d62a17ae | 90 | const char *ospf_area_name_string(struct ospf_area *area) |
718e3744 | 91 | { |
d62a17ae | 92 | static char buf[OSPF_AREA_STRING_MAXLEN] = ""; |
d7c0a89a | 93 | uint32_t area_id; |
718e3744 | 94 | |
d62a17ae | 95 | if (!area) |
96 | return "-"; | |
718e3744 | 97 | |
d62a17ae | 98 | area_id = ntohl(area->area_id.s_addr); |
772270f3 QY |
99 | snprintf(buf, sizeof(buf), "%d.%d.%d.%d", (area_id >> 24) & 0xff, |
100 | (area_id >> 16) & 0xff, (area_id >> 8) & 0xff, area_id & 0xff); | |
d62a17ae | 101 | return buf; |
718e3744 | 102 | } |
103 | ||
104 | #define OSPF_AREA_DESC_STRING_MAXLEN 23 | |
d62a17ae | 105 | const char *ospf_area_desc_string(struct ospf_area *area) |
718e3744 | 106 | { |
d62a17ae | 107 | static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = ""; |
d7c0a89a | 108 | uint8_t type; |
d62a17ae | 109 | |
110 | if (!area) | |
111 | return "(incomplete)"; | |
112 | ||
113 | type = area->external_routing; | |
114 | switch (type) { | |
115 | case OSPF_AREA_NSSA: | |
772270f3 | 116 | snprintf(buf, sizeof(buf), "%s [NSSA]", |
d62a17ae | 117 | ospf_area_name_string(area)); |
118 | break; | |
119 | case OSPF_AREA_STUB: | |
772270f3 | 120 | snprintf(buf, sizeof(buf), "%s [Stub]", |
d62a17ae | 121 | ospf_area_name_string(area)); |
122 | break; | |
123 | default: | |
124 | return ospf_area_name_string(area); | |
125 | } | |
126 | ||
127 | return buf; | |
718e3744 | 128 | } |
129 | ||
130 | #define OSPF_IF_STRING_MAXLEN 40 | |
d62a17ae | 131 | const char *ospf_if_name_string(struct ospf_interface *oi) |
718e3744 | 132 | { |
d62a17ae | 133 | static char buf[OSPF_IF_STRING_MAXLEN] = ""; |
d7c0a89a | 134 | uint32_t ifaddr; |
718e3744 | 135 | |
d62a17ae | 136 | if (!oi || !oi->address) |
137 | return "inactive"; | |
718e3744 | 138 | |
d62a17ae | 139 | if (oi->type == OSPF_IFTYPE_VIRTUALLINK) |
140 | return oi->ifp->name; | |
718e3744 | 141 | |
d62a17ae | 142 | ifaddr = ntohl(oi->address->u.prefix4.s_addr); |
772270f3 | 143 | snprintf(buf, sizeof(buf), "%s:%d.%d.%d.%d", oi->ifp->name, |
d62a17ae | 144 | (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff, |
145 | (ifaddr >> 8) & 0xff, ifaddr & 0xff); | |
146 | return buf; | |
718e3744 | 147 | } |
148 | ||
6b0655a2 | 149 | |
d62a17ae | 150 | void ospf_nbr_state_message(struct ospf_neighbor *nbr, char *buf, size_t size) |
718e3744 | 151 | { |
d62a17ae | 152 | int state; |
153 | struct ospf_interface *oi = nbr->oi; | |
718e3744 | 154 | |
d62a17ae | 155 | if (IPV4_ADDR_SAME(&DR(oi), &nbr->address.u.prefix4)) |
156 | state = ISM_DR; | |
157 | else if (IPV4_ADDR_SAME(&BDR(oi), &nbr->address.u.prefix4)) | |
158 | state = ISM_Backup; | |
159 | else | |
160 | state = ISM_DROther; | |
718e3744 | 161 | |
d62a17ae | 162 | snprintf(buf, size, "%s/%s", |
163 | lookup_msg(ospf_nsm_state_msg, nbr->state, NULL), | |
164 | lookup_msg(ospf_ism_state_msg, state, NULL)); | |
718e3744 | 165 | } |
166 | ||
d62a17ae | 167 | const char *ospf_timeval_dump(struct timeval *t, char *buf, size_t size) |
718e3744 | 168 | { |
d62a17ae | 169 | /* Making formatted timer strings. */ |
d24f6e2a | 170 | #define MINUTE_IN_SECONDS 60 |
171 | #define HOUR_IN_SECONDS (60*MINUTE_IN_SECONDS) | |
7de06eab | 172 | |
6e3e2c6d | 173 | unsigned long w, d, h, m, ms, us; |
d62a17ae | 174 | |
175 | if (!t) | |
176 | return "inactive"; | |
177 | ||
6e3e2c6d | 178 | w = d = h = m = ms = 0; |
d62a17ae | 179 | memset(buf, 0, size); |
180 | ||
181 | us = t->tv_usec; | |
182 | if (us >= 1000) { | |
183 | ms = us / 1000; | |
184 | us %= 1000; | |
f38b7f6d | 185 | (void)us; /* unused */ |
d62a17ae | 186 | } |
187 | ||
188 | if (ms >= 1000) { | |
189 | t->tv_sec += ms / 1000; | |
190 | ms %= 1000; | |
191 | } | |
192 | ||
7de06eab MS |
193 | if (t->tv_sec > ONE_WEEK_SECOND) { |
194 | w = t->tv_sec / ONE_WEEK_SECOND; | |
195 | t->tv_sec -= w * ONE_WEEK_SECOND; | |
d62a17ae | 196 | } |
197 | ||
7de06eab MS |
198 | if (t->tv_sec > ONE_DAY_SECOND) { |
199 | d = t->tv_sec / ONE_DAY_SECOND; | |
200 | t->tv_sec -= d * ONE_DAY_SECOND; | |
d62a17ae | 201 | } |
202 | ||
203 | if (t->tv_sec >= HOUR_IN_SECONDS) { | |
204 | h = t->tv_sec / HOUR_IN_SECONDS; | |
205 | t->tv_sec -= h * HOUR_IN_SECONDS; | |
206 | } | |
207 | ||
208 | if (t->tv_sec >= MINUTE_IN_SECONDS) { | |
209 | m = t->tv_sec / MINUTE_IN_SECONDS; | |
210 | t->tv_sec -= m * MINUTE_IN_SECONDS; | |
211 | } | |
212 | ||
213 | if (w > 99) | |
2ec42b85 | 214 | snprintf(buf, size, "%luw%1lud", w, d); |
d62a17ae | 215 | else if (w) |
2ec42b85 | 216 | snprintf(buf, size, "%luw%1lud%02luh", w, d, h); |
d62a17ae | 217 | else if (d) |
2ec42b85 | 218 | snprintf(buf, size, "%1lud%02luh%02lum", d, h, m); |
d62a17ae | 219 | else if (h) |
2ec42b85 | 220 | snprintf(buf, size, "%luh%02lum%02lds", h, m, (long)t->tv_sec); |
d62a17ae | 221 | else if (m) |
2ec42b85 | 222 | snprintf(buf, size, "%lum%02lds", m, (long)t->tv_sec); |
7de06eab | 223 | else if (t->tv_sec > 0 || ms > 0) |
2ec42b85 | 224 | snprintf(buf, size, "%ld.%03lus", (long)t->tv_sec, ms); |
d62a17ae | 225 | else |
226 | snprintf(buf, size, "%ld usecs", (long)t->tv_usec); | |
227 | ||
228 | return buf; | |
718e3744 | 229 | } |
230 | ||
d62a17ae | 231 | const char *ospf_timer_dump(struct thread *t, char *buf, size_t size) |
d24f6e2a | 232 | { |
d62a17ae | 233 | struct timeval result; |
234 | if (!t) | |
235 | return "inactive"; | |
cbf3e3eb | 236 | |
d62a17ae | 237 | monotime_until(&t->u.sands, &result); |
238 | return ospf_timeval_dump(&result, buf, size); | |
d24f6e2a | 239 | } |
240 | ||
d7c0a89a | 241 | static void ospf_packet_hello_dump(struct stream *s, uint16_t length) |
718e3744 | 242 | { |
d62a17ae | 243 | struct ospf_hello *hello; |
8db278b5 | 244 | int i, len; |
d62a17ae | 245 | |
2d34fb80 | 246 | hello = (struct ospf_hello *)stream_pnt(s); |
d62a17ae | 247 | |
248 | zlog_debug("Hello"); | |
96b663a3 | 249 | zlog_debug(" NetworkMask %pI4", &hello->network_mask); |
d62a17ae | 250 | zlog_debug(" HelloInterval %d", ntohs(hello->hello_interval)); |
251 | zlog_debug(" Options %d (%s)", hello->options, | |
252 | ospf_options_dump(hello->options)); | |
253 | zlog_debug(" RtrPriority %d", hello->priority); | |
254 | zlog_debug(" RtrDeadInterval %ld", | |
d7c0a89a | 255 | (unsigned long)ntohl(hello->dead_interval)); |
96b663a3 MS |
256 | zlog_debug(" DRouter %pI4", &hello->d_router); |
257 | zlog_debug(" BDRouter %pI4", &hello->bd_router); | |
d62a17ae | 258 | |
8db278b5 OD |
259 | len = length - OSPF_HEADER_SIZE - OSPF_HELLO_MIN_SIZE; |
260 | zlog_debug(" # Neighbors %d", len / 4); | |
261 | for (i = 0; len > 0; i++, len -= sizeof(struct in_addr)) | |
96b663a3 | 262 | zlog_debug(" Neighbor %pI4", &hello->neighbors[i]); |
718e3744 | 263 | } |
264 | ||
d7c0a89a | 265 | static char *ospf_dd_flags_dump(uint8_t flags, char *buf, size_t size) |
718e3744 | 266 | { |
d62a17ae | 267 | snprintf(buf, size, "%s|%s|%s", (flags & OSPF_DD_FLAG_I) ? "I" : "-", |
268 | (flags & OSPF_DD_FLAG_M) ? "M" : "-", | |
269 | (flags & OSPF_DD_FLAG_MS) ? "MS" : "-"); | |
718e3744 | 270 | |
d62a17ae | 271 | return buf; |
718e3744 | 272 | } |
273 | ||
d7c0a89a | 274 | static char *ospf_router_lsa_flags_dump(uint8_t flags, char *buf, size_t size) |
718e3744 | 275 | { |
d62a17ae | 276 | snprintf(buf, size, "%s|%s|%s", |
277 | (flags & ROUTER_LSA_VIRTUAL) ? "V" : "-", | |
278 | (flags & ROUTER_LSA_EXTERNAL) ? "E" : "-", | |
279 | (flags & ROUTER_LSA_BORDER) ? "B" : "-"); | |
718e3744 | 280 | |
d62a17ae | 281 | return buf; |
718e3744 | 282 | } |
283 | ||
d7c0a89a | 284 | static void ospf_router_lsa_dump(struct stream *s, uint16_t length) |
718e3744 | 285 | { |
d62a17ae | 286 | char buf[BUFSIZ]; |
287 | struct router_lsa *rl; | |
8db278b5 OD |
288 | struct router_link *rlnk; |
289 | int i, len, sum; | |
d62a17ae | 290 | |
2d34fb80 | 291 | rl = (struct router_lsa *)stream_pnt(s); |
d62a17ae | 292 | |
293 | zlog_debug(" Router-LSA"); | |
294 | zlog_debug(" flags %s", | |
295 | ospf_router_lsa_flags_dump(rl->flags, buf, BUFSIZ)); | |
296 | zlog_debug(" # links %d", ntohs(rl->links)); | |
297 | ||
8db278b5 OD |
298 | len = length - OSPF_LSA_HEADER_SIZE - 4; |
299 | rlnk = &rl->link[0]; | |
300 | sum = 0; | |
301 | for (i = 0; sum < len && rlnk; sum += 12, rlnk = &rl->link[++i]) { | |
302 | zlog_debug(" Link ID %pI4", &rlnk->link_id); | |
303 | zlog_debug(" Link Data %pI4", &rlnk->link_data); | |
304 | zlog_debug(" Type %d", (uint8_t)rlnk->type); | |
305 | zlog_debug(" TOS %d", (uint8_t)rlnk->tos); | |
306 | zlog_debug(" metric %d", ntohs(rlnk->metric)); | |
d62a17ae | 307 | } |
718e3744 | 308 | } |
309 | ||
d7c0a89a | 310 | static void ospf_network_lsa_dump(struct stream *s, uint16_t length) |
718e3744 | 311 | { |
d62a17ae | 312 | struct network_lsa *nl; |
313 | int i, cnt; | |
314 | ||
8db278b5 OD |
315 | zlog_debug(" Network-LSA"); |
316 | ||
2d34fb80 | 317 | nl = (struct network_lsa *)stream_pnt(s); |
8db278b5 | 318 | cnt = (length - (OSPF_LSA_HEADER_SIZE + 4)) / 4; |
d62a17ae | 319 | |
d62a17ae | 320 | /* |
321 | zlog_debug ("LSA total size %d", ntohs (nl->header.length)); | |
322 | zlog_debug ("Network-LSA size %d", | |
323 | ntohs (nl->header.length) - OSPF_LSA_HEADER_SIZE); | |
324 | */ | |
96b663a3 | 325 | zlog_debug(" Network Mask %pI4", &nl->mask); |
d62a17ae | 326 | zlog_debug(" # Attached Routers %d", cnt); |
327 | for (i = 0; i < cnt; i++) | |
96b663a3 MS |
328 | zlog_debug(" Attached Router %pI4", |
329 | &nl->routers[i]); | |
718e3744 | 330 | } |
331 | ||
d7c0a89a | 332 | static void ospf_summary_lsa_dump(struct stream *s, uint16_t length) |
718e3744 | 333 | { |
d62a17ae | 334 | struct summary_lsa *sl; |
718e3744 | 335 | |
2d34fb80 | 336 | sl = (struct summary_lsa *)stream_pnt(s); |
718e3744 | 337 | |
d62a17ae | 338 | zlog_debug(" Summary-LSA"); |
96b663a3 | 339 | zlog_debug(" Network Mask %pI4", &sl->mask); |
8db278b5 | 340 | zlog_debug(" TOS=%d metric %d", sl->tos, GET_METRIC(sl->metric)); |
718e3744 | 341 | } |
342 | ||
d7c0a89a | 343 | static void ospf_as_external_lsa_dump(struct stream *s, uint16_t length) |
718e3744 | 344 | { |
d62a17ae | 345 | struct as_external_lsa *al; |
8db278b5 OD |
346 | struct as_route *asr; |
347 | int size, sum; | |
d62a17ae | 348 | int i; |
349 | ||
2d34fb80 | 350 | al = (struct as_external_lsa *)stream_pnt(s); |
d62a17ae | 351 | zlog_debug(" %s", ospf_lsa_type_msg[al->header.type].str); |
96b663a3 | 352 | zlog_debug(" Network Mask %pI4", &al->mask); |
d62a17ae | 353 | |
8db278b5 OD |
354 | size = length - OSPF_LSA_HEADER_SIZE - 4; |
355 | asr = &al->e[0]; | |
356 | sum = 0; | |
357 | for (i = 0; sum < size && asr; sum += 12, asr = &al->e[++i]) { | |
d62a17ae | 358 | zlog_debug(" bit %s TOS=%d metric %d", |
8db278b5 OD |
359 | IS_EXTERNAL_METRIC(asr->tos) ? "E" : "-", |
360 | asr->tos & 0x7f, GET_METRIC(asr->metric)); | |
361 | zlog_debug(" Forwarding address %pI4", &asr->fwd_addr); | |
d62a17ae | 362 | zlog_debug(" External Route Tag %" ROUTE_TAG_PRI, |
8db278b5 | 363 | asr->route_tag); |
d62a17ae | 364 | } |
718e3744 | 365 | } |
366 | ||
d7c0a89a | 367 | static void ospf_lsa_header_list_dump(struct stream *s, uint16_t length) |
718e3744 | 368 | { |
d62a17ae | 369 | struct lsa_header *lsa; |
8db278b5 | 370 | int len; |
718e3744 | 371 | |
d62a17ae | 372 | zlog_debug(" # LSA Headers %d", length / OSPF_LSA_HEADER_SIZE); |
718e3744 | 373 | |
d62a17ae | 374 | /* LSA Headers. */ |
8db278b5 OD |
375 | len = length; |
376 | while (len > 0) { | |
2d34fb80 | 377 | lsa = (struct lsa_header *)stream_pnt(s); |
d62a17ae | 378 | ospf_lsa_header_dump(lsa); |
718e3744 | 379 | |
d62a17ae | 380 | stream_forward_getp(s, OSPF_LSA_HEADER_SIZE); |
8db278b5 | 381 | len -= OSPF_LSA_HEADER_SIZE; |
d62a17ae | 382 | } |
718e3744 | 383 | } |
384 | ||
d7c0a89a | 385 | static void ospf_packet_db_desc_dump(struct stream *s, uint16_t length) |
718e3744 | 386 | { |
d62a17ae | 387 | struct ospf_db_desc *dd; |
388 | char dd_flags[8]; | |
718e3744 | 389 | |
d7c0a89a | 390 | uint32_t gp; |
718e3744 | 391 | |
d62a17ae | 392 | gp = stream_get_getp(s); |
2d34fb80 | 393 | dd = (struct ospf_db_desc *)stream_pnt(s); |
718e3744 | 394 | |
d62a17ae | 395 | zlog_debug("Database Description"); |
396 | zlog_debug(" Interface MTU %d", ntohs(dd->mtu)); | |
397 | zlog_debug(" Options %d (%s)", dd->options, | |
398 | ospf_options_dump(dd->options)); | |
399 | zlog_debug(" Flags %d (%s)", dd->flags, | |
0d6f7fd6 | 400 | ospf_dd_flags_dump(dd->flags, dd_flags, sizeof(dd_flags))); |
d7c0a89a QY |
401 | zlog_debug(" Sequence Number 0x%08lx", |
402 | (unsigned long)ntohl(dd->dd_seqnum)); | |
718e3744 | 403 | |
d62a17ae | 404 | length -= OSPF_HEADER_SIZE + OSPF_DB_DESC_MIN_SIZE; |
718e3744 | 405 | |
d62a17ae | 406 | stream_forward_getp(s, OSPF_DB_DESC_MIN_SIZE); |
718e3744 | 407 | |
d62a17ae | 408 | ospf_lsa_header_list_dump(s, length); |
718e3744 | 409 | |
d62a17ae | 410 | stream_set_getp(s, gp); |
718e3744 | 411 | } |
412 | ||
d7c0a89a | 413 | static void ospf_packet_ls_req_dump(struct stream *s, uint16_t length) |
718e3744 | 414 | { |
d7c0a89a QY |
415 | uint32_t sp; |
416 | uint32_t ls_type; | |
d62a17ae | 417 | struct in_addr ls_id; |
418 | struct in_addr adv_router; | |
8db278b5 | 419 | int sum; |
718e3744 | 420 | |
d62a17ae | 421 | sp = stream_get_getp(s); |
718e3744 | 422 | |
d62a17ae | 423 | length -= OSPF_HEADER_SIZE; |
718e3744 | 424 | |
d62a17ae | 425 | zlog_debug("Link State Request"); |
426 | zlog_debug(" # Requests %d", length / 12); | |
718e3744 | 427 | |
8db278b5 OD |
428 | sum = 0; |
429 | for (; sum < length; sum += 12) { | |
d62a17ae | 430 | ls_type = stream_getl(s); |
431 | ls_id.s_addr = stream_get_ipv4(s); | |
432 | adv_router.s_addr = stream_get_ipv4(s); | |
718e3744 | 433 | |
d62a17ae | 434 | zlog_debug(" LS type %d", ls_type); |
96b663a3 MS |
435 | zlog_debug(" Link State ID %pI4", &ls_id); |
436 | zlog_debug(" Advertising Router %pI4", &adv_router); | |
d62a17ae | 437 | } |
718e3744 | 438 | |
d62a17ae | 439 | stream_set_getp(s, sp); |
718e3744 | 440 | } |
441 | ||
d7c0a89a | 442 | static void ospf_packet_ls_upd_dump(struct stream *s, uint16_t length) |
718e3744 | 443 | { |
d7c0a89a | 444 | uint32_t sp; |
d62a17ae | 445 | struct lsa_header *lsa; |
8db278b5 | 446 | int lsa_len, len; |
d7c0a89a | 447 | uint32_t count; |
d62a17ae | 448 | |
8db278b5 | 449 | len = length - OSPF_HEADER_SIZE; |
d62a17ae | 450 | |
451 | sp = stream_get_getp(s); | |
452 | ||
453 | count = stream_getl(s); | |
8db278b5 | 454 | len -= 4; |
d62a17ae | 455 | |
456 | zlog_debug("Link State Update"); | |
457 | zlog_debug(" # LSAs %d", count); | |
458 | ||
8db278b5 OD |
459 | while (len > 0 && count > 0) { |
460 | if ((uint16_t)len < OSPF_LSA_HEADER_SIZE || len % 4 != 0) { | |
d62a17ae | 461 | zlog_debug(" Remaining %d bytes; Incorrect length.", |
8db278b5 | 462 | len); |
d62a17ae | 463 | break; |
464 | } | |
465 | ||
2d34fb80 | 466 | lsa = (struct lsa_header *)stream_pnt(s); |
d62a17ae | 467 | lsa_len = ntohs(lsa->length); |
468 | ospf_lsa_header_dump(lsa); | |
469 | ||
8db278b5 OD |
470 | /* Check that LSA length is valid */ |
471 | if (lsa_len > len || lsa_len % 4 != 0) { | |
472 | zlog_debug(" LSA length %d is incorrect!", lsa_len); | |
473 | break; | |
474 | } | |
d62a17ae | 475 | switch (lsa->type) { |
476 | case OSPF_ROUTER_LSA: | |
8db278b5 | 477 | ospf_router_lsa_dump(s, lsa_len); |
d62a17ae | 478 | break; |
479 | case OSPF_NETWORK_LSA: | |
8db278b5 | 480 | ospf_network_lsa_dump(s, lsa_len); |
d62a17ae | 481 | break; |
482 | case OSPF_SUMMARY_LSA: | |
483 | case OSPF_ASBR_SUMMARY_LSA: | |
8db278b5 | 484 | ospf_summary_lsa_dump(s, lsa_len); |
d62a17ae | 485 | break; |
486 | case OSPF_AS_EXTERNAL_LSA: | |
8db278b5 | 487 | ospf_as_external_lsa_dump(s, lsa_len); |
d62a17ae | 488 | break; |
489 | case OSPF_AS_NSSA_LSA: | |
8db278b5 | 490 | ospf_as_external_lsa_dump(s, lsa_len); |
d62a17ae | 491 | break; |
492 | case OSPF_OPAQUE_LINK_LSA: | |
493 | case OSPF_OPAQUE_AREA_LSA: | |
494 | case OSPF_OPAQUE_AS_LSA: | |
8db278b5 | 495 | ospf_opaque_lsa_dump(s, lsa_len); |
d62a17ae | 496 | break; |
497 | default: | |
498 | break; | |
499 | } | |
500 | ||
501 | stream_forward_getp(s, lsa_len); | |
8db278b5 | 502 | len -= lsa_len; |
d62a17ae | 503 | count--; |
718e3744 | 504 | } |
505 | ||
d62a17ae | 506 | stream_set_getp(s, sp); |
718e3744 | 507 | } |
508 | ||
d7c0a89a | 509 | static void ospf_packet_ls_ack_dump(struct stream *s, uint16_t length) |
718e3744 | 510 | { |
d7c0a89a | 511 | uint32_t sp; |
718e3744 | 512 | |
d62a17ae | 513 | length -= OSPF_HEADER_SIZE; |
514 | sp = stream_get_getp(s); | |
718e3744 | 515 | |
d62a17ae | 516 | zlog_debug("Link State Acknowledgment"); |
517 | ospf_lsa_header_list_dump(s, length); | |
718e3744 | 518 | |
d62a17ae | 519 | stream_set_getp(s, sp); |
718e3744 | 520 | } |
521 | ||
d62a17ae | 522 | static void ospf_header_dump(struct ospf_header *ospfh) |
718e3744 | 523 | { |
d62a17ae | 524 | char buf[9]; |
d7c0a89a | 525 | uint16_t auth_type = ntohs(ospfh->auth_type); |
d62a17ae | 526 | |
527 | zlog_debug("Header"); | |
528 | zlog_debug(" Version %d", ospfh->version); | |
529 | zlog_debug(" Type %d (%s)", ospfh->type, | |
530 | lookup_msg(ospf_packet_type_str, ospfh->type, NULL)); | |
531 | zlog_debug(" Packet Len %d", ntohs(ospfh->length)); | |
96b663a3 MS |
532 | zlog_debug(" Router ID %pI4", &ospfh->router_id); |
533 | zlog_debug(" Area ID %pI4", &ospfh->area_id); | |
d62a17ae | 534 | zlog_debug(" Checksum 0x%x", ntohs(ospfh->checksum)); |
535 | zlog_debug(" AuType %s", | |
536 | lookup_msg(ospf_auth_type_str, auth_type, NULL)); | |
537 | ||
538 | switch (auth_type) { | |
539 | case OSPF_AUTH_NULL: | |
540 | break; | |
541 | case OSPF_AUTH_SIMPLE: | |
4d65d927 | 542 | strlcpy(buf, (char *)ospfh->u.auth_data, sizeof(buf)); |
d62a17ae | 543 | zlog_debug(" Simple Password %s", buf); |
544 | break; | |
545 | case OSPF_AUTH_CRYPTOGRAPHIC: | |
546 | zlog_debug(" Cryptographic Authentication"); | |
547 | zlog_debug(" Key ID %d", ospfh->u.crypt.key_id); | |
548 | zlog_debug(" Auth Data Len %d", ospfh->u.crypt.auth_data_len); | |
549 | zlog_debug(" Sequence number %ld", | |
d7c0a89a | 550 | (unsigned long)ntohl(ospfh->u.crypt.crypt_seqnum)); |
d62a17ae | 551 | break; |
552 | default: | |
553 | zlog_debug("* This is not supported authentication type"); | |
554 | break; | |
555 | } | |
718e3744 | 556 | } |
557 | ||
d62a17ae | 558 | void ospf_packet_dump(struct stream *s) |
718e3744 | 559 | { |
d62a17ae | 560 | struct ospf_header *ospfh; |
561 | unsigned long gp; | |
562 | ||
563 | /* Preserve pointer. */ | |
564 | gp = stream_get_getp(s); | |
565 | ||
566 | /* OSPF Header dump. */ | |
2d34fb80 | 567 | ospfh = (struct ospf_header *)stream_pnt(s); |
d62a17ae | 568 | |
569 | /* Until detail flag is set, return. */ | |
570 | if (!(term_debug_ospf_packet[ospfh->type - 1] & OSPF_DEBUG_DETAIL)) | |
571 | return; | |
572 | ||
573 | /* Show OSPF header detail. */ | |
574 | ospf_header_dump(ospfh); | |
575 | stream_forward_getp(s, OSPF_HEADER_SIZE); | |
576 | ||
577 | switch (ospfh->type) { | |
578 | case OSPF_MSG_HELLO: | |
579 | ospf_packet_hello_dump(s, ntohs(ospfh->length)); | |
580 | break; | |
581 | case OSPF_MSG_DB_DESC: | |
582 | ospf_packet_db_desc_dump(s, ntohs(ospfh->length)); | |
583 | break; | |
584 | case OSPF_MSG_LS_REQ: | |
585 | ospf_packet_ls_req_dump(s, ntohs(ospfh->length)); | |
586 | break; | |
587 | case OSPF_MSG_LS_UPD: | |
588 | ospf_packet_ls_upd_dump(s, ntohs(ospfh->length)); | |
589 | break; | |
590 | case OSPF_MSG_LS_ACK: | |
591 | ospf_packet_ls_ack_dump(s, ntohs(ospfh->length)); | |
592 | break; | |
593 | default: | |
594 | break; | |
595 | } | |
596 | ||
597 | stream_set_getp(s, gp); | |
718e3744 | 598 | } |
599 | ||
692b4c65 QY |
600 | DEFUN (debug_ospf_packet, |
601 | debug_ospf_packet_cmd, | |
602 | "debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]", | |
603 | DEBUG_STR | |
604 | OSPF_STR | |
605 | "Instance ID\n" | |
606 | "OSPF packets\n" | |
607 | "OSPF Hello\n" | |
608 | "OSPF Database Description\n" | |
609 | "OSPF Link State Request\n" | |
610 | "OSPF Link State Update\n" | |
611 | "OSPF Link State Acknowledgment\n" | |
612 | "OSPF all packets\n" | |
613 | "Packet sent\n" | |
614 | "Detail Information\n" | |
615 | "Packet received\n" | |
616 | "Detail Information\n" | |
617 | "Detail Information\n") | |
618 | { | |
d62a17ae | 619 | int inst = (argv[2]->type == RANGE_TKN) ? 1 : 0; |
620 | int detail = strmatch(argv[argc - 1]->text, "detail"); | |
621 | int send = strmatch(argv[argc - (1 + detail)]->text, "send"); | |
622 | int recv = strmatch(argv[argc - (1 + detail)]->text, "recv"); | |
623 | char *packet = argv[3 + inst]->text; | |
718e3744 | 624 | |
d62a17ae | 625 | if (inst) // user passed instance ID |
626 | { | |
409f98ab | 627 | if (inst != ospf_instance) |
ac28e4ec | 628 | return CMD_NOT_MY_INSTANCE; |
d62a17ae | 629 | } |
630 | ||
631 | int type = 0; | |
632 | int flag = 0; | |
633 | int i; | |
634 | ||
635 | /* Check packet type. */ | |
636 | if (strmatch(packet, "hello")) | |
637 | type = OSPF_DEBUG_HELLO; | |
638 | else if (strmatch(packet, "dd")) | |
639 | type = OSPF_DEBUG_DB_DESC; | |
640 | else if (strmatch(packet, "ls-request")) | |
641 | type = OSPF_DEBUG_LS_REQ; | |
642 | else if (strmatch(packet, "ls-update")) | |
643 | type = OSPF_DEBUG_LS_UPD; | |
644 | else if (strmatch(packet, "ls-ack")) | |
645 | type = OSPF_DEBUG_LS_ACK; | |
646 | else if (strmatch(packet, "all")) | |
647 | type = OSPF_DEBUG_ALL; | |
648 | ||
649 | /* Cases: | |
650 | * (none) = send + recv | |
651 | * detail = send + recv + detail | |
652 | * recv = recv | |
653 | * send = send | |
654 | * recv detail = recv + detail | |
655 | * send detail = send + detail | |
656 | */ | |
657 | if (!send && !recv) | |
658 | send = recv = 1; | |
659 | ||
660 | flag |= (send) ? OSPF_DEBUG_SEND : 0; | |
661 | flag |= (recv) ? OSPF_DEBUG_RECV : 0; | |
662 | flag |= (detail) ? OSPF_DEBUG_DETAIL : 0; | |
663 | ||
664 | for (i = 0; i < 5; i++) | |
665 | if (type & (0x01 << i)) { | |
666 | if (vty->node == CONFIG_NODE) | |
667 | DEBUG_PACKET_ON(i, flag); | |
668 | else | |
669 | TERM_DEBUG_PACKET_ON(i, flag); | |
670 | } | |
671 | ||
672 | return CMD_SUCCESS; | |
718e3744 | 673 | } |
674 | ||
692b4c65 QY |
675 | DEFUN (no_debug_ospf_packet, |
676 | no_debug_ospf_packet_cmd, | |
677 | "no debug ospf [(1-65535)] packet <hello|dd|ls-request|ls-update|ls-ack|all> [<send [detail]|recv [detail]|detail>]", | |
678 | NO_STR | |
718e3744 | 679 | DEBUG_STR |
680 | OSPF_STR | |
7c8ff89e | 681 | "Instance ID\n" |
718e3744 | 682 | "OSPF packets\n" |
683 | "OSPF Hello\n" | |
684 | "OSPF Database Description\n" | |
685 | "OSPF Link State Request\n" | |
686 | "OSPF Link State Update\n" | |
687 | "OSPF Link State Acknowledgment\n" | |
692b4c65 QY |
688 | "OSPF all packets\n" |
689 | "Packet sent\n" | |
690 | "Detail Information\n" | |
691 | "Packet received\n" | |
692 | "Detail Information\n" | |
693 | "Detail Information\n") | |
694 | { | |
d62a17ae | 695 | int inst = (argv[3]->type == RANGE_TKN) ? 1 : 0; |
696 | int detail = strmatch(argv[argc - 1]->text, "detail"); | |
697 | int send = strmatch(argv[argc - (1 + detail)]->text, "send"); | |
698 | int recv = strmatch(argv[argc - (1 + detail)]->text, "recv"); | |
699 | char *packet = argv[4 + inst]->text; | |
700 | ||
701 | if (inst) // user passed instance ID | |
702 | { | |
409f98ab | 703 | if (inst != ospf_instance) |
ac28e4ec | 704 | return CMD_NOT_MY_INSTANCE; |
d62a17ae | 705 | } |
706 | ||
707 | int type = 0; | |
708 | int flag = 0; | |
709 | int i; | |
710 | ||
711 | /* Check packet type. */ | |
712 | if (strmatch(packet, "hello")) | |
713 | type = OSPF_DEBUG_HELLO; | |
714 | else if (strmatch(packet, "dd")) | |
715 | type = OSPF_DEBUG_DB_DESC; | |
716 | else if (strmatch(packet, "ls-request")) | |
717 | type = OSPF_DEBUG_LS_REQ; | |
718 | else if (strmatch(packet, "ls-update")) | |
719 | type = OSPF_DEBUG_LS_UPD; | |
720 | else if (strmatch(packet, "ls-ack")) | |
721 | type = OSPF_DEBUG_LS_ACK; | |
722 | else if (strmatch(packet, "all")) | |
723 | type = OSPF_DEBUG_ALL; | |
724 | ||
725 | /* Cases: | |
726 | * (none) = send + recv | |
727 | * detail = send + recv + detail | |
728 | * recv = recv | |
729 | * send = send | |
730 | * recv detail = recv + detail | |
731 | * send detail = send + detail | |
732 | */ | |
733 | if (!send && !recv) | |
734 | send = recv = 1; | |
735 | ||
736 | flag |= (send) ? OSPF_DEBUG_SEND : 0; | |
737 | flag |= (recv) ? OSPF_DEBUG_RECV : 0; | |
738 | flag |= (detail) ? OSPF_DEBUG_DETAIL : 0; | |
739 | ||
740 | for (i = 0; i < 5; i++) | |
741 | if (type & (0x01 << i)) { | |
742 | if (vty->node == CONFIG_NODE) | |
743 | DEBUG_PACKET_OFF(i, flag); | |
744 | else | |
745 | TERM_DEBUG_PACKET_OFF(i, flag); | |
746 | } | |
718e3744 | 747 | |
748 | #ifdef DEBUG | |
d62a17ae | 749 | /* |
750 | for (i = 0; i < 5; i++) | |
751 | zlog_debug ("flag[%d] = %d", i, ospf_debug_packet[i]); | |
752 | */ | |
718e3744 | 753 | #endif /* DEBUG */ |
754 | ||
d62a17ae | 755 | return CMD_SUCCESS; |
718e3744 | 756 | } |
757 | ||
692b4c65 QY |
758 | DEFUN (debug_ospf_ism, |
759 | debug_ospf_ism_cmd, | |
760 | "debug ospf [(1-65535)] ism [<status|events|timers>]", | |
718e3744 | 761 | DEBUG_STR |
762 | OSPF_STR | |
7c8ff89e | 763 | "Instance ID\n" |
692b4c65 QY |
764 | "OSPF Interface State Machine\n" |
765 | "ISM Status Information\n" | |
766 | "ISM Event Information\n" | |
767 | "ISM TImer Information\n") | |
7c8ff89e | 768 | { |
d62a17ae | 769 | int inst = (argv[2]->type == RANGE_TKN); |
770 | char *dbgparam = (argc == 4 + inst) ? argv[argc - 1]->text : NULL; | |
771 | ||
772 | if (inst) // user passed instance ID | |
718e3744 | 773 | { |
409f98ab | 774 | if (inst != ospf_instance) |
ac28e4ec | 775 | return CMD_NOT_MY_INSTANCE; |
718e3744 | 776 | } |
777 | ||
d62a17ae | 778 | if (vty->node == CONFIG_NODE) { |
779 | if (!dbgparam) | |
780 | DEBUG_ON(ism, ISM); | |
781 | else { | |
782 | if (strmatch(dbgparam, "status")) | |
783 | DEBUG_ON(ism, ISM_STATUS); | |
784 | else if (strmatch(dbgparam, "events")) | |
785 | DEBUG_ON(ism, ISM_EVENTS); | |
786 | else if (strmatch(dbgparam, "timers")) | |
787 | DEBUG_ON(ism, ISM_TIMERS); | |
788 | } | |
789 | ||
790 | return CMD_SUCCESS; | |
791 | } | |
792 | ||
793 | /* ENABLE_NODE. */ | |
794 | if (!dbgparam) | |
795 | TERM_DEBUG_ON(ism, ISM); | |
796 | else { | |
797 | if (strmatch(dbgparam, "status")) | |
798 | TERM_DEBUG_ON(ism, ISM_STATUS); | |
799 | else if (strmatch(dbgparam, "events")) | |
800 | TERM_DEBUG_ON(ism, ISM_EVENTS); | |
801 | else if (strmatch(dbgparam, "timers")) | |
802 | TERM_DEBUG_ON(ism, ISM_TIMERS); | |
803 | } | |
804 | ||
805 | return CMD_SUCCESS; | |
718e3744 | 806 | } |
807 | ||
692b4c65 QY |
808 | DEFUN (no_debug_ospf_ism, |
809 | no_debug_ospf_ism_cmd, | |
810 | "no debug ospf [(1-65535)] ism [<status|events|timers>]", | |
16cedbb0 | 811 | NO_STR |
718e3744 | 812 | DEBUG_STR |
813 | OSPF_STR | |
7c8ff89e | 814 | "Instance ID\n" |
692b4c65 QY |
815 | "OSPF Interface State Machine\n" |
816 | "ISM Status Information\n" | |
817 | "ISM Event Information\n" | |
818 | "ISM TImer Information\n") | |
7c8ff89e | 819 | { |
d62a17ae | 820 | int inst = (argv[3]->type == RANGE_TKN); |
821 | char *dbgparam = (argc == 5 + inst) ? argv[argc - 1]->text : NULL; | |
822 | ||
823 | if (inst) // user passed instance ID | |
718e3744 | 824 | { |
409f98ab | 825 | if (inst != ospf_instance) |
ac28e4ec | 826 | return CMD_NOT_MY_INSTANCE; |
d62a17ae | 827 | } |
828 | ||
829 | if (vty->node == CONFIG_NODE) { | |
830 | if (!dbgparam) | |
831 | DEBUG_OFF(ism, ISM); | |
832 | else { | |
833 | if (strmatch(dbgparam, "status")) | |
834 | DEBUG_OFF(ism, ISM_STATUS); | |
835 | else if (strmatch(dbgparam, "events")) | |
836 | DEBUG_OFF(ism, ISM_EVENTS); | |
837 | else if (strmatch(dbgparam, "timers")) | |
838 | DEBUG_OFF(ism, ISM_TIMERS); | |
839 | } | |
840 | ||
841 | return CMD_SUCCESS; | |
842 | } | |
843 | ||
844 | /* ENABLE_NODE. */ | |
845 | if (!dbgparam) | |
846 | TERM_DEBUG_OFF(ism, ISM); | |
847 | else { | |
848 | if (strmatch(dbgparam, "status")) | |
849 | TERM_DEBUG_OFF(ism, ISM_STATUS); | |
850 | else if (strmatch(dbgparam, "events")) | |
851 | TERM_DEBUG_OFF(ism, ISM_EVENTS); | |
852 | else if (strmatch(dbgparam, "timers")) | |
853 | TERM_DEBUG_OFF(ism, ISM_TIMERS); | |
718e3744 | 854 | } |
692b4c65 | 855 | |
d62a17ae | 856 | return CMD_SUCCESS; |
718e3744 | 857 | } |
858 | ||
d62a17ae | 859 | static int debug_ospf_nsm_common(struct vty *vty, int arg_base, int argc, |
860 | struct cmd_token **argv) | |
718e3744 | 861 | { |
d62a17ae | 862 | if (vty->node == CONFIG_NODE) { |
863 | if (argc == arg_base + 0) | |
864 | DEBUG_ON(nsm, NSM); | |
865 | else if (argc == arg_base + 1) { | |
866 | if (strmatch(argv[arg_base]->text, "status")) | |
867 | DEBUG_ON(nsm, NSM_STATUS); | |
868 | else if (strmatch(argv[arg_base]->text, "events")) | |
869 | DEBUG_ON(nsm, NSM_EVENTS); | |
870 | else if (strmatch(argv[arg_base]->text, "timers")) | |
871 | DEBUG_ON(nsm, NSM_TIMERS); | |
872 | } | |
873 | ||
874 | return CMD_SUCCESS; | |
875 | } | |
876 | ||
877 | /* ENABLE_NODE. */ | |
878 | if (argc == arg_base + 0) | |
879 | TERM_DEBUG_ON(nsm, NSM); | |
880 | else if (argc == arg_base + 1) { | |
881 | if (strmatch(argv[arg_base]->text, "status")) | |
882 | TERM_DEBUG_ON(nsm, NSM_STATUS); | |
883 | else if (strmatch(argv[arg_base]->text, "events")) | |
884 | TERM_DEBUG_ON(nsm, NSM_EVENTS); | |
885 | else if (strmatch(argv[arg_base]->text, "timers")) | |
886 | TERM_DEBUG_ON(nsm, NSM_TIMERS); | |
718e3744 | 887 | } |
888 | ||
d62a17ae | 889 | return CMD_SUCCESS; |
718e3744 | 890 | } |
891 | ||
7c8ff89e DS |
892 | DEFUN (debug_ospf_nsm, |
893 | debug_ospf_nsm_cmd, | |
6de69f83 | 894 | "debug ospf nsm [<status|events|timers>]", |
7c8ff89e DS |
895 | DEBUG_STR |
896 | OSPF_STR | |
1d68dbfe DW |
897 | "OSPF Neighbor State Machine\n" |
898 | "NSM Status Information\n" | |
899 | "NSM Event Information\n" | |
900 | "NSM Timer Information\n") | |
7c8ff89e | 901 | { |
d62a17ae | 902 | return debug_ospf_nsm_common(vty, 3, argc, argv); |
7c8ff89e DS |
903 | } |
904 | ||
7c8ff89e DS |
905 | DEFUN (debug_ospf_instance_nsm, |
906 | debug_ospf_instance_nsm_cmd, | |
6de69f83 | 907 | "debug ospf (1-65535) nsm [<status|events|timers>]", |
718e3744 | 908 | DEBUG_STR |
909 | OSPF_STR | |
7c8ff89e | 910 | "Instance ID\n" |
1d68dbfe DW |
911 | "OSPF Neighbor State Machine\n" |
912 | "NSM Status Information\n" | |
913 | "NSM Event Information\n" | |
914 | "NSM Timer Information\n") | |
7c8ff89e | 915 | { |
d62a17ae | 916 | int idx_number = 2; |
d7c0a89a | 917 | unsigned short instance = 0; |
7c8ff89e | 918 | |
d62a17ae | 919 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
920 | if (instance != ospf_instance) |
921 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 922 | |
d62a17ae | 923 | return debug_ospf_nsm_common(vty, 4, argc, argv); |
7c8ff89e DS |
924 | } |
925 | ||
7c8ff89e | 926 | |
d62a17ae | 927 | static int no_debug_ospf_nsm_common(struct vty *vty, int arg_base, int argc, |
928 | struct cmd_token **argv) | |
718e3744 | 929 | { |
d62a17ae | 930 | /* XXX qlyoung */ |
931 | if (vty->node == CONFIG_NODE) { | |
932 | if (argc == arg_base + 0) | |
933 | DEBUG_OFF(nsm, NSM); | |
934 | else if (argc == arg_base + 1) { | |
935 | if (strmatch(argv[arg_base]->text, "status")) | |
936 | DEBUG_OFF(nsm, NSM_STATUS); | |
937 | else if (strmatch(argv[arg_base]->text, "events")) | |
938 | DEBUG_OFF(nsm, NSM_EVENTS); | |
939 | else if (strmatch(argv[arg_base]->text, "timers")) | |
940 | DEBUG_OFF(nsm, NSM_TIMERS); | |
941 | } | |
942 | ||
943 | return CMD_SUCCESS; | |
944 | } | |
945 | ||
946 | /* ENABLE_NODE. */ | |
947 | if (argc == arg_base + 0) | |
948 | TERM_DEBUG_OFF(nsm, NSM); | |
949 | else if (argc == arg_base + 1) { | |
950 | if (strmatch(argv[arg_base]->text, "status")) | |
951 | TERM_DEBUG_OFF(nsm, NSM_STATUS); | |
952 | else if (strmatch(argv[arg_base]->text, "events")) | |
953 | TERM_DEBUG_OFF(nsm, NSM_EVENTS); | |
954 | else if (strmatch(argv[arg_base]->text, "timers")) | |
955 | TERM_DEBUG_OFF(nsm, NSM_TIMERS); | |
718e3744 | 956 | } |
957 | ||
d62a17ae | 958 | return CMD_SUCCESS; |
718e3744 | 959 | } |
960 | ||
7c8ff89e DS |
961 | DEFUN (no_debug_ospf_nsm, |
962 | no_debug_ospf_nsm_cmd, | |
6de69f83 | 963 | "no debug ospf nsm [<status|events|timers>]", |
7c8ff89e DS |
964 | NO_STR |
965 | DEBUG_STR | |
966 | OSPF_STR | |
16cedbb0 | 967 | "OSPF Neighbor State Machine\n" |
1d68dbfe DW |
968 | "NSM Status Information\n" |
969 | "NSM Event Information\n" | |
970 | "NSM Timer Information\n") | |
7c8ff89e | 971 | { |
d62a17ae | 972 | return no_debug_ospf_nsm_common(vty, 4, argc, argv); |
7c8ff89e DS |
973 | } |
974 | ||
718e3744 | 975 | |
7c8ff89e DS |
976 | DEFUN (no_debug_ospf_instance_nsm, |
977 | no_debug_ospf_instance_nsm_cmd, | |
6de69f83 | 978 | "no debug ospf (1-65535) nsm [<status|events|timers>]", |
7c8ff89e | 979 | NO_STR |
718e3744 | 980 | DEBUG_STR |
981 | OSPF_STR | |
7c8ff89e | 982 | "Instance ID\n" |
16cedbb0 | 983 | "OSPF Neighbor State Machine\n" |
1d68dbfe DW |
984 | "NSM Status Information\n" |
985 | "NSM Event Information\n" | |
986 | "NSM Timer Information\n") | |
7c8ff89e | 987 | { |
d62a17ae | 988 | int idx_number = 3; |
d7c0a89a | 989 | unsigned short instance = 0; |
7c8ff89e | 990 | |
d62a17ae | 991 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab | 992 | if (instance != ospf_instance) |
ac28e4ec | 993 | return CMD_NOT_MY_INSTANCE; |
7c8ff89e | 994 | |
d62a17ae | 995 | return no_debug_ospf_nsm_common(vty, 5, argc, argv); |
7c8ff89e DS |
996 | } |
997 | ||
7c8ff89e | 998 | |
d62a17ae | 999 | static int debug_ospf_lsa_common(struct vty *vty, int arg_base, int argc, |
1000 | struct cmd_token **argv) | |
718e3744 | 1001 | { |
d62a17ae | 1002 | if (vty->node == CONFIG_NODE) { |
1003 | if (argc == arg_base + 0) | |
1004 | DEBUG_ON(lsa, LSA); | |
1005 | else if (argc == arg_base + 1) { | |
1006 | if (strmatch(argv[arg_base]->text, "generate")) | |
1007 | DEBUG_ON(lsa, LSA_GENERATE); | |
1008 | else if (strmatch(argv[arg_base]->text, "flooding")) | |
1009 | DEBUG_ON(lsa, LSA_FLOODING); | |
1010 | else if (strmatch(argv[arg_base]->text, "install")) | |
1011 | DEBUG_ON(lsa, LSA_INSTALL); | |
1012 | else if (strmatch(argv[arg_base]->text, "refresh")) | |
1013 | DEBUG_ON(lsa, LSA_REFRESH); | |
ac8c9518 | 1014 | else if (strmatch(argv[arg_base]->text, "aggregate")) |
1015 | DEBUG_ON(lsa, EXTNL_LSA_AGGR); | |
d62a17ae | 1016 | } |
1017 | ||
1018 | return CMD_SUCCESS; | |
718e3744 | 1019 | } |
1020 | ||
d62a17ae | 1021 | /* ENABLE_NODE. */ |
1022 | if (argc == arg_base + 0) | |
1023 | TERM_DEBUG_ON(lsa, LSA); | |
1024 | else if (argc == arg_base + 1) { | |
1025 | if (strmatch(argv[arg_base]->text, "generate")) | |
1026 | TERM_DEBUG_ON(lsa, LSA_GENERATE); | |
1027 | else if (strmatch(argv[arg_base]->text, "flooding")) | |
1028 | TERM_DEBUG_ON(lsa, LSA_FLOODING); | |
1029 | else if (strmatch(argv[arg_base]->text, "install")) | |
1030 | TERM_DEBUG_ON(lsa, LSA_INSTALL); | |
1031 | else if (strmatch(argv[arg_base]->text, "refresh")) | |
1032 | TERM_DEBUG_ON(lsa, LSA_REFRESH); | |
ac8c9518 | 1033 | else if (strmatch(argv[arg_base]->text, "aggregate")) |
1034 | TERM_DEBUG_ON(lsa, EXTNL_LSA_AGGR); | |
d62a17ae | 1035 | } |
1036 | ||
1037 | return CMD_SUCCESS; | |
718e3744 | 1038 | } |
1039 | ||
7c8ff89e DS |
1040 | DEFUN (debug_ospf_lsa, |
1041 | debug_ospf_lsa_cmd, | |
ac8c9518 | 1042 | "debug ospf lsa [<generate|flooding|install|refresh|aggregate>]", |
7c8ff89e DS |
1043 | DEBUG_STR |
1044 | OSPF_STR | |
1d68dbfe DW |
1045 | "OSPF Link State Advertisement\n" |
1046 | "LSA Generation\n" | |
1047 | "LSA Flooding\n" | |
1048 | "LSA Install/Delete\n" | |
ac8c9518 | 1049 | "LSA Refresh\n" |
1050 | "External LSA Aggregation\n") | |
7c8ff89e | 1051 | { |
d62a17ae | 1052 | return debug_ospf_lsa_common(vty, 3, argc, argv); |
7c8ff89e DS |
1053 | } |
1054 | ||
7c8ff89e DS |
1055 | DEFUN (debug_ospf_instance_lsa, |
1056 | debug_ospf_instance_lsa_cmd, | |
ac8c9518 | 1057 | "debug ospf (1-65535) lsa " |
1058 | "[<generate|flooding|install|refresh|aggregate>]", | |
718e3744 | 1059 | DEBUG_STR |
1060 | OSPF_STR | |
7c8ff89e | 1061 | "Instance ID\n" |
1d68dbfe DW |
1062 | "OSPF Link State Advertisement\n" |
1063 | "LSA Generation\n" | |
1064 | "LSA Flooding\n" | |
1065 | "LSA Install/Delete\n" | |
ac8c9518 | 1066 | "LSA Refresh\n" |
1067 | "External LSA Aggregation\n") | |
7c8ff89e | 1068 | { |
d62a17ae | 1069 | int idx_number = 2; |
d7c0a89a | 1070 | unsigned short instance = 0; |
7c8ff89e | 1071 | |
d62a17ae | 1072 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab | 1073 | if (instance != ospf_instance) |
ac28e4ec | 1074 | return CMD_NOT_MY_INSTANCE; |
7c8ff89e | 1075 | |
d62a17ae | 1076 | return debug_ospf_lsa_common(vty, 4, argc, argv); |
7c8ff89e DS |
1077 | } |
1078 | ||
7c8ff89e | 1079 | |
d62a17ae | 1080 | static int no_debug_ospf_lsa_common(struct vty *vty, int arg_base, int argc, |
1081 | struct cmd_token **argv) | |
718e3744 | 1082 | { |
d62a17ae | 1083 | if (vty->node == CONFIG_NODE) { |
1084 | if (argc == arg_base + 0) | |
1085 | DEBUG_OFF(lsa, LSA); | |
1086 | else if (argc == arg_base + 1) { | |
1087 | if (strmatch(argv[arg_base]->text, "generate")) | |
1088 | DEBUG_OFF(lsa, LSA_GENERATE); | |
1089 | else if (strmatch(argv[arg_base]->text, "flooding")) | |
1090 | DEBUG_OFF(lsa, LSA_FLOODING); | |
1091 | else if (strmatch(argv[arg_base]->text, "install")) | |
1092 | DEBUG_OFF(lsa, LSA_INSTALL); | |
1093 | else if (strmatch(argv[arg_base]->text, "refresh")) | |
1094 | DEBUG_OFF(lsa, LSA_REFRESH); | |
ac8c9518 | 1095 | else if (strmatch(argv[arg_base]->text, "aggregate")) |
1096 | DEBUG_OFF(lsa, EXTNL_LSA_AGGR); | |
d62a17ae | 1097 | } |
1098 | ||
1099 | return CMD_SUCCESS; | |
1100 | } | |
1101 | ||
1102 | /* ENABLE_NODE. */ | |
1103 | if (argc == arg_base + 0) | |
1104 | TERM_DEBUG_OFF(lsa, LSA); | |
1105 | else if (argc == arg_base + 1) { | |
1106 | if (strmatch(argv[arg_base]->text, "generate")) | |
1107 | TERM_DEBUG_OFF(lsa, LSA_GENERATE); | |
1108 | else if (strmatch(argv[arg_base]->text, "flooding")) | |
1109 | TERM_DEBUG_OFF(lsa, LSA_FLOODING); | |
1110 | else if (strmatch(argv[arg_base]->text, "install")) | |
1111 | TERM_DEBUG_OFF(lsa, LSA_INSTALL); | |
1112 | else if (strmatch(argv[arg_base]->text, "refresh")) | |
1113 | TERM_DEBUG_OFF(lsa, LSA_REFRESH); | |
ac8c9518 | 1114 | else if (strmatch(argv[arg_base]->text, "aggregate")) |
1115 | TERM_DEBUG_OFF(lsa, EXTNL_LSA_AGGR); | |
718e3744 | 1116 | } |
1117 | ||
d62a17ae | 1118 | return CMD_SUCCESS; |
718e3744 | 1119 | } |
1120 | ||
7c8ff89e DS |
1121 | DEFUN (no_debug_ospf_lsa, |
1122 | no_debug_ospf_lsa_cmd, | |
ac8c9518 | 1123 | "no debug ospf lsa [<generate|flooding|install|refresh|aggregate>]", |
7c8ff89e DS |
1124 | NO_STR |
1125 | DEBUG_STR | |
1126 | OSPF_STR | |
1d68dbfe DW |
1127 | "OSPF Link State Advertisement\n" |
1128 | "LSA Generation\n" | |
1129 | "LSA Flooding\n" | |
1130 | "LSA Install/Delete\n" | |
ac8c9518 | 1131 | "LSA Refres\n" |
1132 | "External LSA Aggregation\n") | |
7c8ff89e | 1133 | { |
d62a17ae | 1134 | return no_debug_ospf_lsa_common(vty, 4, argc, argv); |
7c8ff89e DS |
1135 | } |
1136 | ||
7c8ff89e DS |
1137 | DEFUN (no_debug_ospf_instance_lsa, |
1138 | no_debug_ospf_instance_lsa_cmd, | |
ac8c9518 | 1139 | "no debug ospf (1-65535) lsa " |
1140 | "[<generate|flooding|install|refresh|aggregate>]", | |
7c8ff89e DS |
1141 | NO_STR |
1142 | DEBUG_STR | |
1143 | OSPF_STR | |
1144 | "Instance ID\n" | |
1d68dbfe DW |
1145 | "OSPF Link State Advertisement\n" |
1146 | "LSA Generation\n" | |
1147 | "LSA Flooding\n" | |
1148 | "LSA Install/Delete\n" | |
ac8c9518 | 1149 | "LSA Refres\n" |
1150 | "External LSA Aggregation\n") | |
7c8ff89e | 1151 | { |
d62a17ae | 1152 | int idx_number = 3; |
d7c0a89a | 1153 | unsigned short instance = 0; |
7c8ff89e | 1154 | |
d62a17ae | 1155 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab | 1156 | if (instance != ospf_instance) |
ac28e4ec | 1157 | return CMD_NOT_MY_INSTANCE; |
6b0655a2 | 1158 | |
d62a17ae | 1159 | return no_debug_ospf_lsa_common(vty, 5, argc, argv); |
7c8ff89e DS |
1160 | } |
1161 | ||
7c8ff89e | 1162 | |
d62a17ae | 1163 | static int debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, |
1164 | struct cmd_token **argv) | |
718e3744 | 1165 | { |
d62a17ae | 1166 | if (vty->node == CONFIG_NODE) { |
1167 | if (argc == arg_base + 0) | |
1168 | DEBUG_ON(zebra, ZEBRA); | |
1169 | else if (argc == arg_base + 1) { | |
1170 | if (strmatch(argv[arg_base]->text, "interface")) | |
1171 | DEBUG_ON(zebra, ZEBRA_INTERFACE); | |
1172 | else if (strmatch(argv[arg_base]->text, "redistribute")) | |
1173 | DEBUG_ON(zebra, ZEBRA_REDISTRIBUTE); | |
1174 | } | |
1175 | ||
1176 | return CMD_SUCCESS; | |
1177 | } | |
1178 | ||
1179 | /* ENABLE_NODE. */ | |
1180 | if (argc == arg_base + 0) | |
1181 | TERM_DEBUG_ON(zebra, ZEBRA); | |
1182 | else if (argc == arg_base + 1) { | |
1183 | if (strmatch(argv[arg_base]->text, "interface")) | |
1184 | TERM_DEBUG_ON(zebra, ZEBRA_INTERFACE); | |
1185 | else if (strmatch(argv[arg_base]->text, "redistribute")) | |
1186 | TERM_DEBUG_ON(zebra, ZEBRA_REDISTRIBUTE); | |
718e3744 | 1187 | } |
1188 | ||
d62a17ae | 1189 | return CMD_SUCCESS; |
718e3744 | 1190 | } |
1191 | ||
7c8ff89e DS |
1192 | DEFUN (debug_ospf_zebra, |
1193 | debug_ospf_zebra_cmd, | |
6de69f83 | 1194 | "debug ospf zebra [<interface|redistribute>]", |
7c8ff89e DS |
1195 | DEBUG_STR |
1196 | OSPF_STR | |
41e7fb80 | 1197 | ZEBRA_STR |
1d68dbfe DW |
1198 | "Zebra interface\n" |
1199 | "Zebra redistribute\n") | |
7c8ff89e | 1200 | { |
d62a17ae | 1201 | return debug_ospf_zebra_common(vty, 3, argc, argv); |
7c8ff89e DS |
1202 | } |
1203 | ||
7c8ff89e DS |
1204 | DEFUN (debug_ospf_instance_zebra, |
1205 | debug_ospf_instance_zebra_cmd, | |
6de69f83 | 1206 | "debug ospf (1-65535) zebra [<interface|redistribute>]", |
718e3744 | 1207 | DEBUG_STR |
1208 | OSPF_STR | |
7c8ff89e | 1209 | "Instance ID\n" |
41e7fb80 | 1210 | ZEBRA_STR |
1d68dbfe DW |
1211 | "Zebra interface\n" |
1212 | "Zebra redistribute\n") | |
7c8ff89e | 1213 | { |
d62a17ae | 1214 | int idx_number = 2; |
d7c0a89a | 1215 | unsigned short instance = 0; |
7c8ff89e | 1216 | |
d62a17ae | 1217 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab | 1218 | if (instance != ospf_instance) |
ac28e4ec | 1219 | return CMD_NOT_MY_INSTANCE; |
7c8ff89e | 1220 | |
d62a17ae | 1221 | return debug_ospf_zebra_common(vty, 4, argc, argv); |
7c8ff89e DS |
1222 | } |
1223 | ||
7c8ff89e | 1224 | |
d62a17ae | 1225 | static int no_debug_ospf_zebra_common(struct vty *vty, int arg_base, int argc, |
1226 | struct cmd_token **argv) | |
718e3744 | 1227 | { |
d62a17ae | 1228 | if (vty->node == CONFIG_NODE) { |
1229 | if (argc == arg_base + 0) | |
1230 | DEBUG_OFF(zebra, ZEBRA); | |
1231 | else if (argc == arg_base + 1) { | |
1232 | if (strmatch(argv[arg_base]->text, "interface")) | |
1233 | DEBUG_OFF(zebra, ZEBRA_INTERFACE); | |
1234 | else if (strmatch(argv[arg_base]->text, "redistribute")) | |
1235 | DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE); | |
1236 | } | |
1237 | ||
1238 | return CMD_SUCCESS; | |
1239 | } | |
1240 | ||
1241 | /* ENABLE_NODE. */ | |
1242 | if (argc == arg_base + 0) | |
1243 | TERM_DEBUG_OFF(zebra, ZEBRA); | |
1244 | else if (argc == arg_base + 1) { | |
1245 | if (strmatch(argv[arg_base]->text, "interface")) | |
1246 | TERM_DEBUG_OFF(zebra, ZEBRA_INTERFACE); | |
1247 | else if (strmatch(argv[arg_base]->text, "redistribute")) | |
1248 | TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE); | |
718e3744 | 1249 | } |
1250 | ||
d62a17ae | 1251 | return CMD_SUCCESS; |
718e3744 | 1252 | } |
1253 | ||
7c8ff89e DS |
1254 | DEFUN (no_debug_ospf_zebra, |
1255 | no_debug_ospf_zebra_cmd, | |
6de69f83 | 1256 | "no debug ospf zebra [<interface|redistribute>]", |
7c8ff89e DS |
1257 | NO_STR |
1258 | DEBUG_STR | |
1259 | OSPF_STR | |
41e7fb80 | 1260 | ZEBRA_STR |
1d68dbfe DW |
1261 | "Zebra interface\n" |
1262 | "Zebra redistribute\n") | |
7c8ff89e | 1263 | { |
d62a17ae | 1264 | return no_debug_ospf_zebra_common(vty, 4, argc, argv); |
7c8ff89e DS |
1265 | } |
1266 | ||
7c8ff89e DS |
1267 | DEFUN (no_debug_ospf_instance_zebra, |
1268 | no_debug_ospf_instance_zebra_cmd, | |
6de69f83 | 1269 | "no debug ospf (1-65535) zebra [<interface|redistribute>]", |
7c8ff89e DS |
1270 | NO_STR |
1271 | DEBUG_STR | |
1272 | OSPF_STR | |
1273 | "Instance ID\n" | |
41e7fb80 | 1274 | ZEBRA_STR |
1d68dbfe DW |
1275 | "Zebra interface\n" |
1276 | "Zebra redistribute\n") | |
7c8ff89e | 1277 | { |
d62a17ae | 1278 | int idx_number = 3; |
d7c0a89a | 1279 | unsigned short instance = 0; |
7c8ff89e | 1280 | |
d62a17ae | 1281 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1282 | if (instance != ospf_instance) |
1283 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 1284 | |
d62a17ae | 1285 | return no_debug_ospf_zebra_common(vty, 5, argc, argv); |
7c8ff89e DS |
1286 | } |
1287 | ||
7c8ff89e | 1288 | |
718e3744 | 1289 | DEFUN (debug_ospf_event, |
1290 | debug_ospf_event_cmd, | |
1291 | "debug ospf event", | |
1292 | DEBUG_STR | |
1293 | OSPF_STR | |
1294 | "OSPF event information\n") | |
1295 | { | |
d62a17ae | 1296 | if (vty->node == CONFIG_NODE) |
1297 | CONF_DEBUG_ON(event, EVENT); | |
1298 | TERM_DEBUG_ON(event, EVENT); | |
1299 | return CMD_SUCCESS; | |
718e3744 | 1300 | } |
1301 | ||
1302 | DEFUN (no_debug_ospf_event, | |
1303 | no_debug_ospf_event_cmd, | |
1304 | "no debug ospf event", | |
1305 | NO_STR | |
1306 | DEBUG_STR | |
1307 | OSPF_STR | |
1308 | "OSPF event information\n") | |
1309 | { | |
d62a17ae | 1310 | if (vty->node == CONFIG_NODE) |
1311 | CONF_DEBUG_OFF(event, EVENT); | |
1312 | TERM_DEBUG_OFF(event, EVENT); | |
1313 | return CMD_SUCCESS; | |
718e3744 | 1314 | } |
1315 | ||
7c8ff89e DS |
1316 | DEFUN (debug_ospf_instance_event, |
1317 | debug_ospf_instance_event_cmd, | |
6147e2c6 | 1318 | "debug ospf (1-65535) event", |
7c8ff89e DS |
1319 | DEBUG_STR |
1320 | OSPF_STR | |
1321 | "Instance ID\n" | |
1322 | "OSPF event information\n") | |
1323 | { | |
d62a17ae | 1324 | int idx_number = 2; |
d7c0a89a | 1325 | unsigned short instance = 0; |
7c8ff89e | 1326 | |
d62a17ae | 1327 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1328 | if (instance != ospf_instance) |
1329 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 1330 | |
d62a17ae | 1331 | if (vty->node == CONFIG_NODE) |
1332 | CONF_DEBUG_ON(event, EVENT); | |
1333 | TERM_DEBUG_ON(event, EVENT); | |
1334 | return CMD_SUCCESS; | |
7c8ff89e DS |
1335 | } |
1336 | ||
1337 | DEFUN (no_debug_ospf_instance_event, | |
1338 | no_debug_ospf_instance_event_cmd, | |
6147e2c6 | 1339 | "no debug ospf (1-65535) event", |
7c8ff89e DS |
1340 | NO_STR |
1341 | DEBUG_STR | |
1342 | OSPF_STR | |
1343 | "Instance ID\n" | |
1344 | "OSPF event information\n") | |
1345 | { | |
d62a17ae | 1346 | int idx_number = 3; |
d7c0a89a | 1347 | unsigned short instance = 0; |
7c8ff89e | 1348 | |
d62a17ae | 1349 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1350 | if (instance != ospf_instance) |
1351 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 1352 | |
d62a17ae | 1353 | if (vty->node == CONFIG_NODE) |
1354 | CONF_DEBUG_OFF(event, EVENT); | |
1355 | TERM_DEBUG_OFF(event, EVENT); | |
1356 | return CMD_SUCCESS; | |
7c8ff89e DS |
1357 | } |
1358 | ||
718e3744 | 1359 | DEFUN (debug_ospf_nssa, |
1360 | debug_ospf_nssa_cmd, | |
1361 | "debug ospf nssa", | |
1362 | DEBUG_STR | |
1363 | OSPF_STR | |
1364 | "OSPF nssa information\n") | |
1365 | { | |
d62a17ae | 1366 | if (vty->node == CONFIG_NODE) |
1367 | CONF_DEBUG_ON(nssa, NSSA); | |
1368 | TERM_DEBUG_ON(nssa, NSSA); | |
1369 | return CMD_SUCCESS; | |
718e3744 | 1370 | } |
1371 | ||
1372 | DEFUN (no_debug_ospf_nssa, | |
1373 | no_debug_ospf_nssa_cmd, | |
1374 | "no debug ospf nssa", | |
1375 | NO_STR | |
1376 | DEBUG_STR | |
1377 | OSPF_STR | |
1378 | "OSPF nssa information\n") | |
1379 | { | |
d62a17ae | 1380 | if (vty->node == CONFIG_NODE) |
1381 | CONF_DEBUG_OFF(nssa, NSSA); | |
1382 | TERM_DEBUG_OFF(nssa, NSSA); | |
1383 | return CMD_SUCCESS; | |
718e3744 | 1384 | } |
1385 | ||
7c8ff89e DS |
1386 | DEFUN (debug_ospf_instance_nssa, |
1387 | debug_ospf_instance_nssa_cmd, | |
6147e2c6 | 1388 | "debug ospf (1-65535) nssa", |
7c8ff89e DS |
1389 | DEBUG_STR |
1390 | OSPF_STR | |
1391 | "Instance ID\n" | |
1392 | "OSPF nssa information\n") | |
1393 | { | |
d62a17ae | 1394 | int idx_number = 2; |
d7c0a89a | 1395 | unsigned short instance = 0; |
7c8ff89e | 1396 | |
d62a17ae | 1397 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1398 | if (instance != ospf_instance) |
1399 | return CMD_NOT_MY_INSTANCE; | |
6b0655a2 | 1400 | |
d62a17ae | 1401 | if (vty->node == CONFIG_NODE) |
1402 | CONF_DEBUG_ON(nssa, NSSA); | |
1403 | TERM_DEBUG_ON(nssa, NSSA); | |
1404 | return CMD_SUCCESS; | |
7c8ff89e DS |
1405 | } |
1406 | ||
1407 | DEFUN (no_debug_ospf_instance_nssa, | |
1408 | no_debug_ospf_instance_nssa_cmd, | |
6147e2c6 | 1409 | "no debug ospf (1-65535) nssa", |
7c8ff89e | 1410 | NO_STR |
718e3744 | 1411 | DEBUG_STR |
7c8ff89e DS |
1412 | OSPF_STR |
1413 | "Instance ID\n" | |
1414 | "OSPF nssa information\n") | |
1415 | { | |
d62a17ae | 1416 | int idx_number = 3; |
d7c0a89a | 1417 | unsigned short instance = 0; |
7c8ff89e | 1418 | |
d62a17ae | 1419 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1420 | if (instance != ospf_instance) |
1421 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 1422 | |
d62a17ae | 1423 | if (vty->node == CONFIG_NODE) |
1424 | CONF_DEBUG_OFF(nssa, NSSA); | |
1425 | TERM_DEBUG_OFF(nssa, NSSA); | |
1426 | return CMD_SUCCESS; | |
7c8ff89e DS |
1427 | } |
1428 | ||
16f1b9ee OD |
1429 | DEFUN (debug_ospf_te, |
1430 | debug_ospf_te_cmd, | |
1431 | "debug ospf te", | |
1432 | DEBUG_STR | |
1433 | OSPF_STR | |
1434 | "OSPF-TE information\n") | |
1435 | { | |
d62a17ae | 1436 | if (vty->node == CONFIG_NODE) |
1437 | CONF_DEBUG_ON(te, TE); | |
1438 | TERM_DEBUG_ON(te, TE); | |
1439 | return CMD_SUCCESS; | |
16f1b9ee OD |
1440 | } |
1441 | ||
1442 | DEFUN (no_debug_ospf_te, | |
1443 | no_debug_ospf_te_cmd, | |
1444 | "no debug ospf te", | |
1445 | NO_STR | |
1446 | DEBUG_STR | |
1447 | OSPF_STR | |
1448 | "OSPF-TE information\n") | |
1449 | { | |
d62a17ae | 1450 | if (vty->node == CONFIG_NODE) |
1451 | CONF_DEBUG_OFF(te, TE); | |
1452 | TERM_DEBUG_OFF(te, TE); | |
1453 | return CMD_SUCCESS; | |
16f1b9ee OD |
1454 | } |
1455 | ||
cf9b9f77 OD |
1456 | DEFUN (debug_ospf_sr, |
1457 | debug_ospf_sr_cmd, | |
1458 | "debug ospf sr", | |
1459 | DEBUG_STR | |
1460 | OSPF_STR | |
1461 | "OSPF-SR information\n") | |
1462 | { | |
1463 | if (vty->node == CONFIG_NODE) | |
1464 | CONF_DEBUG_ON(sr, SR); | |
1465 | TERM_DEBUG_ON(sr, SR); | |
1466 | return CMD_SUCCESS; | |
1467 | } | |
1468 | ||
1469 | DEFUN (no_debug_ospf_sr, | |
1470 | no_debug_ospf_sr_cmd, | |
1471 | "no debug ospf sr", | |
1472 | NO_STR | |
1473 | DEBUG_STR | |
1474 | OSPF_STR | |
1475 | "OSPF-SR information\n") | |
1476 | { | |
1477 | if (vty->node == CONFIG_NODE) | |
1478 | CONF_DEBUG_OFF(sr, SR); | |
1479 | TERM_DEBUG_OFF(sr, SR); | |
1480 | return CMD_SUCCESS; | |
1481 | } | |
1482 | ||
a4553b5b G |
1483 | DEFUN(debug_ospf_ti_lfa, debug_ospf_ti_lfa_cmd, "debug ospf ti-lfa", |
1484 | DEBUG_STR OSPF_STR "OSPF-SR TI-LFA information\n") | |
1485 | { | |
1486 | if (vty->node == CONFIG_NODE) | |
1487 | CONF_DEBUG_ON(ti_lfa, TI_LFA); | |
1488 | TERM_DEBUG_ON(ti_lfa, TI_LFA); | |
1489 | return CMD_SUCCESS; | |
1490 | } | |
1491 | ||
1492 | DEFUN(no_debug_ospf_ti_lfa, no_debug_ospf_ti_lfa_cmd, "no debug ospf ti-lfa", | |
1493 | NO_STR DEBUG_STR OSPF_STR "OSPF-SR TI-LFA information\n") | |
1494 | { | |
1495 | if (vty->node == CONFIG_NODE) | |
1496 | CONF_DEBUG_OFF(ti_lfa, TI_LFA); | |
1497 | TERM_DEBUG_OFF(ti_lfa, TI_LFA); | |
1498 | return CMD_SUCCESS; | |
1499 | } | |
1500 | ||
1febb13d S |
1501 | DEFUN (debug_ospf_default_info, |
1502 | debug_ospf_default_info_cmd, | |
1503 | "debug ospf default-information", | |
1504 | DEBUG_STR | |
1505 | OSPF_STR | |
1506 | "OSPF default information\n") | |
1507 | { | |
1508 | if (vty->node == CONFIG_NODE) | |
1509 | CONF_DEBUG_ON(defaultinfo, DEFAULTINFO); | |
1510 | TERM_DEBUG_ON(defaultinfo, DEFAULTINFO); | |
1511 | return CMD_SUCCESS; | |
1512 | } | |
1513 | ||
1514 | DEFUN (no_debug_ospf_default_info, | |
1515 | no_debug_ospf_default_info_cmd, | |
1516 | "no debug ospf default-information", | |
1517 | NO_STR | |
1518 | DEBUG_STR | |
1519 | OSPF_STR | |
1520 | "OSPF default information\n") | |
1521 | { | |
1522 | if (vty->node == CONFIG_NODE) | |
1523 | CONF_DEBUG_OFF(defaultinfo, DEFAULTINFO); | |
1524 | TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO); | |
1525 | return CMD_SUCCESS; | |
1526 | } | |
1527 | ||
132a782e | 1528 | DEFUN(debug_ospf_ldp_sync, |
1529 | debug_ospf_ldp_sync_cmd, | |
1530 | "debug ospf ldp-sync", | |
1531 | DEBUG_STR OSPF_STR | |
1532 | "OSPF LDP-Sync information\n") | |
1533 | { | |
1534 | if (vty->node == CONFIG_NODE) | |
1535 | CONF_DEBUG_ON(ldp_sync, LDP_SYNC); | |
1536 | TERM_DEBUG_ON(ldp_sync, LDP_SYNC); | |
1537 | return CMD_SUCCESS; | |
1538 | } | |
1539 | ||
1540 | DEFUN(no_debug_ospf_ldp_sync, | |
1541 | no_debug_ospf_ldp_sync_cmd, | |
1542 | "no debug ospf ldp-sync", | |
1543 | NO_STR | |
1544 | DEBUG_STR | |
1545 | OSPF_STR | |
1546 | "OSPF LDP-Sync information\n") | |
1547 | { | |
1548 | if (vty->node == CONFIG_NODE) | |
1549 | CONF_DEBUG_OFF(ldp_sync, LDP_SYNC); | |
1550 | TERM_DEBUG_OFF(ldp_sync, LDP_SYNC); | |
caa1cd9e | 1551 | |
1552 | return CMD_SUCCESS; | |
1553 | } | |
1554 | ||
3f87e1d8 G |
1555 | DEFPY(debug_ospf_gr, debug_ospf_gr_cmd, "[no$no] debug ospf graceful-restart", |
1556 | NO_STR DEBUG_STR OSPF_STR "OSPF Graceful Restart\n") | |
caa1cd9e | 1557 | { |
1558 | if (vty->node == CONFIG_NODE) | |
3f87e1d8 | 1559 | CONF_DEBUG_ON(gr, GR); |
caa1cd9e | 1560 | |
1561 | if (!no) | |
3f87e1d8 | 1562 | TERM_DEBUG_ON(gr, GR); |
caa1cd9e | 1563 | else |
3f87e1d8 | 1564 | TERM_DEBUG_OFF(gr, GR); |
caa1cd9e | 1565 | |
132a782e | 1566 | return CMD_SUCCESS; |
1567 | } | |
1568 | ||
e4505a2e RZ |
1569 | DEFPY(debug_ospf_bfd, debug_ospf_bfd_cmd, |
1570 | "[no] debug ospf bfd", | |
1571 | NO_STR | |
1572 | DEBUG_STR | |
1573 | OSPF_STR | |
1574 | "Bidirection Forwarding Detection\n") | |
1575 | { | |
1576 | if (vty->node == CONFIG_NODE) { | |
1577 | if (no) { | |
1578 | bfd_protocol_integration_set_debug(false); | |
1579 | CONF_DEBUG_OFF(bfd, BFD_LIB); | |
1580 | } else { | |
1581 | bfd_protocol_integration_set_debug(true); | |
1582 | CONF_DEBUG_ON(bfd, BFD_LIB); | |
1583 | } | |
1584 | } | |
1585 | ||
1586 | if (no) | |
1587 | TERM_DEBUG_OFF(bfd, BFD_LIB); | |
1588 | else | |
1589 | TERM_DEBUG_ON(bfd, BFD_LIB); | |
1590 | ||
1591 | return CMD_SUCCESS; | |
1592 | } | |
1593 | ||
4dfd8aff DW |
1594 | DEFUN (no_debug_ospf, |
1595 | no_debug_ospf_cmd, | |
1596 | "no debug ospf", | |
1597 | NO_STR | |
1598 | DEBUG_STR | |
1599 | OSPF_STR) | |
1600 | { | |
d62a17ae | 1601 | int flag = OSPF_DEBUG_SEND | OSPF_DEBUG_RECV | OSPF_DEBUG_DETAIL; |
1602 | int i; | |
1603 | ||
1604 | if (vty->node == CONFIG_NODE) { | |
1605 | CONF_DEBUG_OFF(event, EVENT); | |
1606 | CONF_DEBUG_OFF(nssa, NSSA); | |
1607 | DEBUG_OFF(ism, ISM_EVENTS); | |
1608 | DEBUG_OFF(ism, ISM_STATUS); | |
1609 | DEBUG_OFF(ism, ISM_TIMERS); | |
1610 | DEBUG_OFF(lsa, LSA); | |
1611 | DEBUG_OFF(lsa, LSA_FLOODING); | |
1612 | DEBUG_OFF(lsa, LSA_GENERATE); | |
1613 | DEBUG_OFF(lsa, LSA_INSTALL); | |
1614 | DEBUG_OFF(lsa, LSA_REFRESH); | |
1615 | DEBUG_OFF(nsm, NSM); | |
1616 | DEBUG_OFF(nsm, NSM_EVENTS); | |
1617 | DEBUG_OFF(nsm, NSM_STATUS); | |
1618 | DEBUG_OFF(nsm, NSM_TIMERS); | |
1619 | DEBUG_OFF(zebra, ZEBRA); | |
1620 | DEBUG_OFF(zebra, ZEBRA_INTERFACE); | |
1621 | DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE); | |
1febb13d | 1622 | DEBUG_OFF(defaultinfo, DEFAULTINFO); |
132a782e | 1623 | DEBUG_OFF(ldp_sync, LDP_SYNC); |
d62a17ae | 1624 | |
e4505a2e RZ |
1625 | /* BFD debugging is two parts: OSPF and library. */ |
1626 | DEBUG_OFF(bfd, BFD_LIB); | |
1627 | bfd_protocol_integration_set_debug(false); | |
1628 | ||
d62a17ae | 1629 | for (i = 0; i < 5; i++) |
1630 | DEBUG_PACKET_OFF(i, flag); | |
1631 | } | |
1632 | ||
1633 | for (i = 0; i < 5; i++) | |
1634 | TERM_DEBUG_PACKET_OFF(i, flag); | |
1635 | ||
1636 | TERM_DEBUG_OFF(event, EVENT); | |
1637 | TERM_DEBUG_OFF(ism, ISM); | |
1638 | TERM_DEBUG_OFF(ism, ISM_EVENTS); | |
1639 | TERM_DEBUG_OFF(ism, ISM_STATUS); | |
1640 | TERM_DEBUG_OFF(ism, ISM_TIMERS); | |
1641 | TERM_DEBUG_OFF(lsa, LSA); | |
1642 | TERM_DEBUG_OFF(lsa, LSA_FLOODING); | |
1643 | TERM_DEBUG_OFF(lsa, LSA_GENERATE); | |
1644 | TERM_DEBUG_OFF(lsa, LSA_INSTALL); | |
1645 | TERM_DEBUG_OFF(lsa, LSA_REFRESH); | |
1646 | TERM_DEBUG_OFF(nsm, NSM); | |
1647 | TERM_DEBUG_OFF(nsm, NSM_EVENTS); | |
1648 | TERM_DEBUG_OFF(nsm, NSM_STATUS); | |
1649 | TERM_DEBUG_OFF(nsm, NSM_TIMERS); | |
1650 | TERM_DEBUG_OFF(nssa, NSSA); | |
1651 | TERM_DEBUG_OFF(zebra, ZEBRA); | |
1652 | TERM_DEBUG_OFF(zebra, ZEBRA_INTERFACE); | |
1653 | TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE); | |
1febb13d | 1654 | TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO); |
132a782e | 1655 | TERM_DEBUG_OFF(ldp_sync, LDP_SYNC); |
e4505a2e | 1656 | TERM_DEBUG_OFF(bfd, BFD_LIB); |
d62a17ae | 1657 | |
1658 | return CMD_SUCCESS; | |
4dfd8aff | 1659 | } |
7c8ff89e | 1660 | |
409f98ab | 1661 | static int show_debugging_ospf_common(struct vty *vty) |
718e3744 | 1662 | { |
d62a17ae | 1663 | int i; |
1664 | ||
409f98ab IR |
1665 | if (ospf_instance) |
1666 | vty_out(vty, "\nOSPF Instance: %d\n\n", ospf_instance); | |
d62a17ae | 1667 | |
1668 | vty_out(vty, "OSPF debugging status:\n"); | |
1669 | ||
1670 | /* Show debug status for events. */ | |
1671 | if (IS_DEBUG_OSPF(event, EVENT)) | |
1672 | vty_out(vty, " OSPF event debugging is on\n"); | |
1673 | ||
1674 | /* Show debug status for ISM. */ | |
1675 | if (IS_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM) | |
1676 | vty_out(vty, " OSPF ISM debugging is on\n"); | |
1677 | else { | |
1678 | if (IS_DEBUG_OSPF(ism, ISM_STATUS)) | |
1679 | vty_out(vty, " OSPF ISM status debugging is on\n"); | |
1680 | if (IS_DEBUG_OSPF(ism, ISM_EVENTS)) | |
1681 | vty_out(vty, " OSPF ISM event debugging is on\n"); | |
1682 | if (IS_DEBUG_OSPF(ism, ISM_TIMERS)) | |
1683 | vty_out(vty, " OSPF ISM timer debugging is on\n"); | |
1684 | } | |
1685 | ||
1686 | /* Show debug status for NSM. */ | |
1687 | if (IS_DEBUG_OSPF(nsm, NSM) == OSPF_DEBUG_NSM) | |
1688 | vty_out(vty, " OSPF NSM debugging is on\n"); | |
1689 | else { | |
1690 | if (IS_DEBUG_OSPF(nsm, NSM_STATUS)) | |
1691 | vty_out(vty, " OSPF NSM status debugging is on\n"); | |
1692 | if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) | |
1693 | vty_out(vty, " OSPF NSM event debugging is on\n"); | |
1694 | if (IS_DEBUG_OSPF(nsm, NSM_TIMERS)) | |
1695 | vty_out(vty, " OSPF NSM timer debugging is on\n"); | |
1696 | } | |
1697 | ||
1698 | /* Show debug status for OSPF Packets. */ | |
1699 | for (i = 0; i < 5; i++) | |
1700 | if (IS_DEBUG_OSPF_PACKET(i, SEND) | |
1701 | && IS_DEBUG_OSPF_PACKET(i, RECV)) { | |
1702 | vty_out(vty, " OSPF packet %s%s debugging is on\n", | |
1703 | lookup_msg(ospf_packet_type_str, i + 1, NULL), | |
1704 | IS_DEBUG_OSPF_PACKET(i, DETAIL) ? " detail" | |
1705 | : ""); | |
1706 | } else { | |
1707 | if (IS_DEBUG_OSPF_PACKET(i, SEND)) | |
1708 | vty_out(vty, | |
1709 | " OSPF packet %s send%s debugging is on\n", | |
1710 | lookup_msg(ospf_packet_type_str, i + 1, | |
1711 | NULL), | |
1712 | IS_DEBUG_OSPF_PACKET(i, DETAIL) | |
1713 | ? " detail" | |
1714 | : ""); | |
1715 | if (IS_DEBUG_OSPF_PACKET(i, RECV)) | |
1716 | vty_out(vty, | |
1717 | " OSPF packet %s receive%s debugging is on\n", | |
1718 | lookup_msg(ospf_packet_type_str, i + 1, | |
1719 | NULL), | |
1720 | IS_DEBUG_OSPF_PACKET(i, DETAIL) | |
1721 | ? " detail" | |
1722 | : ""); | |
1723 | } | |
1724 | ||
1725 | /* Show debug status for OSPF LSAs. */ | |
1726 | if (IS_DEBUG_OSPF(lsa, LSA) == OSPF_DEBUG_LSA) | |
1727 | vty_out(vty, " OSPF LSA debugging is on\n"); | |
1728 | else { | |
1729 | if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) | |
1730 | vty_out(vty, " OSPF LSA generation debugging is on\n"); | |
1731 | if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
1732 | vty_out(vty, " OSPF LSA flooding debugging is on\n"); | |
1733 | if (IS_DEBUG_OSPF(lsa, LSA_INSTALL)) | |
1734 | vty_out(vty, " OSPF LSA install debugging is on\n"); | |
1735 | if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) | |
1736 | vty_out(vty, " OSPF LSA refresh debugging is on\n"); | |
1737 | } | |
1738 | ||
1739 | /* Show debug status for Zebra. */ | |
1740 | if (IS_DEBUG_OSPF(zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) | |
1741 | vty_out(vty, " OSPF Zebra debugging is on\n"); | |
1742 | else { | |
1743 | if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) | |
1744 | vty_out(vty, | |
1745 | " OSPF Zebra interface debugging is on\n"); | |
1746 | if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) | |
1747 | vty_out(vty, | |
1748 | " OSPF Zebra redistribute debugging is on\n"); | |
1749 | } | |
1750 | ||
1febb13d S |
1751 | if (IS_DEBUG_OSPF(defaultinfo, DEFAULTINFO) == OSPF_DEBUG_DEFAULTINFO) |
1752 | vty_out(vty, "OSPF default information is on\n"); | |
1753 | ||
d62a17ae | 1754 | /* Show debug status for NSSA. */ |
1755 | if (IS_DEBUG_OSPF(nssa, NSSA) == OSPF_DEBUG_NSSA) | |
1756 | vty_out(vty, " OSPF NSSA debugging is on\n"); | |
1757 | ||
132a782e | 1758 | /* Show debug status for LDP-SYNC. */ |
1759 | if (IS_DEBUG_OSPF(ldp_sync, LDP_SYNC) == OSPF_DEBUG_LDP_SYNC) | |
1760 | vty_out(vty, " OSPF ldp-sync debugging is on\n"); | |
1761 | ||
3f87e1d8 G |
1762 | /* Show debug status for GR. */ |
1763 | if (IS_DEBUG_OSPF(gr, GR) == OSPF_DEBUG_GR) | |
1764 | vty_out(vty, " OSPF Graceful Restart debugging is on\n"); | |
caa1cd9e | 1765 | |
e4505a2e RZ |
1766 | if (IS_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB) |
1767 | vty_out(vty, | |
1768 | " OSPF BFD integration library debugging is on\n"); | |
1769 | ||
d62a17ae | 1770 | vty_out(vty, "\n"); |
1771 | ||
1772 | return CMD_SUCCESS; | |
718e3744 | 1773 | } |
1774 | ||
87f6dc50 DS |
1775 | DEFUN_NOSH (show_debugging_ospf, |
1776 | show_debugging_ospf_cmd, | |
1777 | "show debugging [ospf]", | |
1778 | SHOW_STR | |
1779 | DEBUG_STR | |
1780 | OSPF_STR) | |
7c8ff89e | 1781 | { |
409f98ab | 1782 | return show_debugging_ospf_common(vty); |
7c8ff89e DS |
1783 | } |
1784 | ||
87f6dc50 DS |
1785 | DEFUN_NOSH (show_debugging_ospf_instance, |
1786 | show_debugging_ospf_instance_cmd, | |
1787 | "show debugging ospf (1-65535)", | |
1788 | SHOW_STR | |
1789 | DEBUG_STR | |
1790 | OSPF_STR | |
1791 | "Instance ID\n") | |
7c8ff89e | 1792 | { |
d62a17ae | 1793 | int idx_number = 3; |
d7c0a89a | 1794 | unsigned short instance = 0; |
7c8ff89e | 1795 | |
d62a17ae | 1796 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
409f98ab IR |
1797 | if (instance != ospf_instance) |
1798 | return CMD_NOT_MY_INSTANCE; | |
7c8ff89e | 1799 | |
409f98ab | 1800 | return show_debugging_ospf_common(vty); |
7c8ff89e DS |
1801 | } |
1802 | ||
612c2c15 | 1803 | static int config_write_debug(struct vty *vty); |
718e3744 | 1804 | /* Debug node. */ |
d62a17ae | 1805 | static struct cmd_node debug_node = { |
f4b8291f | 1806 | .name = "debug", |
62b346ee DL |
1807 | .node = DEBUG_NODE, |
1808 | .prompt = "", | |
612c2c15 | 1809 | .config_write = config_write_debug, |
718e3744 | 1810 | }; |
1811 | ||
d62a17ae | 1812 | static int config_write_debug(struct vty *vty) |
718e3744 | 1813 | { |
d62a17ae | 1814 | int write = 0; |
1815 | int i, r; | |
1816 | ||
1817 | const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", | |
1818 | "ls-ack"}; | |
1819 | const char *detail_str[] = { | |
1820 | "", " send", " recv", "", | |
1821 | " detail", " send detail", " recv detail", " detail"}; | |
1822 | ||
d62a17ae | 1823 | char str[16]; |
1824 | memset(str, 0, 16); | |
1825 | ||
409f98ab IR |
1826 | if (ospf_instance) |
1827 | snprintf(str, sizeof(str), " %u", ospf_instance); | |
d62a17ae | 1828 | |
1829 | /* debug ospf ism (status|events|timers). */ | |
1830 | if (IS_CONF_DEBUG_OSPF(ism, ISM) == OSPF_DEBUG_ISM) | |
1831 | vty_out(vty, "debug ospf%s ism\n", str); | |
1832 | else { | |
1833 | if (IS_CONF_DEBUG_OSPF(ism, ISM_STATUS)) | |
1834 | vty_out(vty, "debug ospf%s ism status\n", str); | |
1835 | if (IS_CONF_DEBUG_OSPF(ism, ISM_EVENTS)) | |
1836 | vty_out(vty, "debug ospf%s ism event\n", str); | |
1837 | if (IS_CONF_DEBUG_OSPF(ism, ISM_TIMERS)) | |
1838 | vty_out(vty, "debug ospf%s ism timer\n", str); | |
1839 | } | |
1840 | ||
1841 | /* debug ospf nsm (status|events|timers). */ | |
1842 | if (IS_CONF_DEBUG_OSPF(nsm, NSM) == OSPF_DEBUG_NSM) | |
1843 | vty_out(vty, "debug ospf%s nsm\n", str); | |
1844 | else { | |
1845 | if (IS_CONF_DEBUG_OSPF(nsm, NSM_STATUS)) | |
1846 | vty_out(vty, "debug ospf%s nsm status\n", str); | |
1847 | if (IS_CONF_DEBUG_OSPF(nsm, NSM_EVENTS)) | |
1848 | vty_out(vty, "debug ospf%s nsm event\n", str); | |
1849 | if (IS_CONF_DEBUG_OSPF(nsm, NSM_TIMERS)) | |
1850 | vty_out(vty, "debug ospf%s nsm timer\n", str); | |
1851 | } | |
1852 | ||
1853 | /* debug ospf lsa (generate|flooding|install|refresh). */ | |
1854 | if (IS_CONF_DEBUG_OSPF(lsa, LSA) == OSPF_DEBUG_LSA) | |
1855 | vty_out(vty, "debug ospf%s lsa\n", str); | |
1856 | else { | |
1857 | if (IS_CONF_DEBUG_OSPF(lsa, LSA_GENERATE)) | |
1858 | vty_out(vty, "debug ospf%s lsa generate\n", str); | |
1859 | if (IS_CONF_DEBUG_OSPF(lsa, LSA_FLOODING)) | |
1860 | vty_out(vty, "debug ospf%s lsa flooding\n", str); | |
1861 | if (IS_CONF_DEBUG_OSPF(lsa, LSA_INSTALL)) | |
1862 | vty_out(vty, "debug ospf%s lsa install\n", str); | |
1863 | if (IS_CONF_DEBUG_OSPF(lsa, LSA_REFRESH)) | |
1864 | vty_out(vty, "debug ospf%s lsa refresh\n", str); | |
1865 | ||
1866 | write = 1; | |
1867 | } | |
1868 | ||
1869 | /* debug ospf zebra (interface|redistribute). */ | |
1870 | if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA) == OSPF_DEBUG_ZEBRA) | |
1871 | vty_out(vty, "debug ospf%s zebra\n", str); | |
1872 | else { | |
1873 | if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) | |
1874 | vty_out(vty, "debug ospf%s zebra interface\n", str); | |
1875 | if (IS_CONF_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) | |
1876 | vty_out(vty, "debug ospf%s zebra redistribute\n", str); | |
1877 | ||
1878 | write = 1; | |
1879 | } | |
1880 | ||
1881 | /* debug ospf event. */ | |
1882 | if (IS_CONF_DEBUG_OSPF(event, EVENT) == OSPF_DEBUG_EVENT) { | |
1883 | vty_out(vty, "debug ospf%s event\n", str); | |
1884 | write = 1; | |
1885 | } | |
1886 | ||
1887 | /* debug ospf nssa. */ | |
1888 | if (IS_CONF_DEBUG_OSPF(nssa, NSSA) == OSPF_DEBUG_NSSA) { | |
1889 | vty_out(vty, "debug ospf%s nssa\n", str); | |
1890 | write = 1; | |
1891 | } | |
1892 | ||
1893 | /* debug ospf packet all detail. */ | |
1894 | r = OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL; | |
1895 | for (i = 0; i < 5; i++) | |
1896 | r &= conf_debug_ospf_packet[i] | |
1897 | & (OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL); | |
1898 | if (r == (OSPF_DEBUG_SEND_RECV | OSPF_DEBUG_DETAIL)) { | |
1899 | vty_out(vty, "debug ospf%s packet all detail\n", str); | |
1900 | return 1; | |
1901 | } | |
1902 | ||
1903 | /* debug ospf packet all. */ | |
1904 | r = OSPF_DEBUG_SEND_RECV; | |
1905 | for (i = 0; i < 5; i++) | |
1906 | r &= conf_debug_ospf_packet[i] & OSPF_DEBUG_SEND_RECV; | |
1907 | if (r == OSPF_DEBUG_SEND_RECV) { | |
1908 | vty_out(vty, "debug ospf%s packet all\n", str); | |
1909 | for (i = 0; i < 5; i++) | |
1910 | if (conf_debug_ospf_packet[i] & OSPF_DEBUG_DETAIL) | |
1911 | vty_out(vty, "debug ospf%s packet %s detail\n", | |
1912 | str, type_str[i]); | |
1913 | return 1; | |
1914 | } | |
1915 | ||
1916 | /* debug ospf packet (hello|dd|ls-request|ls-update|ls-ack) | |
1917 | (send|recv) (detail). */ | |
1918 | for (i = 0; i < 5; i++) { | |
1919 | if (conf_debug_ospf_packet[i] == 0) | |
1920 | continue; | |
1921 | ||
1922 | vty_out(vty, "debug ospf%s packet %s%s\n", str, type_str[i], | |
1923 | detail_str[conf_debug_ospf_packet[i]]); | |
1924 | write = 1; | |
1925 | } | |
1926 | ||
7743f2f8 OD |
1927 | /* debug ospf te */ |
1928 | if (IS_CONF_DEBUG_OSPF(te, TE) == OSPF_DEBUG_TE) { | |
1929 | vty_out(vty, "debug ospf%s te\n", str); | |
1930 | write = 1; | |
1931 | } | |
1932 | ||
1933 | /* debug ospf sr */ | |
1934 | if (IS_CONF_DEBUG_OSPF(sr, SR) == OSPF_DEBUG_SR) { | |
1935 | vty_out(vty, "debug ospf%s sr\n", str); | |
1936 | write = 1; | |
1937 | } | |
1938 | ||
a4553b5b G |
1939 | /* debug ospf sr ti-lfa */ |
1940 | if (IS_CONF_DEBUG_OSPF(sr, TI_LFA) == OSPF_DEBUG_TI_LFA) { | |
1941 | vty_out(vty, "debug ospf%s ti-lfa\n", str); | |
1942 | write = 1; | |
1943 | } | |
1944 | ||
132a782e | 1945 | /* debug ospf ldp-sync */ |
1946 | if (IS_CONF_DEBUG_OSPF(ldp_sync, LDP_SYNC) == OSPF_DEBUG_LDP_SYNC) { | |
1947 | vty_out(vty, "debug ospf%s ldp-sync\n", str); | |
1948 | write = 1; | |
1949 | } | |
caa1cd9e | 1950 | |
3f87e1d8 G |
1951 | /* debug ospf gr */ |
1952 | if (IS_CONF_DEBUG_OSPF(gr, GR) == OSPF_DEBUG_GR) { | |
1953 | vty_out(vty, "debug ospf%s graceful-restart\n", str); | |
caa1cd9e | 1954 | write = 1; |
1955 | } | |
1956 | ||
e4505a2e RZ |
1957 | if (IS_CONF_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB) { |
1958 | vty_out(vty, "debug ospf%s bfd\n", str); | |
1959 | write = 1; | |
1960 | } | |
1961 | ||
d62a17ae | 1962 | return write; |
718e3744 | 1963 | } |
1964 | ||
1965 | /* Initialize debug commands. */ | |
6243a7b5 | 1966 | void ospf_debug_init(void) |
718e3744 | 1967 | { |
612c2c15 | 1968 | install_node(&debug_node); |
d62a17ae | 1969 | |
1970 | install_element(ENABLE_NODE, &show_debugging_ospf_cmd); | |
1971 | install_element(ENABLE_NODE, &debug_ospf_ism_cmd); | |
1972 | install_element(ENABLE_NODE, &debug_ospf_nsm_cmd); | |
1973 | install_element(ENABLE_NODE, &debug_ospf_lsa_cmd); | |
1974 | install_element(ENABLE_NODE, &debug_ospf_zebra_cmd); | |
1975 | install_element(ENABLE_NODE, &debug_ospf_event_cmd); | |
1976 | install_element(ENABLE_NODE, &debug_ospf_nssa_cmd); | |
1977 | install_element(ENABLE_NODE, &debug_ospf_te_cmd); | |
cf9b9f77 | 1978 | install_element(ENABLE_NODE, &debug_ospf_sr_cmd); |
a4553b5b | 1979 | install_element(ENABLE_NODE, &debug_ospf_ti_lfa_cmd); |
1febb13d | 1980 | install_element(ENABLE_NODE, &debug_ospf_default_info_cmd); |
132a782e | 1981 | install_element(ENABLE_NODE, &debug_ospf_ldp_sync_cmd); |
d62a17ae | 1982 | install_element(ENABLE_NODE, &no_debug_ospf_ism_cmd); |
1983 | install_element(ENABLE_NODE, &no_debug_ospf_nsm_cmd); | |
1984 | install_element(ENABLE_NODE, &no_debug_ospf_lsa_cmd); | |
1985 | install_element(ENABLE_NODE, &no_debug_ospf_zebra_cmd); | |
1986 | install_element(ENABLE_NODE, &no_debug_ospf_event_cmd); | |
1987 | install_element(ENABLE_NODE, &no_debug_ospf_nssa_cmd); | |
1988 | install_element(ENABLE_NODE, &no_debug_ospf_te_cmd); | |
cf9b9f77 | 1989 | install_element(ENABLE_NODE, &no_debug_ospf_sr_cmd); |
a4553b5b | 1990 | install_element(ENABLE_NODE, &no_debug_ospf_ti_lfa_cmd); |
1febb13d | 1991 | install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd); |
132a782e | 1992 | install_element(ENABLE_NODE, &no_debug_ospf_ldp_sync_cmd); |
caa1cd9e | 1993 | install_element(ENABLE_NODE, &debug_ospf_gr_cmd); |
e4505a2e | 1994 | install_element(ENABLE_NODE, &debug_ospf_bfd_cmd); |
d62a17ae | 1995 | |
1996 | install_element(ENABLE_NODE, &show_debugging_ospf_instance_cmd); | |
1997 | install_element(ENABLE_NODE, &debug_ospf_packet_cmd); | |
1998 | install_element(ENABLE_NODE, &no_debug_ospf_packet_cmd); | |
1999 | ||
2000 | install_element(ENABLE_NODE, &debug_ospf_instance_nsm_cmd); | |
2001 | install_element(ENABLE_NODE, &debug_ospf_instance_lsa_cmd); | |
2002 | install_element(ENABLE_NODE, &debug_ospf_instance_zebra_cmd); | |
2003 | install_element(ENABLE_NODE, &debug_ospf_instance_event_cmd); | |
2004 | install_element(ENABLE_NODE, &debug_ospf_instance_nssa_cmd); | |
2005 | install_element(ENABLE_NODE, &no_debug_ospf_instance_nsm_cmd); | |
2006 | install_element(ENABLE_NODE, &no_debug_ospf_instance_lsa_cmd); | |
2007 | install_element(ENABLE_NODE, &no_debug_ospf_instance_zebra_cmd); | |
2008 | install_element(ENABLE_NODE, &no_debug_ospf_instance_event_cmd); | |
2009 | install_element(ENABLE_NODE, &no_debug_ospf_instance_nssa_cmd); | |
2010 | install_element(ENABLE_NODE, &no_debug_ospf_cmd); | |
2011 | ||
2012 | install_element(CONFIG_NODE, &debug_ospf_packet_cmd); | |
2013 | install_element(CONFIG_NODE, &no_debug_ospf_packet_cmd); | |
2014 | install_element(CONFIG_NODE, &debug_ospf_ism_cmd); | |
2015 | install_element(CONFIG_NODE, &no_debug_ospf_ism_cmd); | |
2016 | ||
2017 | install_element(CONFIG_NODE, &debug_ospf_nsm_cmd); | |
2018 | install_element(CONFIG_NODE, &debug_ospf_lsa_cmd); | |
2019 | install_element(CONFIG_NODE, &debug_ospf_zebra_cmd); | |
2020 | install_element(CONFIG_NODE, &debug_ospf_event_cmd); | |
2021 | install_element(CONFIG_NODE, &debug_ospf_nssa_cmd); | |
2022 | install_element(CONFIG_NODE, &debug_ospf_te_cmd); | |
cf9b9f77 | 2023 | install_element(CONFIG_NODE, &debug_ospf_sr_cmd); |
a4553b5b | 2024 | install_element(CONFIG_NODE, &debug_ospf_ti_lfa_cmd); |
1febb13d | 2025 | install_element(CONFIG_NODE, &debug_ospf_default_info_cmd); |
132a782e | 2026 | install_element(CONFIG_NODE, &debug_ospf_ldp_sync_cmd); |
d62a17ae | 2027 | install_element(CONFIG_NODE, &no_debug_ospf_nsm_cmd); |
2028 | install_element(CONFIG_NODE, &no_debug_ospf_lsa_cmd); | |
2029 | install_element(CONFIG_NODE, &no_debug_ospf_zebra_cmd); | |
2030 | install_element(CONFIG_NODE, &no_debug_ospf_event_cmd); | |
2031 | install_element(CONFIG_NODE, &no_debug_ospf_nssa_cmd); | |
2032 | install_element(CONFIG_NODE, &no_debug_ospf_te_cmd); | |
cf9b9f77 | 2033 | install_element(CONFIG_NODE, &no_debug_ospf_sr_cmd); |
a4553b5b | 2034 | install_element(CONFIG_NODE, &no_debug_ospf_ti_lfa_cmd); |
1febb13d | 2035 | install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd); |
132a782e | 2036 | install_element(CONFIG_NODE, &no_debug_ospf_ldp_sync_cmd); |
caa1cd9e | 2037 | install_element(CONFIG_NODE, &debug_ospf_gr_cmd); |
e4505a2e | 2038 | install_element(CONFIG_NODE, &debug_ospf_bfd_cmd); |
d62a17ae | 2039 | |
2040 | install_element(CONFIG_NODE, &debug_ospf_instance_nsm_cmd); | |
2041 | install_element(CONFIG_NODE, &debug_ospf_instance_lsa_cmd); | |
2042 | install_element(CONFIG_NODE, &debug_ospf_instance_zebra_cmd); | |
2043 | install_element(CONFIG_NODE, &debug_ospf_instance_event_cmd); | |
2044 | install_element(CONFIG_NODE, &debug_ospf_instance_nssa_cmd); | |
2045 | install_element(CONFIG_NODE, &no_debug_ospf_instance_nsm_cmd); | |
2046 | install_element(CONFIG_NODE, &no_debug_ospf_instance_lsa_cmd); | |
2047 | install_element(CONFIG_NODE, &no_debug_ospf_instance_zebra_cmd); | |
2048 | install_element(CONFIG_NODE, &no_debug_ospf_instance_event_cmd); | |
2049 | install_element(CONFIG_NODE, &no_debug_ospf_instance_nssa_cmd); | |
2050 | install_element(CONFIG_NODE, &no_debug_ospf_cmd); | |
718e3744 | 2051 | } |