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"
32 /* Each prefix-list's entry. */
33 struct prefix_list_entry
40 enum prefix_list_type type
;
48 struct prefix_list_entry
*next
;
49 struct prefix_list_entry
*prev
;
52 /* List of struct prefix_list. */
53 struct prefix_list_list
55 struct prefix_list
*head
;
56 struct prefix_list
*tail
;
59 /* Master structure of prefix_list. */
62 /* List of prefix_list which name is number. */
63 struct prefix_list_list num
;
65 /* List of prefix_list which name is string. */
66 struct prefix_list_list str
;
68 /* Whether sequential number is used. */
71 /* The latest update. */
72 struct prefix_list
*recent
;
74 /* Hook function which is executed when new prefix_list is added. */
77 /* Hook function which is executed when prefix_list is deleted. */
78 void (*delete_hook
) ();
81 /* Static structure of IPv4 prefix_list's master. */
82 static struct prefix_master prefix_master_ipv4
=
92 /* Static structure of IPv6 prefix-list's master. */
93 static struct prefix_master prefix_master_ipv6
=
101 #endif /* HAVE_IPV6*/
103 /* Static structure of BGP ORF prefix_list's master. */
104 static struct prefix_master prefix_master_orf
=
113 static struct prefix_master
*
114 prefix_master_get (afi_t afi
)
117 return &prefix_master_ipv4
;
119 else if (afi
== AFI_IP6
)
120 return &prefix_master_ipv6
;
121 #endif /* HAVE_IPV6 */
122 else if (afi
== AFI_ORF_PREFIX
)
123 return &prefix_master_orf
;
127 /* Lookup prefix_list from list of prefix_list by name. */
129 prefix_list_lookup (afi_t afi
, const char *name
)
131 struct prefix_list
*plist
;
132 struct prefix_master
*master
;
137 master
= prefix_master_get (afi
);
141 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
142 if (strcmp (plist
->name
, name
) == 0)
145 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
146 if (strcmp (plist
->name
, name
) == 0)
152 static struct prefix_list
*
155 struct prefix_list
*new;
157 new = XCALLOC (MTYPE_PREFIX_LIST
, sizeof (struct prefix_list
));
162 prefix_list_free (struct prefix_list
*plist
)
164 XFREE (MTYPE_PREFIX_LIST
, plist
);
167 static struct prefix_list_entry
*
168 prefix_list_entry_new ()
170 struct prefix_list_entry
*new;
172 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY
, sizeof (struct prefix_list_entry
));
177 prefix_list_entry_free (struct prefix_list_entry
*pentry
)
179 XFREE (MTYPE_PREFIX_LIST_ENTRY
, pentry
);
182 /* Insert new prefix list to list of prefix_list. Each prefix_list
183 is sorted by the name. */
184 static struct prefix_list
*
185 prefix_list_insert (afi_t afi
, const char *name
)
189 struct prefix_list
*plist
;
190 struct prefix_list
*point
;
191 struct prefix_list_list
*list
;
192 struct prefix_master
*master
;
194 master
= prefix_master_get (afi
);
198 /* Allocate new prefix_list and copy given name. */
199 plist
= prefix_list_new ();
200 plist
->name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, name
);
201 plist
->master
= master
;
203 /* If name is made by all digit character. We treat it as
205 for (number
= 0, i
= 0; i
< strlen (name
); i
++)
207 if (isdigit ((int) name
[i
]))
208 number
= (number
* 10) + (name
[i
] - '0');
213 /* In case of name is all digit character */
214 if (i
== strlen (name
))
216 plist
->type
= PREFIX_TYPE_NUMBER
;
218 /* Set prefix_list to number list. */
221 for (point
= list
->head
; point
; point
= point
->next
)
222 if (atol (point
->name
) >= number
)
227 plist
->type
= PREFIX_TYPE_STRING
;
229 /* Set prefix_list to string list. */
232 /* Set point to insertion point. */
233 for (point
= list
->head
; point
; point
= point
->next
)
234 if (strcmp (point
->name
, name
) >= 0)
238 /* In case of this is the first element of master. */
239 if (list
->head
== NULL
)
241 list
->head
= list
->tail
= plist
;
245 /* In case of insertion is made at the tail of access_list. */
248 plist
->prev
= list
->tail
;
249 list
->tail
->next
= plist
;
254 /* In case of insertion is made at the head of access_list. */
255 if (point
== list
->head
)
257 plist
->next
= list
->head
;
258 list
->head
->prev
= plist
;
263 /* Insertion is made at middle of the access_list. */
265 plist
->prev
= point
->prev
;
268 point
->prev
->next
= plist
;
274 static struct prefix_list
*
275 prefix_list_get (afi_t afi
, const char *name
)
277 struct prefix_list
*plist
;
279 plist
= prefix_list_lookup (afi
, name
);
282 plist
= prefix_list_insert (afi
, name
);
286 /* Delete prefix-list from prefix_list_master and free it. */
288 prefix_list_delete (struct prefix_list
*plist
)
290 struct prefix_list_list
*list
;
291 struct prefix_master
*master
;
292 struct prefix_list_entry
*pentry
;
293 struct prefix_list_entry
*next
;
295 /* If prefix-list contain prefix_list_entry free all of it. */
296 for (pentry
= plist
->head
; pentry
; pentry
= next
)
299 prefix_list_entry_free (pentry
);
303 master
= plist
->master
;
305 if (plist
->type
== PREFIX_TYPE_NUMBER
)
311 plist
->next
->prev
= plist
->prev
;
313 list
->tail
= plist
->prev
;
316 plist
->prev
->next
= plist
->next
;
318 list
->head
= plist
->next
;
321 XFREE (MTYPE_TMP
, plist
->desc
);
323 /* Make sure master's recent changed prefix-list information is
325 master
->recent
= NULL
;
328 XFREE (MTYPE_PREFIX_LIST_STR
, plist
->name
);
330 prefix_list_free (plist
);
332 if (master
->delete_hook
)
333 (*master
->delete_hook
) ();
336 static struct prefix_list_entry
*
337 prefix_list_entry_make (struct prefix
*prefix
, enum prefix_list_type type
,
338 int seq
, int le
, int ge
, int any
)
340 struct prefix_list_entry
*pentry
;
342 pentry
= prefix_list_entry_new ();
347 prefix_copy (&pentry
->prefix
, prefix
);
356 /* Add hook function. */
358 prefix_list_add_hook (void (*func
) (struct prefix_list
*plist
))
360 prefix_master_ipv4
.add_hook
= func
;
362 prefix_master_ipv6
.add_hook
= func
;
363 #endif /* HAVE_IPV6 */
366 /* Delete hook function. */
368 prefix_list_delete_hook (void (*func
) (struct prefix_list
*plist
))
370 prefix_master_ipv4
.delete_hook
= func
;
372 prefix_master_ipv6
.delete_hook
= func
;
373 #endif /* HAVE_IPVt6 */
376 /* Calculate new sequential number. */
378 prefix_new_seq_get (struct prefix_list
*plist
)
382 struct prefix_list_entry
*pentry
;
386 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
388 if (maxseq
< pentry
->seq
)
389 maxseq
= pentry
->seq
;
392 newseq
= ((maxseq
/ 5) * 5) + 5;
397 /* Return prefix list entry which has same seq number. */
398 static struct prefix_list_entry
*
399 prefix_seq_check (struct prefix_list
*plist
, int seq
)
401 struct prefix_list_entry
*pentry
;
403 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
404 if (pentry
->seq
== seq
)
409 static struct prefix_list_entry
*
410 prefix_list_entry_lookup (struct prefix_list
*plist
, struct prefix
*prefix
,
411 enum prefix_list_type type
, int seq
, int le
, int ge
)
413 struct prefix_list_entry
*pentry
;
415 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
416 if (prefix_same (&pentry
->prefix
, prefix
) && pentry
->type
== type
)
418 if (seq
>= 0 && pentry
->seq
!= seq
)
421 if (pentry
->le
!= le
)
423 if (pentry
->ge
!= ge
)
433 prefix_list_entry_delete (struct prefix_list
*plist
,
434 struct prefix_list_entry
*pentry
,
437 if (plist
== NULL
|| pentry
== NULL
)
440 pentry
->prev
->next
= pentry
->next
;
442 plist
->head
= pentry
->next
;
444 pentry
->next
->prev
= pentry
->prev
;
446 plist
->tail
= pentry
->prev
;
448 prefix_list_entry_free (pentry
);
454 if (plist
->master
->delete_hook
)
455 (*plist
->master
->delete_hook
) (plist
);
457 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
458 prefix_list_delete (plist
);
460 plist
->master
->recent
= plist
;
465 prefix_list_entry_add (struct prefix_list
*plist
,
466 struct prefix_list_entry
*pentry
)
468 struct prefix_list_entry
*replace
;
469 struct prefix_list_entry
*point
;
471 /* Automatic asignment of seq no. */
472 if (pentry
->seq
== -1)
473 pentry
->seq
= prefix_new_seq_get (plist
);
475 /* Is there any same seq prefix list entry? */
476 replace
= prefix_seq_check (plist
, pentry
->seq
);
478 prefix_list_entry_delete (plist
, replace
, 0);
480 /* Check insert point. */
481 for (point
= plist
->head
; point
; point
= point
->next
)
482 if (point
->seq
>= pentry
->seq
)
485 /* In case of this is the first element of the list. */
486 pentry
->next
= point
;
491 point
->prev
->next
= pentry
;
493 plist
->head
= pentry
;
495 pentry
->prev
= point
->prev
;
496 point
->prev
= pentry
;
501 plist
->tail
->next
= pentry
;
503 plist
->head
= pentry
;
505 pentry
->prev
= plist
->tail
;
506 plist
->tail
= pentry
;
509 /* Increment count. */
512 /* Run hook function. */
513 if (plist
->master
->add_hook
)
514 (*plist
->master
->add_hook
) (plist
);
516 plist
->master
->recent
= plist
;
519 /* Return string of prefix_list_type. */
521 prefix_list_type_str (struct prefix_list_entry
*pentry
)
523 switch (pentry
->type
)
535 prefix_list_entry_match (struct prefix_list_entry
*pentry
, struct prefix
*p
)
539 ret
= prefix_match (&pentry
->prefix
, p
);
543 /* In case of le nor ge is specified, exact match is performed. */
544 if (! pentry
->le
&& ! pentry
->ge
)
546 if (pentry
->prefix
.prefixlen
!= p
->prefixlen
)
552 if (p
->prefixlen
> pentry
->le
)
556 if (p
->prefixlen
< pentry
->ge
)
562 enum prefix_list_type
563 prefix_list_apply (struct prefix_list
*plist
, void *object
)
565 struct prefix_list_entry
*pentry
;
568 p
= (struct prefix
*) object
;
573 if (plist
->count
== 0)
574 return PREFIX_PERMIT
;
576 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
579 if (prefix_list_entry_match (pentry
, p
))
590 prefix_list_print (struct prefix_list
*plist
)
592 struct prefix_list_entry
*pentry
;
597 printf ("ip prefix-list %s: %d entries\n", plist
->name
, plist
->count
);
599 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
602 printf ("any %s\n", prefix_list_type_str (pentry
));
610 printf (" seq %d %s %s/%d",
612 prefix_list_type_str (pentry
),
613 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
616 printf (" ge %d", pentry
->ge
);
618 printf (" le %d", pentry
->le
);
624 /* Retrun 1 when plist already include pentry policy. */
625 static struct prefix_list_entry
*
626 prefix_entry_dup_check (struct prefix_list
*plist
,
627 struct prefix_list_entry
*new)
629 struct prefix_list_entry
*pentry
;
633 seq
= prefix_new_seq_get (plist
);
637 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
639 if (prefix_same (&pentry
->prefix
, &new->prefix
)
640 && pentry
->type
== new->type
641 && pentry
->le
== new->le
642 && pentry
->ge
== new->ge
643 && pentry
->seq
!= seq
)
650 vty_invalid_prefix_range (struct vty
*vty
, const char *prefix
)
652 vty_out (vty
, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
653 prefix
, VTY_NEWLINE
);
658 vty_prefix_list_install (struct vty
*vty
, afi_t afi
, const char *name
,
659 const char *seq
, const char *typestr
,
660 const char *prefix
, const char *ge
, const char *le
)
663 enum prefix_list_type type
;
664 struct prefix_list
*plist
;
665 struct prefix_list_entry
*pentry
;
666 struct prefix_list_entry
*dup
;
673 /* Sequential number. */
677 /* ge and le number */
683 /* Check filter type. */
684 if (strncmp ("permit", typestr
, 1) == 0)
685 type
= PREFIX_PERMIT
;
686 else if (strncmp ("deny", typestr
, 1) == 0)
690 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
694 /* "any" is special token for matching any IPv4 addresses. */
697 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
699 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
701 lenum
= IPV4_MAX_BITLEN
;
705 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
709 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
714 else if (afi
== AFI_IP6
)
716 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
718 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
720 lenum
= IPV6_MAX_BITLEN
;
724 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
728 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
732 #endif /* HAVE_IPV6 */
734 /* ge and le check. */
735 if (genum
&& genum
<= p
.prefixlen
)
736 return vty_invalid_prefix_range (vty
, prefix
);
738 if (lenum
&& lenum
<= p
.prefixlen
)
739 return vty_invalid_prefix_range (vty
, prefix
);
741 if (lenum
&& genum
> lenum
)
742 return vty_invalid_prefix_range (vty
, prefix
);
744 if (genum
&& lenum
== (afi
== AFI_IP
? 32 : 128))
747 /* Get prefix_list with name. */
748 plist
= prefix_list_get (afi
, name
);
750 /* Make prefix entry. */
751 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
753 /* Check same policy. */
754 dup
= prefix_entry_dup_check (plist
, pentry
);
758 prefix_list_entry_free (pentry
);
759 vty_out (vty
, "%% Insertion failed - prefix-list entry exists:%s",
761 vty_out (vty
, " seq %d %s %s", dup
->seq
, typestr
, prefix
);
763 vty_out (vty
, " ge %d", genum
);
765 vty_out (vty
, " le %d", lenum
);
766 vty_out (vty
, "%s", VTY_NEWLINE
);
770 /* Install new filter to the access_list. */
771 prefix_list_entry_add (plist
, pentry
);
777 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
778 const char *seq
, const char *typestr
,
779 const char *prefix
, const char *ge
, const char *le
)
782 enum prefix_list_type type
;
783 struct prefix_list
*plist
;
784 struct prefix_list_entry
*pentry
;
790 /* Check prefix list name. */
791 plist
= prefix_list_lookup (afi
, name
);
794 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
798 /* Only prefix-list name specified, delete the entire prefix-list. */
799 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
800 ge
== NULL
&& le
== NULL
)
802 prefix_list_delete (plist
);
806 /* Check sequence number. */
810 /* ge and le number */
816 /* Check of filter type. */
817 if (strncmp ("permit", typestr
, 1) == 0)
818 type
= PREFIX_PERMIT
;
819 else if (strncmp ("deny", typestr
, 1) == 0)
823 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
827 /* "any" is special token for matching any IPv4 addresses. */
830 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
832 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
834 lenum
= IPV4_MAX_BITLEN
;
837 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
841 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
846 else if (afi
== AFI_IP6
)
848 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
850 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
852 lenum
= IPV6_MAX_BITLEN
;
855 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
859 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
863 #endif /* HAVE_IPV6 */
865 /* Lookup prefix entry. */
866 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
870 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
874 /* Install new filter to the access_list. */
875 prefix_list_entry_delete (plist
, pentry
, 1);
881 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
883 struct prefix_list
*plist
;
885 plist
= prefix_list_lookup (afi
, name
);
888 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
894 XFREE (MTYPE_TMP
, plist
->desc
);
898 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
899 prefix_list_delete (plist
);
915 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
916 struct prefix_master
*master
, enum display_type dtype
,
919 struct prefix_list_entry
*pentry
;
921 if (dtype
== normal_display
)
923 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
924 afi
== AFI_IP
? "" : "v6",
925 plist
->name
, plist
->count
, VTY_NEWLINE
);
927 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
929 else if (dtype
== summary_display
|| dtype
== detail_display
)
931 vty_out (vty
, "ip%s prefix-list %s:%s",
932 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
935 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
937 vty_out (vty
, " count: %d, range entries: %d, sequences: %d - %d%s",
938 plist
->count
, plist
->rangecount
,
939 plist
->head
? plist
->head
->seq
: 0,
940 plist
->tail
? plist
->tail
->seq
: 0,
944 if (dtype
!= summary_display
)
946 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
948 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
954 vty_out (vty
, "seq %d ", pentry
->seq
);
956 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
959 vty_out (vty
, "any");
962 struct prefix
*p
= &pentry
->prefix
;
965 vty_out (vty
, "%s/%d",
966 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
970 vty_out (vty
, " ge %d", pentry
->ge
);
972 vty_out (vty
, " le %d", pentry
->le
);
975 if (dtype
== detail_display
|| dtype
== sequential_display
)
976 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
977 pentry
->hitcnt
, pentry
->refcnt
);
979 vty_out (vty
, "%s", VTY_NEWLINE
);
985 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
986 const char *seq
, enum display_type dtype
)
988 struct prefix_list
*plist
;
989 struct prefix_master
*master
;
992 master
= prefix_master_get (afi
);
1001 plist
= prefix_list_lookup (afi
, name
);
1004 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1007 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1011 if (dtype
== detail_display
|| dtype
== summary_display
)
1014 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1015 master
->recent
->name
, VTY_NEWLINE
);
1018 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1019 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1021 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1022 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1029 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1030 const char *prefix
, enum display_type type
)
1032 struct prefix_list
*plist
;
1033 struct prefix_list_entry
*pentry
;
1038 plist
= prefix_list_lookup (afi
, name
);
1041 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1045 ret
= str2prefix (prefix
, &p
);
1048 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1052 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1056 if (type
== normal_display
|| type
== first_match_display
)
1057 if (prefix_same (&p
, &pentry
->prefix
))
1060 if (type
== longer_display
)
1061 if (prefix_match (&p
, &pentry
->prefix
))
1066 vty_out (vty
, " seq %d %s ",
1068 prefix_list_type_str (pentry
));
1071 vty_out (vty
, "any");
1074 struct prefix
*p
= &pentry
->prefix
;
1077 vty_out (vty
, "%s/%d",
1078 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1082 vty_out (vty
, " ge %d", pentry
->ge
);
1084 vty_out (vty
, " le %d", pentry
->le
);
1087 if (type
== normal_display
|| type
== first_match_display
)
1088 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1089 pentry
->hitcnt
, pentry
->refcnt
);
1091 vty_out (vty
, "%s", VTY_NEWLINE
);
1093 if (type
== first_match_display
)
1101 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1104 struct prefix_master
*master
;
1105 struct prefix_list
*plist
;
1106 struct prefix_list_entry
*pentry
;
1110 master
= prefix_master_get (afi
);
1114 if (name
== NULL
&& prefix
== NULL
)
1116 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1117 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1120 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1121 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1126 plist
= prefix_list_lookup (afi
, name
);
1129 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1135 ret
= str2prefix (prefix
, &p
);
1138 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1143 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1147 if (prefix_match (&pentry
->prefix
, &p
))
1157 DEFUN (ip_prefix_list
,
1159 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1162 "Name of a prefix list\n"
1163 "Specify packets to reject\n"
1164 "Specify packets to forward\n"
1165 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1166 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1168 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1169 argv
[1], argv
[2], NULL
, NULL
);
1172 DEFUN (ip_prefix_list_ge
,
1173 ip_prefix_list_ge_cmd
,
1174 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1177 "Name of a prefix list\n"
1178 "Specify packets to reject\n"
1179 "Specify packets to forward\n"
1180 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1181 "Minimum prefix length to be matched\n"
1182 "Minimum prefix length\n")
1184 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1185 argv
[2], argv
[3], NULL
);
1188 DEFUN (ip_prefix_list_ge_le
,
1189 ip_prefix_list_ge_le_cmd
,
1190 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1193 "Name of a prefix list\n"
1194 "Specify packets to reject\n"
1195 "Specify packets to forward\n"
1196 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1197 "Minimum prefix length to be matched\n"
1198 "Minimum prefix length\n"
1199 "Maximum prefix length to be matched\n"
1200 "Maximum prefix length\n")
1202 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1203 argv
[2], argv
[3], argv
[4]);
1206 DEFUN (ip_prefix_list_le
,
1207 ip_prefix_list_le_cmd
,
1208 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1211 "Name of a prefix list\n"
1212 "Specify packets to reject\n"
1213 "Specify packets to forward\n"
1214 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1215 "Maximum prefix length to be matched\n"
1216 "Maximum prefix length\n")
1218 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1219 argv
[2], NULL
, argv
[3]);
1222 DEFUN (ip_prefix_list_le_ge
,
1223 ip_prefix_list_le_ge_cmd
,
1224 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1227 "Name of a prefix list\n"
1228 "Specify packets to reject\n"
1229 "Specify packets to forward\n"
1230 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1231 "Maximum prefix length to be matched\n"
1232 "Maximum prefix length\n"
1233 "Minimum prefix length to be matched\n"
1234 "Minimum prefix length\n")
1236 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1237 argv
[2], argv
[4], argv
[3]);
1240 DEFUN (ip_prefix_list_seq
,
1241 ip_prefix_list_seq_cmd
,
1242 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1245 "Name of a prefix list\n"
1246 "sequence number of an entry\n"
1248 "Specify packets to reject\n"
1249 "Specify packets to forward\n"
1250 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1251 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1253 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1254 argv
[3], NULL
, NULL
);
1257 DEFUN (ip_prefix_list_seq_ge
,
1258 ip_prefix_list_seq_ge_cmd
,
1259 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1262 "Name of a prefix list\n"
1263 "sequence number of an entry\n"
1265 "Specify packets to reject\n"
1266 "Specify packets to forward\n"
1267 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1268 "Minimum prefix length to be matched\n"
1269 "Minimum prefix length\n")
1271 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1272 argv
[3], argv
[4], NULL
);
1275 DEFUN (ip_prefix_list_seq_ge_le
,
1276 ip_prefix_list_seq_ge_le_cmd
,
1277 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1280 "Name of a prefix list\n"
1281 "sequence number of an entry\n"
1283 "Specify packets to reject\n"
1284 "Specify packets to forward\n"
1285 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1286 "Minimum prefix length to be matched\n"
1287 "Minimum prefix length\n"
1288 "Maximum prefix length to be matched\n"
1289 "Maximum prefix length\n")
1291 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1292 argv
[3], argv
[4], argv
[5]);
1295 DEFUN (ip_prefix_list_seq_le
,
1296 ip_prefix_list_seq_le_cmd
,
1297 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1300 "Name of a prefix list\n"
1301 "sequence number of an entry\n"
1303 "Specify packets to reject\n"
1304 "Specify packets to forward\n"
1305 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1306 "Maximum prefix length to be matched\n"
1307 "Maximum prefix length\n")
1309 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1310 argv
[3], NULL
, argv
[4]);
1313 DEFUN (ip_prefix_list_seq_le_ge
,
1314 ip_prefix_list_seq_le_ge_cmd
,
1315 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1318 "Name of a prefix list\n"
1319 "sequence number of an entry\n"
1321 "Specify packets to reject\n"
1322 "Specify packets to forward\n"
1323 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1324 "Maximum prefix length to be matched\n"
1325 "Maximum prefix length\n"
1326 "Minimum prefix length to be matched\n"
1327 "Minimum prefix length\n")
1329 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1330 argv
[3], argv
[5], argv
[4]);
1333 DEFUN (no_ip_prefix_list
,
1334 no_ip_prefix_list_cmd
,
1335 "no ip prefix-list WORD",
1339 "Name of a prefix list\n")
1341 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1345 DEFUN (no_ip_prefix_list_prefix
,
1346 no_ip_prefix_list_prefix_cmd
,
1347 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1351 "Name of a prefix list\n"
1352 "Specify packets to reject\n"
1353 "Specify packets to forward\n"
1354 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1355 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1357 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1358 argv
[2], NULL
, NULL
);
1361 DEFUN (no_ip_prefix_list_ge
,
1362 no_ip_prefix_list_ge_cmd
,
1363 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1367 "Name of a prefix list\n"
1368 "Specify packets to reject\n"
1369 "Specify packets to forward\n"
1370 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1371 "Minimum prefix length to be matched\n"
1372 "Minimum prefix length\n")
1374 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1375 argv
[2], argv
[3], NULL
);
1378 DEFUN (no_ip_prefix_list_ge_le
,
1379 no_ip_prefix_list_ge_le_cmd
,
1380 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1384 "Name of a prefix list\n"
1385 "Specify packets to reject\n"
1386 "Specify packets to forward\n"
1387 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1388 "Minimum prefix length to be matched\n"
1389 "Minimum prefix length\n"
1390 "Maximum prefix length to be matched\n"
1391 "Maximum prefix length\n")
1393 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1394 argv
[2], argv
[3], argv
[4]);
1397 DEFUN (no_ip_prefix_list_le
,
1398 no_ip_prefix_list_le_cmd
,
1399 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1403 "Name of a prefix list\n"
1404 "Specify packets to reject\n"
1405 "Specify packets to forward\n"
1406 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1407 "Maximum prefix length to be matched\n"
1408 "Maximum prefix length\n")
1410 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1411 argv
[2], NULL
, argv
[3]);
1414 DEFUN (no_ip_prefix_list_le_ge
,
1415 no_ip_prefix_list_le_ge_cmd
,
1416 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1420 "Name of a prefix list\n"
1421 "Specify packets to reject\n"
1422 "Specify packets to forward\n"
1423 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1424 "Maximum prefix length to be matched\n"
1425 "Maximum prefix length\n"
1426 "Minimum prefix length to be matched\n"
1427 "Minimum prefix length\n")
1429 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1430 argv
[2], argv
[4], argv
[3]);
1433 DEFUN (no_ip_prefix_list_seq
,
1434 no_ip_prefix_list_seq_cmd
,
1435 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1439 "Name of a prefix list\n"
1440 "sequence number of an entry\n"
1442 "Specify packets to reject\n"
1443 "Specify packets to forward\n"
1444 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1445 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1447 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1448 argv
[3], NULL
, NULL
);
1451 DEFUN (no_ip_prefix_list_seq_ge
,
1452 no_ip_prefix_list_seq_ge_cmd
,
1453 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1457 "Name of a prefix list\n"
1458 "sequence number of an entry\n"
1460 "Specify packets to reject\n"
1461 "Specify packets to forward\n"
1462 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1463 "Minimum prefix length to be matched\n"
1464 "Minimum prefix length\n")
1466 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1467 argv
[3], argv
[4], NULL
);
1470 DEFUN (no_ip_prefix_list_seq_ge_le
,
1471 no_ip_prefix_list_seq_ge_le_cmd
,
1472 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1476 "Name of a prefix list\n"
1477 "sequence number of an entry\n"
1479 "Specify packets to reject\n"
1480 "Specify packets to forward\n"
1481 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1482 "Minimum prefix length to be matched\n"
1483 "Minimum prefix length\n"
1484 "Maximum prefix length to be matched\n"
1485 "Maximum prefix length\n")
1487 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1488 argv
[3], argv
[4], argv
[5]);
1491 DEFUN (no_ip_prefix_list_seq_le
,
1492 no_ip_prefix_list_seq_le_cmd
,
1493 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1497 "Name of a prefix list\n"
1498 "sequence number of an entry\n"
1500 "Specify packets to reject\n"
1501 "Specify packets to forward\n"
1502 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1503 "Maximum prefix length to be matched\n"
1504 "Maximum prefix length\n")
1506 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1507 argv
[3], NULL
, argv
[4]);
1510 DEFUN (no_ip_prefix_list_seq_le_ge
,
1511 no_ip_prefix_list_seq_le_ge_cmd
,
1512 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1516 "Name of a prefix list\n"
1517 "sequence number of an entry\n"
1519 "Specify packets to reject\n"
1520 "Specify packets to forward\n"
1521 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1522 "Maximum prefix length to be matched\n"
1523 "Maximum prefix length\n"
1524 "Minimum prefix length to be matched\n"
1525 "Minimum prefix length\n")
1527 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1528 argv
[3], argv
[5], argv
[4]);
1531 DEFUN (ip_prefix_list_sequence_number
,
1532 ip_prefix_list_sequence_number_cmd
,
1533 "ip prefix-list sequence-number",
1536 "Include/exclude sequence numbers in NVGEN\n")
1538 prefix_master_ipv4
.seqnum
= 1;
1542 DEFUN (no_ip_prefix_list_sequence_number
,
1543 no_ip_prefix_list_sequence_number_cmd
,
1544 "no ip prefix-list sequence-number",
1548 "Include/exclude sequence numbers in NVGEN\n")
1550 prefix_master_ipv4
.seqnum
= 0;
1554 DEFUN (ip_prefix_list_description
,
1555 ip_prefix_list_description_cmd
,
1556 "ip prefix-list WORD description .LINE",
1559 "Name of a prefix list\n"
1560 "Prefix-list specific description\n"
1561 "Up to 80 characters describing this prefix-list\n")
1563 struct prefix_list
*plist
;
1567 plist
= prefix_list_get (AFI_IP
, argv
[0]);
1571 XFREE (MTYPE_TMP
, plist
->desc
);
1575 /* Below is description get codes. */
1576 b
= buffer_new (1024);
1577 for (i
= 1; i
< argc
; i
++)
1579 buffer_putstr (b
, argv
[i
]);
1580 buffer_putc (b
, ' ');
1582 buffer_putc (b
, '\0');
1584 plist
->desc
= buffer_getstr (b
);
1591 DEFUN (no_ip_prefix_list_description
,
1592 no_ip_prefix_list_description_cmd
,
1593 "no ip prefix-list WORD description",
1597 "Name of a prefix list\n"
1598 "Prefix-list specific description\n")
1600 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1603 ALIAS (no_ip_prefix_list_description
,
1604 no_ip_prefix_list_description_arg_cmd
,
1605 "no ip prefix-list WORD description .LINE",
1609 "Name of a prefix list\n"
1610 "Prefix-list specific description\n"
1611 "Up to 80 characters describing this prefix-list\n")
1613 DEFUN (show_ip_prefix_list
,
1614 show_ip_prefix_list_cmd
,
1615 "show ip prefix-list",
1620 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1623 DEFUN (show_ip_prefix_list_name
,
1624 show_ip_prefix_list_name_cmd
,
1625 "show ip prefix-list WORD",
1629 "Name of a prefix list\n")
1631 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1634 DEFUN (show_ip_prefix_list_name_seq
,
1635 show_ip_prefix_list_name_seq_cmd
,
1636 "show ip prefix-list WORD seq <1-4294967295>",
1640 "Name of a prefix list\n"
1641 "sequence number of an entry\n"
1642 "Sequence number\n")
1644 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1647 DEFUN (show_ip_prefix_list_prefix
,
1648 show_ip_prefix_list_prefix_cmd
,
1649 "show ip prefix-list WORD A.B.C.D/M",
1653 "Name of a prefix list\n"
1654 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1656 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1659 DEFUN (show_ip_prefix_list_prefix_longer
,
1660 show_ip_prefix_list_prefix_longer_cmd
,
1661 "show ip prefix-list WORD A.B.C.D/M longer",
1665 "Name of a prefix list\n"
1666 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1667 "Lookup longer prefix\n")
1669 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1672 DEFUN (show_ip_prefix_list_prefix_first_match
,
1673 show_ip_prefix_list_prefix_first_match_cmd
,
1674 "show ip prefix-list WORD A.B.C.D/M first-match",
1678 "Name of a prefix list\n"
1679 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1680 "First matched prefix\n")
1682 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1685 DEFUN (show_ip_prefix_list_summary
,
1686 show_ip_prefix_list_summary_cmd
,
1687 "show ip prefix-list summary",
1691 "Summary of prefix lists\n")
1693 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1696 DEFUN (show_ip_prefix_list_summary_name
,
1697 show_ip_prefix_list_summary_name_cmd
,
1698 "show ip prefix-list summary WORD",
1702 "Summary of prefix lists\n"
1703 "Name of a prefix list\n")
1705 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1709 DEFUN (show_ip_prefix_list_detail
,
1710 show_ip_prefix_list_detail_cmd
,
1711 "show ip prefix-list detail",
1715 "Detail of prefix lists\n")
1717 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1720 DEFUN (show_ip_prefix_list_detail_name
,
1721 show_ip_prefix_list_detail_name_cmd
,
1722 "show ip prefix-list detail WORD",
1726 "Detail of prefix lists\n"
1727 "Name of a prefix list\n")
1729 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1732 DEFUN (clear_ip_prefix_list
,
1733 clear_ip_prefix_list_cmd
,
1734 "clear ip prefix-list",
1739 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1742 DEFUN (clear_ip_prefix_list_name
,
1743 clear_ip_prefix_list_name_cmd
,
1744 "clear ip prefix-list WORD",
1748 "Name of a prefix list\n")
1750 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1753 DEFUN (clear_ip_prefix_list_name_prefix
,
1754 clear_ip_prefix_list_name_prefix_cmd
,
1755 "clear ip prefix-list WORD A.B.C.D/M",
1759 "Name of a prefix list\n"
1760 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1762 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1766 DEFUN (ipv6_prefix_list
,
1767 ipv6_prefix_list_cmd
,
1768 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1771 "Name of a prefix list\n"
1772 "Specify packets to reject\n"
1773 "Specify packets to forward\n"
1774 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1775 "Any prefix match. Same as \"::0/0 le 128\"\n")
1777 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
1778 argv
[1], argv
[2], NULL
, NULL
);
1781 DEFUN (ipv6_prefix_list_ge
,
1782 ipv6_prefix_list_ge_cmd
,
1783 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1786 "Name of a prefix list\n"
1787 "Specify packets to reject\n"
1788 "Specify packets to forward\n"
1789 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1790 "Minimum prefix length to be matched\n"
1791 "Minimum prefix length\n")
1793 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1794 argv
[2], argv
[3], NULL
);
1797 DEFUN (ipv6_prefix_list_ge_le
,
1798 ipv6_prefix_list_ge_le_cmd
,
1799 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1802 "Name of a prefix list\n"
1803 "Specify packets to reject\n"
1804 "Specify packets to forward\n"
1805 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1806 "Minimum prefix length to be matched\n"
1807 "Minimum prefix length\n"
1808 "Maximum prefix length to be matched\n"
1809 "Maximum prefix length\n")
1812 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1813 argv
[2], argv
[3], argv
[4]);
1816 DEFUN (ipv6_prefix_list_le
,
1817 ipv6_prefix_list_le_cmd
,
1818 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1821 "Name of a prefix list\n"
1822 "Specify packets to reject\n"
1823 "Specify packets to forward\n"
1824 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1825 "Maximum prefix length to be matched\n"
1826 "Maximum prefix length\n")
1828 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1829 argv
[2], NULL
, argv
[3]);
1832 DEFUN (ipv6_prefix_list_le_ge
,
1833 ipv6_prefix_list_le_ge_cmd
,
1834 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1837 "Name of a prefix list\n"
1838 "Specify packets to reject\n"
1839 "Specify packets to forward\n"
1840 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1841 "Maximum prefix length to be matched\n"
1842 "Maximum prefix length\n"
1843 "Minimum prefix length to be matched\n"
1844 "Minimum prefix length\n")
1846 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1847 argv
[2], argv
[4], argv
[3]);
1850 DEFUN (ipv6_prefix_list_seq
,
1851 ipv6_prefix_list_seq_cmd
,
1852 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
1855 "Name of a prefix list\n"
1856 "sequence number of an entry\n"
1858 "Specify packets to reject\n"
1859 "Specify packets to forward\n"
1860 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1861 "Any prefix match. Same as \"::0/0 le 128\"\n")
1863 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1864 argv
[3], NULL
, NULL
);
1867 DEFUN (ipv6_prefix_list_seq_ge
,
1868 ipv6_prefix_list_seq_ge_cmd
,
1869 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
1872 "Name of a prefix list\n"
1873 "sequence number of an entry\n"
1875 "Specify packets to reject\n"
1876 "Specify packets to forward\n"
1877 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1878 "Minimum prefix length to be matched\n"
1879 "Minimum prefix length\n")
1881 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1882 argv
[3], argv
[4], NULL
);
1885 DEFUN (ipv6_prefix_list_seq_ge_le
,
1886 ipv6_prefix_list_seq_ge_le_cmd
,
1887 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1890 "Name of a prefix list\n"
1891 "sequence number of an entry\n"
1893 "Specify packets to reject\n"
1894 "Specify packets to forward\n"
1895 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1896 "Minimum prefix length to be matched\n"
1897 "Minimum prefix length\n"
1898 "Maximum prefix length to be matched\n"
1899 "Maximum prefix length\n")
1901 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1902 argv
[3], argv
[4], argv
[5]);
1905 DEFUN (ipv6_prefix_list_seq_le
,
1906 ipv6_prefix_list_seq_le_cmd
,
1907 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
1910 "Name of a prefix list\n"
1911 "sequence number of an entry\n"
1913 "Specify packets to reject\n"
1914 "Specify packets to forward\n"
1915 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1916 "Maximum prefix length to be matched\n"
1917 "Maximum prefix length\n")
1919 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1920 argv
[3], NULL
, argv
[4]);
1923 DEFUN (ipv6_prefix_list_seq_le_ge
,
1924 ipv6_prefix_list_seq_le_ge_cmd
,
1925 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1928 "Name of a prefix list\n"
1929 "sequence number of an entry\n"
1931 "Specify packets to reject\n"
1932 "Specify packets to forward\n"
1933 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1934 "Maximum prefix length to be matched\n"
1935 "Maximum prefix length\n"
1936 "Minimum prefix length to be matched\n"
1937 "Minimum prefix length\n")
1939 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1940 argv
[3], argv
[5], argv
[4]);
1943 DEFUN (no_ipv6_prefix_list
,
1944 no_ipv6_prefix_list_cmd
,
1945 "no ipv6 prefix-list WORD",
1949 "Name of a prefix list\n")
1951 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
1955 DEFUN (no_ipv6_prefix_list_prefix
,
1956 no_ipv6_prefix_list_prefix_cmd
,
1957 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1961 "Name of a prefix list\n"
1962 "Specify packets to reject\n"
1963 "Specify packets to forward\n"
1964 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1965 "Any prefix match. Same as \"::0/0 le 128\"\n")
1967 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1968 argv
[2], NULL
, NULL
);
1971 DEFUN (no_ipv6_prefix_list_ge
,
1972 no_ipv6_prefix_list_ge_cmd
,
1973 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1977 "Name of a prefix list\n"
1978 "Specify packets to reject\n"
1979 "Specify packets to forward\n"
1980 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1981 "Minimum prefix length to be matched\n"
1982 "Minimum prefix length\n")
1984 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1985 argv
[2], argv
[3], NULL
);
1988 DEFUN (no_ipv6_prefix_list_ge_le
,
1989 no_ipv6_prefix_list_ge_le_cmd
,
1990 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1994 "Name of a prefix list\n"
1995 "Specify packets to reject\n"
1996 "Specify packets to forward\n"
1997 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1998 "Minimum prefix length to be matched\n"
1999 "Minimum prefix length\n"
2000 "Maximum prefix length to be matched\n"
2001 "Maximum prefix length\n")
2003 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2004 argv
[2], argv
[3], argv
[4]);
2007 DEFUN (no_ipv6_prefix_list_le
,
2008 no_ipv6_prefix_list_le_cmd
,
2009 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2013 "Name of a prefix list\n"
2014 "Specify packets to reject\n"
2015 "Specify packets to forward\n"
2016 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2017 "Maximum prefix length to be matched\n"
2018 "Maximum prefix length\n")
2020 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2021 argv
[2], NULL
, argv
[3]);
2024 DEFUN (no_ipv6_prefix_list_le_ge
,
2025 no_ipv6_prefix_list_le_ge_cmd
,
2026 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2030 "Name of a prefix list\n"
2031 "Specify packets to reject\n"
2032 "Specify packets to forward\n"
2033 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2034 "Maximum prefix length to be matched\n"
2035 "Maximum prefix length\n"
2036 "Minimum prefix length to be matched\n"
2037 "Minimum prefix length\n")
2039 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2040 argv
[2], argv
[4], argv
[3]);
2043 DEFUN (no_ipv6_prefix_list_seq
,
2044 no_ipv6_prefix_list_seq_cmd
,
2045 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2049 "Name of a prefix list\n"
2050 "sequence number of an entry\n"
2052 "Specify packets to reject\n"
2053 "Specify packets to forward\n"
2054 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2055 "Any prefix match. Same as \"::0/0 le 128\"\n")
2057 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2058 argv
[3], NULL
, NULL
);
2061 DEFUN (no_ipv6_prefix_list_seq_ge
,
2062 no_ipv6_prefix_list_seq_ge_cmd
,
2063 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2067 "Name of a prefix list\n"
2068 "sequence number of an entry\n"
2070 "Specify packets to reject\n"
2071 "Specify packets to forward\n"
2072 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2073 "Minimum prefix length to be matched\n"
2074 "Minimum prefix length\n")
2076 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2077 argv
[3], argv
[4], NULL
);
2080 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2081 no_ipv6_prefix_list_seq_ge_le_cmd
,
2082 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2086 "Name of a prefix list\n"
2087 "sequence number of an entry\n"
2089 "Specify packets to reject\n"
2090 "Specify packets to forward\n"
2091 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2092 "Minimum prefix length to be matched\n"
2093 "Minimum prefix length\n"
2094 "Maximum prefix length to be matched\n"
2095 "Maximum prefix length\n")
2097 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2098 argv
[3], argv
[4], argv
[5]);
2101 DEFUN (no_ipv6_prefix_list_seq_le
,
2102 no_ipv6_prefix_list_seq_le_cmd
,
2103 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2107 "Name of a prefix list\n"
2108 "sequence number of an entry\n"
2110 "Specify packets to reject\n"
2111 "Specify packets to forward\n"
2112 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2113 "Maximum prefix length to be matched\n"
2114 "Maximum prefix length\n")
2116 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2117 argv
[3], NULL
, argv
[4]);
2120 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2121 no_ipv6_prefix_list_seq_le_ge_cmd
,
2122 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2126 "Name of a prefix list\n"
2127 "sequence number of an entry\n"
2129 "Specify packets to reject\n"
2130 "Specify packets to forward\n"
2131 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2132 "Maximum prefix length to be matched\n"
2133 "Maximum prefix length\n"
2134 "Minimum prefix length to be matched\n"
2135 "Minimum prefix length\n")
2137 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2138 argv
[3], argv
[5], argv
[4]);
2141 DEFUN (ipv6_prefix_list_sequence_number
,
2142 ipv6_prefix_list_sequence_number_cmd
,
2143 "ipv6 prefix-list sequence-number",
2146 "Include/exclude sequence numbers in NVGEN\n")
2148 prefix_master_ipv6
.seqnum
= 1;
2152 DEFUN (no_ipv6_prefix_list_sequence_number
,
2153 no_ipv6_prefix_list_sequence_number_cmd
,
2154 "no ipv6 prefix-list sequence-number",
2158 "Include/exclude sequence numbers in NVGEN\n")
2160 prefix_master_ipv6
.seqnum
= 0;
2164 DEFUN (ipv6_prefix_list_description
,
2165 ipv6_prefix_list_description_cmd
,
2166 "ipv6 prefix-list WORD description .LINE",
2169 "Name of a prefix list\n"
2170 "Prefix-list specific description\n"
2171 "Up to 80 characters describing this prefix-list\n")
2173 struct prefix_list
*plist
;
2177 plist
= prefix_list_get (AFI_IP6
, argv
[0]);
2181 XFREE (MTYPE_TMP
, plist
->desc
);
2185 /* Below is description get codes. */
2186 b
= buffer_new (1024);
2187 for (i
= 1; i
< argc
; i
++)
2189 buffer_putstr (b
, argv
[i
]);
2190 buffer_putc (b
, ' ');
2192 buffer_putc (b
, '\0');
2194 plist
->desc
= buffer_getstr (b
);
2201 DEFUN (no_ipv6_prefix_list_description
,
2202 no_ipv6_prefix_list_description_cmd
,
2203 "no ipv6 prefix-list WORD description",
2207 "Name of a prefix list\n"
2208 "Prefix-list specific description\n")
2210 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2213 ALIAS (no_ipv6_prefix_list_description
,
2214 no_ipv6_prefix_list_description_arg_cmd
,
2215 "no ipv6 prefix-list WORD description .LINE",
2219 "Name of a prefix list\n"
2220 "Prefix-list specific description\n"
2221 "Up to 80 characters describing this prefix-list\n")
2223 DEFUN (show_ipv6_prefix_list
,
2224 show_ipv6_prefix_list_cmd
,
2225 "show ipv6 prefix-list",
2230 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2233 DEFUN (show_ipv6_prefix_list_name
,
2234 show_ipv6_prefix_list_name_cmd
,
2235 "show ipv6 prefix-list WORD",
2239 "Name of a prefix list\n")
2241 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2244 DEFUN (show_ipv6_prefix_list_name_seq
,
2245 show_ipv6_prefix_list_name_seq_cmd
,
2246 "show ipv6 prefix-list WORD seq <1-4294967295>",
2250 "Name of a prefix list\n"
2251 "sequence number of an entry\n"
2252 "Sequence number\n")
2254 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2257 DEFUN (show_ipv6_prefix_list_prefix
,
2258 show_ipv6_prefix_list_prefix_cmd
,
2259 "show ipv6 prefix-list WORD X:X::X:X/M",
2263 "Name of a prefix list\n"
2264 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2266 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2269 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2270 show_ipv6_prefix_list_prefix_longer_cmd
,
2271 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2275 "Name of a prefix list\n"
2276 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2277 "Lookup longer prefix\n")
2279 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2282 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2283 show_ipv6_prefix_list_prefix_first_match_cmd
,
2284 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2288 "Name of a prefix list\n"
2289 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2290 "First matched prefix\n")
2292 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2295 DEFUN (show_ipv6_prefix_list_summary
,
2296 show_ipv6_prefix_list_summary_cmd
,
2297 "show ipv6 prefix-list summary",
2301 "Summary of prefix lists\n")
2303 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2306 DEFUN (show_ipv6_prefix_list_summary_name
,
2307 show_ipv6_prefix_list_summary_name_cmd
,
2308 "show ipv6 prefix-list summary WORD",
2312 "Summary of prefix lists\n"
2313 "Name of a prefix list\n")
2315 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2318 DEFUN (show_ipv6_prefix_list_detail
,
2319 show_ipv6_prefix_list_detail_cmd
,
2320 "show ipv6 prefix-list detail",
2324 "Detail of prefix lists\n")
2326 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2329 DEFUN (show_ipv6_prefix_list_detail_name
,
2330 show_ipv6_prefix_list_detail_name_cmd
,
2331 "show ipv6 prefix-list detail WORD",
2335 "Detail of prefix lists\n"
2336 "Name of a prefix list\n")
2338 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2341 DEFUN (clear_ipv6_prefix_list
,
2342 clear_ipv6_prefix_list_cmd
,
2343 "clear ipv6 prefix-list",
2348 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2351 DEFUN (clear_ipv6_prefix_list_name
,
2352 clear_ipv6_prefix_list_name_cmd
,
2353 "clear ipv6 prefix-list WORD",
2357 "Name of a prefix list\n")
2359 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2362 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2363 clear_ipv6_prefix_list_name_prefix_cmd
,
2364 "clear ipv6 prefix-list WORD X:X::X:X/M",
2368 "Name of a prefix list\n"
2369 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2371 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2373 #endif /* HAVE_IPV6 */
2375 /* Configuration write function. */
2377 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2379 struct prefix_list
*plist
;
2380 struct prefix_list_entry
*pentry
;
2381 struct prefix_master
*master
;
2384 master
= prefix_master_get (afi
);
2388 if (! master
->seqnum
)
2390 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2391 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2392 vty_out (vty
, "!%s", VTY_NEWLINE
);
2395 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2399 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2400 afi
== AFI_IP
? "" : "v6",
2401 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2405 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2407 vty_out (vty
, "ip%s prefix-list %s ",
2408 afi
== AFI_IP
? "" : "v6",
2412 vty_out (vty
, "seq %d ", pentry
->seq
);
2414 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2417 vty_out (vty
, "any");
2420 struct prefix
*p
= &pentry
->prefix
;
2423 vty_out (vty
, "%s/%d",
2424 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2428 vty_out (vty
, " ge %d", pentry
->ge
);
2430 vty_out (vty
, " le %d", pentry
->le
);
2432 vty_out (vty
, "%s", VTY_NEWLINE
);
2435 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2438 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2442 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2443 afi
== AFI_IP
? "" : "v6",
2444 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2448 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2450 vty_out (vty
, "ip%s prefix-list %s ",
2451 afi
== AFI_IP
? "" : "v6",
2455 vty_out (vty
, "seq %d ", pentry
->seq
);
2457 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2460 vty_out (vty
, " any");
2463 struct prefix
*p
= &pentry
->prefix
;
2466 vty_out (vty
, " %s/%d",
2467 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2471 vty_out (vty
, " ge %d", pentry
->ge
);
2473 vty_out (vty
, " le %d", pentry
->le
);
2475 vty_out (vty
, "%s", VTY_NEWLINE
);
2484 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2485 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2487 struct prefix_list_entry
*pentry
;
2492 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2494 u_char flag
= init_flag
;
2495 struct prefix
*p
= &pentry
->prefix
;
2497 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2498 permit_flag
: deny_flag
);
2499 stream_putc (s
, flag
);
2500 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2501 stream_putc (s
, (u_char
)pentry
->ge
);
2502 stream_putc (s
, (u_char
)pentry
->le
);
2503 stream_put_prefix (s
, p
);
2510 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2511 int permit
, int set
)
2513 struct prefix_list
*plist
;
2514 struct prefix_list_entry
*pentry
;
2516 /* ge and le value check */
2517 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2519 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2521 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2524 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2527 plist
= prefix_list_get (AFI_ORF_PREFIX
, name
);
2533 pentry
= prefix_list_entry_make (&orfp
->p
,
2534 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2535 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2537 if (prefix_entry_dup_check (plist
, pentry
))
2539 prefix_list_entry_free (pentry
);
2543 prefix_list_entry_add (plist
, pentry
);
2547 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2548 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2549 orfp
->seq
, orfp
->le
, orfp
->ge
);
2554 prefix_list_entry_delete (plist
, pentry
, 1);
2561 prefix_bgp_orf_remove_all (char *name
)
2563 struct prefix_list
*plist
;
2565 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2567 prefix_list_delete (plist
);
2570 /* return prefix count */
2572 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
)
2574 struct prefix_list
*plist
;
2575 struct prefix_list_entry
*pentry
;
2577 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2582 return plist
->count
;
2584 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2585 afi
== AFI_IP
? "" : "v6",
2586 plist
->name
, plist
->count
, VTY_NEWLINE
);
2588 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2590 struct prefix
*p
= &pentry
->prefix
;
2593 vty_out (vty
, " seq %d %s %s/%d", pentry
->seq
,
2594 prefix_list_type_str (pentry
),
2595 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2599 vty_out (vty
, " ge %d", pentry
->ge
);
2601 vty_out (vty
, " le %d", pentry
->le
);
2603 vty_out (vty
, "%s", VTY_NEWLINE
);
2605 return plist
->count
;
2609 prefix_list_reset_orf ()
2611 struct prefix_list
*plist
;
2612 struct prefix_list
*next
;
2613 struct prefix_master
*master
;
2615 master
= prefix_master_get (AFI_ORF_PREFIX
);
2619 for (plist
= master
->num
.head
; plist
; plist
= next
)
2622 prefix_list_delete (plist
);
2624 for (plist
= master
->str
.head
; plist
; plist
= next
)
2627 prefix_list_delete (plist
);
2630 assert (master
->num
.head
== NULL
);
2631 assert (master
->num
.tail
== NULL
);
2633 assert (master
->str
.head
== NULL
);
2634 assert (master
->str
.tail
== NULL
);
2637 master
->recent
= NULL
;
2641 /* Prefix-list node. */
2642 struct cmd_node prefix_node
=
2645 "", /* Prefix list has no interface. */
2650 config_write_prefix_ipv4 (struct vty
*vty
)
2652 return config_write_prefix_afi (AFI_IP
, vty
);
2656 prefix_list_reset_ipv4 ()
2658 struct prefix_list
*plist
;
2659 struct prefix_list
*next
;
2660 struct prefix_master
*master
;
2662 master
= prefix_master_get (AFI_IP
);
2666 for (plist
= master
->num
.head
; plist
; plist
= next
)
2669 prefix_list_delete (plist
);
2671 for (plist
= master
->str
.head
; plist
; plist
= next
)
2674 prefix_list_delete (plist
);
2677 assert (master
->num
.head
== NULL
);
2678 assert (master
->num
.tail
== NULL
);
2680 assert (master
->str
.head
== NULL
);
2681 assert (master
->str
.tail
== NULL
);
2684 master
->recent
= NULL
;
2688 prefix_list_init_ipv4 ()
2690 install_node (&prefix_node
, config_write_prefix_ipv4
);
2692 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2693 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2694 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2695 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2696 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2697 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2698 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2699 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2700 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2701 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2703 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2704 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2705 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2706 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2707 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2708 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2709 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2710 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2711 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2712 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2713 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2715 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2716 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2717 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2719 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2720 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2722 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2723 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2724 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2725 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2726 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2727 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2728 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2729 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2730 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2731 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2733 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2734 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2735 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2736 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2737 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2738 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2739 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2740 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2741 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2742 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2744 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2745 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2746 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2750 /* Prefix-list node. */
2751 struct cmd_node prefix_ipv6_node
=
2754 "", /* Prefix list has no interface. */
2759 config_write_prefix_ipv6 (struct vty
*vty
)
2761 return config_write_prefix_afi (AFI_IP6
, vty
);
2765 prefix_list_reset_ipv6 ()
2767 struct prefix_list
*plist
;
2768 struct prefix_list
*next
;
2769 struct prefix_master
*master
;
2771 master
= prefix_master_get (AFI_IP6
);
2775 for (plist
= master
->num
.head
; plist
; plist
= next
)
2778 prefix_list_delete (plist
);
2780 for (plist
= master
->str
.head
; plist
; plist
= next
)
2783 prefix_list_delete (plist
);
2786 assert (master
->num
.head
== NULL
);
2787 assert (master
->num
.tail
== NULL
);
2789 assert (master
->str
.head
== NULL
);
2790 assert (master
->str
.tail
== NULL
);
2793 master
->recent
= NULL
;
2797 prefix_list_init_ipv6 ()
2799 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2801 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2802 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2803 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2804 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2805 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2806 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2807 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2808 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2809 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
2810 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
2812 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
2813 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
2814 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
2815 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
2816 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
2817 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
2818 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
2819 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
2820 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
2821 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
2822 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
2824 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
2825 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
2826 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
2828 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
2829 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
2831 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
2832 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
2833 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2834 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2835 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2836 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2837 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2838 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2839 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2840 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2842 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
2843 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
2844 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2845 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2846 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2847 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2848 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2849 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2850 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2851 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2853 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
2854 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
2855 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
2857 #endif /* HAVE_IPV6 */
2862 prefix_list_init_ipv4 ();
2864 prefix_list_init_ipv6 ();
2865 #endif /* HAVE_IPV6 */
2869 prefix_list_reset ()
2871 prefix_list_reset_ipv4 ();
2873 prefix_list_reset_ipv6 ();
2874 #endif /* HAVE_IPV6 */
2875 prefix_list_reset_orf ();