]>
Commit | Line | Data |
---|---|---|
7f57883e DS |
1 | /* |
2 | * EIGRP Dump Functions and Debugging. | |
3 | * Copyright (C) 2013-2014 | |
4 | * Authors: | |
5 | * Donnie Savage | |
6 | * Jan Janovic | |
7 | * Matej Perina | |
8 | * Peter Orsag | |
9 | * Peter Paluch | |
10 | * | |
11 | * This file is part of GNU Zebra. | |
12 | * | |
13 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
14 | * under the terms of the GNU General Public License as published by the | |
15 | * Free Software Foundation; either version 2, or (at your option) any | |
16 | * later version. | |
17 | * | |
18 | * GNU Zebra is distributed in the hope that it will be useful, but | |
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | * General Public License for more details. | |
22 | * | |
896014f4 DL |
23 | * You should have received a copy of the GNU General Public License along |
24 | * with this program; see the file COPYING; if not, write to the Free Software | |
25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
7f57883e DS |
26 | */ |
27 | ||
28 | #include <zebra.h> | |
29 | ||
30 | #include "linklist.h" | |
31 | #include "thread.h" | |
32 | #include "prefix.h" | |
33 | #include "command.h" | |
34 | #include "stream.h" | |
35 | #include "log.h" | |
36 | #include "sockopt.h" | |
37 | #include "table.h" | |
38 | #include "keychain.h" | |
39 | ||
40 | #include "eigrpd/eigrp_structs.h" | |
41 | #include "eigrpd/eigrpd.h" | |
42 | #include "eigrpd/eigrp_interface.h" | |
43 | #include "eigrpd/eigrp_neighbor.h" | |
44 | #include "eigrpd/eigrp_packet.h" | |
45 | #include "eigrpd/eigrp_zebra.h" | |
46 | #include "eigrpd/eigrp_vty.h" | |
47 | #include "eigrpd/eigrp_network.h" | |
48 | #include "eigrpd/eigrp_dump.h" | |
49 | #include "eigrpd/eigrp_topology.h" | |
50 | ||
51 | /* Enable debug option variables -- valid only session. */ | |
52 | unsigned long term_debug_eigrp = 0; | |
53 | unsigned long term_debug_eigrp_nei = 0; | |
54 | unsigned long term_debug_eigrp_packet[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
55 | unsigned long term_debug_eigrp_zebra = 6; | |
56 | unsigned long term_debug_eigrp_transmit = 0; | |
57 | ||
58 | /* Configuration debug option variables. */ | |
59 | unsigned long conf_debug_eigrp = 0; | |
60 | unsigned long conf_debug_eigrp_nei = 0; | |
61 | unsigned long conf_debug_eigrp_packet[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
62 | unsigned long conf_debug_eigrp_zebra = 0; | |
63 | unsigned long conf_debug_eigrp_transmit = 0; | |
64 | ||
65 | ||
66 | static int | |
67 | config_write_debug (struct vty *vty) | |
68 | { | |
69 | int write = 0; | |
70 | int i; | |
71 | ||
f9e5c9ca DS |
72 | const char *type_str[] = {"update", "request", "query", "reply", |
73 | "hello", "", "probe", "ack", "", | |
74 | "SIA query", "SIA reply", "stub", "all"}; | |
7f57883e | 75 | const char *detail_str[] = {"", " send", " recv", "", " detail", |
f9e5c9ca | 76 | " send detail", " recv detail", " detail"}; |
7f57883e DS |
77 | |
78 | ||
79 | /* debug eigrp event. */ | |
7f57883e DS |
80 | |
81 | /* debug eigrp packet */ | |
82 | for (i = 0; i < 10; i++) | |
83 | { | |
f9e5c9ca DS |
84 | if (conf_debug_eigrp_packet[i] == 0 && term_debug_eigrp_packet[i] == 0 ) |
85 | continue; | |
7f57883e | 86 | |
f9e5c9ca DS |
87 | vty_out (vty, "debug eigrp packet %s%s%s", |
88 | type_str[i], detail_str[conf_debug_eigrp_packet[i]], | |
89 | VTY_NEWLINE); | |
90 | write = 1; | |
7f57883e DS |
91 | } |
92 | ||
7f57883e DS |
93 | return write; |
94 | } | |
95 | ||
7f57883e DS |
96 | static int |
97 | eigrp_neighbor_packet_queue_sum (struct eigrp_interface *ei) | |
98 | { | |
99 | struct eigrp_neighbor *nbr; | |
100 | struct listnode *node, *nnode; | |
101 | int sum; | |
102 | sum = 0; | |
103 | ||
104 | for (ALL_LIST_ELEMENTS (ei->nbrs, node, nnode, nbr)) | |
105 | { | |
106 | sum += nbr->retrans_queue->count; | |
107 | } | |
108 | ||
109 | return sum; | |
110 | } | |
111 | ||
112 | /* | |
113 | * Expects header to be in host order | |
114 | */ | |
115 | void | |
116 | eigrp_ip_header_dump (struct ip *iph) | |
117 | { | |
118 | /* IP Header dump. */ | |
119 | zlog_debug ("ip_v %u", iph->ip_v); | |
120 | zlog_debug ("ip_hl %u", iph->ip_hl); | |
121 | zlog_debug ("ip_tos %u", iph->ip_tos); | |
122 | zlog_debug ("ip_len %u", iph->ip_len); | |
123 | zlog_debug ("ip_id %u", (u_int32_t) iph->ip_id); | |
124 | zlog_debug ("ip_off %u", (u_int32_t) iph->ip_off); | |
125 | zlog_debug ("ip_ttl %u", iph->ip_ttl); | |
126 | zlog_debug ("ip_p %u", iph->ip_p); | |
127 | zlog_debug ("ip_sum 0x%x", (u_int32_t) iph->ip_sum); | |
128 | zlog_debug ("ip_src %s", inet_ntoa (iph->ip_src)); | |
129 | zlog_debug ("ip_dst %s", inet_ntoa (iph->ip_dst)); | |
130 | } | |
131 | ||
132 | /* | |
133 | * Expects header to be in host order | |
134 | */ | |
135 | void | |
136 | eigrp_header_dump (struct eigrp_header *eigrph) | |
137 | { | |
138 | /* EIGRP Header dump. */ | |
f9e5c9ca DS |
139 | zlog_debug ("eigrp_version %u", eigrph->version); |
140 | zlog_debug ("eigrp_opcode %u", eigrph->opcode); | |
141 | zlog_debug ("eigrp_checksum 0x%x", ntohs(eigrph->checksum)); | |
142 | zlog_debug ("eigrp_flags 0x%x", ntohl(eigrph->flags)); | |
143 | zlog_debug ("eigrp_sequence %u", ntohl(eigrph->sequence)); | |
144 | zlog_debug ("eigrp_ack %u", ntohl(eigrph->ack)); | |
145 | zlog_debug ("eigrp_vrid %u", ntohs(eigrph->vrid)); | |
146 | zlog_debug ("eigrp_AS %u", ntohs(eigrph->ASNumber)); | |
7f57883e DS |
147 | } |
148 | ||
149 | const char * | |
150 | eigrp_if_name_string (struct eigrp_interface *ei) | |
151 | { | |
152 | static char buf[EIGRP_IF_STRING_MAXLEN] = ""; | |
153 | ||
154 | if (!ei) | |
155 | return "inactive"; | |
156 | ||
157 | snprintf (buf, EIGRP_IF_STRING_MAXLEN, | |
158 | "%s", ei->ifp->name); | |
159 | return buf; | |
160 | } | |
161 | ||
162 | const char * | |
163 | eigrp_topology_ip_string (struct eigrp_prefix_entry *tn) | |
164 | { | |
165 | static char buf[EIGRP_IF_STRING_MAXLEN] = ""; | |
166 | u_int32_t ifaddr; | |
167 | ||
168 | ifaddr = ntohl (tn->destination_ipv4->prefix.s_addr); | |
169 | snprintf (buf, EIGRP_IF_STRING_MAXLEN, | |
170 | "%u.%u.%u.%u", | |
171 | (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff, | |
172 | (ifaddr >> 8) & 0xff, ifaddr & 0xff); | |
173 | return buf; | |
174 | } | |
175 | ||
176 | ||
177 | const char * | |
178 | eigrp_if_ip_string (struct eigrp_interface *ei) | |
179 | { | |
180 | static char buf[EIGRP_IF_STRING_MAXLEN] = ""; | |
181 | u_int32_t ifaddr; | |
182 | ||
183 | if (!ei) | |
184 | return "inactive"; | |
185 | ||
186 | ifaddr = ntohl (ei->address->u.prefix4.s_addr); | |
187 | snprintf (buf, EIGRP_IF_STRING_MAXLEN, | |
188 | "%u.%u.%u.%u", | |
189 | (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff, | |
190 | (ifaddr >> 8) & 0xff, ifaddr & 0xff); | |
191 | ||
192 | return buf; | |
193 | } | |
194 | ||
195 | const char * | |
196 | eigrp_neigh_ip_string (struct eigrp_neighbor *nbr) | |
197 | { | |
198 | static char buf[EIGRP_IF_STRING_MAXLEN] = ""; | |
199 | u_int32_t ifaddr; | |
200 | ||
201 | ifaddr = ntohl (nbr->src.s_addr); | |
202 | snprintf (buf, EIGRP_IF_STRING_MAXLEN, | |
203 | "%u.%u.%u.%u", | |
204 | (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff, | |
205 | (ifaddr >> 8) & 0xff, ifaddr & 0xff); | |
206 | ||
207 | return buf; | |
208 | } | |
209 | ||
210 | void | |
211 | show_ip_eigrp_interface_header (struct vty *vty, struct eigrp *eigrp) | |
212 | { | |
213 | ||
214 | vty_out (vty, "%s%s%d%s%s%s %-10s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s%s %-39s %-12s %-7s %-14s %-12s %-8s%s", | |
215 | VTY_NEWLINE, | |
216 | "EIGRP interfaces for AS(",eigrp->AS,")",VTY_NEWLINE,VTY_NEWLINE, | |
217 | "Interface", "Bandwidth", "Delay", "Peers", "Xmit Queue", "Mean", | |
218 | "Pacing Time", "Multicast", "Pending", "Hello", "Holdtime", | |
219 | VTY_NEWLINE,"","Un/Reliable","SRTT","Un/Reliable","Flow Timer","Routes", | |
220 | VTY_NEWLINE); | |
221 | } | |
222 | ||
223 | void | |
224 | show_ip_eigrp_interface_sub (struct vty *vty, struct eigrp *eigrp, | |
f9e5c9ca | 225 | struct eigrp_interface *ei) |
7f57883e DS |
226 | { |
227 | vty_out (vty, "%-11s ", eigrp_if_name_string (ei)); | |
f9e5c9ca DS |
228 | vty_out (vty, "%-11u", IF_DEF_PARAMS (ei->ifp)->bandwidth); |
229 | vty_out (vty, "%-11u", IF_DEF_PARAMS (ei->ifp)->delay); | |
7f57883e | 230 | vty_out (vty, "%-7u", ei->nbrs->count); |
f9e5c9ca DS |
231 | vty_out (vty, "%u %c %-10u",0,'/', eigrp_neighbor_packet_queue_sum (ei)); |
232 | vty_out (vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0); | |
233 | vty_out (vty, "%-8u %-8u %s", | |
234 | IF_DEF_PARAMS (ei->ifp)->v_hello, | |
235 | IF_DEF_PARAMS (ei->ifp)->v_wait,VTY_NEWLINE); | |
7f57883e DS |
236 | } |
237 | ||
238 | void | |
239 | show_ip_eigrp_interface_detail (struct vty *vty, struct eigrp *eigrp, | |
f9e5c9ca | 240 | struct eigrp_interface *ei) |
7f57883e | 241 | { |
f9e5c9ca DS |
242 | vty_out (vty, "%-2s %s %d %-3s %s","","Hello interval is ", 0, " sec", VTY_NEWLINE); |
243 | vty_out (vty, "%-2s %s %s %s","", "Next xmit serial","<none>", VTY_NEWLINE); | |
244 | vty_out (vty, "%-2s %s %d %s %d %s %d %s %d %s", | |
245 | "", "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", | |
246 | 0, "/", 0, VTY_NEWLINE); | |
247 | vty_out (vty, "%-2s %s %d %s %d %s %d %s", | |
248 | "", "Mcast exceptions: ", 0, " CR packets: ", | |
249 | 0, " ACKs supressed: ", 0, VTY_NEWLINE); | |
250 | vty_out (vty, "%-2s %s %d %s %d %s", | |
251 | "", "Retransmissions sent: ", 0, "Out-of-sequence rcvd: ", | |
252 | 0 ,VTY_NEWLINE); | |
253 | vty_out (vty, "%-2s %s %s %s %s", | |
254 | "", "Authentication mode is ", "not","set", VTY_NEWLINE); | |
255 | vty_out (vty, "%-2s %s %s", "", "Use multicast", VTY_NEWLINE); | |
7f57883e DS |
256 | } |
257 | ||
258 | void | |
259 | show_ip_eigrp_neighbor_header (struct vty *vty, struct eigrp *eigrp) | |
260 | { | |
261 | vty_out (vty, "%s%s%d%s%s%s%-3s %-17s %-20s %-6s %-8s %-6s %-5s %-5s %-5s%s %-41s %-6s %-8s %-6s %-4s %-6s %-5s %s", | |
262 | VTY_NEWLINE, | |
263 | "EIGRP neighbors for AS(",eigrp->AS,")",VTY_NEWLINE,VTY_NEWLINE, | |
264 | "H", "Address", "Interface", "Hold", "Uptime", | |
265 | "SRTT", "RTO", "Q", "Seq", VTY_NEWLINE | |
266 | ,"","(sec)","","(ms)","","Cnt","Num", VTY_NEWLINE); | |
267 | } | |
268 | ||
269 | void | |
270 | show_ip_eigrp_neighbor_sub (struct vty *vty, struct eigrp_neighbor *nbr, | |
f9e5c9ca | 271 | int detail) |
7f57883e DS |
272 | { |
273 | ||
f9e5c9ca DS |
274 | vty_out (vty, "%-3u %-17s %-21s", 0, |
275 | eigrp_neigh_ip_string (nbr), eigrp_if_name_string (nbr->ei)); | |
276 | vty_out (vty,"%-7lu", thread_timer_remain_second (nbr->t_holddown)); | |
277 | vty_out (vty,"%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME); | |
278 | vty_out (vty,"%-7lu", nbr->retrans_queue->count); | |
279 | vty_out (vty,"%u%s", nbr->recv_sequence_number, VTY_NEWLINE); | |
7f57883e DS |
280 | |
281 | ||
282 | if (detail) | |
283 | { | |
284 | vty_out(vty," Version %u.%u/%u.%u", | |
f9e5c9ca DS |
285 | nbr->os_rel_major, nbr->os_rel_minor, |
286 | nbr->tlv_rel_major, nbr->tlv_rel_minor); | |
7f57883e | 287 | vty_out(vty,", Retrans: %lu, Retries: %lu", |
f9e5c9ca | 288 | nbr->retrans_queue->count, 0UL); |
7f57883e DS |
289 | vty_out(vty,", %s%s", eigrp_nbr_state_str(nbr), VTY_NEWLINE); |
290 | } | |
291 | } | |
292 | ||
293 | /* | |
294 | * Print standard header for show EIGRP topology output | |
295 | */ | |
296 | void | |
297 | show_ip_eigrp_topology_header (struct vty *vty, struct eigrp *eigrp) | |
298 | { | |
299 | struct in_addr router_id; | |
1ad13df9 | 300 | router_id.s_addr = eigrp->router_id; |
7f57883e | 301 | |
1ad13df9 DS |
302 | vty_out (vty, "%sEIGRP Topology Table for AS(%d)/ID(%s)%s%s", |
303 | VTY_NEWLINE, eigrp->AS, inet_ntoa(router_id), VTY_NEWLINE, VTY_NEWLINE); | |
304 | vty_out (vty, "Codes: P - Passive, A - Active, U - Update, Q - Query, " | |
305 | "R - Reply%s r - reply Status, s - sia Status%s%s", | |
306 | VTY_NEWLINE, VTY_NEWLINE,VTY_NEWLINE); | |
7f57883e DS |
307 | } |
308 | ||
309 | void | |
310 | show_ip_eigrp_prefix_entry (struct vty *vty, struct eigrp_prefix_entry *tn) | |
311 | { | |
057fad8d DS |
312 | struct list *successors = eigrp_topology_get_successor(tn); |
313 | ||
7f57883e | 314 | vty_out (vty, "%-3c",(tn->state > 0) ? 'A' : 'P'); |
910a5c0e | 315 | |
057fad8d DS |
316 | vty_out (vty, "%s/%u, ", |
317 | inet_ntoa (tn->destination_ipv4->prefix), tn->destination_ipv4->prefixlen); | |
318 | vty_out (vty, "%u successors, ", successors->count); | |
910a5c0e | 319 | vty_out (vty, "FD is %u, serno: %" PRIu64 " %s", tn->fdistance, tn->serno, VTY_NEWLINE); |
057fad8d DS |
320 | |
321 | list_delete(successors); | |
7f57883e DS |
322 | } |
323 | ||
324 | void | |
63863c47 RW |
325 | show_ip_eigrp_neighbor_entry (struct vty *vty, struct eigrp *eigrp, |
326 | struct eigrp_neighbor_entry *te, int *first) | |
7f57883e | 327 | { |
63863c47 RW |
328 | if (te->reported_distance == EIGRP_MAX_METRIC) |
329 | return; | |
330 | ||
331 | if (*first) | |
332 | { | |
333 | show_ip_eigrp_prefix_entry (vty, te->prefix); | |
334 | *first = 0; | |
335 | } | |
336 | ||
7f57883e | 337 | if (te->adv_router == eigrp->neighbor_self) |
f9e5c9ca DS |
338 | vty_out (vty, "%-7s%s, %s%s", " ", "via Connected", |
339 | eigrp_if_name_string (te->ei), VTY_NEWLINE); | |
7f57883e DS |
340 | else |
341 | { | |
f9e5c9ca DS |
342 | vty_out (vty, "%-7s%s%s (%u/%u), %s%s", |
343 | " ", "via ", inet_ntoa (te->adv_router->src), | |
344 | te->distance, te->reported_distance, | |
345 | eigrp_if_name_string (te->ei), VTY_NEWLINE); | |
7f57883e DS |
346 | } |
347 | } | |
348 | ||
349 | ||
350 | DEFUN (show_debugging_eigrp, | |
351 | show_debugging_eigrp_cmd, | |
352 | "show debugging eigrp", | |
353 | SHOW_STR | |
354 | DEBUG_STR | |
355 | EIGRP_STR) | |
356 | { | |
357 | int i; | |
358 | ||
359 | vty_out (vty, "EIGRP debugging status:%s", VTY_NEWLINE); | |
360 | ||
361 | /* Show debug status for events. */ | |
362 | if (IS_DEBUG_EIGRP(event,EVENT)) | |
363 | vty_out (vty, " EIGRP event debugging is on%s", VTY_NEWLINE); | |
364 | ||
365 | /* Show debug status for EIGRP Packets. */ | |
366 | for (i = 0; i < 11 ; i++) | |
f9e5c9ca | 367 | { |
7f57883e DS |
368 | if (i == 8) |
369 | continue; | |
370 | ||
f9e5c9ca DS |
371 | if (IS_DEBUG_EIGRP_PACKET (i, SEND) && IS_DEBUG_EIGRP_PACKET (i, RECV)) |
372 | { | |
373 | vty_out (vty, " EIGRP packet %s%s debugging is on%s", | |
374 | LOOKUP (eigrp_packet_type_str, i + 1), | |
375 | IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : "", | |
376 | VTY_NEWLINE); | |
377 | } | |
378 | else | |
379 | { | |
380 | if (IS_DEBUG_EIGRP_PACKET (i, SEND)) | |
381 | vty_out (vty, " EIGRP packet %s send%s debugging is on%s", | |
382 | LOOKUP (eigrp_packet_type_str, i + 1), | |
383 | IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : "", | |
384 | VTY_NEWLINE); | |
385 | if (IS_DEBUG_EIGRP_PACKET (i, RECV)) | |
386 | vty_out (vty, " EIGRP packet %s receive%s debugging is on%s", | |
387 | LOOKUP (eigrp_packet_type_str, i + 1), | |
388 | IS_DEBUG_EIGRP_PACKET (i, PACKET_DETAIL) ? " detail" : "", | |
389 | VTY_NEWLINE); | |
390 | } | |
391 | } | |
7f57883e DS |
392 | |
393 | return CMD_SUCCESS; | |
394 | } | |
395 | ||
396 | ||
397 | /* | |
f9e5c9ca DS |
398 | [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all) |
399 | [send|recv [detail]] | |
7f57883e DS |
400 | */ |
401 | ||
402 | DEFUN (debug_eigrp_transmit, | |
403 | debug_eigrp_transmit_cmd, | |
404 | "debug eigrp transmit <send|recv|all> [detail]", | |
405 | DEBUG_STR | |
406 | EIGRP_STR | |
407 | "EIGRP transmission events\n" | |
408 | "packet sent\n" | |
409 | "packet received\n" | |
410 | "all packets\n" | |
411 | "Detailed Information\n") | |
412 | { | |
413 | int flag = 0; | |
414 | int idx = 2; | |
415 | ||
416 | /* send or recv. */ | |
417 | if (argv_find (argv, argc, "send", &idx)) | |
418 | flag = EIGRP_DEBUG_SEND; | |
419 | else if (argv_find (argv, argc, "recv", &idx)) | |
420 | flag = EIGRP_DEBUG_RECV; | |
421 | else if (argv_find (argv, argc, "all", &idx) == 0) | |
422 | flag = EIGRP_DEBUG_SEND_RECV; | |
423 | ||
424 | /* detail option */ | |
425 | if (argv_find (argv, argc, "detail", &idx) == 0) | |
426 | flag = EIGRP_DEBUG_PACKET_DETAIL; | |
427 | ||
428 | if (vty->node == CONFIG_NODE) | |
429 | DEBUG_TRANSMIT_ON (0, flag); | |
430 | else | |
431 | TERM_DEBUG_TRANSMIT_ON (0, flag); | |
432 | ||
433 | return CMD_SUCCESS; | |
434 | } | |
435 | ||
436 | DEFUN (no_debug_eigrp_transmit, | |
437 | no_debug_eigrp_transmit_cmd, | |
438 | "no debug eigrp transmit <send|recv|all> [detail]", | |
439 | NO_STR | |
440 | UNDEBUG_STR | |
441 | EIGRP_STR | |
442 | "EIGRP transmission events\n" | |
443 | "packet sent\n" | |
444 | "packet received\n" | |
445 | "all packets\n" | |
446 | "Detailed Information\n") | |
447 | { | |
448 | int flag = 0; | |
449 | int idx = 3; | |
450 | ||
451 | /* send or recv. */ | |
452 | if (argv_find (argv, argc, "send", &idx) == 0) | |
453 | flag = EIGRP_DEBUG_SEND; | |
454 | else if (argv_find (argv, argc, "recv", &idx) == 0) | |
455 | flag = EIGRP_DEBUG_RECV; | |
456 | else if (argv_find (argv, argc, "all", &idx) == 0) | |
457 | flag = EIGRP_DEBUG_SEND_RECV; | |
458 | ||
459 | /* detail option */ | |
460 | if (argv_find (argv, argc, "detail", &idx) == 0) | |
461 | flag = EIGRP_DEBUG_PACKET_DETAIL; | |
462 | ||
463 | if (vty->node == CONFIG_NODE) | |
464 | DEBUG_TRANSMIT_OFF (0, flag); | |
465 | else | |
466 | TERM_DEBUG_TRANSMIT_OFF (0, flag); | |
467 | ||
468 | return CMD_SUCCESS; | |
469 | } | |
470 | ||
471 | DEFUN (debug_eigrp_packets, | |
472 | debug_eigrp_packets_all_cmd, | |
473 | "debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]", | |
474 | DEBUG_STR | |
475 | EIGRP_STR | |
476 | "EIGRP packets\n" | |
477 | "EIGRP SIA-Query packets\n" | |
478 | "EIGRP SIA-Reply packets\n" | |
479 | "EIGRP ack packets\n" | |
480 | "EIGRP hello packets\n" | |
481 | "EIGRP probe packets\n" | |
482 | "EIGRP query packets\n" | |
483 | "EIGRP reply packets\n" | |
484 | "EIGRP request packets\n" | |
485 | "EIGRP retransmissions\n" | |
486 | "EIGRP stub packets\n" | |
487 | "Display all EIGRP packets except Hellos\n" | |
488 | "EIGRP update packets\n" | |
489 | "Display all EIGRP packets\n" | |
490 | "Send Packets\n" | |
491 | "Receive Packets\n" | |
492 | "Detail Information\n") | |
493 | { | |
494 | int type = 0; | |
495 | int flag = 0; | |
496 | int i; | |
497 | int idx = 0; | |
498 | ||
499 | /* Check packet type. */ | |
500 | if (argv_find (argv, argc, "hello", &idx) == 0) | |
501 | type = EIGRP_DEBUG_HELLO; | |
502 | if (argv_find (argv, argc, "update", &idx) == 0) | |
503 | type = EIGRP_DEBUG_UPDATE; | |
504 | if (argv_find (argv, argc, "query", &idx) == 0) | |
505 | type = EIGRP_DEBUG_QUERY; | |
506 | if (argv_find (argv, argc, "ack", &idx) == 0) | |
507 | type = EIGRP_DEBUG_ACK; | |
508 | if (argv_find (argv, argc, "probe", &idx) == 0) | |
509 | type = EIGRP_DEBUG_PROBE; | |
510 | if (argv_find (argv, argc, "stub", &idx) == 0) | |
511 | type = EIGRP_DEBUG_STUB; | |
512 | if (argv_find (argv, argc, "reply", &idx) == 0) | |
513 | type = EIGRP_DEBUG_REPLY; | |
514 | if (argv_find (argv, argc, "request", &idx) == 0) | |
515 | type = EIGRP_DEBUG_REQUEST; | |
516 | if (argv_find (argv, argc, "siaquery", &idx) == 0) | |
517 | type = EIGRP_DEBUG_SIAQUERY; | |
518 | if (argv_find (argv, argc, "siareply", &idx) == 0) | |
519 | type = EIGRP_DEBUG_SIAREPLY; | |
520 | if (argv_find (argv, argc, "all", &idx) == 0) | |
521 | type = EIGRP_DEBUG_PACKETS_ALL; | |
522 | ||
523 | ||
524 | /* All packet types, both send and recv. */ | |
525 | flag = EIGRP_DEBUG_SEND_RECV; | |
526 | ||
527 | /* send or recv. */ | |
528 | if (argv_find (argv, argc, "s", &idx) == 0) | |
529 | flag = EIGRP_DEBUG_SEND; | |
530 | else if (argv_find (argv, argc, "r", &idx) == 0) | |
531 | flag = EIGRP_DEBUG_RECV; | |
532 | ||
533 | /* detail. */ | |
534 | if (argv_find (argv, argc, "detail", &idx) == 0) | |
535 | flag |= EIGRP_DEBUG_PACKET_DETAIL; | |
536 | ||
537 | for (i = 0; i < 11; i++) | |
538 | if (type & (0x01 << i)) | |
539 | { | |
540 | if (vty->node == CONFIG_NODE) | |
541 | DEBUG_PACKET_ON (i, flag); | |
542 | else | |
543 | TERM_DEBUG_PACKET_ON (i, flag); | |
544 | } | |
545 | ||
546 | return CMD_SUCCESS; | |
547 | } | |
548 | ||
549 | DEFUN (no_debug_eigrp_packets, | |
550 | no_debug_eigrp_packets_all_cmd, | |
551 | "no debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]", | |
552 | NO_STR | |
553 | UNDEBUG_STR | |
554 | EIGRP_STR | |
555 | "EIGRP packets\n" | |
556 | "EIGRP SIA-Query packets\n" | |
557 | "EIGRP SIA-Reply packets\n" | |
558 | "EIGRP ack packets\n" | |
559 | "EIGRP hello packets\n" | |
560 | "EIGRP probe packets\n" | |
561 | "EIGRP query packets\n" | |
562 | "EIGRP reply packets\n" | |
563 | "EIGRP request packets\n" | |
564 | "EIGRP retransmissions\n" | |
565 | "EIGRP stub packets\n" | |
566 | "Display all EIGRP packets except Hellos\n" | |
567 | "EIGRP update packets\n" | |
568 | "Display all EIGRP packets\n" | |
569 | "Send Packets\n" | |
570 | "Receive Packets\n" | |
571 | "Detailed Information\n") | |
572 | { | |
573 | int type = 0; | |
574 | int flag = 0; | |
575 | int i; | |
576 | int idx = 0; | |
577 | ||
578 | /* Check packet type. */ | |
579 | if (argv_find (argv, argc, "hello", &idx) == 0) | |
580 | type = EIGRP_DEBUG_HELLO; | |
581 | if (argv_find (argv, argc, "update", &idx) == 0) | |
582 | type = EIGRP_DEBUG_UPDATE; | |
583 | if (argv_find (argv, argc, "query", &idx) == 0) | |
584 | type = EIGRP_DEBUG_QUERY; | |
585 | if (argv_find (argv, argc, "ack", &idx) == 0) | |
586 | type = EIGRP_DEBUG_ACK; | |
587 | if (argv_find (argv, argc, "probe", &idx) == 0) | |
588 | type = EIGRP_DEBUG_PROBE; | |
589 | if (argv_find (argv, argc, "stub", &idx) == 0) | |
590 | type = EIGRP_DEBUG_STUB; | |
591 | if (argv_find (argv, argc, "reply", &idx) == 0) | |
592 | type = EIGRP_DEBUG_REPLY; | |
593 | if (argv_find (argv, argc, "request", &idx) == 0) | |
594 | type = EIGRP_DEBUG_REQUEST; | |
595 | if (argv_find (argv, argc, "siaquery", &idx) == 0) | |
596 | type = EIGRP_DEBUG_SIAQUERY; | |
597 | if (argv_find (argv, argc, "siareply", &idx) == 0) | |
598 | type = EIGRP_DEBUG_SIAREPLY; | |
599 | ||
600 | /* Default, both send and recv. */ | |
601 | flag = EIGRP_DEBUG_SEND_RECV; | |
602 | ||
603 | /* send or recv. */ | |
604 | if (argv_find (argv, argc, "send", &idx) == 0) | |
605 | flag = EIGRP_DEBUG_SEND; | |
606 | else if (argv_find (argv, argc, "reply", &idx) == 0) | |
607 | flag = EIGRP_DEBUG_RECV; | |
608 | ||
609 | /* detail. */ | |
610 | if (argv_find (argv, argc, "detail", &idx) == 0) | |
611 | flag |= EIGRP_DEBUG_PACKET_DETAIL; | |
612 | ||
613 | for (i = 0; i < 11; i++) | |
614 | if (type & (0x01 << i)) | |
615 | { | |
616 | if (vty->node == CONFIG_NODE) | |
617 | DEBUG_PACKET_OFF (i, flag); | |
618 | else | |
619 | TERM_DEBUG_PACKET_OFF (i, flag); | |
620 | } | |
621 | ||
622 | return CMD_SUCCESS; | |
623 | } | |
624 | ||
625 | /* Debug node. */ | |
626 | static struct cmd_node eigrp_debug_node = | |
627 | { | |
628 | DEBUG_NODE, | |
629 | "", | |
630 | 1 /* VTYSH */ | |
631 | }; | |
632 | ||
633 | /* Initialize debug commands. */ | |
634 | void | |
635 | eigrp_debug_init () | |
636 | { | |
637 | install_node (&eigrp_debug_node, config_write_debug); | |
638 | ||
639 | install_element (ENABLE_NODE, &show_debugging_eigrp_cmd); | |
640 | install_element (ENABLE_NODE, &debug_eigrp_packets_all_cmd); | |
641 | install_element (ENABLE_NODE, &no_debug_eigrp_packets_all_cmd); | |
642 | install_element (ENABLE_NODE, &debug_eigrp_transmit_cmd); | |
643 | install_element (ENABLE_NODE, &no_debug_eigrp_transmit_cmd); | |
644 | ||
645 | install_element (CONFIG_NODE, &show_debugging_eigrp_cmd); | |
646 | install_element (CONFIG_NODE, &debug_eigrp_packets_all_cmd); | |
647 | install_element (CONFIG_NODE, &no_debug_eigrp_packets_all_cmd); | |
648 | install_element (CONFIG_NODE, &no_debug_eigrp_transmit_cmd); | |
649 | } | |
650 | ||
651 |