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. */
75 void (*add_hook
) (struct prefix_list
*);
77 /* Hook function which is executed when prefix_list is deleted. */
78 void (*delete_hook
) (struct prefix_list
*);
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
*
153 prefix_list_new (void)
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 (void)
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
) (NULL
);
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
))
589 static void __attribute__ ((unused
))
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
;
1565 plist
= prefix_list_get (AFI_IP
, argv
[0]);
1569 XFREE (MTYPE_TMP
, plist
->desc
);
1572 plist
->desc
= argv_concat(argv
, argc
, 1);
1577 DEFUN (no_ip_prefix_list_description
,
1578 no_ip_prefix_list_description_cmd
,
1579 "no ip prefix-list WORD description",
1583 "Name of a prefix list\n"
1584 "Prefix-list specific description\n")
1586 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1589 ALIAS (no_ip_prefix_list_description
,
1590 no_ip_prefix_list_description_arg_cmd
,
1591 "no ip prefix-list WORD description .LINE",
1595 "Name of a prefix list\n"
1596 "Prefix-list specific description\n"
1597 "Up to 80 characters describing this prefix-list\n")
1599 DEFUN (show_ip_prefix_list
,
1600 show_ip_prefix_list_cmd
,
1601 "show ip prefix-list",
1606 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1609 DEFUN (show_ip_prefix_list_name
,
1610 show_ip_prefix_list_name_cmd
,
1611 "show ip prefix-list WORD",
1615 "Name of a prefix list\n")
1617 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1620 DEFUN (show_ip_prefix_list_name_seq
,
1621 show_ip_prefix_list_name_seq_cmd
,
1622 "show ip prefix-list WORD seq <1-4294967295>",
1626 "Name of a prefix list\n"
1627 "sequence number of an entry\n"
1628 "Sequence number\n")
1630 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1633 DEFUN (show_ip_prefix_list_prefix
,
1634 show_ip_prefix_list_prefix_cmd
,
1635 "show ip prefix-list WORD A.B.C.D/M",
1639 "Name of a prefix list\n"
1640 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1642 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1645 DEFUN (show_ip_prefix_list_prefix_longer
,
1646 show_ip_prefix_list_prefix_longer_cmd
,
1647 "show ip prefix-list WORD A.B.C.D/M longer",
1651 "Name of a prefix list\n"
1652 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1653 "Lookup longer prefix\n")
1655 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1658 DEFUN (show_ip_prefix_list_prefix_first_match
,
1659 show_ip_prefix_list_prefix_first_match_cmd
,
1660 "show ip prefix-list WORD A.B.C.D/M first-match",
1664 "Name of a prefix list\n"
1665 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1666 "First matched prefix\n")
1668 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1671 DEFUN (show_ip_prefix_list_summary
,
1672 show_ip_prefix_list_summary_cmd
,
1673 "show ip prefix-list summary",
1677 "Summary of prefix lists\n")
1679 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1682 DEFUN (show_ip_prefix_list_summary_name
,
1683 show_ip_prefix_list_summary_name_cmd
,
1684 "show ip prefix-list summary WORD",
1688 "Summary of prefix lists\n"
1689 "Name of a prefix list\n")
1691 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1695 DEFUN (show_ip_prefix_list_detail
,
1696 show_ip_prefix_list_detail_cmd
,
1697 "show ip prefix-list detail",
1701 "Detail of prefix lists\n")
1703 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1706 DEFUN (show_ip_prefix_list_detail_name
,
1707 show_ip_prefix_list_detail_name_cmd
,
1708 "show ip prefix-list detail WORD",
1712 "Detail of prefix lists\n"
1713 "Name of a prefix list\n")
1715 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1718 DEFUN (clear_ip_prefix_list
,
1719 clear_ip_prefix_list_cmd
,
1720 "clear ip prefix-list",
1725 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1728 DEFUN (clear_ip_prefix_list_name
,
1729 clear_ip_prefix_list_name_cmd
,
1730 "clear ip prefix-list WORD",
1734 "Name of a prefix list\n")
1736 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1739 DEFUN (clear_ip_prefix_list_name_prefix
,
1740 clear_ip_prefix_list_name_prefix_cmd
,
1741 "clear ip prefix-list WORD A.B.C.D/M",
1745 "Name of a prefix list\n"
1746 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1748 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1752 DEFUN (ipv6_prefix_list
,
1753 ipv6_prefix_list_cmd
,
1754 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1757 "Name of a prefix list\n"
1758 "Specify packets to reject\n"
1759 "Specify packets to forward\n"
1760 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1761 "Any prefix match. Same as \"::0/0 le 128\"\n")
1763 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
1764 argv
[1], argv
[2], NULL
, NULL
);
1767 DEFUN (ipv6_prefix_list_ge
,
1768 ipv6_prefix_list_ge_cmd
,
1769 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1772 "Name of a prefix list\n"
1773 "Specify packets to reject\n"
1774 "Specify packets to forward\n"
1775 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1776 "Minimum prefix length to be matched\n"
1777 "Minimum prefix length\n")
1779 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1780 argv
[2], argv
[3], NULL
);
1783 DEFUN (ipv6_prefix_list_ge_le
,
1784 ipv6_prefix_list_ge_le_cmd
,
1785 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1788 "Name of a prefix list\n"
1789 "Specify packets to reject\n"
1790 "Specify packets to forward\n"
1791 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1792 "Minimum prefix length to be matched\n"
1793 "Minimum prefix length\n"
1794 "Maximum prefix length to be matched\n"
1795 "Maximum prefix length\n")
1798 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1799 argv
[2], argv
[3], argv
[4]);
1802 DEFUN (ipv6_prefix_list_le
,
1803 ipv6_prefix_list_le_cmd
,
1804 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1807 "Name of a prefix list\n"
1808 "Specify packets to reject\n"
1809 "Specify packets to forward\n"
1810 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1811 "Maximum prefix length to be matched\n"
1812 "Maximum prefix length\n")
1814 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1815 argv
[2], NULL
, argv
[3]);
1818 DEFUN (ipv6_prefix_list_le_ge
,
1819 ipv6_prefix_list_le_ge_cmd
,
1820 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1823 "Name of a prefix list\n"
1824 "Specify packets to reject\n"
1825 "Specify packets to forward\n"
1826 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1827 "Maximum prefix length to be matched\n"
1828 "Maximum prefix length\n"
1829 "Minimum prefix length to be matched\n"
1830 "Minimum prefix length\n")
1832 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1833 argv
[2], argv
[4], argv
[3]);
1836 DEFUN (ipv6_prefix_list_seq
,
1837 ipv6_prefix_list_seq_cmd
,
1838 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
1841 "Name of a prefix list\n"
1842 "sequence number of an entry\n"
1844 "Specify packets to reject\n"
1845 "Specify packets to forward\n"
1846 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1847 "Any prefix match. Same as \"::0/0 le 128\"\n")
1849 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1850 argv
[3], NULL
, NULL
);
1853 DEFUN (ipv6_prefix_list_seq_ge
,
1854 ipv6_prefix_list_seq_ge_cmd
,
1855 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
1858 "Name of a prefix list\n"
1859 "sequence number of an entry\n"
1861 "Specify packets to reject\n"
1862 "Specify packets to forward\n"
1863 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1864 "Minimum prefix length to be matched\n"
1865 "Minimum prefix length\n")
1867 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1868 argv
[3], argv
[4], NULL
);
1871 DEFUN (ipv6_prefix_list_seq_ge_le
,
1872 ipv6_prefix_list_seq_ge_le_cmd
,
1873 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1876 "Name of a prefix list\n"
1877 "sequence number of an entry\n"
1879 "Specify packets to reject\n"
1880 "Specify packets to forward\n"
1881 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1882 "Minimum prefix length to be matched\n"
1883 "Minimum prefix length\n"
1884 "Maximum prefix length to be matched\n"
1885 "Maximum prefix length\n")
1887 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1888 argv
[3], argv
[4], argv
[5]);
1891 DEFUN (ipv6_prefix_list_seq_le
,
1892 ipv6_prefix_list_seq_le_cmd
,
1893 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
1896 "Name of a prefix list\n"
1897 "sequence number of an entry\n"
1899 "Specify packets to reject\n"
1900 "Specify packets to forward\n"
1901 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1902 "Maximum prefix length to be matched\n"
1903 "Maximum prefix length\n")
1905 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1906 argv
[3], NULL
, argv
[4]);
1909 DEFUN (ipv6_prefix_list_seq_le_ge
,
1910 ipv6_prefix_list_seq_le_ge_cmd
,
1911 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1914 "Name of a prefix list\n"
1915 "sequence number of an entry\n"
1917 "Specify packets to reject\n"
1918 "Specify packets to forward\n"
1919 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1920 "Maximum prefix length to be matched\n"
1921 "Maximum prefix length\n"
1922 "Minimum prefix length to be matched\n"
1923 "Minimum prefix length\n")
1925 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1926 argv
[3], argv
[5], argv
[4]);
1929 DEFUN (no_ipv6_prefix_list
,
1930 no_ipv6_prefix_list_cmd
,
1931 "no ipv6 prefix-list WORD",
1935 "Name of a prefix list\n")
1937 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
1941 DEFUN (no_ipv6_prefix_list_prefix
,
1942 no_ipv6_prefix_list_prefix_cmd
,
1943 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1947 "Name of a prefix list\n"
1948 "Specify packets to reject\n"
1949 "Specify packets to forward\n"
1950 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1951 "Any prefix match. Same as \"::0/0 le 128\"\n")
1953 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1954 argv
[2], NULL
, NULL
);
1957 DEFUN (no_ipv6_prefix_list_ge
,
1958 no_ipv6_prefix_list_ge_cmd
,
1959 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1963 "Name of a prefix list\n"
1964 "Specify packets to reject\n"
1965 "Specify packets to forward\n"
1966 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1967 "Minimum prefix length to be matched\n"
1968 "Minimum prefix length\n")
1970 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1971 argv
[2], argv
[3], NULL
);
1974 DEFUN (no_ipv6_prefix_list_ge_le
,
1975 no_ipv6_prefix_list_ge_le_cmd
,
1976 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1980 "Name of a prefix list\n"
1981 "Specify packets to reject\n"
1982 "Specify packets to forward\n"
1983 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1984 "Minimum prefix length to be matched\n"
1985 "Minimum prefix length\n"
1986 "Maximum prefix length to be matched\n"
1987 "Maximum prefix length\n")
1989 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1990 argv
[2], argv
[3], argv
[4]);
1993 DEFUN (no_ipv6_prefix_list_le
,
1994 no_ipv6_prefix_list_le_cmd
,
1995 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1999 "Name of a prefix list\n"
2000 "Specify packets to reject\n"
2001 "Specify packets to forward\n"
2002 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2003 "Maximum prefix length to be matched\n"
2004 "Maximum prefix length\n")
2006 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2007 argv
[2], NULL
, argv
[3]);
2010 DEFUN (no_ipv6_prefix_list_le_ge
,
2011 no_ipv6_prefix_list_le_ge_cmd
,
2012 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2016 "Name of a prefix list\n"
2017 "Specify packets to reject\n"
2018 "Specify packets to forward\n"
2019 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2020 "Maximum prefix length to be matched\n"
2021 "Maximum prefix length\n"
2022 "Minimum prefix length to be matched\n"
2023 "Minimum prefix length\n")
2025 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2026 argv
[2], argv
[4], argv
[3]);
2029 DEFUN (no_ipv6_prefix_list_seq
,
2030 no_ipv6_prefix_list_seq_cmd
,
2031 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2035 "Name of a prefix list\n"
2036 "sequence number of an entry\n"
2038 "Specify packets to reject\n"
2039 "Specify packets to forward\n"
2040 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2041 "Any prefix match. Same as \"::0/0 le 128\"\n")
2043 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2044 argv
[3], NULL
, NULL
);
2047 DEFUN (no_ipv6_prefix_list_seq_ge
,
2048 no_ipv6_prefix_list_seq_ge_cmd
,
2049 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2053 "Name of a prefix list\n"
2054 "sequence number of an entry\n"
2056 "Specify packets to reject\n"
2057 "Specify packets to forward\n"
2058 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2059 "Minimum prefix length to be matched\n"
2060 "Minimum prefix length\n")
2062 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2063 argv
[3], argv
[4], NULL
);
2066 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2067 no_ipv6_prefix_list_seq_ge_le_cmd
,
2068 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2072 "Name of a prefix list\n"
2073 "sequence number of an entry\n"
2075 "Specify packets to reject\n"
2076 "Specify packets to forward\n"
2077 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2078 "Minimum prefix length to be matched\n"
2079 "Minimum prefix length\n"
2080 "Maximum prefix length to be matched\n"
2081 "Maximum prefix length\n")
2083 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2084 argv
[3], argv
[4], argv
[5]);
2087 DEFUN (no_ipv6_prefix_list_seq_le
,
2088 no_ipv6_prefix_list_seq_le_cmd
,
2089 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2093 "Name of a prefix list\n"
2094 "sequence number of an entry\n"
2096 "Specify packets to reject\n"
2097 "Specify packets to forward\n"
2098 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2099 "Maximum prefix length to be matched\n"
2100 "Maximum prefix length\n")
2102 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2103 argv
[3], NULL
, argv
[4]);
2106 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2107 no_ipv6_prefix_list_seq_le_ge_cmd
,
2108 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2112 "Name of a prefix list\n"
2113 "sequence number of an entry\n"
2115 "Specify packets to reject\n"
2116 "Specify packets to forward\n"
2117 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2118 "Maximum prefix length to be matched\n"
2119 "Maximum prefix length\n"
2120 "Minimum prefix length to be matched\n"
2121 "Minimum prefix length\n")
2123 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2124 argv
[3], argv
[5], argv
[4]);
2127 DEFUN (ipv6_prefix_list_sequence_number
,
2128 ipv6_prefix_list_sequence_number_cmd
,
2129 "ipv6 prefix-list sequence-number",
2132 "Include/exclude sequence numbers in NVGEN\n")
2134 prefix_master_ipv6
.seqnum
= 1;
2138 DEFUN (no_ipv6_prefix_list_sequence_number
,
2139 no_ipv6_prefix_list_sequence_number_cmd
,
2140 "no ipv6 prefix-list sequence-number",
2144 "Include/exclude sequence numbers in NVGEN\n")
2146 prefix_master_ipv6
.seqnum
= 0;
2150 DEFUN (ipv6_prefix_list_description
,
2151 ipv6_prefix_list_description_cmd
,
2152 "ipv6 prefix-list WORD description .LINE",
2155 "Name of a prefix list\n"
2156 "Prefix-list specific description\n"
2157 "Up to 80 characters describing this prefix-list\n")
2159 struct prefix_list
*plist
;
2161 plist
= prefix_list_get (AFI_IP6
, argv
[0]);
2165 XFREE (MTYPE_TMP
, plist
->desc
);
2168 plist
->desc
= argv_concat(argv
, argc
, 1);
2173 DEFUN (no_ipv6_prefix_list_description
,
2174 no_ipv6_prefix_list_description_cmd
,
2175 "no ipv6 prefix-list WORD description",
2179 "Name of a prefix list\n"
2180 "Prefix-list specific description\n")
2182 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2185 ALIAS (no_ipv6_prefix_list_description
,
2186 no_ipv6_prefix_list_description_arg_cmd
,
2187 "no ipv6 prefix-list WORD description .LINE",
2191 "Name of a prefix list\n"
2192 "Prefix-list specific description\n"
2193 "Up to 80 characters describing this prefix-list\n")
2195 DEFUN (show_ipv6_prefix_list
,
2196 show_ipv6_prefix_list_cmd
,
2197 "show ipv6 prefix-list",
2202 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2205 DEFUN (show_ipv6_prefix_list_name
,
2206 show_ipv6_prefix_list_name_cmd
,
2207 "show ipv6 prefix-list WORD",
2211 "Name of a prefix list\n")
2213 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2216 DEFUN (show_ipv6_prefix_list_name_seq
,
2217 show_ipv6_prefix_list_name_seq_cmd
,
2218 "show ipv6 prefix-list WORD seq <1-4294967295>",
2222 "Name of a prefix list\n"
2223 "sequence number of an entry\n"
2224 "Sequence number\n")
2226 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2229 DEFUN (show_ipv6_prefix_list_prefix
,
2230 show_ipv6_prefix_list_prefix_cmd
,
2231 "show ipv6 prefix-list WORD X:X::X:X/M",
2235 "Name of a prefix list\n"
2236 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2238 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2241 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2242 show_ipv6_prefix_list_prefix_longer_cmd
,
2243 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2247 "Name of a prefix list\n"
2248 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2249 "Lookup longer prefix\n")
2251 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2254 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2255 show_ipv6_prefix_list_prefix_first_match_cmd
,
2256 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2260 "Name of a prefix list\n"
2261 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2262 "First matched prefix\n")
2264 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2267 DEFUN (show_ipv6_prefix_list_summary
,
2268 show_ipv6_prefix_list_summary_cmd
,
2269 "show ipv6 prefix-list summary",
2273 "Summary of prefix lists\n")
2275 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2278 DEFUN (show_ipv6_prefix_list_summary_name
,
2279 show_ipv6_prefix_list_summary_name_cmd
,
2280 "show ipv6 prefix-list summary WORD",
2284 "Summary of prefix lists\n"
2285 "Name of a prefix list\n")
2287 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2290 DEFUN (show_ipv6_prefix_list_detail
,
2291 show_ipv6_prefix_list_detail_cmd
,
2292 "show ipv6 prefix-list detail",
2296 "Detail of prefix lists\n")
2298 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2301 DEFUN (show_ipv6_prefix_list_detail_name
,
2302 show_ipv6_prefix_list_detail_name_cmd
,
2303 "show ipv6 prefix-list detail WORD",
2307 "Detail of prefix lists\n"
2308 "Name of a prefix list\n")
2310 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2313 DEFUN (clear_ipv6_prefix_list
,
2314 clear_ipv6_prefix_list_cmd
,
2315 "clear ipv6 prefix-list",
2320 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2323 DEFUN (clear_ipv6_prefix_list_name
,
2324 clear_ipv6_prefix_list_name_cmd
,
2325 "clear ipv6 prefix-list WORD",
2329 "Name of a prefix list\n")
2331 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2334 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2335 clear_ipv6_prefix_list_name_prefix_cmd
,
2336 "clear ipv6 prefix-list WORD X:X::X:X/M",
2340 "Name of a prefix list\n"
2341 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2343 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2345 #endif /* HAVE_IPV6 */
2347 /* Configuration write function. */
2349 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2351 struct prefix_list
*plist
;
2352 struct prefix_list_entry
*pentry
;
2353 struct prefix_master
*master
;
2356 master
= prefix_master_get (afi
);
2360 if (! master
->seqnum
)
2362 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2363 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2364 vty_out (vty
, "!%s", VTY_NEWLINE
);
2367 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2371 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2372 afi
== AFI_IP
? "" : "v6",
2373 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2377 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2379 vty_out (vty
, "ip%s prefix-list %s ",
2380 afi
== AFI_IP
? "" : "v6",
2384 vty_out (vty
, "seq %d ", pentry
->seq
);
2386 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2389 vty_out (vty
, "any");
2392 struct prefix
*p
= &pentry
->prefix
;
2395 vty_out (vty
, "%s/%d",
2396 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2400 vty_out (vty
, " ge %d", pentry
->ge
);
2402 vty_out (vty
, " le %d", pentry
->le
);
2404 vty_out (vty
, "%s", VTY_NEWLINE
);
2407 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2410 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2414 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2415 afi
== AFI_IP
? "" : "v6",
2416 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2420 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2422 vty_out (vty
, "ip%s prefix-list %s ",
2423 afi
== AFI_IP
? "" : "v6",
2427 vty_out (vty
, "seq %d ", pentry
->seq
);
2429 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2432 vty_out (vty
, " any");
2435 struct prefix
*p
= &pentry
->prefix
;
2438 vty_out (vty
, " %s/%d",
2439 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2443 vty_out (vty
, " ge %d", pentry
->ge
);
2445 vty_out (vty
, " le %d", pentry
->le
);
2447 vty_out (vty
, "%s", VTY_NEWLINE
);
2456 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2457 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2459 struct prefix_list_entry
*pentry
;
2464 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2466 u_char flag
= init_flag
;
2467 struct prefix
*p
= &pentry
->prefix
;
2469 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2470 permit_flag
: deny_flag
);
2471 stream_putc (s
, flag
);
2472 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2473 stream_putc (s
, (u_char
)pentry
->ge
);
2474 stream_putc (s
, (u_char
)pentry
->le
);
2475 stream_put_prefix (s
, p
);
2482 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2483 int permit
, int set
)
2485 struct prefix_list
*plist
;
2486 struct prefix_list_entry
*pentry
;
2488 /* ge and le value check */
2489 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2491 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2493 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2496 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2499 plist
= prefix_list_get (AFI_ORF_PREFIX
, name
);
2505 pentry
= prefix_list_entry_make (&orfp
->p
,
2506 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2507 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2509 if (prefix_entry_dup_check (plist
, pentry
))
2511 prefix_list_entry_free (pentry
);
2515 prefix_list_entry_add (plist
, pentry
);
2519 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2520 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2521 orfp
->seq
, orfp
->le
, orfp
->ge
);
2526 prefix_list_entry_delete (plist
, pentry
, 1);
2533 prefix_bgp_orf_remove_all (char *name
)
2535 struct prefix_list
*plist
;
2537 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2539 prefix_list_delete (plist
);
2542 /* return prefix count */
2544 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
)
2546 struct prefix_list
*plist
;
2547 struct prefix_list_entry
*pentry
;
2549 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2554 return plist
->count
;
2556 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2557 afi
== AFI_IP
? "" : "v6",
2558 plist
->name
, plist
->count
, VTY_NEWLINE
);
2560 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2562 struct prefix
*p
= &pentry
->prefix
;
2565 vty_out (vty
, " seq %d %s %s/%d", pentry
->seq
,
2566 prefix_list_type_str (pentry
),
2567 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2571 vty_out (vty
, " ge %d", pentry
->ge
);
2573 vty_out (vty
, " le %d", pentry
->le
);
2575 vty_out (vty
, "%s", VTY_NEWLINE
);
2577 return plist
->count
;
2581 prefix_list_reset_orf (void)
2583 struct prefix_list
*plist
;
2584 struct prefix_list
*next
;
2585 struct prefix_master
*master
;
2587 master
= prefix_master_get (AFI_ORF_PREFIX
);
2591 for (plist
= master
->num
.head
; plist
; plist
= next
)
2594 prefix_list_delete (plist
);
2596 for (plist
= master
->str
.head
; plist
; plist
= next
)
2599 prefix_list_delete (plist
);
2602 assert (master
->num
.head
== NULL
);
2603 assert (master
->num
.tail
== NULL
);
2605 assert (master
->str
.head
== NULL
);
2606 assert (master
->str
.tail
== NULL
);
2609 master
->recent
= NULL
;
2613 /* Prefix-list node. */
2614 struct cmd_node prefix_node
=
2617 "", /* Prefix list has no interface. */
2622 config_write_prefix_ipv4 (struct vty
*vty
)
2624 return config_write_prefix_afi (AFI_IP
, vty
);
2628 prefix_list_reset_ipv4 (void)
2630 struct prefix_list
*plist
;
2631 struct prefix_list
*next
;
2632 struct prefix_master
*master
;
2634 master
= prefix_master_get (AFI_IP
);
2638 for (plist
= master
->num
.head
; plist
; plist
= next
)
2641 prefix_list_delete (plist
);
2643 for (plist
= master
->str
.head
; plist
; plist
= next
)
2646 prefix_list_delete (plist
);
2649 assert (master
->num
.head
== NULL
);
2650 assert (master
->num
.tail
== NULL
);
2652 assert (master
->str
.head
== NULL
);
2653 assert (master
->str
.tail
== NULL
);
2656 master
->recent
= NULL
;
2660 prefix_list_init_ipv4 (void)
2662 install_node (&prefix_node
, config_write_prefix_ipv4
);
2664 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2665 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2666 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2667 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2668 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2669 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2670 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2671 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2672 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2673 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2675 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2676 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2677 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2678 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2679 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2680 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2681 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2682 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2683 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2684 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2685 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2687 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2688 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2689 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2691 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2692 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2694 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2695 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2696 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2697 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2698 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2699 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2700 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2701 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2702 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2703 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2705 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2706 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2707 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2708 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2709 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2710 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2711 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2712 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2713 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2714 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2716 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2717 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2718 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2722 /* Prefix-list node. */
2723 struct cmd_node prefix_ipv6_node
=
2726 "", /* Prefix list has no interface. */
2731 config_write_prefix_ipv6 (struct vty
*vty
)
2733 return config_write_prefix_afi (AFI_IP6
, vty
);
2737 prefix_list_reset_ipv6 (void)
2739 struct prefix_list
*plist
;
2740 struct prefix_list
*next
;
2741 struct prefix_master
*master
;
2743 master
= prefix_master_get (AFI_IP6
);
2747 for (plist
= master
->num
.head
; plist
; plist
= next
)
2750 prefix_list_delete (plist
);
2752 for (plist
= master
->str
.head
; plist
; plist
= next
)
2755 prefix_list_delete (plist
);
2758 assert (master
->num
.head
== NULL
);
2759 assert (master
->num
.tail
== NULL
);
2761 assert (master
->str
.head
== NULL
);
2762 assert (master
->str
.tail
== NULL
);
2765 master
->recent
= NULL
;
2769 prefix_list_init_ipv6 (void)
2771 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2773 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2774 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2775 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2776 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2777 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2778 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2779 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2780 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2781 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
2782 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
2784 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
2785 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
2786 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
2787 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
2788 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
2789 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
2790 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
2791 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
2792 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
2793 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
2794 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
2796 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
2797 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
2798 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
2800 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
2801 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
2803 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
2804 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
2805 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2806 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2807 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2808 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2809 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2810 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2811 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2812 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2814 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
2815 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
2816 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2817 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2818 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2819 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2820 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2821 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2822 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2823 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2825 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
2826 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
2827 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
2829 #endif /* HAVE_IPV6 */
2834 prefix_list_init_ipv4 ();
2836 prefix_list_init_ipv6 ();
2837 #endif /* HAVE_IPV6 */
2841 prefix_list_reset ()
2843 prefix_list_reset_ipv4 ();
2845 prefix_list_reset_ipv6 ();
2846 #endif /* HAVE_IPV6 */
2847 prefix_list_reset_orf ();