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