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