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