diff options
| author | whitespace / reindent <invalid@invalid.invalid> | 2017-08-09 11:49:42 +0200 | 
|---|---|---|
| committer | whitespace / reindent <invalid@invalid.invalid> | 2017-08-09 12:03:17 +0200 | 
| commit | ac4d0be5874fafd14212d6007fff7495edc9b152 (patch) | |
| tree | 5e2f0d3189de928c849f9983406389ade3b098cb /lib/plist.c | |
| parent | 76a86854181c27819e5cf71b12ae1fa5ccd9e02a (diff) | |
*: reindentreindent-3.0-after
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/plist.c')
| -rw-r--r-- | lib/plist.c | 3839 | 
1 files changed, 1900 insertions, 1939 deletions
diff --git a/lib/plist.c b/lib/plist.c index 3714969696..2af13244ff 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -33,10 +33,10 @@  #include "plist_int.h" -DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST,       "Prefix List") -DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR,  "Prefix List Str") +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List") +DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str")  DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") -DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE,  "Prefix List Trie Table") +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table")  /* not currently changeable, code assumes bytes further down */  #define PLC_BITS	8 @@ -59,1358 +59,1247 @@ struct pltrie_table {  };  /* List of struct prefix_list. */ -struct prefix_list_list -{ -  struct prefix_list *head; -  struct prefix_list *tail; +struct prefix_list_list { +	struct prefix_list *head; +	struct prefix_list *tail;  };  /* Master structure of prefix_list. */ -struct prefix_master -{ -  /* List of prefix_list which name is number. */ -  struct prefix_list_list num; +struct prefix_master { +	/* List of prefix_list which name is number. */ +	struct prefix_list_list num; -  /* List of prefix_list which name is string. */ -  struct prefix_list_list str; +	/* List of prefix_list which name is string. */ +	struct prefix_list_list str; -  /* Whether sequential number is used. */ -  int seqnum; +	/* Whether sequential number is used. */ +	int seqnum; -  /* The latest update. */ -  struct prefix_list *recent; +	/* The latest update. */ +	struct prefix_list *recent; -  /* Hook function which is executed when new prefix_list is added. */ -  void (*add_hook) (struct prefix_list *); +	/* Hook function which is executed when new prefix_list is added. */ +	void (*add_hook)(struct prefix_list *); -  /* Hook function which is executed when prefix_list is deleted. */ -  void (*delete_hook) (struct prefix_list *); +	/* Hook function which is executed when prefix_list is deleted. */ +	void (*delete_hook)(struct prefix_list *); -  /* number of bytes that have a trie level */ -  size_t trie_depth; +	/* number of bytes that have a trie level */ +	size_t trie_depth;  };  /* Static structure of IPv4 prefix_list's master. */ -static struct prefix_master prefix_master_ipv4 =  -{  -  {NULL, NULL}, -  {NULL, NULL}, -  1, -  NULL, -  NULL, -  NULL, -  PLC_MAXLEVELV4, +static struct prefix_master prefix_master_ipv4 = { +	{NULL, NULL}, {NULL, NULL}, 1, NULL, NULL, NULL, PLC_MAXLEVELV4,  };  /* Static structure of IPv6 prefix-list's master. */ -static struct prefix_master prefix_master_ipv6 =  -{  -  {NULL, NULL}, -  {NULL, NULL}, -  1, -  NULL, -  NULL, -  NULL, -  PLC_MAXLEVELV6, +static struct prefix_master prefix_master_ipv6 = { +	{NULL, NULL}, {NULL, NULL}, 1, NULL, NULL, NULL, PLC_MAXLEVELV6,  };  /* Static structure of BGP ORF prefix_list's master. */ -static struct prefix_master prefix_master_orf_v4 = -{ -  {NULL, NULL}, -  {NULL, NULL}, -  1, -  NULL, -  NULL, -  NULL, -  PLC_MAXLEVELV4, +static struct prefix_master prefix_master_orf_v4 = { +	{NULL, NULL}, {NULL, NULL}, 1, NULL, NULL, NULL, PLC_MAXLEVELV4,  };  /* Static structure of BGP ORF prefix_list's master. */ -static struct prefix_master prefix_master_orf_v6 = -{ -  {NULL, NULL}, -  {NULL, NULL}, -  1, -  NULL, -  NULL, -  NULL, -  PLC_MAXLEVELV6, +static struct prefix_master prefix_master_orf_v6 = { +	{NULL, NULL}, {NULL, NULL}, 1, NULL, NULL, NULL, PLC_MAXLEVELV6,  }; -static struct prefix_master * -prefix_master_get (afi_t afi, int orf) +static struct prefix_master *prefix_master_get(afi_t afi, int orf)  { -  if (afi == AFI_IP) -    return orf ? &prefix_master_orf_v4 : &prefix_master_ipv4; -  if (afi == AFI_IP6) -    return orf ? &prefix_master_orf_v6 : &prefix_master_ipv6; -  return NULL; +	if (afi == AFI_IP) +		return orf ? &prefix_master_orf_v4 : &prefix_master_ipv4; +	if (afi == AFI_IP6) +		return orf ? &prefix_master_orf_v6 : &prefix_master_ipv6; +	return NULL;  } -const char *prefix_list_name (struct prefix_list *plist) +const char *prefix_list_name(struct prefix_list *plist)  { -  return plist->name; +	return plist->name;  }  /* Lookup prefix_list from list of prefix_list by name. */ -static struct prefix_list * -prefix_list_lookup_do (afi_t afi, int orf, const char *name) +static struct prefix_list *prefix_list_lookup_do(afi_t afi, int orf, +						 const char *name)  { -  struct prefix_list *plist; -  struct prefix_master *master; +	struct prefix_list *plist; +	struct prefix_master *master; -  if (name == NULL) -    return NULL; +	if (name == NULL) +		return NULL; -  master = prefix_master_get (afi, orf); -  if (master == NULL) -    return NULL; +	master = prefix_master_get(afi, orf); +	if (master == NULL) +		return NULL; -  for (plist = master->num.head; plist; plist = plist->next) -    if (strcmp (plist->name, name) == 0) -      return plist; +	for (plist = master->num.head; plist; plist = plist->next) +		if (strcmp(plist->name, name) == 0) +			return plist; -  for (plist = master->str.head; plist; plist = plist->next) -    if (strcmp (plist->name, name) == 0) -      return plist; +	for (plist = master->str.head; plist; plist = plist->next) +		if (strcmp(plist->name, name) == 0) +			return plist; -  return NULL; +	return NULL;  } -struct prefix_list * -prefix_list_lookup (afi_t afi, const char *name) +struct prefix_list *prefix_list_lookup(afi_t afi, const char *name)  { -  return prefix_list_lookup_do (afi, 0, name); +	return prefix_list_lookup_do(afi, 0, name);  } -struct prefix_list * -prefix_bgp_orf_lookup (afi_t afi, const char *name) +struct prefix_list *prefix_bgp_orf_lookup(afi_t afi, const char *name)  { -  return prefix_list_lookup_do (afi, 1, name); +	return prefix_list_lookup_do(afi, 1, name);  } -static struct prefix_list * -prefix_list_new (void) +static struct prefix_list *prefix_list_new(void)  { -  struct prefix_list *new; +	struct prefix_list *new; -  new = XCALLOC (MTYPE_PREFIX_LIST, sizeof (struct prefix_list)); -  return new; +	new = XCALLOC(MTYPE_PREFIX_LIST, sizeof(struct prefix_list)); +	return new;  } -static void -prefix_list_free (struct prefix_list *plist) +static void prefix_list_free(struct prefix_list *plist)  { -  XFREE (MTYPE_PREFIX_LIST, plist); +	XFREE(MTYPE_PREFIX_LIST, plist);  } -static struct prefix_list_entry * -prefix_list_entry_new (void) +static struct prefix_list_entry *prefix_list_entry_new(void)  { -  struct prefix_list_entry *new; +	struct prefix_list_entry *new; -  new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY, sizeof (struct prefix_list_entry)); -  return new; +	new = XCALLOC(MTYPE_PREFIX_LIST_ENTRY, +		      sizeof(struct prefix_list_entry)); +	return new;  } -static void -prefix_list_entry_free (struct prefix_list_entry *pentry) +static void prefix_list_entry_free(struct prefix_list_entry *pentry)  { -  XFREE (MTYPE_PREFIX_LIST_ENTRY, pentry); +	XFREE(MTYPE_PREFIX_LIST_ENTRY, pentry);  }  /* Insert new prefix list to list of prefix_list.  Each prefix_list     is sorted by the name. */ -static struct prefix_list * -prefix_list_insert (afi_t afi, int orf, const char *name) -{ -  unsigned int i; -  long number; -  struct prefix_list *plist; -  struct prefix_list *point; -  struct prefix_list_list *list; -  struct prefix_master *master; - -  master = prefix_master_get (afi, orf); -  if (master == NULL) -    return NULL; - -  /* Allocate new prefix_list and copy given name. */ -  plist = prefix_list_new (); -  plist->name = XSTRDUP (MTYPE_MPREFIX_LIST_STR, name); -  plist->master = master; -  plist->trie = XCALLOC (MTYPE_PREFIX_LIST_TRIE, sizeof (struct pltrie_table)); - -  /* If name is made by all digit character.  We treat it as -     number. */ -  for (number = 0, i = 0; i < strlen (name); i++) -    { -      if (isdigit ((int) name[i])) -	number = (number * 10) + (name[i] - '0'); -      else -	break; -    } - -  /* In case of name is all digit character */ -  if (i == strlen (name)) -    { -      plist->type = PREFIX_TYPE_NUMBER; - -      /* Set prefix_list to number list. */ -      list = &master->num; - -      for (point = list->head; point; point = point->next) -	if (atol (point->name) >= number) -	  break; -    } -  else -    { -      plist->type = PREFIX_TYPE_STRING; - -      /* Set prefix_list to string list. */ -      list = &master->str; -   -      /* Set point to insertion point. */ -      for (point = list->head; point; point = point->next) -	if (strcmp (point->name, name) >= 0) -	  break; -    } - -  /* In case of this is the first element of master. */ -  if (list->head == NULL) -    { -      list->head = list->tail = plist; -      return plist; -    } - -  /* In case of insertion is made at the tail of access_list. */ -  if (point == NULL) -    { -      plist->prev = list->tail; -      list->tail->next = plist; -      list->tail = plist; -      return plist; -    } - -  /* In case of insertion is made at the head of access_list. */ -  if (point == list->head) -    { -      plist->next = list->head; -      list->head->prev = plist; -      list->head = plist; -      return plist; -    } - -  /* Insertion is made at middle of the access_list. */ -  plist->next = point; -  plist->prev = point->prev; - -  if (point->prev) -    point->prev->next = plist; -  point->prev = plist; - -  return plist; -} - -static struct prefix_list * -prefix_list_get (afi_t afi, int orf, const char *name) -{ -  struct prefix_list *plist; - -  plist = prefix_list_lookup_do (afi, orf, name); - -  if (plist == NULL) -    plist = prefix_list_insert (afi, orf, name); -  return plist; -} - -static void prefix_list_trie_del (struct prefix_list *plist, -                                  struct prefix_list_entry *pentry); +static struct prefix_list *prefix_list_insert(afi_t afi, int orf, +					      const char *name) +{ +	unsigned int i; +	long number; +	struct prefix_list *plist; +	struct prefix_list *point; +	struct prefix_list_list *list; +	struct prefix_master *master; + +	master = prefix_master_get(afi, orf); +	if (master == NULL) +		return NULL; + +	/* Allocate new prefix_list and copy given name. */ +	plist = prefix_list_new(); +	plist->name = XSTRDUP(MTYPE_MPREFIX_LIST_STR, name); +	plist->master = master; +	plist->trie = +		XCALLOC(MTYPE_PREFIX_LIST_TRIE, sizeof(struct pltrie_table)); + +	/* If name is made by all digit character.  We treat it as +	   number. */ +	for (number = 0, i = 0; i < strlen(name); i++) { +		if (isdigit((int)name[i])) +			number = (number * 10) + (name[i] - '0'); +		else +			break; +	} -/* Delete prefix-list from prefix_list_master and free it. */ -static void -prefix_list_delete (struct prefix_list *plist) +	/* In case of name is all digit character */ +	if (i == strlen(name)) { +		plist->type = PREFIX_TYPE_NUMBER; + +		/* Set prefix_list to number list. */ +		list = &master->num; + +		for (point = list->head; point; point = point->next) +			if (atol(point->name) >= number) +				break; +	} else { +		plist->type = PREFIX_TYPE_STRING; + +		/* Set prefix_list to string list. */ +		list = &master->str; + +		/* Set point to insertion point. */ +		for (point = list->head; point; point = point->next) +			if (strcmp(point->name, name) >= 0) +				break; +	} + +	/* In case of this is the first element of master. */ +	if (list->head == NULL) { +		list->head = list->tail = plist; +		return plist; +	} + +	/* In case of insertion is made at the tail of access_list. */ +	if (point == NULL) { +		plist->prev = list->tail; +		list->tail->next = plist; +		list->tail = plist; +		return plist; +	} + +	/* In case of insertion is made at the head of access_list. */ +	if (point == list->head) { +		plist->next = list->head; +		list->head->prev = plist; +		list->head = plist; +		return plist; +	} + +	/* Insertion is made at middle of the access_list. */ +	plist->next = point; +	plist->prev = point->prev; + +	if (point->prev) +		point->prev->next = plist; +	point->prev = plist; + +	return plist; +} + +static struct prefix_list *prefix_list_get(afi_t afi, int orf, const char *name)  { -  struct prefix_list_list *list; -  struct prefix_master *master; -  struct prefix_list_entry *pentry; -  struct prefix_list_entry *next; +	struct prefix_list *plist; -  /* If prefix-list contain prefix_list_entry free all of it. */ -  for (pentry = plist->head; pentry; pentry = next) -    { -      next = pentry->next; -      prefix_list_trie_del (plist, pentry); -      prefix_list_entry_free (pentry); -      plist->count--; -    } +	plist = prefix_list_lookup_do(afi, orf, name); -  master = plist->master; +	if (plist == NULL) +		plist = prefix_list_insert(afi, orf, name); +	return plist; +} + +static void prefix_list_trie_del(struct prefix_list *plist, +				 struct prefix_list_entry *pentry); + +/* Delete prefix-list from prefix_list_master and free it. */ +static void prefix_list_delete(struct prefix_list *plist) +{ +	struct prefix_list_list *list; +	struct prefix_master *master; +	struct prefix_list_entry *pentry; +	struct prefix_list_entry *next; + +	/* If prefix-list contain prefix_list_entry free all of it. */ +	for (pentry = plist->head; pentry; pentry = next) { +		next = pentry->next; +		prefix_list_trie_del(plist, pentry); +		prefix_list_entry_free(pentry); +		plist->count--; +	} -  if (plist->type == PREFIX_TYPE_NUMBER) -    list = &master->num; -  else -    list = &master->str; +	master = plist->master; -  if (plist->next) -    plist->next->prev = plist->prev; -  else -    list->tail = plist->prev; +	if (plist->type == PREFIX_TYPE_NUMBER) +		list = &master->num; +	else +		list = &master->str; -  if (plist->prev) -    plist->prev->next = plist->next; -  else -    list->head = plist->next; +	if (plist->next) +		plist->next->prev = plist->prev; +	else +		list->tail = plist->prev; -  if (plist->desc) -    XFREE (MTYPE_TMP, plist->desc); +	if (plist->prev) +		plist->prev->next = plist->next; +	else +		list->head = plist->next; -  /* Make sure master's recent changed prefix-list information is -     cleared. */ -  master->recent = NULL; +	if (plist->desc) +		XFREE(MTYPE_TMP, plist->desc); -  route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_DELETED); +	/* Make sure master's recent changed prefix-list information is +	   cleared. */ +	master->recent = NULL; -  if (master->delete_hook) -    (*master->delete_hook) (plist); +	route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_DELETED); -  if (plist->name) -    XFREE (MTYPE_MPREFIX_LIST_STR, plist->name); +	if (master->delete_hook) +		(*master->delete_hook)(plist); -  XFREE (MTYPE_PREFIX_LIST_TRIE, plist->trie); +	if (plist->name) +		XFREE(MTYPE_MPREFIX_LIST_STR, plist->name); -  prefix_list_free (plist); +	XFREE(MTYPE_PREFIX_LIST_TRIE, plist->trie); +	prefix_list_free(plist);  }  static struct prefix_list_entry * -prefix_list_entry_make (struct prefix *prefix, enum prefix_list_type type, -			int seq, int le, int ge, int any) +prefix_list_entry_make(struct prefix *prefix, enum prefix_list_type type, +		       int seq, int le, int ge, int any)  { -  struct prefix_list_entry *pentry; +	struct prefix_list_entry *pentry; -  pentry = prefix_list_entry_new (); +	pentry = prefix_list_entry_new(); -  if (any) -    pentry->any = 1; +	if (any) +		pentry->any = 1; -  prefix_copy (&pentry->prefix, prefix); -  pentry->type = type; -  pentry->seq = seq; -  pentry->le = le; -  pentry->ge = ge; +	prefix_copy(&pentry->prefix, prefix); +	pentry->type = type; +	pentry->seq = seq; +	pentry->le = le; +	pentry->ge = ge; -  return pentry; +	return pentry;  }  /* Add hook function. */ -void -prefix_list_add_hook (void (*func) (struct prefix_list *plist)) +void prefix_list_add_hook(void (*func)(struct prefix_list *plist))  { -  prefix_master_ipv4.add_hook = func; -  prefix_master_ipv6.add_hook = func; +	prefix_master_ipv4.add_hook = func; +	prefix_master_ipv6.add_hook = func;  }  /* Delete hook function. */ -void -prefix_list_delete_hook (void (*func) (struct prefix_list *plist)) +void prefix_list_delete_hook(void (*func)(struct prefix_list *plist))  { -  prefix_master_ipv4.delete_hook = func; -  prefix_master_ipv6.delete_hook = func; +	prefix_master_ipv4.delete_hook = func; +	prefix_master_ipv6.delete_hook = func;  }  /* Calculate new sequential number. */ -static int -prefix_new_seq_get (struct prefix_list *plist) +static int prefix_new_seq_get(struct prefix_list *plist)  { -  int maxseq; -  int newseq; -  struct prefix_list_entry *pentry; +	int maxseq; +	int newseq; +	struct prefix_list_entry *pentry; + +	maxseq = newseq = 0; -  maxseq = newseq = 0; +	for (pentry = plist->head; pentry; pentry = pentry->next) { +		if (maxseq < pentry->seq) +			maxseq = pentry->seq; +	} -  for (pentry = plist->head; pentry; pentry = pentry->next) -    { -      if (maxseq < pentry->seq) -	maxseq = pentry->seq; -    } +	newseq = ((maxseq / 5) * 5) + 5; -  newseq = ((maxseq / 5) * 5) + 5; -   -  return newseq; +	return newseq;  }  /* Return prefix list entry which has same seq number. */ -static struct prefix_list_entry * -prefix_seq_check (struct prefix_list *plist, int seq) +static struct prefix_list_entry *prefix_seq_check(struct prefix_list *plist, +						  int seq)  { -  struct prefix_list_entry *pentry; +	struct prefix_list_entry *pentry; -  for (pentry = plist->head; pentry; pentry = pentry->next) -    if (pentry->seq == seq) -      return pentry; -  return NULL; +	for (pentry = plist->head; pentry; pentry = pentry->next) +		if (pentry->seq == seq) +			return pentry; +	return NULL;  }  static struct prefix_list_entry * -prefix_list_entry_lookup (struct prefix_list *plist, struct prefix *prefix, -			  enum prefix_list_type type, int seq, int le, int ge) +prefix_list_entry_lookup(struct prefix_list *plist, struct prefix *prefix, +			 enum prefix_list_type type, int seq, int le, int ge)  { -  struct prefix_list_entry *pentry; +	struct prefix_list_entry *pentry; -  for (pentry = plist->head; pentry; pentry = pentry->next) -    if (prefix_same (&pentry->prefix, prefix) && pentry->type == type) -      { -	if (seq >= 0 && pentry->seq != seq) -	  continue; +	for (pentry = plist->head; pentry; pentry = pentry->next) +		if (prefix_same(&pentry->prefix, prefix) +		    && pentry->type == type) { +			if (seq >= 0 && pentry->seq != seq) +				continue; -	if (pentry->le != le) -	  continue; -	if (pentry->ge != ge) -	  continue; +			if (pentry->le != le) +				continue; +			if (pentry->ge != ge) +				continue; -	return pentry; -      } +			return pentry; +		} -  return NULL; +	return NULL;  } -static void -trie_walk_affected (size_t validbits, struct pltrie_table *table, uint8_t byte, -                    struct prefix_list_entry *object, -                    void (*fn)(struct prefix_list_entry *object, -                               struct prefix_list_entry **updptr)) +static void trie_walk_affected(size_t validbits, struct pltrie_table *table, +			       uint8_t byte, struct prefix_list_entry *object, +			       void (*fn)(struct prefix_list_entry *object, +					  struct prefix_list_entry **updptr))  { -  uint8_t mask; -  uint16_t bwalk; +	uint8_t mask; +	uint16_t bwalk; -  if (validbits > PLC_BITS) -    { -      fn (object, &table->entries[byte].final_chain); -      return; -    } +	if (validbits > PLC_BITS) { +		fn(object, &table->entries[byte].final_chain); +		return; +	} + +	mask = (1 << (8 - validbits)) - 1; +	for (bwalk = byte & ~mask; bwalk <= byte + mask; bwalk++) { +		fn(object, &table->entries[bwalk].up_chain); +	} +} -  mask = (1 << (8 - validbits)) - 1; -  for (bwalk = byte & ~mask; bwalk <= byte + mask; bwalk++) -    { -      fn (object, &table->entries[bwalk].up_chain); -    } +static void trie_uninstall_fn(struct prefix_list_entry *object, +			      struct prefix_list_entry **updptr) +{ +	for (; *updptr; updptr = &(*updptr)->next_best) +		if (*updptr == object) { +			*updptr = object->next_best; +			break; +		}  } -static void trie_uninstall_fn (struct prefix_list_entry *object, -                               struct prefix_list_entry **updptr) +static int trie_table_empty(struct pltrie_table *table)  { -  for (; *updptr; updptr = &(*updptr)->next_best) -    if (*updptr == object) -      { -        *updptr = object->next_best; -        break; -      } +	size_t i; +	for (i = 0; i < PLC_LEN; i++) +		if (table->entries[i].next_table || table->entries[i].up_chain) +			return 0; +	return 1;  } -static int -trie_table_empty (struct pltrie_table *table) +static void prefix_list_trie_del(struct prefix_list *plist, +				 struct prefix_list_entry *pentry)  { -  size_t i; -  for (i = 0; i < PLC_LEN; i++) -    if (table->entries[i].next_table || table->entries[i].up_chain) -      return 0; -  return 1; +	size_t depth, maxdepth = plist->master->trie_depth; +	uint8_t *bytes = &pentry->prefix.u.prefix; +	size_t validbits = pentry->prefix.prefixlen; +	struct pltrie_table *table, **tables[PLC_MAXLEVEL]; + +	table = plist->trie; +	for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++) { +		uint8_t byte = bytes[depth]; +		assert(table->entries[byte].next_table); + +		tables[depth + 1] = &table->entries[byte].next_table; +		table = table->entries[byte].next_table; + +		validbits -= PLC_BITS; +	} + +	trie_walk_affected(validbits, table, bytes[depth], pentry, +			   trie_uninstall_fn); + +	for (; depth > 0; depth--) +		if (trie_table_empty(*tables[depth])) { +			XFREE(MTYPE_PREFIX_LIST_TRIE, *tables[depth]); +			*tables[depth] = NULL; +		}  } -static void -prefix_list_trie_del (struct prefix_list *plist, -		      struct prefix_list_entry *pentry) + +static void prefix_list_entry_delete(struct prefix_list *plist, +				     struct prefix_list_entry *pentry, +				     int update_list)  { -  size_t depth, maxdepth = plist->master->trie_depth; -  uint8_t *bytes = &pentry->prefix.u.prefix; -  size_t validbits = pentry->prefix.prefixlen; -  struct pltrie_table *table, **tables[PLC_MAXLEVEL]; +	if (plist == NULL || pentry == NULL) +		return; + +	prefix_list_trie_del(plist, pentry); -  table = plist->trie; -  for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++) -    { -      uint8_t byte = bytes[depth]; -      assert (table->entries[byte].next_table); +	if (pentry->prev) +		pentry->prev->next = pentry->next; +	else +		plist->head = pentry->next; +	if (pentry->next) +		pentry->next->prev = pentry->prev; +	else +		plist->tail = pentry->prev; -      tables[depth + 1] = &table->entries[byte].next_table; -      table = table->entries[byte].next_table; +	prefix_list_entry_free(pentry); -      validbits -= PLC_BITS; -    } +	plist->count--; -  trie_walk_affected (validbits, table, bytes[depth], pentry, trie_uninstall_fn); +	if (update_list) { +		route_map_notify_dependencies(plist->name, +					      RMAP_EVENT_PLIST_DELETED); +		if (plist->master->delete_hook) +			(*plist->master->delete_hook)(plist); -  for (; depth > 0; depth--) -    if (trie_table_empty (*tables[depth])) -      { -        XFREE (MTYPE_PREFIX_LIST_TRIE, *tables[depth]); -        *tables[depth] = NULL; -      } +		if (plist->head == NULL && plist->tail == NULL +		    && plist->desc == NULL) +			prefix_list_delete(plist); +		else +			plist->master->recent = plist; +	}  } +static void trie_install_fn(struct prefix_list_entry *object, +			    struct prefix_list_entry **updptr) +{ +	while (*updptr) { +		if (*updptr == object) +			return; +		if ((*updptr)->prefix.prefixlen < object->prefix.prefixlen) +			break; +		if ((*updptr)->seq > object->seq) +			break; +		updptr = &(*updptr)->next_best; +	} + +	if (!object->next_best) +		object->next_best = *updptr; +	else +		assert(object->next_best == *updptr || !*updptr); + +	*updptr = object; +} -static void -prefix_list_entry_delete (struct prefix_list *plist,  -			  struct prefix_list_entry *pentry, -			  int update_list) +static void prefix_list_trie_add(struct prefix_list *plist, +				 struct prefix_list_entry *pentry)  { -  if (plist == NULL || pentry == NULL) -    return; +	size_t depth = plist->master->trie_depth; +	uint8_t *bytes = &pentry->prefix.u.prefix; +	size_t validbits = pentry->prefix.prefixlen; +	struct pltrie_table *table; -  prefix_list_trie_del (plist, pentry); +	table = plist->trie; +	while (validbits > PLC_BITS && depth > 1) { +		if (!table->entries[*bytes].next_table) +			table->entries[*bytes].next_table = +				XCALLOC(MTYPE_PREFIX_LIST_TRIE, +					sizeof(struct pltrie_table)); +		table = table->entries[*bytes].next_table; +		bytes++; +		depth--; +		validbits -= PLC_BITS; +	} + +	trie_walk_affected(validbits, table, *bytes, pentry, trie_install_fn); +} + +static void prefix_list_entry_add(struct prefix_list *plist, +				  struct prefix_list_entry *pentry) +{ +	struct prefix_list_entry *replace; +	struct prefix_list_entry *point; -  if (pentry->prev) -    pentry->prev->next = pentry->next; -  else -    plist->head = pentry->next; -  if (pentry->next) -    pentry->next->prev = pentry->prev; -  else -    plist->tail = pentry->prev; +	/* Automatic asignment of seq no. */ +	if (pentry->seq == -1) +		pentry->seq = prefix_new_seq_get(plist); + +	if (plist->tail && pentry->seq > plist->tail->seq) +		point = NULL; +	else { +		/* Is there any same seq prefix list entry? */ +		replace = prefix_seq_check(plist, pentry->seq); +		if (replace) +			prefix_list_entry_delete(plist, replace, 0); + +		/* Check insert point. */ +		for (point = plist->head; point; point = point->next) +			if (point->seq >= pentry->seq) +				break; +	} + +	/* In case of this is the first element of the list. */ +	pentry->next = point; + +	if (point) { +		if (point->prev) +			point->prev->next = pentry; +		else +			plist->head = pentry; + +		pentry->prev = point->prev; +		point->prev = pentry; +	} else { +		if (plist->tail) +			plist->tail->next = pentry; +		else +			plist->head = pentry; + +		pentry->prev = plist->tail; +		plist->tail = pentry; +	} -  prefix_list_entry_free (pentry); +	prefix_list_trie_add(plist, pentry); -  plist->count--; +	/* Increment count. */ +	plist->count++; -  if (update_list) -    { -      route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_DELETED); -      if (plist->master->delete_hook) -	(*plist->master->delete_hook) (plist); +	/* Run hook function. */ +	if (plist->master->add_hook) +		(*plist->master->add_hook)(plist); -      if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL) -	prefix_list_delete (plist); -      else +	route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_ADDED);  	plist->master->recent = plist; -    } -} - -static void trie_install_fn (struct prefix_list_entry *object, -                             struct prefix_list_entry **updptr) -{ -  while (*updptr) -    { -      if (*updptr == object) -        return; -      if ((*updptr)->prefix.prefixlen < object->prefix.prefixlen) -        break; -      if ((*updptr)->seq > object->seq) -        break; -      updptr = &(*updptr)->next_best; -    } - -  if (!object->next_best) -    object->next_best = *updptr; -  else -    assert (object->next_best == *updptr || !*updptr); - -  *updptr = object; -} - -static void -prefix_list_trie_add (struct prefix_list *plist, -		      struct prefix_list_entry *pentry) -{ -  size_t depth = plist->master->trie_depth; -  uint8_t *bytes = &pentry->prefix.u.prefix; -  size_t validbits = pentry->prefix.prefixlen; -  struct pltrie_table *table; - -  table = plist->trie; -  while (validbits > PLC_BITS && depth > 1) -    { -      if (!table->entries[*bytes].next_table) -        table->entries[*bytes].next_table = XCALLOC (MTYPE_PREFIX_LIST_TRIE, -                sizeof(struct pltrie_table)); -      table = table->entries[*bytes].next_table; -      bytes++; -      depth--; -      validbits -= PLC_BITS; -    } - -  trie_walk_affected (validbits, table, *bytes, pentry, trie_install_fn); -} - -static void -prefix_list_entry_add (struct prefix_list *plist, -		       struct prefix_list_entry *pentry) -{ -  struct prefix_list_entry *replace; -  struct prefix_list_entry *point; - -  /* Automatic asignment of seq no. */ -  if (pentry->seq == -1) -    pentry->seq = prefix_new_seq_get (plist); - -  if (plist->tail && pentry->seq > plist->tail->seq) -    point = NULL; -  else -    { -      /* Is there any same seq prefix list entry? */ -      replace = prefix_seq_check (plist, pentry->seq); -      if (replace) -        prefix_list_entry_delete (plist, replace, 0); - -      /* Check insert point. */ -      for (point = plist->head; point; point = point->next) -        if (point->seq >= pentry->seq) -          break; -    } - -  /* In case of this is the first element of the list. */ -  pentry->next = point; - -  if (point) -    { -      if (point->prev) -	point->prev->next = pentry; -      else -	plist->head = pentry; - -      pentry->prev = point->prev; -      point->prev = pentry; -    } -  else -    { -      if (plist->tail) -	plist->tail->next = pentry; -      else -	plist->head = pentry; - -      pentry->prev = plist->tail; -      plist->tail = pentry; -    } - -  prefix_list_trie_add (plist, pentry); - -  /* Increment count. */ -  plist->count++; - -  /* Run hook function. */ -  if (plist->master->add_hook) -    (*plist->master->add_hook) (plist); - -  route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_ADDED); -  plist->master->recent = plist;  }  /* Return string of prefix_list_type. */ -static const char * -prefix_list_type_str (struct prefix_list_entry *pentry) -{ -  switch (pentry->type) -    { -    case PREFIX_PERMIT: -      return "permit"; -    case PREFIX_DENY: -      return "deny"; -    default: -      return ""; -    } -} - -static int -prefix_list_entry_match (struct prefix_list_entry *pentry, struct prefix *p) -{ -  int ret; - -  ret = prefix_match (&pentry->prefix, p); -  if (! ret) -    return 0; -   -  /* In case of le nor ge is specified, exact match is performed. */ -  if (! pentry->le && ! pentry->ge) -    { -      if (pentry->prefix.prefixlen != p->prefixlen) -	return 0; -    } -  else -    {   -      if (pentry->le) -	if (p->prefixlen > pentry->le) -	  return 0; - -      if (pentry->ge) -	if (p->prefixlen < pentry->ge) -	  return 0; -    } -  return 1; -} - -enum prefix_list_type -prefix_list_apply (struct prefix_list *plist, void *object) -{ -  struct prefix_list_entry *pentry, *pbest = NULL; - -  struct prefix *p = (struct prefix *) object; -  uint8_t *byte = &p->u.prefix; -  size_t depth; -  size_t validbits = p->prefixlen; -  struct pltrie_table *table; - -  if (plist == NULL) -    return PREFIX_DENY; - -  if (plist->count == 0) -    return PREFIX_PERMIT; - -  depth = plist->master->trie_depth; -  table = plist->trie; -  while (1) -    { -      for (pentry = table->entries[*byte].up_chain; pentry; pentry = pentry->next_best) -        { -          if (pbest && pbest->seq < pentry->seq) -            continue; -          if (prefix_list_entry_match (pentry, p)) -            pbest = pentry; -        } - -      if (validbits <= PLC_BITS) -        break; -      validbits -= PLC_BITS; - -      if (--depth) -        { -          if (!table->entries[*byte].next_table) -            break; - -          table = table->entries[*byte].next_table; -          byte++; -          continue; -        } - -      for (pentry = table->entries[*byte].final_chain; pentry; pentry = pentry->next_best) -        { -          if (pbest && pbest->seq < pentry->seq) -            continue; -          if (prefix_list_entry_match (pentry, p)) -            pbest = pentry; -        } -      break; -    } - -  if (pbest == NULL) -    return PREFIX_DENY; - -  return pbest->type; -} - -static void __attribute__ ((unused)) -prefix_list_print (struct prefix_list *plist) -{ -  struct prefix_list_entry *pentry; - -  if (plist == NULL) -    return; - -  printf ("ip prefix-list %s: %d entries\n", plist->name, plist->count); - -  for (pentry = plist->head; pentry; pentry = pentry->next) -    { -      if (pentry->any) -	printf ("any %s\n", prefix_list_type_str (pentry)); -      else -	{ -	  struct prefix *p; -	  char buf[BUFSIZ]; -	   -	  p = &pentry->prefix; -	   -	  printf ("  seq %u %s %s/%d", -		  pentry->seq, -		  prefix_list_type_str (pentry), -		  inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		  p->prefixlen); -	  if (pentry->ge) -	    printf (" ge %d", pentry->ge); -	  if (pentry->le) -	    printf (" le %d", pentry->le); -	  printf ("\n"); +static const char *prefix_list_type_str(struct prefix_list_entry *pentry) +{ +	switch (pentry->type) { +	case PREFIX_PERMIT: +		return "permit"; +	case PREFIX_DENY: +		return "deny"; +	default: +		return ""; +	} +} + +static int prefix_list_entry_match(struct prefix_list_entry *pentry, +				   struct prefix *p) +{ +	int ret; + +	ret = prefix_match(&pentry->prefix, p); +	if (!ret) +		return 0; + +	/* In case of le nor ge is specified, exact match is performed. */ +	if (!pentry->le && !pentry->ge) { +		if (pentry->prefix.prefixlen != p->prefixlen) +			return 0; +	} else { +		if (pentry->le) +			if (p->prefixlen > pentry->le) +				return 0; + +		if (pentry->ge) +			if (p->prefixlen < pentry->ge) +				return 0; +	} +	return 1; +} + +enum prefix_list_type prefix_list_apply(struct prefix_list *plist, void *object) +{ +	struct prefix_list_entry *pentry, *pbest = NULL; + +	struct prefix *p = (struct prefix *)object; +	uint8_t *byte = &p->u.prefix; +	size_t depth; +	size_t validbits = p->prefixlen; +	struct pltrie_table *table; + +	if (plist == NULL) +		return PREFIX_DENY; + +	if (plist->count == 0) +		return PREFIX_PERMIT; + +	depth = plist->master->trie_depth; +	table = plist->trie; +	while (1) { +		for (pentry = table->entries[*byte].up_chain; pentry; +		     pentry = pentry->next_best) { +			if (pbest && pbest->seq < pentry->seq) +				continue; +			if (prefix_list_entry_match(pentry, p)) +				pbest = pentry; +		} + +		if (validbits <= PLC_BITS) +			break; +		validbits -= PLC_BITS; + +		if (--depth) { +			if (!table->entries[*byte].next_table) +				break; + +			table = table->entries[*byte].next_table; +			byte++; +			continue; +		} + +		for (pentry = table->entries[*byte].final_chain; pentry; +		     pentry = pentry->next_best) { +			if (pbest && pbest->seq < pentry->seq) +				continue; +			if (prefix_list_entry_match(pentry, p)) +				pbest = pentry; +		} +		break; +	} + +	if (pbest == NULL) +		return PREFIX_DENY; + +	return pbest->type; +} + +static void __attribute__((unused)) prefix_list_print(struct prefix_list *plist) +{ +	struct prefix_list_entry *pentry; + +	if (plist == NULL) +		return; + +	printf("ip prefix-list %s: %d entries\n", plist->name, plist->count); + +	for (pentry = plist->head; pentry; pentry = pentry->next) { +		if (pentry->any) +			printf("any %s\n", prefix_list_type_str(pentry)); +		else { +			struct prefix *p; +			char buf[BUFSIZ]; + +			p = &pentry->prefix; + +			printf("  seq %u %s %s/%d", pentry->seq, +			       prefix_list_type_str(pentry), +			       inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), +			       p->prefixlen); +			if (pentry->ge) +				printf(" ge %d", pentry->ge); +			if (pentry->le) +				printf(" le %d", pentry->le); +			printf("\n"); +		}  	} -    }  }  /* Retrun 1 when plist already include pentry policy. */  static struct prefix_list_entry * -prefix_entry_dup_check (struct prefix_list *plist, -			struct prefix_list_entry *new) -{ -  size_t depth, maxdepth = plist->master->trie_depth; -  uint8_t byte, *bytes = &new->prefix.u.prefix; -  size_t validbits = new->prefix.prefixlen; -  struct pltrie_table *table; -  struct prefix_list_entry *pentry; -  int seq = 0; - -  if (new->seq == -1) -    seq = prefix_new_seq_get (plist); -  else -    seq = new->seq; - -  table = plist->trie; -  for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++) -    { -      byte = bytes[depth]; -      if (!table->entries[byte].next_table) -        return NULL; - -      table = table->entries[byte].next_table; -      validbits -= PLC_BITS; -    } - -  byte = bytes[depth]; -  if (validbits > PLC_BITS) -    pentry = table->entries[byte].final_chain; -  else -    pentry = table->entries[byte].up_chain; - -  for (; pentry; pentry = pentry->next_best) -    { -      if (prefix_same (&pentry->prefix, &new->prefix) -	  && pentry->type == new->type -	  && pentry->le == new->le -	  && pentry->ge == new->ge -	  && pentry->seq != seq) -	return pentry; -    } -  return NULL; -} - -static int -vty_invalid_prefix_range (struct vty *vty, const char *prefix) -{ -  vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s", -           prefix, VTY_NEWLINE); -  return CMD_WARNING; -} - -static int -vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,  -                         const char *seq, const char *typestr, -			 const char *prefix, const char *ge, const char *le) -{ -  int ret; -  enum prefix_list_type type; -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  struct prefix_list_entry *dup; -  struct prefix p, p_tmp; -  int any = 0; -  int seqnum = -1; -  int lenum = 0; -  int genum = 0; - -  /* Sequential number. */ -  if (seq) -    seqnum = atoi (seq); - -  /* ge and le number */ -  if (ge) -    genum = atoi (ge); -  if (le) -    lenum = atoi (le); - -  /* Check filter type. */ -  if (strncmp ("permit", typestr, 1) == 0) -    type = PREFIX_PERMIT; -  else if (strncmp ("deny", typestr, 1) == 0) -    type = PREFIX_DENY; -  else -    { -      vty_out (vty, "%% prefix type must be permit or deny%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  /* "any" is special token for matching any IPv4 addresses.  */ -  switch (afi) -    { -    case AFI_IP: -      if (strncmp ("any", prefix, strlen (prefix)) == 0) -	{ -	  ret = str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4 *) &p); -	  genum = 0; -	  lenum = IPV4_MAX_BITLEN; -	  any = 1; +prefix_entry_dup_check(struct prefix_list *plist, struct prefix_list_entry *new) +{ +	size_t depth, maxdepth = plist->master->trie_depth; +	uint8_t byte, *bytes = &new->prefix.u.prefix; +	size_t validbits = new->prefix.prefixlen; +	struct pltrie_table *table; +	struct prefix_list_entry *pentry; +	int seq = 0; + +	if (new->seq == -1) +		seq = prefix_new_seq_get(plist); +	else +		seq = new->seq; + +	table = plist->trie; +	for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++) { +		byte = bytes[depth]; +		if (!table->entries[byte].next_table) +			return NULL; + +		table = table->entries[byte].next_table; +		validbits -= PLC_BITS;  	} -      else -	ret = str2prefix_ipv4 (prefix, (struct prefix_ipv4 *) &p); -      if (ret <= 0) -	{ -	  vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE); -	  return CMD_WARNING; +	byte = bytes[depth]; +	if (validbits > PLC_BITS) +		pentry = table->entries[byte].final_chain; +	else +		pentry = table->entries[byte].up_chain; + +	for (; pentry; pentry = pentry->next_best) { +		if (prefix_same(&pentry->prefix, &new->prefix) +		    && pentry->type == new->type && pentry->le == new->le +		    && pentry->ge == new->ge && pentry->seq != seq) +			return pentry;  	} +	return NULL; +} + +static int vty_invalid_prefix_range(struct vty *vty, const char *prefix) +{ +	vty_out(vty, +		"%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s", +		prefix, VTY_NEWLINE); +	return CMD_WARNING; +} -      /* make a copy to verify prefix matches mask length */ -      prefix_copy (&p_tmp, &p); -      apply_mask_ipv4 ((struct prefix_ipv4 *) &p_tmp); - -      break; -    case AFI_IP6: -      if (strncmp ("any", prefix, strlen (prefix)) == 0) -	{ -	  ret = str2prefix_ipv6 ("::/0", (struct prefix_ipv6 *) &p); -	  genum = 0; -	  lenum = IPV6_MAX_BITLEN; -	  any = 1; +static int vty_prefix_list_install(struct vty *vty, afi_t afi, const char *name, +				   const char *seq, const char *typestr, +				   const char *prefix, const char *ge, +				   const char *le) +{ +	int ret; +	enum prefix_list_type type; +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	struct prefix_list_entry *dup; +	struct prefix p, p_tmp; +	int any = 0; +	int seqnum = -1; +	int lenum = 0; +	int genum = 0; + +	/* Sequential number. */ +	if (seq) +		seqnum = atoi(seq); + +	/* ge and le number */ +	if (ge) +		genum = atoi(ge); +	if (le) +		lenum = atoi(le); + +	/* Check filter type. */ +	if (strncmp("permit", typestr, 1) == 0) +		type = PREFIX_PERMIT; +	else if (strncmp("deny", typestr, 1) == 0) +		type = PREFIX_DENY; +	else { +		vty_out(vty, "%% prefix type must be permit or deny%s", +			VTY_NEWLINE); +		return CMD_WARNING;  	} -      else -	ret = str2prefix_ipv6 (prefix, (struct prefix_ipv6 *) &p); -      if (ret <= 0) -	{ -	  vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE); -	  return CMD_WARNING; +	/* "any" is special token for matching any IPv4 addresses.  */ +	switch (afi) { +	case AFI_IP: +		if (strncmp("any", prefix, strlen(prefix)) == 0) { +			ret = str2prefix_ipv4("0.0.0.0/0", +					      (struct prefix_ipv4 *)&p); +			genum = 0; +			lenum = IPV4_MAX_BITLEN; +			any = 1; +		} else +			ret = str2prefix_ipv4(prefix, (struct prefix_ipv4 *)&p); + +		if (ret <= 0) { +			vty_out(vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE); +			return CMD_WARNING; +		} + +		/* make a copy to verify prefix matches mask length */ +		prefix_copy(&p_tmp, &p); +		apply_mask_ipv4((struct prefix_ipv4 *)&p_tmp); + +		break; +	case AFI_IP6: +		if (strncmp("any", prefix, strlen(prefix)) == 0) { +			ret = str2prefix_ipv6("::/0", (struct prefix_ipv6 *)&p); +			genum = 0; +			lenum = IPV6_MAX_BITLEN; +			any = 1; +		} else +			ret = str2prefix_ipv6(prefix, (struct prefix_ipv6 *)&p); + +		if (ret <= 0) { +			vty_out(vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE); +			return CMD_WARNING; +		} + +		/* make a copy to verify prefix matches mask length */ +		prefix_copy(&p_tmp, &p); +		apply_mask_ipv6((struct prefix_ipv6 *)&p_tmp); + +		break; +	case AFI_L2VPN: +	default: +		vty_out(vty, "%% Unrecognized AFI (%d)%s", afi, VTY_NEWLINE); +		return CMD_WARNING; +		break;  	} -      /* make a copy to verify prefix matches mask length */ -      prefix_copy (&p_tmp, &p); -      apply_mask_ipv6 ((struct prefix_ipv6 *) &p_tmp); - -      break; -    case AFI_L2VPN: -    default: -      vty_out (vty, "%% Unrecognized AFI (%d)%s", afi, VTY_NEWLINE); -      return CMD_WARNING; -      break; -    } - -  /* If prefix has bits not under the mask, adjust it to fit */ -  if (!prefix_same (&p_tmp, &p)) -    { -      char buf[PREFIX2STR_BUFFER]; -      char buf_tmp[PREFIX2STR_BUFFER]; -      prefix2str(&p, buf, sizeof(buf)); -      prefix2str(&p_tmp, buf_tmp, sizeof(buf_tmp)); -      zlog_warn ("Prefix-list %s prefix changed from %s to %s to match length", -                 name, buf, buf_tmp); -      p = p_tmp; -    } - -  /* ge and le check. */ -  if (genum && (genum <= p.prefixlen)) -    return vty_invalid_prefix_range (vty, prefix); - -  if (lenum && (lenum <= p.prefixlen)) -    return vty_invalid_prefix_range (vty, prefix); - -  if (lenum && (genum > lenum)) -    return vty_invalid_prefix_range (vty, prefix); - -  if (genum && (lenum == (afi == AFI_IP ? 32 : 128))) -    lenum = 0; - -  /* Get prefix_list with name. */ -  plist = prefix_list_get (afi, 0, name); - -  /* Make prefix entry. */ -  pentry = prefix_list_entry_make (&p, type, seqnum, lenum, genum, any); -     -  /* Check same policy. */ -  dup = prefix_entry_dup_check (plist, pentry); - -  if (dup) -    { -      prefix_list_entry_free (pentry); -      return CMD_SUCCESS; -    } - -  /* Install new filter to the access_list. */ -  prefix_list_entry_add (plist, pentry); - -  return CMD_SUCCESS; -} - -static int -vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,  -                           const char *seq, const char *typestr, -			   const char *prefix, const char *ge, const char *le) -{ -  int ret; -  enum prefix_list_type type; -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  struct prefix p; -  int seqnum = -1; -  int lenum = 0; -  int genum = 0; - -  /* Check prefix list name. */ -  plist = prefix_list_lookup (afi, name); -  if (! plist) -    { -      vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  /* Only prefix-list name specified, delete the entire prefix-list. */ -  if (seq == NULL && typestr == NULL && prefix == NULL &&  -      ge == NULL && le == NULL) -    { -      prefix_list_delete (plist); -      return CMD_SUCCESS; -    } - -  /* We must have, at a minimum, both the type and prefix here */ -  if ((typestr == NULL) || (prefix == NULL)) -    { -      vty_out (vty, "%% Both prefix and type required%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  /* Check sequence number. */ -  if (seq) -    seqnum = atoi (seq); - -  /* ge and le number */ -  if (ge) -    genum = atoi (ge); -  if (le) -    lenum = atoi (le); - -  /* Check of filter type. */ -  if (strncmp ("permit", typestr, 1) == 0) -    type = PREFIX_PERMIT; -  else if (strncmp ("deny", typestr, 1) == 0) -    type = PREFIX_DENY; -  else -    { -      vty_out (vty, "%% prefix type must be permit or deny%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  /* "any" is special token for matching any IPv4 addresses.  */ -  if (afi == AFI_IP) -    { -      if (strncmp ("any", prefix, strlen (prefix)) == 0) -	{ -	  ret = str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4 *) &p); -	  genum = 0; -	  lenum = IPV4_MAX_BITLEN; +	/* If prefix has bits not under the mask, adjust it to fit */ +	if (!prefix_same(&p_tmp, &p)) { +		char buf[PREFIX2STR_BUFFER]; +		char buf_tmp[PREFIX2STR_BUFFER]; +		prefix2str(&p, buf, sizeof(buf)); +		prefix2str(&p_tmp, buf_tmp, sizeof(buf_tmp)); +		zlog_warn( +			"Prefix-list %s prefix changed from %s to %s to match length", +			name, buf, buf_tmp); +		p = p_tmp;  	} -      else -	ret = str2prefix_ipv4 (prefix, (struct prefix_ipv4 *) &p); -      if (ret <= 0) -	{ -	  vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE); -	  return CMD_WARNING; +	/* ge and le check. */ +	if (genum && (genum <= p.prefixlen)) +		return vty_invalid_prefix_range(vty, prefix); + +	if (lenum && (lenum <= p.prefixlen)) +		return vty_invalid_prefix_range(vty, prefix); + +	if (lenum && (genum > lenum)) +		return vty_invalid_prefix_range(vty, prefix); + +	if (genum && (lenum == (afi == AFI_IP ? 32 : 128))) +		lenum = 0; + +	/* Get prefix_list with name. */ +	plist = prefix_list_get(afi, 0, name); + +	/* Make prefix entry. */ +	pentry = prefix_list_entry_make(&p, type, seqnum, lenum, genum, any); + +	/* Check same policy. */ +	dup = prefix_entry_dup_check(plist, pentry); + +	if (dup) { +		prefix_list_entry_free(pentry); +		return CMD_SUCCESS;  	} -    } -  else if (afi == AFI_IP6) -    { -      if (strncmp ("any", prefix, strlen (prefix)) == 0) -	{ -	  ret = str2prefix_ipv6 ("::/0", (struct prefix_ipv6 *) &p); -	  genum = 0; -	  lenum = IPV6_MAX_BITLEN; + +	/* Install new filter to the access_list. */ +	prefix_list_entry_add(plist, pentry); + +	return CMD_SUCCESS; +} + +static int vty_prefix_list_uninstall(struct vty *vty, afi_t afi, +				     const char *name, const char *seq, +				     const char *typestr, const char *prefix, +				     const char *ge, const char *le) +{ +	int ret; +	enum prefix_list_type type; +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	struct prefix p; +	int seqnum = -1; +	int lenum = 0; +	int genum = 0; + +	/* Check prefix list name. */ +	plist = prefix_list_lookup(afi, name); +	if (!plist) { +		vty_out(vty, "%% Can't find specified prefix-list%s", +			VTY_NEWLINE); +		return CMD_WARNING;  	} -      else -	ret = str2prefix_ipv6 (prefix, (struct prefix_ipv6 *) &p); -      if (ret <= 0) -	{ -	  vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE); -	  return CMD_WARNING; +	/* Only prefix-list name specified, delete the entire prefix-list. */ +	if (seq == NULL && typestr == NULL && prefix == NULL && ge == NULL +	    && le == NULL) { +		prefix_list_delete(plist); +		return CMD_SUCCESS;  	} -    } -  /* Lookup prefix entry. */ -  pentry = prefix_list_entry_lookup(plist, &p, type, seqnum, lenum, genum); +	/* We must have, at a minimum, both the type and prefix here */ +	if ((typestr == NULL) || (prefix == NULL)) { +		vty_out(vty, "%% Both prefix and type required%s", VTY_NEWLINE); +		return CMD_WARNING; +	} -  if (pentry == NULL) -    { -      vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -      return CMD_WARNING; -    } +	/* Check sequence number. */ +	if (seq) +		seqnum = atoi(seq); + +	/* ge and le number */ +	if (ge) +		genum = atoi(ge); +	if (le) +		lenum = atoi(le); + +	/* Check of filter type. */ +	if (strncmp("permit", typestr, 1) == 0) +		type = PREFIX_PERMIT; +	else if (strncmp("deny", typestr, 1) == 0) +		type = PREFIX_DENY; +	else { +		vty_out(vty, "%% prefix type must be permit or deny%s", +			VTY_NEWLINE); +		return CMD_WARNING; +	} -  /* Install new filter to the access_list. */ -  prefix_list_entry_delete (plist, pentry, 1); +	/* "any" is special token for matching any IPv4 addresses.  */ +	if (afi == AFI_IP) { +		if (strncmp("any", prefix, strlen(prefix)) == 0) { +			ret = str2prefix_ipv4("0.0.0.0/0", +					      (struct prefix_ipv4 *)&p); +			genum = 0; +			lenum = IPV4_MAX_BITLEN; +		} else +			ret = str2prefix_ipv4(prefix, (struct prefix_ipv4 *)&p); + +		if (ret <= 0) { +			vty_out(vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE); +			return CMD_WARNING; +		} +	} else if (afi == AFI_IP6) { +		if (strncmp("any", prefix, strlen(prefix)) == 0) { +			ret = str2prefix_ipv6("::/0", (struct prefix_ipv6 *)&p); +			genum = 0; +			lenum = IPV6_MAX_BITLEN; +		} else +			ret = str2prefix_ipv6(prefix, (struct prefix_ipv6 *)&p); + +		if (ret <= 0) { +			vty_out(vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE); +			return CMD_WARNING; +		} +	} -  return CMD_SUCCESS; +	/* Lookup prefix entry. */ +	pentry = +		prefix_list_entry_lookup(plist, &p, type, seqnum, lenum, genum); + +	if (pentry == NULL) { +		vty_out(vty, "%% Can't find specified prefix-list%s", +			VTY_NEWLINE); +		return CMD_WARNING; +	} + +	/* Install new filter to the access_list. */ +	prefix_list_entry_delete(plist, pentry, 1); + +	return CMD_SUCCESS;  } -static int -vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name) +static int vty_prefix_list_desc_unset(struct vty *vty, afi_t afi, +				      const char *name)  { -  struct prefix_list *plist; +	struct prefix_list *plist; -  plist = prefix_list_lookup (afi, name); -  if (! plist) -    { -      vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -      return CMD_WARNING; -    } +	plist = prefix_list_lookup(afi, name); +	if (!plist) { +		vty_out(vty, "%% Can't find specified prefix-list%s", +			VTY_NEWLINE); +		return CMD_WARNING; +	} -  if (plist->desc) -    { -      XFREE (MTYPE_TMP, plist->desc); -      plist->desc = NULL; -    } +	if (plist->desc) { +		XFREE(MTYPE_TMP, plist->desc); +		plist->desc = NULL; +	} -  if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL) -    prefix_list_delete (plist); +	if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL) +		prefix_list_delete(plist); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  } -enum display_type -{ -  normal_display, -  summary_display, -  detail_display, -  sequential_display, -  longer_display, -  first_match_display +enum display_type { +	normal_display, +	summary_display, +	detail_display, +	sequential_display, +	longer_display, +	first_match_display  }; -static void -vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist, -		       struct prefix_master *master, enum display_type dtype, -		       int seqnum) -{ -  struct prefix_list_entry *pentry; - -  /* Print the name of the protocol */ -  vty_out(vty, "%s: ", zlog_protoname()); -                                                                            -  if (dtype == normal_display) -    { -      vty_out (vty, "ip%s prefix-list %s: %d entries%s", -	       afi == AFI_IP ? "" : "v6", -	       plist->name, plist->count, VTY_NEWLINE); -      if (plist->desc) -	vty_out (vty, "   Description: %s%s", plist->desc, VTY_NEWLINE); -    } -  else if (dtype == summary_display || dtype == detail_display) -    { -      vty_out (vty, "ip%s prefix-list %s:%s", -	       afi == AFI_IP ? "" : "v6", plist->name, VTY_NEWLINE); - -      if (plist->desc) -	vty_out (vty, "   Description: %s%s", plist->desc, VTY_NEWLINE); - -      vty_out (vty, "   count: %d, range entries: %d, sequences: %u - %u%s", -	       plist->count, plist->rangecount,  -	       plist->head ? plist->head->seq : 0,  -	       plist->tail ? plist->tail->seq : 0, -	       VTY_NEWLINE); -    } - -  if (dtype != summary_display) -    { -      for (pentry = plist->head; pentry; pentry = pentry->next) -	{ -	  if (dtype == sequential_display && pentry->seq != seqnum) -	    continue; -	     -	  vty_out (vty, "   "); - -	  if (master->seqnum) -	    vty_out (vty, "seq %u ", pentry->seq); - -	  vty_out (vty, "%s ", prefix_list_type_str (pentry)); - -	  if (pentry->any) -	    vty_out (vty, "any"); -	  else -	    { -	      struct prefix *p = &pentry->prefix; -	      char buf[BUFSIZ]; - -	      vty_out (vty, "%s/%d", -		       inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		       p->prefixlen); - -	      if (pentry->ge) -		vty_out (vty, " ge %d", pentry->ge); -	      if (pentry->le) -		vty_out (vty, " le %d", pentry->le); -	    } - -	  if (dtype == detail_display || dtype == sequential_display) -	    vty_out (vty, " (hit count: %ld, refcount: %ld)",  -		     pentry->hitcnt, pentry->refcnt); -	   -	  vty_out (vty, "%s", VTY_NEWLINE); +static void vty_show_prefix_entry(struct vty *vty, afi_t afi, +				  struct prefix_list *plist, +				  struct prefix_master *master, +				  enum display_type dtype, int seqnum) +{ +	struct prefix_list_entry *pentry; + +	/* Print the name of the protocol */ +	vty_out(vty, "%s: ", zlog_protoname()); + +	if (dtype == normal_display) { +		vty_out(vty, "ip%s prefix-list %s: %d entries%s", +			afi == AFI_IP ? "" : "v6", plist->name, plist->count, +			VTY_NEWLINE); +		if (plist->desc) +			vty_out(vty, "   Description: %s%s", plist->desc, +				VTY_NEWLINE); +	} else if (dtype == summary_display || dtype == detail_display) { +		vty_out(vty, "ip%s prefix-list %s:%s", +			afi == AFI_IP ? "" : "v6", plist->name, VTY_NEWLINE); + +		if (plist->desc) +			vty_out(vty, "   Description: %s%s", plist->desc, +				VTY_NEWLINE); + +		vty_out(vty, +			"   count: %d, range entries: %d, sequences: %u - %u%s", +			plist->count, plist->rangecount, +			plist->head ? plist->head->seq : 0, +			plist->tail ? plist->tail->seq : 0, VTY_NEWLINE);  	} -    } -} -static int -vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name, -		      const char *seq, enum display_type dtype) -{ -  struct prefix_list *plist; -  struct prefix_master *master; -  int seqnum = 0; +	if (dtype != summary_display) { +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			if (dtype == sequential_display +			    && pentry->seq != seqnum) +				continue; -  master = prefix_master_get (afi, 0); -  if (master == NULL) -    return CMD_WARNING; +			vty_out(vty, "   "); -  if (seq) -    seqnum = atoi (seq); +			if (master->seqnum) +				vty_out(vty, "seq %u ", pentry->seq); -  if (name) -    { -      plist = prefix_list_lookup (afi, name); -      if (! plist) -	{ -	  vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -	  return CMD_WARNING; -	} -      vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum); -    } -  else -    { -      if (dtype == detail_display || dtype == summary_display) -	{ -	  if (master->recent) -	    vty_out (vty, "Prefix-list with the last deletion/insertion: %s%s", -		     master->recent->name, VTY_NEWLINE); -	} +			vty_out(vty, "%s ", prefix_list_type_str(pentry)); + +			if (pentry->any) +				vty_out(vty, "any"); +			else { +				struct prefix *p = &pentry->prefix; +				char buf[BUFSIZ]; + +				vty_out(vty, "%s/%d", +					inet_ntop(p->family, &p->u.prefix, buf, +						  BUFSIZ), +					p->prefixlen); + +				if (pentry->ge) +					vty_out(vty, " ge %d", pentry->ge); +				if (pentry->le) +					vty_out(vty, " le %d", pentry->le); +			} + +			if (dtype == detail_display +			    || dtype == sequential_display) +				vty_out(vty, " (hit count: %ld, refcount: %ld)", +					pentry->hitcnt, pentry->refcnt); -      for (plist = master->num.head; plist; plist = plist->next) -	vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum); - -      for (plist = master->str.head; plist; plist = plist->next) -	vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum); -    } - -  return CMD_SUCCESS; -} - -static int -vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,  -			     const char *prefix, enum display_type type) -{ -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  struct prefix p; -  int ret; -  int match; - -  plist = prefix_list_lookup (afi, name); -  if (! plist) -    { -      vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  ret = str2prefix (prefix, &p); -  if (ret <= 0) -    { -      vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE); -      return CMD_WARNING; -    } - -  for (pentry = plist->head; pentry; pentry = pentry->next) -    { -      match = 0; - -      if (type == normal_display || type == first_match_display) -	if (prefix_same (&p, &pentry->prefix)) -	  match = 1; - -      if (type == longer_display) -	if (prefix_match (&p, &pentry->prefix)) -	  match = 1; - -      if (match) -	{ -	  vty_out (vty, "   seq %u %s ", -		   pentry->seq, -		   prefix_list_type_str (pentry)); - -	  if (pentry->any) -	    vty_out (vty, "any"); -	  else -	    { -	      struct prefix *p = &pentry->prefix; -	      char buf[BUFSIZ]; -	       -	      vty_out (vty, "%s/%d", -		       inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		       p->prefixlen); - -	      if (pentry->ge) -		vty_out (vty, " ge %d", pentry->ge); -	      if (pentry->le) -		vty_out (vty, " le %d", pentry->le); -	    } -	   -	  if (type == normal_display || type == first_match_display) -	    vty_out (vty, " (hit count: %ld, refcount: %ld)",  -		     pentry->hitcnt, pentry->refcnt); - -	  vty_out (vty, "%s", VTY_NEWLINE); - -	  if (type == first_match_display) -	    return CMD_SUCCESS; +			vty_out(vty, "%s", VTY_NEWLINE); +		}  	} -    } -  return CMD_SUCCESS;  } -static int -vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,  -                       const char *prefix) -{ -  struct prefix_master *master; -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  int ret; -  struct prefix p; +static int vty_show_prefix_list(struct vty *vty, afi_t afi, const char *name, +				const char *seq, enum display_type dtype) +{ +	struct prefix_list *plist; +	struct prefix_master *master; +	int seqnum = 0; + +	master = prefix_master_get(afi, 0); +	if (master == NULL) +		return CMD_WARNING; + +	if (seq) +		seqnum = atoi(seq); + +	if (name) { +		plist = prefix_list_lookup(afi, name); +		if (!plist) { +			vty_out(vty, "%% Can't find specified prefix-list%s", +				VTY_NEWLINE); +			return CMD_WARNING; +		} +		vty_show_prefix_entry(vty, afi, plist, master, dtype, seqnum); +	} else { +		if (dtype == detail_display || dtype == summary_display) { +			if (master->recent) +				vty_out(vty, +					"Prefix-list with the last deletion/insertion: %s%s", +					master->recent->name, VTY_NEWLINE); +		} + +		for (plist = master->num.head; plist; plist = plist->next) +			vty_show_prefix_entry(vty, afi, plist, master, dtype, +					      seqnum); + +		for (plist = master->str.head; plist; plist = plist->next) +			vty_show_prefix_entry(vty, afi, plist, master, dtype, +					      seqnum); +	} -  master = prefix_master_get (afi, 0); -  if (master == NULL) -    return CMD_WARNING; +	return CMD_SUCCESS; +} -  if (name == NULL && prefix == NULL) -    { -      for (plist = master->num.head; plist; plist = plist->next) -	for (pentry = plist->head; pentry; pentry = pentry->next) -	  pentry->hitcnt = 0; +static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi, +				       const char *name, const char *prefix, +				       enum display_type type) +{ +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	struct prefix p; +	int ret; +	int match; -      for (plist = master->str.head; plist; plist = plist->next) -	for (pentry = plist->head; pentry; pentry = pentry->next) -	  pentry->hitcnt = 0; -    } -  else -    { -      plist = prefix_list_lookup (afi, name); -      if (! plist) -	{ -	  vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE); -	  return CMD_WARNING; +	plist = prefix_list_lookup(afi, name); +	if (!plist) { +		vty_out(vty, "%% Can't find specified prefix-list%s", +			VTY_NEWLINE); +		return CMD_WARNING;  	} -      if (prefix) -	{ -	  ret = str2prefix (prefix, &p); -	  if (ret <= 0) -	    { -	      vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE); -	      return CMD_WARNING; -	    } +	ret = str2prefix(prefix, &p); +	if (ret <= 0) { +		vty_out(vty, "%% prefix is malformed%s", VTY_NEWLINE); +		return CMD_WARNING;  	} -      for (pentry = plist->head; pentry; pentry = pentry->next) -	{ -	  if (prefix) -	    { -	      if (prefix_match (&pentry->prefix, &p)) -		pentry->hitcnt = 0; -	    } -	  else -	    pentry->hitcnt = 0; +	for (pentry = plist->head; pentry; pentry = pentry->next) { +		match = 0; + +		if (type == normal_display || type == first_match_display) +			if (prefix_same(&p, &pentry->prefix)) +				match = 1; + +		if (type == longer_display) +			if (prefix_match(&p, &pentry->prefix)) +				match = 1; + +		if (match) { +			vty_out(vty, "   seq %u %s ", pentry->seq, +				prefix_list_type_str(pentry)); + +			if (pentry->any) +				vty_out(vty, "any"); +			else { +				struct prefix *p = &pentry->prefix; +				char buf[BUFSIZ]; + +				vty_out(vty, "%s/%d", +					inet_ntop(p->family, &p->u.prefix, buf, +						  BUFSIZ), +					p->prefixlen); + +				if (pentry->ge) +					vty_out(vty, " ge %d", pentry->ge); +				if (pentry->le) +					vty_out(vty, " le %d", pentry->le); +			} + +			if (type == normal_display +			    || type == first_match_display) +				vty_out(vty, " (hit count: %ld, refcount: %ld)", +					pentry->hitcnt, pentry->refcnt); + +			vty_out(vty, "%s", VTY_NEWLINE); + +			if (type == first_match_display) +				return CMD_SUCCESS; +		}  	} -    } -  return CMD_SUCCESS; +	return CMD_SUCCESS; +} + +static int vty_clear_prefix_list(struct vty *vty, afi_t afi, const char *name, +				 const char *prefix) +{ +	struct prefix_master *master; +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	int ret; +	struct prefix p; + +	master = prefix_master_get(afi, 0); +	if (master == NULL) +		return CMD_WARNING; + +	if (name == NULL && prefix == NULL) { +		for (plist = master->num.head; plist; plist = plist->next) +			for (pentry = plist->head; pentry; +			     pentry = pentry->next) +				pentry->hitcnt = 0; + +		for (plist = master->str.head; plist; plist = plist->next) +			for (pentry = plist->head; pentry; +			     pentry = pentry->next) +				pentry->hitcnt = 0; +	} else { +		plist = prefix_list_lookup(afi, name); +		if (!plist) { +			vty_out(vty, "%% Can't find specified prefix-list%s", +				VTY_NEWLINE); +			return CMD_WARNING; +		} + +		if (prefix) { +			ret = str2prefix(prefix, &p); +			if (ret <= 0) { +				vty_out(vty, "%% prefix is malformed%s", +					VTY_NEWLINE); +				return CMD_WARNING; +			} +		} + +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			if (prefix) { +				if (prefix_match(&pentry->prefix, &p)) +					pentry->hitcnt = 0; +			} else +				pentry->hitcnt = 0; +		} +	} +	return CMD_SUCCESS;  }  DEFUN (ip_prefix_list, @@ -1424,11 +1313,12 @@ DEFUN (ip_prefix_list,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv4_any = 4; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL,  -				  argv[idx_permit_deny]->arg, argv[idx_ipv4_any]->arg, NULL, NULL); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv4_any = 4; +	return vty_prefix_list_install(vty, AFI_IP, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv4_any]->arg, NULL, NULL);  }  DEFUN (ip_prefix_list_ge, @@ -1443,12 +1333,14 @@ DEFUN (ip_prefix_list_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv4_prefixlen = 4; -  int idx_number = 6; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,  -				 argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv4_prefixlen = 4; +	int idx_number = 6; +	return vty_prefix_list_install(vty, AFI_IP, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv4_prefixlen]->arg, +				       argv[idx_number]->arg, NULL);  }  DEFUN (ip_prefix_list_ge_le, @@ -1465,13 +1357,15 @@ DEFUN (ip_prefix_list_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv4_prefixlen = 4; -  int idx_number = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,  -				  argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv4_prefixlen = 4; +	int idx_number = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number]->arg, argv[idx_number_2]->arg);  }  DEFUN (ip_prefix_list_le, @@ -1486,12 +1380,14 @@ DEFUN (ip_prefix_list_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv4_prefixlen = 4; -  int idx_number = 6; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv4_prefixlen = 4; +	int idx_number = 6; +	return vty_prefix_list_install(vty, AFI_IP, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv4_prefixlen]->arg, NULL, +				       argv[idx_number]->arg);  }  DEFUN (ip_prefix_list_le_ge, @@ -1508,13 +1404,15 @@ DEFUN (ip_prefix_list_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv4_prefixlen = 4; -  int idx_number = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv4_prefixlen = 4; +	int idx_number = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number]->arg);  }  DEFUN (ip_prefix_list_seq, @@ -1530,12 +1428,14 @@ DEFUN (ip_prefix_list_seq,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv4_any = 6; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_any]->arg, NULL, NULL); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv4_any = 6; +	return vty_prefix_list_install(vty, AFI_IP, argv[idx_word]->arg, +				       argv[idx_number]->arg, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv4_any]->arg, NULL, NULL);  }  DEFUN (ip_prefix_list_seq_ge, @@ -1552,13 +1452,15 @@ DEFUN (ip_prefix_list_seq_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv4_prefixlen = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv4_prefixlen = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, NULL);  }  DEFUN (ip_prefix_list_seq_ge_le, @@ -1577,14 +1479,16 @@ DEFUN (ip_prefix_list_seq_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv4_prefixlen = 6; -  int idx_number_2 = 8; -  int idx_number_3 = 10; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv4_prefixlen = 6; +	int idx_number_2 = 8; +	int idx_number_3 = 10; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number_3]->arg);  }  DEFUN (ip_prefix_list_seq_le, @@ -1601,13 +1505,15 @@ DEFUN (ip_prefix_list_seq_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv4_prefixlen = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv4_prefixlen = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, NULL, +		argv[idx_number_2]->arg);  }  DEFUN (ip_prefix_list_seq_le_ge, @@ -1626,14 +1532,16 @@ DEFUN (ip_prefix_list_seq_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv4_prefixlen = 6; -  int idx_number_2 = 8; -  int idx_number_3 = 10; -  return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv4_prefixlen = 6; +	int idx_number_2 = 8; +	int idx_number_3 = 10; +	return vty_prefix_list_install( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_3]->arg, argv[idx_number_2]->arg);  }  DEFUN (no_ip_prefix_list, @@ -1644,9 +1552,9 @@ DEFUN (no_ip_prefix_list,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, NULL, -				    NULL, NULL, NULL); +	int idx_word = 3; +	return vty_prefix_list_uninstall(vty, AFI_IP, argv[idx_word]->arg, NULL, +					 NULL, NULL, NULL, NULL);  }  DEFUN (no_ip_prefix_list_prefix, @@ -1661,11 +1569,12 @@ DEFUN (no_ip_prefix_list_prefix,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "Any prefix match.  Same as \"0.0.0.0/0 le 32\"\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv4_any = 5; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_any]->arg, NULL, NULL); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv4_any = 5; +	return vty_prefix_list_uninstall(vty, AFI_IP, argv[idx_word]->arg, NULL, +					 argv[idx_permit_deny]->arg, +					 argv[idx_ipv4_any]->arg, NULL, NULL);  }  DEFUN (no_ip_prefix_list_ge, @@ -1681,12 +1590,14 @@ DEFUN (no_ip_prefix_list_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv4_prefixlen = 5; -  int idx_number = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv4_prefixlen = 5; +	int idx_number = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP, argv[idx_word]->arg, NULL, +					 argv[idx_permit_deny]->arg, +					 argv[idx_ipv4_prefixlen]->arg, +					 argv[idx_number]->arg, NULL);  }  DEFUN (no_ip_prefix_list_ge_le, @@ -1704,13 +1615,15 @@ DEFUN (no_ip_prefix_list_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv4_prefixlen = 5; -  int idx_number = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv4_prefixlen = 5; +	int idx_number = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number]->arg, argv[idx_number_2]->arg);  }  DEFUN (no_ip_prefix_list_le, @@ -1726,12 +1639,14 @@ DEFUN (no_ip_prefix_list_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv4_prefixlen = 5; -  int idx_number = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv4_prefixlen = 5; +	int idx_number = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP, argv[idx_word]->arg, NULL, +					 argv[idx_permit_deny]->arg, +					 argv[idx_ipv4_prefixlen]->arg, NULL, +					 argv[idx_number]->arg);  }  DEFUN (no_ip_prefix_list_le_ge, @@ -1749,13 +1664,15 @@ DEFUN (no_ip_prefix_list_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv4_prefixlen = 5; -  int idx_number = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv4_prefixlen = 5; +	int idx_number = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number]->arg);  }  DEFUN (no_ip_prefix_list_seq, @@ -1772,12 +1689,14 @@ DEFUN (no_ip_prefix_list_seq,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "Any prefix match.  Same as \"0.0.0.0/0 le 32\"\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv4_any = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_any]->arg, NULL, NULL); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv4_any = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP, argv[idx_word]->arg, +					 argv[idx_number]->arg, +					 argv[idx_permit_deny]->arg, +					 argv[idx_ipv4_any]->arg, NULL, NULL);  }  DEFUN (no_ip_prefix_list_seq_ge, @@ -1795,13 +1714,15 @@ DEFUN (no_ip_prefix_list_seq_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv4_prefixlen = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv4_prefixlen = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, NULL);  }  DEFUN (no_ip_prefix_list_seq_ge_le, @@ -1821,14 +1742,16 @@ DEFUN (no_ip_prefix_list_seq_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv4_prefixlen = 7; -  int idx_number_2 = 9; -  int idx_number_3 = 11; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv4_prefixlen = 7; +	int idx_number_2 = 9; +	int idx_number_3 = 11; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number_3]->arg);  }  DEFUN (no_ip_prefix_list_seq_le, @@ -1846,13 +1769,15 @@ DEFUN (no_ip_prefix_list_seq_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv4_prefixlen = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv4_prefixlen = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, NULL, +		argv[idx_number_2]->arg);  }  DEFUN (no_ip_prefix_list_seq_le_ge, @@ -1872,14 +1797,16 @@ DEFUN (no_ip_prefix_list_seq_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv4_prefixlen = 7; -  int idx_number_2 = 9; -  int idx_number_3 = 11; -  return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv4_prefixlen = 7; +	int idx_number_2 = 9; +	int idx_number_3 = 11; +	return vty_prefix_list_uninstall( +		vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv4_prefixlen]->arg, +		argv[idx_number_3]->arg, argv[idx_number_2]->arg);  }  DEFUN (ip_prefix_list_sequence_number, @@ -1889,8 +1816,8 @@ DEFUN (ip_prefix_list_sequence_number,         PREFIX_LIST_STR         "Include/exclude sequence numbers in NVGEN\n")  { -  prefix_master_ipv4.seqnum = 1; -  return CMD_SUCCESS; +	prefix_master_ipv4.seqnum = 1; +	return CMD_SUCCESS;  }  DEFUN (no_ip_prefix_list_sequence_number, @@ -1901,8 +1828,8 @@ DEFUN (no_ip_prefix_list_sequence_number,         PREFIX_LIST_STR         "Include/exclude sequence numbers in NVGEN\n")  { -  prefix_master_ipv4.seqnum = 0; -  return CMD_SUCCESS; +	prefix_master_ipv4.seqnum = 0; +	return CMD_SUCCESS;  }  DEFUN (ip_prefix_list_description, @@ -1914,20 +1841,19 @@ DEFUN (ip_prefix_list_description,         "Prefix-list specific description\n"         "Up to 80 characters describing this prefix-list\n")  { -  int idx_word = 2; -  int idx_line = 4; -  struct prefix_list *plist; +	int idx_word = 2; +	int idx_line = 4; +	struct prefix_list *plist; + +	plist = prefix_list_get(AFI_IP, 0, argv[idx_word]->arg); -  plist = prefix_list_get (AFI_IP, 0, argv[idx_word]->arg); -   -  if (plist->desc) -    { -      XFREE (MTYPE_TMP, plist->desc); -      plist->desc = NULL; -    } -  plist->desc = argv_concat(argv, argc, idx_line); +	if (plist->desc) { +		XFREE(MTYPE_TMP, plist->desc); +		plist->desc = NULL; +	} +	plist->desc = argv_concat(argv, argc, idx_line); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ip_prefix_list_description, @@ -1939,8 +1865,8 @@ DEFUN (no_ip_prefix_list_description,         "Name of a prefix list\n"         "Prefix-list specific description\n")  { -  int idx_word = 3; -  return vty_prefix_list_desc_unset (vty, AFI_IP, argv[idx_word]->arg); +	int idx_word = 3; +	return vty_prefix_list_desc_unset(vty, AFI_IP, argv[idx_word]->arg);  }  /* ALIAS_FIXME */ @@ -1954,7 +1880,7 @@ DEFUN (no_ip_prefix_list_description_comment,         "Prefix-list specific description\n"         "Up to 80 characters describing this prefix-list\n")  { -  return no_ip_prefix_list_description (self, vty, argc, argv); +	return no_ip_prefix_list_description(self, vty, argc, argv);  }  DEFUN (show_ip_prefix_list, @@ -1964,7 +1890,7 @@ DEFUN (show_ip_prefix_list,         IP_STR         PREFIX_LIST_STR)  { -  return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, normal_display); +	return vty_show_prefix_list(vty, AFI_IP, NULL, NULL, normal_display);  }  DEFUN (show_ip_prefix_list_name, @@ -1975,8 +1901,9 @@ DEFUN (show_ip_prefix_list_name,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, normal_display); +	int idx_word = 3; +	return vty_show_prefix_list(vty, AFI_IP, argv[idx_word]->arg, NULL, +				    normal_display);  }  DEFUN (show_ip_prefix_list_name_seq, @@ -1989,9 +1916,10 @@ DEFUN (show_ip_prefix_list_name_seq,         "sequence number of an entry\n"         "Sequence number\n")  { -  int idx_word = 3; -  int idx_number = 5; -  return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display); +	int idx_word = 3; +	int idx_number = 5; +	return vty_show_prefix_list(vty, AFI_IP, argv[idx_word]->arg, +				    argv[idx_number]->arg, sequential_display);  }  DEFUN (show_ip_prefix_list_prefix, @@ -2003,9 +1931,11 @@ DEFUN (show_ip_prefix_list_prefix,         "Name of a prefix list\n"         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")  { -  int idx_word = 3; -  int idx_ipv4_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, normal_display); +	int idx_word = 3; +	int idx_ipv4_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP, argv[idx_word]->arg, +					   argv[idx_ipv4_prefixlen]->arg, +					   normal_display);  }  DEFUN (show_ip_prefix_list_prefix_longer, @@ -2018,9 +1948,11 @@ DEFUN (show_ip_prefix_list_prefix_longer,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "Lookup longer prefix\n")  { -  int idx_word = 3; -  int idx_ipv4_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, longer_display); +	int idx_word = 3; +	int idx_ipv4_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP, argv[idx_word]->arg, +					   argv[idx_ipv4_prefixlen]->arg, +					   longer_display);  }  DEFUN (show_ip_prefix_list_prefix_first_match, @@ -2033,9 +1965,11 @@ DEFUN (show_ip_prefix_list_prefix_first_match,         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"         "First matched prefix\n")  { -  int idx_word = 3; -  int idx_ipv4_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, first_match_display); +	int idx_word = 3; +	int idx_ipv4_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP, argv[idx_word]->arg, +					   argv[idx_ipv4_prefixlen]->arg, +					   first_match_display);  }  DEFUN (show_ip_prefix_list_summary, @@ -2046,7 +1980,7 @@ DEFUN (show_ip_prefix_list_summary,         PREFIX_LIST_STR         "Summary of prefix lists\n")  { -  return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, summary_display); +	return vty_show_prefix_list(vty, AFI_IP, NULL, NULL, summary_display);  }  DEFUN (show_ip_prefix_list_summary_name, @@ -2058,8 +1992,9 @@ DEFUN (show_ip_prefix_list_summary_name,         "Summary of prefix lists\n"         "Name of a prefix list\n")  { -  int idx_word = 4; -  return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, summary_display); +	int idx_word = 4; +	return vty_show_prefix_list(vty, AFI_IP, argv[idx_word]->arg, NULL, +				    summary_display);  } @@ -2071,7 +2006,7 @@ DEFUN (show_ip_prefix_list_detail,         PREFIX_LIST_STR         "Detail of prefix lists\n")  { -  return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, detail_display); +	return vty_show_prefix_list(vty, AFI_IP, NULL, NULL, detail_display);  }  DEFUN (show_ip_prefix_list_detail_name, @@ -2083,8 +2018,9 @@ DEFUN (show_ip_prefix_list_detail_name,         "Detail of prefix lists\n"         "Name of a prefix list\n")  { -  int idx_word = 4; -  return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, detail_display); +	int idx_word = 4; +	return vty_show_prefix_list(vty, AFI_IP, argv[idx_word]->arg, NULL, +				    detail_display);  }  DEFUN (clear_ip_prefix_list, @@ -2094,7 +2030,7 @@ DEFUN (clear_ip_prefix_list,         IP_STR         PREFIX_LIST_STR)  { -  return vty_clear_prefix_list (vty, AFI_IP, NULL, NULL); +	return vty_clear_prefix_list(vty, AFI_IP, NULL, NULL);  }  DEFUN (clear_ip_prefix_list_name, @@ -2105,8 +2041,8 @@ DEFUN (clear_ip_prefix_list_name,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL); +	int idx_word = 3; +	return vty_clear_prefix_list(vty, AFI_IP, argv[idx_word]->arg, NULL);  }  DEFUN (clear_ip_prefix_list_name_prefix, @@ -2118,9 +2054,10 @@ DEFUN (clear_ip_prefix_list_name_prefix,         "Name of a prefix list\n"         "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")  { -  int idx_word = 3; -  int idx_ipv4_prefixlen = 4; -  return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg); +	int idx_word = 3; +	int idx_ipv4_prefixlen = 4; +	return vty_clear_prefix_list(vty, AFI_IP, argv[idx_word]->arg, +				     argv[idx_ipv4_prefixlen]->arg);  }  DEFUN (ipv6_prefix_list, @@ -2134,11 +2071,12 @@ DEFUN (ipv6_prefix_list,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "Any prefix match.  Same as \"::0/0 le 128\"\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv6_any = 4; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL,  -				  argv[idx_permit_deny]->arg, argv[idx_ipv6_any]->arg, NULL, NULL); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv6_any = 4; +	return vty_prefix_list_install(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv6_any]->arg, NULL, NULL);  }  DEFUN (ipv6_prefix_list_ge, @@ -2153,12 +2091,14 @@ DEFUN (ipv6_prefix_list_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv6_prefixlen = 4; -  int idx_number = 6; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,  -				 argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv6_prefixlen = 4; +	int idx_number = 6; +	return vty_prefix_list_install(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv6_prefixlen]->arg, +				       argv[idx_number]->arg, NULL);  }  DEFUN (ipv6_prefix_list_ge_le, @@ -2174,15 +2114,16 @@ DEFUN (ipv6_prefix_list_ge_le,         "Minimum prefix length\n"         "Maximum prefix length to be matched\n"         "Maximum prefix length\n") -  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv6_prefixlen = 4; -  int idx_number = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,  -				  argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv6_prefixlen = 4; +	int idx_number = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number]->arg, argv[idx_number_2]->arg);  }  DEFUN (ipv6_prefix_list_le, @@ -2197,12 +2138,14 @@ DEFUN (ipv6_prefix_list_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv6_prefixlen = 4; -  int idx_number = 6; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv6_prefixlen = 4; +	int idx_number = 6; +	return vty_prefix_list_install(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv6_prefixlen]->arg, NULL, +				       argv[idx_number]->arg);  }  DEFUN (ipv6_prefix_list_le_ge, @@ -2219,13 +2162,15 @@ DEFUN (ipv6_prefix_list_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_permit_deny = 3; -  int idx_ipv6_prefixlen = 4; -  int idx_number = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); +	int idx_word = 2; +	int idx_permit_deny = 3; +	int idx_ipv6_prefixlen = 4; +	int idx_number = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number]->arg);  }  DEFUN (ipv6_prefix_list_seq, @@ -2241,12 +2186,14 @@ DEFUN (ipv6_prefix_list_seq,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "Any prefix match.  Same as \"::0/0 le 128\"\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv6_any = 6; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_any]->arg, NULL, NULL); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv6_any = 6; +	return vty_prefix_list_install(vty, AFI_IP6, argv[idx_word]->arg, +				       argv[idx_number]->arg, +				       argv[idx_permit_deny]->arg, +				       argv[idx_ipv6_any]->arg, NULL, NULL);  }  DEFUN (ipv6_prefix_list_seq_ge, @@ -2263,13 +2210,15 @@ DEFUN (ipv6_prefix_list_seq_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv6_prefixlen = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv6_prefixlen = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, NULL);  }  DEFUN (ipv6_prefix_list_seq_ge_le, @@ -2288,14 +2237,16 @@ DEFUN (ipv6_prefix_list_seq_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv6_prefixlen = 6; -  int idx_number_2 = 8; -  int idx_number_3 = 10; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv6_prefixlen = 6; +	int idx_number_2 = 8; +	int idx_number_3 = 10; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number_3]->arg);  }  DEFUN (ipv6_prefix_list_seq_le, @@ -2312,13 +2263,15 @@ DEFUN (ipv6_prefix_list_seq_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv6_prefixlen = 6; -  int idx_number_2 = 8; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv6_prefixlen = 6; +	int idx_number_2 = 8; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, NULL, +		argv[idx_number_2]->arg);  }  DEFUN (ipv6_prefix_list_seq_le_ge, @@ -2337,14 +2290,16 @@ DEFUN (ipv6_prefix_list_seq_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 2; -  int idx_number = 4; -  int idx_permit_deny = 5; -  int idx_ipv6_prefixlen = 6; -  int idx_number_2 = 8; -  int idx_number_3 = 10; -  return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				  argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); +	int idx_word = 2; +	int idx_number = 4; +	int idx_permit_deny = 5; +	int idx_ipv6_prefixlen = 6; +	int idx_number_2 = 8; +	int idx_number_3 = 10; +	return vty_prefix_list_install( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_3]->arg, argv[idx_number_2]->arg);  }  DEFUN (no_ipv6_prefix_list, @@ -2355,9 +2310,9 @@ DEFUN (no_ipv6_prefix_list,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, NULL, -				    NULL, NULL, NULL); +	int idx_word = 3; +	return vty_prefix_list_uninstall(vty, AFI_IP6, argv[idx_word]->arg, +					 NULL, NULL, NULL, NULL, NULL);  }  DEFUN (no_ipv6_prefix_list_prefix, @@ -2372,11 +2327,12 @@ DEFUN (no_ipv6_prefix_list_prefix,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "Any prefix match.  Same as \"::0/0 le 128\"\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv6_any = 5; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_any]->arg, NULL, NULL); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv6_any = 5; +	return vty_prefix_list_uninstall(vty, AFI_IP6, argv[idx_word]->arg, +					 NULL, argv[idx_permit_deny]->arg, +					 argv[idx_ipv6_any]->arg, NULL, NULL);  }  DEFUN (no_ipv6_prefix_list_ge, @@ -2392,12 +2348,14 @@ DEFUN (no_ipv6_prefix_list_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv6_prefixlen = 5; -  int idx_number = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv6_prefixlen = 5; +	int idx_number = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP6, argv[idx_word]->arg, +					 NULL, argv[idx_permit_deny]->arg, +					 argv[idx_ipv6_prefixlen]->arg, +					 argv[idx_number]->arg, NULL);  }  DEFUN (no_ipv6_prefix_list_ge_le, @@ -2415,13 +2373,15 @@ DEFUN (no_ipv6_prefix_list_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv6_prefixlen = 5; -  int idx_number = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv6_prefixlen = 5; +	int idx_number = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number]->arg, argv[idx_number_2]->arg);  }  DEFUN (no_ipv6_prefix_list_le, @@ -2437,12 +2397,14 @@ DEFUN (no_ipv6_prefix_list_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv6_prefixlen = 5; -  int idx_number = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv6_prefixlen = 5; +	int idx_number = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP6, argv[idx_word]->arg, +					 NULL, argv[idx_permit_deny]->arg, +					 argv[idx_ipv6_prefixlen]->arg, NULL, +					 argv[idx_number]->arg);  }  DEFUN (no_ipv6_prefix_list_le_ge, @@ -2460,13 +2422,15 @@ DEFUN (no_ipv6_prefix_list_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_permit_deny = 4; -  int idx_ipv6_prefixlen = 5; -  int idx_number = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg); +	int idx_word = 3; +	int idx_permit_deny = 4; +	int idx_ipv6_prefixlen = 5; +	int idx_number = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, NULL, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number]->arg);  }  DEFUN (no_ipv6_prefix_list_seq, @@ -2483,12 +2447,14 @@ DEFUN (no_ipv6_prefix_list_seq,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "Any prefix match.  Same as \"::0/0 le 128\"\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv6_any = 7; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_any]->arg, NULL, NULL); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv6_any = 7; +	return vty_prefix_list_uninstall(vty, AFI_IP6, argv[idx_word]->arg, +					 argv[idx_number]->arg, +					 argv[idx_permit_deny]->arg, +					 argv[idx_ipv6_any]->arg, NULL, NULL);  }  DEFUN (no_ipv6_prefix_list_seq_ge, @@ -2506,13 +2472,15 @@ DEFUN (no_ipv6_prefix_list_seq_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv6_prefixlen = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv6_prefixlen = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, NULL);  }  DEFUN (no_ipv6_prefix_list_seq_ge_le, @@ -2532,14 +2500,16 @@ DEFUN (no_ipv6_prefix_list_seq_ge_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv6_prefixlen = 7; -  int idx_number_2 = 9; -  int idx_number_3 = 11; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv6_prefixlen = 7; +	int idx_number_2 = 9; +	int idx_number_3 = 11; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_2]->arg, argv[idx_number_3]->arg);  }  DEFUN (no_ipv6_prefix_list_seq_le, @@ -2557,13 +2527,15 @@ DEFUN (no_ipv6_prefix_list_seq_le,         "Maximum prefix length to be matched\n"         "Maximum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv6_prefixlen = 7; -  int idx_number_2 = 9; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv6_prefixlen = 7; +	int idx_number_2 = 9; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, NULL, +		argv[idx_number_2]->arg);  }  DEFUN (no_ipv6_prefix_list_seq_le_ge, @@ -2583,14 +2555,16 @@ DEFUN (no_ipv6_prefix_list_seq_le_ge,         "Minimum prefix length to be matched\n"         "Minimum prefix length\n")  { -  int idx_word = 3; -  int idx_number = 5; -  int idx_permit_deny = 6; -  int idx_ipv6_prefixlen = 7; -  int idx_number_2 = 9; -  int idx_number_3 = 11; -  return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg, -				    argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg); +	int idx_word = 3; +	int idx_number = 5; +	int idx_permit_deny = 6; +	int idx_ipv6_prefixlen = 7; +	int idx_number_2 = 9; +	int idx_number_3 = 11; +	return vty_prefix_list_uninstall( +		vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, +		argv[idx_permit_deny]->arg, argv[idx_ipv6_prefixlen]->arg, +		argv[idx_number_3]->arg, argv[idx_number_2]->arg);  }  DEFUN (ipv6_prefix_list_sequence_number, @@ -2600,8 +2574,8 @@ DEFUN (ipv6_prefix_list_sequence_number,         PREFIX_LIST_STR         "Include/exclude sequence numbers in NVGEN\n")  { -  prefix_master_ipv6.seqnum = 1; -  return CMD_SUCCESS; +	prefix_master_ipv6.seqnum = 1; +	return CMD_SUCCESS;  }  DEFUN (no_ipv6_prefix_list_sequence_number, @@ -2612,8 +2586,8 @@ DEFUN (no_ipv6_prefix_list_sequence_number,         PREFIX_LIST_STR         "Include/exclude sequence numbers in NVGEN\n")  { -  prefix_master_ipv6.seqnum = 0; -  return CMD_SUCCESS; +	prefix_master_ipv6.seqnum = 0; +	return CMD_SUCCESS;  }  DEFUN (ipv6_prefix_list_description, @@ -2625,20 +2599,19 @@ DEFUN (ipv6_prefix_list_description,         "Prefix-list specific description\n"         "Up to 80 characters describing this prefix-list\n")  { -  int idx_word = 2; -  int iddx_line = 4; -  struct prefix_list *plist; +	int idx_word = 2; +	int iddx_line = 4; +	struct prefix_list *plist; + +	plist = prefix_list_get(AFI_IP6, 0, argv[idx_word]->arg); -  plist = prefix_list_get (AFI_IP6, 0, argv[idx_word]->arg); -   -  if (plist->desc) -    { -      XFREE (MTYPE_TMP, plist->desc); -      plist->desc = NULL; -    } -  plist->desc = argv_concat(argv, argc, iddx_line); +	if (plist->desc) { +		XFREE(MTYPE_TMP, plist->desc); +		plist->desc = NULL; +	} +	plist->desc = argv_concat(argv, argc, iddx_line); -  return CMD_SUCCESS; +	return CMD_SUCCESS;  }  DEFUN (no_ipv6_prefix_list_description, @@ -2650,8 +2623,8 @@ DEFUN (no_ipv6_prefix_list_description,         "Name of a prefix list\n"         "Prefix-list specific description\n")  { -  int idx_word = 3; -  return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[idx_word]->arg); +	int idx_word = 3; +	return vty_prefix_list_desc_unset(vty, AFI_IP6, argv[idx_word]->arg);  }  /* ALIAS_FIXME */ @@ -2665,7 +2638,7 @@ DEFUN (no_ipv6_prefix_list_description_comment,         "Prefix-list specific description\n"         "Up to 80 characters describing this prefix-list\n")  { -  return no_ipv6_prefix_list_description (self, vty, argc, argv); +	return no_ipv6_prefix_list_description(self, vty, argc, argv);  } @@ -2676,7 +2649,7 @@ DEFUN (show_ipv6_prefix_list,         IPV6_STR         PREFIX_LIST_STR)  { -  return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, normal_display); +	return vty_show_prefix_list(vty, AFI_IP6, NULL, NULL, normal_display);  }  DEFUN (show_ipv6_prefix_list_name, @@ -2687,8 +2660,9 @@ DEFUN (show_ipv6_prefix_list_name,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, normal_display); +	int idx_word = 3; +	return vty_show_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				    normal_display);  }  DEFUN (show_ipv6_prefix_list_name_seq, @@ -2701,9 +2675,10 @@ DEFUN (show_ipv6_prefix_list_name_seq,         "sequence number of an entry\n"         "Sequence number\n")  { -  int idx_word = 3; -  int idx_number = 5; -  return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display); +	int idx_word = 3; +	int idx_number = 5; +	return vty_show_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, +				    argv[idx_number]->arg, sequential_display);  }  DEFUN (show_ipv6_prefix_list_prefix, @@ -2715,9 +2690,11 @@ DEFUN (show_ipv6_prefix_list_prefix,         "Name of a prefix list\n"         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")  { -  int idx_word = 3; -  int idx_ipv6_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, normal_display); +	int idx_word = 3; +	int idx_ipv6_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP6, argv[idx_word]->arg, +					   argv[idx_ipv6_prefixlen]->arg, +					   normal_display);  }  DEFUN (show_ipv6_prefix_list_prefix_longer, @@ -2730,9 +2707,11 @@ DEFUN (show_ipv6_prefix_list_prefix_longer,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "Lookup longer prefix\n")  { -  int idx_word = 3; -  int idx_ipv6_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, longer_display); +	int idx_word = 3; +	int idx_ipv6_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP6, argv[idx_word]->arg, +					   argv[idx_ipv6_prefixlen]->arg, +					   longer_display);  }  DEFUN (show_ipv6_prefix_list_prefix_first_match, @@ -2745,9 +2724,11 @@ DEFUN (show_ipv6_prefix_list_prefix_first_match,         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"         "First matched prefix\n")  { -  int idx_word = 3; -  int idx_ipv6_prefixlen = 4; -  return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, first_match_display); +	int idx_word = 3; +	int idx_ipv6_prefixlen = 4; +	return vty_show_prefix_list_prefix(vty, AFI_IP6, argv[idx_word]->arg, +					   argv[idx_ipv6_prefixlen]->arg, +					   first_match_display);  }  DEFUN (show_ipv6_prefix_list_summary, @@ -2758,7 +2739,7 @@ DEFUN (show_ipv6_prefix_list_summary,         PREFIX_LIST_STR         "Summary of prefix lists\n")  { -  return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, summary_display); +	return vty_show_prefix_list(vty, AFI_IP6, NULL, NULL, summary_display);  }  DEFUN (show_ipv6_prefix_list_summary_name, @@ -2770,8 +2751,9 @@ DEFUN (show_ipv6_prefix_list_summary_name,         "Summary of prefix lists\n"         "Name of a prefix list\n")  { -  int idx_word = 4; -  return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, summary_display); +	int idx_word = 4; +	return vty_show_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				    summary_display);  }  DEFUN (show_ipv6_prefix_list_detail, @@ -2782,7 +2764,7 @@ DEFUN (show_ipv6_prefix_list_detail,         PREFIX_LIST_STR         "Detail of prefix lists\n")  { -  return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, detail_display); +	return vty_show_prefix_list(vty, AFI_IP6, NULL, NULL, detail_display);  }  DEFUN (show_ipv6_prefix_list_detail_name, @@ -2794,8 +2776,9 @@ DEFUN (show_ipv6_prefix_list_detail_name,         "Detail of prefix lists\n"         "Name of a prefix list\n")  { -  int idx_word = 4; -  return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, detail_display); +	int idx_word = 4; +	return vty_show_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, NULL, +				    detail_display);  }  DEFUN (clear_ipv6_prefix_list, @@ -2805,7 +2788,7 @@ DEFUN (clear_ipv6_prefix_list,         IPV6_STR         PREFIX_LIST_STR)  { -  return vty_clear_prefix_list (vty, AFI_IP6, NULL, NULL); +	return vty_clear_prefix_list(vty, AFI_IP6, NULL, NULL);  }  DEFUN (clear_ipv6_prefix_list_name, @@ -2816,8 +2799,8 @@ DEFUN (clear_ipv6_prefix_list_name,         PREFIX_LIST_STR         "Name of a prefix list\n")  { -  int idx_word = 3; -  return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL); +	int idx_word = 3; +	return vty_clear_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, NULL);  }  DEFUN (clear_ipv6_prefix_list_name_prefix, @@ -2829,461 +2812,439 @@ DEFUN (clear_ipv6_prefix_list_name_prefix,         "Name of a prefix list\n"         "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")  { -  int idx_word = 3; -  int idx_ipv6_prefixlen = 4; -  return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg); +	int idx_word = 3; +	int idx_ipv6_prefixlen = 4; +	return vty_clear_prefix_list(vty, AFI_IP6, argv[idx_word]->arg, +				     argv[idx_ipv6_prefixlen]->arg);  }  /* Configuration write function. */ -static int -config_write_prefix_afi (afi_t afi, struct vty *vty) -{ -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  struct prefix_master *master; -  int write = 0; - -  master = prefix_master_get (afi, 0); -  if (master == NULL) -    return 0; - -  if (! master->seqnum) -    { -      vty_out (vty, "no ip%s prefix-list sequence-number%s",  -	       afi == AFI_IP ? "" : "v6", VTY_NEWLINE); -      vty_out (vty, "!%s", VTY_NEWLINE); -    } - -  for (plist = master->num.head; plist; plist = plist->next) -    { -      if (plist->desc) -	{ -	  vty_out (vty, "ip%s prefix-list %s description %s%s", -		   afi == AFI_IP ? "" : "v6", -		   plist->name, plist->desc, VTY_NEWLINE); -	  write++; -	} +static int config_write_prefix_afi(afi_t afi, struct vty *vty) +{ +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	struct prefix_master *master; +	int write = 0; -      for (pentry = plist->head; pentry; pentry = pentry->next) -	{ -	  vty_out (vty, "ip%s prefix-list %s ", -		   afi == AFI_IP ? "" : "v6", -		   plist->name); - -	  if (master->seqnum) -	    vty_out (vty, "seq %u ", pentry->seq); -	 -	  vty_out (vty, "%s ", prefix_list_type_str (pentry)); - -	  if (pentry->any) -	    vty_out (vty, "any"); -	  else -	    { -	      struct prefix *p = &pentry->prefix; -	      char buf[BUFSIZ]; - -	      vty_out (vty, "%s/%d", -		       inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		       p->prefixlen); - -	      if (pentry->ge) -		vty_out (vty, " ge %d", pentry->ge); -	      if (pentry->le) -		vty_out (vty, " le %d", pentry->le); -	    } -	  vty_out (vty, "%s", VTY_NEWLINE); -	  write++; +	master = prefix_master_get(afi, 0); +	if (master == NULL) +		return 0; + +	if (!master->seqnum) { +		vty_out(vty, "no ip%s prefix-list sequence-number%s", +			afi == AFI_IP ? "" : "v6", VTY_NEWLINE); +		vty_out(vty, "!%s", VTY_NEWLINE);  	} -      /* vty_out (vty, "!%s", VTY_NEWLINE); */ -    } - -  for (plist = master->str.head; plist; plist = plist->next) -    { -      if (plist->desc) -	{ -	  vty_out (vty, "ip%s prefix-list %s description %s%s", -		   afi == AFI_IP ? "" : "v6", -		   plist->name, plist->desc, VTY_NEWLINE); -	  write++; + +	for (plist = master->num.head; plist; plist = plist->next) { +		if (plist->desc) { +			vty_out(vty, "ip%s prefix-list %s description %s%s", +				afi == AFI_IP ? "" : "v6", plist->name, +				plist->desc, VTY_NEWLINE); +			write++; +		} + +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			vty_out(vty, "ip%s prefix-list %s ", +				afi == AFI_IP ? "" : "v6", plist->name); + +			if (master->seqnum) +				vty_out(vty, "seq %u ", pentry->seq); + +			vty_out(vty, "%s ", prefix_list_type_str(pentry)); + +			if (pentry->any) +				vty_out(vty, "any"); +			else { +				struct prefix *p = &pentry->prefix; +				char buf[BUFSIZ]; + +				vty_out(vty, "%s/%d", +					inet_ntop(p->family, &p->u.prefix, buf, +						  BUFSIZ), +					p->prefixlen); + +				if (pentry->ge) +					vty_out(vty, " ge %d", pentry->ge); +				if (pentry->le) +					vty_out(vty, " le %d", pentry->le); +			} +			vty_out(vty, "%s", VTY_NEWLINE); +			write++; +		} +		/* vty_out (vty, "!%s", VTY_NEWLINE); */  	} -      for (pentry = plist->head; pentry; pentry = pentry->next) -	{ -	  vty_out (vty, "ip%s prefix-list %s ", -		   afi == AFI_IP ? "" : "v6", -		   plist->name); - -	  if (master->seqnum) -	    vty_out (vty, "seq %u ", pentry->seq); - -	  vty_out (vty, "%s", prefix_list_type_str (pentry)); - -	  if (pentry->any) -	    vty_out (vty, " any"); -	  else -	    { -	      struct prefix *p = &pentry->prefix; -	      char buf[BUFSIZ]; - -	      vty_out (vty, " %s/%d", -		       inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -		       p->prefixlen); - -	      if (pentry->ge) -		vty_out (vty, " ge %d", pentry->ge); -	      if (pentry->le) -		vty_out (vty, " le %d", pentry->le); -	    } -	  vty_out (vty, "%s", VTY_NEWLINE); -	  write++; +	for (plist = master->str.head; plist; plist = plist->next) { +		if (plist->desc) { +			vty_out(vty, "ip%s prefix-list %s description %s%s", +				afi == AFI_IP ? "" : "v6", plist->name, +				plist->desc, VTY_NEWLINE); +			write++; +		} + +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			vty_out(vty, "ip%s prefix-list %s ", +				afi == AFI_IP ? "" : "v6", plist->name); + +			if (master->seqnum) +				vty_out(vty, "seq %u ", pentry->seq); + +			vty_out(vty, "%s", prefix_list_type_str(pentry)); + +			if (pentry->any) +				vty_out(vty, " any"); +			else { +				struct prefix *p = &pentry->prefix; +				char buf[BUFSIZ]; + +				vty_out(vty, " %s/%d", +					inet_ntop(p->family, &p->u.prefix, buf, +						  BUFSIZ), +					p->prefixlen); + +				if (pentry->ge) +					vty_out(vty, " ge %d", pentry->ge); +				if (pentry->le) +					vty_out(vty, " le %d", pentry->le); +			} +			vty_out(vty, "%s", VTY_NEWLINE); +			write++; +		}  	} -    } -   -  return write; + +	return write;  } -struct stream * -prefix_bgp_orf_entry (struct stream *s, struct prefix_list *plist, -		      u_char init_flag, u_char permit_flag, u_char deny_flag) +struct stream *prefix_bgp_orf_entry(struct stream *s, struct prefix_list *plist, +				    u_char init_flag, u_char permit_flag, +				    u_char deny_flag)  { -  struct prefix_list_entry *pentry; +	struct prefix_list_entry *pentry; -  if (! plist) -    return s; +	if (!plist) +		return s; -  for (pentry = plist->head; pentry; pentry = pentry->next) -    { -      u_char flag = init_flag; -      struct prefix *p = &pentry->prefix; +	for (pentry = plist->head; pentry; pentry = pentry->next) { +		u_char flag = init_flag; +		struct prefix *p = &pentry->prefix; -      flag |= (pentry->type == PREFIX_PERMIT ? -               permit_flag : deny_flag); -      stream_putc (s, flag); -      stream_putl (s, (u_int32_t)pentry->seq); -      stream_putc (s, (u_char)pentry->ge); -      stream_putc (s, (u_char)pentry->le); -      stream_put_prefix (s, p); -    } +		flag |= (pentry->type == PREFIX_PERMIT ? permit_flag +						       : deny_flag); +		stream_putc(s, flag); +		stream_putl(s, (u_int32_t)pentry->seq); +		stream_putc(s, (u_char)pentry->ge); +		stream_putc(s, (u_char)pentry->le); +		stream_put_prefix(s, p); +	} -  return s; +	return s;  } -int -prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp, -		    int permit, int set) +int prefix_bgp_orf_set(char *name, afi_t afi, struct orf_prefix *orfp, +		       int permit, int set)  { -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; -  /* ge and le value check */  -  if (orfp->ge && orfp->ge <= orfp->p.prefixlen) -    return CMD_WARNING; -  if (orfp->le && orfp->le <= orfp->p.prefixlen) -    return CMD_WARNING; -  if (orfp->le && orfp->ge > orfp->le) -    return CMD_WARNING; +	/* ge and le value check */ +	if (orfp->ge && orfp->ge <= orfp->p.prefixlen) +		return CMD_WARNING; +	if (orfp->le && orfp->le <= orfp->p.prefixlen) +		return CMD_WARNING; +	if (orfp->le && orfp->ge > orfp->le) +		return CMD_WARNING; -  if (orfp->ge && orfp->le == (afi == AFI_IP ? 32 : 128)) -    orfp->le = 0; +	if (orfp->ge && orfp->le == (afi == AFI_IP ? 32 : 128)) +		orfp->le = 0; -  plist = prefix_list_get (afi, 1, name); -  if (! plist) -    return CMD_WARNING; +	plist = prefix_list_get(afi, 1, name); +	if (!plist) +		return CMD_WARNING; -  if (set) -    { -      pentry = prefix_list_entry_make (&orfp->p, -				       (permit ? PREFIX_PERMIT : PREFIX_DENY), -				       orfp->seq, orfp->le, orfp->ge, 0); +	if (set) { +		pentry = prefix_list_entry_make( +			&orfp->p, (permit ? PREFIX_PERMIT : PREFIX_DENY), +			orfp->seq, orfp->le, orfp->ge, 0); -      if (prefix_entry_dup_check (plist, pentry)) -	{ -	  prefix_list_entry_free (pentry); -	  return CMD_WARNING; -	} +		if (prefix_entry_dup_check(plist, pentry)) { +			prefix_list_entry_free(pentry); +			return CMD_WARNING; +		} -      prefix_list_entry_add (plist, pentry); -    } -  else -    { -      pentry = prefix_list_entry_lookup (plist, &orfp->p, -					 (permit ? PREFIX_PERMIT : PREFIX_DENY), -					 orfp->seq, orfp->le, orfp->ge); +		prefix_list_entry_add(plist, pentry); +	} else { +		pentry = prefix_list_entry_lookup( +			plist, &orfp->p, (permit ? PREFIX_PERMIT : PREFIX_DENY), +			orfp->seq, orfp->le, orfp->ge); -      if (! pentry) -	return CMD_WARNING; +		if (!pentry) +			return CMD_WARNING; -      prefix_list_entry_delete (plist, pentry, 1); -    } +		prefix_list_entry_delete(plist, pentry, 1); +	} -  return CMD_SUCCESS; +	return CMD_SUCCESS;  } -void -prefix_bgp_orf_remove_all (afi_t afi, char *name) +void prefix_bgp_orf_remove_all(afi_t afi, char *name)  { -  struct prefix_list *plist; +	struct prefix_list *plist; -  plist = prefix_bgp_orf_lookup (afi, name); -  if (plist) -    prefix_list_delete (plist); +	plist = prefix_bgp_orf_lookup(afi, name); +	if (plist) +		prefix_list_delete(plist);  }  /* return prefix count */ -int -prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_json) -{ -  struct prefix_list *plist; -  struct prefix_list_entry *pentry; -  json_object *json = NULL; -  json_object *json_prefix = NULL; -  json_object *json_list = NULL; - -  plist = prefix_bgp_orf_lookup (afi, name); -  if (! plist) -    return 0; - -  if (! vty) -    return plist->count; - -  if(use_json) -    { -      json = json_object_new_object(); -      json_prefix = json_object_new_object(); -      json_list = json_object_new_object(); - -      json_object_int_add(json_prefix, "prefixListCounter", plist->count); -      json_object_string_add(json_prefix, "prefixListName", plist->name); - -      for (pentry = plist->head; pentry; pentry = pentry->next) -        { -          struct prefix *p = &pentry->prefix; -          char buf_a[BUFSIZ]; -          char buf_b[BUFSIZ]; - -          sprintf(buf_a, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf_b, BUFSIZ), -                            p->prefixlen); - -          json_object_int_add(json_list, "seq", pentry->seq); -          json_object_string_add(json_list, "seqPrefixListType", prefix_list_type_str (pentry)); - -          if (pentry->ge) -            json_object_int_add(json_list, "ge", pentry->ge); -          if (pentry->le) -            json_object_int_add(json_list, "le", pentry->le); - -          json_object_object_add(json_prefix, buf_a, json_list); -        } -      if (afi == AFI_IP) -        json_object_object_add(json, "ipPrefixList", json_prefix); -      else -        json_object_object_add(json, "ipv6PrefixList", json_prefix); - -      vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); -      json_object_free(json); -    } -  else -    { -      vty_out (vty, "ip%s prefix-list %s: %d entries%s", -               afi == AFI_IP ? "" : "v6", -               plist->name, plist->count, VTY_NEWLINE); - -      for (pentry = plist->head; pentry; pentry = pentry->next) -        { -          struct prefix *p = &pentry->prefix; -          char buf[BUFSIZ]; - -          vty_out (vty, "   seq %u %s %s/%d", pentry->seq, -                   prefix_list_type_str (pentry), -                   inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), -                   p->prefixlen); - -          if (pentry->ge) -            vty_out (vty, " ge %d", pentry->ge); -          if (pentry->le) -            vty_out (vty, " le %d", pentry->le); - -          vty_out (vty, "%s", VTY_NEWLINE); -        } -    } -  return plist->count; -} - -static void -prefix_list_reset_afi (afi_t afi, int orf) -{ -  struct prefix_list *plist; -  struct prefix_list *next; -  struct prefix_master *master; - -  master = prefix_master_get (afi, orf); -  if (master == NULL) -    return; - -  for (plist = master->num.head; plist; plist = next) -    { -      next = plist->next; -      prefix_list_delete (plist); -    } -  for (plist = master->str.head; plist; plist = next) -    { -      next = plist->next; -      prefix_list_delete (plist); -    } - -  assert (master->num.head == NULL); -  assert (master->num.tail == NULL); - -  assert (master->str.head == NULL); -  assert (master->str.tail == NULL); - -  master->seqnum = 1; -  master->recent = NULL; +int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, +				u_char use_json) +{ +	struct prefix_list *plist; +	struct prefix_list_entry *pentry; +	json_object *json = NULL; +	json_object *json_prefix = NULL; +	json_object *json_list = NULL; + +	plist = prefix_bgp_orf_lookup(afi, name); +	if (!plist) +		return 0; + +	if (!vty) +		return plist->count; + +	if (use_json) { +		json = json_object_new_object(); +		json_prefix = json_object_new_object(); +		json_list = json_object_new_object(); + +		json_object_int_add(json_prefix, "prefixListCounter", +				    plist->count); +		json_object_string_add(json_prefix, "prefixListName", +				       plist->name); + +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			struct prefix *p = &pentry->prefix; +			char buf_a[BUFSIZ]; +			char buf_b[BUFSIZ]; + +			sprintf(buf_a, "%s/%d", +				inet_ntop(p->family, &p->u.prefix, buf_b, +					  BUFSIZ), +				p->prefixlen); + +			json_object_int_add(json_list, "seq", pentry->seq); +			json_object_string_add(json_list, "seqPrefixListType", +					       prefix_list_type_str(pentry)); + +			if (pentry->ge) +				json_object_int_add(json_list, "ge", +						    pentry->ge); +			if (pentry->le) +				json_object_int_add(json_list, "le", +						    pentry->le); + +			json_object_object_add(json_prefix, buf_a, json_list); +		} +		if (afi == AFI_IP) +			json_object_object_add(json, "ipPrefixList", +					       json_prefix); +		else +			json_object_object_add(json, "ipv6PrefixList", +					       json_prefix); + +		vty_out(vty, "%s%s", json_object_to_json_string_ext( +					     json, JSON_C_TO_STRING_PRETTY), +			VTY_NEWLINE); +		json_object_free(json); +	} else { +		vty_out(vty, "ip%s prefix-list %s: %d entries%s", +			afi == AFI_IP ? "" : "v6", plist->name, plist->count, +			VTY_NEWLINE); + +		for (pentry = plist->head; pentry; pentry = pentry->next) { +			struct prefix *p = &pentry->prefix; +			char buf[BUFSIZ]; + +			vty_out(vty, "   seq %u %s %s/%d", pentry->seq, +				prefix_list_type_str(pentry), +				inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), +				p->prefixlen); + +			if (pentry->ge) +				vty_out(vty, " ge %d", pentry->ge); +			if (pentry->le) +				vty_out(vty, " le %d", pentry->le); + +			vty_out(vty, "%s", VTY_NEWLINE); +		} +	} +	return plist->count;  } - -/* Prefix-list node. */ -static struct cmd_node prefix_node = +static void prefix_list_reset_afi(afi_t afi, int orf)  { -  PREFIX_NODE, -  "",				/* Prefix list has no interface. */ -  1 -}; +	struct prefix_list *plist; +	struct prefix_list *next; +	struct prefix_master *master; + +	master = prefix_master_get(afi, orf); +	if (master == NULL) +		return; -static int -config_write_prefix_ipv4 (struct vty *vty) -{ -  return config_write_prefix_afi (AFI_IP, vty); -} - -static void -prefix_list_init_ipv4 (void) -{ -  install_node (&prefix_node, config_write_prefix_ipv4); - -  install_element (CONFIG_NODE, &ip_prefix_list_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_ge_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_ge_le_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_le_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_le_ge_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_seq_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_le_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_seq_le_cmd); -  install_element (CONFIG_NODE, &ip_prefix_list_seq_le_ge_cmd); - -  install_element (CONFIG_NODE, &no_ip_prefix_list_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_prefix_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_ge_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_ge_le_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_le_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_le_ge_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_seq_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_le_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_ge_cmd); - -  install_element (CONFIG_NODE, &ip_prefix_list_description_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_description_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_description_comment_cmd); - -  install_element (CONFIG_NODE, &ip_prefix_list_sequence_number_cmd); -  install_element (CONFIG_NODE, &no_ip_prefix_list_sequence_number_cmd); - -  install_element (VIEW_NODE, &show_ip_prefix_list_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_name_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_name_seq_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_prefix_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_prefix_longer_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_prefix_first_match_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_summary_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_summary_name_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_detail_cmd); -  install_element (VIEW_NODE, &show_ip_prefix_list_detail_name_cmd); - -  install_element (ENABLE_NODE, &clear_ip_prefix_list_cmd); -  install_element (ENABLE_NODE, &clear_ip_prefix_list_name_cmd); -  install_element (ENABLE_NODE, &clear_ip_prefix_list_name_prefix_cmd); +	for (plist = master->num.head; plist; plist = next) { +		next = plist->next; +		prefix_list_delete(plist); +	} +	for (plist = master->str.head; plist; plist = next) { +		next = plist->next; +		prefix_list_delete(plist); +	} + +	assert(master->num.head == NULL); +	assert(master->num.tail == NULL); + +	assert(master->str.head == NULL); +	assert(master->str.tail == NULL); + +	master->seqnum = 1; +	master->recent = NULL;  } +  /* Prefix-list node. */ -static struct cmd_node prefix_ipv6_node = -{ -  PREFIX_IPV6_NODE, -  "",				/* Prefix list has no interface. */ -  1 -}; +static struct cmd_node prefix_node = {PREFIX_NODE, +				      "", /* Prefix list has no interface. */ +				      1}; + +static int config_write_prefix_ipv4(struct vty *vty) +{ +	return config_write_prefix_afi(AFI_IP, vty); +} + +static void prefix_list_init_ipv4(void) +{ +	install_node(&prefix_node, config_write_prefix_ipv4); + +	install_element(CONFIG_NODE, &ip_prefix_list_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_ge_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_ge_le_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_le_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_le_ge_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_seq_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_seq_ge_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_seq_ge_le_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_seq_le_cmd); +	install_element(CONFIG_NODE, &ip_prefix_list_seq_le_ge_cmd); + +	install_element(CONFIG_NODE, &no_ip_prefix_list_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_prefix_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_ge_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_ge_le_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_le_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_le_ge_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_seq_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_seq_ge_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_seq_ge_le_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_seq_le_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_seq_le_ge_cmd); + +	install_element(CONFIG_NODE, &ip_prefix_list_description_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_description_cmd); +	install_element(CONFIG_NODE, +			&no_ip_prefix_list_description_comment_cmd); + +	install_element(CONFIG_NODE, &ip_prefix_list_sequence_number_cmd); +	install_element(CONFIG_NODE, &no_ip_prefix_list_sequence_number_cmd); + +	install_element(VIEW_NODE, &show_ip_prefix_list_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_name_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_name_seq_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_prefix_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_prefix_longer_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_prefix_first_match_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_summary_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_summary_name_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_detail_cmd); +	install_element(VIEW_NODE, &show_ip_prefix_list_detail_name_cmd); + +	install_element(ENABLE_NODE, &clear_ip_prefix_list_cmd); +	install_element(ENABLE_NODE, &clear_ip_prefix_list_name_cmd); +	install_element(ENABLE_NODE, &clear_ip_prefix_list_name_prefix_cmd); +} -static int -config_write_prefix_ipv6 (struct vty *vty) -{ -  return config_write_prefix_afi (AFI_IP6, vty); -} - -static void -prefix_list_init_ipv6 (void) -{ -  install_node (&prefix_ipv6_node, config_write_prefix_ipv6); - -  install_element (CONFIG_NODE, &ipv6_prefix_list_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_ge_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_ge_le_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_le_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_le_ge_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_seq_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_le_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_cmd); -  install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_ge_cmd); - -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_prefix_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_le_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_ge_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_le_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_ge_cmd); - -  install_element (CONFIG_NODE, &ipv6_prefix_list_description_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_comment_cmd); - -  install_element (CONFIG_NODE, &ipv6_prefix_list_sequence_number_cmd); -  install_element (CONFIG_NODE, &no_ipv6_prefix_list_sequence_number_cmd); - -  install_element (VIEW_NODE, &show_ipv6_prefix_list_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_name_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_name_seq_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_longer_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_name_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_cmd); -  install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_name_cmd); - -  install_element (ENABLE_NODE, &clear_ipv6_prefix_list_cmd); -  install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_cmd); -  install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_prefix_cmd); -} - -void -prefix_list_init () -{ -  prefix_list_init_ipv4 (); -  prefix_list_init_ipv6 (); -} - -void -prefix_list_reset () -{ -  prefix_list_reset_afi (AFI_IP,  0); -  prefix_list_reset_afi (AFI_IP6, 0); -  prefix_list_reset_afi (AFI_IP,  1); -  prefix_list_reset_afi (AFI_IP6, 1); +/* Prefix-list node. */ +static struct cmd_node prefix_ipv6_node = { +	PREFIX_IPV6_NODE, "", /* Prefix list has no interface. */ +	1}; + +static int config_write_prefix_ipv6(struct vty *vty) +{ +	return config_write_prefix_afi(AFI_IP6, vty); +} + +static void prefix_list_init_ipv6(void) +{ +	install_node(&prefix_ipv6_node, config_write_prefix_ipv6); + +	install_element(CONFIG_NODE, &ipv6_prefix_list_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_ge_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_ge_le_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_le_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_le_ge_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_seq_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_seq_ge_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_seq_ge_le_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_seq_le_cmd); +	install_element(CONFIG_NODE, &ipv6_prefix_list_seq_le_ge_cmd); + +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_prefix_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_ge_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_ge_le_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_le_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_le_ge_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_seq_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_le_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_seq_le_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_seq_le_ge_cmd); + +	install_element(CONFIG_NODE, &ipv6_prefix_list_description_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_description_cmd); +	install_element(CONFIG_NODE, +			&no_ipv6_prefix_list_description_comment_cmd); + +	install_element(CONFIG_NODE, &ipv6_prefix_list_sequence_number_cmd); +	install_element(CONFIG_NODE, &no_ipv6_prefix_list_sequence_number_cmd); + +	install_element(VIEW_NODE, &show_ipv6_prefix_list_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_name_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_name_seq_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_prefix_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_prefix_longer_cmd); +	install_element(VIEW_NODE, +			&show_ipv6_prefix_list_prefix_first_match_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_summary_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_summary_name_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_detail_cmd); +	install_element(VIEW_NODE, &show_ipv6_prefix_list_detail_name_cmd); + +	install_element(ENABLE_NODE, &clear_ipv6_prefix_list_cmd); +	install_element(ENABLE_NODE, &clear_ipv6_prefix_list_name_cmd); +	install_element(ENABLE_NODE, &clear_ipv6_prefix_list_name_prefix_cmd); +} + +void prefix_list_init() +{ +	prefix_list_init_ipv4(); +	prefix_list_init_ipv6(); +} + +void prefix_list_reset() +{ +	prefix_list_reset_afi(AFI_IP, 0); +	prefix_list_reset_afi(AFI_IP6, 0); +	prefix_list_reset_afi(AFI_IP, 1); +	prefix_list_reset_afi(AFI_IP6, 1);  }  | 
