1 /* Prefix list functions.
2 * Copyright (C) 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your
9 * option) any later version.
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
28 #include "sockunion.h"
33 /* Each prefix-list's entry. */
34 struct prefix_list_entry
41 enum prefix_list_type type
;
49 struct prefix_list_entry
*next
;
50 struct prefix_list_entry
*prev
;
53 /* List of struct prefix_list. */
54 struct prefix_list_list
56 struct prefix_list
*head
;
57 struct prefix_list
*tail
;
60 /* Master structure of prefix_list. */
63 /* List of prefix_list which name is number. */
64 struct prefix_list_list num
;
66 /* List of prefix_list which name is string. */
67 struct prefix_list_list str
;
69 /* Whether sequential number is used. */
72 /* The latest update. */
73 struct prefix_list
*recent
;
75 /* Hook function which is executed when new prefix_list is added. */
76 void (*add_hook
) (struct prefix_list
*);
78 /* Hook function which is executed when prefix_list is deleted. */
79 void (*delete_hook
) (struct prefix_list
*);
82 /* Static structure of IPv4 prefix_list's master. */
83 static struct prefix_master prefix_master_ipv4
=
93 /* Static structure of IPv6 prefix-list's master. */
94 static struct prefix_master prefix_master_ipv6
=
102 #endif /* HAVE_IPV6*/
104 /* Static structure of BGP ORF prefix_list's master. */
105 static struct prefix_master prefix_master_orf
=
114 static struct prefix_master
*
115 prefix_master_get (afi_t afi
)
118 return &prefix_master_ipv4
;
120 else if (afi
== AFI_IP6
)
121 return &prefix_master_ipv6
;
122 #endif /* HAVE_IPV6 */
123 else if (afi
== AFI_ORF_PREFIX
)
124 return &prefix_master_orf
;
128 /* Lookup prefix_list from list of prefix_list by name. */
130 prefix_list_lookup (afi_t afi
, const char *name
)
132 struct prefix_list
*plist
;
133 struct prefix_master
*master
;
138 master
= prefix_master_get (afi
);
142 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
143 if (strcmp (plist
->name
, name
) == 0)
146 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
147 if (strcmp (plist
->name
, name
) == 0)
153 static struct prefix_list
*
154 prefix_list_new (void)
156 struct prefix_list
*new;
158 new = XCALLOC (MTYPE_PREFIX_LIST
, sizeof (struct prefix_list
));
163 prefix_list_free (struct prefix_list
*plist
)
165 XFREE (MTYPE_PREFIX_LIST
, plist
);
168 static struct prefix_list_entry
*
169 prefix_list_entry_new (void)
171 struct prefix_list_entry
*new;
173 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY
, sizeof (struct prefix_list_entry
));
178 prefix_list_entry_free (struct prefix_list_entry
*pentry
)
180 XFREE (MTYPE_PREFIX_LIST_ENTRY
, pentry
);
183 /* Insert new prefix list to list of prefix_list. Each prefix_list
184 is sorted by the name. */
185 static struct prefix_list
*
186 prefix_list_insert (afi_t afi
, const char *name
)
190 struct prefix_list
*plist
;
191 struct prefix_list
*point
;
192 struct prefix_list_list
*list
;
193 struct prefix_master
*master
;
195 master
= prefix_master_get (afi
);
199 /* Allocate new prefix_list and copy given name. */
200 plist
= prefix_list_new ();
201 plist
->name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, name
);
202 plist
->master
= master
;
204 /* If name is made by all digit character. We treat it as
206 for (number
= 0, i
= 0; i
< strlen (name
); i
++)
208 if (isdigit ((int) name
[i
]))
209 number
= (number
* 10) + (name
[i
] - '0');
214 /* In case of name is all digit character */
215 if (i
== strlen (name
))
217 plist
->type
= PREFIX_TYPE_NUMBER
;
219 /* Set prefix_list to number list. */
222 for (point
= list
->head
; point
; point
= point
->next
)
223 if (atol (point
->name
) >= number
)
228 plist
->type
= PREFIX_TYPE_STRING
;
230 /* Set prefix_list to string list. */
233 /* Set point to insertion point. */
234 for (point
= list
->head
; point
; point
= point
->next
)
235 if (strcmp (point
->name
, name
) >= 0)
239 /* In case of this is the first element of master. */
240 if (list
->head
== NULL
)
242 list
->head
= list
->tail
= plist
;
246 /* In case of insertion is made at the tail of access_list. */
249 plist
->prev
= list
->tail
;
250 list
->tail
->next
= plist
;
255 /* In case of insertion is made at the head of access_list. */
256 if (point
== list
->head
)
258 plist
->next
= list
->head
;
259 list
->head
->prev
= plist
;
264 /* Insertion is made at middle of the access_list. */
266 plist
->prev
= point
->prev
;
269 point
->prev
->next
= plist
;
275 static struct prefix_list
*
276 prefix_list_get (afi_t afi
, const char *name
)
278 struct prefix_list
*plist
;
280 plist
= prefix_list_lookup (afi
, name
);
283 plist
= prefix_list_insert (afi
, name
);
287 /* Delete prefix-list from prefix_list_master and free it. */
289 prefix_list_delete (struct prefix_list
*plist
)
291 struct prefix_list_list
*list
;
292 struct prefix_master
*master
;
293 struct prefix_list_entry
*pentry
;
294 struct prefix_list_entry
*next
;
296 /* If prefix-list contain prefix_list_entry free all of it. */
297 for (pentry
= plist
->head
; pentry
; pentry
= next
)
300 prefix_list_entry_free (pentry
);
304 master
= plist
->master
;
306 if (plist
->type
== PREFIX_TYPE_NUMBER
)
312 plist
->next
->prev
= plist
->prev
;
314 list
->tail
= plist
->prev
;
317 plist
->prev
->next
= plist
->next
;
319 list
->head
= plist
->next
;
322 XFREE (MTYPE_TMP
, plist
->desc
);
324 /* Make sure master's recent changed prefix-list information is
326 master
->recent
= NULL
;
329 XFREE (MTYPE_PREFIX_LIST_STR
, plist
->name
);
331 prefix_list_free (plist
);
333 if (master
->delete_hook
)
334 (*master
->delete_hook
) (NULL
);
337 static struct prefix_list_entry
*
338 prefix_list_entry_make (struct prefix
*prefix
, enum prefix_list_type type
,
339 int seq
, int le
, int ge
, int any
)
341 struct prefix_list_entry
*pentry
;
343 pentry
= prefix_list_entry_new ();
348 prefix_copy (&pentry
->prefix
, prefix
);
357 /* Add hook function. */
359 prefix_list_add_hook (void (*func
) (struct prefix_list
*plist
))
361 prefix_master_ipv4
.add_hook
= func
;
363 prefix_master_ipv6
.add_hook
= func
;
364 #endif /* HAVE_IPV6 */
367 /* Delete hook function. */
369 prefix_list_delete_hook (void (*func
) (struct prefix_list
*plist
))
371 prefix_master_ipv4
.delete_hook
= func
;
373 prefix_master_ipv6
.delete_hook
= func
;
374 #endif /* HAVE_IPVt6 */
377 /* Calculate new sequential number. */
379 prefix_new_seq_get (struct prefix_list
*plist
)
383 struct prefix_list_entry
*pentry
;
387 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
389 if (maxseq
< pentry
->seq
)
390 maxseq
= pentry
->seq
;
393 newseq
= ((maxseq
/ 5) * 5) + 5;
398 /* Return prefix list entry which has same seq number. */
399 static struct prefix_list_entry
*
400 prefix_seq_check (struct prefix_list
*plist
, int seq
)
402 struct prefix_list_entry
*pentry
;
404 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
405 if (pentry
->seq
== seq
)
410 static struct prefix_list_entry
*
411 prefix_list_entry_lookup (struct prefix_list
*plist
, struct prefix
*prefix
,
412 enum prefix_list_type type
, int seq
, int le
, int ge
)
414 struct prefix_list_entry
*pentry
;
416 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
417 if (prefix_same (&pentry
->prefix
, prefix
) && pentry
->type
== type
)
419 if (seq
>= 0 && pentry
->seq
!= seq
)
422 if (pentry
->le
!= le
)
424 if (pentry
->ge
!= ge
)
434 prefix_list_entry_delete (struct prefix_list
*plist
,
435 struct prefix_list_entry
*pentry
,
438 if (plist
== NULL
|| pentry
== NULL
)
441 pentry
->prev
->next
= pentry
->next
;
443 plist
->head
= pentry
->next
;
445 pentry
->next
->prev
= pentry
->prev
;
447 plist
->tail
= pentry
->prev
;
449 prefix_list_entry_free (pentry
);
455 if (plist
->master
->delete_hook
)
456 (*plist
->master
->delete_hook
) (plist
);
458 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
459 prefix_list_delete (plist
);
461 plist
->master
->recent
= plist
;
466 prefix_list_entry_add (struct prefix_list
*plist
,
467 struct prefix_list_entry
*pentry
)
469 struct prefix_list_entry
*replace
;
470 struct prefix_list_entry
*point
;
472 /* Automatic asignment of seq no. */
473 if (pentry
->seq
== -1)
474 pentry
->seq
= prefix_new_seq_get (plist
);
476 /* Is there any same seq prefix list entry? */
477 replace
= prefix_seq_check (plist
, pentry
->seq
);
479 prefix_list_entry_delete (plist
, replace
, 0);
481 /* Check insert point. */
482 for (point
= plist
->head
; point
; point
= point
->next
)
483 if (point
->seq
>= pentry
->seq
)
486 /* In case of this is the first element of the list. */
487 pentry
->next
= point
;
492 point
->prev
->next
= pentry
;
494 plist
->head
= pentry
;
496 pentry
->prev
= point
->prev
;
497 point
->prev
= pentry
;
502 plist
->tail
->next
= pentry
;
504 plist
->head
= pentry
;
506 pentry
->prev
= plist
->tail
;
507 plist
->tail
= pentry
;
510 /* Increment count. */
513 /* Run hook function. */
514 if (plist
->master
->add_hook
)
515 (*plist
->master
->add_hook
) (plist
);
517 plist
->master
->recent
= plist
;
520 /* Return string of prefix_list_type. */
522 prefix_list_type_str (struct prefix_list_entry
*pentry
)
524 switch (pentry
->type
)
536 prefix_list_entry_match (struct prefix_list_entry
*pentry
, struct prefix
*p
)
540 ret
= prefix_match (&pentry
->prefix
, p
);
544 /* In case of le nor ge is specified, exact match is performed. */
545 if (! pentry
->le
&& ! pentry
->ge
)
547 if (pentry
->prefix
.prefixlen
!= p
->prefixlen
)
553 if (p
->prefixlen
> pentry
->le
)
557 if (p
->prefixlen
< pentry
->ge
)
563 enum prefix_list_type
564 prefix_list_apply (struct prefix_list
*plist
, void *object
)
566 struct prefix_list_entry
*pentry
;
569 p
= (struct prefix
*) object
;
574 if (plist
->count
== 0)
575 return PREFIX_PERMIT
;
577 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
580 if (prefix_list_entry_match (pentry
, p
))
590 static void __attribute__ ((unused
))
591 prefix_list_print (struct prefix_list
*plist
)
593 struct prefix_list_entry
*pentry
;
598 printf ("ip prefix-list %s: %d entries\n", plist
->name
, plist
->count
);
600 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
603 printf ("any %s\n", prefix_list_type_str (pentry
));
611 printf (" seq %d %s %s/%d",
613 prefix_list_type_str (pentry
),
614 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
617 printf (" ge %d", pentry
->ge
);
619 printf (" le %d", pentry
->le
);
625 /* Retrun 1 when plist already include pentry policy. */
626 static struct prefix_list_entry
*
627 prefix_entry_dup_check (struct prefix_list
*plist
,
628 struct prefix_list_entry
*new)
630 struct prefix_list_entry
*pentry
;
634 seq
= prefix_new_seq_get (plist
);
638 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
640 if (prefix_same (&pentry
->prefix
, &new->prefix
)
641 && pentry
->type
== new->type
642 && pentry
->le
== new->le
643 && pentry
->ge
== new->ge
644 && pentry
->seq
!= seq
)
651 vty_invalid_prefix_range (struct vty
*vty
, const char *prefix
)
653 vty_out (vty
, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
654 prefix
, VTY_NEWLINE
);
659 vty_prefix_list_install (struct vty
*vty
, afi_t afi
, const char *name
,
660 const char *seq
, const char *typestr
,
661 const char *prefix
, const char *ge
, const char *le
)
664 enum prefix_list_type type
;
665 struct prefix_list
*plist
;
666 struct prefix_list_entry
*pentry
;
667 struct prefix_list_entry
*dup
;
674 /* Sequential number. */
678 /* ge and le number */
684 /* Check filter type. */
685 if (strncmp ("permit", typestr
, 1) == 0)
686 type
= PREFIX_PERMIT
;
687 else if (strncmp ("deny", typestr
, 1) == 0)
691 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
695 /* "any" is special token for matching any IPv4 addresses. */
698 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
700 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
702 lenum
= IPV4_MAX_BITLEN
;
706 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
710 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
715 else if (afi
== AFI_IP6
)
717 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
719 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
721 lenum
= IPV6_MAX_BITLEN
;
725 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
729 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
733 #endif /* HAVE_IPV6 */
735 /* ge and le check. */
736 if (genum
&& genum
<= p
.prefixlen
)
737 return vty_invalid_prefix_range (vty
, prefix
);
739 if (lenum
&& lenum
<= p
.prefixlen
)
740 return vty_invalid_prefix_range (vty
, prefix
);
742 if (lenum
&& genum
> lenum
)
743 return vty_invalid_prefix_range (vty
, prefix
);
745 if (genum
&& lenum
== (afi
== AFI_IP
? 32 : 128))
748 /* Get prefix_list with name. */
749 plist
= prefix_list_get (afi
, name
);
751 /* Make prefix entry. */
752 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
754 /* Check same policy. */
755 dup
= prefix_entry_dup_check (plist
, pentry
);
759 prefix_list_entry_free (pentry
);
760 vty_out (vty
, "%% Insertion failed - prefix-list entry exists:%s",
762 vty_out (vty
, " seq %d %s %s", dup
->seq
, typestr
, prefix
);
764 vty_out (vty
, " ge %d", genum
);
766 vty_out (vty
, " le %d", lenum
);
767 vty_out (vty
, "%s", VTY_NEWLINE
);
771 /* Install new filter to the access_list. */
772 prefix_list_entry_add (plist
, pentry
);
778 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
779 const char *seq
, const char *typestr
,
780 const char *prefix
, const char *ge
, const char *le
)
783 enum prefix_list_type type
;
784 struct prefix_list
*plist
;
785 struct prefix_list_entry
*pentry
;
791 /* Check prefix list name. */
792 plist
= prefix_list_lookup (afi
, name
);
795 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
799 /* Only prefix-list name specified, delete the entire prefix-list. */
800 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
801 ge
== NULL
&& le
== NULL
)
803 prefix_list_delete (plist
);
807 /* We must have, at a minimum, both the type and prefix here */
808 if ((typestr
== NULL
) || (prefix
== NULL
))
810 vty_out (vty
, "%% Both prefix and type required%s", VTY_NEWLINE
);
814 /* Check sequence number. */
818 /* ge and le number */
824 /* Check of filter type. */
825 if (strncmp ("permit", typestr
, 1) == 0)
826 type
= PREFIX_PERMIT
;
827 else if (strncmp ("deny", typestr
, 1) == 0)
831 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
835 /* "any" is special token for matching any IPv4 addresses. */
838 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
840 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
842 lenum
= IPV4_MAX_BITLEN
;
845 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
849 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
854 else if (afi
== AFI_IP6
)
856 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
858 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
860 lenum
= IPV6_MAX_BITLEN
;
863 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
867 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
871 #endif /* HAVE_IPV6 */
873 /* Lookup prefix entry. */
874 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
878 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
882 /* Install new filter to the access_list. */
883 prefix_list_entry_delete (plist
, pentry
, 1);
889 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
891 struct prefix_list
*plist
;
893 plist
= prefix_list_lookup (afi
, name
);
896 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
902 XFREE (MTYPE_TMP
, plist
->desc
);
906 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
907 prefix_list_delete (plist
);
923 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
924 struct prefix_master
*master
, enum display_type dtype
,
927 struct prefix_list_entry
*pentry
;
929 /* Print the name of the protocol */
931 vty_out (vty
, "%s: ", zlog_proto_names
[zlog_default
->protocol
]);
933 if (dtype
== normal_display
)
935 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
936 afi
== AFI_IP
? "" : "v6",
937 plist
->name
, plist
->count
, VTY_NEWLINE
);
939 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
941 else if (dtype
== summary_display
|| dtype
== detail_display
)
943 vty_out (vty
, "ip%s prefix-list %s:%s",
944 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
947 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
949 vty_out (vty
, " count: %d, range entries: %d, sequences: %d - %d%s",
950 plist
->count
, plist
->rangecount
,
951 plist
->head
? plist
->head
->seq
: 0,
952 plist
->tail
? plist
->tail
->seq
: 0,
956 if (dtype
!= summary_display
)
958 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
960 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
966 vty_out (vty
, "seq %d ", pentry
->seq
);
968 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
971 vty_out (vty
, "any");
974 struct prefix
*p
= &pentry
->prefix
;
977 vty_out (vty
, "%s/%d",
978 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
982 vty_out (vty
, " ge %d", pentry
->ge
);
984 vty_out (vty
, " le %d", pentry
->le
);
987 if (dtype
== detail_display
|| dtype
== sequential_display
)
988 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
989 pentry
->hitcnt
, pentry
->refcnt
);
991 vty_out (vty
, "%s", VTY_NEWLINE
);
997 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
998 const char *seq
, enum display_type dtype
)
1000 struct prefix_list
*plist
;
1001 struct prefix_master
*master
;
1004 master
= prefix_master_get (afi
);
1009 seqnum
= atoi (seq
);
1013 plist
= prefix_list_lookup (afi
, name
);
1016 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1019 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1023 if (dtype
== detail_display
|| dtype
== summary_display
)
1026 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1027 master
->recent
->name
, VTY_NEWLINE
);
1030 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1031 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1033 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1034 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1041 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1042 const char *prefix
, enum display_type type
)
1044 struct prefix_list
*plist
;
1045 struct prefix_list_entry
*pentry
;
1050 plist
= prefix_list_lookup (afi
, name
);
1053 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1057 ret
= str2prefix (prefix
, &p
);
1060 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1064 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1068 if (type
== normal_display
|| type
== first_match_display
)
1069 if (prefix_same (&p
, &pentry
->prefix
))
1072 if (type
== longer_display
)
1073 if (prefix_match (&p
, &pentry
->prefix
))
1078 vty_out (vty
, " seq %d %s ",
1080 prefix_list_type_str (pentry
));
1083 vty_out (vty
, "any");
1086 struct prefix
*p
= &pentry
->prefix
;
1089 vty_out (vty
, "%s/%d",
1090 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1094 vty_out (vty
, " ge %d", pentry
->ge
);
1096 vty_out (vty
, " le %d", pentry
->le
);
1099 if (type
== normal_display
|| type
== first_match_display
)
1100 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1101 pentry
->hitcnt
, pentry
->refcnt
);
1103 vty_out (vty
, "%s", VTY_NEWLINE
);
1105 if (type
== first_match_display
)
1113 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1116 struct prefix_master
*master
;
1117 struct prefix_list
*plist
;
1118 struct prefix_list_entry
*pentry
;
1122 master
= prefix_master_get (afi
);
1126 if (name
== NULL
&& prefix
== NULL
)
1128 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1129 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1132 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1133 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1138 plist
= prefix_list_lookup (afi
, name
);
1141 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1147 ret
= str2prefix (prefix
, &p
);
1150 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1155 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1159 if (prefix_match (&pentry
->prefix
, &p
))
1169 DEFUN (ip_prefix_list
,
1171 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1174 "Name of a prefix list\n"
1175 "Specify packets to reject\n"
1176 "Specify packets to forward\n"
1177 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1178 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1180 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1181 argv
[1], argv
[2], NULL
, NULL
);
1184 DEFUN (ip_prefix_list_ge
,
1185 ip_prefix_list_ge_cmd
,
1186 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1189 "Name of a prefix list\n"
1190 "Specify packets to reject\n"
1191 "Specify packets to forward\n"
1192 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1193 "Minimum prefix length to be matched\n"
1194 "Minimum prefix length\n")
1196 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1197 argv
[2], argv
[3], NULL
);
1200 DEFUN (ip_prefix_list_ge_le
,
1201 ip_prefix_list_ge_le_cmd
,
1202 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1205 "Name of a prefix list\n"
1206 "Specify packets to reject\n"
1207 "Specify packets to forward\n"
1208 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1209 "Minimum prefix length to be matched\n"
1210 "Minimum prefix length\n"
1211 "Maximum prefix length to be matched\n"
1212 "Maximum prefix length\n")
1214 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1215 argv
[2], argv
[3], argv
[4]);
1218 DEFUN (ip_prefix_list_le
,
1219 ip_prefix_list_le_cmd
,
1220 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1223 "Name of a prefix list\n"
1224 "Specify packets to reject\n"
1225 "Specify packets to forward\n"
1226 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1227 "Maximum prefix length to be matched\n"
1228 "Maximum prefix length\n")
1230 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1231 argv
[2], NULL
, argv
[3]);
1234 DEFUN (ip_prefix_list_le_ge
,
1235 ip_prefix_list_le_ge_cmd
,
1236 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1239 "Name of a prefix list\n"
1240 "Specify packets to reject\n"
1241 "Specify packets to forward\n"
1242 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1243 "Maximum prefix length to be matched\n"
1244 "Maximum prefix length\n"
1245 "Minimum prefix length to be matched\n"
1246 "Minimum prefix length\n")
1248 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1249 argv
[2], argv
[4], argv
[3]);
1252 DEFUN (ip_prefix_list_seq
,
1253 ip_prefix_list_seq_cmd
,
1254 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1257 "Name of a prefix list\n"
1258 "sequence number of an entry\n"
1260 "Specify packets to reject\n"
1261 "Specify packets to forward\n"
1262 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1263 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1265 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1266 argv
[3], NULL
, NULL
);
1269 DEFUN (ip_prefix_list_seq_ge
,
1270 ip_prefix_list_seq_ge_cmd
,
1271 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1274 "Name of a prefix list\n"
1275 "sequence number of an entry\n"
1277 "Specify packets to reject\n"
1278 "Specify packets to forward\n"
1279 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1280 "Minimum prefix length to be matched\n"
1281 "Minimum prefix length\n")
1283 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1284 argv
[3], argv
[4], NULL
);
1287 DEFUN (ip_prefix_list_seq_ge_le
,
1288 ip_prefix_list_seq_ge_le_cmd
,
1289 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1292 "Name of a prefix list\n"
1293 "sequence number of an entry\n"
1295 "Specify packets to reject\n"
1296 "Specify packets to forward\n"
1297 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1298 "Minimum prefix length to be matched\n"
1299 "Minimum prefix length\n"
1300 "Maximum prefix length to be matched\n"
1301 "Maximum prefix length\n")
1303 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1304 argv
[3], argv
[4], argv
[5]);
1307 DEFUN (ip_prefix_list_seq_le
,
1308 ip_prefix_list_seq_le_cmd
,
1309 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1312 "Name of a prefix list\n"
1313 "sequence number of an entry\n"
1315 "Specify packets to reject\n"
1316 "Specify packets to forward\n"
1317 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1318 "Maximum prefix length to be matched\n"
1319 "Maximum prefix length\n")
1321 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1322 argv
[3], NULL
, argv
[4]);
1325 DEFUN (ip_prefix_list_seq_le_ge
,
1326 ip_prefix_list_seq_le_ge_cmd
,
1327 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1330 "Name of a prefix list\n"
1331 "sequence number of an entry\n"
1333 "Specify packets to reject\n"
1334 "Specify packets to forward\n"
1335 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1336 "Maximum prefix length to be matched\n"
1337 "Maximum prefix length\n"
1338 "Minimum prefix length to be matched\n"
1339 "Minimum prefix length\n")
1341 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1342 argv
[3], argv
[5], argv
[4]);
1345 DEFUN (no_ip_prefix_list
,
1346 no_ip_prefix_list_cmd
,
1347 "no ip prefix-list WORD",
1351 "Name of a prefix list\n")
1353 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1357 DEFUN (no_ip_prefix_list_prefix
,
1358 no_ip_prefix_list_prefix_cmd
,
1359 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1363 "Name of a prefix list\n"
1364 "Specify packets to reject\n"
1365 "Specify packets to forward\n"
1366 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1367 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1369 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1370 argv
[2], NULL
, NULL
);
1373 DEFUN (no_ip_prefix_list_ge
,
1374 no_ip_prefix_list_ge_cmd
,
1375 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1379 "Name of a prefix list\n"
1380 "Specify packets to reject\n"
1381 "Specify packets to forward\n"
1382 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1383 "Minimum prefix length to be matched\n"
1384 "Minimum prefix length\n")
1386 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1387 argv
[2], argv
[3], NULL
);
1390 DEFUN (no_ip_prefix_list_ge_le
,
1391 no_ip_prefix_list_ge_le_cmd
,
1392 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1396 "Name of a prefix list\n"
1397 "Specify packets to reject\n"
1398 "Specify packets to forward\n"
1399 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1400 "Minimum prefix length to be matched\n"
1401 "Minimum prefix length\n"
1402 "Maximum prefix length to be matched\n"
1403 "Maximum prefix length\n")
1405 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1406 argv
[2], argv
[3], argv
[4]);
1409 DEFUN (no_ip_prefix_list_le
,
1410 no_ip_prefix_list_le_cmd
,
1411 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1415 "Name of a prefix list\n"
1416 "Specify packets to reject\n"
1417 "Specify packets to forward\n"
1418 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1419 "Maximum prefix length to be matched\n"
1420 "Maximum prefix length\n")
1422 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1423 argv
[2], NULL
, argv
[3]);
1426 DEFUN (no_ip_prefix_list_le_ge
,
1427 no_ip_prefix_list_le_ge_cmd
,
1428 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1432 "Name of a prefix list\n"
1433 "Specify packets to reject\n"
1434 "Specify packets to forward\n"
1435 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1436 "Maximum prefix length to be matched\n"
1437 "Maximum prefix length\n"
1438 "Minimum prefix length to be matched\n"
1439 "Minimum prefix length\n")
1441 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1442 argv
[2], argv
[4], argv
[3]);
1445 DEFUN (no_ip_prefix_list_seq
,
1446 no_ip_prefix_list_seq_cmd
,
1447 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1451 "Name of a prefix list\n"
1452 "sequence number of an entry\n"
1454 "Specify packets to reject\n"
1455 "Specify packets to forward\n"
1456 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1457 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1459 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1460 argv
[3], NULL
, NULL
);
1463 DEFUN (no_ip_prefix_list_seq_ge
,
1464 no_ip_prefix_list_seq_ge_cmd
,
1465 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1469 "Name of a prefix list\n"
1470 "sequence number of an entry\n"
1472 "Specify packets to reject\n"
1473 "Specify packets to forward\n"
1474 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1475 "Minimum prefix length to be matched\n"
1476 "Minimum prefix length\n")
1478 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1479 argv
[3], argv
[4], NULL
);
1482 DEFUN (no_ip_prefix_list_seq_ge_le
,
1483 no_ip_prefix_list_seq_ge_le_cmd
,
1484 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1488 "Name of a prefix list\n"
1489 "sequence number of an entry\n"
1491 "Specify packets to reject\n"
1492 "Specify packets to forward\n"
1493 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1494 "Minimum prefix length to be matched\n"
1495 "Minimum prefix length\n"
1496 "Maximum prefix length to be matched\n"
1497 "Maximum prefix length\n")
1499 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1500 argv
[3], argv
[4], argv
[5]);
1503 DEFUN (no_ip_prefix_list_seq_le
,
1504 no_ip_prefix_list_seq_le_cmd
,
1505 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1509 "Name of a prefix list\n"
1510 "sequence number of an entry\n"
1512 "Specify packets to reject\n"
1513 "Specify packets to forward\n"
1514 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1515 "Maximum prefix length to be matched\n"
1516 "Maximum prefix length\n")
1518 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1519 argv
[3], NULL
, argv
[4]);
1522 DEFUN (no_ip_prefix_list_seq_le_ge
,
1523 no_ip_prefix_list_seq_le_ge_cmd
,
1524 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1528 "Name of a prefix list\n"
1529 "sequence number of an entry\n"
1531 "Specify packets to reject\n"
1532 "Specify packets to forward\n"
1533 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1534 "Maximum prefix length to be matched\n"
1535 "Maximum prefix length\n"
1536 "Minimum prefix length to be matched\n"
1537 "Minimum prefix length\n")
1539 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1540 argv
[3], argv
[5], argv
[4]);
1543 DEFUN (ip_prefix_list_sequence_number
,
1544 ip_prefix_list_sequence_number_cmd
,
1545 "ip prefix-list sequence-number",
1548 "Include/exclude sequence numbers in NVGEN\n")
1550 prefix_master_ipv4
.seqnum
= 1;
1554 DEFUN (no_ip_prefix_list_sequence_number
,
1555 no_ip_prefix_list_sequence_number_cmd
,
1556 "no ip prefix-list sequence-number",
1560 "Include/exclude sequence numbers in NVGEN\n")
1562 prefix_master_ipv4
.seqnum
= 0;
1566 DEFUN (ip_prefix_list_description
,
1567 ip_prefix_list_description_cmd
,
1568 "ip prefix-list WORD description .LINE",
1571 "Name of a prefix list\n"
1572 "Prefix-list specific description\n"
1573 "Up to 80 characters describing this prefix-list\n")
1575 struct prefix_list
*plist
;
1577 plist
= prefix_list_get (AFI_IP
, argv
[0]);
1581 XFREE (MTYPE_TMP
, plist
->desc
);
1584 plist
->desc
= argv_concat(argv
, argc
, 1);
1589 DEFUN (no_ip_prefix_list_description
,
1590 no_ip_prefix_list_description_cmd
,
1591 "no ip prefix-list WORD description",
1595 "Name of a prefix list\n"
1596 "Prefix-list specific description\n")
1598 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1601 ALIAS (no_ip_prefix_list_description
,
1602 no_ip_prefix_list_description_arg_cmd
,
1603 "no ip prefix-list WORD description .LINE",
1607 "Name of a prefix list\n"
1608 "Prefix-list specific description\n"
1609 "Up to 80 characters describing this prefix-list\n")
1611 DEFUN (show_ip_prefix_list
,
1612 show_ip_prefix_list_cmd
,
1613 "show ip prefix-list",
1618 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1621 DEFUN (show_ip_prefix_list_name
,
1622 show_ip_prefix_list_name_cmd
,
1623 "show ip prefix-list WORD",
1627 "Name of a prefix list\n")
1629 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1632 DEFUN (show_ip_prefix_list_name_seq
,
1633 show_ip_prefix_list_name_seq_cmd
,
1634 "show ip prefix-list WORD seq <1-4294967295>",
1638 "Name of a prefix list\n"
1639 "sequence number of an entry\n"
1640 "Sequence number\n")
1642 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1645 DEFUN (show_ip_prefix_list_prefix
,
1646 show_ip_prefix_list_prefix_cmd
,
1647 "show ip prefix-list WORD A.B.C.D/M",
1651 "Name of a prefix list\n"
1652 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1654 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1657 DEFUN (show_ip_prefix_list_prefix_longer
,
1658 show_ip_prefix_list_prefix_longer_cmd
,
1659 "show ip prefix-list WORD A.B.C.D/M longer",
1663 "Name of a prefix list\n"
1664 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1665 "Lookup longer prefix\n")
1667 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1670 DEFUN (show_ip_prefix_list_prefix_first_match
,
1671 show_ip_prefix_list_prefix_first_match_cmd
,
1672 "show ip prefix-list WORD A.B.C.D/M first-match",
1676 "Name of a prefix list\n"
1677 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1678 "First matched prefix\n")
1680 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1683 DEFUN (show_ip_prefix_list_summary
,
1684 show_ip_prefix_list_summary_cmd
,
1685 "show ip prefix-list summary",
1689 "Summary of prefix lists\n")
1691 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1694 DEFUN (show_ip_prefix_list_summary_name
,
1695 show_ip_prefix_list_summary_name_cmd
,
1696 "show ip prefix-list summary WORD",
1700 "Summary of prefix lists\n"
1701 "Name of a prefix list\n")
1703 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1707 DEFUN (show_ip_prefix_list_detail
,
1708 show_ip_prefix_list_detail_cmd
,
1709 "show ip prefix-list detail",
1713 "Detail of prefix lists\n")
1715 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1718 DEFUN (show_ip_prefix_list_detail_name
,
1719 show_ip_prefix_list_detail_name_cmd
,
1720 "show ip prefix-list detail WORD",
1724 "Detail of prefix lists\n"
1725 "Name of a prefix list\n")
1727 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1730 DEFUN (clear_ip_prefix_list
,
1731 clear_ip_prefix_list_cmd
,
1732 "clear ip prefix-list",
1737 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1740 DEFUN (clear_ip_prefix_list_name
,
1741 clear_ip_prefix_list_name_cmd
,
1742 "clear ip prefix-list WORD",
1746 "Name of a prefix list\n")
1748 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1751 DEFUN (clear_ip_prefix_list_name_prefix
,
1752 clear_ip_prefix_list_name_prefix_cmd
,
1753 "clear ip prefix-list WORD A.B.C.D/M",
1757 "Name of a prefix list\n"
1758 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1760 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1764 DEFUN (ipv6_prefix_list
,
1765 ipv6_prefix_list_cmd
,
1766 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1769 "Name of a prefix list\n"
1770 "Specify packets to reject\n"
1771 "Specify packets to forward\n"
1772 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1773 "Any prefix match. Same as \"::0/0 le 128\"\n")
1775 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
1776 argv
[1], argv
[2], NULL
, NULL
);
1779 DEFUN (ipv6_prefix_list_ge
,
1780 ipv6_prefix_list_ge_cmd
,
1781 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1784 "Name of a prefix list\n"
1785 "Specify packets to reject\n"
1786 "Specify packets to forward\n"
1787 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1788 "Minimum prefix length to be matched\n"
1789 "Minimum prefix length\n")
1791 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1792 argv
[2], argv
[3], NULL
);
1795 DEFUN (ipv6_prefix_list_ge_le
,
1796 ipv6_prefix_list_ge_le_cmd
,
1797 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1800 "Name of a prefix list\n"
1801 "Specify packets to reject\n"
1802 "Specify packets to forward\n"
1803 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1804 "Minimum prefix length to be matched\n"
1805 "Minimum prefix length\n"
1806 "Maximum prefix length to be matched\n"
1807 "Maximum prefix length\n")
1810 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1811 argv
[2], argv
[3], argv
[4]);
1814 DEFUN (ipv6_prefix_list_le
,
1815 ipv6_prefix_list_le_cmd
,
1816 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1819 "Name of a prefix list\n"
1820 "Specify packets to reject\n"
1821 "Specify packets to forward\n"
1822 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1823 "Maximum prefix length to be matched\n"
1824 "Maximum prefix length\n")
1826 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1827 argv
[2], NULL
, argv
[3]);
1830 DEFUN (ipv6_prefix_list_le_ge
,
1831 ipv6_prefix_list_le_ge_cmd
,
1832 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1835 "Name of a prefix list\n"
1836 "Specify packets to reject\n"
1837 "Specify packets to forward\n"
1838 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1839 "Maximum prefix length to be matched\n"
1840 "Maximum prefix length\n"
1841 "Minimum prefix length to be matched\n"
1842 "Minimum prefix length\n")
1844 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1845 argv
[2], argv
[4], argv
[3]);
1848 DEFUN (ipv6_prefix_list_seq
,
1849 ipv6_prefix_list_seq_cmd
,
1850 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
1853 "Name of a prefix list\n"
1854 "sequence number of an entry\n"
1856 "Specify packets to reject\n"
1857 "Specify packets to forward\n"
1858 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1859 "Any prefix match. Same as \"::0/0 le 128\"\n")
1861 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1862 argv
[3], NULL
, NULL
);
1865 DEFUN (ipv6_prefix_list_seq_ge
,
1866 ipv6_prefix_list_seq_ge_cmd
,
1867 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
1870 "Name of a prefix list\n"
1871 "sequence number of an entry\n"
1873 "Specify packets to reject\n"
1874 "Specify packets to forward\n"
1875 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1876 "Minimum prefix length to be matched\n"
1877 "Minimum prefix length\n")
1879 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1880 argv
[3], argv
[4], NULL
);
1883 DEFUN (ipv6_prefix_list_seq_ge_le
,
1884 ipv6_prefix_list_seq_ge_le_cmd
,
1885 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1888 "Name of a prefix list\n"
1889 "sequence number of an entry\n"
1891 "Specify packets to reject\n"
1892 "Specify packets to forward\n"
1893 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1894 "Minimum prefix length to be matched\n"
1895 "Minimum prefix length\n"
1896 "Maximum prefix length to be matched\n"
1897 "Maximum prefix length\n")
1899 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1900 argv
[3], argv
[4], argv
[5]);
1903 DEFUN (ipv6_prefix_list_seq_le
,
1904 ipv6_prefix_list_seq_le_cmd
,
1905 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
1908 "Name of a prefix list\n"
1909 "sequence number of an entry\n"
1911 "Specify packets to reject\n"
1912 "Specify packets to forward\n"
1913 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1914 "Maximum prefix length to be matched\n"
1915 "Maximum prefix length\n")
1917 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1918 argv
[3], NULL
, argv
[4]);
1921 DEFUN (ipv6_prefix_list_seq_le_ge
,
1922 ipv6_prefix_list_seq_le_ge_cmd
,
1923 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1926 "Name of a prefix list\n"
1927 "sequence number of an entry\n"
1929 "Specify packets to reject\n"
1930 "Specify packets to forward\n"
1931 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1932 "Maximum prefix length to be matched\n"
1933 "Maximum prefix length\n"
1934 "Minimum prefix length to be matched\n"
1935 "Minimum prefix length\n")
1937 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1938 argv
[3], argv
[5], argv
[4]);
1941 DEFUN (no_ipv6_prefix_list
,
1942 no_ipv6_prefix_list_cmd
,
1943 "no ipv6 prefix-list WORD",
1947 "Name of a prefix list\n")
1949 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
1953 DEFUN (no_ipv6_prefix_list_prefix
,
1954 no_ipv6_prefix_list_prefix_cmd
,
1955 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1959 "Name of a prefix list\n"
1960 "Specify packets to reject\n"
1961 "Specify packets to forward\n"
1962 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1963 "Any prefix match. Same as \"::0/0 le 128\"\n")
1965 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1966 argv
[2], NULL
, NULL
);
1969 DEFUN (no_ipv6_prefix_list_ge
,
1970 no_ipv6_prefix_list_ge_cmd
,
1971 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1975 "Name of a prefix list\n"
1976 "Specify packets to reject\n"
1977 "Specify packets to forward\n"
1978 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1979 "Minimum prefix length to be matched\n"
1980 "Minimum prefix length\n")
1982 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1983 argv
[2], argv
[3], NULL
);
1986 DEFUN (no_ipv6_prefix_list_ge_le
,
1987 no_ipv6_prefix_list_ge_le_cmd
,
1988 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1992 "Name of a prefix list\n"
1993 "Specify packets to reject\n"
1994 "Specify packets to forward\n"
1995 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1996 "Minimum prefix length to be matched\n"
1997 "Minimum prefix length\n"
1998 "Maximum prefix length to be matched\n"
1999 "Maximum prefix length\n")
2001 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2002 argv
[2], argv
[3], argv
[4]);
2005 DEFUN (no_ipv6_prefix_list_le
,
2006 no_ipv6_prefix_list_le_cmd
,
2007 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2011 "Name of a prefix list\n"
2012 "Specify packets to reject\n"
2013 "Specify packets to forward\n"
2014 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2015 "Maximum prefix length to be matched\n"
2016 "Maximum prefix length\n")
2018 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2019 argv
[2], NULL
, argv
[3]);
2022 DEFUN (no_ipv6_prefix_list_le_ge
,
2023 no_ipv6_prefix_list_le_ge_cmd
,
2024 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2028 "Name of a prefix list\n"
2029 "Specify packets to reject\n"
2030 "Specify packets to forward\n"
2031 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2032 "Maximum prefix length to be matched\n"
2033 "Maximum prefix length\n"
2034 "Minimum prefix length to be matched\n"
2035 "Minimum prefix length\n")
2037 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2038 argv
[2], argv
[4], argv
[3]);
2041 DEFUN (no_ipv6_prefix_list_seq
,
2042 no_ipv6_prefix_list_seq_cmd
,
2043 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2047 "Name of a prefix list\n"
2048 "sequence number of an entry\n"
2050 "Specify packets to reject\n"
2051 "Specify packets to forward\n"
2052 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2053 "Any prefix match. Same as \"::0/0 le 128\"\n")
2055 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2056 argv
[3], NULL
, NULL
);
2059 DEFUN (no_ipv6_prefix_list_seq_ge
,
2060 no_ipv6_prefix_list_seq_ge_cmd
,
2061 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2065 "Name of a prefix list\n"
2066 "sequence number of an entry\n"
2068 "Specify packets to reject\n"
2069 "Specify packets to forward\n"
2070 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2071 "Minimum prefix length to be matched\n"
2072 "Minimum prefix length\n")
2074 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2075 argv
[3], argv
[4], NULL
);
2078 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2079 no_ipv6_prefix_list_seq_ge_le_cmd
,
2080 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2084 "Name of a prefix list\n"
2085 "sequence number of an entry\n"
2087 "Specify packets to reject\n"
2088 "Specify packets to forward\n"
2089 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2090 "Minimum prefix length to be matched\n"
2091 "Minimum prefix length\n"
2092 "Maximum prefix length to be matched\n"
2093 "Maximum prefix length\n")
2095 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2096 argv
[3], argv
[4], argv
[5]);
2099 DEFUN (no_ipv6_prefix_list_seq_le
,
2100 no_ipv6_prefix_list_seq_le_cmd
,
2101 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2105 "Name of a prefix list\n"
2106 "sequence number of an entry\n"
2108 "Specify packets to reject\n"
2109 "Specify packets to forward\n"
2110 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2111 "Maximum prefix length to be matched\n"
2112 "Maximum prefix length\n")
2114 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2115 argv
[3], NULL
, argv
[4]);
2118 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2119 no_ipv6_prefix_list_seq_le_ge_cmd
,
2120 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2124 "Name of a prefix list\n"
2125 "sequence number of an entry\n"
2127 "Specify packets to reject\n"
2128 "Specify packets to forward\n"
2129 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2130 "Maximum prefix length to be matched\n"
2131 "Maximum prefix length\n"
2132 "Minimum prefix length to be matched\n"
2133 "Minimum prefix length\n")
2135 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2136 argv
[3], argv
[5], argv
[4]);
2139 DEFUN (ipv6_prefix_list_sequence_number
,
2140 ipv6_prefix_list_sequence_number_cmd
,
2141 "ipv6 prefix-list sequence-number",
2144 "Include/exclude sequence numbers in NVGEN\n")
2146 prefix_master_ipv6
.seqnum
= 1;
2150 DEFUN (no_ipv6_prefix_list_sequence_number
,
2151 no_ipv6_prefix_list_sequence_number_cmd
,
2152 "no ipv6 prefix-list sequence-number",
2156 "Include/exclude sequence numbers in NVGEN\n")
2158 prefix_master_ipv6
.seqnum
= 0;
2162 DEFUN (ipv6_prefix_list_description
,
2163 ipv6_prefix_list_description_cmd
,
2164 "ipv6 prefix-list WORD description .LINE",
2167 "Name of a prefix list\n"
2168 "Prefix-list specific description\n"
2169 "Up to 80 characters describing this prefix-list\n")
2171 struct prefix_list
*plist
;
2173 plist
= prefix_list_get (AFI_IP6
, argv
[0]);
2177 XFREE (MTYPE_TMP
, plist
->desc
);
2180 plist
->desc
= argv_concat(argv
, argc
, 1);
2185 DEFUN (no_ipv6_prefix_list_description
,
2186 no_ipv6_prefix_list_description_cmd
,
2187 "no ipv6 prefix-list WORD description",
2191 "Name of a prefix list\n"
2192 "Prefix-list specific description\n")
2194 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2197 ALIAS (no_ipv6_prefix_list_description
,
2198 no_ipv6_prefix_list_description_arg_cmd
,
2199 "no ipv6 prefix-list WORD description .LINE",
2203 "Name of a prefix list\n"
2204 "Prefix-list specific description\n"
2205 "Up to 80 characters describing this prefix-list\n")
2207 DEFUN (show_ipv6_prefix_list
,
2208 show_ipv6_prefix_list_cmd
,
2209 "show ipv6 prefix-list",
2214 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2217 DEFUN (show_ipv6_prefix_list_name
,
2218 show_ipv6_prefix_list_name_cmd
,
2219 "show ipv6 prefix-list WORD",
2223 "Name of a prefix list\n")
2225 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2228 DEFUN (show_ipv6_prefix_list_name_seq
,
2229 show_ipv6_prefix_list_name_seq_cmd
,
2230 "show ipv6 prefix-list WORD seq <1-4294967295>",
2234 "Name of a prefix list\n"
2235 "sequence number of an entry\n"
2236 "Sequence number\n")
2238 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2241 DEFUN (show_ipv6_prefix_list_prefix
,
2242 show_ipv6_prefix_list_prefix_cmd
,
2243 "show ipv6 prefix-list WORD X:X::X:X/M",
2247 "Name of a prefix list\n"
2248 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2250 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2253 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2254 show_ipv6_prefix_list_prefix_longer_cmd
,
2255 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2259 "Name of a prefix list\n"
2260 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2261 "Lookup longer prefix\n")
2263 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2266 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2267 show_ipv6_prefix_list_prefix_first_match_cmd
,
2268 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2272 "Name of a prefix list\n"
2273 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2274 "First matched prefix\n")
2276 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2279 DEFUN (show_ipv6_prefix_list_summary
,
2280 show_ipv6_prefix_list_summary_cmd
,
2281 "show ipv6 prefix-list summary",
2285 "Summary of prefix lists\n")
2287 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2290 DEFUN (show_ipv6_prefix_list_summary_name
,
2291 show_ipv6_prefix_list_summary_name_cmd
,
2292 "show ipv6 prefix-list summary WORD",
2296 "Summary of prefix lists\n"
2297 "Name of a prefix list\n")
2299 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2302 DEFUN (show_ipv6_prefix_list_detail
,
2303 show_ipv6_prefix_list_detail_cmd
,
2304 "show ipv6 prefix-list detail",
2308 "Detail of prefix lists\n")
2310 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2313 DEFUN (show_ipv6_prefix_list_detail_name
,
2314 show_ipv6_prefix_list_detail_name_cmd
,
2315 "show ipv6 prefix-list detail WORD",
2319 "Detail of prefix lists\n"
2320 "Name of a prefix list\n")
2322 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2325 DEFUN (clear_ipv6_prefix_list
,
2326 clear_ipv6_prefix_list_cmd
,
2327 "clear ipv6 prefix-list",
2332 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2335 DEFUN (clear_ipv6_prefix_list_name
,
2336 clear_ipv6_prefix_list_name_cmd
,
2337 "clear ipv6 prefix-list WORD",
2341 "Name of a prefix list\n")
2343 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2346 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2347 clear_ipv6_prefix_list_name_prefix_cmd
,
2348 "clear ipv6 prefix-list WORD X:X::X:X/M",
2352 "Name of a prefix list\n"
2353 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2355 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2357 #endif /* HAVE_IPV6 */
2359 /* Configuration write function. */
2361 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2363 struct prefix_list
*plist
;
2364 struct prefix_list_entry
*pentry
;
2365 struct prefix_master
*master
;
2368 master
= prefix_master_get (afi
);
2372 if (! master
->seqnum
)
2374 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2375 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2376 vty_out (vty
, "!%s", VTY_NEWLINE
);
2379 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2383 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2384 afi
== AFI_IP
? "" : "v6",
2385 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2389 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2391 vty_out (vty
, "ip%s prefix-list %s ",
2392 afi
== AFI_IP
? "" : "v6",
2396 vty_out (vty
, "seq %d ", pentry
->seq
);
2398 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2401 vty_out (vty
, "any");
2404 struct prefix
*p
= &pentry
->prefix
;
2407 vty_out (vty
, "%s/%d",
2408 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2412 vty_out (vty
, " ge %d", pentry
->ge
);
2414 vty_out (vty
, " le %d", pentry
->le
);
2416 vty_out (vty
, "%s", VTY_NEWLINE
);
2419 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2422 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2426 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2427 afi
== AFI_IP
? "" : "v6",
2428 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2432 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2434 vty_out (vty
, "ip%s prefix-list %s ",
2435 afi
== AFI_IP
? "" : "v6",
2439 vty_out (vty
, "seq %d ", pentry
->seq
);
2441 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2444 vty_out (vty
, " any");
2447 struct prefix
*p
= &pentry
->prefix
;
2450 vty_out (vty
, " %s/%d",
2451 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2455 vty_out (vty
, " ge %d", pentry
->ge
);
2457 vty_out (vty
, " le %d", pentry
->le
);
2459 vty_out (vty
, "%s", VTY_NEWLINE
);
2468 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2469 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2471 struct prefix_list_entry
*pentry
;
2476 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2478 u_char flag
= init_flag
;
2479 struct prefix
*p
= &pentry
->prefix
;
2481 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2482 permit_flag
: deny_flag
);
2483 stream_putc (s
, flag
);
2484 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2485 stream_putc (s
, (u_char
)pentry
->ge
);
2486 stream_putc (s
, (u_char
)pentry
->le
);
2487 stream_put_prefix (s
, p
);
2494 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2495 int permit
, int set
)
2497 struct prefix_list
*plist
;
2498 struct prefix_list_entry
*pentry
;
2500 /* ge and le value check */
2501 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2503 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2505 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2508 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2511 plist
= prefix_list_get (AFI_ORF_PREFIX
, name
);
2517 pentry
= prefix_list_entry_make (&orfp
->p
,
2518 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2519 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2521 if (prefix_entry_dup_check (plist
, pentry
))
2523 prefix_list_entry_free (pentry
);
2527 prefix_list_entry_add (plist
, pentry
);
2531 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2532 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2533 orfp
->seq
, orfp
->le
, orfp
->ge
);
2538 prefix_list_entry_delete (plist
, pentry
, 1);
2545 prefix_bgp_orf_remove_all (char *name
)
2547 struct prefix_list
*plist
;
2549 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2551 prefix_list_delete (plist
);
2554 /* return prefix count */
2556 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
)
2558 struct prefix_list
*plist
;
2559 struct prefix_list_entry
*pentry
;
2561 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2566 return plist
->count
;
2568 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2569 afi
== AFI_IP
? "" : "v6",
2570 plist
->name
, plist
->count
, VTY_NEWLINE
);
2572 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2574 struct prefix
*p
= &pentry
->prefix
;
2577 vty_out (vty
, " seq %d %s %s/%d", pentry
->seq
,
2578 prefix_list_type_str (pentry
),
2579 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2583 vty_out (vty
, " ge %d", pentry
->ge
);
2585 vty_out (vty
, " le %d", pentry
->le
);
2587 vty_out (vty
, "%s", VTY_NEWLINE
);
2589 return plist
->count
;
2593 prefix_list_reset_orf (void)
2595 struct prefix_list
*plist
;
2596 struct prefix_list
*next
;
2597 struct prefix_master
*master
;
2599 master
= prefix_master_get (AFI_ORF_PREFIX
);
2603 for (plist
= master
->num
.head
; plist
; plist
= next
)
2606 prefix_list_delete (plist
);
2608 for (plist
= master
->str
.head
; plist
; plist
= next
)
2611 prefix_list_delete (plist
);
2614 assert (master
->num
.head
== NULL
);
2615 assert (master
->num
.tail
== NULL
);
2617 assert (master
->str
.head
== NULL
);
2618 assert (master
->str
.tail
== NULL
);
2621 master
->recent
= NULL
;
2625 /* Prefix-list node. */
2626 struct cmd_node prefix_node
=
2629 "", /* Prefix list has no interface. */
2634 config_write_prefix_ipv4 (struct vty
*vty
)
2636 return config_write_prefix_afi (AFI_IP
, vty
);
2640 prefix_list_reset_ipv4 (void)
2642 struct prefix_list
*plist
;
2643 struct prefix_list
*next
;
2644 struct prefix_master
*master
;
2646 master
= prefix_master_get (AFI_IP
);
2650 for (plist
= master
->num
.head
; plist
; plist
= next
)
2653 prefix_list_delete (plist
);
2655 for (plist
= master
->str
.head
; plist
; plist
= next
)
2658 prefix_list_delete (plist
);
2661 assert (master
->num
.head
== NULL
);
2662 assert (master
->num
.tail
== NULL
);
2664 assert (master
->str
.head
== NULL
);
2665 assert (master
->str
.tail
== NULL
);
2668 master
->recent
= NULL
;
2672 prefix_list_init_ipv4 (void)
2674 install_node (&prefix_node
, config_write_prefix_ipv4
);
2676 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2677 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2678 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2679 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2680 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2681 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2682 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2683 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2684 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2685 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2687 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2688 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2689 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2690 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2691 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2692 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2693 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2694 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2695 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2696 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2697 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2699 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2700 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2701 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2703 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2704 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2706 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2707 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2708 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2709 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2710 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2711 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2712 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2713 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2714 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2715 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2717 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2718 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2719 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2720 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2721 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2722 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2723 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2724 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2725 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2726 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2728 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2729 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2730 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2734 /* Prefix-list node. */
2735 struct cmd_node prefix_ipv6_node
=
2738 "", /* Prefix list has no interface. */
2743 config_write_prefix_ipv6 (struct vty
*vty
)
2745 return config_write_prefix_afi (AFI_IP6
, vty
);
2749 prefix_list_reset_ipv6 (void)
2751 struct prefix_list
*plist
;
2752 struct prefix_list
*next
;
2753 struct prefix_master
*master
;
2755 master
= prefix_master_get (AFI_IP6
);
2759 for (plist
= master
->num
.head
; plist
; plist
= next
)
2762 prefix_list_delete (plist
);
2764 for (plist
= master
->str
.head
; plist
; plist
= next
)
2767 prefix_list_delete (plist
);
2770 assert (master
->num
.head
== NULL
);
2771 assert (master
->num
.tail
== NULL
);
2773 assert (master
->str
.head
== NULL
);
2774 assert (master
->str
.tail
== NULL
);
2777 master
->recent
= NULL
;
2781 prefix_list_init_ipv6 (void)
2783 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2785 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2786 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2787 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2788 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2789 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2790 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2791 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2792 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2793 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
2794 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
2796 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
2797 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
2798 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
2799 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
2800 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
2801 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
2802 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
2803 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
2804 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
2805 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
2806 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
2808 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
2809 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
2810 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
2812 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
2813 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
2815 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
2816 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
2817 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2818 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2819 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2820 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2821 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2822 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2823 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2824 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2826 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
2827 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
2828 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2829 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2830 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2831 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2832 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2833 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2834 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2835 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2837 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
2838 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
2839 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
2841 #endif /* HAVE_IPV6 */
2846 prefix_list_init_ipv4 ();
2848 prefix_list_init_ipv6 ();
2849 #endif /* HAVE_IPV6 */
2853 prefix_list_reset ()
2855 prefix_list_reset_ipv4 ();
2857 prefix_list_reset_ipv6 ();
2858 #endif /* HAVE_IPV6 */
2859 prefix_list_reset_orf ();