diff options
Diffstat (limited to 'bgpd/rfapi/vnc_debug.c')
| -rw-r--r-- | bgpd/rfapi/vnc_debug.c | 176 | 
1 files changed, 78 insertions, 98 deletions
diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c index b5ff5bbc88..77f3c81946 100644 --- a/bgpd/rfapi/vnc_debug.c +++ b/bgpd/rfapi/vnc_debug.c @@ -1,4 +1,4 @@ -/*  +/*   *   * Copyright 2016, LabN Consulting, L.L.C.   * @@ -35,19 +35,18 @@ unsigned long conf_vnc_debug;  unsigned long term_vnc_debug;  struct vnc_debug { -	unsigned long	bit; -	const char		*name; +	unsigned long bit; +	const char *name;  }; -struct vnc_debug	vncdebug[] = -{ -	{VNC_DEBUG_RFAPI_QUERY,		"rfapi-query"}, -	{VNC_DEBUG_IMPORT_BI_ATTACH,	"import-bi-attach"}, -	{VNC_DEBUG_IMPORT_DEL_REMOTE,	"import-del-remote"}, -	{VNC_DEBUG_EXPORT_BGP_GETCE,	"export-bgp-getce"}, -	{VNC_DEBUG_EXPORT_BGP_DIRECT_ADD,	"export-bgp-direct-add"}, -	{VNC_DEBUG_IMPORT_BGP_ADD_ROUTE,	"import-bgp-add-route"}, -	{VNC_DEBUG_VERBOSE,         	"verbose"}, +struct vnc_debug vncdebug[] = { +	{VNC_DEBUG_RFAPI_QUERY, "rfapi-query"}, +	{VNC_DEBUG_IMPORT_BI_ATTACH, "import-bi-attach"}, +	{VNC_DEBUG_IMPORT_DEL_REMOTE, "import-del-remote"}, +	{VNC_DEBUG_EXPORT_BGP_GETCE, "export-bgp-getce"}, +	{VNC_DEBUG_EXPORT_BGP_DIRECT_ADD, "export-bgp-direct-add"}, +	{VNC_DEBUG_IMPORT_BGP_ADD_ROUTE, "import-bgp-add-route"}, +	{VNC_DEBUG_VERBOSE, "verbose"},  };  #define VNC_STR "VNC information\n" @@ -66,28 +65,23 @@ DEFUN (debug_bgp_vnc,         "import delete remote routes\n"         "verbose logging\n")  { -  size_t	i; - -  for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) -    { -      if (!strcmp(argv[3]->arg, vncdebug[i].name)) -	{ -	  if (vty->node == CONFIG_NODE) -	    { -	      conf_vnc_debug |= vncdebug[i].bit; -	      term_vnc_debug |= vncdebug[i].bit; -	    } -	  else -	    { -	      term_vnc_debug |= vncdebug[i].bit; -	      vty_out (vty, "BGP vnc %s debugging is on%s", -		vncdebug[i].name, VTY_NEWLINE); -	    } -	  return CMD_SUCCESS; +	size_t i; + +	for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) { +		if (!strcmp(argv[3]->arg, vncdebug[i].name)) { +			if (vty->node == CONFIG_NODE) { +				conf_vnc_debug |= vncdebug[i].bit; +				term_vnc_debug |= vncdebug[i].bit; +			} else { +				term_vnc_debug |= vncdebug[i].bit; +				vty_out(vty, "BGP vnc %s debugging is on%s", +					vncdebug[i].name, VTY_NEWLINE); +			} +			return CMD_SUCCESS; +		}  	} -    } -  vty_out (vty, "Unknown debug flag: %s%s", argv[3]->arg, VTY_NEWLINE); -  return CMD_WARNING; +	vty_out(vty, "Unknown debug flag: %s%s", argv[3]->arg, VTY_NEWLINE); +	return CMD_WARNING;  }  DEFUN (no_debug_bgp_vnc, @@ -103,30 +97,25 @@ DEFUN (no_debug_bgp_vnc,         "import delete remote routes\n"         "verbose logging\n")  { -  size_t	i; - -  if (!strcmp(argv[0]->arg, "no")) -    argc--, argv++; -  for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) -    { -      if (!strcmp(argv[3]->arg, vncdebug[i].name)) -	{ -	  if (vty->node == CONFIG_NODE) -	    { -	      conf_vnc_debug &= ~vncdebug[i].bit; -	      term_vnc_debug &= ~vncdebug[i].bit; -	    } -	  else -	    { -	      term_vnc_debug &= ~vncdebug[i].bit; -	      vty_out (vty, "BGP vnc %s debugging is off%s", -		vncdebug[i].name, VTY_NEWLINE); -	    } -	  return CMD_SUCCESS; +	size_t i; + +	if (!strcmp(argv[0]->arg, "no")) +		argc--, argv++; +	for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) { +		if (!strcmp(argv[3]->arg, vncdebug[i].name)) { +			if (vty->node == CONFIG_NODE) { +				conf_vnc_debug &= ~vncdebug[i].bit; +				term_vnc_debug &= ~vncdebug[i].bit; +			} else { +				term_vnc_debug &= ~vncdebug[i].bit; +				vty_out(vty, "BGP vnc %s debugging is off%s", +					vncdebug[i].name, VTY_NEWLINE); +			} +			return CMD_SUCCESS; +		}  	} -    } -  vty_out (vty, "Unknown debug flag: %s%s", argv[3]->arg, VTY_NEWLINE); -  return CMD_WARNING; +	vty_out(vty, "Unknown debug flag: %s%s", argv[3]->arg, VTY_NEWLINE); +	return CMD_WARNING;  } @@ -144,10 +133,11 @@ DEFUN (no_debug_bgp_vnc_all,         BGP_STR         VNC_STR)  { -  term_vnc_debug = 0; -  vty_out (vty, "All possible VNC debugging has been turned off%s", VTY_NEWLINE); -       -  return CMD_SUCCESS; +	term_vnc_debug = 0; +	vty_out(vty, "All possible VNC debugging has been turned off%s", +		VTY_NEWLINE); + +	return CMD_SUCCESS;  }  /*********************************************************************** @@ -162,55 +152,45 @@ DEFUN (show_debugging_bgp_vnc,         BGP_STR         VNC_STR)  { -  size_t	i; +	size_t i; -  vty_out (vty, "BGP VNC debugging status:%s", VTY_NEWLINE); +	vty_out(vty, "BGP VNC debugging status:%s", VTY_NEWLINE); -  for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) -    { -      if (term_vnc_debug & vncdebug[i].bit) -	{ -	  vty_out (vty, "  BGP VNC %s debugging is on%s", -	    vncdebug[i].name, VTY_NEWLINE); +	for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) { +		if (term_vnc_debug & vncdebug[i].bit) { +			vty_out(vty, "  BGP VNC %s debugging is on%s", +				vncdebug[i].name, VTY_NEWLINE); +		}  	} -    } -  vty_out (vty, "%s", VTY_NEWLINE); -  return CMD_SUCCESS; +	vty_out(vty, "%s", VTY_NEWLINE); +	return CMD_SUCCESS;  } -static int -bgp_vnc_config_write_debug (struct vty *vty) +static int bgp_vnc_config_write_debug(struct vty *vty)  { -  int write = 0; -  size_t	i; - -  for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) -    { -      if (conf_vnc_debug & vncdebug[i].bit) -	{ -	  vty_out (vty, "debug bgp vnc %s%s", vncdebug[i].name, VTY_NEWLINE); -	  write++; +	int write = 0; +	size_t i; + +	for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) { +		if (conf_vnc_debug & vncdebug[i].bit) { +			vty_out(vty, "debug bgp vnc %s%s", vncdebug[i].name, +				VTY_NEWLINE); +			write++; +		}  	} -    } -  return write; +	return write;  } -static struct cmd_node debug_node = -{ -  DEBUG_VNC_NODE, -  "", -  1 -}; +static struct cmd_node debug_node = {DEBUG_VNC_NODE, "", 1}; -void -vnc_debug_init (void) +void vnc_debug_init(void)  { -  install_node (&debug_node, bgp_vnc_config_write_debug); -  install_element (ENABLE_NODE, &show_debugging_bgp_vnc_cmd); +	install_node(&debug_node, bgp_vnc_config_write_debug); +	install_element(ENABLE_NODE, &show_debugging_bgp_vnc_cmd); -  install_element (ENABLE_NODE, &debug_bgp_vnc_cmd); -  install_element (CONFIG_NODE, &debug_bgp_vnc_cmd); -  install_element (ENABLE_NODE, &no_debug_bgp_vnc_cmd); +	install_element(ENABLE_NODE, &debug_bgp_vnc_cmd); +	install_element(CONFIG_NODE, &debug_bgp_vnc_cmd); +	install_element(ENABLE_NODE, &no_debug_bgp_vnc_cmd); -  install_element (ENABLE_NODE, &no_debug_bgp_vnc_all_cmd); +	install_element(ENABLE_NODE, &no_debug_bgp_vnc_all_cmd);  }  | 
