diff options
Diffstat (limited to 'vtysh/vtysh_config.c')
| -rw-r--r-- | vtysh/vtysh_config.c | 678 | 
1 files changed, 337 insertions, 341 deletions
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 4dd373ed97..74509d1ec8 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -28,414 +28,410 @@  #include "vtysh/vtysh_user.h"  DEFINE_MGROUP(MVTYSH, "vtysh") -DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG,      "Vtysh configuration") +DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG, "Vtysh configuration")  DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line")  vector configvec; -struct config -{ -  /* Configuration node name. */ -  char *name; +struct config { +	/* Configuration node name. */ +	char *name; -  /* Configuration string line. */ -  struct list *line; +	/* Configuration string line. */ +	struct list *line; -  /* Configuration can be nest. */ -  struct config *config; +	/* Configuration can be nest. */ +	struct config *config; -  /* Index of this config. */ -  u_int32_t index; +	/* Index of this config. */ +	u_int32_t index;  };  struct list *config_top; -static int -line_cmp (char *c1, char *c2) +static int line_cmp(char *c1, char *c2)  { -  return strcmp (c1, c2); +	return strcmp(c1, c2);  } -static void -line_del (char *line) +static void line_del(char *line)  { -  XFREE (MTYPE_VTYSH_CONFIG_LINE, line); +	XFREE(MTYPE_VTYSH_CONFIG_LINE, line);  } -static struct config * -config_new (void) +static struct config *config_new(void)  { -  struct config *config; -  config = XCALLOC (MTYPE_VTYSH_CONFIG, sizeof (struct config)); -  return config; +	struct config *config; +	config = XCALLOC(MTYPE_VTYSH_CONFIG, sizeof(struct config)); +	return config;  } -static int -config_cmp (struct config *c1, struct config *c2) +static int config_cmp(struct config *c1, struct config *c2)  { -  return strcmp (c1->name, c2->name); +	return strcmp(c1->name, c2->name);  } -static void -config_del (struct config* config) +static void config_del(struct config *config)  { -  list_delete (config->line); -  if (config->name) -    XFREE (MTYPE_VTYSH_CONFIG_LINE, config->name); -  XFREE (MTYPE_VTYSH_CONFIG, config); +	list_delete(config->line); +	if (config->name) +		XFREE(MTYPE_VTYSH_CONFIG_LINE, config->name); +	XFREE(MTYPE_VTYSH_CONFIG, config);  } -static struct config * -config_get (int index, const char *line) +static struct config *config_get(int index, const char *line)  { -  struct config *config; -  struct config *config_loop; -  struct list *master; -  struct listnode *node, *nnode; - -  config = config_loop = NULL; - -  master = vector_lookup_ensure (configvec, index); - -  if (! master) -    { -      master = list_new (); -      master->del = (void (*) (void *))config_del; -      master->cmp = (int (*)(void *, void *)) config_cmp; -      vector_set_index (configvec, index, master); -    } -   -  for (ALL_LIST_ELEMENTS (master, node, nnode, config_loop)) -    { -      if (strcmp (config_loop->name, line) == 0) -	config = config_loop; -    } - -  if (! config) -    { -      config = config_new (); -      config->line = list_new (); -      config->line->del = (void (*) (void *))line_del; -      config->line->cmp = (int (*)(void *, void *)) line_cmp; -      config->name = XSTRDUP (MTYPE_VTYSH_CONFIG_LINE, line); -      config->index = index; -      listnode_add (master, config); -    } -  return config; +	struct config *config; +	struct config *config_loop; +	struct list *master; +	struct listnode *node, *nnode; + +	config = config_loop = NULL; + +	master = vector_lookup_ensure(configvec, index); + +	if (!master) { +		master = list_new(); +		master->del = (void (*)(void *))config_del; +		master->cmp = (int (*)(void *, void *))config_cmp; +		vector_set_index(configvec, index, master); +	} + +	for (ALL_LIST_ELEMENTS(master, node, nnode, config_loop)) { +		if (strcmp(config_loop->name, line) == 0) +			config = config_loop; +	} + +	if (!config) { +		config = config_new(); +		config->line = list_new(); +		config->line->del = (void (*)(void *))line_del; +		config->line->cmp = (int (*)(void *, void *))line_cmp; +		config->name = XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line); +		config->index = index; +		listnode_add(master, config); +	} +	return config;  } -void -config_add_line (struct list *config, const char *line) +void config_add_line(struct list *config, const char *line)  { -  listnode_add (config, XSTRDUP (MTYPE_VTYSH_CONFIG_LINE, line)); +	listnode_add(config, XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line));  } -static void -config_add_line_uniq (struct list *config, const char *line) +static void config_add_line_uniq(struct list *config, const char *line)  { -  struct listnode *node, *nnode; -  char *pnt; - -  for (ALL_LIST_ELEMENTS (config, node, nnode, pnt)) -    { -      if (strcmp (pnt, line) == 0) -	return; -    } -  listnode_add_sort (config, XSTRDUP (MTYPE_VTYSH_CONFIG_LINE, line)); +	struct listnode *node, *nnode; +	char *pnt; + +	for (ALL_LIST_ELEMENTS(config, node, nnode, pnt)) { +		if (strcmp(pnt, line) == 0) +			return; +	} +	listnode_add_sort(config, XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line));  } -void -vtysh_config_parse_line (void *arg, const char *line) +void vtysh_config_parse_line(void *arg, const char *line)  { -  char c; -  static struct config *config = NULL; - -  if (! line) -    return; - -  c = line[0]; - -  if (c == '\0') -    return; - -  /* printf ("[%s]\n", line); */ - -  switch (c) -    { -    /* Suppress exclamation points ! and commented lines. The !s are generated -     * dynamically in vtysh_config_dump() */ -    case '!': -    case '#': -      break; -    case ' ': -      /* Store line to current configuration. */ -      if (config) -	{ -	  if (strncmp (line, " link-params", strlen (" link-params")) == 0) -	    { -	      config_add_line (config->line, line); -	      config->index = LINK_PARAMS_NODE; -	    } -	  else if (config->index == LINK_PARAMS_NODE && -	      strncmp (line, "  exit-link-params", strlen ("  exit")) == 0) -	    { -	      config_add_line (config->line, line); -	      config->index = INTERFACE_NODE; -	    } -	  else if (config->index == RMAP_NODE || -                   config->index == INTERFACE_NODE || -                   config->index == NS_NODE || -                   config->index == VTY_NODE || -                   config->index == VRF_NODE) -	    config_add_line_uniq (config->line, line); -	  else -	    config_add_line (config->line, line); -	} -      else -	config_add_line (config_top, line); -      break; -    default: -      if (strncmp (line, "interface", strlen ("interface")) == 0) -	config = config_get (INTERFACE_NODE, line); -      else if (strncmp (line, "logical-router", strlen ("ns")) == 0) -	config = config_get (NS_NODE, line); -      else if (strncmp (line, "vrf", strlen ("vrf")) == 0) -	config = config_get (VRF_NODE, line); -      else if (strncmp (line, "router-id", strlen ("router-id")) == 0) -	config = config_get (ZEBRA_NODE, line); -      else if (strncmp (line, "router rip", strlen ("router rip")) == 0) -	config = config_get (RIP_NODE, line); -      else if (strncmp (line, "router ripng", strlen ("router ripng")) == 0) -	config = config_get (RIPNG_NODE, line); -      else if (strncmp (line, "router eigrp", strlen ("router eigrp")) == 0) -        config = config_get (EIGRP_NODE, line); -      else if (strncmp (line, "router babel", strlen ("router babel")) == 0) -	config = config_get (BABEL_NODE, line); -      else if (strncmp (line, "router ospf", strlen ("router ospf")) == 0) -	config = config_get (OSPF_NODE, line); -      else if (strncmp (line, "router ospf6", strlen ("router ospf6")) == 0) -	config = config_get (OSPF6_NODE, line); -      else if (strncmp (line, "mpls ldp", strlen ("mpls ldp")) == 0) -	config = config_get (LDP_NODE, line); -      else if (strncmp (line, "l2vpn", strlen ("l2vpn")) == 0) -	config = config_get (LDP_L2VPN_NODE, line); -      else if (strncmp (line, "router bgp", strlen ("router bgp")) == 0) -	config = config_get (BGP_NODE, line); -      else if (strncmp (line, "router isis", strlen ("router isis")) == 0) -  	config = config_get (ISIS_NODE, line); -      else if (strncmp (line, "route-map", strlen ("route-map")) == 0) -	config = config_get (RMAP_NODE, line); -      else if (strncmp (line, "access-list", strlen ("access-list")) == 0) -	config = config_get (ACCESS_NODE, line); -      else if (strncmp (line, "ipv6 access-list", -	       strlen ("ipv6 access-list")) == 0) -	config = config_get (ACCESS_IPV6_NODE, line); -      else if (strncmp (line, "ip prefix-list", -	       strlen ("ip prefix-list")) == 0) -	config = config_get (PREFIX_NODE, line); -      else if (strncmp (line, "ipv6 prefix-list", -	       strlen ("ipv6 prefix-list")) == 0) -	config = config_get (PREFIX_IPV6_NODE, line); -      else if (strncmp (line, "ip as-path access-list", -	       strlen ("ip as-path access-list")) == 0) -	config = config_get (AS_LIST_NODE, line); -      else if (strncmp (line, "ip community-list", strlen ("ip community-list")) == 0 || -               strncmp (line, "ip extcommunity-list", strlen ("ip extcommunity-list")) == 0) -	config = config_get (COMMUNITY_LIST_NODE, line); -      else if (strncmp (line, "ip route", strlen ("ip route")) == 0) -	config = config_get (IP_NODE, line); -      else if (strncmp (line, "ipv6 route", strlen ("ipv6 route")) == 0) -   	config = config_get (IP_NODE, line); -      else if (strncmp (line, "key", strlen ("key")) == 0) -	config = config_get (KEYCHAIN_NODE, line); -      else if (strncmp (line, "line", strlen ("line")) == 0) -	config = config_get (VTY_NODE, line); -      else if ( (strncmp (line, "ipv6 forwarding", -		 strlen ("ipv6 forwarding")) == 0) -	       || (strncmp (line, "ip forwarding", -		   strlen ("ip forwarding")) == 0) ) -	config = config_get (FORWARDING_NODE, line); -      else if (strncmp (line, "service", strlen ("service")) == 0) -	config = config_get (SERVICE_NODE, line); -      else if (strncmp (line, "debug vrf", strlen ("debug vrf")) == 0) -	config = config_get (VRF_DEBUG_NODE, line); -      else if (strncmp (line, "debug", strlen ("debug")) == 0) -	config = config_get (DEBUG_NODE, line); -      else if (strncmp (line, "password", strlen ("password")) == 0 -	       || strncmp (line, "enable password", -			   strlen ("enable password")) == 0) -	config = config_get (AAA_NODE, line); -      else if (strncmp (line, "ip protocol", strlen ("ip protocol")) == 0) -	config = config_get (PROTOCOL_NODE, line); -      else if (strncmp (line, "ipv6 protocol", strlen ("ipv6 protocol")) == 0) -	config = config_get (PROTOCOL_NODE, line); -      else if (strncmp (line, "ip nht", strlen ("ip nht")) == 0) -	config = config_get (PROTOCOL_NODE, line); -      else if (strncmp (line, "ipv6 nht", strlen ("ipv6 nht")) == 0) -	config = config_get (PROTOCOL_NODE, line); -      else if (strncmp (line, "mpls", strlen ("mpls")) == 0) -	config = config_get (MPLS_NODE, line); -      else -	{ -	  if (strncmp (line, "log", strlen ("log")) == 0 -	      || strncmp (line, "hostname", strlen ("hostname")) == 0 -	      || strncmp (line, "frr", strlen ("frr")) == 0 -	      || strncmp (line, "agentx", strlen ("agentx")) == 0 -              || strncmp (line, "no log", strlen ("no log")) == 0 -	     ) -	    config_add_line_uniq (config_top, line); -	  else -	    config_add_line (config_top, line); -	  config = NULL; +	char c; +	static struct config *config = NULL; + +	if (!line) +		return; + +	c = line[0]; + +	if (c == '\0') +		return; + +	/* printf ("[%s]\n", line); */ + +	switch (c) { +	/* Suppress exclamation points ! and commented lines. The !s are +	 * generated +	 * dynamically in vtysh_config_dump() */ +	case '!': +	case '#': +		break; +	case ' ': +		/* Store line to current configuration. */ +		if (config) { +			if (strncmp(line, " link-params", +				    strlen(" link-params")) +			    == 0) { +				config_add_line(config->line, line); +				config->index = LINK_PARAMS_NODE; +			} else if (config->index == LINK_PARAMS_NODE +				   && strncmp(line, "  exit-link-params", +					      strlen("  exit")) +					      == 0) { +				config_add_line(config->line, line); +				config->index = INTERFACE_NODE; +			} else if (config->index == RMAP_NODE +				   || config->index == INTERFACE_NODE +				   || config->index == NS_NODE +				   || config->index == VTY_NODE +				   || config->index == VRF_NODE) +				config_add_line_uniq(config->line, line); +			else +				config_add_line(config->line, line); +		} else +			config_add_line(config_top, line); +		break; +	default: +		if (strncmp(line, "interface", strlen("interface")) == 0) +			config = config_get(INTERFACE_NODE, line); +		else if (strncmp(line, "logical-router", strlen("ns")) == 0) +			config = config_get(NS_NODE, line); +		else if (strncmp(line, "vrf", strlen("vrf")) == 0) +			config = config_get(VRF_NODE, line); +		else if (strncmp(line, "router-id", strlen("router-id")) == 0) +			config = config_get(ZEBRA_NODE, line); +		else if (strncmp(line, "router rip", strlen("router rip")) == 0) +			config = config_get(RIP_NODE, line); +		else if (strncmp(line, "router ripng", strlen("router ripng")) +			 == 0) +			config = config_get(RIPNG_NODE, line); +		else if (strncmp(line, "router eigrp", strlen("router eigrp")) +			 == 0) +			config = config_get(EIGRP_NODE, line); +		else if (strncmp(line, "router babel", strlen("router babel")) +			 == 0) +			config = config_get(BABEL_NODE, line); +		else if (strncmp(line, "router ospf", strlen("router ospf")) +			 == 0) +			config = config_get(OSPF_NODE, line); +		else if (strncmp(line, "router ospf6", strlen("router ospf6")) +			 == 0) +			config = config_get(OSPF6_NODE, line); +		else if (strncmp(line, "mpls ldp", strlen("mpls ldp")) == 0) +			config = config_get(LDP_NODE, line); +		else if (strncmp(line, "l2vpn", strlen("l2vpn")) == 0) +			config = config_get(LDP_L2VPN_NODE, line); +		else if (strncmp(line, "router bgp", strlen("router bgp")) == 0) +			config = config_get(BGP_NODE, line); +		else if (strncmp(line, "router isis", strlen("router isis")) +			 == 0) +			config = config_get(ISIS_NODE, line); +		else if (strncmp(line, "route-map", strlen("route-map")) == 0) +			config = config_get(RMAP_NODE, line); +		else if (strncmp(line, "access-list", strlen("access-list")) +			 == 0) +			config = config_get(ACCESS_NODE, line); +		else if (strncmp(line, "ipv6 access-list", +				 strlen("ipv6 access-list")) +			 == 0) +			config = config_get(ACCESS_IPV6_NODE, line); +		else if (strncmp(line, "ip prefix-list", +				 strlen("ip prefix-list")) +			 == 0) +			config = config_get(PREFIX_NODE, line); +		else if (strncmp(line, "ipv6 prefix-list", +				 strlen("ipv6 prefix-list")) +			 == 0) +			config = config_get(PREFIX_IPV6_NODE, line); +		else if (strncmp(line, "ip as-path access-list", +				 strlen("ip as-path access-list")) +			 == 0) +			config = config_get(AS_LIST_NODE, line); +		else if (strncmp(line, "ip community-list", +				 strlen("ip community-list")) +				 == 0 +			 || strncmp(line, "ip extcommunity-list", +				    strlen("ip extcommunity-list")) +				    == 0) +			config = config_get(COMMUNITY_LIST_NODE, line); +		else if (strncmp(line, "ip route", strlen("ip route")) == 0) +			config = config_get(IP_NODE, line); +		else if (strncmp(line, "ipv6 route", strlen("ipv6 route")) == 0) +			config = config_get(IP_NODE, line); +		else if (strncmp(line, "key", strlen("key")) == 0) +			config = config_get(KEYCHAIN_NODE, line); +		else if (strncmp(line, "line", strlen("line")) == 0) +			config = config_get(VTY_NODE, line); +		else if ((strncmp(line, "ipv6 forwarding", +				  strlen("ipv6 forwarding")) +			  == 0) +			 || (strncmp(line, "ip forwarding", +				     strlen("ip forwarding")) +			     == 0)) +			config = config_get(FORWARDING_NODE, line); +		else if (strncmp(line, "service", strlen("service")) == 0) +			config = config_get(SERVICE_NODE, line); +		else if (strncmp(line, "debug vrf", strlen("debug vrf")) == 0) +			config = config_get(VRF_DEBUG_NODE, line); +		else if (strncmp(line, "debug", strlen("debug")) == 0) +			config = config_get(DEBUG_NODE, line); +		else if (strncmp(line, "password", strlen("password")) == 0 +			 || strncmp(line, "enable password", +				    strlen("enable password")) +				    == 0) +			config = config_get(AAA_NODE, line); +		else if (strncmp(line, "ip protocol", strlen("ip protocol")) +			 == 0) +			config = config_get(PROTOCOL_NODE, line); +		else if (strncmp(line, "ipv6 protocol", strlen("ipv6 protocol")) +			 == 0) +			config = config_get(PROTOCOL_NODE, line); +		else if (strncmp(line, "ip nht", strlen("ip nht")) == 0) +			config = config_get(PROTOCOL_NODE, line); +		else if (strncmp(line, "ipv6 nht", strlen("ipv6 nht")) == 0) +			config = config_get(PROTOCOL_NODE, line); +		else if (strncmp(line, "mpls", strlen("mpls")) == 0) +			config = config_get(MPLS_NODE, line); +		else { +			if (strncmp(line, "log", strlen("log")) == 0 +			    || strncmp(line, "hostname", strlen("hostname")) +				       == 0 +			    || strncmp(line, "frr", strlen("frr")) == 0 +			    || strncmp(line, "agentx", strlen("agentx")) == 0 +			    || strncmp(line, "no log", strlen("no log")) == 0) +				config_add_line_uniq(config_top, line); +			else +				config_add_line(config_top, line); +			config = NULL; +		} +		break;  	} -      break; -    }  }  /* Macro to check delimiter is needed between each configuration line   * or not. */ -#define NO_DELIMITER(I)  \ -  ((I) == ACCESS_NODE || (I) == PREFIX_NODE || (I) == IP_NODE \ -   || (I) == AS_LIST_NODE || (I) == COMMUNITY_LIST_NODE || \ -   (I) == ACCESS_IPV6_NODE || (I) == PREFIX_IPV6_NODE \ -   || (I) == SERVICE_NODE || (I) == FORWARDING_NODE || (I) == DEBUG_NODE \ -   || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE || (I) == MPLS_NODE) +#define NO_DELIMITER(I)                                                        \ +	((I) == ACCESS_NODE || (I) == PREFIX_NODE || (I) == IP_NODE            \ +	 || (I) == AS_LIST_NODE || (I) == COMMUNITY_LIST_NODE                  \ +	 || (I) == ACCESS_IPV6_NODE || (I) == PREFIX_IPV6_NODE                 \ +	 || (I) == SERVICE_NODE || (I) == FORWARDING_NODE || (I) == DEBUG_NODE \ +	 || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE || (I) == MPLS_NODE)  /* Display configuration to file pointer. */ -void -vtysh_config_dump (FILE *fp) +void vtysh_config_dump(FILE *fp)  { -  struct listnode *node, *nnode; -  struct listnode *mnode, *mnnode; -  struct config *config; -  struct list *master; -  char *line; -  unsigned int i; - -  for (ALL_LIST_ELEMENTS (config_top, node, nnode, line)) -    { -      fprintf (fp, "%s\n", line); -      fflush (fp); -    } -  fprintf (fp, "!\n"); -  fflush (fp); - -  for (i = 0; i < vector_active (configvec); i++) -    if ((master = vector_slot (configvec, i)) != NULL) -      { -        for (ALL_LIST_ELEMENTS (master, node, nnode, config)) -          { -            /* Don't print empty sections for interface/vrf. Route maps on the -             * other hand could have a legitimate empty section at the end. -             */ -            if ((config->index == INTERFACE_NODE || config->index == VRF_NODE) -                && list_isempty (config->line)) -              continue; - -            fprintf (fp, "%s\n", config->name); -            fflush (fp); - -            for (ALL_LIST_ELEMENTS (config->line, mnode, mnnode, line)) -              { -                fprintf  (fp, "%s\n", line); -                fflush (fp); -              } -            if (! NO_DELIMITER (i)) -              { -                fprintf (fp, "!\n"); -                fflush (fp); -              } -          } -        if (NO_DELIMITER (i)) -          { -            fprintf (fp, "!\n"); -            fflush (fp); -          } -      } - -  for (i = 0; i < vector_active (configvec); i++) -    if ((master = vector_slot (configvec, i)) != NULL) -      { -        list_delete (master); -        vector_slot (configvec, i) = NULL; -      } -  list_delete_all_node (config_top); +	struct listnode *node, *nnode; +	struct listnode *mnode, *mnnode; +	struct config *config; +	struct list *master; +	char *line; +	unsigned int i; + +	for (ALL_LIST_ELEMENTS(config_top, node, nnode, line)) { +		fprintf(fp, "%s\n", line); +		fflush(fp); +	} +	fprintf(fp, "!\n"); +	fflush(fp); + +	for (i = 0; i < vector_active(configvec); i++) +		if ((master = vector_slot(configvec, i)) != NULL) { +			for (ALL_LIST_ELEMENTS(master, node, nnode, config)) { +				/* Don't print empty sections for interface/vrf. +				 * Route maps on the +				 * other hand could have a legitimate empty +				 * section at the end. +				 */ +				if ((config->index == INTERFACE_NODE +				     || config->index == VRF_NODE) +				    && list_isempty(config->line)) +					continue; + +				fprintf(fp, "%s\n", config->name); +				fflush(fp); + +				for (ALL_LIST_ELEMENTS(config->line, mnode, +						       mnnode, line)) { +					fprintf(fp, "%s\n", line); +					fflush(fp); +				} +				if (!NO_DELIMITER(i)) { +					fprintf(fp, "!\n"); +					fflush(fp); +				} +			} +			if (NO_DELIMITER(i)) { +				fprintf(fp, "!\n"); +				fflush(fp); +			} +		} + +	for (i = 0; i < vector_active(configvec); i++) +		if ((master = vector_slot(configvec, i)) != NULL) { +			list_delete(master); +			vector_slot(configvec, i) = NULL; +		} +	list_delete_all_node(config_top);  }  /* Read up configuration file from file_name. */ -static int -vtysh_read_file (FILE *confp) +static int vtysh_read_file(FILE *confp)  { -  struct vty *vty; -  int ret; +	struct vty *vty; +	int ret; + +	vty = vty_new(); +	vty->fd = 0; /* stdout */ +	vty->type = VTY_TERM; +	vty->node = CONFIG_NODE; -  vty = vty_new (); -  vty->fd = 0;			/* stdout */ -  vty->type = VTY_TERM; -  vty->node = CONFIG_NODE; -   -  vtysh_execute_no_pager ("enable"); -  vtysh_execute_no_pager ("configure terminal"); +	vtysh_execute_no_pager("enable"); +	vtysh_execute_no_pager("configure terminal"); -  /* Execute configuration file. */ -  ret = vtysh_config_from_file (vty, confp); +	/* Execute configuration file. */ +	ret = vtysh_config_from_file(vty, confp); -  vtysh_execute_no_pager ("end"); -  vtysh_execute_no_pager ("disable"); +	vtysh_execute_no_pager("end"); +	vtysh_execute_no_pager("disable"); -  vty_close (vty); +	vty_close(vty); -  return (ret); +	return (ret);  }  /* Read up configuration file from config_default_dir. */ -int -vtysh_read_config (const char *config_default_dir) +int vtysh_read_config(const char *config_default_dir)  { -  FILE *confp = NULL; -  int ret; - -  confp = fopen (config_default_dir, "r"); -  if (confp == NULL) -    { -      fprintf (stderr, "%% Can't open configuration file %s due to '%s'.\n", -               config_default_dir, safe_strerror (errno)); -      return (CMD_ERR_NO_FILE); -    } +	FILE *confp = NULL; +	int ret; + +	confp = fopen(config_default_dir, "r"); +	if (confp == NULL) { +		fprintf(stderr, +			"%% Can't open configuration file %s due to '%s'.\n", +			config_default_dir, safe_strerror(errno)); +		return (CMD_ERR_NO_FILE); +	} -  ret = vtysh_read_file (confp); -  fclose (confp); +	ret = vtysh_read_file(confp); +	fclose(confp); -  return (ret); +	return (ret);  }  /* We don't write vtysh specific into file from vtysh. vtysh.conf should   * be edited by hand. So, we handle only "write terminal" case here and   * integrate vtysh specific conf with conf from daemons.   */ -void -vtysh_config_write () +void vtysh_config_write()  { -  char line[81]; -  extern struct host host; - -  if (host.name) -    { -      sprintf (line, "hostname %s", host.name); -      vtysh_config_parse_line(NULL, line); -    } -  if (vtysh_write_integrated == WRITE_INTEGRATED_NO) -    vtysh_config_parse_line (NULL, "no service integrated-vtysh-config"); -  if (vtysh_write_integrated == WRITE_INTEGRATED_YES) -    vtysh_config_parse_line (NULL, "service integrated-vtysh-config"); - -  user_config_write (); +	char line[81]; +	extern struct host host; + +	if (host.name) { +		sprintf(line, "hostname %s", host.name); +		vtysh_config_parse_line(NULL, line); +	} +	if (vtysh_write_integrated == WRITE_INTEGRATED_NO) +		vtysh_config_parse_line(NULL, +					"no service integrated-vtysh-config"); +	if (vtysh_write_integrated == WRITE_INTEGRATED_YES) +		vtysh_config_parse_line(NULL, +					"service integrated-vtysh-config"); + +	user_config_write();  } -void -vtysh_config_init () +void vtysh_config_init()  { -  config_top = list_new (); -  config_top->del = (void (*) (void *))line_del; -  configvec = vector_init (1); +	config_top = list_new(); +	config_top->del = (void (*)(void *))line_del; +	configvec = vector_init(1);  }  | 
