struct prefix_list_list str;
/* Whether sequential number is used. */
- int seqnum;
+ bool seqnum;
/* The latest update. */
struct prefix_list *recent;
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)
+ int64_t seq, int le, int ge, int any)
{
struct prefix_list_entry *pentry;
}
/* Calculate new sequential number. */
-static int prefix_new_seq_get(struct prefix_list *plist)
+static int64_t prefix_new_seq_get(struct prefix_list *plist)
{
- int maxseq;
- int newseq;
+ int64_t maxseq;
+ int64_t newseq;
struct prefix_list_entry *pentry;
maxseq = newseq = 0;
newseq = ((maxseq / 5) * 5) + 5;
- return newseq;
+ return (newseq > UINT_MAX) ? UINT_MAX : newseq;
}
/* Return prefix list entry which has same seq number. */
static struct prefix_list_entry *prefix_seq_check(struct prefix_list *plist,
- int seq)
+ int64_t seq)
{
struct prefix_list_entry *pentry;
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)
+ enum prefix_list_type type, int64_t seq,
+ int le, int ge)
{
struct prefix_list_entry *pentry;
struct prefix_list_entry *pentry)
{
size_t depth, maxdepth = plist->master->trie_depth;
- uint8_t *bytes = &pentry->prefix.u.prefix;
+ uint8_t *bytes = pentry->prefix.u.val;
size_t validbits = pentry->prefix.prefixlen;
struct pltrie_table *table, **tables[PLC_MAXLEVEL];
struct prefix_list_entry *pentry)
{
size_t depth = plist->master->trie_depth;
- uint8_t *bytes = &pentry->prefix.u.prefix;
+ uint8_t *bytes = pentry->prefix.u.val;
size_t validbits = pentry->prefix.prefixlen;
struct pltrie_table *table;
}
static int prefix_list_entry_match(struct prefix_list_entry *pentry,
- struct prefix *p)
+ const struct prefix *p)
{
int ret;
return 1;
}
-enum prefix_list_type prefix_list_apply_which_prefix(struct prefix_list *plist,
- struct prefix **which,
- void *object)
+enum prefix_list_type prefix_list_apply_which_prefix(
+ struct prefix_list *plist,
+ const struct prefix **which,
+ const void *object)
{
struct prefix_list_entry *pentry, *pbest = NULL;
- struct prefix *p = (struct prefix *)object;
- uint8_t *byte = &p->u.prefix;
+ const struct prefix *p = (const struct prefix *)object;
+ const uint8_t *byte = p->u.val;
size_t depth;
size_t validbits = p->prefixlen;
struct pltrie_table *table;
p = &pentry->prefix;
- printf(" seq %u %s %s/%d", pentry->seq,
+ printf(" seq %" PRId64 " %s %s/%d", pentry->seq,
prefix_list_type_str(pentry),
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop(p->family, p->u.val, buf, BUFSIZ),
p->prefixlen);
if (pentry->ge)
printf(" ge %d", pentry->ge);
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;
+ uint8_t byte, *bytes = new->prefix.u.val;
size_t validbits = new->prefix.prefixlen;
struct pltrie_table *table;
struct prefix_list_entry *pentry;
- int seq = 0;
+ int64_t seq = 0;
if (new->seq == -1)
seq = prefix_new_seq_get(plist);
struct prefix_list_entry *dup;
struct prefix p, p_tmp;
int any = 0;
- int seqnum = -1;
+ int64_t seqnum = -1;
int lenum = 0;
int genum = 0;
+ if (name == NULL || prefix == NULL || typestr == NULL) {
+ vty_out(vty, "%% Missing prefix or type\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
/* Sequential number. */
if (seq)
- seqnum = atoi(seq);
+ seqnum = (int64_t)atol(seq);
/* ge and le number */
if (ge)
char buf_tmp[PREFIX2STR_BUFFER];
prefix2str(&p, buf, sizeof(buf));
prefix2str(&p_tmp, buf_tmp, sizeof(buf_tmp));
- zlog_warn(
+ vty_out(vty,
+ "%% Prefix-list %s prefix changed from %s to %s to match length\n",
+ name, buf, buf_tmp);
+ zlog_info(
"Prefix-list %s prefix changed from %s to %s to match length",
name, buf, buf_tmp);
p = p_tmp;
struct prefix_list *plist;
struct prefix_list_entry *pentry;
struct prefix p;
- int seqnum = -1;
+ int64_t seqnum = -1;
int lenum = 0;
int genum = 0;
/* Check sequence number. */
if (seq)
- seqnum = atoi(seq);
+ seqnum = (int64_t)atol(seq);
/* ge and le number */
if (ge)
vty_out(vty, " Description: %s\n", plist->desc);
vty_out(vty,
- " count: %d, range entries: %d, sequences: %u - %u\n",
+ " count: %d, range entries: %d, sequences: %" PRId64 " - %" PRId64 "\n",
plist->count, plist->rangecount,
plist->head ? plist->head->seq : 0,
plist->tail ? plist->tail->seq : 0);
vty_out(vty, " ");
if (master->seqnum)
- vty_out(vty, "seq %u ", pentry->seq);
+ vty_out(vty, "seq %" PRId64 " ", pentry->seq);
vty_out(vty, "%s ", prefix_list_type_str(pentry));
char buf[BUFSIZ];
vty_out(vty, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
+ inet_ntop(p->family, p->u.val, buf,
BUFSIZ),
p->prefixlen);
{
struct prefix_list *plist;
struct prefix_master *master;
- int seqnum = 0;
+ int64_t seqnum = 0;
master = prefix_master_get(afi, 0);
if (master == NULL)
return CMD_WARNING;
if (seq)
- seqnum = atoi(seq);
+ seqnum = (int64_t)atol(seq);
if (name) {
plist = prefix_list_lookup(afi, name);
}
if (match) {
- vty_out(vty, " seq %u %s ", pentry->seq,
+ vty_out(vty, " seq %" PRId64 " %s ", pentry->seq,
prefix_list_type_str(pentry));
if (pentry->any)
vty_out(vty, "any");
else {
- struct prefix *p = &pentry->prefix;
+ struct prefix *pf = &pentry->prefix;
char buf[BUFSIZ];
vty_out(vty, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
+ inet_ntop(pf->family, pf->u.val, buf,
BUFSIZ),
- p->prefixlen);
+ pf->prefixlen);
if (pentry->ge)
vty_out(vty, " ge %d", pentry->ge);
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
- prefix_master_ipv4.seqnum = no ? 0 : 1;
+ prefix_master_ipv4.seqnum = no ? false : true;
return CMD_SUCCESS;
}
PREFIX_LIST_STR
"Include/exclude sequence numbers in NVGEN\n")
{
- prefix_master_ipv6.seqnum = no ? 0 : 1;
+ prefix_master_ipv6.seqnum = no ? false : true;
return CMD_SUCCESS;
}
afi == AFI_IP ? "" : "v6", plist->name);
if (master->seqnum)
- vty_out(vty, "seq %u ", pentry->seq);
+ vty_out(vty, "seq %" PRId64 " ", pentry->seq);
vty_out(vty, "%s ", prefix_list_type_str(pentry));
char buf[BUFSIZ];
vty_out(vty, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
+ inet_ntop(p->family, p->u.val, buf,
BUFSIZ),
p->prefixlen);
afi == AFI_IP ? "" : "v6", plist->name);
if (master->seqnum)
- vty_out(vty, "seq %u ", pentry->seq);
+ vty_out(vty, "seq %" PRId64 " ", pentry->seq);
vty_out(vty, "%s", prefix_list_type_str(pentry));
char buf[BUFSIZ];
vty_out(vty, " %s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
+ inet_ntop(p->family, p->u.val, buf,
BUFSIZ),
p->prefixlen);
/* return prefix count */
int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name,
- uint8_t use_json)
+ bool use_json)
{
struct prefix_list *plist;
struct prefix_list_entry *pentry;
char buf_b[BUFSIZ];
sprintf(buf_a, "%s/%d",
- inet_ntop(p->family, &p->u.prefix, buf_b,
+ inet_ntop(p->family, p->u.val, buf_b,
BUFSIZ),
p->prefixlen);
struct prefix *p = &pentry->prefix;
char buf[BUFSIZ];
- vty_out(vty, " seq %u %s %s/%d", pentry->seq,
+ vty_out(vty, " seq %" PRId64 " %s %s/%d",
+ pentry->seq,
prefix_list_type_str(pentry),
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
+ inet_ntop(p->family, p->u.val, buf, BUFSIZ),
p->prefixlen);
if (pentry->ge)