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"
34 /* Each prefix-list's entry. */
35 struct prefix_list_entry
42 enum prefix_list_type type
;
50 struct prefix_list_entry
*next
;
51 struct prefix_list_entry
*prev
;
54 /* List of struct prefix_list. */
55 struct prefix_list_list
57 struct prefix_list
*head
;
58 struct prefix_list
*tail
;
61 /* Master structure of prefix_list. */
64 /* List of prefix_list which name is number. */
65 struct prefix_list_list num
;
67 /* List of prefix_list which name is string. */
68 struct prefix_list_list str
;
70 /* Whether sequential number is used. */
73 /* The latest update. */
74 struct prefix_list
*recent
;
76 /* Hook function which is executed when new prefix_list is added. */
77 void (*add_hook
) (struct prefix_list
*);
79 /* Hook function which is executed when prefix_list is deleted. */
80 void (*delete_hook
) (struct prefix_list
*);
83 /* Static structure of IPv4 prefix_list's master. */
84 static struct prefix_master prefix_master_ipv4
=
94 /* Static structure of IPv6 prefix-list's master. */
95 static struct prefix_master prefix_master_ipv6
=
103 #endif /* HAVE_IPV6*/
105 /* Static structure of BGP ORF prefix_list's master. */
106 static struct prefix_master prefix_master_orf
=
115 static struct prefix_master
*
116 prefix_master_get (afi_t afi
)
119 return &prefix_master_ipv4
;
121 else if (afi
== AFI_IP6
)
122 return &prefix_master_ipv6
;
123 #endif /* HAVE_IPV6 */
124 else if (afi
== AFI_ORF_PREFIX
)
125 return &prefix_master_orf
;
129 /* Lookup prefix_list from list of prefix_list by name. */
131 prefix_list_lookup (afi_t afi
, const char *name
)
133 struct prefix_list
*plist
;
134 struct prefix_master
*master
;
139 master
= prefix_master_get (afi
);
143 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
144 if (strcmp (plist
->name
, name
) == 0)
147 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
148 if (strcmp (plist
->name
, name
) == 0)
154 static struct prefix_list
*
155 prefix_list_new (void)
157 struct prefix_list
*new;
159 new = XCALLOC (MTYPE_PREFIX_LIST
, sizeof (struct prefix_list
));
164 prefix_list_free (struct prefix_list
*plist
)
166 XFREE (MTYPE_PREFIX_LIST
, plist
);
169 static struct prefix_list_entry
*
170 prefix_list_entry_new (void)
172 struct prefix_list_entry
*new;
174 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY
, sizeof (struct prefix_list_entry
));
179 prefix_list_entry_free (struct prefix_list_entry
*pentry
)
181 XFREE (MTYPE_PREFIX_LIST_ENTRY
, pentry
);
184 /* Insert new prefix list to list of prefix_list. Each prefix_list
185 is sorted by the name. */
186 static struct prefix_list
*
187 prefix_list_insert (afi_t afi
, const char *name
)
191 struct prefix_list
*plist
;
192 struct prefix_list
*point
;
193 struct prefix_list_list
*list
;
194 struct prefix_master
*master
;
196 master
= prefix_master_get (afi
);
200 /* Allocate new prefix_list and copy given name. */
201 plist
= prefix_list_new ();
202 plist
->name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, name
);
203 plist
->master
= master
;
205 /* If name is made by all digit character. We treat it as
207 for (number
= 0, i
= 0; i
< strlen (name
); i
++)
209 if (isdigit ((int) name
[i
]))
210 number
= (number
* 10) + (name
[i
] - '0');
215 /* In case of name is all digit character */
216 if (i
== strlen (name
))
218 plist
->type
= PREFIX_TYPE_NUMBER
;
220 /* Set prefix_list to number list. */
223 for (point
= list
->head
; point
; point
= point
->next
)
224 if (atol (point
->name
) >= number
)
229 plist
->type
= PREFIX_TYPE_STRING
;
231 /* Set prefix_list to string list. */
234 /* Set point to insertion point. */
235 for (point
= list
->head
; point
; point
= point
->next
)
236 if (strcmp (point
->name
, name
) >= 0)
240 /* In case of this is the first element of master. */
241 if (list
->head
== NULL
)
243 list
->head
= list
->tail
= plist
;
247 /* In case of insertion is made at the tail of access_list. */
250 plist
->prev
= list
->tail
;
251 list
->tail
->next
= plist
;
256 /* In case of insertion is made at the head of access_list. */
257 if (point
== list
->head
)
259 plist
->next
= list
->head
;
260 list
->head
->prev
= plist
;
265 /* Insertion is made at middle of the access_list. */
267 plist
->prev
= point
->prev
;
270 point
->prev
->next
= plist
;
276 static struct prefix_list
*
277 prefix_list_get (afi_t afi
, const char *name
)
279 struct prefix_list
*plist
;
281 plist
= prefix_list_lookup (afi
, name
);
284 plist
= prefix_list_insert (afi
, name
);
288 /* Delete prefix-list from prefix_list_master and free it. */
290 prefix_list_delete (struct prefix_list
*plist
)
292 struct prefix_list_list
*list
;
293 struct prefix_master
*master
;
294 struct prefix_list_entry
*pentry
;
295 struct prefix_list_entry
*next
;
297 /* If prefix-list contain prefix_list_entry free all of it. */
298 for (pentry
= plist
->head
; pentry
; pentry
= next
)
301 prefix_list_entry_free (pentry
);
305 master
= plist
->master
;
307 if (plist
->type
== PREFIX_TYPE_NUMBER
)
313 plist
->next
->prev
= plist
->prev
;
315 list
->tail
= plist
->prev
;
318 plist
->prev
->next
= plist
->next
;
320 list
->head
= plist
->next
;
323 XFREE (MTYPE_TMP
, plist
->desc
);
325 /* Make sure master's recent changed prefix-list information is
327 master
->recent
= NULL
;
329 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
331 if (master
->delete_hook
)
332 (*master
->delete_hook
) (plist
);
335 XFREE (MTYPE_PREFIX_LIST_STR
, plist
->name
);
337 prefix_list_free (plist
);
341 static struct prefix_list_entry
*
342 prefix_list_entry_make (struct prefix
*prefix
, enum prefix_list_type type
,
343 int seq
, int le
, int ge
, int any
)
345 struct prefix_list_entry
*pentry
;
347 pentry
= prefix_list_entry_new ();
352 prefix_copy (&pentry
->prefix
, prefix
);
361 /* Add hook function. */
363 prefix_list_add_hook (void (*func
) (struct prefix_list
*plist
))
365 prefix_master_ipv4
.add_hook
= func
;
367 prefix_master_ipv6
.add_hook
= func
;
368 #endif /* HAVE_IPV6 */
371 /* Delete hook function. */
373 prefix_list_delete_hook (void (*func
) (struct prefix_list
*plist
))
375 prefix_master_ipv4
.delete_hook
= func
;
377 prefix_master_ipv6
.delete_hook
= func
;
378 #endif /* HAVE_IPVt6 */
381 /* Calculate new sequential number. */
383 prefix_new_seq_get (struct prefix_list
*plist
)
387 struct prefix_list_entry
*pentry
;
391 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
393 if (maxseq
< pentry
->seq
)
394 maxseq
= pentry
->seq
;
397 newseq
= ((maxseq
/ 5) * 5) + 5;
402 /* Return prefix list entry which has same seq number. */
403 static struct prefix_list_entry
*
404 prefix_seq_check (struct prefix_list
*plist
, int seq
)
406 struct prefix_list_entry
*pentry
;
408 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
409 if (pentry
->seq
== seq
)
414 static struct prefix_list_entry
*
415 prefix_list_entry_lookup (struct prefix_list
*plist
, struct prefix
*prefix
,
416 enum prefix_list_type type
, int seq
, int le
, int ge
)
418 struct prefix_list_entry
*pentry
;
420 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
421 if (prefix_same (&pentry
->prefix
, prefix
) && pentry
->type
== type
)
423 if (seq
>= 0 && pentry
->seq
!= seq
)
426 if (pentry
->le
!= le
)
428 if (pentry
->ge
!= ge
)
438 prefix_list_entry_delete (struct prefix_list
*plist
,
439 struct prefix_list_entry
*pentry
,
442 if (plist
== NULL
|| pentry
== NULL
)
445 pentry
->prev
->next
= pentry
->next
;
447 plist
->head
= pentry
->next
;
449 pentry
->next
->prev
= pentry
->prev
;
451 plist
->tail
= pentry
->prev
;
453 prefix_list_entry_free (pentry
);
459 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
460 if (plist
->master
->delete_hook
)
461 (*plist
->master
->delete_hook
) (plist
);
463 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
464 prefix_list_delete (plist
);
466 plist
->master
->recent
= plist
;
471 prefix_list_entry_add (struct prefix_list
*plist
,
472 struct prefix_list_entry
*pentry
)
474 struct prefix_list_entry
*replace
;
475 struct prefix_list_entry
*point
;
477 /* Automatic asignment of seq no. */
478 if (pentry
->seq
== -1)
479 pentry
->seq
= prefix_new_seq_get (plist
);
481 /* Is there any same seq prefix list entry? */
482 replace
= prefix_seq_check (plist
, pentry
->seq
);
484 prefix_list_entry_delete (plist
, replace
, 0);
486 /* Check insert point. */
487 for (point
= plist
->head
; point
; point
= point
->next
)
488 if (point
->seq
>= pentry
->seq
)
491 /* In case of this is the first element of the list. */
492 pentry
->next
= point
;
497 point
->prev
->next
= pentry
;
499 plist
->head
= pentry
;
501 pentry
->prev
= point
->prev
;
502 point
->prev
= pentry
;
507 plist
->tail
->next
= pentry
;
509 plist
->head
= pentry
;
511 pentry
->prev
= plist
->tail
;
512 plist
->tail
= pentry
;
515 /* Increment count. */
518 /* Run hook function. */
519 if (plist
->master
->add_hook
)
520 (*plist
->master
->add_hook
) (plist
);
522 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_ADDED
);
523 plist
->master
->recent
= plist
;
526 /* Return string of prefix_list_type. */
528 prefix_list_type_str (struct prefix_list_entry
*pentry
)
530 switch (pentry
->type
)
542 prefix_list_entry_match (struct prefix_list_entry
*pentry
, struct prefix
*p
)
546 ret
= prefix_match (&pentry
->prefix
, p
);
550 /* In case of le nor ge is specified, exact match is performed. */
551 if (! pentry
->le
&& ! pentry
->ge
)
553 if (pentry
->prefix
.prefixlen
!= p
->prefixlen
)
559 if (p
->prefixlen
> pentry
->le
)
563 if (p
->prefixlen
< pentry
->ge
)
569 enum prefix_list_type
570 prefix_list_apply (struct prefix_list
*plist
, void *object
)
572 struct prefix_list_entry
*pentry
;
575 p
= (struct prefix
*) object
;
580 if (plist
->count
== 0)
581 return PREFIX_PERMIT
;
583 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
586 if (prefix_list_entry_match (pentry
, p
))
596 static void __attribute__ ((unused
))
597 prefix_list_print (struct prefix_list
*plist
)
599 struct prefix_list_entry
*pentry
;
604 printf ("ip prefix-list %s: %d entries\n", plist
->name
, plist
->count
);
606 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
609 printf ("any %s\n", prefix_list_type_str (pentry
));
617 printf (" seq %d %s %s/%d",
619 prefix_list_type_str (pentry
),
620 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
623 printf (" ge %d", pentry
->ge
);
625 printf (" le %d", pentry
->le
);
631 /* Retrun 1 when plist already include pentry policy. */
632 static struct prefix_list_entry
*
633 prefix_entry_dup_check (struct prefix_list
*plist
,
634 struct prefix_list_entry
*new)
636 struct prefix_list_entry
*pentry
;
640 seq
= prefix_new_seq_get (plist
);
644 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
646 if (prefix_same (&pentry
->prefix
, &new->prefix
)
647 && pentry
->type
== new->type
648 && pentry
->le
== new->le
649 && pentry
->ge
== new->ge
650 && pentry
->seq
!= seq
)
657 vty_invalid_prefix_range (struct vty
*vty
, const char *prefix
)
659 vty_out (vty
, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
660 prefix
, VTY_NEWLINE
);
665 vty_prefix_list_install (struct vty
*vty
, afi_t afi
, const char *name
,
666 const char *seq
, const char *typestr
,
667 const char *prefix
, const char *ge
, const char *le
)
670 enum prefix_list_type type
;
671 struct prefix_list
*plist
;
672 struct prefix_list_entry
*pentry
;
673 struct prefix_list_entry
*dup
;
680 /* Sequential number. */
684 /* ge and le number */
690 /* Check filter type. */
691 if (strncmp ("permit", typestr
, 1) == 0)
692 type
= PREFIX_PERMIT
;
693 else if (strncmp ("deny", typestr
, 1) == 0)
697 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
701 /* "any" is special token for matching any IPv4 addresses. */
704 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
706 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
708 lenum
= IPV4_MAX_BITLEN
;
712 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
716 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
721 else if (afi
== AFI_IP6
)
723 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
725 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
727 lenum
= IPV6_MAX_BITLEN
;
731 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
735 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
739 #endif /* HAVE_IPV6 */
741 /* ge and le check. */
742 if (genum
&& genum
<= p
.prefixlen
)
743 return vty_invalid_prefix_range (vty
, prefix
);
745 if (lenum
&& lenum
<= p
.prefixlen
)
746 return vty_invalid_prefix_range (vty
, prefix
);
748 if (lenum
&& genum
> lenum
)
749 return vty_invalid_prefix_range (vty
, prefix
);
751 if (genum
&& lenum
== (afi
== AFI_IP
? 32 : 128))
754 /* Get prefix_list with name. */
755 plist
= prefix_list_get (afi
, name
);
757 /* Make prefix entry. */
758 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
760 /* Check same policy. */
761 dup
= prefix_entry_dup_check (plist
, pentry
);
765 prefix_list_entry_free (pentry
);
766 vty_out (vty
, "%% Insertion failed - prefix-list entry exists:%s",
768 vty_out (vty
, " seq %d %s %s", dup
->seq
, typestr
, prefix
);
770 vty_out (vty
, " ge %d", genum
);
772 vty_out (vty
, " le %d", lenum
);
773 vty_out (vty
, "%s", VTY_NEWLINE
);
777 /* Install new filter to the access_list. */
778 prefix_list_entry_add (plist
, pentry
);
784 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
785 const char *seq
, const char *typestr
,
786 const char *prefix
, const char *ge
, const char *le
)
789 enum prefix_list_type type
;
790 struct prefix_list
*plist
;
791 struct prefix_list_entry
*pentry
;
797 /* Check prefix list name. */
798 plist
= prefix_list_lookup (afi
, name
);
801 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
805 /* Only prefix-list name specified, delete the entire prefix-list. */
806 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
807 ge
== NULL
&& le
== NULL
)
809 prefix_list_delete (plist
);
813 /* We must have, at a minimum, both the type and prefix here */
814 if ((typestr
== NULL
) || (prefix
== NULL
))
816 vty_out (vty
, "%% Both prefix and type required%s", VTY_NEWLINE
);
820 /* Check sequence number. */
824 /* ge and le number */
830 /* Check of filter type. */
831 if (strncmp ("permit", typestr
, 1) == 0)
832 type
= PREFIX_PERMIT
;
833 else if (strncmp ("deny", typestr
, 1) == 0)
837 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
841 /* "any" is special token for matching any IPv4 addresses. */
844 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
846 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
848 lenum
= IPV4_MAX_BITLEN
;
851 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
855 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
860 else if (afi
== AFI_IP6
)
862 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
864 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
866 lenum
= IPV6_MAX_BITLEN
;
869 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
873 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
877 #endif /* HAVE_IPV6 */
879 /* Lookup prefix entry. */
880 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
884 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
888 /* Install new filter to the access_list. */
889 prefix_list_entry_delete (plist
, pentry
, 1);
895 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
897 struct prefix_list
*plist
;
899 plist
= prefix_list_lookup (afi
, name
);
902 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
908 XFREE (MTYPE_TMP
, plist
->desc
);
912 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
913 prefix_list_delete (plist
);
929 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
930 struct prefix_master
*master
, enum display_type dtype
,
933 struct prefix_list_entry
*pentry
;
935 /* Print the name of the protocol */
937 vty_out (vty
, "%s: ", zlog_proto_names
[zlog_default
->protocol
]);
939 if (dtype
== normal_display
)
941 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
942 afi
== AFI_IP
? "" : "v6",
943 plist
->name
, plist
->count
, VTY_NEWLINE
);
945 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
947 else if (dtype
== summary_display
|| dtype
== detail_display
)
949 vty_out (vty
, "ip%s prefix-list %s:%s",
950 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
953 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
955 vty_out (vty
, " count: %d, range entries: %d, sequences: %d - %d%s",
956 plist
->count
, plist
->rangecount
,
957 plist
->head
? plist
->head
->seq
: 0,
958 plist
->tail
? plist
->tail
->seq
: 0,
962 if (dtype
!= summary_display
)
964 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
966 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
972 vty_out (vty
, "seq %d ", pentry
->seq
);
974 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
977 vty_out (vty
, "any");
980 struct prefix
*p
= &pentry
->prefix
;
983 vty_out (vty
, "%s/%d",
984 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
988 vty_out (vty
, " ge %d", pentry
->ge
);
990 vty_out (vty
, " le %d", pentry
->le
);
993 if (dtype
== detail_display
|| dtype
== sequential_display
)
994 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
995 pentry
->hitcnt
, pentry
->refcnt
);
997 vty_out (vty
, "%s", VTY_NEWLINE
);
1003 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1004 const char *seq
, enum display_type dtype
)
1006 struct prefix_list
*plist
;
1007 struct prefix_master
*master
;
1010 master
= prefix_master_get (afi
);
1015 seqnum
= atoi (seq
);
1019 plist
= prefix_list_lookup (afi
, name
);
1022 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1025 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1029 if (dtype
== detail_display
|| dtype
== summary_display
)
1032 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1033 master
->recent
->name
, VTY_NEWLINE
);
1036 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1037 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1039 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1040 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1047 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1048 const char *prefix
, enum display_type type
)
1050 struct prefix_list
*plist
;
1051 struct prefix_list_entry
*pentry
;
1056 plist
= prefix_list_lookup (afi
, name
);
1059 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1063 ret
= str2prefix (prefix
, &p
);
1066 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1070 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1074 if (type
== normal_display
|| type
== first_match_display
)
1075 if (prefix_same (&p
, &pentry
->prefix
))
1078 if (type
== longer_display
)
1079 if (prefix_match (&p
, &pentry
->prefix
))
1084 vty_out (vty
, " seq %d %s ",
1086 prefix_list_type_str (pentry
));
1089 vty_out (vty
, "any");
1092 struct prefix
*p
= &pentry
->prefix
;
1095 vty_out (vty
, "%s/%d",
1096 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1100 vty_out (vty
, " ge %d", pentry
->ge
);
1102 vty_out (vty
, " le %d", pentry
->le
);
1105 if (type
== normal_display
|| type
== first_match_display
)
1106 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1107 pentry
->hitcnt
, pentry
->refcnt
);
1109 vty_out (vty
, "%s", VTY_NEWLINE
);
1111 if (type
== first_match_display
)
1119 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1122 struct prefix_master
*master
;
1123 struct prefix_list
*plist
;
1124 struct prefix_list_entry
*pentry
;
1128 master
= prefix_master_get (afi
);
1132 if (name
== NULL
&& prefix
== NULL
)
1134 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1135 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1138 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1139 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1144 plist
= prefix_list_lookup (afi
, name
);
1147 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1153 ret
= str2prefix (prefix
, &p
);
1156 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1161 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1165 if (prefix_match (&pentry
->prefix
, &p
))
1175 DEFUN (ip_prefix_list
,
1177 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1180 "Name of a prefix list\n"
1181 "Specify packets to reject\n"
1182 "Specify packets to forward\n"
1183 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1184 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1186 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1187 argv
[1], argv
[2], NULL
, NULL
);
1190 DEFUN (ip_prefix_list_ge
,
1191 ip_prefix_list_ge_cmd
,
1192 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1195 "Name of a prefix list\n"
1196 "Specify packets to reject\n"
1197 "Specify packets to forward\n"
1198 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1199 "Minimum prefix length to be matched\n"
1200 "Minimum prefix length\n")
1202 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1203 argv
[2], argv
[3], NULL
);
1206 DEFUN (ip_prefix_list_ge_le
,
1207 ip_prefix_list_ge_le_cmd
,
1208 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> 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 "Minimum prefix length to be matched\n"
1216 "Minimum prefix length\n"
1217 "Maximum prefix length to be matched\n"
1218 "Maximum prefix length\n")
1220 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1221 argv
[2], argv
[3], argv
[4]);
1224 DEFUN (ip_prefix_list_le
,
1225 ip_prefix_list_le_cmd
,
1226 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1229 "Name of a prefix list\n"
1230 "Specify packets to reject\n"
1231 "Specify packets to forward\n"
1232 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1233 "Maximum prefix length to be matched\n"
1234 "Maximum prefix length\n")
1236 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1237 argv
[2], NULL
, argv
[3]);
1240 DEFUN (ip_prefix_list_le_ge
,
1241 ip_prefix_list_le_ge_cmd
,
1242 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1245 "Name of a prefix list\n"
1246 "Specify packets to reject\n"
1247 "Specify packets to forward\n"
1248 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1249 "Maximum prefix length to be matched\n"
1250 "Maximum prefix length\n"
1251 "Minimum prefix length to be matched\n"
1252 "Minimum prefix length\n")
1254 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1255 argv
[2], argv
[4], argv
[3]);
1258 DEFUN (ip_prefix_list_seq
,
1259 ip_prefix_list_seq_cmd
,
1260 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1263 "Name of a prefix list\n"
1264 "sequence number of an entry\n"
1266 "Specify packets to reject\n"
1267 "Specify packets to forward\n"
1268 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1269 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1271 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1272 argv
[3], NULL
, NULL
);
1275 DEFUN (ip_prefix_list_seq_ge
,
1276 ip_prefix_list_seq_ge_cmd
,
1277 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <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")
1289 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1290 argv
[3], argv
[4], NULL
);
1293 DEFUN (ip_prefix_list_seq_ge_le
,
1294 ip_prefix_list_seq_ge_le_cmd
,
1295 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1298 "Name of a prefix list\n"
1299 "sequence number of an entry\n"
1301 "Specify packets to reject\n"
1302 "Specify packets to forward\n"
1303 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1304 "Minimum prefix length to be matched\n"
1305 "Minimum prefix length\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], argv
[4], argv
[5]);
1313 DEFUN (ip_prefix_list_seq_le
,
1314 ip_prefix_list_seq_le_cmd
,
1315 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <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")
1327 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1328 argv
[3], NULL
, argv
[4]);
1331 DEFUN (ip_prefix_list_seq_le_ge
,
1332 ip_prefix_list_seq_le_ge_cmd
,
1333 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1336 "Name of a prefix list\n"
1337 "sequence number of an entry\n"
1339 "Specify packets to reject\n"
1340 "Specify packets to forward\n"
1341 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1342 "Maximum prefix length to be matched\n"
1343 "Maximum prefix length\n"
1344 "Minimum prefix length to be matched\n"
1345 "Minimum prefix length\n")
1347 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1348 argv
[3], argv
[5], argv
[4]);
1351 DEFUN (no_ip_prefix_list
,
1352 no_ip_prefix_list_cmd
,
1353 "no ip prefix-list WORD",
1357 "Name of a prefix list\n")
1359 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1363 DEFUN (no_ip_prefix_list_prefix
,
1364 no_ip_prefix_list_prefix_cmd
,
1365 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1369 "Name of a prefix list\n"
1370 "Specify packets to reject\n"
1371 "Specify packets to forward\n"
1372 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1373 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1375 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1376 argv
[2], NULL
, NULL
);
1379 DEFUN (no_ip_prefix_list_ge
,
1380 no_ip_prefix_list_ge_cmd
,
1381 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1385 "Name of a prefix list\n"
1386 "Specify packets to reject\n"
1387 "Specify packets to forward\n"
1388 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1389 "Minimum prefix length to be matched\n"
1390 "Minimum prefix length\n")
1392 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1393 argv
[2], argv
[3], NULL
);
1396 DEFUN (no_ip_prefix_list_ge_le
,
1397 no_ip_prefix_list_ge_le_cmd
,
1398 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> 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 "Minimum prefix length to be matched\n"
1407 "Minimum prefix length\n"
1408 "Maximum prefix length to be matched\n"
1409 "Maximum prefix length\n")
1411 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1412 argv
[2], argv
[3], argv
[4]);
1415 DEFUN (no_ip_prefix_list_le
,
1416 no_ip_prefix_list_le_cmd
,
1417 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1421 "Name of a prefix list\n"
1422 "Specify packets to reject\n"
1423 "Specify packets to forward\n"
1424 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1425 "Maximum prefix length to be matched\n"
1426 "Maximum prefix length\n")
1428 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1429 argv
[2], NULL
, argv
[3]);
1432 DEFUN (no_ip_prefix_list_le_ge
,
1433 no_ip_prefix_list_le_ge_cmd
,
1434 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1438 "Name of a prefix list\n"
1439 "Specify packets to reject\n"
1440 "Specify packets to forward\n"
1441 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1442 "Maximum prefix length to be matched\n"
1443 "Maximum prefix length\n"
1444 "Minimum prefix length to be matched\n"
1445 "Minimum prefix length\n")
1447 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1448 argv
[2], argv
[4], argv
[3]);
1451 DEFUN (no_ip_prefix_list_seq
,
1452 no_ip_prefix_list_seq_cmd
,
1453 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
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 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1465 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1466 argv
[3], NULL
, NULL
);
1469 DEFUN (no_ip_prefix_list_seq_ge
,
1470 no_ip_prefix_list_seq_ge_cmd
,
1471 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <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")
1484 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1485 argv
[3], argv
[4], NULL
);
1488 DEFUN (no_ip_prefix_list_seq_ge_le
,
1489 no_ip_prefix_list_seq_ge_le_cmd
,
1490 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1494 "Name of a prefix list\n"
1495 "sequence number of an entry\n"
1497 "Specify packets to reject\n"
1498 "Specify packets to forward\n"
1499 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1500 "Minimum prefix length to be matched\n"
1501 "Minimum prefix length\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], argv
[4], argv
[5]);
1509 DEFUN (no_ip_prefix_list_seq_le
,
1510 no_ip_prefix_list_seq_le_cmd
,
1511 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <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")
1524 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1525 argv
[3], NULL
, argv
[4]);
1528 DEFUN (no_ip_prefix_list_seq_le_ge
,
1529 no_ip_prefix_list_seq_le_ge_cmd
,
1530 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1534 "Name of a prefix list\n"
1535 "sequence number of an entry\n"
1537 "Specify packets to reject\n"
1538 "Specify packets to forward\n"
1539 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1540 "Maximum prefix length to be matched\n"
1541 "Maximum prefix length\n"
1542 "Minimum prefix length to be matched\n"
1543 "Minimum prefix length\n")
1545 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1546 argv
[3], argv
[5], argv
[4]);
1549 DEFUN (ip_prefix_list_sequence_number
,
1550 ip_prefix_list_sequence_number_cmd
,
1551 "ip prefix-list sequence-number",
1554 "Include/exclude sequence numbers in NVGEN\n")
1556 prefix_master_ipv4
.seqnum
= 1;
1560 DEFUN (no_ip_prefix_list_sequence_number
,
1561 no_ip_prefix_list_sequence_number_cmd
,
1562 "no ip prefix-list sequence-number",
1566 "Include/exclude sequence numbers in NVGEN\n")
1568 prefix_master_ipv4
.seqnum
= 0;
1572 DEFUN (ip_prefix_list_description
,
1573 ip_prefix_list_description_cmd
,
1574 "ip prefix-list WORD description .LINE",
1577 "Name of a prefix list\n"
1578 "Prefix-list specific description\n"
1579 "Up to 80 characters describing this prefix-list\n")
1581 struct prefix_list
*plist
;
1583 plist
= prefix_list_get (AFI_IP
, argv
[0]);
1587 XFREE (MTYPE_TMP
, plist
->desc
);
1590 plist
->desc
= argv_concat(argv
, argc
, 1);
1595 DEFUN (no_ip_prefix_list_description
,
1596 no_ip_prefix_list_description_cmd
,
1597 "no ip prefix-list WORD description",
1601 "Name of a prefix list\n"
1602 "Prefix-list specific description\n")
1604 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1607 ALIAS (no_ip_prefix_list_description
,
1608 no_ip_prefix_list_description_arg_cmd
,
1609 "no ip prefix-list WORD description .LINE",
1613 "Name of a prefix list\n"
1614 "Prefix-list specific description\n"
1615 "Up to 80 characters describing this prefix-list\n")
1617 DEFUN (show_ip_prefix_list
,
1618 show_ip_prefix_list_cmd
,
1619 "show ip prefix-list",
1624 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1627 DEFUN (show_ip_prefix_list_name
,
1628 show_ip_prefix_list_name_cmd
,
1629 "show ip prefix-list WORD",
1633 "Name of a prefix list\n")
1635 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1638 DEFUN (show_ip_prefix_list_name_seq
,
1639 show_ip_prefix_list_name_seq_cmd
,
1640 "show ip prefix-list WORD seq <1-4294967295>",
1644 "Name of a prefix list\n"
1645 "sequence number of an entry\n"
1646 "Sequence number\n")
1648 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1651 DEFUN (show_ip_prefix_list_prefix
,
1652 show_ip_prefix_list_prefix_cmd
,
1653 "show ip prefix-list WORD A.B.C.D/M",
1657 "Name of a prefix list\n"
1658 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1660 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1663 DEFUN (show_ip_prefix_list_prefix_longer
,
1664 show_ip_prefix_list_prefix_longer_cmd
,
1665 "show ip prefix-list WORD A.B.C.D/M longer",
1669 "Name of a prefix list\n"
1670 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1671 "Lookup longer prefix\n")
1673 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1676 DEFUN (show_ip_prefix_list_prefix_first_match
,
1677 show_ip_prefix_list_prefix_first_match_cmd
,
1678 "show ip prefix-list WORD A.B.C.D/M first-match",
1682 "Name of a prefix list\n"
1683 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1684 "First matched prefix\n")
1686 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1689 DEFUN (show_ip_prefix_list_summary
,
1690 show_ip_prefix_list_summary_cmd
,
1691 "show ip prefix-list summary",
1695 "Summary of prefix lists\n")
1697 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1700 DEFUN (show_ip_prefix_list_summary_name
,
1701 show_ip_prefix_list_summary_name_cmd
,
1702 "show ip prefix-list summary WORD",
1706 "Summary of prefix lists\n"
1707 "Name of a prefix list\n")
1709 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1713 DEFUN (show_ip_prefix_list_detail
,
1714 show_ip_prefix_list_detail_cmd
,
1715 "show ip prefix-list detail",
1719 "Detail of prefix lists\n")
1721 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1724 DEFUN (show_ip_prefix_list_detail_name
,
1725 show_ip_prefix_list_detail_name_cmd
,
1726 "show ip prefix-list detail WORD",
1730 "Detail of prefix lists\n"
1731 "Name of a prefix list\n")
1733 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1736 DEFUN (clear_ip_prefix_list
,
1737 clear_ip_prefix_list_cmd
,
1738 "clear ip prefix-list",
1743 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1746 DEFUN (clear_ip_prefix_list_name
,
1747 clear_ip_prefix_list_name_cmd
,
1748 "clear ip prefix-list WORD",
1752 "Name of a prefix list\n")
1754 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1757 DEFUN (clear_ip_prefix_list_name_prefix
,
1758 clear_ip_prefix_list_name_prefix_cmd
,
1759 "clear ip prefix-list WORD A.B.C.D/M",
1763 "Name of a prefix list\n"
1764 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1766 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1770 DEFUN (ipv6_prefix_list
,
1771 ipv6_prefix_list_cmd
,
1772 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1775 "Name of a prefix list\n"
1776 "Specify packets to reject\n"
1777 "Specify packets to forward\n"
1778 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1779 "Any prefix match. Same as \"::0/0 le 128\"\n")
1781 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
1782 argv
[1], argv
[2], NULL
, NULL
);
1785 DEFUN (ipv6_prefix_list_ge
,
1786 ipv6_prefix_list_ge_cmd
,
1787 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1790 "Name of a prefix list\n"
1791 "Specify packets to reject\n"
1792 "Specify packets to forward\n"
1793 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1794 "Minimum prefix length to be matched\n"
1795 "Minimum prefix length\n")
1797 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1798 argv
[2], argv
[3], NULL
);
1801 DEFUN (ipv6_prefix_list_ge_le
,
1802 ipv6_prefix_list_ge_le_cmd
,
1803 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1806 "Name of a prefix list\n"
1807 "Specify packets to reject\n"
1808 "Specify packets to forward\n"
1809 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1810 "Minimum prefix length to be matched\n"
1811 "Minimum prefix length\n"
1812 "Maximum prefix length to be matched\n"
1813 "Maximum prefix length\n")
1816 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1817 argv
[2], argv
[3], argv
[4]);
1820 DEFUN (ipv6_prefix_list_le
,
1821 ipv6_prefix_list_le_cmd
,
1822 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
1825 "Name of a prefix list\n"
1826 "Specify packets to reject\n"
1827 "Specify packets to forward\n"
1828 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1829 "Maximum prefix length to be matched\n"
1830 "Maximum prefix length\n")
1832 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1833 argv
[2], NULL
, argv
[3]);
1836 DEFUN (ipv6_prefix_list_le_ge
,
1837 ipv6_prefix_list_le_ge_cmd
,
1838 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1841 "Name of a prefix list\n"
1842 "Specify packets to reject\n"
1843 "Specify packets to forward\n"
1844 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1845 "Maximum prefix length to be matched\n"
1846 "Maximum prefix length\n"
1847 "Minimum prefix length to be matched\n"
1848 "Minimum prefix length\n")
1850 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1851 argv
[2], argv
[4], argv
[3]);
1854 DEFUN (ipv6_prefix_list_seq
,
1855 ipv6_prefix_list_seq_cmd
,
1856 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
1859 "Name of a prefix list\n"
1860 "sequence number of an entry\n"
1862 "Specify packets to reject\n"
1863 "Specify packets to forward\n"
1864 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1865 "Any prefix match. Same as \"::0/0 le 128\"\n")
1867 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1868 argv
[3], NULL
, NULL
);
1871 DEFUN (ipv6_prefix_list_seq_ge
,
1872 ipv6_prefix_list_seq_ge_cmd
,
1873 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <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")
1885 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1886 argv
[3], argv
[4], NULL
);
1889 DEFUN (ipv6_prefix_list_seq_ge_le
,
1890 ipv6_prefix_list_seq_ge_le_cmd
,
1891 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1894 "Name of a prefix list\n"
1895 "sequence number of an entry\n"
1897 "Specify packets to reject\n"
1898 "Specify packets to forward\n"
1899 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1900 "Minimum prefix length to be matched\n"
1901 "Minimum prefix length\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], argv
[4], argv
[5]);
1909 DEFUN (ipv6_prefix_list_seq_le
,
1910 ipv6_prefix_list_seq_le_cmd
,
1911 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <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")
1923 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1924 argv
[3], NULL
, argv
[4]);
1927 DEFUN (ipv6_prefix_list_seq_le_ge
,
1928 ipv6_prefix_list_seq_le_ge_cmd
,
1929 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
1932 "Name of a prefix list\n"
1933 "sequence number of an entry\n"
1935 "Specify packets to reject\n"
1936 "Specify packets to forward\n"
1937 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1938 "Maximum prefix length to be matched\n"
1939 "Maximum prefix length\n"
1940 "Minimum prefix length to be matched\n"
1941 "Minimum prefix length\n")
1943 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
1944 argv
[3], argv
[5], argv
[4]);
1947 DEFUN (no_ipv6_prefix_list
,
1948 no_ipv6_prefix_list_cmd
,
1949 "no ipv6 prefix-list WORD",
1953 "Name of a prefix list\n")
1955 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
1959 DEFUN (no_ipv6_prefix_list_prefix
,
1960 no_ipv6_prefix_list_prefix_cmd
,
1961 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1965 "Name of a prefix list\n"
1966 "Specify packets to reject\n"
1967 "Specify packets to forward\n"
1968 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1969 "Any prefix match. Same as \"::0/0 le 128\"\n")
1971 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1972 argv
[2], NULL
, NULL
);
1975 DEFUN (no_ipv6_prefix_list_ge
,
1976 no_ipv6_prefix_list_ge_cmd
,
1977 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
1981 "Name of a prefix list\n"
1982 "Specify packets to reject\n"
1983 "Specify packets to forward\n"
1984 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
1985 "Minimum prefix length to be matched\n"
1986 "Minimum prefix length\n")
1988 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
1989 argv
[2], argv
[3], NULL
);
1992 DEFUN (no_ipv6_prefix_list_ge_le
,
1993 no_ipv6_prefix_list_ge_le_cmd
,
1994 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
1998 "Name of a prefix list\n"
1999 "Specify packets to reject\n"
2000 "Specify packets to forward\n"
2001 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2002 "Minimum prefix length to be matched\n"
2003 "Minimum prefix length\n"
2004 "Maximum prefix length to be matched\n"
2005 "Maximum prefix length\n")
2007 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2008 argv
[2], argv
[3], argv
[4]);
2011 DEFUN (no_ipv6_prefix_list_le
,
2012 no_ipv6_prefix_list_le_cmd
,
2013 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2017 "Name of a prefix list\n"
2018 "Specify packets to reject\n"
2019 "Specify packets to forward\n"
2020 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2021 "Maximum prefix length to be matched\n"
2022 "Maximum prefix length\n")
2024 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2025 argv
[2], NULL
, argv
[3]);
2028 DEFUN (no_ipv6_prefix_list_le_ge
,
2029 no_ipv6_prefix_list_le_ge_cmd
,
2030 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2034 "Name of a prefix list\n"
2035 "Specify packets to reject\n"
2036 "Specify packets to forward\n"
2037 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2038 "Maximum prefix length to be matched\n"
2039 "Maximum prefix length\n"
2040 "Minimum prefix length to be matched\n"
2041 "Minimum prefix length\n")
2043 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2044 argv
[2], argv
[4], argv
[3]);
2047 DEFUN (no_ipv6_prefix_list_seq
,
2048 no_ipv6_prefix_list_seq_cmd
,
2049 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
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 "Any prefix match. Same as \"::0/0 le 128\"\n")
2061 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2062 argv
[3], NULL
, NULL
);
2065 DEFUN (no_ipv6_prefix_list_seq_ge
,
2066 no_ipv6_prefix_list_seq_ge_cmd
,
2067 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2071 "Name of a prefix list\n"
2072 "sequence number of an entry\n"
2074 "Specify packets to reject\n"
2075 "Specify packets to forward\n"
2076 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2077 "Minimum prefix length to be matched\n"
2078 "Minimum prefix length\n")
2080 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2081 argv
[3], argv
[4], NULL
);
2084 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2085 no_ipv6_prefix_list_seq_ge_le_cmd
,
2086 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2090 "Name of a prefix list\n"
2091 "sequence number of an entry\n"
2093 "Specify packets to reject\n"
2094 "Specify packets to forward\n"
2095 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2096 "Minimum prefix length to be matched\n"
2097 "Minimum prefix length\n"
2098 "Maximum prefix length to be matched\n"
2099 "Maximum prefix length\n")
2101 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2102 argv
[3], argv
[4], argv
[5]);
2105 DEFUN (no_ipv6_prefix_list_seq_le
,
2106 no_ipv6_prefix_list_seq_le_cmd
,
2107 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2111 "Name of a prefix list\n"
2112 "sequence number of an entry\n"
2114 "Specify packets to reject\n"
2115 "Specify packets to forward\n"
2116 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2117 "Maximum prefix length to be matched\n"
2118 "Maximum prefix length\n")
2120 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2121 argv
[3], NULL
, argv
[4]);
2124 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2125 no_ipv6_prefix_list_seq_le_ge_cmd
,
2126 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2130 "Name of a prefix list\n"
2131 "sequence number of an entry\n"
2133 "Specify packets to reject\n"
2134 "Specify packets to forward\n"
2135 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2136 "Maximum prefix length to be matched\n"
2137 "Maximum prefix length\n"
2138 "Minimum prefix length to be matched\n"
2139 "Minimum prefix length\n")
2141 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2142 argv
[3], argv
[5], argv
[4]);
2145 DEFUN (ipv6_prefix_list_sequence_number
,
2146 ipv6_prefix_list_sequence_number_cmd
,
2147 "ipv6 prefix-list sequence-number",
2150 "Include/exclude sequence numbers in NVGEN\n")
2152 prefix_master_ipv6
.seqnum
= 1;
2156 DEFUN (no_ipv6_prefix_list_sequence_number
,
2157 no_ipv6_prefix_list_sequence_number_cmd
,
2158 "no ipv6 prefix-list sequence-number",
2162 "Include/exclude sequence numbers in NVGEN\n")
2164 prefix_master_ipv6
.seqnum
= 0;
2168 DEFUN (ipv6_prefix_list_description
,
2169 ipv6_prefix_list_description_cmd
,
2170 "ipv6 prefix-list WORD description .LINE",
2173 "Name of a prefix list\n"
2174 "Prefix-list specific description\n"
2175 "Up to 80 characters describing this prefix-list\n")
2177 struct prefix_list
*plist
;
2179 plist
= prefix_list_get (AFI_IP6
, argv
[0]);
2183 XFREE (MTYPE_TMP
, plist
->desc
);
2186 plist
->desc
= argv_concat(argv
, argc
, 1);
2191 DEFUN (no_ipv6_prefix_list_description
,
2192 no_ipv6_prefix_list_description_cmd
,
2193 "no ipv6 prefix-list WORD description",
2197 "Name of a prefix list\n"
2198 "Prefix-list specific description\n")
2200 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2203 ALIAS (no_ipv6_prefix_list_description
,
2204 no_ipv6_prefix_list_description_arg_cmd
,
2205 "no ipv6 prefix-list WORD description .LINE",
2209 "Name of a prefix list\n"
2210 "Prefix-list specific description\n"
2211 "Up to 80 characters describing this prefix-list\n")
2213 DEFUN (show_ipv6_prefix_list
,
2214 show_ipv6_prefix_list_cmd
,
2215 "show ipv6 prefix-list",
2220 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2223 DEFUN (show_ipv6_prefix_list_name
,
2224 show_ipv6_prefix_list_name_cmd
,
2225 "show ipv6 prefix-list WORD",
2229 "Name of a prefix list\n")
2231 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2234 DEFUN (show_ipv6_prefix_list_name_seq
,
2235 show_ipv6_prefix_list_name_seq_cmd
,
2236 "show ipv6 prefix-list WORD seq <1-4294967295>",
2240 "Name of a prefix list\n"
2241 "sequence number of an entry\n"
2242 "Sequence number\n")
2244 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2247 DEFUN (show_ipv6_prefix_list_prefix
,
2248 show_ipv6_prefix_list_prefix_cmd
,
2249 "show ipv6 prefix-list WORD X:X::X:X/M",
2253 "Name of a prefix list\n"
2254 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2256 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2259 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2260 show_ipv6_prefix_list_prefix_longer_cmd
,
2261 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2265 "Name of a prefix list\n"
2266 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2267 "Lookup longer prefix\n")
2269 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2272 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2273 show_ipv6_prefix_list_prefix_first_match_cmd
,
2274 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2278 "Name of a prefix list\n"
2279 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2280 "First matched prefix\n")
2282 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2285 DEFUN (show_ipv6_prefix_list_summary
,
2286 show_ipv6_prefix_list_summary_cmd
,
2287 "show ipv6 prefix-list summary",
2291 "Summary of prefix lists\n")
2293 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2296 DEFUN (show_ipv6_prefix_list_summary_name
,
2297 show_ipv6_prefix_list_summary_name_cmd
,
2298 "show ipv6 prefix-list summary WORD",
2302 "Summary of prefix lists\n"
2303 "Name of a prefix list\n")
2305 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2308 DEFUN (show_ipv6_prefix_list_detail
,
2309 show_ipv6_prefix_list_detail_cmd
,
2310 "show ipv6 prefix-list detail",
2314 "Detail of prefix lists\n")
2316 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2319 DEFUN (show_ipv6_prefix_list_detail_name
,
2320 show_ipv6_prefix_list_detail_name_cmd
,
2321 "show ipv6 prefix-list detail WORD",
2325 "Detail of prefix lists\n"
2326 "Name of a prefix list\n")
2328 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2331 DEFUN (clear_ipv6_prefix_list
,
2332 clear_ipv6_prefix_list_cmd
,
2333 "clear ipv6 prefix-list",
2338 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2341 DEFUN (clear_ipv6_prefix_list_name
,
2342 clear_ipv6_prefix_list_name_cmd
,
2343 "clear ipv6 prefix-list WORD",
2347 "Name of a prefix list\n")
2349 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2352 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2353 clear_ipv6_prefix_list_name_prefix_cmd
,
2354 "clear ipv6 prefix-list WORD X:X::X:X/M",
2358 "Name of a prefix list\n"
2359 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2361 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2363 #endif /* HAVE_IPV6 */
2365 /* Configuration write function. */
2367 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2369 struct prefix_list
*plist
;
2370 struct prefix_list_entry
*pentry
;
2371 struct prefix_master
*master
;
2374 master
= prefix_master_get (afi
);
2378 if (! master
->seqnum
)
2380 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2381 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2382 vty_out (vty
, "!%s", VTY_NEWLINE
);
2385 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2389 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2390 afi
== AFI_IP
? "" : "v6",
2391 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2395 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2397 vty_out (vty
, "ip%s prefix-list %s ",
2398 afi
== AFI_IP
? "" : "v6",
2402 vty_out (vty
, "seq %d ", pentry
->seq
);
2404 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2407 vty_out (vty
, "any");
2410 struct prefix
*p
= &pentry
->prefix
;
2413 vty_out (vty
, "%s/%d",
2414 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2418 vty_out (vty
, " ge %d", pentry
->ge
);
2420 vty_out (vty
, " le %d", pentry
->le
);
2422 vty_out (vty
, "%s", VTY_NEWLINE
);
2425 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2428 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2432 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2433 afi
== AFI_IP
? "" : "v6",
2434 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2438 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2440 vty_out (vty
, "ip%s prefix-list %s ",
2441 afi
== AFI_IP
? "" : "v6",
2445 vty_out (vty
, "seq %d ", pentry
->seq
);
2447 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2450 vty_out (vty
, " any");
2453 struct prefix
*p
= &pentry
->prefix
;
2456 vty_out (vty
, " %s/%d",
2457 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2461 vty_out (vty
, " ge %d", pentry
->ge
);
2463 vty_out (vty
, " le %d", pentry
->le
);
2465 vty_out (vty
, "%s", VTY_NEWLINE
);
2474 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2475 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2477 struct prefix_list_entry
*pentry
;
2482 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2484 u_char flag
= init_flag
;
2485 struct prefix
*p
= &pentry
->prefix
;
2487 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2488 permit_flag
: deny_flag
);
2489 stream_putc (s
, flag
);
2490 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2491 stream_putc (s
, (u_char
)pentry
->ge
);
2492 stream_putc (s
, (u_char
)pentry
->le
);
2493 stream_put_prefix (s
, p
);
2500 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2501 int permit
, int set
)
2503 struct prefix_list
*plist
;
2504 struct prefix_list_entry
*pentry
;
2506 /* ge and le value check */
2507 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2509 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2511 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2514 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2517 plist
= prefix_list_get (AFI_ORF_PREFIX
, name
);
2523 pentry
= prefix_list_entry_make (&orfp
->p
,
2524 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2525 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2527 if (prefix_entry_dup_check (plist
, pentry
))
2529 prefix_list_entry_free (pentry
);
2533 prefix_list_entry_add (plist
, pentry
);
2537 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2538 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2539 orfp
->seq
, orfp
->le
, orfp
->ge
);
2544 prefix_list_entry_delete (plist
, pentry
, 1);
2551 prefix_bgp_orf_remove_all (char *name
)
2553 struct prefix_list
*plist
;
2555 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2557 prefix_list_delete (plist
);
2560 /* return prefix count */
2562 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
)
2564 struct prefix_list
*plist
;
2565 struct prefix_list_entry
*pentry
;
2567 plist
= prefix_list_lookup (AFI_ORF_PREFIX
, name
);
2572 return plist
->count
;
2574 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2575 afi
== AFI_IP
? "" : "v6",
2576 plist
->name
, plist
->count
, VTY_NEWLINE
);
2578 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2580 struct prefix
*p
= &pentry
->prefix
;
2583 vty_out (vty
, " seq %d %s %s/%d", pentry
->seq
,
2584 prefix_list_type_str (pentry
),
2585 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2589 vty_out (vty
, " ge %d", pentry
->ge
);
2591 vty_out (vty
, " le %d", pentry
->le
);
2593 vty_out (vty
, "%s", VTY_NEWLINE
);
2595 return plist
->count
;
2599 prefix_list_reset_orf (void)
2601 struct prefix_list
*plist
;
2602 struct prefix_list
*next
;
2603 struct prefix_master
*master
;
2605 master
= prefix_master_get (AFI_ORF_PREFIX
);
2609 for (plist
= master
->num
.head
; plist
; plist
= next
)
2612 prefix_list_delete (plist
);
2614 for (plist
= master
->str
.head
; plist
; plist
= next
)
2617 prefix_list_delete (plist
);
2620 assert (master
->num
.head
== NULL
);
2621 assert (master
->num
.tail
== NULL
);
2623 assert (master
->str
.head
== NULL
);
2624 assert (master
->str
.tail
== NULL
);
2627 master
->recent
= NULL
;
2631 /* Prefix-list node. */
2632 static struct cmd_node prefix_node
=
2635 "", /* Prefix list has no interface. */
2640 config_write_prefix_ipv4 (struct vty
*vty
)
2642 return config_write_prefix_afi (AFI_IP
, vty
);
2646 prefix_list_reset_ipv4 (void)
2648 struct prefix_list
*plist
;
2649 struct prefix_list
*next
;
2650 struct prefix_master
*master
;
2652 master
= prefix_master_get (AFI_IP
);
2656 for (plist
= master
->num
.head
; plist
; plist
= next
)
2659 prefix_list_delete (plist
);
2661 for (plist
= master
->str
.head
; plist
; plist
= next
)
2664 prefix_list_delete (plist
);
2667 assert (master
->num
.head
== NULL
);
2668 assert (master
->num
.tail
== NULL
);
2670 assert (master
->str
.head
== NULL
);
2671 assert (master
->str
.tail
== NULL
);
2674 master
->recent
= NULL
;
2678 prefix_list_init_ipv4 (void)
2680 install_node (&prefix_node
, config_write_prefix_ipv4
);
2682 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2683 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2684 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2685 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2686 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2687 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2688 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2689 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2690 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2691 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2693 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2694 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2695 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2696 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2697 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2698 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2699 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2700 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2701 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2702 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2703 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2705 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2706 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2707 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2709 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2710 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2712 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2713 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2714 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2715 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2716 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2717 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2718 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2719 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2720 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2721 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2723 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2724 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2725 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2726 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2727 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2728 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2729 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2730 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2731 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2732 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2734 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2735 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2736 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2740 /* Prefix-list node. */
2741 static struct cmd_node prefix_ipv6_node
=
2744 "", /* Prefix list has no interface. */
2749 config_write_prefix_ipv6 (struct vty
*vty
)
2751 return config_write_prefix_afi (AFI_IP6
, vty
);
2755 prefix_list_reset_ipv6 (void)
2757 struct prefix_list
*plist
;
2758 struct prefix_list
*next
;
2759 struct prefix_master
*master
;
2761 master
= prefix_master_get (AFI_IP6
);
2765 for (plist
= master
->num
.head
; plist
; plist
= next
)
2768 prefix_list_delete (plist
);
2770 for (plist
= master
->str
.head
; plist
; plist
= next
)
2773 prefix_list_delete (plist
);
2776 assert (master
->num
.head
== NULL
);
2777 assert (master
->num
.tail
== NULL
);
2779 assert (master
->str
.head
== NULL
);
2780 assert (master
->str
.tail
== NULL
);
2783 master
->recent
= NULL
;
2787 prefix_list_init_ipv6 (void)
2789 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2791 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2792 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2793 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2794 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2795 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2796 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2797 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2798 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2799 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
2800 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
2802 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
2803 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
2804 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
2805 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
2806 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
2807 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
2808 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
2809 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
2810 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
2811 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
2812 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
2814 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
2815 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
2816 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
2818 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
2819 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
2821 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
2822 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
2823 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2824 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2825 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2826 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2827 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2828 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2829 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2830 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2832 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
2833 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
2834 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
2835 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
2836 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
2837 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
2838 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
2839 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
2840 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
2841 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
2843 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
2844 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
2845 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
2847 #endif /* HAVE_IPV6 */
2852 prefix_list_init_ipv4 ();
2854 prefix_list_init_ipv6 ();
2855 #endif /* HAVE_IPV6 */
2859 prefix_list_reset ()
2861 prefix_list_reset_ipv4 ();
2863 prefix_list_reset_ipv6 ();
2864 #endif /* HAVE_IPV6 */
2865 prefix_list_reset_orf ();