PLC_MAXLEVELV4,
};
-#ifdef HAVE_IPV6
/* Static structure of IPv6 prefix-list's master. */
static struct prefix_master prefix_master_ipv6 =
{
NULL,
PLC_MAXLEVELV6,
};
-#endif /* HAVE_IPV6*/
/* Static structure of BGP ORF prefix_list's master. */
static struct prefix_master prefix_master_orf_v4 =
prefix_list_add_hook (void (*func) (struct prefix_list *plist))
{
prefix_master_ipv4.add_hook = func;
-#ifdef HAVE_IPV6
prefix_master_ipv6.add_hook = func;
-#endif /* HAVE_IPV6 */
}
/* Delete hook function. */
prefix_list_delete_hook (void (*func) (struct prefix_list *plist))
{
prefix_master_ipv4.delete_hook = func;
-#ifdef HAVE_IPV6
prefix_master_ipv6.delete_hook = func;
-#endif /* HAVE_IPVt6 */
}
/* Calculate new sequential number. */
struct prefix_list *plist;
struct prefix_list_entry *pentry;
struct prefix_list_entry *dup;
- struct prefix p;
+ struct prefix p, p_tmp;
int any = 0;
int seqnum = -1;
int lenum = 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)
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_ETHER:
default:
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 (dup)
{
prefix_list_entry_free (pentry);
- vty_out (vty, "%% Insertion failed - prefix-list entry exists:%s",
- VTY_NEWLINE);
- vty_out (vty, " seq %u %s %s", dup->seq, typestr, prefix);
- if (! any && genum)
- vty_out (vty, " ge %d", genum);
- if (! any && lenum)
- vty_out (vty, " le %d", lenum);
- vty_out (vty, "%s", VTY_NEWLINE);
return CMD_SUCCESS;
}
return CMD_WARNING;
}
}
-#ifdef HAVE_IPV6
else if (afi == AFI_IP6)
{
if (strncmp ("any", prefix, strlen (prefix)) == 0)
return CMD_WARNING;
}
}
-#endif /* HAVE_IPV6 */
/* Lookup prefix entry. */
pentry = prefix_list_entry_lookup(plist, &p, type, seqnum, lenum, genum);
"Up to 80 characters describing this prefix-list\n")
{
int idx_word = 2;
+ int idx_line = 4;
struct prefix_list *plist;
plist = prefix_list_get (AFI_IP, 0, argv[idx_word]->arg);
XFREE (MTYPE_TMP, plist->desc);
plist->desc = NULL;
}
- plist->desc = argv_concat(argv, argc, 1);
+ plist->desc = argv_concat(argv, argc, idx_line);
return CMD_SUCCESS;
}
return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg);
}
-#ifdef HAVE_IPV6
DEFUN (ipv6_prefix_list,
ipv6_prefix_list_cmd,
"ipv6 prefix-list WORD <deny|permit> <X:X::X:X/M|any>",
"Up to 80 characters describing this prefix-list\n")
{
int idx_word = 2;
+ int iddx_line = 4;
struct prefix_list *plist;
plist = prefix_list_get (AFI_IP6, 0, argv[idx_word]->arg);
XFREE (MTYPE_TMP, plist->desc);
plist->desc = NULL;
}
- plist->desc = argv_concat(argv, argc, 1);
+ plist->desc = argv_concat(argv, argc, iddx_line);
return CMD_SUCCESS;
}
"Prefix-list specific description\n"
"Up to 80 characters describing this prefix-list\n")
{
- return no_ipv6_prefix_list_description_comment (self, vty, argc, argv);
+ return no_ipv6_prefix_list_description (self, vty, argc, argv);
}
int idx_ipv6_prefixlen = 4;
return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg);
}
-#endif /* HAVE_IPV6 */
/* Configuration write function. */
static int
else
json_object_object_add(json, "ipv6PrefixList", json_prefix);
- vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
+ vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
json_object_free(json);
}
else
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, &show_ip_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_name_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_name_seq_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_prefix_first_match_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_summary_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_summary_name_cmd);
- install_element (ENABLE_NODE, &show_ip_prefix_list_detail_cmd);
- install_element (ENABLE_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);
}
-#ifdef HAVE_IPV6
/* Prefix-list node. */
static struct cmd_node prefix_ipv6_node =
{
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, &show_ipv6_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_name_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_name_seq_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_summary_name_cmd);
- install_element (ENABLE_NODE, &show_ipv6_prefix_list_detail_cmd);
- install_element (ENABLE_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);
}
-#endif /* HAVE_IPV6 */
void
prefix_list_init ()
{
prefix_list_init_ipv4 ();
-#ifdef HAVE_IPV6
prefix_list_init_ipv6 ();
-#endif /* HAVE_IPV6 */
}
void