usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / zebra / bgpd / bgp_debug.c
blobb00230310226abd1c08c5b2cf8ee97d3e1a66b75
1 /* BGP-4, BGP-4+ packet debug routine
2 Copyright (C) 1996, 97, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
21 #include <zebra.h>
23 #include "version.h"
24 #include "prefix.h"
25 #include "linklist.h"
26 #include "stream.h"
27 #include "command.h"
28 #include "str.h"
29 #include "log.h"
30 #include "sockunion.h"
32 #include "bgpd/bgpd.h"
33 #include "bgpd/bgp_aspath.h"
34 #include "bgpd/bgp_route.h"
35 #include "bgpd/bgp_attr.h"
36 #include "bgpd/bgp_debug.h"
37 #include "bgpd/bgp_community.h"
38 #include "bgpd/bgp_ecommunity.h"
40 unsigned long conf_bgp_debug_fsm;
41 unsigned long conf_bgp_debug_events;
42 unsigned long conf_bgp_debug_packet;
43 unsigned long conf_bgp_debug_filter;
44 unsigned long conf_bgp_debug_keepalive;
45 unsigned long conf_bgp_debug_update;
46 unsigned long conf_bgp_debug_normal;
48 unsigned long term_bgp_debug_fsm;
49 unsigned long term_bgp_debug_events;
50 unsigned long term_bgp_debug_packet;
51 unsigned long term_bgp_debug_filter;
52 unsigned long term_bgp_debug_keepalive;
53 unsigned long term_bgp_debug_update;
54 unsigned long term_bgp_debug_normal;
56 /* messages for BGP-4 status */
57 struct message bgp_status_msg[] =
59 { 0, "null" },
60 { Idle, "Idle" },
61 { Connect, "Connect" },
62 { Active, "Active" },
63 { OpenSent, "OpenSent" },
64 { OpenConfirm, "OpenConfirm" },
65 { Established, "Established" },
67 int bgp_status_msg_max = BGP_STATUS_MAX;
69 /* BGP message type string. */
70 char *bgp_type_str[] =
72 NULL,
73 "OPEN",
74 "UPDATE",
75 "NOTIFICATION",
76 "KEEPALIVE",
77 "ROUTE-REFRESH",
78 "CAPABILITY"
81 /* message for BGP-4 Notify */
82 struct message bgp_notify_msg[] =
84 { 0, "" },
85 { BGP_NOTIFY_HEADER_ERR, "Message Header Error"},
86 { BGP_NOTIFY_OPEN_ERR, "OPEN Message Error"},
87 { BGP_NOTIFY_UPDATE_ERR, "UPDATE Message Error"},
88 { BGP_NOTIFY_HOLD_ERR, "Hold Timer Expired"},
89 { BGP_NOTIFY_FSM_ERR, "Finite State Machine Error"},
90 { BGP_NOTIFY_CEASE, "Cease"},
91 { BGP_NOTIFY_CAPABILITY_ERR, "CAPABILITY Message Error"},
93 int bgp_notify_msg_max = BGP_NOTIFY_MAX;
95 struct message bgp_notify_head_msg[] =
97 { 0, "null"},
98 { BGP_NOTIFY_HEADER_NOT_SYNC, "/Connection Not Synchronized"},
99 { BGP_NOTIFY_HEADER_BAD_MESLEN, "/Bad Message Length"},
100 { BGP_NOTIFY_HEADER_BAD_MESTYPE, "/Bad Message Type"}
102 int bgp_notify_head_msg_max = BGP_NOTIFY_HEADER_MAX;
104 struct message bgp_notify_open_msg[] =
106 { 0, "null" },
107 { BGP_NOTIFY_OPEN_UNSUP_VERSION, "/Unsupported Version Number" },
108 { BGP_NOTIFY_OPEN_BAD_PEER_AS, "/Bad Peer AS"},
109 { BGP_NOTIFY_OPEN_BAD_BGP_IDENT, "/Bad BGP Identifier"},
110 { BGP_NOTIFY_OPEN_UNSUP_PARAM, "/Unsupported Optional Parameter"},
111 { BGP_NOTIFY_OPEN_AUTH_FAILURE, "/Authentication Failure"},
112 { BGP_NOTIFY_OPEN_UNACEP_HOLDTIME, "/Unacceptable Hold Time"},
113 { BGP_NOTIFY_OPEN_UNSUP_CAPBL, "/Unsupported Capability"},
115 int bgp_notify_open_msg_max = BGP_NOTIFY_OPEN_MAX;
117 struct message bgp_notify_update_msg[] =
119 { 0, "null"},
120 { BGP_NOTIFY_UPDATE_MAL_ATTR, "/Malformed Attribute List"},
121 { BGP_NOTIFY_UPDATE_UNREC_ATTR, "/Unrecognized Well-known Attribute"},
122 { BGP_NOTIFY_UPDATE_MISS_ATTR, "/Missing Well-known Attribute"},
123 { BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR, "/Attribute Flags Error"},
124 { BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, "/Attribute Length Error"},
125 { BGP_NOTIFY_UPDATE_INVAL_ORIGIN, "/Invalid ORIGIN Attribute"},
126 { BGP_NOTIFY_UPDATE_AS_ROUTE_LOOP, "/AS Routing Loop"},
127 { BGP_NOTIFY_UPDATE_INVAL_NEXT_HOP, "/Invalid NEXT_HOP Attribute"},
128 { BGP_NOTIFY_UPDATE_OPT_ATTR_ERR, "/Optional Attribute Error"},
129 { BGP_NOTIFY_UPDATE_INVAL_NETWORK, "/Invalid Network Field"},
130 { BGP_NOTIFY_UPDATE_MAL_AS_PATH, "/Malformed AS_PATH"},
132 int bgp_notify_update_msg_max = BGP_NOTIFY_UPDATE_MAX;
134 struct message bgp_notify_cease_msg[] =
136 { 0, ""},
137 { BGP_NOTIFY_CEASE_MAX_PREFIX, "/Maximum Number of Prefixes Reached"},
138 { BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, "/Administratively Shutdown"},
139 { BGP_NOTIFY_CEASE_PEER_UNCONFIG, "/Peer Unconfigured"},
140 { BGP_NOTIFY_CEASE_ADMIN_RESET, "/Administratively Reset"},
141 { BGP_NOTIFY_CEASE_CONNECT_REJECT, "/Connection Rejected"},
142 { BGP_NOTIFY_CEASE_CONFIG_CHANGE, "/Other Configuration Change"},
143 { BGP_NOTIFY_CEASE_CONNECT_COLLISION, "/Connection Collision Resolution"},
144 { BGP_NOTIFY_CEASE_OUT_OF_RESOURCE, "/Out of Resource"},
146 int bgp_notify_cease_msg_max = BGP_NOTIFY_CEASE_MAX;
148 struct message bgp_notify_capability_msg[] =
150 { 0, "null"},
151 { BGP_NOTIFY_CAPABILITY_INVALID_ACTION, "/Invalid Action Value"},
152 { BGP_NOTIFY_CAPABILITY_INVALID_LENGTH, "/Invalid Capability Length"},
153 { BGP_NOTIFY_CAPABILITY_MALFORMED_CODE, "/Malformed Capability Value"},
155 int bgp_notify_capability_msg_max = BGP_NOTIFY_CAPABILITY_MAX;
157 /* Origin strings. */
158 char *bgp_origin_str[] = {"i","e","?"};
159 char *bgp_origin_long_str[] = {"IGP","EGP","incomplete"};
161 /* Dump attribute. */
163 bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size)
165 if (! attr)
166 return 0;
168 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
169 snprintf (buf, size, "nexthop %s", inet_ntoa (attr->nexthop));
171 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
172 snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s",
173 bgp_origin_str[attr->origin]);
175 #ifdef HAVE_IPV6
177 char addrbuf[BUFSIZ];
179 /* Add MP case. */
180 if (attr->mp_nexthop_len == 16 || attr->mp_nexthop_len == 32)
181 snprintf (buf + strlen (buf), size - strlen (buf), ", mp_nexthop %s",
182 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
183 addrbuf, BUFSIZ));
185 if (attr->mp_nexthop_len == 32)
186 snprintf (buf + strlen (buf), size - strlen (buf), "(%s)",
187 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
188 addrbuf, BUFSIZ));
190 #endif /* HAVE_IPV6 */
192 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
193 snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u",
194 attr->local_pref);
196 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)))
197 snprintf (buf + strlen (buf), size - strlen (buf), ", metric %u",
198 attr->med);
200 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
201 snprintf (buf + strlen (buf), size - strlen (buf), ", community %s",
202 community_str (attr->community));
204 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)))
205 snprintf (buf + strlen (buf), size - strlen (buf), ", ecommunity %s",
206 ecommunity_str (attr->ecommunity));
208 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE)))
209 snprintf (buf + strlen (buf), size - strlen (buf), ", atomic-aggregate");
211 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR)))
212 snprintf (buf + strlen (buf), size - strlen (buf), ", aggregated by %d %s",
213 attr->aggregator_as, inet_ntoa (attr->aggregator_addr));
215 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID)))
216 snprintf (buf + strlen (buf), size - strlen (buf), ", originator %s",
217 inet_ntoa (attr->originator_id));
219 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)))
221 int i;
223 snprintf (buf + strlen (buf), size - strlen (buf), ", clusterlist");
224 for (i = 0; i < attr->cluster->length / 4; i++)
225 snprintf (buf + strlen (buf), size - strlen (buf), " %s",
226 inet_ntoa (attr->cluster->list[i]));
229 if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
230 snprintf (buf + strlen (buf), size - strlen (buf), ", path %s",
231 aspath_print (attr->aspath));
233 if (strlen (buf) > 1)
234 return 1;
235 else
236 return 0;
239 /* dump notify packet */
240 void
241 bgp_notify_print(struct peer *peer, struct bgp_notify *bgp_notify, char *direct)
243 char *subcode_str;
245 subcode_str = "";
247 switch (bgp_notify->code)
249 case BGP_NOTIFY_HEADER_ERR:
250 subcode_str = LOOKUP (bgp_notify_head_msg, bgp_notify->subcode);
251 break;
252 case BGP_NOTIFY_OPEN_ERR:
253 subcode_str = LOOKUP (bgp_notify_open_msg, bgp_notify->subcode);
254 break;
255 case BGP_NOTIFY_UPDATE_ERR:
256 subcode_str = LOOKUP (bgp_notify_update_msg, bgp_notify->subcode);
257 break;
258 case BGP_NOTIFY_HOLD_ERR:
259 subcode_str = "";
260 break;
261 case BGP_NOTIFY_FSM_ERR:
262 subcode_str = "";
263 break;
264 case BGP_NOTIFY_CEASE:
265 subcode_str = LOOKUP (bgp_notify_cease_msg, bgp_notify->subcode);
266 break;
267 case BGP_NOTIFY_CAPABILITY_ERR:
268 subcode_str = LOOKUP (bgp_notify_capability_msg, bgp_notify->subcode);
269 break;
272 if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
273 zlog_info ("%%NOTIFICATION: %s neighbor %s %d/%d (%s%s) %d bytes %s",
274 strcmp (direct, "received") == 0 ? "received from" : "sent to",
275 peer->host, bgp_notify->code, bgp_notify->subcode,
276 LOOKUP (bgp_notify_msg, bgp_notify->code),
277 subcode_str, bgp_notify->length,
278 bgp_notify->data ? bgp_notify->data : "");
279 else if (BGP_DEBUG (normal, NORMAL))
280 plog_info (peer->log, "%s %s NOTIFICATION %d/%d (%s%s) %d bytes %s",
281 peer ? peer->host : "",
282 direct, bgp_notify->code, bgp_notify->subcode,
283 LOOKUP (bgp_notify_msg, bgp_notify->code),
284 subcode_str, bgp_notify->length,
285 bgp_notify->data ? bgp_notify->data : "");
288 /* Debug option setting interface. */
289 unsigned long bgp_debug_option = 0;
291 int
292 debug (unsigned int option)
294 return bgp_debug_option & option;
297 DEFUN (debug_bgp_fsm,
298 debug_bgp_fsm_cmd,
299 "debug bgp fsm",
300 DEBUG_STR
301 BGP_STR
302 "BGP Finite State Machine\n")
304 if (vty->node == CONFIG_NODE)
305 DEBUG_ON (fsm, FSM);
306 else
308 TERM_DEBUG_ON (fsm, FSM);
309 vty_out (vty, "BGP fsm debugging is on%s", VTY_NEWLINE);
311 return CMD_SUCCESS;
314 DEFUN (no_debug_bgp_fsm,
315 no_debug_bgp_fsm_cmd,
316 "no debug bgp fsm",
317 NO_STR
318 DEBUG_STR
319 BGP_STR
320 "Finite State Machine\n")
322 if (vty->node == CONFIG_NODE)
323 DEBUG_OFF (fsm, FSM);
324 else
326 TERM_DEBUG_OFF (fsm, FSM);
327 vty_out (vty, "BGP fsm debugging is off%s", VTY_NEWLINE);
329 return CMD_SUCCESS;
332 ALIAS (no_debug_bgp_fsm,
333 undebug_bgp_fsm_cmd,
334 "undebug bgp fsm",
335 UNDEBUG_STR
336 DEBUG_STR
337 BGP_STR
338 "Finite State Machine\n");
340 DEFUN (debug_bgp_events,
341 debug_bgp_events_cmd,
342 "debug bgp events",
343 DEBUG_STR
344 BGP_STR
345 "BGP events\n")
347 if (vty->node == CONFIG_NODE)
348 DEBUG_ON (events, EVENTS);
349 else
351 TERM_DEBUG_ON (events, EVENTS);
352 vty_out (vty, "BGP events debugging is on%s", VTY_NEWLINE);
354 return CMD_SUCCESS;
357 DEFUN (no_debug_bgp_events,
358 no_debug_bgp_events_cmd,
359 "no debug bgp events",
360 NO_STR
361 DEBUG_STR
362 BGP_STR
363 "BGP events\n")
365 if (vty->node == CONFIG_NODE)
366 DEBUG_OFF (events, EVENTS);
367 else
369 TERM_DEBUG_OFF (events, EVENTS);
370 vty_out (vty, "BGP events debugging is off%s", VTY_NEWLINE);
372 return CMD_SUCCESS;
375 ALIAS (no_debug_bgp_events,
376 undebug_bgp_events_cmd,
377 "undebug bgp events",
378 UNDEBUG_STR
379 BGP_STR
380 "BGP events\n");
382 DEFUN (debug_bgp_filter,
383 debug_bgp_filter_cmd,
384 "debug bgp filters",
385 DEBUG_STR
386 BGP_STR
387 "BGP filters\n")
389 if (vty->node == CONFIG_NODE)
390 DEBUG_ON (filter, FILTER);
391 else
393 TERM_DEBUG_ON (filter, FILTER);
394 vty_out (vty, "BGP filters debugging is on%s", VTY_NEWLINE);
396 return CMD_SUCCESS;
399 DEFUN (no_debug_bgp_filter,
400 no_debug_bgp_filter_cmd,
401 "no debug bgp filters",
402 NO_STR
403 DEBUG_STR
404 BGP_STR
405 "BGP filters\n")
407 if (vty->node == CONFIG_NODE)
408 DEBUG_OFF (filter, FILTER);
409 else
411 TERM_DEBUG_OFF (filter, FILTER);
412 vty_out (vty, "BGP filters debugging is off%s", VTY_NEWLINE);
414 return CMD_SUCCESS;
417 ALIAS (no_debug_bgp_filter,
418 undebug_bgp_filter_cmd,
419 "undebug bgp filters",
420 UNDEBUG_STR
421 BGP_STR
422 "BGP filters\n");
424 DEFUN (debug_bgp_keepalive,
425 debug_bgp_keepalive_cmd,
426 "debug bgp keepalives",
427 DEBUG_STR
428 BGP_STR
429 "BGP keepalives\n")
431 if (vty->node == CONFIG_NODE)
432 DEBUG_ON (keepalive, KEEPALIVE);
433 else
435 TERM_DEBUG_ON (keepalive, KEEPALIVE);
436 vty_out (vty, "BGP keepalives debugging is on%s", VTY_NEWLINE);
438 return CMD_SUCCESS;
441 DEFUN (no_debug_bgp_keepalive,
442 no_debug_bgp_keepalive_cmd,
443 "no debug bgp keepalives",
444 NO_STR
445 DEBUG_STR
446 BGP_STR
447 "BGP keepalives\n")
449 if (vty->node == CONFIG_NODE)
450 DEBUG_OFF (keepalive, KEEPALIVE);
451 else
453 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
454 vty_out (vty, "BGP keepalives debugging is off%s", VTY_NEWLINE);
456 return CMD_SUCCESS;
459 ALIAS (no_debug_bgp_keepalive,
460 undebug_bgp_keepalive_cmd,
461 "undebug bgp keepalives",
462 UNDEBUG_STR
463 BGP_STR
464 "BGP keepalives\n");
466 DEFUN (debug_bgp_update,
467 debug_bgp_update_cmd,
468 "debug bgp updates",
469 DEBUG_STR
470 BGP_STR
471 "BGP updates\n")
473 if (vty->node == CONFIG_NODE)
475 DEBUG_ON (update, UPDATE_IN);
476 DEBUG_ON (update, UPDATE_OUT);
478 else
480 TERM_DEBUG_ON (update, UPDATE_IN);
481 TERM_DEBUG_ON (update, UPDATE_OUT);
482 vty_out (vty, "BGP updates debugging is on%s", VTY_NEWLINE);
484 return CMD_SUCCESS;
487 DEFUN (debug_bgp_update_direct,
488 debug_bgp_update_direct_cmd,
489 "debug bgp updates (in|out)",
490 DEBUG_STR
491 BGP_STR
492 "BGP updates\n"
493 "Inbound updates\n"
494 "Outbound updates\n")
496 if (vty->node == CONFIG_NODE)
498 if (strncmp ("i", argv[0], 1) == 0)
500 DEBUG_OFF (update, UPDATE_OUT);
501 DEBUG_ON (update, UPDATE_IN);
503 else
505 DEBUG_OFF (update, UPDATE_IN);
506 DEBUG_ON (update, UPDATE_OUT);
509 else
511 if (strncmp ("i", argv[0], 1) == 0)
513 TERM_DEBUG_OFF (update, UPDATE_OUT);
514 TERM_DEBUG_ON (update, UPDATE_IN);
515 vty_out (vty, "BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
517 else
519 TERM_DEBUG_OFF (update, UPDATE_IN);
520 TERM_DEBUG_ON (update, UPDATE_OUT);
521 vty_out (vty, "BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
524 return CMD_SUCCESS;
527 DEFUN (no_debug_bgp_update,
528 no_debug_bgp_update_cmd,
529 "no debug bgp updates",
530 NO_STR
531 DEBUG_STR
532 BGP_STR
533 "BGP updates\n")
535 if (vty->node == CONFIG_NODE)
537 DEBUG_OFF (update, UPDATE_IN);
538 DEBUG_OFF (update, UPDATE_OUT);
540 else
542 TERM_DEBUG_OFF (update, UPDATE_IN);
543 TERM_DEBUG_OFF (update, UPDATE_OUT);
544 vty_out (vty, "BGP updates debugging is off%s", VTY_NEWLINE);
546 return CMD_SUCCESS;
549 ALIAS (no_debug_bgp_update,
550 undebug_bgp_update_cmd,
551 "undebug bgp updates",
552 UNDEBUG_STR
553 BGP_STR
554 "BGP updates\n");
556 DEFUN (debug_bgp_normal,
557 debug_bgp_normal_cmd,
558 "debug bgp",
559 DEBUG_STR
560 BGP_STR)
562 if (vty->node == CONFIG_NODE)
563 DEBUG_ON (normal, NORMAL);
564 else
566 TERM_DEBUG_ON (normal, NORMAL);
567 vty_out (vty, "BGP debugging is on%s", VTY_NEWLINE);
569 return CMD_SUCCESS;
572 DEFUN (no_debug_bgp_normal,
573 no_debug_bgp_normal_cmd,
574 "no debug bgp",
575 NO_STR
576 DEBUG_STR
577 BGP_STR)
579 if (vty->node == CONFIG_NODE)
580 DEBUG_OFF (normal, NORMAL);
581 else
583 TERM_DEBUG_OFF (normal, NORMAL);
584 vty_out (vty, "BGP debugging is off%s", VTY_NEWLINE);
586 return CMD_SUCCESS;
589 ALIAS (no_debug_bgp_normal,
590 undebug_bgp_normal_cmd,
591 "undebug bgp",
592 UNDEBUG_STR
593 BGP_STR);
595 DEFUN (no_debug_bgp_all,
596 no_debug_bgp_all_cmd,
597 "no debug all bgp",
598 NO_STR
599 DEBUG_STR
600 "Enable all debugging\n"
601 BGP_STR)
603 TERM_DEBUG_OFF (normal, NORMAL);
604 TERM_DEBUG_OFF (events, EVENTS);
605 TERM_DEBUG_OFF (keepalive, KEEPALIVE);
606 TERM_DEBUG_OFF (update, UPDATE_IN);
607 TERM_DEBUG_OFF (update, UPDATE_OUT);
608 TERM_DEBUG_OFF (fsm, FSM);
609 TERM_DEBUG_OFF (filter, FILTER);
610 vty_out (vty, "All possible debugging has been turned off%s", VTY_NEWLINE);
612 return CMD_SUCCESS;
615 ALIAS (no_debug_bgp_all,
616 undebug_bgp_all_cmd,
617 "undebug all bgp",
618 UNDEBUG_STR
619 "Enable all debugging\n"
620 BGP_STR);
622 DEFUN (show_debugging_bgp,
623 show_debugging_bgp_cmd,
624 "show debugging bgp",
625 SHOW_STR
626 DEBUG_STR
627 BGP_STR)
629 vty_out (vty, "BGP debugging status:%s", VTY_NEWLINE);
631 if (BGP_DEBUG (normal, NORMAL))
632 vty_out (vty, " BGP debugging is on%s", VTY_NEWLINE);
633 if (BGP_DEBUG (events, EVENTS))
634 vty_out (vty, " BGP events debugging is on%s", VTY_NEWLINE);
635 if (BGP_DEBUG (keepalive, KEEPALIVE))
636 vty_out (vty, " BGP keepalives debugging is on%s", VTY_NEWLINE);
637 if (BGP_DEBUG (update, UPDATE_IN) && BGP_DEBUG (update, UPDATE_OUT))
638 vty_out (vty, " BGP updates debugging is on%s", VTY_NEWLINE);
639 else if (BGP_DEBUG (update, UPDATE_IN))
640 vty_out (vty, " BGP updates debugging is on (inbound)%s", VTY_NEWLINE);
641 else if (BGP_DEBUG (update, UPDATE_OUT))
642 vty_out (vty, " BGP updates debugging is on (outbound)%s", VTY_NEWLINE);
643 if (BGP_DEBUG (fsm, FSM))
644 vty_out (vty, " BGP fsm debugging is on%s", VTY_NEWLINE);
645 if (BGP_DEBUG (filter, FILTER))
646 vty_out (vty, " BGP filter debugging is on%s", VTY_NEWLINE);
647 vty_out (vty, "%s", VTY_NEWLINE);
648 return CMD_SUCCESS;
652 bgp_config_write_debug (struct vty *vty)
654 int write = 0;
656 if (CONF_BGP_DEBUG (normal, NORMAL))
658 vty_out (vty, "debug bgp%s", VTY_NEWLINE);
659 write++;
662 if (CONF_BGP_DEBUG (events, EVENTS))
664 vty_out (vty, "debug bgp events%s", VTY_NEWLINE);
665 write++;
668 if (CONF_BGP_DEBUG (keepalive, KEEPALIVE))
670 vty_out (vty, "debug bgp keepalives%s", VTY_NEWLINE);
671 write++;
674 if (CONF_BGP_DEBUG (update, UPDATE_IN) && CONF_BGP_DEBUG (update, UPDATE_OUT))
676 vty_out (vty, "debug bgp updates%s", VTY_NEWLINE);
677 write++;
679 else if (CONF_BGP_DEBUG (update, UPDATE_IN))
681 vty_out (vty, "debug bgp updates in%s", VTY_NEWLINE);
682 write++;
684 else if (CONF_BGP_DEBUG (update, UPDATE_OUT))
686 vty_out (vty, "debug bgp updates out%s", VTY_NEWLINE);
687 write++;
690 if (CONF_BGP_DEBUG (fsm, FSM))
692 vty_out (vty, "debug bgp fsm%s", VTY_NEWLINE);
693 write++;
696 if (CONF_BGP_DEBUG (filter, FILTER))
698 vty_out (vty, "debug bgp filters%s", VTY_NEWLINE);
699 write++;
702 return write;
705 struct cmd_node debug_node =
707 DEBUG_NODE,
712 void
713 bgp_debug_init ()
715 install_node (&debug_node, bgp_config_write_debug);
717 install_element (ENABLE_NODE, &show_debugging_bgp_cmd);
719 install_element (ENABLE_NODE, &debug_bgp_fsm_cmd);
720 install_element (CONFIG_NODE, &debug_bgp_fsm_cmd);
721 install_element (ENABLE_NODE, &debug_bgp_events_cmd);
722 install_element (CONFIG_NODE, &debug_bgp_events_cmd);
723 install_element (ENABLE_NODE, &debug_bgp_filter_cmd);
724 install_element (CONFIG_NODE, &debug_bgp_filter_cmd);
725 install_element (ENABLE_NODE, &debug_bgp_keepalive_cmd);
726 install_element (CONFIG_NODE, &debug_bgp_keepalive_cmd);
727 install_element (ENABLE_NODE, &debug_bgp_update_cmd);
728 install_element (CONFIG_NODE, &debug_bgp_update_cmd);
729 install_element (ENABLE_NODE, &debug_bgp_update_direct_cmd);
730 install_element (CONFIG_NODE, &debug_bgp_update_direct_cmd);
731 install_element (ENABLE_NODE, &debug_bgp_normal_cmd);
732 install_element (CONFIG_NODE, &debug_bgp_normal_cmd);
734 install_element (ENABLE_NODE, &no_debug_bgp_fsm_cmd);
735 install_element (ENABLE_NODE, &undebug_bgp_fsm_cmd);
736 install_element (CONFIG_NODE, &no_debug_bgp_fsm_cmd);
737 install_element (ENABLE_NODE, &no_debug_bgp_events_cmd);
738 install_element (ENABLE_NODE, &undebug_bgp_events_cmd);
739 install_element (CONFIG_NODE, &no_debug_bgp_events_cmd);
740 install_element (ENABLE_NODE, &no_debug_bgp_filter_cmd);
741 install_element (ENABLE_NODE, &undebug_bgp_filter_cmd);
742 install_element (CONFIG_NODE, &no_debug_bgp_filter_cmd);
743 install_element (ENABLE_NODE, &no_debug_bgp_keepalive_cmd);
744 install_element (ENABLE_NODE, &undebug_bgp_keepalive_cmd);
745 install_element (CONFIG_NODE, &no_debug_bgp_keepalive_cmd);
746 install_element (ENABLE_NODE, &no_debug_bgp_update_cmd);
747 install_element (ENABLE_NODE, &undebug_bgp_update_cmd);
748 install_element (CONFIG_NODE, &no_debug_bgp_update_cmd);
749 install_element (ENABLE_NODE, &no_debug_bgp_normal_cmd);
750 install_element (ENABLE_NODE, &undebug_bgp_normal_cmd);
751 install_element (CONFIG_NODE, &no_debug_bgp_normal_cmd);
752 install_element (ENABLE_NODE, &no_debug_bgp_all_cmd);
753 install_element (ENABLE_NODE, &undebug_bgp_all_cmd);