]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_dump.c
Merge pull request #10590 from donaldsharp/bgp_error_codes
[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 *
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. */
52unsigned long term_debug_eigrp = 0;
53unsigned long term_debug_eigrp_nei = 0;
4dfa4846 54unsigned long term_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
7f57883e
DS
55unsigned long term_debug_eigrp_zebra = 6;
56unsigned long term_debug_eigrp_transmit = 0;
57
58/* Configuration debug option variables. */
59unsigned long conf_debug_eigrp = 0;
60unsigned long conf_debug_eigrp_nei = 0;
4dfa4846 61unsigned long conf_debug_eigrp_packet[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
7f57883e
DS
62unsigned long conf_debug_eigrp_zebra = 0;
63unsigned long conf_debug_eigrp_transmit = 0;
64
65
d62a17ae 66static int config_write_debug(struct vty *vty)
7f57883e 67{
d62a17ae 68 int write = 0;
69 int i;
7f57883e 70
d62a17ae 71 const char *type_str[] = {"update", "request", "query", "reply",
72 "hello", "", "probe", "ack",
73 "", "SIA query", "SIA reply", "stub",
74 "all"};
75 const char *detail_str[] = {
76 "", " send", " recv", "",
77 " detail", " send detail", " recv detail", " detail"};
7f57883e
DS
78
79
d62a17ae 80 /* debug eigrp event. */
7f57883e 81
d62a17ae 82 /* debug eigrp packet */
83 for (i = 0; i < 10; i++) {
84 if (conf_debug_eigrp_packet[i] == 0
85 && term_debug_eigrp_packet[i] == 0)
86 continue;
7f57883e 87
d62a17ae 88 vty_out(vty, "debug eigrp packet %s%s\n", type_str[i],
89 detail_str[conf_debug_eigrp_packet[i]]);
90 write = 1;
91 }
7f57883e 92
d62a17ae 93 return write;
7f57883e
DS
94}
95
d62a17ae 96static int eigrp_neighbor_packet_queue_sum(struct eigrp_interface *ei)
7f57883e 97{
d62a17ae 98 struct eigrp_neighbor *nbr;
99 struct listnode *node, *nnode;
100 int sum;
101 sum = 0;
7f57883e 102
d62a17ae 103 for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) {
104 sum += nbr->retrans_queue->count;
105 }
7f57883e 106
d62a17ae 107 return sum;
7f57883e
DS
108}
109
110/*
111 * Expects header to be in host order
112 */
d62a17ae 113void eigrp_ip_header_dump(struct ip *iph)
7f57883e 114{
d62a17ae 115 /* IP Header dump. */
116 zlog_debug("ip_v %u", iph->ip_v);
117 zlog_debug("ip_hl %u", iph->ip_hl);
118 zlog_debug("ip_tos %u", iph->ip_tos);
119 zlog_debug("ip_len %u", iph->ip_len);
d7c0a89a
QY
120 zlog_debug("ip_id %u", (uint32_t)iph->ip_id);
121 zlog_debug("ip_off %u", (uint32_t)iph->ip_off);
d62a17ae 122 zlog_debug("ip_ttl %u", iph->ip_ttl);
123 zlog_debug("ip_p %u", iph->ip_p);
d7c0a89a 124 zlog_debug("ip_sum 0x%x", (uint32_t)iph->ip_sum);
37b4b3cc
DS
125 zlog_debug("ip_src %pI4", &iph->ip_src);
126 zlog_debug("ip_dst %pI4", &iph->ip_dst);
7f57883e
DS
127}
128
129/*
130 * Expects header to be in host order
131 */
d62a17ae 132void eigrp_header_dump(struct eigrp_header *eigrph)
7f57883e 133{
d62a17ae 134 /* EIGRP Header dump. */
135 zlog_debug("eigrp_version %u", eigrph->version);
136 zlog_debug("eigrp_opcode %u", eigrph->opcode);
137 zlog_debug("eigrp_checksum 0x%x", ntohs(eigrph->checksum));
138 zlog_debug("eigrp_flags 0x%x", ntohl(eigrph->flags));
139 zlog_debug("eigrp_sequence %u", ntohl(eigrph->sequence));
140 zlog_debug("eigrp_ack %u", ntohl(eigrph->ack));
141 zlog_debug("eigrp_vrid %u", ntohs(eigrph->vrid));
142 zlog_debug("eigrp_AS %u", ntohs(eigrph->ASNumber));
7f57883e
DS
143}
144
d62a17ae 145const char *eigrp_if_name_string(struct eigrp_interface *ei)
7f57883e 146{
d62a17ae 147 if (!ei)
148 return "inactive";
7f57883e 149
152e64e3 150 return ei->ifp->name;
7f57883e 151}
7f57883e 152
d62a17ae 153void show_ip_eigrp_interface_header(struct vty *vty, struct eigrp *eigrp)
7f57883e
DS
154{
155
d62a17ae 156 vty_out(vty,
b31ad7fc 157 "\nEIGRP interfaces for AS(%d)\n\n%-16s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s\n %-44s %-12s %-7s %-14s %-12s %-8s\n",
d62a17ae 158 eigrp->AS, "Interface", "Bandwidth", "Delay", "Peers",
159 "Xmit Queue", "Mean", "Pacing Time", "Multicast", "Pending",
160 "Hello", "Holdtime", "", "Un/Reliable", "SRTT", "Un/Reliable",
161 "Flow Timer", "Routes");
7f57883e
DS
162}
163
d62a17ae 164void show_ip_eigrp_interface_sub(struct vty *vty, struct eigrp *eigrp,
165 struct eigrp_interface *ei)
7f57883e 166{
b31ad7fc 167 vty_out(vty, "%-16s ", IF_NAME(ei));
b748db67
DS
168 vty_out(vty, "%-11u", ei->params.bandwidth);
169 vty_out(vty, "%-11u", ei->params.delay);
d62a17ae 170 vty_out(vty, "%-7u", ei->nbrs->count);
171 vty_out(vty, "%u %c %-10u", 0, '/',
172 eigrp_neighbor_packet_queue_sum(ei));
173 vty_out(vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0);
996c9314 174 vty_out(vty, "%-8u %-8u \n", ei->params.v_hello, ei->params.v_wait);
7f57883e
DS
175}
176
d62a17ae 177void show_ip_eigrp_interface_detail(struct vty *vty, struct eigrp *eigrp,
178 struct eigrp_interface *ei)
7f57883e 179{
d62a17ae 180 vty_out(vty, "%-2s %s %d %-3s \n", "", "Hello interval is ", 0, " sec");
181 vty_out(vty, "%-2s %s %s \n", "", "Next xmit serial", "<none>");
182 vty_out(vty, "%-2s %s %d %s %d %s %d %s %d \n", "",
183 "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0,
184 "/", 0);
185 vty_out(vty, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0,
0437e105 186 " CR packets: ", 0, " ACKs suppressed: ", 0);
d62a17ae 187 vty_out(vty, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0,
188 "Out-of-sequence rcvd: ", 0);
189 vty_out(vty, "%-2s %s %s %s \n", "", "Authentication mode is ", "not",
190 "set");
191 vty_out(vty, "%-2s %s \n", "", "Use multicast");
7f57883e
DS
192}
193
d62a17ae 194void show_ip_eigrp_neighbor_header(struct vty *vty, struct eigrp *eigrp)
7f57883e 195{
d62a17ae 196 vty_out(vty,
197 "\nEIGRP neighbors for AS(%d)\n\n%-3s %-17s %-20s %-6s %-8s %-6s %-5s %-5s %-5s\n %-41s %-6s %-8s %-6s %-4s %-6s %-5s \n",
198 eigrp->AS, "H", "Address", "Interface", "Hold", "Uptime",
199 "SRTT", "RTO", "Q", "Seq", "", "(sec)", "", "(ms)", "", "Cnt",
200 "Num");
7f57883e
DS
201}
202
d62a17ae 203void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
204 int detail)
7f57883e
DS
205{
206
37b4b3cc 207 vty_out(vty, "%-3u %-17pI4 %-21s", 0, &nbr->src, IF_NAME(nbr->ei));
2085179b 208 if (nbr->t_holddown)
996c9314
LB
209 vty_out(vty, "%-7lu",
210 thread_timer_remain_second(nbr->t_holddown));
2085179b
AL
211 else
212 vty_out(vty, "- ");
d62a17ae 213 vty_out(vty, "%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME);
214 vty_out(vty, "%-7lu", nbr->retrans_queue->count);
215 vty_out(vty, "%u\n", nbr->recv_sequence_number);
216
217
218 if (detail) {
219 vty_out(vty, " Version %u.%u/%u.%u", nbr->os_rel_major,
220 nbr->os_rel_minor, nbr->tlv_rel_major,
221 nbr->tlv_rel_minor);
222 vty_out(vty, ", Retrans: %lu, Retries: %lu",
223 nbr->retrans_queue->count, 0UL);
224 vty_out(vty, ", %s\n", eigrp_nbr_state_str(nbr));
225 }
7f57883e
DS
226}
227
228/*
229 * Print standard header for show EIGRP topology output
230 */
d62a17ae 231void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
7f57883e 232{
37b4b3cc
DS
233 vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%pI4)\n\n",
234 eigrp->AS, &eigrp->router_id);
d62a17ae 235 vty_out(vty,
3efd0893 236 "Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply\n r - reply Status, s - sia Status\n\n");
7f57883e
DS
237}
238
dc4accdd
DS
239void show_ip_eigrp_prefix_descriptor(struct vty *vty,
240 struct eigrp_prefix_descriptor *tn)
7f57883e 241{
d62a17ae 242 struct list *successors = eigrp_topology_get_successor(tn);
057fad8d 243
d62a17ae 244 vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
910a5c0e 245
2dbe669b 246 vty_out(vty, "%pFX, ", tn->destination);
996c9314 247 vty_out(vty, "%u successors, ", (successors) ? successors->count : 0);
d62a17ae 248 vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
249 tn->serno);
057fad8d 250
dbfd865b 251 if (successors)
6a154c88 252 list_delete(&successors);
7f57883e
DS
253}
254
dc4accdd
DS
255void show_ip_eigrp_route_descriptor(struct vty *vty, struct eigrp *eigrp,
256 struct eigrp_route_descriptor *te,
257 bool *first)
7f57883e 258{
d62a17ae 259 if (te->reported_distance == EIGRP_MAX_METRIC)
260 return;
261
262 if (*first) {
dc4accdd 263 show_ip_eigrp_prefix_descriptor(vty, te->prefix);
95fc2ae7 264 *first = false;
d62a17ae 265 }
266
267 if (te->adv_router == eigrp->neighbor_self)
268 vty_out(vty, "%-7s%s, %s\n", " ", "via Connected",
152e64e3 269 IF_NAME(te->ei));
d62a17ae 270 else {
37b4b3cc
DS
271 vty_out(vty, "%-7s%s%pI4 (%u/%u), %s\n", " ", "via ",
272 &te->adv_router->src, te->distance,
152e64e3 273 te->reported_distance, IF_NAME(te->ei));
d62a17ae 274 }
7f57883e
DS
275}
276
277
87f6dc50
DS
278DEFUN_NOSH (show_debugging_eigrp,
279 show_debugging_eigrp_cmd,
280 "show debugging [eigrp]",
281 SHOW_STR
282 DEBUG_STR
283 EIGRP_STR)
7f57883e 284{
d62a17ae 285 int i;
286
287 vty_out(vty, "EIGRP debugging status:\n");
288
289 /* Show debug status for events. */
290 if (IS_DEBUG_EIGRP(event, EVENT))
291 vty_out(vty, " EIGRP event debugging is on\n");
292
293 /* Show debug status for EIGRP Packets. */
294 for (i = 0; i < 11; i++) {
295 if (i == 8)
296 continue;
297
298 if (IS_DEBUG_EIGRP_PACKET(i, SEND)
299 && IS_DEBUG_EIGRP_PACKET(i, RECV)) {
300 vty_out(vty, " EIGRP packet %s%s debugging is on\n",
301 lookup_msg(eigrp_packet_type_str, i + 1, NULL),
302 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
303 ? " detail"
304 : "");
305 } else {
306 if (IS_DEBUG_EIGRP_PACKET(i, SEND))
307 vty_out(vty,
308 " EIGRP packet %s send%s debugging is on\n",
309 lookup_msg(eigrp_packet_type_str, i + 1,
310 NULL),
311 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
312 ? " detail"
313 : "");
314 if (IS_DEBUG_EIGRP_PACKET(i, RECV))
315 vty_out(vty,
316 " EIGRP packet %s receive%s debugging is on\n",
317 lookup_msg(eigrp_packet_type_str, i + 1,
318 NULL),
319 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
320 ? " detail"
321 : "");
322 }
323 }
324
325 return CMD_SUCCESS;
7f57883e
DS
326}
327
328
329/*
f9e5c9ca
DS
330 [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all)
331 [send|recv [detail]]
7f57883e
DS
332*/
333
334DEFUN (debug_eigrp_transmit,
335 debug_eigrp_transmit_cmd,
336 "debug eigrp transmit <send|recv|all> [detail]",
337 DEBUG_STR
338 EIGRP_STR
339 "EIGRP transmission events\n"
340 "packet sent\n"
341 "packet received\n"
342 "all packets\n"
343 "Detailed Information\n")
344{
d62a17ae 345 int flag = 0;
346 int idx = 2;
347
348 /* send or recv. */
349 if (argv_find(argv, argc, "send", &idx))
350 flag = EIGRP_DEBUG_SEND;
351 else if (argv_find(argv, argc, "recv", &idx))
352 flag = EIGRP_DEBUG_RECV;
89bb508b 353 else if (argv_find(argv, argc, "all", &idx))
d62a17ae 354 flag = EIGRP_DEBUG_SEND_RECV;
355
356 /* detail option */
89bb508b 357 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 358 flag = EIGRP_DEBUG_PACKET_DETAIL;
359
360 if (vty->node == CONFIG_NODE)
361 DEBUG_TRANSMIT_ON(0, flag);
362 else
363 TERM_DEBUG_TRANSMIT_ON(0, flag);
364
365 return CMD_SUCCESS;
7f57883e
DS
366}
367
368DEFUN (no_debug_eigrp_transmit,
369 no_debug_eigrp_transmit_cmd,
370 "no debug eigrp transmit <send|recv|all> [detail]",
371 NO_STR
372 UNDEBUG_STR
373 EIGRP_STR
374 "EIGRP transmission events\n"
375 "packet sent\n"
376 "packet received\n"
377 "all packets\n"
378 "Detailed Information\n")
379{
d62a17ae 380 int flag = 0;
381 int idx = 3;
382
383 /* send or recv. */
89bb508b 384 if (argv_find(argv, argc, "send", &idx))
d62a17ae 385 flag = EIGRP_DEBUG_SEND;
89bb508b 386 else if (argv_find(argv, argc, "recv", &idx))
d62a17ae 387 flag = EIGRP_DEBUG_RECV;
89bb508b 388 else if (argv_find(argv, argc, "all", &idx))
d62a17ae 389 flag = EIGRP_DEBUG_SEND_RECV;
390
391 /* detail option */
89bb508b 392 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 393 flag = EIGRP_DEBUG_PACKET_DETAIL;
394
395 if (vty->node == CONFIG_NODE)
396 DEBUG_TRANSMIT_OFF(0, flag);
397 else
398 TERM_DEBUG_TRANSMIT_OFF(0, flag);
399
400 return CMD_SUCCESS;
7f57883e
DS
401}
402
403DEFUN (debug_eigrp_packets,
404 debug_eigrp_packets_all_cmd,
405 "debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
406 DEBUG_STR
407 EIGRP_STR
408 "EIGRP packets\n"
409 "EIGRP SIA-Query packets\n"
410 "EIGRP SIA-Reply packets\n"
411 "EIGRP ack packets\n"
412 "EIGRP hello packets\n"
413 "EIGRP probe packets\n"
414 "EIGRP query packets\n"
415 "EIGRP reply packets\n"
416 "EIGRP request packets\n"
417 "EIGRP retransmissions\n"
418 "EIGRP stub packets\n"
419 "Display all EIGRP packets except Hellos\n"
420 "EIGRP update packets\n"
421 "Display all EIGRP packets\n"
422 "Send Packets\n"
423 "Receive Packets\n"
424 "Detail Information\n")
425{
d62a17ae 426 int type = 0;
427 int flag = 0;
428 int i;
429 int idx = 0;
430
431 /* Check packet type. */
89bb508b 432 if (argv_find(argv, argc, "hello", &idx))
d62a17ae 433 type = EIGRP_DEBUG_HELLO;
89bb508b 434 if (argv_find(argv, argc, "update", &idx))
d62a17ae 435 type = EIGRP_DEBUG_UPDATE;
89bb508b 436 if (argv_find(argv, argc, "query", &idx))
d62a17ae 437 type = EIGRP_DEBUG_QUERY;
89bb508b 438 if (argv_find(argv, argc, "ack", &idx))
d62a17ae 439 type = EIGRP_DEBUG_ACK;
89bb508b 440 if (argv_find(argv, argc, "probe", &idx))
d62a17ae 441 type = EIGRP_DEBUG_PROBE;
89bb508b 442 if (argv_find(argv, argc, "stub", &idx))
d62a17ae 443 type = EIGRP_DEBUG_STUB;
89bb508b 444 if (argv_find(argv, argc, "reply", &idx))
d62a17ae 445 type = EIGRP_DEBUG_REPLY;
89bb508b 446 if (argv_find(argv, argc, "request", &idx))
d62a17ae 447 type = EIGRP_DEBUG_REQUEST;
89bb508b 448 if (argv_find(argv, argc, "siaquery", &idx))
d62a17ae 449 type = EIGRP_DEBUG_SIAQUERY;
89bb508b 450 if (argv_find(argv, argc, "siareply", &idx))
d62a17ae 451 type = EIGRP_DEBUG_SIAREPLY;
89bb508b 452 if (argv_find(argv, argc, "all", &idx))
d62a17ae 453 type = EIGRP_DEBUG_PACKETS_ALL;
454
455
456 /* All packet types, both send and recv. */
457 flag = EIGRP_DEBUG_SEND_RECV;
458
459 /* send or recv. */
89bb508b 460 if (argv_find(argv, argc, "s", &idx))
d62a17ae 461 flag = EIGRP_DEBUG_SEND;
89bb508b 462 else if (argv_find(argv, argc, "r", &idx))
d62a17ae 463 flag = EIGRP_DEBUG_RECV;
464
465 /* detail. */
89bb508b 466 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 467 flag |= EIGRP_DEBUG_PACKET_DETAIL;
468
469 for (i = 0; i < 11; i++)
470 if (type & (0x01 << i)) {
471 if (vty->node == CONFIG_NODE)
472 DEBUG_PACKET_ON(i, flag);
473 else
474 TERM_DEBUG_PACKET_ON(i, flag);
475 }
476
477 return CMD_SUCCESS;
7f57883e
DS
478}
479
480DEFUN (no_debug_eigrp_packets,
481 no_debug_eigrp_packets_all_cmd,
482 "no debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
483 NO_STR
484 UNDEBUG_STR
485 EIGRP_STR
486 "EIGRP packets\n"
487 "EIGRP SIA-Query packets\n"
488 "EIGRP SIA-Reply packets\n"
489 "EIGRP ack packets\n"
490 "EIGRP hello packets\n"
491 "EIGRP probe packets\n"
492 "EIGRP query packets\n"
493 "EIGRP reply packets\n"
494 "EIGRP request packets\n"
495 "EIGRP retransmissions\n"
496 "EIGRP stub packets\n"
497 "Display all EIGRP packets except Hellos\n"
498 "EIGRP update packets\n"
499 "Display all EIGRP packets\n"
500 "Send Packets\n"
501 "Receive Packets\n"
502 "Detailed Information\n")
503{
d62a17ae 504 int type = 0;
505 int flag = 0;
506 int i;
507 int idx = 0;
508
509 /* Check packet type. */
89bb508b 510 if (argv_find(argv, argc, "hello", &idx))
d62a17ae 511 type = EIGRP_DEBUG_HELLO;
89bb508b 512 if (argv_find(argv, argc, "update", &idx))
d62a17ae 513 type = EIGRP_DEBUG_UPDATE;
89bb508b 514 if (argv_find(argv, argc, "query", &idx))
d62a17ae 515 type = EIGRP_DEBUG_QUERY;
89bb508b 516 if (argv_find(argv, argc, "ack", &idx))
d62a17ae 517 type = EIGRP_DEBUG_ACK;
89bb508b 518 if (argv_find(argv, argc, "probe", &idx))
d62a17ae 519 type = EIGRP_DEBUG_PROBE;
89bb508b 520 if (argv_find(argv, argc, "stub", &idx))
d62a17ae 521 type = EIGRP_DEBUG_STUB;
89bb508b 522 if (argv_find(argv, argc, "reply", &idx))
d62a17ae 523 type = EIGRP_DEBUG_REPLY;
89bb508b 524 if (argv_find(argv, argc, "request", &idx))
d62a17ae 525 type = EIGRP_DEBUG_REQUEST;
89bb508b 526 if (argv_find(argv, argc, "siaquery", &idx))
d62a17ae 527 type = EIGRP_DEBUG_SIAQUERY;
89bb508b 528 if (argv_find(argv, argc, "siareply", &idx))
d62a17ae 529 type = EIGRP_DEBUG_SIAREPLY;
530
531 /* Default, both send and recv. */
532 flag = EIGRP_DEBUG_SEND_RECV;
533
534 /* send or recv. */
89bb508b 535 if (argv_find(argv, argc, "send", &idx))
d62a17ae 536 flag = EIGRP_DEBUG_SEND;
89bb508b 537 else if (argv_find(argv, argc, "reply", &idx))
d62a17ae 538 flag = EIGRP_DEBUG_RECV;
539
540 /* detail. */
89bb508b 541 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 542 flag |= EIGRP_DEBUG_PACKET_DETAIL;
543
544 for (i = 0; i < 11; i++)
545 if (type & (0x01 << i)) {
546 if (vty->node == CONFIG_NODE)
547 DEBUG_PACKET_OFF(i, flag);
548 else
549 TERM_DEBUG_PACKET_OFF(i, flag);
550 }
551
552 return CMD_SUCCESS;
7f57883e
DS
553}
554
555/* Debug node. */
612c2c15 556static int config_write_debug(struct vty *vty);
d62a17ae 557static struct cmd_node eigrp_debug_node = {
f4b8291f 558 .name = "debug",
62b346ee
DL
559 .node = DEBUG_NODE,
560 .prompt = "",
612c2c15 561 .config_write = config_write_debug,
7f57883e
DS
562};
563
564/* Initialize debug commands. */
4d762f26 565void eigrp_debug_init(void)
7f57883e 566{
612c2c15 567 install_node(&eigrp_debug_node);
d62a17ae 568
569 install_element(ENABLE_NODE, &show_debugging_eigrp_cmd);
570 install_element(ENABLE_NODE, &debug_eigrp_packets_all_cmd);
571 install_element(ENABLE_NODE, &no_debug_eigrp_packets_all_cmd);
572 install_element(ENABLE_NODE, &debug_eigrp_transmit_cmd);
573 install_element(ENABLE_NODE, &no_debug_eigrp_transmit_cmd);
574
575 install_element(CONFIG_NODE, &show_debugging_eigrp_cmd);
576 install_element(CONFIG_NODE, &debug_eigrp_packets_all_cmd);
577 install_element(CONFIG_NODE, &no_debug_eigrp_packets_all_cmd);
af83cb12 578 install_element(CONFIG_NODE, &debug_eigrp_transmit_cmd);
d62a17ae 579 install_element(CONFIG_NODE, &no_debug_eigrp_transmit_cmd);
7f57883e 580}