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