]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_dump.c
zebra: Allow ns delete to happen after under/over flow checks
[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);
d62a17ae 125 zlog_debug("ip_src %s", inet_ntoa(iph->ip_src));
126 zlog_debug("ip_dst %s", inet_ntoa(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 static char buf[EIGRP_IF_STRING_MAXLEN] = "";
7f57883e 148
d62a17ae 149 if (!ei)
150 return "inactive";
7f57883e 151
d62a17ae 152 snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%s", ei->ifp->name);
153 return buf;
7f57883e
DS
154}
155
d62a17ae 156const char *eigrp_topology_ip_string(struct eigrp_prefix_entry *tn)
7f57883e 157{
d62a17ae 158 static char buf[EIGRP_IF_STRING_MAXLEN] = "";
d7c0a89a 159 uint32_t ifaddr;
d62a17ae 160
02b45998 161 ifaddr = ntohl(tn->destination->u.prefix4.s_addr);
d62a17ae 162 snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
163 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
164 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
165 return buf;
7f57883e
DS
166}
167
168
d62a17ae 169const char *eigrp_if_ip_string(struct eigrp_interface *ei)
7f57883e 170{
d62a17ae 171 static char buf[EIGRP_IF_STRING_MAXLEN] = "";
d7c0a89a 172 uint32_t ifaddr;
7f57883e 173
d62a17ae 174 if (!ei)
175 return "inactive";
7f57883e 176
d62a17ae 177 ifaddr = ntohl(ei->address->u.prefix4.s_addr);
178 snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
179 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
180 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
7f57883e 181
d62a17ae 182 return buf;
7f57883e
DS
183}
184
d62a17ae 185const char *eigrp_neigh_ip_string(struct eigrp_neighbor *nbr)
7f57883e 186{
d62a17ae 187 static char buf[EIGRP_IF_STRING_MAXLEN] = "";
d7c0a89a 188 uint32_t ifaddr;
7f57883e 189
d62a17ae 190 ifaddr = ntohl(nbr->src.s_addr);
191 snprintf(buf, EIGRP_IF_STRING_MAXLEN, "%u.%u.%u.%u",
192 (ifaddr >> 24) & 0xff, (ifaddr >> 16) & 0xff,
193 (ifaddr >> 8) & 0xff, ifaddr & 0xff);
7f57883e 194
d62a17ae 195 return buf;
7f57883e
DS
196}
197
d62a17ae 198void show_ip_eigrp_interface_header(struct vty *vty, struct eigrp *eigrp)
7f57883e
DS
199{
200
d62a17ae 201 vty_out(vty,
202 "\nEIGRP interfaces for AS(%d)\n\n %-10s %-10s %-10s %-6s %-12s %-7s %-14s %-12s %-8s %-8s %-8s\n %-39s %-12s %-7s %-14s %-12s %-8s\n",
203 eigrp->AS, "Interface", "Bandwidth", "Delay", "Peers",
204 "Xmit Queue", "Mean", "Pacing Time", "Multicast", "Pending",
205 "Hello", "Holdtime", "", "Un/Reliable", "SRTT", "Un/Reliable",
206 "Flow Timer", "Routes");
7f57883e
DS
207}
208
d62a17ae 209void show_ip_eigrp_interface_sub(struct vty *vty, struct eigrp *eigrp,
210 struct eigrp_interface *ei)
7f57883e 211{
d62a17ae 212 vty_out(vty, "%-11s ", eigrp_if_name_string(ei));
b748db67
DS
213 vty_out(vty, "%-11u", ei->params.bandwidth);
214 vty_out(vty, "%-11u", ei->params.delay);
d62a17ae 215 vty_out(vty, "%-7u", ei->nbrs->count);
216 vty_out(vty, "%u %c %-10u", 0, '/',
217 eigrp_neighbor_packet_queue_sum(ei));
218 vty_out(vty, "%-7u %-14u %-12u %-8u", 0, 0, 0, 0);
996c9314 219 vty_out(vty, "%-8u %-8u \n", ei->params.v_hello, ei->params.v_wait);
7f57883e
DS
220}
221
d62a17ae 222void show_ip_eigrp_interface_detail(struct vty *vty, struct eigrp *eigrp,
223 struct eigrp_interface *ei)
7f57883e 224{
d62a17ae 225 vty_out(vty, "%-2s %s %d %-3s \n", "", "Hello interval is ", 0, " sec");
226 vty_out(vty, "%-2s %s %s \n", "", "Next xmit serial", "<none>");
227 vty_out(vty, "%-2s %s %d %s %d %s %d %s %d \n", "",
228 "Un/reliable mcasts: ", 0, "/", 0, "Un/reliable ucasts: ", 0,
229 "/", 0);
230 vty_out(vty, "%-2s %s %d %s %d %s %d \n", "", "Mcast exceptions: ", 0,
0437e105 231 " CR packets: ", 0, " ACKs suppressed: ", 0);
d62a17ae 232 vty_out(vty, "%-2s %s %d %s %d \n", "", "Retransmissions sent: ", 0,
233 "Out-of-sequence rcvd: ", 0);
234 vty_out(vty, "%-2s %s %s %s \n", "", "Authentication mode is ", "not",
235 "set");
236 vty_out(vty, "%-2s %s \n", "", "Use multicast");
7f57883e
DS
237}
238
d62a17ae 239void show_ip_eigrp_neighbor_header(struct vty *vty, struct eigrp *eigrp)
7f57883e 240{
d62a17ae 241 vty_out(vty,
242 "\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",
243 eigrp->AS, "H", "Address", "Interface", "Hold", "Uptime",
244 "SRTT", "RTO", "Q", "Seq", "", "(sec)", "", "(ms)", "", "Cnt",
245 "Num");
7f57883e
DS
246}
247
d62a17ae 248void show_ip_eigrp_neighbor_sub(struct vty *vty, struct eigrp_neighbor *nbr,
249 int detail)
7f57883e
DS
250{
251
d62a17ae 252 vty_out(vty, "%-3u %-17s %-21s", 0, eigrp_neigh_ip_string(nbr),
253 eigrp_if_name_string(nbr->ei));
2085179b 254 if (nbr->t_holddown)
996c9314
LB
255 vty_out(vty, "%-7lu",
256 thread_timer_remain_second(nbr->t_holddown));
2085179b
AL
257 else
258 vty_out(vty, "- ");
d62a17ae 259 vty_out(vty, "%-8u %-6u %-5u", 0, 0, EIGRP_PACKET_RETRANS_TIME);
260 vty_out(vty, "%-7lu", nbr->retrans_queue->count);
261 vty_out(vty, "%u\n", nbr->recv_sequence_number);
262
263
264 if (detail) {
265 vty_out(vty, " Version %u.%u/%u.%u", nbr->os_rel_major,
266 nbr->os_rel_minor, nbr->tlv_rel_major,
267 nbr->tlv_rel_minor);
268 vty_out(vty, ", Retrans: %lu, Retries: %lu",
269 nbr->retrans_queue->count, 0UL);
270 vty_out(vty, ", %s\n", eigrp_nbr_state_str(nbr));
271 }
7f57883e
DS
272}
273
274/*
275 * Print standard header for show EIGRP topology output
276 */
d62a17ae 277void show_ip_eigrp_topology_header(struct vty *vty, struct eigrp *eigrp)
7f57883e 278{
d62a17ae 279 struct in_addr router_id;
280 router_id.s_addr = eigrp->router_id;
281
282 vty_out(vty, "\nEIGRP Topology Table for AS(%d)/ID(%s)\n\n", eigrp->AS,
283 inet_ntoa(router_id));
284 vty_out(vty,
285 "Codes: P - Passive, A - Active, U - Update, Q - Query, "
286 "R - Reply\n r - reply Status, s - sia Status\n\n");
7f57883e
DS
287}
288
d62a17ae 289void show_ip_eigrp_prefix_entry(struct vty *vty, struct eigrp_prefix_entry *tn)
7f57883e 290{
d62a17ae 291 struct list *successors = eigrp_topology_get_successor(tn);
02b45998 292 char buffer[PREFIX_STRLEN];
057fad8d 293
d62a17ae 294 vty_out(vty, "%-3c", (tn->state > 0) ? 'A' : 'P');
910a5c0e 295
02b45998
DS
296 vty_out(vty, "%s, ",
297 prefix2str(tn->destination, buffer, PREFIX_STRLEN));
996c9314 298 vty_out(vty, "%u successors, ", (successors) ? successors->count : 0);
d62a17ae 299 vty_out(vty, "FD is %u, serno: %" PRIu64 " \n", tn->fdistance,
300 tn->serno);
057fad8d 301
dbfd865b 302 if (successors)
6a154c88 303 list_delete(&successors);
7f57883e
DS
304}
305
255ab940 306void show_ip_eigrp_nexthop_entry(struct vty *vty, struct eigrp *eigrp,
996c9314 307 struct eigrp_nexthop_entry *te, int *first)
7f57883e 308{
d62a17ae 309 if (te->reported_distance == EIGRP_MAX_METRIC)
310 return;
311
312 if (*first) {
313 show_ip_eigrp_prefix_entry(vty, te->prefix);
314 *first = 0;
315 }
316
317 if (te->adv_router == eigrp->neighbor_self)
318 vty_out(vty, "%-7s%s, %s\n", " ", "via Connected",
319 eigrp_if_name_string(te->ei));
320 else {
321 vty_out(vty, "%-7s%s%s (%u/%u), %s\n", " ", "via ",
322 inet_ntoa(te->adv_router->src), te->distance,
323 te->reported_distance, eigrp_if_name_string(te->ei));
324 }
7f57883e
DS
325}
326
327
87f6dc50
DS
328DEFUN_NOSH (show_debugging_eigrp,
329 show_debugging_eigrp_cmd,
330 "show debugging [eigrp]",
331 SHOW_STR
332 DEBUG_STR
333 EIGRP_STR)
7f57883e 334{
d62a17ae 335 int i;
336
337 vty_out(vty, "EIGRP debugging status:\n");
338
339 /* Show debug status for events. */
340 if (IS_DEBUG_EIGRP(event, EVENT))
341 vty_out(vty, " EIGRP event debugging is on\n");
342
343 /* Show debug status for EIGRP Packets. */
344 for (i = 0; i < 11; i++) {
345 if (i == 8)
346 continue;
347
348 if (IS_DEBUG_EIGRP_PACKET(i, SEND)
349 && IS_DEBUG_EIGRP_PACKET(i, RECV)) {
350 vty_out(vty, " EIGRP packet %s%s debugging is on\n",
351 lookup_msg(eigrp_packet_type_str, i + 1, NULL),
352 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
353 ? " detail"
354 : "");
355 } else {
356 if (IS_DEBUG_EIGRP_PACKET(i, SEND))
357 vty_out(vty,
358 " EIGRP packet %s send%s debugging is on\n",
359 lookup_msg(eigrp_packet_type_str, i + 1,
360 NULL),
361 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
362 ? " detail"
363 : "");
364 if (IS_DEBUG_EIGRP_PACKET(i, RECV))
365 vty_out(vty,
366 " EIGRP packet %s receive%s debugging is on\n",
367 lookup_msg(eigrp_packet_type_str, i + 1,
368 NULL),
369 IS_DEBUG_EIGRP_PACKET(i, PACKET_DETAIL)
370 ? " detail"
371 : "");
372 }
373 }
374
375 return CMD_SUCCESS;
7f57883e
DS
376}
377
378
379/*
f9e5c9ca
DS
380 [no] debug eigrp packet (hello|dd|ls-request|ls-update|ls-ack|all)
381 [send|recv [detail]]
7f57883e
DS
382*/
383
384DEFUN (debug_eigrp_transmit,
385 debug_eigrp_transmit_cmd,
386 "debug eigrp transmit <send|recv|all> [detail]",
387 DEBUG_STR
388 EIGRP_STR
389 "EIGRP transmission events\n"
390 "packet sent\n"
391 "packet received\n"
392 "all packets\n"
393 "Detailed Information\n")
394{
d62a17ae 395 int flag = 0;
396 int idx = 2;
397
398 /* send or recv. */
399 if (argv_find(argv, argc, "send", &idx))
400 flag = EIGRP_DEBUG_SEND;
401 else if (argv_find(argv, argc, "recv", &idx))
402 flag = EIGRP_DEBUG_RECV;
89bb508b 403 else if (argv_find(argv, argc, "all", &idx))
d62a17ae 404 flag = EIGRP_DEBUG_SEND_RECV;
405
406 /* detail option */
89bb508b 407 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 408 flag = EIGRP_DEBUG_PACKET_DETAIL;
409
410 if (vty->node == CONFIG_NODE)
411 DEBUG_TRANSMIT_ON(0, flag);
412 else
413 TERM_DEBUG_TRANSMIT_ON(0, flag);
414
415 return CMD_SUCCESS;
7f57883e
DS
416}
417
418DEFUN (no_debug_eigrp_transmit,
419 no_debug_eigrp_transmit_cmd,
420 "no debug eigrp transmit <send|recv|all> [detail]",
421 NO_STR
422 UNDEBUG_STR
423 EIGRP_STR
424 "EIGRP transmission events\n"
425 "packet sent\n"
426 "packet received\n"
427 "all packets\n"
428 "Detailed Information\n")
429{
d62a17ae 430 int flag = 0;
431 int idx = 3;
432
433 /* send or recv. */
89bb508b 434 if (argv_find(argv, argc, "send", &idx))
d62a17ae 435 flag = EIGRP_DEBUG_SEND;
89bb508b 436 else if (argv_find(argv, argc, "recv", &idx))
d62a17ae 437 flag = EIGRP_DEBUG_RECV;
89bb508b 438 else if (argv_find(argv, argc, "all", &idx))
d62a17ae 439 flag = EIGRP_DEBUG_SEND_RECV;
440
441 /* detail option */
89bb508b 442 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 443 flag = EIGRP_DEBUG_PACKET_DETAIL;
444
445 if (vty->node == CONFIG_NODE)
446 DEBUG_TRANSMIT_OFF(0, flag);
447 else
448 TERM_DEBUG_TRANSMIT_OFF(0, flag);
449
450 return CMD_SUCCESS;
7f57883e
DS
451}
452
453DEFUN (debug_eigrp_packets,
454 debug_eigrp_packets_all_cmd,
455 "debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
456 DEBUG_STR
457 EIGRP_STR
458 "EIGRP packets\n"
459 "EIGRP SIA-Query packets\n"
460 "EIGRP SIA-Reply packets\n"
461 "EIGRP ack packets\n"
462 "EIGRP hello packets\n"
463 "EIGRP probe packets\n"
464 "EIGRP query packets\n"
465 "EIGRP reply packets\n"
466 "EIGRP request packets\n"
467 "EIGRP retransmissions\n"
468 "EIGRP stub packets\n"
469 "Display all EIGRP packets except Hellos\n"
470 "EIGRP update packets\n"
471 "Display all EIGRP packets\n"
472 "Send Packets\n"
473 "Receive Packets\n"
474 "Detail Information\n")
475{
d62a17ae 476 int type = 0;
477 int flag = 0;
478 int i;
479 int idx = 0;
480
481 /* Check packet type. */
89bb508b 482 if (argv_find(argv, argc, "hello", &idx))
d62a17ae 483 type = EIGRP_DEBUG_HELLO;
89bb508b 484 if (argv_find(argv, argc, "update", &idx))
d62a17ae 485 type = EIGRP_DEBUG_UPDATE;
89bb508b 486 if (argv_find(argv, argc, "query", &idx))
d62a17ae 487 type = EIGRP_DEBUG_QUERY;
89bb508b 488 if (argv_find(argv, argc, "ack", &idx))
d62a17ae 489 type = EIGRP_DEBUG_ACK;
89bb508b 490 if (argv_find(argv, argc, "probe", &idx))
d62a17ae 491 type = EIGRP_DEBUG_PROBE;
89bb508b 492 if (argv_find(argv, argc, "stub", &idx))
d62a17ae 493 type = EIGRP_DEBUG_STUB;
89bb508b 494 if (argv_find(argv, argc, "reply", &idx))
d62a17ae 495 type = EIGRP_DEBUG_REPLY;
89bb508b 496 if (argv_find(argv, argc, "request", &idx))
d62a17ae 497 type = EIGRP_DEBUG_REQUEST;
89bb508b 498 if (argv_find(argv, argc, "siaquery", &idx))
d62a17ae 499 type = EIGRP_DEBUG_SIAQUERY;
89bb508b 500 if (argv_find(argv, argc, "siareply", &idx))
d62a17ae 501 type = EIGRP_DEBUG_SIAREPLY;
89bb508b 502 if (argv_find(argv, argc, "all", &idx))
d62a17ae 503 type = EIGRP_DEBUG_PACKETS_ALL;
504
505
506 /* All packet types, both send and recv. */
507 flag = EIGRP_DEBUG_SEND_RECV;
508
509 /* send or recv. */
89bb508b 510 if (argv_find(argv, argc, "s", &idx))
d62a17ae 511 flag = EIGRP_DEBUG_SEND;
89bb508b 512 else if (argv_find(argv, argc, "r", &idx))
d62a17ae 513 flag = EIGRP_DEBUG_RECV;
514
515 /* detail. */
89bb508b 516 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 517 flag |= EIGRP_DEBUG_PACKET_DETAIL;
518
519 for (i = 0; i < 11; i++)
520 if (type & (0x01 << i)) {
521 if (vty->node == CONFIG_NODE)
522 DEBUG_PACKET_ON(i, flag);
523 else
524 TERM_DEBUG_PACKET_ON(i, flag);
525 }
526
527 return CMD_SUCCESS;
7f57883e
DS
528}
529
530DEFUN (no_debug_eigrp_packets,
531 no_debug_eigrp_packets_all_cmd,
532 "no debug eigrp packets <siaquery|siareply|ack|hello|probe|query|reply|request|retry|stub|terse|update|all> [send|receive] [detail]",
533 NO_STR
534 UNDEBUG_STR
535 EIGRP_STR
536 "EIGRP packets\n"
537 "EIGRP SIA-Query packets\n"
538 "EIGRP SIA-Reply packets\n"
539 "EIGRP ack packets\n"
540 "EIGRP hello packets\n"
541 "EIGRP probe packets\n"
542 "EIGRP query packets\n"
543 "EIGRP reply packets\n"
544 "EIGRP request packets\n"
545 "EIGRP retransmissions\n"
546 "EIGRP stub packets\n"
547 "Display all EIGRP packets except Hellos\n"
548 "EIGRP update packets\n"
549 "Display all EIGRP packets\n"
550 "Send Packets\n"
551 "Receive Packets\n"
552 "Detailed Information\n")
553{
d62a17ae 554 int type = 0;
555 int flag = 0;
556 int i;
557 int idx = 0;
558
559 /* Check packet type. */
89bb508b 560 if (argv_find(argv, argc, "hello", &idx))
d62a17ae 561 type = EIGRP_DEBUG_HELLO;
89bb508b 562 if (argv_find(argv, argc, "update", &idx))
d62a17ae 563 type = EIGRP_DEBUG_UPDATE;
89bb508b 564 if (argv_find(argv, argc, "query", &idx))
d62a17ae 565 type = EIGRP_DEBUG_QUERY;
89bb508b 566 if (argv_find(argv, argc, "ack", &idx))
d62a17ae 567 type = EIGRP_DEBUG_ACK;
89bb508b 568 if (argv_find(argv, argc, "probe", &idx))
d62a17ae 569 type = EIGRP_DEBUG_PROBE;
89bb508b 570 if (argv_find(argv, argc, "stub", &idx))
d62a17ae 571 type = EIGRP_DEBUG_STUB;
89bb508b 572 if (argv_find(argv, argc, "reply", &idx))
d62a17ae 573 type = EIGRP_DEBUG_REPLY;
89bb508b 574 if (argv_find(argv, argc, "request", &idx))
d62a17ae 575 type = EIGRP_DEBUG_REQUEST;
89bb508b 576 if (argv_find(argv, argc, "siaquery", &idx))
d62a17ae 577 type = EIGRP_DEBUG_SIAQUERY;
89bb508b 578 if (argv_find(argv, argc, "siareply", &idx))
d62a17ae 579 type = EIGRP_DEBUG_SIAREPLY;
580
581 /* Default, both send and recv. */
582 flag = EIGRP_DEBUG_SEND_RECV;
583
584 /* send or recv. */
89bb508b 585 if (argv_find(argv, argc, "send", &idx))
d62a17ae 586 flag = EIGRP_DEBUG_SEND;
89bb508b 587 else if (argv_find(argv, argc, "reply", &idx))
d62a17ae 588 flag = EIGRP_DEBUG_RECV;
589
590 /* detail. */
89bb508b 591 if (argv_find(argv, argc, "detail", &idx))
d62a17ae 592 flag |= EIGRP_DEBUG_PACKET_DETAIL;
593
594 for (i = 0; i < 11; i++)
595 if (type & (0x01 << i)) {
596 if (vty->node == CONFIG_NODE)
597 DEBUG_PACKET_OFF(i, flag);
598 else
599 TERM_DEBUG_PACKET_OFF(i, flag);
600 }
601
602 return CMD_SUCCESS;
7f57883e
DS
603}
604
605/* Debug node. */
d62a17ae 606static struct cmd_node eigrp_debug_node = {
607 DEBUG_NODE, "", 1 /* VTYSH */
7f57883e
DS
608};
609
610/* Initialize debug commands. */
d62a17ae 611void eigrp_debug_init()
7f57883e 612{
d62a17ae 613 install_node(&eigrp_debug_node, config_write_debug);
614
615 install_element(ENABLE_NODE, &show_debugging_eigrp_cmd);
616 install_element(ENABLE_NODE, &debug_eigrp_packets_all_cmd);
617 install_element(ENABLE_NODE, &no_debug_eigrp_packets_all_cmd);
618 install_element(ENABLE_NODE, &debug_eigrp_transmit_cmd);
619 install_element(ENABLE_NODE, &no_debug_eigrp_transmit_cmd);
620
621 install_element(CONFIG_NODE, &show_debugging_eigrp_cmd);
622 install_element(CONFIG_NODE, &debug_eigrp_packets_all_cmd);
623 install_element(CONFIG_NODE, &no_debug_eigrp_packets_all_cmd);
af83cb12 624 install_element(CONFIG_NODE, &debug_eigrp_transmit_cmd);
d62a17ae 625 install_element(CONFIG_NODE, &no_debug_eigrp_transmit_cmd);
7f57883e 626}