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
, 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
, 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
, 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
, 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
,
659 char *name
, char *seq
, char *typestr
,
660 char *prefix
, char *ge
, 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
,
778 char *name
, char *seq
, char *typestr
,
779 char *prefix
, char *ge
, 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
, 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
, char *name
,
986 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
, char *name
,
1030 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
, char *name
, char *prefix
)
1103 struct prefix_master
*master
;
1104 struct prefix_list
*plist
;
1105 struct prefix_list_entry
*pentry
;
1109 master
= prefix_master_get (afi
);
1113 if (name
== NULL
&& prefix
== NULL
)
1115 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1116 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1119 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1120 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1125 plist
= prefix_list_lookup (afi
, name
);
1128 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1134 ret
= str2prefix (prefix
, &p
);
1137 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1142 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1146 if (prefix_match (&pentry
->prefix
, &p
))
1156 DEFUN (ip_prefix_list
,
1158 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1161 "Name of a prefix list\n"
1162 "Specify packets to reject\n"
1163 "Specify packets to forward\n"
1164 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1165 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1167 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1168 argv
[1], argv
[2], NULL
, NULL
);
1171 DEFUN (ip_prefix_list_ge
,
1172 ip_prefix_list_ge_cmd
,
1173 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1176 "Name of a prefix list\n"
1177 "Specify packets to reject\n"
1178 "Specify packets to forward\n"
1179 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1180 "Minimum prefix length to be matched\n"
1181 "Minimum prefix length\n")
1183 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1184 argv
[2], argv
[3], NULL
);
1187 DEFUN (ip_prefix_list_ge_le
,
1188 ip_prefix_list_ge_le_cmd
,
1189 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1192 "Name of a prefix list\n"
1193 "Specify packets to reject\n"
1194 "Specify packets to forward\n"
1195 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1196 "Minimum prefix length to be matched\n"
1197 "Minimum prefix length\n"
1198 "Maximum prefix length to be matched\n"
1199 "Maximum prefix length\n")
1201 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1202 argv
[2], argv
[3], argv
[4]);
1205 DEFUN (ip_prefix_list_le
,
1206 ip_prefix_list_le_cmd
,
1207 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1210 "Name of a prefix list\n"
1211 "Specify packets to reject\n"
1212 "Specify packets to forward\n"
1213 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1214 "Maximum prefix length to be matched\n"
1215 "Maximum prefix length\n")
1217 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1218 argv
[2], NULL
, argv
[3]);
1221 DEFUN (ip_prefix_list_le_ge
,
1222 ip_prefix_list_le_ge_cmd
,
1223 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1226 "Name of a prefix list\n"
1227 "Specify packets to reject\n"
1228 "Specify packets to forward\n"
1229 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1230 "Maximum prefix length to be matched\n"
1231 "Maximum prefix length\n"
1232 "Minimum prefix length to be matched\n"
1233 "Minimum prefix length\n")
1235 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1236 argv
[2], argv
[4], argv
[3]);
1239 DEFUN (ip_prefix_list_seq
,
1240 ip_prefix_list_seq_cmd
,
1241 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1244 "Name of a prefix list\n"
1245 "sequence number of an entry\n"
1247 "Specify packets to reject\n"
1248 "Specify packets to forward\n"
1249 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1250 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1252 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1253 argv
[3], NULL
, NULL
);
1256 DEFUN (ip_prefix_list_seq_ge
,
1257 ip_prefix_list_seq_ge_cmd
,
1258 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1261 "Name of a prefix list\n"
1262 "sequence number of an entry\n"
1264 "Specify packets to reject\n"
1265 "Specify packets to forward\n"
1266 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1267 "Minimum prefix length to be matched\n"
1268 "Minimum prefix length\n")
1270 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1271 argv
[3], argv
[4], NULL
);
1274 DEFUN (ip_prefix_list_seq_ge_le
,
1275 ip_prefix_list_seq_ge_le_cmd
,
1276 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1279 "Name of a prefix list\n"
1280 "sequence number of an entry\n"
1282 "Specify packets to reject\n"
1283 "Specify packets to forward\n"
1284 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1285 "Minimum prefix length to be matched\n"
1286 "Minimum prefix length\n"
1287 "Maximum prefix length to be matched\n"
1288 "Maximum prefix length\n")
1290 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1291 argv
[3], argv
[4], argv
[5]);
1294 DEFUN (ip_prefix_list_seq_le
,
1295 ip_prefix_list_seq_le_cmd
,
1296 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1299 "Name of a prefix list\n"
1300 "sequence number of an entry\n"
1302 "Specify packets to reject\n"
1303 "Specify packets to forward\n"
1304 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1305 "Maximum prefix length to be matched\n"
1306 "Maximum prefix length\n")
1308 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1309 argv
[3], NULL
, argv
[4]);
1312 DEFUN (ip_prefix_list_seq_le_ge
,
1313 ip_prefix_list_seq_le_ge_cmd
,
1314 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1317 "Name of a prefix list\n"
1318 "sequence number of an entry\n"
1320 "Specify packets to reject\n"
1321 "Specify packets to forward\n"
1322 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1323 "Maximum prefix length to be matched\n"
1324 "Maximum prefix length\n"
1325 "Minimum prefix length to be matched\n"
1326 "Minimum prefix length\n")
1328 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1329 argv
[3], argv
[5], argv
[4]);
1332 DEFUN (no_ip_prefix_list
,
1333 no_ip_prefix_list_cmd
,
1334 "no ip prefix-list WORD",
1338 "Name of a prefix list\n")
1340 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1344 DEFUN (no_ip_prefix_list_prefix
,
1345 no_ip_prefix_list_prefix_cmd
,
1346 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1350 "Name of a prefix list\n"
1351 "Specify packets to reject\n"
1352 "Specify packets to forward\n"
1353 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1354 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1356 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1357 argv
[2], NULL
, NULL
);
1360 DEFUN (no_ip_prefix_list_ge
,
1361 no_ip_prefix_list_ge_cmd
,
1362 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1366 "Name of a prefix list\n"
1367 "Specify packets to reject\n"
1368 "Specify packets to forward\n"
1369 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1370 "Minimum prefix length to be matched\n"
1371 "Minimum prefix length\n")
1373 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1374 argv
[2], argv
[3], NULL
);
1377 DEFUN (no_ip_prefix_list_ge_le
,
1378 no_ip_prefix_list_ge_le_cmd
,
1379 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1383 "Name of a prefix list\n"
1384 "Specify packets to reject\n"
1385 "Specify packets to forward\n"
1386 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1387 "Minimum prefix length to be matched\n"
1388 "Minimum prefix length\n"
1389 "Maximum prefix length to be matched\n"
1390 "Maximum prefix length\n")
1392 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1393 argv
[2], argv
[3], argv
[4]);
1396 DEFUN (no_ip_prefix_list_le
,
1397 no_ip_prefix_list_le_cmd
,
1398 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1402 "Name of a prefix list\n"
1403 "Specify packets to reject\n"
1404 "Specify packets to forward\n"
1405 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1406 "Maximum prefix length to be matched\n"
1407 "Maximum prefix length\n")
1409 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1410 argv
[2], NULL
, argv
[3]);
1413 DEFUN (no_ip_prefix_list_le_ge
,
1414 no_ip_prefix_list_le_ge_cmd
,
1415 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1419 "Name of a prefix list\n"
1420 "Specify packets to reject\n"
1421 "Specify packets to forward\n"
1422 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1423 "Maximum prefix length to be matched\n"
1424 "Maximum prefix length\n"
1425 "Minimum prefix length to be matched\n"
1426 "Minimum prefix length\n")
1428 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1429 argv
[2], argv
[4], argv
[3]);
1432 DEFUN (no_ip_prefix_list_seq
,
1433 no_ip_prefix_list_seq_cmd
,
1434 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1438 "Name of a prefix list\n"
1439 "sequence number of an entry\n"
1441 "Specify packets to reject\n"
1442 "Specify packets to forward\n"
1443 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1444 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1446 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1447 argv
[3], NULL
, NULL
);
1450 DEFUN (no_ip_prefix_list_seq_ge
,
1451 no_ip_prefix_list_seq_ge_cmd
,
1452 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1456 "Name of a prefix list\n"
1457 "sequence number of an entry\n"
1459 "Specify packets to reject\n"
1460 "Specify packets to forward\n"
1461 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1462 "Minimum prefix length to be matched\n"
1463 "Minimum prefix length\n")
1465 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1466 argv
[3], argv
[4], NULL
);
1469 DEFUN (no_ip_prefix_list_seq_ge_le
,
1470 no_ip_prefix_list_seq_ge_le_cmd
,
1471 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1475 "Name of a prefix list\n"
1476 "sequence number of an entry\n"
1478 "Specify packets to reject\n"
1479 "Specify packets to forward\n"
1480 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1481 "Minimum prefix length to be matched\n"
1482 "Minimum prefix length\n"
1483 "Maximum prefix length to be matched\n"
1484 "Maximum prefix length\n")
1486 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1487 argv
[3], argv
[4], argv
[5]);
1490 DEFUN (no_ip_prefix_list_seq_le
,
1491 no_ip_prefix_list_seq_le_cmd
,
1492 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1496 "Name of a prefix list\n"
1497 "sequence number of an entry\n"
1499 "Specify packets to reject\n"
1500 "Specify packets to forward\n"
1501 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1502 "Maximum prefix length to be matched\n"
1503 "Maximum prefix length\n")
1505 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1506 argv
[3], NULL
, argv
[4]);
1509 DEFUN (no_ip_prefix_list_seq_le_ge
,
1510 no_ip_prefix_list_seq_le_ge_cmd
,
1511 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1515 "Name of a prefix list\n"
1516 "sequence number of an entry\n"
1518 "Specify packets to reject\n"
1519 "Specify packets to forward\n"
1520 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1521 "Maximum prefix length to be matched\n"
1522 "Maximum prefix length\n"
1523 "Minimum prefix length to be matched\n"
1524 "Minimum prefix length\n")
1526 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1527 argv
[3], argv
[5], argv
[4]);
1530 DEFUN (ip_prefix_list_sequence_number
,
1531 ip_prefix_list_sequence_number_cmd
,
1532 "ip prefix-list sequence-number",
1535 "Include/exclude sequence numbers in NVGEN\n")
1537 prefix_master_ipv4
.seqnum
= 1;
1541 DEFUN (no_ip_prefix_list_sequence_number
,
1542 no_ip_prefix_list_sequence_number_cmd
,
1543 "no ip prefix-list sequence-number",
1547 "Include/exclude sequence numbers in NVGEN\n")
1549 prefix_master_ipv4
.seqnum
= 0;
1553 DEFUN (ip_prefix_list_description
,
1554 ip_prefix_list_description_cmd
,
1555 "ip prefix-list WORD description .LINE",
1558 "Name of a prefix list\n"
1559 "Prefix-list specific description\n"
1560 "Up to 80 characters describing this prefix-list\n")
1562 struct prefix_list
*plist
;
1566 plist
= prefix_list_get (AFI_IP
, argv
[0]);
1570 XFREE (MTYPE_TMP
, plist
->desc
);
1574 /* Below is description get codes. */
1575 b
= buffer_new (1024);
1576 for (i
= 1; i
< argc
; i
++)
1578 buffer_putstr (b
, argv
[i
]);
1579 buffer_putc (b
, ' ');
1581 buffer_putc (b
, '\0');
1583 plist
->desc
= buffer_getstr (b
);
1590 DEFUN (no_ip_prefix_list_description
,
1591 no_ip_prefix_list_description_cmd
,
1592 "no ip prefix-list WORD description",
1596 "Name of a prefix list\n"
1597 "Prefix-list specific description\n")
1599 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1602 ALIAS (no_ip_prefix_list_description
,
1603 no_ip_prefix_list_description_arg_cmd
,
1604 "no ip prefix-list WORD description .LINE",
1608 "Name of a prefix list\n"
1609 "Prefix-list specific description\n"
1610 "Up to 80 characters describing this prefix-list\n")
1612 DEFUN (show_ip_prefix_list
,
1613 show_ip_prefix_list_cmd
,
1614 "show ip prefix-list",
1619 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1622 DEFUN (show_ip_prefix_list_name
,
1623 show_ip_prefix_list_name_cmd
,
1624 "show ip prefix-list WORD",
1628 "Name of a prefix list\n")
1630 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1633 DEFUN (show_ip_prefix_list_name_seq
,
1634 show_ip_prefix_list_name_seq_cmd
,
1635 "show ip prefix-list WORD seq <1-4294967295>",
1639 "Name of a prefix list\n"
1640 "sequence number of an entry\n"
1641 "Sequence number\n")
1643 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1646 DEFUN (show_ip_prefix_list_prefix
,
1647 show_ip_prefix_list_prefix_cmd
,
1648 "show ip prefix-list WORD A.B.C.D/M",
1652 "Name of a prefix list\n"
1653 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1655 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1658 DEFUN (show_ip_prefix_list_prefix_longer
,
1659 show_ip_prefix_list_prefix_longer_cmd
,
1660 "show ip prefix-list WORD A.B.C.D/M longer",
1664 "Name of a prefix list\n"
1665 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1666 "Lookup longer prefix\n")
1668 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1671 DEFUN (show_ip_prefix_list_prefix_first_match
,
1672 show_ip_prefix_list_prefix_first_match_cmd
,
1673 "show ip prefix-list WORD A.B.C.D/M first-match",
1677 "Name of a prefix list\n"
1678 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1679 "First matched prefix\n")
1681 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1684 DEFUN (show_ip_prefix_list_summary
,
1685 show_ip_prefix_list_summary_cmd
,
1686 "show ip prefix-list summary",
1690 "Summary of prefix lists\n")
1692 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1695 DEFUN (show_ip_prefix_list_summary_name
,
1696 show_ip_prefix_list_summary_name_cmd
,
1697 "show ip prefix-list summary WORD",
1701 "Summary of prefix lists\n"
1702 "Name of a prefix list\n")
1704 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1708 DEFUN (show_ip_prefix_list_detail
,
1709 show_ip_prefix_list_detail_cmd
,
1710 "show ip prefix-list detail",
1714 "Detail of prefix lists\n")
1716 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1719 DEFUN (show_ip_prefix_list_detail_name
,
1720 show_ip_prefix_list_detail_name_cmd
,
1721 "show ip prefix-list detail WORD",
1725 "Detail of prefix lists\n"
1726 "Name of a prefix list\n")
1728 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1731 DEFUN (clear_ip_prefix_list
,
1732 clear_ip_prefix_list_cmd
,
1733 "clear ip prefix-list",
1738 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1741 DEFUN (clear_ip_prefix_list_name
,
1742 clear_ip_prefix_list_name_cmd
,
1743 "clear ip prefix-list WORD",
1747 "Name of a prefix list\n")
1749 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1752 DEFUN (clear_ip_prefix_list_name_prefix
,
1753 clear_ip_prefix_list_name_prefix_cmd
,
1754 "clear ip prefix-list WORD A.B.C.D/M",
1758 "Name of a prefix list\n"
1759 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1761 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1765 DEFUN (ipv6_prefix_list
,
1766 ipv6_prefix_list_cmd
,
1767 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1770 "Name of a prefix list\n"
1771 "Specify packets to reject\n"
1772 "Specify packets to forward\n"
1773 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1774 "Any prefix match. Same as \"::0/0 le 128\"\n")
1776 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
1777 argv
[1], argv
[2], NULL
, NULL
);
1780 DEFUN (ipv6_prefix_list_ge
,
1781 ipv6_prefix_list_ge_cmd
,
1782 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1785 "Name of a prefix list\n"
1786 "Specify packets to reject\n"
1787 "Specify packets to forward\n"
1788 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1789 "Minimum prefix length to be matched\n"
1790 "Minimum prefix length\n")
1792 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1793 argv
[2], argv
[3], NULL
);
1796 DEFUN (ipv6_prefix_list_ge_le
,
1797 ipv6_prefix_list_ge_le_cmd
,
1798 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1801 "Name of a prefix list\n"
1802 "Specify packets to reject\n"
1803 "Specify packets to forward\n"
1804 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1805 "Minimum prefix length to be matched\n"
1806 "Minimum prefix length\n"
1807 "Maximum prefix length to be matched\n"
1808 "Maximum prefix length\n")
1811 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1812 argv
[2], argv
[3], argv
[4]);
1815 DEFUN (ipv6_prefix_list_le
,
1816 ipv6_prefix_list_le_cmd
,
1817 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1820 "Name of a prefix list\n"
1821 "Specify packets to reject\n"
1822 "Specify packets to forward\n"
1823 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1824 "Maximum prefix length to be matched\n"
1825 "Maximum prefix length\n")
1827 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1828 argv
[2], NULL
, argv
[3]);
1831 DEFUN (ipv6_prefix_list_le_ge
,
1832 ipv6_prefix_list_le_ge_cmd
,
1833 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1836 "Name of a prefix list\n"
1837 "Specify packets to reject\n"
1838 "Specify packets to forward\n"
1839 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1840 "Maximum prefix length to be matched\n"
1841 "Maximum prefix length\n"
1842 "Minimum prefix length to be matched\n"
1843 "Minimum prefix length\n")
1845 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1846 argv
[2], argv
[4], argv
[3]);
1849 DEFUN (ipv6_prefix_list_seq
,
1850 ipv6_prefix_list_seq_cmd
,
1851 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
1854 "Name of a prefix list\n"
1855 "sequence number of an entry\n"
1857 "Specify packets to reject\n"
1858 "Specify packets to forward\n"
1859 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1860 "Any prefix match. Same as \"::0/0 le 128\"\n")
1862 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1863 argv
[3], NULL
, NULL
);
1866 DEFUN (ipv6_prefix_list_seq_ge
,
1867 ipv6_prefix_list_seq_ge_cmd
,
1868 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
1871 "Name of a prefix list\n"
1872 "sequence number of an entry\n"
1874 "Specify packets to reject\n"
1875 "Specify packets to forward\n"
1876 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1877 "Minimum prefix length to be matched\n"
1878 "Minimum prefix length\n")
1880 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1881 argv
[3], argv
[4], NULL
);
1884 DEFUN (ipv6_prefix_list_seq_ge_le
,
1885 ipv6_prefix_list_seq_ge_le_cmd
,
1886 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1889 "Name of a prefix list\n"
1890 "sequence number of an entry\n"
1892 "Specify packets to reject\n"
1893 "Specify packets to forward\n"
1894 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1895 "Minimum prefix length to be matched\n"
1896 "Minimum prefix length\n"
1897 "Maximum prefix length to be matched\n"
1898 "Maximum prefix length\n")
1900 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1901 argv
[3], argv
[4], argv
[5]);
1904 DEFUN (ipv6_prefix_list_seq_le
,
1905 ipv6_prefix_list_seq_le_cmd
,
1906 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
1909 "Name of a prefix list\n"
1910 "sequence number of an entry\n"
1912 "Specify packets to reject\n"
1913 "Specify packets to forward\n"
1914 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1915 "Maximum prefix length to be matched\n"
1916 "Maximum prefix length\n")
1918 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1919 argv
[3], NULL
, argv
[4]);
1922 DEFUN (ipv6_prefix_list_seq_le_ge
,
1923 ipv6_prefix_list_seq_le_ge_cmd
,
1924 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1927 "Name of a prefix list\n"
1928 "sequence number of an entry\n"
1930 "Specify packets to reject\n"
1931 "Specify packets to forward\n"
1932 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1933 "Maximum prefix length to be matched\n"
1934 "Maximum prefix length\n"
1935 "Minimum prefix length to be matched\n"
1936 "Minimum prefix length\n")
1938 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1939 argv
[3], argv
[5], argv
[4]);
1942 DEFUN (no_ipv6_prefix_list
,
1943 no_ipv6_prefix_list_cmd
,
1944 "no ipv6 prefix-list WORD",
1948 "Name of a prefix list\n")
1950 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
1954 DEFUN (no_ipv6_prefix_list_prefix
,
1955 no_ipv6_prefix_list_prefix_cmd
,
1956 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1960 "Name of a prefix list\n"
1961 "Specify packets to reject\n"
1962 "Specify packets to forward\n"
1963 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1964 "Any prefix match. Same as \"::0/0 le 128\"\n")
1966 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1967 argv
[2], NULL
, NULL
);
1970 DEFUN (no_ipv6_prefix_list_ge
,
1971 no_ipv6_prefix_list_ge_cmd
,
1972 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1976 "Name of a prefix list\n"
1977 "Specify packets to reject\n"
1978 "Specify packets to forward\n"
1979 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1980 "Minimum prefix length to be matched\n"
1981 "Minimum prefix length\n")
1983 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1984 argv
[2], argv
[3], NULL
);
1987 DEFUN (no_ipv6_prefix_list_ge_le
,
1988 no_ipv6_prefix_list_ge_le_cmd
,
1989 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1993 "Name of a prefix list\n"
1994 "Specify packets to reject\n"
1995 "Specify packets to forward\n"
1996 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1997 "Minimum prefix length to be matched\n"
1998 "Minimum prefix length\n"
1999 "Maximum prefix length to be matched\n"
2000 "Maximum prefix length\n")
2002 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2003 argv
[2], argv
[3], argv
[4]);
2006 DEFUN (no_ipv6_prefix_list_le
,
2007 no_ipv6_prefix_list_le_cmd
,
2008 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2012 "Name of a prefix list\n"
2013 "Specify packets to reject\n"
2014 "Specify packets to forward\n"
2015 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2016 "Maximum prefix length to be matched\n"
2017 "Maximum prefix length\n")
2019 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2020 argv
[2], NULL
, argv
[3]);
2023 DEFUN (no_ipv6_prefix_list_le_ge
,
2024 no_ipv6_prefix_list_le_ge_cmd
,
2025 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2029 "Name of a prefix list\n"
2030 "Specify packets to reject\n"
2031 "Specify packets to forward\n"
2032 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2033 "Maximum prefix length to be matched\n"
2034 "Maximum prefix length\n"
2035 "Minimum prefix length to be matched\n"
2036 "Minimum prefix length\n")
2038 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2039 argv
[2], argv
[4], argv
[3]);
2042 DEFUN (no_ipv6_prefix_list_seq
,
2043 no_ipv6_prefix_list_seq_cmd
,
2044 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2048 "Name of a prefix list\n"
2049 "sequence number of an entry\n"
2051 "Specify packets to reject\n"
2052 "Specify packets to forward\n"
2053 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2054 "Any prefix match. Same as \"::0/0 le 128\"\n")
2056 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2057 argv
[3], NULL
, NULL
);
2060 DEFUN (no_ipv6_prefix_list_seq_ge
,
2061 no_ipv6_prefix_list_seq_ge_cmd
,
2062 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2066 "Name of a prefix list\n"
2067 "sequence number of an entry\n"
2069 "Specify packets to reject\n"
2070 "Specify packets to forward\n"
2071 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2072 "Minimum prefix length to be matched\n"
2073 "Minimum prefix length\n")
2075 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2076 argv
[3], argv
[4], NULL
);
2079 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2080 no_ipv6_prefix_list_seq_ge_le_cmd
,
2081 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2085 "Name of a prefix list\n"
2086 "sequence number of an entry\n"
2088 "Specify packets to reject\n"
2089 "Specify packets to forward\n"
2090 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2091 "Minimum prefix length to be matched\n"
2092 "Minimum prefix length\n"
2093 "Maximum prefix length to be matched\n"
2094 "Maximum prefix length\n")
2096 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2097 argv
[3], argv
[4], argv
[5]);
2100 DEFUN (no_ipv6_prefix_list_seq_le
,
2101 no_ipv6_prefix_list_seq_le_cmd
,
2102 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2106 "Name of a prefix list\n"
2107 "sequence number of an entry\n"
2109 "Specify packets to reject\n"
2110 "Specify packets to forward\n"
2111 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2112 "Maximum prefix length to be matched\n"
2113 "Maximum prefix length\n")
2115 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2116 argv
[3], NULL
, argv
[4]);
2119 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2120 no_ipv6_prefix_list_seq_le_ge_cmd
,
2121 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2125 "Name of a prefix list\n"
2126 "sequence number of an entry\n"
2128 "Specify packets to reject\n"
2129 "Specify packets to forward\n"
2130 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2131 "Maximum prefix length to be matched\n"
2132 "Maximum prefix length\n"
2133 "Minimum prefix length to be matched\n"
2134 "Minimum prefix length\n")
2136 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2137 argv
[3], argv
[5], argv
[4]);
2140 DEFUN (ipv6_prefix_list_sequence_number
,
2141 ipv6_prefix_list_sequence_number_cmd
,
2142 "ipv6 prefix-list sequence-number",
2145 "Include/exclude sequence numbers in NVGEN\n")
2147 prefix_master_ipv6
.seqnum
= 1;
2151 DEFUN (no_ipv6_prefix_list_sequence_number
,
2152 no_ipv6_prefix_list_sequence_number_cmd
,
2153 "no ipv6 prefix-list sequence-number",
2157 "Include/exclude sequence numbers in NVGEN\n")
2159 prefix_master_ipv6
.seqnum
= 0;
2163 DEFUN (ipv6_prefix_list_description
,
2164 ipv6_prefix_list_description_cmd
,
2165 "ipv6 prefix-list WORD description .LINE",
2168 "Name of a prefix list\n"
2169 "Prefix-list specific description\n"
2170 "Up to 80 characters describing this prefix-list\n")
2172 struct prefix_list
*plist
;
2176 plist
= prefix_list_get (AFI_IP6
, argv
[0]);
2180 XFREE (MTYPE_TMP
, plist
->desc
);
2184 /* Below is description get codes. */
2185 b
= buffer_new (1024);
2186 for (i
= 1; i
< argc
; i
++)
2188 buffer_putstr (b
, argv
[i
]);
2189 buffer_putc (b
, ' ');
2191 buffer_putc (b
, '\0');
2193 plist
->desc
= buffer_getstr (b
);
2200 DEFUN (no_ipv6_prefix_list_description
,
2201 no_ipv6_prefix_list_description_cmd
,
2202 "no ipv6 prefix-list WORD description",
2206 "Name of a prefix list\n"
2207 "Prefix-list specific description\n")
2209 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2212 ALIAS (no_ipv6_prefix_list_description
,
2213 no_ipv6_prefix_list_description_arg_cmd
,
2214 "no ipv6 prefix-list WORD description .LINE",
2218 "Name of a prefix list\n"
2219 "Prefix-list specific description\n"
2220 "Up to 80 characters describing this prefix-list\n")
2222 DEFUN (show_ipv6_prefix_list
,
2223 show_ipv6_prefix_list_cmd
,
2224 "show ipv6 prefix-list",
2229 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2232 DEFUN (show_ipv6_prefix_list_name
,
2233 show_ipv6_prefix_list_name_cmd
,
2234 "show ipv6 prefix-list WORD",
2238 "Name of a prefix list\n")
2240 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2243 DEFUN (show_ipv6_prefix_list_name_seq
,
2244 show_ipv6_prefix_list_name_seq_cmd
,
2245 "show ipv6 prefix-list WORD seq <1-4294967295>",
2249 "Name of a prefix list\n"
2250 "sequence number of an entry\n"
2251 "Sequence number\n")
2253 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2256 DEFUN (show_ipv6_prefix_list_prefix
,
2257 show_ipv6_prefix_list_prefix_cmd
,
2258 "show ipv6 prefix-list WORD X:X::X:X/M",
2262 "Name of a prefix list\n"
2263 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2265 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2268 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2269 show_ipv6_prefix_list_prefix_longer_cmd
,
2270 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2274 "Name of a prefix list\n"
2275 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2276 "Lookup longer prefix\n")
2278 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2281 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2282 show_ipv6_prefix_list_prefix_first_match_cmd
,
2283 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2287 "Name of a prefix list\n"
2288 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2289 "First matched prefix\n")
2291 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2294 DEFUN (show_ipv6_prefix_list_summary
,
2295 show_ipv6_prefix_list_summary_cmd
,
2296 "show ipv6 prefix-list summary",
2300 "Summary of prefix lists\n")
2302 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2305 DEFUN (show_ipv6_prefix_list_summary_name
,
2306 show_ipv6_prefix_list_summary_name_cmd
,
2307 "show ipv6 prefix-list summary WORD",
2311 "Summary of prefix lists\n"
2312 "Name of a prefix list\n")
2314 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2317 DEFUN (show_ipv6_prefix_list_detail
,
2318 show_ipv6_prefix_list_detail_cmd
,
2319 "show ipv6 prefix-list detail",
2323 "Detail of prefix lists\n")
2325 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2328 DEFUN (show_ipv6_prefix_list_detail_name
,
2329 show_ipv6_prefix_list_detail_name_cmd
,
2330 "show ipv6 prefix-list detail WORD",
2334 "Detail of prefix lists\n"
2335 "Name of a prefix list\n")
2337 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2340 DEFUN (clear_ipv6_prefix_list
,
2341 clear_ipv6_prefix_list_cmd
,
2342 "clear ipv6 prefix-list",
2347 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2350 DEFUN (clear_ipv6_prefix_list_name
,
2351 clear_ipv6_prefix_list_name_cmd
,
2352 "clear ipv6 prefix-list WORD",
2356 "Name of a prefix list\n")
2358 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2361 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2362 clear_ipv6_prefix_list_name_prefix_cmd
,
2363 "clear ipv6 prefix-list WORD X:X::X:X/M",
2367 "Name of a prefix list\n"
2368 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2370 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2372 #endif /* HAVE_IPV6 */
2374 /* Configuration write function. */
2376 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2378 struct prefix_list
*plist
;
2379 struct prefix_list_entry
*pentry
;
2380 struct prefix_master
*master
;
2383 master
= prefix_master_get (afi
);
2387 if (! master
->seqnum
)
2389 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2390 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2391 vty_out (vty
, "!%s", VTY_NEWLINE
);
2394 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2398 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2399 afi
== AFI_IP
? "" : "v6",
2400 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2404 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2406 vty_out (vty
, "ip%s prefix-list %s ",
2407 afi
== AFI_IP
? "" : "v6",
2411 vty_out (vty
, "seq %d ", pentry
->seq
);
2413 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2416 vty_out (vty
, "any");
2419 struct prefix
*p
= &pentry
->prefix
;
2422 vty_out (vty
, "%s/%d",
2423 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2427 vty_out (vty
, " ge %d", pentry
->ge
);
2429 vty_out (vty
, " le %d", pentry
->le
);
2431 vty_out (vty
, "%s", VTY_NEWLINE
);
2434 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2437 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2441 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2442 afi
== AFI_IP
? "" : "v6",
2443 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2447 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2449 vty_out (vty
, "ip%s prefix-list %s ",
2450 afi
== AFI_IP
? "" : "v6",
2454 vty_out (vty
, "seq %d ", pentry
->seq
);
2456 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2459 vty_out (vty
, " any");
2462 struct prefix
*p
= &pentry
->prefix
;
2465 vty_out (vty
, " %s/%d",
2466 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2470 vty_out (vty
, " ge %d", pentry
->ge
);
2472 vty_out (vty
, " le %d", pentry
->le
);
2474 vty_out (vty
, "%s", VTY_NEWLINE
);
2483 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2484 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2486 struct prefix_list_entry
*pentry
;
2491 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2493 u_char flag
= init_flag
;
2494 struct prefix
*p
= &pentry
->prefix
;
2496 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2497 permit_flag
: deny_flag
);
2498 stream_putc (s
, flag
);
2499 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2500 stream_putc (s
, (u_char
)pentry
->ge
);
2501 stream_putc (s
, (u_char
)pentry
->le
);
2502 stream_put_prefix (s
, p
);
2509 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2510 int permit
, int set
)
2512 struct prefix_list
*plist
;
2513 struct prefix_list_entry
*pentry
;
2515 /* ge and le value check */
2516 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2518 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2520 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2523 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2526 plist
= prefix_list_get (AFI_ORF_PREFIX
, name
);
2532 pentry
= prefix_list_entry_make (&orfp
->p
,
2533 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2534 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2536 if (prefix_entry_dup_check (plist
, pentry
))
2538 prefix_list_entry_free (pentry
);
2542 prefix_list_entry_add (plist
, pentry
);
2546 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2547 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2548 orfp
->seq
, orfp
->le
, orfp
->ge
);
2553 prefix_list_entry_delete (plist
, pentry
, 1);
2560 prefix_bgp_orf_remove_all (char *name
)
2562 struct prefix_list
*plist
;
2564 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2566 prefix_list_delete (plist
);
2569 /* return prefix count */
2571 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
)
2573 struct prefix_list
*plist
;
2574 struct prefix_list_entry
*pentry
;
2576 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2581 return plist
->count
;
2583 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2584 afi
== AFI_IP
? "" : "v6",
2585 plist
->name
, plist
->count
, VTY_NEWLINE
);
2587 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2589 struct prefix
*p
= &pentry
->prefix
;
2592 vty_out (vty
, " seq %d %s %s/%d", pentry
->seq
,
2593 prefix_list_type_str (pentry
),
2594 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2598 vty_out (vty
, " ge %d", pentry
->ge
);
2600 vty_out (vty
, " le %d", pentry
->le
);
2602 vty_out (vty
, "%s", VTY_NEWLINE
);
2604 return plist
->count
;
2608 prefix_list_reset_orf ()
2610 struct prefix_list
*plist
;
2611 struct prefix_list
*next
;
2612 struct prefix_master
*master
;
2614 master
= prefix_master_get (AFI_ORF_PREFIX
);
2618 for (plist
= master
->num
.head
; plist
; plist
= next
)
2621 prefix_list_delete (plist
);
2623 for (plist
= master
->str
.head
; plist
; plist
= next
)
2626 prefix_list_delete (plist
);
2629 assert (master
->num
.head
== NULL
);
2630 assert (master
->num
.tail
== NULL
);
2632 assert (master
->str
.head
== NULL
);
2633 assert (master
->str
.tail
== NULL
);
2636 master
->recent
= NULL
;
2640 /* Prefix-list node. */
2641 struct cmd_node prefix_node
=
2644 "", /* Prefix list has no interface. */
2649 config_write_prefix_ipv4 (struct vty
*vty
)
2651 return config_write_prefix_afi (AFI_IP
, vty
);
2655 prefix_list_reset_ipv4 ()
2657 struct prefix_list
*plist
;
2658 struct prefix_list
*next
;
2659 struct prefix_master
*master
;
2661 master
= prefix_master_get (AFI_IP
);
2665 for (plist
= master
->num
.head
; plist
; plist
= next
)
2668 prefix_list_delete (plist
);
2670 for (plist
= master
->str
.head
; plist
; plist
= next
)
2673 prefix_list_delete (plist
);
2676 assert (master
->num
.head
== NULL
);
2677 assert (master
->num
.tail
== NULL
);
2679 assert (master
->str
.head
== NULL
);
2680 assert (master
->str
.tail
== NULL
);
2683 master
->recent
= NULL
;
2687 prefix_list_init_ipv4 ()
2689 install_node (&prefix_node
, config_write_prefix_ipv4
);
2691 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2692 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2693 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2694 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2695 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2696 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2697 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2698 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2699 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2700 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2702 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2703 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2704 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2705 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2706 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2707 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2708 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2709 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2710 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2711 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2712 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2714 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2715 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2716 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2718 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2719 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2721 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2722 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2723 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2724 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2725 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2726 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2727 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2728 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2729 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2730 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2732 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2733 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2734 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2735 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2736 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2737 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2738 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2739 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2740 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2741 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2743 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2744 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2745 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2749 /* Prefix-list node. */
2750 struct cmd_node prefix_ipv6_node
=
2753 "", /* Prefix list has no interface. */
2758 config_write_prefix_ipv6 (struct vty
*vty
)
2760 return config_write_prefix_afi (AFI_IP6
, vty
);
2764 prefix_list_reset_ipv6 ()
2766 struct prefix_list
*plist
;
2767 struct prefix_list
*next
;
2768 struct prefix_master
*master
;
2770 master
= prefix_master_get (AFI_IP6
);
2774 for (plist
= master
->num
.head
; plist
; plist
= next
)
2777 prefix_list_delete (plist
);
2779 for (plist
= master
->str
.head
; plist
; plist
= next
)
2782 prefix_list_delete (plist
);
2785 assert (master
->num
.head
== NULL
);
2786 assert (master
->num
.tail
== NULL
);
2788 assert (master
->str
.head
== NULL
);
2789 assert (master
->str
.tail
== NULL
);
2792 master
->recent
= NULL
;
2796 prefix_list_init_ipv6 ()
2798 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2800 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2801 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2802 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2803 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2804 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2805 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2806 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2807 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2808 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
2809 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
2811 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
2812 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
2813 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
2814 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
2815 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
2816 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
2817 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
2818 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
2819 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
2820 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
2821 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
2823 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
2824 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
2825 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
2827 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
2828 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
2830 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
2831 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
2832 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2833 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2834 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2835 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2836 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2837 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2838 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2839 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2841 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
2842 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
2843 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2844 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2845 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2846 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2847 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2848 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2849 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2850 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2852 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
2853 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
2854 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
2856 #endif /* HAVE_IPV6 */
2861 prefix_list_init_ipv4 ();
2863 prefix_list_init_ipv6 ();
2864 #endif /* HAVE_IPV6 */
2868 prefix_list_reset ()
2870 prefix_list_reset_ipv4 ();
2872 prefix_list_reset_ipv6 ();
2873 #endif /* HAVE_IPV6 */
2874 prefix_list_reset_orf ();