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