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.
29 #include "sockunion.h"
35 #include "plist_int.h"
37 DEFINE_MTYPE_STATIC(LIB
, PREFIX_LIST
, "Prefix List")
38 DEFINE_MTYPE_STATIC(LIB
, MPREFIX_LIST_STR
, "Prefix List Str")
39 DEFINE_MTYPE_STATIC(LIB
, PREFIX_LIST_ENTRY
, "Prefix List Entry")
40 DEFINE_MTYPE_STATIC(LIB
, PREFIX_LIST_TRIE
, "Prefix List Trie Table")
42 /* not currently changeable, code assumes bytes further down */
44 #define PLC_LEN (1 << PLC_BITS)
45 #define PLC_MAXLEVELV4 2 /* /24 for IPv4 */
46 #define PLC_MAXLEVELV6 4 /* /48 for IPv6 */
47 #define PLC_MAXLEVEL 4 /* max(v4,v6) */
51 struct pltrie_table
*next_table
;
52 struct prefix_list_entry
*final_chain
;
55 struct prefix_list_entry
*up_chain
;
59 struct pltrie_entry entries
[PLC_LEN
];
62 /* List of struct prefix_list. */
63 struct prefix_list_list
65 struct prefix_list
*head
;
66 struct prefix_list
*tail
;
69 /* Master structure of prefix_list. */
72 /* List of prefix_list which name is number. */
73 struct prefix_list_list num
;
75 /* List of prefix_list which name is string. */
76 struct prefix_list_list str
;
78 /* Whether sequential number is used. */
81 /* The latest update. */
82 struct prefix_list
*recent
;
84 /* Hook function which is executed when new prefix_list is added. */
85 void (*add_hook
) (struct prefix_list
*);
87 /* Hook function which is executed when prefix_list is deleted. */
88 void (*delete_hook
) (struct prefix_list
*);
90 /* number of bytes that have a trie level */
94 /* Static structure of IPv4 prefix_list's master. */
95 static struct prefix_master prefix_master_ipv4
=
107 /* Static structure of IPv6 prefix-list's master. */
108 static struct prefix_master prefix_master_ipv6
=
118 #endif /* HAVE_IPV6*/
120 /* Static structure of BGP ORF prefix_list's master. */
121 static struct prefix_master prefix_master_orf_v4
=
132 /* Static structure of BGP ORF prefix_list's master. */
133 static struct prefix_master prefix_master_orf_v6
=
144 static struct prefix_master
*
145 prefix_master_get (afi_t afi
, int orf
)
148 return orf
? &prefix_master_orf_v4
: &prefix_master_ipv4
;
150 return orf
? &prefix_master_orf_v6
: &prefix_master_ipv6
;
154 const char *prefix_list_name (struct prefix_list
*plist
)
159 /* Lookup prefix_list from list of prefix_list by name. */
160 static struct prefix_list
*
161 prefix_list_lookup_do (afi_t afi
, int orf
, const char *name
)
163 struct prefix_list
*plist
;
164 struct prefix_master
*master
;
169 master
= prefix_master_get (afi
, orf
);
173 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
174 if (strcmp (plist
->name
, name
) == 0)
177 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
178 if (strcmp (plist
->name
, name
) == 0)
185 prefix_list_lookup (afi_t afi
, const char *name
)
187 return prefix_list_lookup_do (afi
, 0, name
);
191 prefix_bgp_orf_lookup (afi_t afi
, const char *name
)
193 return prefix_list_lookup_do (afi
, 1, name
);
196 static struct prefix_list
*
197 prefix_list_new (void)
199 struct prefix_list
*new;
201 new = XCALLOC (MTYPE_PREFIX_LIST
, sizeof (struct prefix_list
));
206 prefix_list_free (struct prefix_list
*plist
)
208 XFREE (MTYPE_PREFIX_LIST
, plist
);
211 static struct prefix_list_entry
*
212 prefix_list_entry_new (void)
214 struct prefix_list_entry
*new;
216 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY
, sizeof (struct prefix_list_entry
));
221 prefix_list_entry_free (struct prefix_list_entry
*pentry
)
223 XFREE (MTYPE_PREFIX_LIST_ENTRY
, pentry
);
226 /* Insert new prefix list to list of prefix_list. Each prefix_list
227 is sorted by the name. */
228 static struct prefix_list
*
229 prefix_list_insert (afi_t afi
, int orf
, const char *name
)
233 struct prefix_list
*plist
;
234 struct prefix_list
*point
;
235 struct prefix_list_list
*list
;
236 struct prefix_master
*master
;
238 master
= prefix_master_get (afi
, orf
);
242 /* Allocate new prefix_list and copy given name. */
243 plist
= prefix_list_new ();
244 plist
->name
= XSTRDUP (MTYPE_MPREFIX_LIST_STR
, name
);
245 plist
->master
= master
;
246 plist
->trie
= XCALLOC (MTYPE_PREFIX_LIST_TRIE
, sizeof (struct pltrie_table
));
248 /* If name is made by all digit character. We treat it as
250 for (number
= 0, i
= 0; i
< strlen (name
); i
++)
252 if (isdigit ((int) name
[i
]))
253 number
= (number
* 10) + (name
[i
] - '0');
258 /* In case of name is all digit character */
259 if (i
== strlen (name
))
261 plist
->type
= PREFIX_TYPE_NUMBER
;
263 /* Set prefix_list to number list. */
266 for (point
= list
->head
; point
; point
= point
->next
)
267 if (atol (point
->name
) >= number
)
272 plist
->type
= PREFIX_TYPE_STRING
;
274 /* Set prefix_list to string list. */
277 /* Set point to insertion point. */
278 for (point
= list
->head
; point
; point
= point
->next
)
279 if (strcmp (point
->name
, name
) >= 0)
283 /* In case of this is the first element of master. */
284 if (list
->head
== NULL
)
286 list
->head
= list
->tail
= plist
;
290 /* In case of insertion is made at the tail of access_list. */
293 plist
->prev
= list
->tail
;
294 list
->tail
->next
= plist
;
299 /* In case of insertion is made at the head of access_list. */
300 if (point
== list
->head
)
302 plist
->next
= list
->head
;
303 list
->head
->prev
= plist
;
308 /* Insertion is made at middle of the access_list. */
310 plist
->prev
= point
->prev
;
313 point
->prev
->next
= plist
;
319 static struct prefix_list
*
320 prefix_list_get (afi_t afi
, int orf
, const char *name
)
322 struct prefix_list
*plist
;
324 plist
= prefix_list_lookup_do (afi
, orf
, name
);
327 plist
= prefix_list_insert (afi
, orf
, name
);
331 /* Delete prefix-list from prefix_list_master and free it. */
333 prefix_list_delete (struct prefix_list
*plist
)
335 struct prefix_list_list
*list
;
336 struct prefix_master
*master
;
337 struct prefix_list_entry
*pentry
;
338 struct prefix_list_entry
*next
;
340 /* If prefix-list contain prefix_list_entry free all of it. */
341 for (pentry
= plist
->head
; pentry
; pentry
= next
)
344 prefix_list_entry_free (pentry
);
348 master
= plist
->master
;
350 if (plist
->type
== PREFIX_TYPE_NUMBER
)
356 plist
->next
->prev
= plist
->prev
;
358 list
->tail
= plist
->prev
;
361 plist
->prev
->next
= plist
->next
;
363 list
->head
= plist
->next
;
366 XFREE (MTYPE_TMP
, plist
->desc
);
368 /* Make sure master's recent changed prefix-list information is
370 master
->recent
= NULL
;
372 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
374 if (master
->delete_hook
)
375 (*master
->delete_hook
) (plist
);
378 XFREE (MTYPE_MPREFIX_LIST_STR
, plist
->name
);
380 XFREE (MTYPE_PREFIX_LIST_TRIE
, plist
->trie
);
382 prefix_list_free (plist
);
386 static struct prefix_list_entry
*
387 prefix_list_entry_make (struct prefix
*prefix
, enum prefix_list_type type
,
388 int seq
, int le
, int ge
, int any
)
390 struct prefix_list_entry
*pentry
;
392 pentry
= prefix_list_entry_new ();
397 prefix_copy (&pentry
->prefix
, prefix
);
406 /* Add hook function. */
408 prefix_list_add_hook (void (*func
) (struct prefix_list
*plist
))
410 prefix_master_ipv4
.add_hook
= func
;
412 prefix_master_ipv6
.add_hook
= func
;
413 #endif /* HAVE_IPV6 */
416 /* Delete hook function. */
418 prefix_list_delete_hook (void (*func
) (struct prefix_list
*plist
))
420 prefix_master_ipv4
.delete_hook
= func
;
422 prefix_master_ipv6
.delete_hook
= func
;
423 #endif /* HAVE_IPVt6 */
426 /* Calculate new sequential number. */
428 prefix_new_seq_get (struct prefix_list
*plist
)
432 struct prefix_list_entry
*pentry
;
436 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
438 if (maxseq
< pentry
->seq
)
439 maxseq
= pentry
->seq
;
442 newseq
= ((maxseq
/ 5) * 5) + 5;
447 /* Return prefix list entry which has same seq number. */
448 static struct prefix_list_entry
*
449 prefix_seq_check (struct prefix_list
*plist
, int seq
)
451 struct prefix_list_entry
*pentry
;
453 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
454 if (pentry
->seq
== seq
)
459 static struct prefix_list_entry
*
460 prefix_list_entry_lookup (struct prefix_list
*plist
, struct prefix
*prefix
,
461 enum prefix_list_type type
, int seq
, int le
, int ge
)
463 struct prefix_list_entry
*pentry
;
465 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
466 if (prefix_same (&pentry
->prefix
, prefix
) && pentry
->type
== type
)
468 if (seq
>= 0 && pentry
->seq
!= seq
)
471 if (pentry
->le
!= le
)
473 if (pentry
->ge
!= ge
)
483 trie_walk_affected (size_t validbits
, struct pltrie_table
*table
, uint8_t byte
,
484 struct prefix_list_entry
*object
,
485 void (*fn
)(struct prefix_list_entry
*object
,
486 struct prefix_list_entry
**updptr
))
491 if (validbits
> PLC_BITS
)
493 fn (object
, &table
->entries
[byte
].final_chain
);
497 mask
= (1 << (8 - validbits
)) - 1;
498 for (bwalk
= byte
& ~mask
; bwalk
<= byte
+ mask
; bwalk
++)
500 fn (object
, &table
->entries
[bwalk
].up_chain
);
504 static void trie_uninstall_fn (struct prefix_list_entry
*object
,
505 struct prefix_list_entry
**updptr
)
507 for (; *updptr
; updptr
= &(*updptr
)->next_best
)
508 if (*updptr
== object
)
510 *updptr
= object
->next_best
;
516 trie_table_empty (struct pltrie_table
*table
)
519 for (i
= 0; i
< PLC_LEN
; i
++)
520 if (table
->entries
[i
].next_table
|| table
->entries
[i
].up_chain
)
526 prefix_list_trie_del (struct prefix_list
*plist
,
527 struct prefix_list_entry
*pentry
)
529 size_t depth
, maxdepth
= plist
->master
->trie_depth
;
530 uint8_t *bytes
= &pentry
->prefix
.u
.prefix
;
531 size_t validbits
= pentry
->prefix
.prefixlen
;
532 struct pltrie_table
*table
, **tables
[PLC_MAXLEVEL
];
535 for (depth
= 0; validbits
> PLC_BITS
&& depth
< maxdepth
- 1; depth
++)
537 uint8_t byte
= bytes
[depth
];
538 assert (table
->entries
[byte
].next_table
);
540 tables
[depth
+ 1] = &table
->entries
[byte
].next_table
;
541 table
= table
->entries
[byte
].next_table
;
543 validbits
-= PLC_BITS
;
546 trie_walk_affected (validbits
, table
, bytes
[depth
], pentry
, trie_uninstall_fn
);
548 for (; depth
> 0; depth
--)
549 if (trie_table_empty (*tables
[depth
]))
551 XFREE (MTYPE_PREFIX_LIST_TRIE
, *tables
[depth
]);
552 *tables
[depth
] = NULL
;
558 prefix_list_entry_delete (struct prefix_list
*plist
,
559 struct prefix_list_entry
*pentry
,
562 prefix_list_trie_del (plist
, pentry
);
564 if (plist
== NULL
|| pentry
== NULL
)
567 pentry
->prev
->next
= pentry
->next
;
569 plist
->head
= pentry
->next
;
571 pentry
->next
->prev
= pentry
->prev
;
573 plist
->tail
= pentry
->prev
;
575 prefix_list_entry_free (pentry
);
581 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
582 if (plist
->master
->delete_hook
)
583 (*plist
->master
->delete_hook
) (plist
);
585 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
586 prefix_list_delete (plist
);
588 plist
->master
->recent
= plist
;
592 static void trie_install_fn (struct prefix_list_entry
*object
,
593 struct prefix_list_entry
**updptr
)
597 if (*updptr
== object
)
599 if ((*updptr
)->prefix
.prefixlen
< object
->prefix
.prefixlen
)
601 if ((*updptr
)->seq
> object
->seq
)
603 updptr
= &(*updptr
)->next_best
;
606 if (!object
->next_best
)
607 object
->next_best
= *updptr
;
609 assert (object
->next_best
== *updptr
|| !*updptr
);
615 prefix_list_trie_add (struct prefix_list
*plist
,
616 struct prefix_list_entry
*pentry
)
618 size_t depth
= plist
->master
->trie_depth
;
619 uint8_t *bytes
= &pentry
->prefix
.u
.prefix
;
620 size_t validbits
= pentry
->prefix
.prefixlen
;
621 struct pltrie_table
*table
;
624 while (validbits
> PLC_BITS
&& depth
> 1)
626 if (!table
->entries
[*bytes
].next_table
)
627 table
->entries
[*bytes
].next_table
= XCALLOC (MTYPE_PREFIX_LIST_TRIE
,
628 sizeof(struct pltrie_table
));
629 table
= table
->entries
[*bytes
].next_table
;
632 validbits
-= PLC_BITS
;
635 trie_walk_affected (validbits
, table
, *bytes
, pentry
, trie_install_fn
);
639 prefix_list_entry_add (struct prefix_list
*plist
,
640 struct prefix_list_entry
*pentry
)
642 struct prefix_list_entry
*replace
;
643 struct prefix_list_entry
*point
;
645 /* Automatic asignment of seq no. */
646 if (pentry
->seq
== -1)
647 pentry
->seq
= prefix_new_seq_get (plist
);
649 if (plist
->tail
&& pentry
->seq
> plist
->tail
->seq
)
653 /* Is there any same seq prefix list entry? */
654 replace
= prefix_seq_check (plist
, pentry
->seq
);
656 prefix_list_entry_delete (plist
, replace
, 0);
658 /* Check insert point. */
659 for (point
= plist
->head
; point
; point
= point
->next
)
660 if (point
->seq
>= pentry
->seq
)
664 /* In case of this is the first element of the list. */
665 pentry
->next
= point
;
670 point
->prev
->next
= pentry
;
672 plist
->head
= pentry
;
674 pentry
->prev
= point
->prev
;
675 point
->prev
= pentry
;
680 plist
->tail
->next
= pentry
;
682 plist
->head
= pentry
;
684 pentry
->prev
= plist
->tail
;
685 plist
->tail
= pentry
;
688 prefix_list_trie_add (plist
, pentry
);
690 /* Increment count. */
693 /* Run hook function. */
694 if (plist
->master
->add_hook
)
695 (*plist
->master
->add_hook
) (plist
);
697 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_ADDED
);
698 plist
->master
->recent
= plist
;
701 /* Return string of prefix_list_type. */
703 prefix_list_type_str (struct prefix_list_entry
*pentry
)
705 switch (pentry
->type
)
717 prefix_list_entry_match (struct prefix_list_entry
*pentry
, struct prefix
*p
)
721 ret
= prefix_match (&pentry
->prefix
, p
);
725 /* In case of le nor ge is specified, exact match is performed. */
726 if (! pentry
->le
&& ! pentry
->ge
)
728 if (pentry
->prefix
.prefixlen
!= p
->prefixlen
)
734 if (p
->prefixlen
> pentry
->le
)
738 if (p
->prefixlen
< pentry
->ge
)
744 enum prefix_list_type
745 prefix_list_apply (struct prefix_list
*plist
, void *object
)
747 struct prefix_list_entry
*pentry
, *pbest
= NULL
;
749 struct prefix
*p
= (struct prefix
*) object
;
750 uint8_t *byte
= &p
->u
.prefix
;
752 size_t validbits
= p
->prefixlen
;
753 struct pltrie_table
*table
;
758 if (plist
->count
== 0)
759 return PREFIX_PERMIT
;
761 depth
= plist
->master
->trie_depth
;
765 for (pentry
= table
->entries
[*byte
].up_chain
; pentry
; pentry
= pentry
->next_best
)
767 if (pbest
&& pbest
->seq
< pentry
->seq
)
769 if (prefix_list_entry_match (pentry
, p
))
773 if (validbits
<= PLC_BITS
)
775 validbits
-= PLC_BITS
;
779 if (!table
->entries
[*byte
].next_table
)
782 table
= table
->entries
[*byte
].next_table
;
787 for (pentry
= table
->entries
[*byte
].final_chain
; pentry
; pentry
= pentry
->next_best
)
789 if (pbest
&& pbest
->seq
< pentry
->seq
)
791 if (prefix_list_entry_match (pentry
, p
))
803 static void __attribute__ ((unused
))
804 prefix_list_print (struct prefix_list
*plist
)
806 struct prefix_list_entry
*pentry
;
811 printf ("ip prefix-list %s: %d entries\n", plist
->name
, plist
->count
);
813 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
816 printf ("any %s\n", prefix_list_type_str (pentry
));
824 printf (" seq %u %s %s/%d",
826 prefix_list_type_str (pentry
),
827 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
830 printf (" ge %d", pentry
->ge
);
832 printf (" le %d", pentry
->le
);
838 /* Retrun 1 when plist already include pentry policy. */
839 static struct prefix_list_entry
*
840 prefix_entry_dup_check (struct prefix_list
*plist
,
841 struct prefix_list_entry
*new)
843 size_t depth
, maxdepth
= plist
->master
->trie_depth
;
844 uint8_t byte
, *bytes
= &new->prefix
.u
.prefix
;
845 size_t validbits
= new->prefix
.prefixlen
;
846 struct pltrie_table
*table
;
847 struct prefix_list_entry
*pentry
;
851 seq
= prefix_new_seq_get (plist
);
856 for (depth
= 0; validbits
> PLC_BITS
&& depth
< maxdepth
- 1; depth
++)
859 if (!table
->entries
[byte
].next_table
)
862 table
= table
->entries
[byte
].next_table
;
863 validbits
-= PLC_BITS
;
867 if (validbits
> PLC_BITS
)
868 pentry
= table
->entries
[byte
].final_chain
;
870 pentry
= table
->entries
[byte
].up_chain
;
872 for (; pentry
; pentry
= pentry
->next_best
)
874 if (prefix_same (&pentry
->prefix
, &new->prefix
)
875 && pentry
->type
== new->type
876 && pentry
->le
== new->le
877 && pentry
->ge
== new->ge
878 && pentry
->seq
!= seq
)
885 vty_invalid_prefix_range (struct vty
*vty
, const char *prefix
)
887 vty_out (vty
, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
888 prefix
, VTY_NEWLINE
);
893 vty_prefix_list_install (struct vty
*vty
, afi_t afi
, const char *name
,
894 const char *seq
, const char *typestr
,
895 const char *prefix
, const char *ge
, const char *le
)
898 enum prefix_list_type type
;
899 struct prefix_list
*plist
;
900 struct prefix_list_entry
*pentry
;
901 struct prefix_list_entry
*dup
;
902 struct prefix p
, p_tmp
;
908 /* Sequential number. */
912 /* ge and le number */
918 /* Check filter type. */
919 if (strncmp ("permit", typestr
, 1) == 0)
920 type
= PREFIX_PERMIT
;
921 else if (strncmp ("deny", typestr
, 1) == 0)
925 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
929 /* "any" is special token for matching any IPv4 addresses. */
933 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
935 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
937 lenum
= IPV4_MAX_BITLEN
;
941 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
945 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
949 /* make a copy to verify prefix matches mask length */
950 prefix_copy (&p_tmp
, &p
);
951 apply_mask_ipv4 ((struct prefix_ipv4
*) &p_tmp
);
955 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
957 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
959 lenum
= IPV6_MAX_BITLEN
;
963 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
967 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
971 /* make a copy to verify prefix matches mask length */
972 prefix_copy (&p_tmp
, &p
);
973 apply_mask_ipv6 ((struct prefix_ipv6
*) &p_tmp
);
978 vty_out (vty
, "%% Unrecognized AFI (%d)%s", afi
, VTY_NEWLINE
);
983 /* If prefix has bits not under the mask, adjust it to fit */
984 if (!prefix_same (&p_tmp
, &p
))
986 char buf
[PREFIX2STR_BUFFER
];
987 char buf_tmp
[PREFIX2STR_BUFFER
];
988 prefix2str(&p
, buf
, sizeof(buf
));
989 prefix2str(&p_tmp
, buf_tmp
, sizeof(buf_tmp
));
990 zlog_warn ("Prefix-list %s prefix changed from %s to %s to match length",
995 /* ge and le check. */
996 if (genum
&& (genum
<= p
.prefixlen
))
997 return vty_invalid_prefix_range (vty
, prefix
);
999 if (lenum
&& (lenum
<= p
.prefixlen
))
1000 return vty_invalid_prefix_range (vty
, prefix
);
1002 if (lenum
&& (genum
> lenum
))
1003 return vty_invalid_prefix_range (vty
, prefix
);
1005 if (genum
&& (lenum
== (afi
== AFI_IP
? 32 : 128)))
1008 /* Get prefix_list with name. */
1009 plist
= prefix_list_get (afi
, 0, name
);
1011 /* Make prefix entry. */
1012 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
1014 /* Check same policy. */
1015 dup
= prefix_entry_dup_check (plist
, pentry
);
1019 prefix_list_entry_free (pentry
);
1023 /* Install new filter to the access_list. */
1024 prefix_list_entry_add (plist
, pentry
);
1030 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
1031 const char *seq
, const char *typestr
,
1032 const char *prefix
, const char *ge
, const char *le
)
1035 enum prefix_list_type type
;
1036 struct prefix_list
*plist
;
1037 struct prefix_list_entry
*pentry
;
1043 /* Check prefix list name. */
1044 plist
= prefix_list_lookup (afi
, name
);
1047 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1051 /* Only prefix-list name specified, delete the entire prefix-list. */
1052 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
1053 ge
== NULL
&& le
== NULL
)
1055 prefix_list_delete (plist
);
1059 /* We must have, at a minimum, both the type and prefix here */
1060 if ((typestr
== NULL
) || (prefix
== NULL
))
1062 vty_out (vty
, "%% Both prefix and type required%s", VTY_NEWLINE
);
1066 /* Check sequence number. */
1068 seqnum
= atoi (seq
);
1070 /* ge and le number */
1076 /* Check of filter type. */
1077 if (strncmp ("permit", typestr
, 1) == 0)
1078 type
= PREFIX_PERMIT
;
1079 else if (strncmp ("deny", typestr
, 1) == 0)
1083 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
1087 /* "any" is special token for matching any IPv4 addresses. */
1090 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1092 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
1094 lenum
= IPV4_MAX_BITLEN
;
1097 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
1101 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
1106 else if (afi
== AFI_IP6
)
1108 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1110 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
1112 lenum
= IPV6_MAX_BITLEN
;
1115 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
1119 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
1123 #endif /* HAVE_IPV6 */
1125 /* Lookup prefix entry. */
1126 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
1130 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1134 /* Install new filter to the access_list. */
1135 prefix_list_entry_delete (plist
, pentry
, 1);
1141 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
1143 struct prefix_list
*plist
;
1145 plist
= prefix_list_lookup (afi
, name
);
1148 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1154 XFREE (MTYPE_TMP
, plist
->desc
);
1158 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
1159 prefix_list_delete (plist
);
1175 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
1176 struct prefix_master
*master
, enum display_type dtype
,
1179 struct prefix_list_entry
*pentry
;
1181 /* Print the name of the protocol */
1183 vty_out (vty
, "%s: ", zlog_proto_names
[zlog_default
->protocol
]);
1185 if (dtype
== normal_display
)
1187 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
1188 afi
== AFI_IP
? "" : "v6",
1189 plist
->name
, plist
->count
, VTY_NEWLINE
);
1191 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1193 else if (dtype
== summary_display
|| dtype
== detail_display
)
1195 vty_out (vty
, "ip%s prefix-list %s:%s",
1196 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
1199 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1201 vty_out (vty
, " count: %d, range entries: %d, sequences: %u - %u%s",
1202 plist
->count
, plist
->rangecount
,
1203 plist
->head
? plist
->head
->seq
: 0,
1204 plist
->tail
? plist
->tail
->seq
: 0,
1208 if (dtype
!= summary_display
)
1210 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1212 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
1218 vty_out (vty
, "seq %u ", pentry
->seq
);
1220 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
1223 vty_out (vty
, "any");
1226 struct prefix
*p
= &pentry
->prefix
;
1229 vty_out (vty
, "%s/%d",
1230 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1234 vty_out (vty
, " ge %d", pentry
->ge
);
1236 vty_out (vty
, " le %d", pentry
->le
);
1239 if (dtype
== detail_display
|| dtype
== sequential_display
)
1240 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1241 pentry
->hitcnt
, pentry
->refcnt
);
1243 vty_out (vty
, "%s", VTY_NEWLINE
);
1249 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1250 const char *seq
, enum display_type dtype
)
1252 struct prefix_list
*plist
;
1253 struct prefix_master
*master
;
1256 master
= prefix_master_get (afi
, 0);
1261 seqnum
= atoi (seq
);
1265 plist
= prefix_list_lookup (afi
, name
);
1268 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1271 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1275 if (dtype
== detail_display
|| dtype
== summary_display
)
1278 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1279 master
->recent
->name
, VTY_NEWLINE
);
1282 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1283 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1285 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1286 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1293 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1294 const char *prefix
, enum display_type type
)
1296 struct prefix_list
*plist
;
1297 struct prefix_list_entry
*pentry
;
1302 plist
= prefix_list_lookup (afi
, name
);
1305 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1309 ret
= str2prefix (prefix
, &p
);
1312 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1316 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1320 if (type
== normal_display
|| type
== first_match_display
)
1321 if (prefix_same (&p
, &pentry
->prefix
))
1324 if (type
== longer_display
)
1325 if (prefix_match (&p
, &pentry
->prefix
))
1330 vty_out (vty
, " seq %u %s ",
1332 prefix_list_type_str (pentry
));
1335 vty_out (vty
, "any");
1338 struct prefix
*p
= &pentry
->prefix
;
1341 vty_out (vty
, "%s/%d",
1342 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1346 vty_out (vty
, " ge %d", pentry
->ge
);
1348 vty_out (vty
, " le %d", pentry
->le
);
1351 if (type
== normal_display
|| type
== first_match_display
)
1352 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1353 pentry
->hitcnt
, pentry
->refcnt
);
1355 vty_out (vty
, "%s", VTY_NEWLINE
);
1357 if (type
== first_match_display
)
1365 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1368 struct prefix_master
*master
;
1369 struct prefix_list
*plist
;
1370 struct prefix_list_entry
*pentry
;
1374 master
= prefix_master_get (afi
, 0);
1378 if (name
== NULL
&& prefix
== NULL
)
1380 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1381 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1384 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1385 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1390 plist
= prefix_list_lookup (afi
, name
);
1393 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1399 ret
= str2prefix (prefix
, &p
);
1402 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1407 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1411 if (prefix_match (&pentry
->prefix
, &p
))
1421 DEFUN (ip_prefix_list
,
1423 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1426 "Name of a prefix list\n"
1427 "Specify packets to reject\n"
1428 "Specify packets to forward\n"
1429 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1430 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1432 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1433 argv
[1], argv
[2], NULL
, NULL
);
1436 DEFUN (ip_prefix_list_ge
,
1437 ip_prefix_list_ge_cmd
,
1438 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1441 "Name of a prefix list\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 "Minimum prefix length to be matched\n"
1446 "Minimum prefix length\n")
1448 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1449 argv
[2], argv
[3], NULL
);
1452 DEFUN (ip_prefix_list_ge_le
,
1453 ip_prefix_list_ge_le_cmd
,
1454 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1457 "Name of a prefix list\n"
1458 "Specify packets to reject\n"
1459 "Specify packets to forward\n"
1460 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1461 "Minimum prefix length to be matched\n"
1462 "Minimum prefix length\n"
1463 "Maximum prefix length to be matched\n"
1464 "Maximum prefix length\n")
1466 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1467 argv
[2], argv
[3], argv
[4]);
1470 DEFUN (ip_prefix_list_le
,
1471 ip_prefix_list_le_cmd
,
1472 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1475 "Name of a prefix list\n"
1476 "Specify packets to reject\n"
1477 "Specify packets to forward\n"
1478 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1479 "Maximum prefix length to be matched\n"
1480 "Maximum prefix length\n")
1482 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1483 argv
[2], NULL
, argv
[3]);
1486 DEFUN (ip_prefix_list_le_ge
,
1487 ip_prefix_list_le_ge_cmd
,
1488 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1491 "Name of a prefix list\n"
1492 "Specify packets to reject\n"
1493 "Specify packets to forward\n"
1494 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1495 "Maximum prefix length to be matched\n"
1496 "Maximum prefix length\n"
1497 "Minimum prefix length to be matched\n"
1498 "Minimum prefix length\n")
1500 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1501 argv
[2], argv
[4], argv
[3]);
1504 DEFUN (ip_prefix_list_seq
,
1505 ip_prefix_list_seq_cmd
,
1506 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1509 "Name of a prefix list\n"
1510 "sequence number of an entry\n"
1512 "Specify packets to reject\n"
1513 "Specify packets to forward\n"
1514 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1515 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1517 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1518 argv
[3], NULL
, NULL
);
1521 DEFUN (ip_prefix_list_seq_ge
,
1522 ip_prefix_list_seq_ge_cmd
,
1523 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1526 "Name of a prefix list\n"
1527 "sequence number of an entry\n"
1529 "Specify packets to reject\n"
1530 "Specify packets to forward\n"
1531 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1532 "Minimum prefix length to be matched\n"
1533 "Minimum prefix length\n")
1535 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1536 argv
[3], argv
[4], NULL
);
1539 DEFUN (ip_prefix_list_seq_ge_le
,
1540 ip_prefix_list_seq_ge_le_cmd
,
1541 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1544 "Name of a prefix list\n"
1545 "sequence number of an entry\n"
1547 "Specify packets to reject\n"
1548 "Specify packets to forward\n"
1549 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1550 "Minimum prefix length to be matched\n"
1551 "Minimum prefix length\n"
1552 "Maximum prefix length to be matched\n"
1553 "Maximum prefix length\n")
1555 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1556 argv
[3], argv
[4], argv
[5]);
1559 DEFUN (ip_prefix_list_seq_le
,
1560 ip_prefix_list_seq_le_cmd
,
1561 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1564 "Name of a prefix list\n"
1565 "sequence number of an entry\n"
1567 "Specify packets to reject\n"
1568 "Specify packets to forward\n"
1569 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1570 "Maximum prefix length to be matched\n"
1571 "Maximum prefix length\n")
1573 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1574 argv
[3], NULL
, argv
[4]);
1577 DEFUN (ip_prefix_list_seq_le_ge
,
1578 ip_prefix_list_seq_le_ge_cmd
,
1579 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1582 "Name of a prefix list\n"
1583 "sequence number of an entry\n"
1585 "Specify packets to reject\n"
1586 "Specify packets to forward\n"
1587 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1588 "Maximum prefix length to be matched\n"
1589 "Maximum prefix length\n"
1590 "Minimum prefix length to be matched\n"
1591 "Minimum prefix length\n")
1593 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1594 argv
[3], argv
[5], argv
[4]);
1597 DEFUN (no_ip_prefix_list
,
1598 no_ip_prefix_list_cmd
,
1599 "no ip prefix-list WORD",
1603 "Name of a prefix list\n")
1605 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1609 DEFUN (no_ip_prefix_list_prefix
,
1610 no_ip_prefix_list_prefix_cmd
,
1611 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1615 "Name of a prefix list\n"
1616 "Specify packets to reject\n"
1617 "Specify packets to forward\n"
1618 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1619 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1621 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1622 argv
[2], NULL
, NULL
);
1625 DEFUN (no_ip_prefix_list_ge
,
1626 no_ip_prefix_list_ge_cmd
,
1627 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1631 "Name of a prefix list\n"
1632 "Specify packets to reject\n"
1633 "Specify packets to forward\n"
1634 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1635 "Minimum prefix length to be matched\n"
1636 "Minimum prefix length\n")
1638 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1639 argv
[2], argv
[3], NULL
);
1642 DEFUN (no_ip_prefix_list_ge_le
,
1643 no_ip_prefix_list_ge_le_cmd
,
1644 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1648 "Name of a prefix list\n"
1649 "Specify packets to reject\n"
1650 "Specify packets to forward\n"
1651 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1652 "Minimum prefix length to be matched\n"
1653 "Minimum prefix length\n"
1654 "Maximum prefix length to be matched\n"
1655 "Maximum prefix length\n")
1657 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1658 argv
[2], argv
[3], argv
[4]);
1661 DEFUN (no_ip_prefix_list_le
,
1662 no_ip_prefix_list_le_cmd
,
1663 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1667 "Name of a prefix list\n"
1668 "Specify packets to reject\n"
1669 "Specify packets to forward\n"
1670 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1671 "Maximum prefix length to be matched\n"
1672 "Maximum prefix length\n")
1674 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1675 argv
[2], NULL
, argv
[3]);
1678 DEFUN (no_ip_prefix_list_le_ge
,
1679 no_ip_prefix_list_le_ge_cmd
,
1680 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1684 "Name of a prefix list\n"
1685 "Specify packets to reject\n"
1686 "Specify packets to forward\n"
1687 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1688 "Maximum prefix length to be matched\n"
1689 "Maximum prefix length\n"
1690 "Minimum prefix length to be matched\n"
1691 "Minimum prefix length\n")
1693 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1694 argv
[2], argv
[4], argv
[3]);
1697 DEFUN (no_ip_prefix_list_seq
,
1698 no_ip_prefix_list_seq_cmd
,
1699 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1703 "Name of a prefix list\n"
1704 "sequence number of an entry\n"
1706 "Specify packets to reject\n"
1707 "Specify packets to forward\n"
1708 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1709 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1711 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1712 argv
[3], NULL
, NULL
);
1715 DEFUN (no_ip_prefix_list_seq_ge
,
1716 no_ip_prefix_list_seq_ge_cmd
,
1717 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1721 "Name of a prefix list\n"
1722 "sequence number of an entry\n"
1724 "Specify packets to reject\n"
1725 "Specify packets to forward\n"
1726 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1727 "Minimum prefix length to be matched\n"
1728 "Minimum prefix length\n")
1730 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1731 argv
[3], argv
[4], NULL
);
1734 DEFUN (no_ip_prefix_list_seq_ge_le
,
1735 no_ip_prefix_list_seq_ge_le_cmd
,
1736 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1740 "Name of a prefix list\n"
1741 "sequence number of an entry\n"
1743 "Specify packets to reject\n"
1744 "Specify packets to forward\n"
1745 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1746 "Minimum prefix length to be matched\n"
1747 "Minimum prefix length\n"
1748 "Maximum prefix length to be matched\n"
1749 "Maximum prefix length\n")
1751 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1752 argv
[3], argv
[4], argv
[5]);
1755 DEFUN (no_ip_prefix_list_seq_le
,
1756 no_ip_prefix_list_seq_le_cmd
,
1757 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1761 "Name of a prefix list\n"
1762 "sequence number of an entry\n"
1764 "Specify packets to reject\n"
1765 "Specify packets to forward\n"
1766 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1767 "Maximum prefix length to be matched\n"
1768 "Maximum prefix length\n")
1770 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1771 argv
[3], NULL
, argv
[4]);
1774 DEFUN (no_ip_prefix_list_seq_le_ge
,
1775 no_ip_prefix_list_seq_le_ge_cmd
,
1776 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1780 "Name of a prefix list\n"
1781 "sequence number of an entry\n"
1783 "Specify packets to reject\n"
1784 "Specify packets to forward\n"
1785 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1786 "Maximum prefix length to be matched\n"
1787 "Maximum prefix length\n"
1788 "Minimum prefix length to be matched\n"
1789 "Minimum prefix length\n")
1791 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1792 argv
[3], argv
[5], argv
[4]);
1795 DEFUN (ip_prefix_list_sequence_number
,
1796 ip_prefix_list_sequence_number_cmd
,
1797 "ip prefix-list sequence-number",
1800 "Include/exclude sequence numbers in NVGEN\n")
1802 prefix_master_ipv4
.seqnum
= 1;
1806 DEFUN (no_ip_prefix_list_sequence_number
,
1807 no_ip_prefix_list_sequence_number_cmd
,
1808 "no ip prefix-list sequence-number",
1812 "Include/exclude sequence numbers in NVGEN\n")
1814 prefix_master_ipv4
.seqnum
= 0;
1818 DEFUN (ip_prefix_list_description
,
1819 ip_prefix_list_description_cmd
,
1820 "ip prefix-list WORD description .LINE",
1823 "Name of a prefix list\n"
1824 "Prefix-list specific description\n"
1825 "Up to 80 characters describing this prefix-list\n")
1827 struct prefix_list
*plist
;
1829 plist
= prefix_list_get (AFI_IP
, 0, argv
[0]);
1833 XFREE (MTYPE_TMP
, plist
->desc
);
1836 plist
->desc
= argv_concat(argv
, argc
, 1);
1841 DEFUN (no_ip_prefix_list_description
,
1842 no_ip_prefix_list_description_cmd
,
1843 "no ip prefix-list WORD description",
1847 "Name of a prefix list\n"
1848 "Prefix-list specific description\n")
1850 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1853 ALIAS (no_ip_prefix_list_description
,
1854 no_ip_prefix_list_description_arg_cmd
,
1855 "no ip prefix-list WORD description .LINE",
1859 "Name of a prefix list\n"
1860 "Prefix-list specific description\n"
1861 "Up to 80 characters describing this prefix-list\n")
1863 DEFUN (show_ip_prefix_list
,
1864 show_ip_prefix_list_cmd
,
1865 "show ip prefix-list",
1870 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1873 DEFUN (show_ip_prefix_list_name
,
1874 show_ip_prefix_list_name_cmd
,
1875 "show ip prefix-list WORD",
1879 "Name of a prefix list\n")
1881 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1884 DEFUN (show_ip_prefix_list_name_seq
,
1885 show_ip_prefix_list_name_seq_cmd
,
1886 "show ip prefix-list WORD seq <1-4294967295>",
1890 "Name of a prefix list\n"
1891 "sequence number of an entry\n"
1892 "Sequence number\n")
1894 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1897 DEFUN (show_ip_prefix_list_prefix
,
1898 show_ip_prefix_list_prefix_cmd
,
1899 "show ip prefix-list WORD A.B.C.D/M",
1903 "Name of a prefix list\n"
1904 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1906 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1909 DEFUN (show_ip_prefix_list_prefix_longer
,
1910 show_ip_prefix_list_prefix_longer_cmd
,
1911 "show ip prefix-list WORD A.B.C.D/M longer",
1915 "Name of a prefix list\n"
1916 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1917 "Lookup longer prefix\n")
1919 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1922 DEFUN (show_ip_prefix_list_prefix_first_match
,
1923 show_ip_prefix_list_prefix_first_match_cmd
,
1924 "show ip prefix-list WORD A.B.C.D/M first-match",
1928 "Name of a prefix list\n"
1929 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1930 "First matched prefix\n")
1932 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1935 DEFUN (show_ip_prefix_list_summary
,
1936 show_ip_prefix_list_summary_cmd
,
1937 "show ip prefix-list summary",
1941 "Summary of prefix lists\n")
1943 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1946 DEFUN (show_ip_prefix_list_summary_name
,
1947 show_ip_prefix_list_summary_name_cmd
,
1948 "show ip prefix-list summary WORD",
1952 "Summary of prefix lists\n"
1953 "Name of a prefix list\n")
1955 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1959 DEFUN (show_ip_prefix_list_detail
,
1960 show_ip_prefix_list_detail_cmd
,
1961 "show ip prefix-list detail",
1965 "Detail of prefix lists\n")
1967 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1970 DEFUN (show_ip_prefix_list_detail_name
,
1971 show_ip_prefix_list_detail_name_cmd
,
1972 "show ip prefix-list detail WORD",
1976 "Detail of prefix lists\n"
1977 "Name of a prefix list\n")
1979 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1982 DEFUN (clear_ip_prefix_list
,
1983 clear_ip_prefix_list_cmd
,
1984 "clear ip prefix-list",
1989 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1992 DEFUN (clear_ip_prefix_list_name
,
1993 clear_ip_prefix_list_name_cmd
,
1994 "clear ip prefix-list WORD",
1998 "Name of a prefix list\n")
2000 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
2003 DEFUN (clear_ip_prefix_list_name_prefix
,
2004 clear_ip_prefix_list_name_prefix_cmd
,
2005 "clear ip prefix-list WORD A.B.C.D/M",
2009 "Name of a prefix list\n"
2010 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2012 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
2016 DEFUN (ipv6_prefix_list
,
2017 ipv6_prefix_list_cmd
,
2018 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
2021 "Name of a prefix list\n"
2022 "Specify packets to reject\n"
2023 "Specify packets to forward\n"
2024 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2025 "Any prefix match. Same as \"::0/0 le 128\"\n")
2027 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
2028 argv
[1], argv
[2], NULL
, NULL
);
2031 DEFUN (ipv6_prefix_list_ge
,
2032 ipv6_prefix_list_ge_cmd
,
2033 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2036 "Name of a prefix list\n"
2037 "Specify packets to reject\n"
2038 "Specify packets to forward\n"
2039 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2040 "Minimum prefix length to be matched\n"
2041 "Minimum prefix length\n")
2043 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2044 argv
[2], argv
[3], NULL
);
2047 DEFUN (ipv6_prefix_list_ge_le
,
2048 ipv6_prefix_list_ge_le_cmd
,
2049 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2052 "Name of a prefix list\n"
2053 "Specify packets to reject\n"
2054 "Specify packets to forward\n"
2055 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2056 "Minimum prefix length to be matched\n"
2057 "Minimum prefix length\n"
2058 "Maximum prefix length to be matched\n"
2059 "Maximum prefix length\n")
2062 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2063 argv
[2], argv
[3], argv
[4]);
2066 DEFUN (ipv6_prefix_list_le
,
2067 ipv6_prefix_list_le_cmd
,
2068 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2071 "Name of a prefix list\n"
2072 "Specify packets to reject\n"
2073 "Specify packets to forward\n"
2074 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2075 "Maximum prefix length to be matched\n"
2076 "Maximum prefix length\n")
2078 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2079 argv
[2], NULL
, argv
[3]);
2082 DEFUN (ipv6_prefix_list_le_ge
,
2083 ipv6_prefix_list_le_ge_cmd
,
2084 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2087 "Name of a prefix list\n"
2088 "Specify packets to reject\n"
2089 "Specify packets to forward\n"
2090 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2091 "Maximum prefix length to be matched\n"
2092 "Maximum prefix length\n"
2093 "Minimum prefix length to be matched\n"
2094 "Minimum prefix length\n")
2096 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2097 argv
[2], argv
[4], argv
[3]);
2100 DEFUN (ipv6_prefix_list_seq
,
2101 ipv6_prefix_list_seq_cmd
,
2102 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2105 "Name of a prefix list\n"
2106 "sequence number of an entry\n"
2108 "Specify packets to reject\n"
2109 "Specify packets to forward\n"
2110 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2111 "Any prefix match. Same as \"::0/0 le 128\"\n")
2113 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2114 argv
[3], NULL
, NULL
);
2117 DEFUN (ipv6_prefix_list_seq_ge
,
2118 ipv6_prefix_list_seq_ge_cmd
,
2119 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2122 "Name of a prefix list\n"
2123 "sequence number of an entry\n"
2125 "Specify packets to reject\n"
2126 "Specify packets to forward\n"
2127 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2128 "Minimum prefix length to be matched\n"
2129 "Minimum prefix length\n")
2131 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2132 argv
[3], argv
[4], NULL
);
2135 DEFUN (ipv6_prefix_list_seq_ge_le
,
2136 ipv6_prefix_list_seq_ge_le_cmd
,
2137 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2140 "Name of a prefix list\n"
2141 "sequence number of an entry\n"
2143 "Specify packets to reject\n"
2144 "Specify packets to forward\n"
2145 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2146 "Minimum prefix length to be matched\n"
2147 "Minimum prefix length\n"
2148 "Maximum prefix length to be matched\n"
2149 "Maximum prefix length\n")
2151 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2152 argv
[3], argv
[4], argv
[5]);
2155 DEFUN (ipv6_prefix_list_seq_le
,
2156 ipv6_prefix_list_seq_le_cmd
,
2157 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2160 "Name of a prefix list\n"
2161 "sequence number of an entry\n"
2163 "Specify packets to reject\n"
2164 "Specify packets to forward\n"
2165 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2166 "Maximum prefix length to be matched\n"
2167 "Maximum prefix length\n")
2169 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2170 argv
[3], NULL
, argv
[4]);
2173 DEFUN (ipv6_prefix_list_seq_le_ge
,
2174 ipv6_prefix_list_seq_le_ge_cmd
,
2175 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2178 "Name of a prefix list\n"
2179 "sequence number of an entry\n"
2181 "Specify packets to reject\n"
2182 "Specify packets to forward\n"
2183 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2184 "Maximum prefix length to be matched\n"
2185 "Maximum prefix length\n"
2186 "Minimum prefix length to be matched\n"
2187 "Minimum prefix length\n")
2189 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2190 argv
[3], argv
[5], argv
[4]);
2193 DEFUN (no_ipv6_prefix_list
,
2194 no_ipv6_prefix_list_cmd
,
2195 "no ipv6 prefix-list WORD",
2199 "Name of a prefix list\n")
2201 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
2205 DEFUN (no_ipv6_prefix_list_prefix
,
2206 no_ipv6_prefix_list_prefix_cmd
,
2207 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
2211 "Name of a prefix list\n"
2212 "Specify packets to reject\n"
2213 "Specify packets to forward\n"
2214 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2215 "Any prefix match. Same as \"::0/0 le 128\"\n")
2217 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2218 argv
[2], NULL
, NULL
);
2221 DEFUN (no_ipv6_prefix_list_ge
,
2222 no_ipv6_prefix_list_ge_cmd
,
2223 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2227 "Name of a prefix list\n"
2228 "Specify packets to reject\n"
2229 "Specify packets to forward\n"
2230 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2231 "Minimum prefix length to be matched\n"
2232 "Minimum prefix length\n")
2234 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2235 argv
[2], argv
[3], NULL
);
2238 DEFUN (no_ipv6_prefix_list_ge_le
,
2239 no_ipv6_prefix_list_ge_le_cmd
,
2240 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2244 "Name of a prefix list\n"
2245 "Specify packets to reject\n"
2246 "Specify packets to forward\n"
2247 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2248 "Minimum prefix length to be matched\n"
2249 "Minimum prefix length\n"
2250 "Maximum prefix length to be matched\n"
2251 "Maximum prefix length\n")
2253 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2254 argv
[2], argv
[3], argv
[4]);
2257 DEFUN (no_ipv6_prefix_list_le
,
2258 no_ipv6_prefix_list_le_cmd
,
2259 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2263 "Name of a prefix list\n"
2264 "Specify packets to reject\n"
2265 "Specify packets to forward\n"
2266 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2267 "Maximum prefix length to be matched\n"
2268 "Maximum prefix length\n")
2270 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2271 argv
[2], NULL
, argv
[3]);
2274 DEFUN (no_ipv6_prefix_list_le_ge
,
2275 no_ipv6_prefix_list_le_ge_cmd
,
2276 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2280 "Name of a prefix list\n"
2281 "Specify packets to reject\n"
2282 "Specify packets to forward\n"
2283 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2284 "Maximum prefix length to be matched\n"
2285 "Maximum prefix length\n"
2286 "Minimum prefix length to be matched\n"
2287 "Minimum prefix length\n")
2289 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2290 argv
[2], argv
[4], argv
[3]);
2293 DEFUN (no_ipv6_prefix_list_seq
,
2294 no_ipv6_prefix_list_seq_cmd
,
2295 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2299 "Name of a prefix list\n"
2300 "sequence number of an entry\n"
2302 "Specify packets to reject\n"
2303 "Specify packets to forward\n"
2304 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2305 "Any prefix match. Same as \"::0/0 le 128\"\n")
2307 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2308 argv
[3], NULL
, NULL
);
2311 DEFUN (no_ipv6_prefix_list_seq_ge
,
2312 no_ipv6_prefix_list_seq_ge_cmd
,
2313 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2317 "Name of a prefix list\n"
2318 "sequence number of an entry\n"
2320 "Specify packets to reject\n"
2321 "Specify packets to forward\n"
2322 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2323 "Minimum prefix length to be matched\n"
2324 "Minimum prefix length\n")
2326 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2327 argv
[3], argv
[4], NULL
);
2330 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2331 no_ipv6_prefix_list_seq_ge_le_cmd
,
2332 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2336 "Name of a prefix list\n"
2337 "sequence number of an entry\n"
2339 "Specify packets to reject\n"
2340 "Specify packets to forward\n"
2341 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2342 "Minimum prefix length to be matched\n"
2343 "Minimum prefix length\n"
2344 "Maximum prefix length to be matched\n"
2345 "Maximum prefix length\n")
2347 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2348 argv
[3], argv
[4], argv
[5]);
2351 DEFUN (no_ipv6_prefix_list_seq_le
,
2352 no_ipv6_prefix_list_seq_le_cmd
,
2353 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2357 "Name of a prefix list\n"
2358 "sequence number of an entry\n"
2360 "Specify packets to reject\n"
2361 "Specify packets to forward\n"
2362 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2363 "Maximum prefix length to be matched\n"
2364 "Maximum prefix length\n")
2366 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2367 argv
[3], NULL
, argv
[4]);
2370 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2371 no_ipv6_prefix_list_seq_le_ge_cmd
,
2372 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2376 "Name of a prefix list\n"
2377 "sequence number of an entry\n"
2379 "Specify packets to reject\n"
2380 "Specify packets to forward\n"
2381 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2382 "Maximum prefix length to be matched\n"
2383 "Maximum prefix length\n"
2384 "Minimum prefix length to be matched\n"
2385 "Minimum prefix length\n")
2387 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2388 argv
[3], argv
[5], argv
[4]);
2391 DEFUN (ipv6_prefix_list_sequence_number
,
2392 ipv6_prefix_list_sequence_number_cmd
,
2393 "ipv6 prefix-list sequence-number",
2396 "Include/exclude sequence numbers in NVGEN\n")
2398 prefix_master_ipv6
.seqnum
= 1;
2402 DEFUN (no_ipv6_prefix_list_sequence_number
,
2403 no_ipv6_prefix_list_sequence_number_cmd
,
2404 "no ipv6 prefix-list sequence-number",
2408 "Include/exclude sequence numbers in NVGEN\n")
2410 prefix_master_ipv6
.seqnum
= 0;
2414 DEFUN (ipv6_prefix_list_description
,
2415 ipv6_prefix_list_description_cmd
,
2416 "ipv6 prefix-list WORD description .LINE",
2419 "Name of a prefix list\n"
2420 "Prefix-list specific description\n"
2421 "Up to 80 characters describing this prefix-list\n")
2423 struct prefix_list
*plist
;
2425 plist
= prefix_list_get (AFI_IP6
, 0, argv
[0]);
2429 XFREE (MTYPE_TMP
, plist
->desc
);
2432 plist
->desc
= argv_concat(argv
, argc
, 1);
2437 DEFUN (no_ipv6_prefix_list_description
,
2438 no_ipv6_prefix_list_description_cmd
,
2439 "no ipv6 prefix-list WORD description",
2443 "Name of a prefix list\n"
2444 "Prefix-list specific description\n")
2446 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2449 ALIAS (no_ipv6_prefix_list_description
,
2450 no_ipv6_prefix_list_description_arg_cmd
,
2451 "no ipv6 prefix-list WORD description .LINE",
2455 "Name of a prefix list\n"
2456 "Prefix-list specific description\n"
2457 "Up to 80 characters describing this prefix-list\n")
2459 DEFUN (show_ipv6_prefix_list
,
2460 show_ipv6_prefix_list_cmd
,
2461 "show ipv6 prefix-list",
2466 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2469 DEFUN (show_ipv6_prefix_list_name
,
2470 show_ipv6_prefix_list_name_cmd
,
2471 "show ipv6 prefix-list WORD",
2475 "Name of a prefix list\n")
2477 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2480 DEFUN (show_ipv6_prefix_list_name_seq
,
2481 show_ipv6_prefix_list_name_seq_cmd
,
2482 "show ipv6 prefix-list WORD seq <1-4294967295>",
2486 "Name of a prefix list\n"
2487 "sequence number of an entry\n"
2488 "Sequence number\n")
2490 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2493 DEFUN (show_ipv6_prefix_list_prefix
,
2494 show_ipv6_prefix_list_prefix_cmd
,
2495 "show ipv6 prefix-list WORD X:X::X:X/M",
2499 "Name of a prefix list\n"
2500 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2502 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2505 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2506 show_ipv6_prefix_list_prefix_longer_cmd
,
2507 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2511 "Name of a prefix list\n"
2512 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2513 "Lookup longer prefix\n")
2515 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2518 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2519 show_ipv6_prefix_list_prefix_first_match_cmd
,
2520 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2524 "Name of a prefix list\n"
2525 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2526 "First matched prefix\n")
2528 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2531 DEFUN (show_ipv6_prefix_list_summary
,
2532 show_ipv6_prefix_list_summary_cmd
,
2533 "show ipv6 prefix-list summary",
2537 "Summary of prefix lists\n")
2539 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2542 DEFUN (show_ipv6_prefix_list_summary_name
,
2543 show_ipv6_prefix_list_summary_name_cmd
,
2544 "show ipv6 prefix-list summary WORD",
2548 "Summary of prefix lists\n"
2549 "Name of a prefix list\n")
2551 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2554 DEFUN (show_ipv6_prefix_list_detail
,
2555 show_ipv6_prefix_list_detail_cmd
,
2556 "show ipv6 prefix-list detail",
2560 "Detail of prefix lists\n")
2562 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2565 DEFUN (show_ipv6_prefix_list_detail_name
,
2566 show_ipv6_prefix_list_detail_name_cmd
,
2567 "show ipv6 prefix-list detail WORD",
2571 "Detail of prefix lists\n"
2572 "Name of a prefix list\n")
2574 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2577 DEFUN (clear_ipv6_prefix_list
,
2578 clear_ipv6_prefix_list_cmd
,
2579 "clear ipv6 prefix-list",
2584 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2587 DEFUN (clear_ipv6_prefix_list_name
,
2588 clear_ipv6_prefix_list_name_cmd
,
2589 "clear ipv6 prefix-list WORD",
2593 "Name of a prefix list\n")
2595 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2598 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2599 clear_ipv6_prefix_list_name_prefix_cmd
,
2600 "clear ipv6 prefix-list WORD X:X::X:X/M",
2604 "Name of a prefix list\n"
2605 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2607 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2609 #endif /* HAVE_IPV6 */
2611 /* Configuration write function. */
2613 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2615 struct prefix_list
*plist
;
2616 struct prefix_list_entry
*pentry
;
2617 struct prefix_master
*master
;
2620 master
= prefix_master_get (afi
, 0);
2624 if (! master
->seqnum
)
2626 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2627 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2628 vty_out (vty
, "!%s", VTY_NEWLINE
);
2631 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2635 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2636 afi
== AFI_IP
? "" : "v6",
2637 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2641 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2643 vty_out (vty
, "ip%s prefix-list %s ",
2644 afi
== AFI_IP
? "" : "v6",
2648 vty_out (vty
, "seq %u ", pentry
->seq
);
2650 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2653 vty_out (vty
, "any");
2656 struct prefix
*p
= &pentry
->prefix
;
2659 vty_out (vty
, "%s/%d",
2660 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2664 vty_out (vty
, " ge %d", pentry
->ge
);
2666 vty_out (vty
, " le %d", pentry
->le
);
2668 vty_out (vty
, "%s", VTY_NEWLINE
);
2671 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2674 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2678 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2679 afi
== AFI_IP
? "" : "v6",
2680 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2684 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2686 vty_out (vty
, "ip%s prefix-list %s ",
2687 afi
== AFI_IP
? "" : "v6",
2691 vty_out (vty
, "seq %u ", pentry
->seq
);
2693 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2696 vty_out (vty
, " any");
2699 struct prefix
*p
= &pentry
->prefix
;
2702 vty_out (vty
, " %s/%d",
2703 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2707 vty_out (vty
, " ge %d", pentry
->ge
);
2709 vty_out (vty
, " le %d", pentry
->le
);
2711 vty_out (vty
, "%s", VTY_NEWLINE
);
2720 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2721 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2723 struct prefix_list_entry
*pentry
;
2728 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2730 u_char flag
= init_flag
;
2731 struct prefix
*p
= &pentry
->prefix
;
2733 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2734 permit_flag
: deny_flag
);
2735 stream_putc (s
, flag
);
2736 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2737 stream_putc (s
, (u_char
)pentry
->ge
);
2738 stream_putc (s
, (u_char
)pentry
->le
);
2739 stream_put_prefix (s
, p
);
2746 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2747 int permit
, int set
)
2749 struct prefix_list
*plist
;
2750 struct prefix_list_entry
*pentry
;
2752 /* ge and le value check */
2753 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2755 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2757 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2760 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2763 plist
= prefix_list_get (afi
, 1, name
);
2769 pentry
= prefix_list_entry_make (&orfp
->p
,
2770 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2771 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2773 if (prefix_entry_dup_check (plist
, pentry
))
2775 prefix_list_entry_free (pentry
);
2779 prefix_list_entry_add (plist
, pentry
);
2783 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2784 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2785 orfp
->seq
, orfp
->le
, orfp
->ge
);
2790 prefix_list_entry_delete (plist
, pentry
, 1);
2797 prefix_bgp_orf_remove_all (afi_t afi
, char *name
)
2799 struct prefix_list
*plist
;
2801 plist
= prefix_bgp_orf_lookup (afi
, name
);
2803 prefix_list_delete (plist
);
2806 /* return prefix count */
2808 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
, u_char use_json
)
2810 struct prefix_list
*plist
;
2811 struct prefix_list_entry
*pentry
;
2812 json_object
*json
= NULL
;
2813 json_object
*json_prefix
= NULL
;
2814 json_object
*json_list
= NULL
;
2816 plist
= prefix_bgp_orf_lookup (afi
, name
);
2821 return plist
->count
;
2825 json
= json_object_new_object();
2826 json_prefix
= json_object_new_object();
2827 json_list
= json_object_new_object();
2829 json_object_int_add(json_prefix
, "prefixListCounter", plist
->count
);
2830 json_object_string_add(json_prefix
, "prefixListName", plist
->name
);
2832 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2834 struct prefix
*p
= &pentry
->prefix
;
2838 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
),
2841 json_object_int_add(json_list
, "seq", pentry
->seq
);
2842 json_object_string_add(json_list
, "seqPrefixListType", prefix_list_type_str (pentry
));
2845 json_object_int_add(json_list
, "ge", pentry
->ge
);
2847 json_object_int_add(json_list
, "le", pentry
->le
);
2849 json_object_object_add(json_prefix
, buf_a
, json_list
);
2852 json_object_object_add(json
, "ipPrefixList", json_prefix
);
2854 json_object_object_add(json
, "ipv6PrefixList", json_prefix
);
2856 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
2857 json_object_free(json
);
2861 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2862 afi
== AFI_IP
? "" : "v6",
2863 plist
->name
, plist
->count
, VTY_NEWLINE
);
2865 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2867 struct prefix
*p
= &pentry
->prefix
;
2870 vty_out (vty
, " seq %u %s %s/%d", pentry
->seq
,
2871 prefix_list_type_str (pentry
),
2872 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2876 vty_out (vty
, " ge %d", pentry
->ge
);
2878 vty_out (vty
, " le %d", pentry
->le
);
2880 vty_out (vty
, "%s", VTY_NEWLINE
);
2883 return plist
->count
;
2887 prefix_list_reset_afi (afi_t afi
, int orf
)
2889 struct prefix_list
*plist
;
2890 struct prefix_list
*next
;
2891 struct prefix_master
*master
;
2893 master
= prefix_master_get (afi
, orf
);
2897 for (plist
= master
->num
.head
; plist
; plist
= next
)
2900 prefix_list_delete (plist
);
2902 for (plist
= master
->str
.head
; plist
; plist
= next
)
2905 prefix_list_delete (plist
);
2908 assert (master
->num
.head
== NULL
);
2909 assert (master
->num
.tail
== NULL
);
2911 assert (master
->str
.head
== NULL
);
2912 assert (master
->str
.tail
== NULL
);
2915 master
->recent
= NULL
;
2919 /* Prefix-list node. */
2920 static struct cmd_node prefix_node
=
2923 "", /* Prefix list has no interface. */
2928 config_write_prefix_ipv4 (struct vty
*vty
)
2930 return config_write_prefix_afi (AFI_IP
, vty
);
2934 prefix_list_init_ipv4 (void)
2936 install_node (&prefix_node
, config_write_prefix_ipv4
);
2938 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2939 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2940 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2941 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2942 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2943 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2944 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2945 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2946 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2947 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2949 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2950 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2951 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2952 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2953 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2954 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2955 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2956 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2957 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2958 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2959 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2961 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2962 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2963 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2965 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2966 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2968 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2969 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2970 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2971 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2972 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2973 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2974 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2975 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2976 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2977 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2979 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2980 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2981 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2985 /* Prefix-list node. */
2986 static struct cmd_node prefix_ipv6_node
=
2989 "", /* Prefix list has no interface. */
2994 config_write_prefix_ipv6 (struct vty
*vty
)
2996 return config_write_prefix_afi (AFI_IP6
, vty
);
3000 prefix_list_init_ipv6 (void)
3002 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
3004 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
3005 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
3006 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
3007 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
3008 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
3009 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
3010 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
3011 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
3012 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
3013 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
3015 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
3016 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
3017 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
3018 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
3019 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
3020 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
3021 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
3022 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
3023 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
3024 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
3025 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
3027 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
3028 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
3029 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
3031 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
3032 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
3034 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
3035 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
3036 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
3037 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
3038 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
3039 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
3040 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
3041 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
3042 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
3043 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
3045 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
3046 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
3047 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
3049 #endif /* HAVE_IPV6 */
3054 prefix_list_init_ipv4 ();
3056 prefix_list_init_ipv6 ();
3057 #endif /* HAVE_IPV6 */
3061 prefix_list_reset ()
3063 prefix_list_reset_afi (AFI_IP
, 0);
3064 prefix_list_reset_afi (AFI_IP6
, 0);
3065 prefix_list_reset_afi (AFI_IP
, 1);
3066 prefix_list_reset_afi (AFI_IP6
, 1);