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 /* not currently changeable, code assumes bytes further down */
39 #define PLC_LEN (1 << PLC_BITS)
40 #define PLC_MAXLEVELV4 2 /* /24 for IPv4 */
41 #define PLC_MAXLEVELV6 4 /* /48 for IPv6 */
42 #define PLC_MAXLEVEL 4 /* max(v4,v6) */
46 struct pltrie_table
*next_table
;
47 struct prefix_list_entry
*final_chain
;
50 struct prefix_list_entry
*up_chain
;
54 struct pltrie_entry entries
[PLC_LEN
];
57 /* List of struct prefix_list. */
58 struct prefix_list_list
60 struct prefix_list
*head
;
61 struct prefix_list
*tail
;
64 /* Master structure of prefix_list. */
67 /* List of prefix_list which name is number. */
68 struct prefix_list_list num
;
70 /* List of prefix_list which name is string. */
71 struct prefix_list_list str
;
73 /* Whether sequential number is used. */
76 /* The latest update. */
77 struct prefix_list
*recent
;
79 /* Hook function which is executed when new prefix_list is added. */
80 void (*add_hook
) (struct prefix_list
*);
82 /* Hook function which is executed when prefix_list is deleted. */
83 void (*delete_hook
) (struct prefix_list
*);
85 /* number of bytes that have a trie level */
89 /* Static structure of IPv4 prefix_list's master. */
90 static struct prefix_master prefix_master_ipv4
=
102 /* Static structure of IPv6 prefix-list's master. */
103 static struct prefix_master prefix_master_ipv6
=
113 #endif /* HAVE_IPV6*/
115 /* Static structure of BGP ORF prefix_list's master. */
116 static struct prefix_master prefix_master_orf_v4
=
127 /* Static structure of BGP ORF prefix_list's master. */
128 static struct prefix_master prefix_master_orf_v6
=
139 static struct prefix_master
*
140 prefix_master_get (afi_t afi
, int orf
)
143 return orf
? &prefix_master_orf_v4
: &prefix_master_ipv4
;
145 return orf
? &prefix_master_orf_v6
: &prefix_master_ipv6
;
149 const char *prefix_list_name (struct prefix_list
*plist
)
154 /* Lookup prefix_list from list of prefix_list by name. */
155 static struct prefix_list
*
156 prefix_list_lookup_do (afi_t afi
, int orf
, const char *name
)
158 struct prefix_list
*plist
;
159 struct prefix_master
*master
;
164 master
= prefix_master_get (afi
, orf
);
168 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
169 if (strcmp (plist
->name
, name
) == 0)
172 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
173 if (strcmp (plist
->name
, name
) == 0)
180 prefix_list_lookup (afi_t afi
, const char *name
)
182 return prefix_list_lookup_do (afi
, 0, name
);
186 prefix_bgp_orf_lookup (afi_t afi
, const char *name
)
188 return prefix_list_lookup_do (afi
, 1, name
);
191 static struct prefix_list
*
192 prefix_list_new (void)
194 struct prefix_list
*new;
196 new = XCALLOC (MTYPE_PREFIX_LIST
, sizeof (struct prefix_list
));
201 prefix_list_free (struct prefix_list
*plist
)
203 XFREE (MTYPE_PREFIX_LIST
, plist
);
206 static struct prefix_list_entry
*
207 prefix_list_entry_new (void)
209 struct prefix_list_entry
*new;
211 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY
, sizeof (struct prefix_list_entry
));
216 prefix_list_entry_free (struct prefix_list_entry
*pentry
)
218 XFREE (MTYPE_PREFIX_LIST_ENTRY
, pentry
);
221 /* Insert new prefix list to list of prefix_list. Each prefix_list
222 is sorted by the name. */
223 static struct prefix_list
*
224 prefix_list_insert (afi_t afi
, int orf
, const char *name
)
228 struct prefix_list
*plist
;
229 struct prefix_list
*point
;
230 struct prefix_list_list
*list
;
231 struct prefix_master
*master
;
233 master
= prefix_master_get (afi
, orf
);
237 /* Allocate new prefix_list and copy given name. */
238 plist
= prefix_list_new ();
239 plist
->name
= XSTRDUP (MTYPE_PREFIX_LIST_STR
, name
);
240 plist
->master
= master
;
241 plist
->trie
= XCALLOC (MTYPE_PREFIX_LIST_TRIE
, sizeof (struct pltrie_table
));
243 /* If name is made by all digit character. We treat it as
245 for (number
= 0, i
= 0; i
< strlen (name
); i
++)
247 if (isdigit ((int) name
[i
]))
248 number
= (number
* 10) + (name
[i
] - '0');
253 /* In case of name is all digit character */
254 if (i
== strlen (name
))
256 plist
->type
= PREFIX_TYPE_NUMBER
;
258 /* Set prefix_list to number list. */
261 for (point
= list
->head
; point
; point
= point
->next
)
262 if (atol (point
->name
) >= number
)
267 plist
->type
= PREFIX_TYPE_STRING
;
269 /* Set prefix_list to string list. */
272 /* Set point to insertion point. */
273 for (point
= list
->head
; point
; point
= point
->next
)
274 if (strcmp (point
->name
, name
) >= 0)
278 /* In case of this is the first element of master. */
279 if (list
->head
== NULL
)
281 list
->head
= list
->tail
= plist
;
285 /* In case of insertion is made at the tail of access_list. */
288 plist
->prev
= list
->tail
;
289 list
->tail
->next
= plist
;
294 /* In case of insertion is made at the head of access_list. */
295 if (point
== list
->head
)
297 plist
->next
= list
->head
;
298 list
->head
->prev
= plist
;
303 /* Insertion is made at middle of the access_list. */
305 plist
->prev
= point
->prev
;
308 point
->prev
->next
= plist
;
314 static struct prefix_list
*
315 prefix_list_get (afi_t afi
, int orf
, const char *name
)
317 struct prefix_list
*plist
;
319 plist
= prefix_list_lookup_do (afi
, orf
, name
);
322 plist
= prefix_list_insert (afi
, orf
, name
);
326 /* Delete prefix-list from prefix_list_master and free it. */
328 prefix_list_delete (struct prefix_list
*plist
)
330 struct prefix_list_list
*list
;
331 struct prefix_master
*master
;
332 struct prefix_list_entry
*pentry
;
333 struct prefix_list_entry
*next
;
335 /* If prefix-list contain prefix_list_entry free all of it. */
336 for (pentry
= plist
->head
; pentry
; pentry
= next
)
339 prefix_list_entry_free (pentry
);
343 master
= plist
->master
;
345 if (plist
->type
== PREFIX_TYPE_NUMBER
)
351 plist
->next
->prev
= plist
->prev
;
353 list
->tail
= plist
->prev
;
356 plist
->prev
->next
= plist
->next
;
358 list
->head
= plist
->next
;
361 XFREE (MTYPE_TMP
, plist
->desc
);
363 /* Make sure master's recent changed prefix-list information is
365 master
->recent
= NULL
;
367 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
369 if (master
->delete_hook
)
370 (*master
->delete_hook
) (plist
);
373 XFREE (MTYPE_PREFIX_LIST_STR
, plist
->name
);
375 XFREE (MTYPE_PREFIX_LIST_TRIE
, plist
->trie
);
377 prefix_list_free (plist
);
381 static struct prefix_list_entry
*
382 prefix_list_entry_make (struct prefix
*prefix
, enum prefix_list_type type
,
383 int seq
, int le
, int ge
, int any
)
385 struct prefix_list_entry
*pentry
;
387 pentry
= prefix_list_entry_new ();
392 prefix_copy (&pentry
->prefix
, prefix
);
401 /* Add hook function. */
403 prefix_list_add_hook (void (*func
) (struct prefix_list
*plist
))
405 prefix_master_ipv4
.add_hook
= func
;
407 prefix_master_ipv6
.add_hook
= func
;
408 #endif /* HAVE_IPV6 */
411 /* Delete hook function. */
413 prefix_list_delete_hook (void (*func
) (struct prefix_list
*plist
))
415 prefix_master_ipv4
.delete_hook
= func
;
417 prefix_master_ipv6
.delete_hook
= func
;
418 #endif /* HAVE_IPVt6 */
421 /* Calculate new sequential number. */
423 prefix_new_seq_get (struct prefix_list
*plist
)
427 struct prefix_list_entry
*pentry
;
431 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
433 if (maxseq
< pentry
->seq
)
434 maxseq
= pentry
->seq
;
437 newseq
= ((maxseq
/ 5) * 5) + 5;
442 /* Return prefix list entry which has same seq number. */
443 static struct prefix_list_entry
*
444 prefix_seq_check (struct prefix_list
*plist
, int seq
)
446 struct prefix_list_entry
*pentry
;
448 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
449 if (pentry
->seq
== seq
)
454 static struct prefix_list_entry
*
455 prefix_list_entry_lookup (struct prefix_list
*plist
, struct prefix
*prefix
,
456 enum prefix_list_type type
, int seq
, int le
, int ge
)
458 struct prefix_list_entry
*pentry
;
460 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
461 if (prefix_same (&pentry
->prefix
, prefix
) && pentry
->type
== type
)
463 if (seq
>= 0 && pentry
->seq
!= seq
)
466 if (pentry
->le
!= le
)
468 if (pentry
->ge
!= ge
)
478 trie_walk_affected (size_t validbits
, struct pltrie_table
*table
, uint8_t byte
,
479 struct prefix_list_entry
*object
,
480 void (*fn
)(struct prefix_list_entry
*object
,
481 struct prefix_list_entry
**updptr
))
486 if (validbits
> PLC_BITS
)
488 fn (object
, &table
->entries
[byte
].final_chain
);
492 mask
= (1 << (8 - validbits
)) - 1;
493 for (bwalk
= byte
& ~mask
; bwalk
<= byte
+ mask
; bwalk
++)
495 fn (object
, &table
->entries
[bwalk
].up_chain
);
499 static void trie_uninstall_fn (struct prefix_list_entry
*object
,
500 struct prefix_list_entry
**updptr
)
502 for (; *updptr
; updptr
= &(*updptr
)->next_best
)
503 if (*updptr
== object
)
505 *updptr
= object
->next_best
;
511 trie_table_empty (struct pltrie_table
*table
)
514 for (i
= 0; i
< PLC_LEN
; i
++)
515 if (table
->entries
[i
].next_table
|| table
->entries
[i
].up_chain
)
521 prefix_list_trie_del (struct prefix_list
*plist
,
522 struct prefix_list_entry
*pentry
)
524 size_t depth
, maxdepth
= plist
->master
->trie_depth
;
525 uint8_t *bytes
= &pentry
->prefix
.u
.prefix
;
526 size_t validbits
= pentry
->prefix
.prefixlen
;
527 struct pltrie_table
*table
, **tables
[PLC_MAXLEVEL
];
530 for (depth
= 0; validbits
> PLC_BITS
&& depth
< maxdepth
- 1; depth
++)
532 uint8_t byte
= bytes
[depth
];
533 assert (table
->entries
[byte
].next_table
);
535 tables
[depth
+ 1] = &table
->entries
[byte
].next_table
;
536 table
= table
->entries
[byte
].next_table
;
538 validbits
-= PLC_BITS
;
541 trie_walk_affected (validbits
, table
, bytes
[depth
], pentry
, trie_uninstall_fn
);
543 for (; depth
> 0; depth
--)
544 if (trie_table_empty (*tables
[depth
]))
546 XFREE (MTYPE_PREFIX_LIST_TRIE
, *tables
[depth
]);
547 *tables
[depth
] = NULL
;
553 prefix_list_entry_delete (struct prefix_list
*plist
,
554 struct prefix_list_entry
*pentry
,
557 prefix_list_trie_del (plist
, pentry
);
559 if (plist
== NULL
|| pentry
== NULL
)
562 pentry
->prev
->next
= pentry
->next
;
564 plist
->head
= pentry
->next
;
566 pentry
->next
->prev
= pentry
->prev
;
568 plist
->tail
= pentry
->prev
;
570 prefix_list_entry_free (pentry
);
576 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_DELETED
);
577 if (plist
->master
->delete_hook
)
578 (*plist
->master
->delete_hook
) (plist
);
580 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
581 prefix_list_delete (plist
);
583 plist
->master
->recent
= plist
;
587 static void trie_install_fn (struct prefix_list_entry
*object
,
588 struct prefix_list_entry
**updptr
)
592 if (*updptr
== object
)
594 if ((*updptr
)->prefix
.prefixlen
< object
->prefix
.prefixlen
)
596 if ((*updptr
)->seq
> object
->seq
)
598 updptr
= &(*updptr
)->next_best
;
601 if (!object
->next_best
)
602 object
->next_best
= *updptr
;
604 assert (object
->next_best
== *updptr
|| !*updptr
);
610 prefix_list_trie_add (struct prefix_list
*plist
,
611 struct prefix_list_entry
*pentry
)
613 size_t depth
= plist
->master
->trie_depth
;
614 uint8_t *bytes
= &pentry
->prefix
.u
.prefix
;
615 size_t validbits
= pentry
->prefix
.prefixlen
;
616 struct pltrie_table
*table
;
619 while (validbits
> PLC_BITS
&& depth
> 1)
621 if (!table
->entries
[*bytes
].next_table
)
622 table
->entries
[*bytes
].next_table
= XCALLOC (MTYPE_PREFIX_LIST_TRIE
,
623 sizeof(struct pltrie_table
));
624 table
= table
->entries
[*bytes
].next_table
;
627 validbits
-= PLC_BITS
;
630 trie_walk_affected (validbits
, table
, *bytes
, pentry
, trie_install_fn
);
634 prefix_list_entry_add (struct prefix_list
*plist
,
635 struct prefix_list_entry
*pentry
)
637 struct prefix_list_entry
*replace
;
638 struct prefix_list_entry
*point
;
640 /* Automatic asignment of seq no. */
641 if (pentry
->seq
== -1)
642 pentry
->seq
= prefix_new_seq_get (plist
);
644 if (plist
->tail
&& pentry
->seq
> plist
->tail
->seq
)
648 /* Is there any same seq prefix list entry? */
649 replace
= prefix_seq_check (plist
, pentry
->seq
);
651 prefix_list_entry_delete (plist
, replace
, 0);
653 /* Check insert point. */
654 for (point
= plist
->head
; point
; point
= point
->next
)
655 if (point
->seq
>= pentry
->seq
)
659 /* In case of this is the first element of the list. */
660 pentry
->next
= point
;
665 point
->prev
->next
= pentry
;
667 plist
->head
= pentry
;
669 pentry
->prev
= point
->prev
;
670 point
->prev
= pentry
;
675 plist
->tail
->next
= pentry
;
677 plist
->head
= pentry
;
679 pentry
->prev
= plist
->tail
;
680 plist
->tail
= pentry
;
683 prefix_list_trie_add (plist
, pentry
);
685 /* Increment count. */
688 /* Run hook function. */
689 if (plist
->master
->add_hook
)
690 (*plist
->master
->add_hook
) (plist
);
692 route_map_notify_dependencies(plist
->name
, RMAP_EVENT_PLIST_ADDED
);
693 plist
->master
->recent
= plist
;
696 /* Return string of prefix_list_type. */
698 prefix_list_type_str (struct prefix_list_entry
*pentry
)
700 switch (pentry
->type
)
712 prefix_list_entry_match (struct prefix_list_entry
*pentry
, struct prefix
*p
)
716 ret
= prefix_match (&pentry
->prefix
, p
);
720 /* In case of le nor ge is specified, exact match is performed. */
721 if (! pentry
->le
&& ! pentry
->ge
)
723 if (pentry
->prefix
.prefixlen
!= p
->prefixlen
)
729 if (p
->prefixlen
> pentry
->le
)
733 if (p
->prefixlen
< pentry
->ge
)
739 enum prefix_list_type
740 prefix_list_apply (struct prefix_list
*plist
, void *object
)
742 struct prefix_list_entry
*pentry
, *pbest
= NULL
;
744 struct prefix
*p
= (struct prefix
*) object
;
745 uint8_t *byte
= &p
->u
.prefix
;
747 size_t validbits
= p
->prefixlen
;
748 struct pltrie_table
*table
;
753 if (plist
->count
== 0)
754 return PREFIX_PERMIT
;
756 depth
= plist
->master
->trie_depth
;
760 for (pentry
= table
->entries
[*byte
].up_chain
; pentry
; pentry
= pentry
->next_best
)
762 if (pbest
&& pbest
->seq
< pentry
->seq
)
764 if (prefix_list_entry_match (pentry
, p
))
768 if (validbits
<= PLC_BITS
)
770 validbits
-= PLC_BITS
;
774 if (!table
->entries
[*byte
].next_table
)
777 table
= table
->entries
[*byte
].next_table
;
782 for (pentry
= table
->entries
[*byte
].final_chain
; pentry
; pentry
= pentry
->next_best
)
784 if (pbest
&& pbest
->seq
< pentry
->seq
)
786 if (prefix_list_entry_match (pentry
, p
))
798 static void __attribute__ ((unused
))
799 prefix_list_print (struct prefix_list
*plist
)
801 struct prefix_list_entry
*pentry
;
806 printf ("ip prefix-list %s: %d entries\n", plist
->name
, plist
->count
);
808 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
811 printf ("any %s\n", prefix_list_type_str (pentry
));
819 printf (" seq %u %s %s/%d",
821 prefix_list_type_str (pentry
),
822 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
825 printf (" ge %d", pentry
->ge
);
827 printf (" le %d", pentry
->le
);
833 /* Retrun 1 when plist already include pentry policy. */
834 static struct prefix_list_entry
*
835 prefix_entry_dup_check (struct prefix_list
*plist
,
836 struct prefix_list_entry
*new)
838 size_t depth
, maxdepth
= plist
->master
->trie_depth
;
839 uint8_t byte
, *bytes
= &new->prefix
.u
.prefix
;
840 size_t validbits
= new->prefix
.prefixlen
;
841 struct pltrie_table
*table
;
842 struct prefix_list_entry
*pentry
;
846 seq
= prefix_new_seq_get (plist
);
851 for (depth
= 0; validbits
> PLC_BITS
&& depth
< maxdepth
- 1; depth
++)
854 if (!table
->entries
[byte
].next_table
)
857 table
= table
->entries
[byte
].next_table
;
858 validbits
-= PLC_BITS
;
862 if (validbits
> PLC_BITS
)
863 pentry
= table
->entries
[byte
].final_chain
;
865 pentry
= table
->entries
[byte
].up_chain
;
867 for (; pentry
; pentry
= pentry
->next_best
)
869 if (prefix_same (&pentry
->prefix
, &new->prefix
)
870 && pentry
->type
== new->type
871 && pentry
->le
== new->le
872 && pentry
->ge
== new->ge
873 && pentry
->seq
!= seq
)
880 vty_invalid_prefix_range (struct vty
*vty
, const char *prefix
)
882 vty_out (vty
, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
883 prefix
, VTY_NEWLINE
);
888 vty_prefix_list_install (struct vty
*vty
, afi_t afi
, const char *name
,
889 const char *seq
, const char *typestr
,
890 const char *prefix
, const char *ge
, const char *le
)
893 enum prefix_list_type type
;
894 struct prefix_list
*plist
;
895 struct prefix_list_entry
*pentry
;
896 struct prefix_list_entry
*dup
;
903 /* Sequential number. */
907 /* ge and le number */
913 /* Check filter type. */
914 if (strncmp ("permit", typestr
, 1) == 0)
915 type
= PREFIX_PERMIT
;
916 else if (strncmp ("deny", typestr
, 1) == 0)
920 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
924 /* "any" is special token for matching any IPv4 addresses. */
928 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
930 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
932 lenum
= IPV4_MAX_BITLEN
;
936 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
940 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
945 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
947 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
949 lenum
= IPV6_MAX_BITLEN
;
953 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
957 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
963 /* ge and le check. */
964 if (genum
&& (genum
<= p
.prefixlen
))
965 return vty_invalid_prefix_range (vty
, prefix
);
967 if (lenum
&& (lenum
<= p
.prefixlen
))
968 return vty_invalid_prefix_range (vty
, prefix
);
970 if (lenum
&& (genum
> lenum
))
971 return vty_invalid_prefix_range (vty
, prefix
);
973 if (genum
&& (lenum
== (afi
== AFI_IP
? 32 : 128)))
976 /* Get prefix_list with name. */
977 plist
= prefix_list_get (afi
, 0, name
);
979 /* Make prefix entry. */
980 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
982 /* Check same policy. */
983 dup
= prefix_entry_dup_check (plist
, pentry
);
987 prefix_list_entry_free (pentry
);
988 vty_out (vty
, "%% Insertion failed - prefix-list entry exists:%s",
990 vty_out (vty
, " seq %u %s %s", dup
->seq
, typestr
, prefix
);
992 vty_out (vty
, " ge %d", genum
);
994 vty_out (vty
, " le %d", lenum
);
995 vty_out (vty
, "%s", VTY_NEWLINE
);
999 /* Install new filter to the access_list. */
1000 prefix_list_entry_add (plist
, pentry
);
1006 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
1007 const char *seq
, const char *typestr
,
1008 const char *prefix
, const char *ge
, const char *le
)
1011 enum prefix_list_type type
;
1012 struct prefix_list
*plist
;
1013 struct prefix_list_entry
*pentry
;
1019 /* Check prefix list name. */
1020 plist
= prefix_list_lookup (afi
, name
);
1023 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1027 /* Only prefix-list name specified, delete the entire prefix-list. */
1028 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
1029 ge
== NULL
&& le
== NULL
)
1031 prefix_list_delete (plist
);
1035 /* We must have, at a minimum, both the type and prefix here */
1036 if ((typestr
== NULL
) || (prefix
== NULL
))
1038 vty_out (vty
, "%% Both prefix and type required%s", VTY_NEWLINE
);
1042 /* Check sequence number. */
1044 seqnum
= atoi (seq
);
1046 /* ge and le number */
1052 /* Check of filter type. */
1053 if (strncmp ("permit", typestr
, 1) == 0)
1054 type
= PREFIX_PERMIT
;
1055 else if (strncmp ("deny", typestr
, 1) == 0)
1059 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
1063 /* "any" is special token for matching any IPv4 addresses. */
1066 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1068 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
1070 lenum
= IPV4_MAX_BITLEN
;
1073 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
1077 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
1082 else if (afi
== AFI_IP6
)
1084 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1086 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
1088 lenum
= IPV6_MAX_BITLEN
;
1091 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
1095 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
1099 #endif /* HAVE_IPV6 */
1101 /* Lookup prefix entry. */
1102 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
1106 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1110 /* Install new filter to the access_list. */
1111 prefix_list_entry_delete (plist
, pentry
, 1);
1117 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
1119 struct prefix_list
*plist
;
1121 plist
= prefix_list_lookup (afi
, name
);
1124 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1130 XFREE (MTYPE_TMP
, plist
->desc
);
1134 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
1135 prefix_list_delete (plist
);
1151 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
1152 struct prefix_master
*master
, enum display_type dtype
,
1155 struct prefix_list_entry
*pentry
;
1157 /* Print the name of the protocol */
1159 vty_out (vty
, "%s: ", zlog_proto_names
[zlog_default
->protocol
]);
1161 if (dtype
== normal_display
)
1163 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
1164 afi
== AFI_IP
? "" : "v6",
1165 plist
->name
, plist
->count
, VTY_NEWLINE
);
1167 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1169 else if (dtype
== summary_display
|| dtype
== detail_display
)
1171 vty_out (vty
, "ip%s prefix-list %s:%s",
1172 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
1175 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1177 vty_out (vty
, " count: %d, range entries: %d, sequences: %u - %u%s",
1178 plist
->count
, plist
->rangecount
,
1179 plist
->head
? plist
->head
->seq
: 0,
1180 plist
->tail
? plist
->tail
->seq
: 0,
1184 if (dtype
!= summary_display
)
1186 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1188 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
1194 vty_out (vty
, "seq %u ", pentry
->seq
);
1196 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
1199 vty_out (vty
, "any");
1202 struct prefix
*p
= &pentry
->prefix
;
1205 vty_out (vty
, "%s/%d",
1206 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1210 vty_out (vty
, " ge %d", pentry
->ge
);
1212 vty_out (vty
, " le %d", pentry
->le
);
1215 if (dtype
== detail_display
|| dtype
== sequential_display
)
1216 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1217 pentry
->hitcnt
, pentry
->refcnt
);
1219 vty_out (vty
, "%s", VTY_NEWLINE
);
1225 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1226 const char *seq
, enum display_type dtype
)
1228 struct prefix_list
*plist
;
1229 struct prefix_master
*master
;
1232 master
= prefix_master_get (afi
, 0);
1237 seqnum
= atoi (seq
);
1241 plist
= prefix_list_lookup (afi
, name
);
1244 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1247 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1251 if (dtype
== detail_display
|| dtype
== summary_display
)
1254 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1255 master
->recent
->name
, VTY_NEWLINE
);
1258 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1259 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1261 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1262 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1269 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1270 const char *prefix
, enum display_type type
)
1272 struct prefix_list
*plist
;
1273 struct prefix_list_entry
*pentry
;
1278 plist
= prefix_list_lookup (afi
, name
);
1281 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1285 ret
= str2prefix (prefix
, &p
);
1288 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1292 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1296 if (type
== normal_display
|| type
== first_match_display
)
1297 if (prefix_same (&p
, &pentry
->prefix
))
1300 if (type
== longer_display
)
1301 if (prefix_match (&p
, &pentry
->prefix
))
1306 vty_out (vty
, " seq %u %s ",
1308 prefix_list_type_str (pentry
));
1311 vty_out (vty
, "any");
1314 struct prefix
*p
= &pentry
->prefix
;
1317 vty_out (vty
, "%s/%d",
1318 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1322 vty_out (vty
, " ge %d", pentry
->ge
);
1324 vty_out (vty
, " le %d", pentry
->le
);
1327 if (type
== normal_display
|| type
== first_match_display
)
1328 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1329 pentry
->hitcnt
, pentry
->refcnt
);
1331 vty_out (vty
, "%s", VTY_NEWLINE
);
1333 if (type
== first_match_display
)
1341 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1344 struct prefix_master
*master
;
1345 struct prefix_list
*plist
;
1346 struct prefix_list_entry
*pentry
;
1350 master
= prefix_master_get (afi
, 0);
1354 if (name
== NULL
&& prefix
== NULL
)
1356 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1357 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1360 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1361 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1366 plist
= prefix_list_lookup (afi
, name
);
1369 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1375 ret
= str2prefix (prefix
, &p
);
1378 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1383 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1387 if (prefix_match (&pentry
->prefix
, &p
))
1397 DEFUN (ip_prefix_list
,
1399 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
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 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1408 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1409 argv
[1], argv
[2], NULL
, NULL
);
1412 DEFUN (ip_prefix_list_ge
,
1413 ip_prefix_list_ge_cmd
,
1414 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1417 "Name of a prefix list\n"
1418 "Specify packets to reject\n"
1419 "Specify packets to forward\n"
1420 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1421 "Minimum prefix length to be matched\n"
1422 "Minimum prefix length\n")
1424 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1425 argv
[2], argv
[3], NULL
);
1428 DEFUN (ip_prefix_list_ge_le
,
1429 ip_prefix_list_ge_le_cmd
,
1430 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1433 "Name of a prefix list\n"
1434 "Specify packets to reject\n"
1435 "Specify packets to forward\n"
1436 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1437 "Minimum prefix length to be matched\n"
1438 "Minimum prefix length\n"
1439 "Maximum prefix length to be matched\n"
1440 "Maximum prefix length\n")
1442 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1443 argv
[2], argv
[3], argv
[4]);
1446 DEFUN (ip_prefix_list_le
,
1447 ip_prefix_list_le_cmd
,
1448 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1451 "Name of a prefix list\n"
1452 "Specify packets to reject\n"
1453 "Specify packets to forward\n"
1454 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1455 "Maximum prefix length to be matched\n"
1456 "Maximum prefix length\n")
1458 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1459 argv
[2], NULL
, argv
[3]);
1462 DEFUN (ip_prefix_list_le_ge
,
1463 ip_prefix_list_le_ge_cmd
,
1464 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1467 "Name of a prefix list\n"
1468 "Specify packets to reject\n"
1469 "Specify packets to forward\n"
1470 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1471 "Maximum prefix length to be matched\n"
1472 "Maximum prefix length\n"
1473 "Minimum prefix length to be matched\n"
1474 "Minimum prefix length\n")
1476 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1477 argv
[2], argv
[4], argv
[3]);
1480 DEFUN (ip_prefix_list_seq
,
1481 ip_prefix_list_seq_cmd
,
1482 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1485 "Name of a prefix list\n"
1486 "sequence number of an entry\n"
1488 "Specify packets to reject\n"
1489 "Specify packets to forward\n"
1490 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1491 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1493 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1494 argv
[3], NULL
, NULL
);
1497 DEFUN (ip_prefix_list_seq_ge
,
1498 ip_prefix_list_seq_ge_cmd
,
1499 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1502 "Name of a prefix list\n"
1503 "sequence number of an entry\n"
1505 "Specify packets to reject\n"
1506 "Specify packets to forward\n"
1507 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1508 "Minimum prefix length to be matched\n"
1509 "Minimum prefix length\n")
1511 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1512 argv
[3], argv
[4], NULL
);
1515 DEFUN (ip_prefix_list_seq_ge_le
,
1516 ip_prefix_list_seq_ge_le_cmd
,
1517 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1520 "Name of a prefix list\n"
1521 "sequence number of an entry\n"
1523 "Specify packets to reject\n"
1524 "Specify packets to forward\n"
1525 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1526 "Minimum prefix length to be matched\n"
1527 "Minimum prefix length\n"
1528 "Maximum prefix length to be matched\n"
1529 "Maximum prefix length\n")
1531 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1532 argv
[3], argv
[4], argv
[5]);
1535 DEFUN (ip_prefix_list_seq_le
,
1536 ip_prefix_list_seq_le_cmd
,
1537 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1540 "Name of a prefix list\n"
1541 "sequence number of an entry\n"
1543 "Specify packets to reject\n"
1544 "Specify packets to forward\n"
1545 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1546 "Maximum prefix length to be matched\n"
1547 "Maximum prefix length\n")
1549 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1550 argv
[3], NULL
, argv
[4]);
1553 DEFUN (ip_prefix_list_seq_le_ge
,
1554 ip_prefix_list_seq_le_ge_cmd
,
1555 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1558 "Name of a prefix list\n"
1559 "sequence number of an entry\n"
1561 "Specify packets to reject\n"
1562 "Specify packets to forward\n"
1563 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1564 "Maximum prefix length to be matched\n"
1565 "Maximum prefix length\n"
1566 "Minimum prefix length to be matched\n"
1567 "Minimum prefix length\n")
1569 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1570 argv
[3], argv
[5], argv
[4]);
1573 DEFUN (no_ip_prefix_list
,
1574 no_ip_prefix_list_cmd
,
1575 "no ip prefix-list WORD",
1579 "Name of a prefix list\n")
1581 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1585 DEFUN (no_ip_prefix_list_prefix
,
1586 no_ip_prefix_list_prefix_cmd
,
1587 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1591 "Name of a prefix list\n"
1592 "Specify packets to reject\n"
1593 "Specify packets to forward\n"
1594 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1595 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1597 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1598 argv
[2], NULL
, NULL
);
1601 DEFUN (no_ip_prefix_list_ge
,
1602 no_ip_prefix_list_ge_cmd
,
1603 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1607 "Name of a prefix list\n"
1608 "Specify packets to reject\n"
1609 "Specify packets to forward\n"
1610 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1611 "Minimum prefix length to be matched\n"
1612 "Minimum prefix length\n")
1614 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1615 argv
[2], argv
[3], NULL
);
1618 DEFUN (no_ip_prefix_list_ge_le
,
1619 no_ip_prefix_list_ge_le_cmd
,
1620 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1624 "Name of a prefix list\n"
1625 "Specify packets to reject\n"
1626 "Specify packets to forward\n"
1627 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1628 "Minimum prefix length to be matched\n"
1629 "Minimum prefix length\n"
1630 "Maximum prefix length to be matched\n"
1631 "Maximum prefix length\n")
1633 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1634 argv
[2], argv
[3], argv
[4]);
1637 DEFUN (no_ip_prefix_list_le
,
1638 no_ip_prefix_list_le_cmd
,
1639 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1643 "Name of a prefix list\n"
1644 "Specify packets to reject\n"
1645 "Specify packets to forward\n"
1646 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1647 "Maximum prefix length to be matched\n"
1648 "Maximum prefix length\n")
1650 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1651 argv
[2], NULL
, argv
[3]);
1654 DEFUN (no_ip_prefix_list_le_ge
,
1655 no_ip_prefix_list_le_ge_cmd
,
1656 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1660 "Name of a prefix list\n"
1661 "Specify packets to reject\n"
1662 "Specify packets to forward\n"
1663 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1664 "Maximum prefix length to be matched\n"
1665 "Maximum prefix length\n"
1666 "Minimum prefix length to be matched\n"
1667 "Minimum prefix length\n")
1669 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1670 argv
[2], argv
[4], argv
[3]);
1673 DEFUN (no_ip_prefix_list_seq
,
1674 no_ip_prefix_list_seq_cmd
,
1675 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1679 "Name of a prefix list\n"
1680 "sequence number of an entry\n"
1682 "Specify packets to reject\n"
1683 "Specify packets to forward\n"
1684 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1685 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1687 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1688 argv
[3], NULL
, NULL
);
1691 DEFUN (no_ip_prefix_list_seq_ge
,
1692 no_ip_prefix_list_seq_ge_cmd
,
1693 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1697 "Name of a prefix list\n"
1698 "sequence number of an entry\n"
1700 "Specify packets to reject\n"
1701 "Specify packets to forward\n"
1702 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1703 "Minimum prefix length to be matched\n"
1704 "Minimum prefix length\n")
1706 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1707 argv
[3], argv
[4], NULL
);
1710 DEFUN (no_ip_prefix_list_seq_ge_le
,
1711 no_ip_prefix_list_seq_ge_le_cmd
,
1712 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1716 "Name of a prefix list\n"
1717 "sequence number of an entry\n"
1719 "Specify packets to reject\n"
1720 "Specify packets to forward\n"
1721 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1722 "Minimum prefix length to be matched\n"
1723 "Minimum prefix length\n"
1724 "Maximum prefix length to be matched\n"
1725 "Maximum prefix length\n")
1727 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1728 argv
[3], argv
[4], argv
[5]);
1731 DEFUN (no_ip_prefix_list_seq_le
,
1732 no_ip_prefix_list_seq_le_cmd
,
1733 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1737 "Name of a prefix list\n"
1738 "sequence number of an entry\n"
1740 "Specify packets to reject\n"
1741 "Specify packets to forward\n"
1742 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1743 "Maximum prefix length to be matched\n"
1744 "Maximum prefix length\n")
1746 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1747 argv
[3], NULL
, argv
[4]);
1750 DEFUN (no_ip_prefix_list_seq_le_ge
,
1751 no_ip_prefix_list_seq_le_ge_cmd
,
1752 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1756 "Name of a prefix list\n"
1757 "sequence number of an entry\n"
1759 "Specify packets to reject\n"
1760 "Specify packets to forward\n"
1761 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1762 "Maximum prefix length to be matched\n"
1763 "Maximum prefix length\n"
1764 "Minimum prefix length to be matched\n"
1765 "Minimum prefix length\n")
1767 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1768 argv
[3], argv
[5], argv
[4]);
1771 DEFUN (ip_prefix_list_sequence_number
,
1772 ip_prefix_list_sequence_number_cmd
,
1773 "ip prefix-list sequence-number",
1776 "Include/exclude sequence numbers in NVGEN\n")
1778 prefix_master_ipv4
.seqnum
= 1;
1782 DEFUN (no_ip_prefix_list_sequence_number
,
1783 no_ip_prefix_list_sequence_number_cmd
,
1784 "no ip prefix-list sequence-number",
1788 "Include/exclude sequence numbers in NVGEN\n")
1790 prefix_master_ipv4
.seqnum
= 0;
1794 DEFUN (ip_prefix_list_description
,
1795 ip_prefix_list_description_cmd
,
1796 "ip prefix-list WORD description .LINE",
1799 "Name of a prefix list\n"
1800 "Prefix-list specific description\n"
1801 "Up to 80 characters describing this prefix-list\n")
1803 struct prefix_list
*plist
;
1805 plist
= prefix_list_get (AFI_IP
, 0, argv
[0]);
1809 XFREE (MTYPE_TMP
, plist
->desc
);
1812 plist
->desc
= argv_concat(argv
, argc
, 1);
1817 DEFUN (no_ip_prefix_list_description
,
1818 no_ip_prefix_list_description_cmd
,
1819 "no ip prefix-list WORD description",
1823 "Name of a prefix list\n"
1824 "Prefix-list specific description\n")
1826 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1829 ALIAS (no_ip_prefix_list_description
,
1830 no_ip_prefix_list_description_arg_cmd
,
1831 "no ip prefix-list WORD description .LINE",
1835 "Name of a prefix list\n"
1836 "Prefix-list specific description\n"
1837 "Up to 80 characters describing this prefix-list\n")
1839 DEFUN (show_ip_prefix_list
,
1840 show_ip_prefix_list_cmd
,
1841 "show ip prefix-list",
1846 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1849 DEFUN (show_ip_prefix_list_name
,
1850 show_ip_prefix_list_name_cmd
,
1851 "show ip prefix-list WORD",
1855 "Name of a prefix list\n")
1857 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1860 DEFUN (show_ip_prefix_list_name_seq
,
1861 show_ip_prefix_list_name_seq_cmd
,
1862 "show ip prefix-list WORD seq <1-4294967295>",
1866 "Name of a prefix list\n"
1867 "sequence number of an entry\n"
1868 "Sequence number\n")
1870 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1873 DEFUN (show_ip_prefix_list_prefix
,
1874 show_ip_prefix_list_prefix_cmd
,
1875 "show ip prefix-list WORD A.B.C.D/M",
1879 "Name of a prefix list\n"
1880 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1882 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1885 DEFUN (show_ip_prefix_list_prefix_longer
,
1886 show_ip_prefix_list_prefix_longer_cmd
,
1887 "show ip prefix-list WORD A.B.C.D/M longer",
1891 "Name of a prefix list\n"
1892 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1893 "Lookup longer prefix\n")
1895 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1898 DEFUN (show_ip_prefix_list_prefix_first_match
,
1899 show_ip_prefix_list_prefix_first_match_cmd
,
1900 "show ip prefix-list WORD A.B.C.D/M first-match",
1904 "Name of a prefix list\n"
1905 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1906 "First matched prefix\n")
1908 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1911 DEFUN (show_ip_prefix_list_summary
,
1912 show_ip_prefix_list_summary_cmd
,
1913 "show ip prefix-list summary",
1917 "Summary of prefix lists\n")
1919 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1922 DEFUN (show_ip_prefix_list_summary_name
,
1923 show_ip_prefix_list_summary_name_cmd
,
1924 "show ip prefix-list summary WORD",
1928 "Summary of prefix lists\n"
1929 "Name of a prefix list\n")
1931 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1935 DEFUN (show_ip_prefix_list_detail
,
1936 show_ip_prefix_list_detail_cmd
,
1937 "show ip prefix-list detail",
1941 "Detail of prefix lists\n")
1943 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1946 DEFUN (show_ip_prefix_list_detail_name
,
1947 show_ip_prefix_list_detail_name_cmd
,
1948 "show ip prefix-list detail WORD",
1952 "Detail of prefix lists\n"
1953 "Name of a prefix list\n")
1955 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1958 DEFUN (clear_ip_prefix_list
,
1959 clear_ip_prefix_list_cmd
,
1960 "clear ip prefix-list",
1965 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1968 DEFUN (clear_ip_prefix_list_name
,
1969 clear_ip_prefix_list_name_cmd
,
1970 "clear ip prefix-list WORD",
1974 "Name of a prefix list\n")
1976 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1979 DEFUN (clear_ip_prefix_list_name_prefix
,
1980 clear_ip_prefix_list_name_prefix_cmd
,
1981 "clear ip prefix-list WORD A.B.C.D/M",
1985 "Name of a prefix list\n"
1986 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1988 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1992 DEFUN (ipv6_prefix_list
,
1993 ipv6_prefix_list_cmd
,
1994 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
1997 "Name of a prefix list\n"
1998 "Specify packets to reject\n"
1999 "Specify packets to forward\n"
2000 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2001 "Any prefix match. Same as \"::0/0 le 128\"\n")
2003 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
2004 argv
[1], argv
[2], NULL
, NULL
);
2007 DEFUN (ipv6_prefix_list_ge
,
2008 ipv6_prefix_list_ge_cmd
,
2009 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2012 "Name of a prefix list\n"
2013 "Specify packets to reject\n"
2014 "Specify packets to forward\n"
2015 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2016 "Minimum prefix length to be matched\n"
2017 "Minimum prefix length\n")
2019 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2020 argv
[2], argv
[3], NULL
);
2023 DEFUN (ipv6_prefix_list_ge_le
,
2024 ipv6_prefix_list_ge_le_cmd
,
2025 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2028 "Name of a prefix list\n"
2029 "Specify packets to reject\n"
2030 "Specify packets to forward\n"
2031 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2032 "Minimum prefix length to be matched\n"
2033 "Minimum prefix length\n"
2034 "Maximum prefix length to be matched\n"
2035 "Maximum prefix length\n")
2038 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2039 argv
[2], argv
[3], argv
[4]);
2042 DEFUN (ipv6_prefix_list_le
,
2043 ipv6_prefix_list_le_cmd
,
2044 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2047 "Name of a prefix list\n"
2048 "Specify packets to reject\n"
2049 "Specify packets to forward\n"
2050 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2051 "Maximum prefix length to be matched\n"
2052 "Maximum prefix length\n")
2054 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2055 argv
[2], NULL
, argv
[3]);
2058 DEFUN (ipv6_prefix_list_le_ge
,
2059 ipv6_prefix_list_le_ge_cmd
,
2060 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2063 "Name of a prefix list\n"
2064 "Specify packets to reject\n"
2065 "Specify packets to forward\n"
2066 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2067 "Maximum prefix length to be matched\n"
2068 "Maximum prefix length\n"
2069 "Minimum prefix length to be matched\n"
2070 "Minimum prefix length\n")
2072 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2073 argv
[2], argv
[4], argv
[3]);
2076 DEFUN (ipv6_prefix_list_seq
,
2077 ipv6_prefix_list_seq_cmd
,
2078 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2081 "Name of a prefix list\n"
2082 "sequence number of an entry\n"
2084 "Specify packets to reject\n"
2085 "Specify packets to forward\n"
2086 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2087 "Any prefix match. Same as \"::0/0 le 128\"\n")
2089 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2090 argv
[3], NULL
, NULL
);
2093 DEFUN (ipv6_prefix_list_seq_ge
,
2094 ipv6_prefix_list_seq_ge_cmd
,
2095 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2098 "Name of a prefix list\n"
2099 "sequence number of an entry\n"
2101 "Specify packets to reject\n"
2102 "Specify packets to forward\n"
2103 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2104 "Minimum prefix length to be matched\n"
2105 "Minimum prefix length\n")
2107 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2108 argv
[3], argv
[4], NULL
);
2111 DEFUN (ipv6_prefix_list_seq_ge_le
,
2112 ipv6_prefix_list_seq_ge_le_cmd
,
2113 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2116 "Name of a prefix list\n"
2117 "sequence number of an entry\n"
2119 "Specify packets to reject\n"
2120 "Specify packets to forward\n"
2121 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2122 "Minimum prefix length to be matched\n"
2123 "Minimum prefix length\n"
2124 "Maximum prefix length to be matched\n"
2125 "Maximum prefix length\n")
2127 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2128 argv
[3], argv
[4], argv
[5]);
2131 DEFUN (ipv6_prefix_list_seq_le
,
2132 ipv6_prefix_list_seq_le_cmd
,
2133 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2136 "Name of a prefix list\n"
2137 "sequence number of an entry\n"
2139 "Specify packets to reject\n"
2140 "Specify packets to forward\n"
2141 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2142 "Maximum prefix length to be matched\n"
2143 "Maximum prefix length\n")
2145 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2146 argv
[3], NULL
, argv
[4]);
2149 DEFUN (ipv6_prefix_list_seq_le_ge
,
2150 ipv6_prefix_list_seq_le_ge_cmd
,
2151 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2154 "Name of a prefix list\n"
2155 "sequence number of an entry\n"
2157 "Specify packets to reject\n"
2158 "Specify packets to forward\n"
2159 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2160 "Maximum prefix length to be matched\n"
2161 "Maximum prefix length\n"
2162 "Minimum prefix length to be matched\n"
2163 "Minimum prefix length\n")
2165 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2166 argv
[3], argv
[5], argv
[4]);
2169 DEFUN (no_ipv6_prefix_list
,
2170 no_ipv6_prefix_list_cmd
,
2171 "no ipv6 prefix-list WORD",
2175 "Name of a prefix list\n")
2177 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
2181 DEFUN (no_ipv6_prefix_list_prefix
,
2182 no_ipv6_prefix_list_prefix_cmd
,
2183 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
2187 "Name of a prefix list\n"
2188 "Specify packets to reject\n"
2189 "Specify packets to forward\n"
2190 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2191 "Any prefix match. Same as \"::0/0 le 128\"\n")
2193 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2194 argv
[2], NULL
, NULL
);
2197 DEFUN (no_ipv6_prefix_list_ge
,
2198 no_ipv6_prefix_list_ge_cmd
,
2199 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2203 "Name of a prefix list\n"
2204 "Specify packets to reject\n"
2205 "Specify packets to forward\n"
2206 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2207 "Minimum prefix length to be matched\n"
2208 "Minimum prefix length\n")
2210 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2211 argv
[2], argv
[3], NULL
);
2214 DEFUN (no_ipv6_prefix_list_ge_le
,
2215 no_ipv6_prefix_list_ge_le_cmd
,
2216 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2220 "Name of a prefix list\n"
2221 "Specify packets to reject\n"
2222 "Specify packets to forward\n"
2223 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2224 "Minimum prefix length to be matched\n"
2225 "Minimum prefix length\n"
2226 "Maximum prefix length to be matched\n"
2227 "Maximum prefix length\n")
2229 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2230 argv
[2], argv
[3], argv
[4]);
2233 DEFUN (no_ipv6_prefix_list_le
,
2234 no_ipv6_prefix_list_le_cmd
,
2235 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128>",
2239 "Name of a prefix list\n"
2240 "Specify packets to reject\n"
2241 "Specify packets to forward\n"
2242 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2243 "Maximum prefix length to be matched\n"
2244 "Maximum prefix length\n")
2246 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2247 argv
[2], NULL
, argv
[3]);
2250 DEFUN (no_ipv6_prefix_list_le_ge
,
2251 no_ipv6_prefix_list_le_ge_cmd
,
2252 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2256 "Name of a prefix list\n"
2257 "Specify packets to reject\n"
2258 "Specify packets to forward\n"
2259 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2260 "Maximum prefix length to be matched\n"
2261 "Maximum prefix length\n"
2262 "Minimum prefix length to be matched\n"
2263 "Minimum prefix length\n")
2265 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2266 argv
[2], argv
[4], argv
[3]);
2269 DEFUN (no_ipv6_prefix_list_seq
,
2270 no_ipv6_prefix_list_seq_cmd
,
2271 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2275 "Name of a prefix list\n"
2276 "sequence number of an entry\n"
2278 "Specify packets to reject\n"
2279 "Specify packets to forward\n"
2280 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2281 "Any prefix match. Same as \"::0/0 le 128\"\n")
2283 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2284 argv
[3], NULL
, NULL
);
2287 DEFUN (no_ipv6_prefix_list_seq_ge
,
2288 no_ipv6_prefix_list_seq_ge_cmd
,
2289 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2293 "Name of a prefix list\n"
2294 "sequence number of an entry\n"
2296 "Specify packets to reject\n"
2297 "Specify packets to forward\n"
2298 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2299 "Minimum prefix length to be matched\n"
2300 "Minimum prefix length\n")
2302 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2303 argv
[3], argv
[4], NULL
);
2306 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2307 no_ipv6_prefix_list_seq_ge_le_cmd
,
2308 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2312 "Name of a prefix list\n"
2313 "sequence number of an entry\n"
2315 "Specify packets to reject\n"
2316 "Specify packets to forward\n"
2317 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2318 "Minimum prefix length to be matched\n"
2319 "Minimum prefix length\n"
2320 "Maximum prefix length to be matched\n"
2321 "Maximum prefix length\n")
2323 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2324 argv
[3], argv
[4], argv
[5]);
2327 DEFUN (no_ipv6_prefix_list_seq_le
,
2328 no_ipv6_prefix_list_seq_le_cmd
,
2329 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2333 "Name of a prefix list\n"
2334 "sequence number of an entry\n"
2336 "Specify packets to reject\n"
2337 "Specify packets to forward\n"
2338 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2339 "Maximum prefix length to be matched\n"
2340 "Maximum prefix length\n")
2342 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2343 argv
[3], NULL
, argv
[4]);
2346 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2347 no_ipv6_prefix_list_seq_le_ge_cmd
,
2348 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2352 "Name of a prefix list\n"
2353 "sequence number of an entry\n"
2355 "Specify packets to reject\n"
2356 "Specify packets to forward\n"
2357 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2358 "Maximum prefix length to be matched\n"
2359 "Maximum prefix length\n"
2360 "Minimum prefix length to be matched\n"
2361 "Minimum prefix length\n")
2363 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2364 argv
[3], argv
[5], argv
[4]);
2367 DEFUN (ipv6_prefix_list_sequence_number
,
2368 ipv6_prefix_list_sequence_number_cmd
,
2369 "ipv6 prefix-list sequence-number",
2372 "Include/exclude sequence numbers in NVGEN\n")
2374 prefix_master_ipv6
.seqnum
= 1;
2378 DEFUN (no_ipv6_prefix_list_sequence_number
,
2379 no_ipv6_prefix_list_sequence_number_cmd
,
2380 "no ipv6 prefix-list sequence-number",
2384 "Include/exclude sequence numbers in NVGEN\n")
2386 prefix_master_ipv6
.seqnum
= 0;
2390 DEFUN (ipv6_prefix_list_description
,
2391 ipv6_prefix_list_description_cmd
,
2392 "ipv6 prefix-list WORD description .LINE",
2395 "Name of a prefix list\n"
2396 "Prefix-list specific description\n"
2397 "Up to 80 characters describing this prefix-list\n")
2399 struct prefix_list
*plist
;
2401 plist
= prefix_list_get (AFI_IP6
, 0, argv
[0]);
2405 XFREE (MTYPE_TMP
, plist
->desc
);
2408 plist
->desc
= argv_concat(argv
, argc
, 1);
2413 DEFUN (no_ipv6_prefix_list_description
,
2414 no_ipv6_prefix_list_description_cmd
,
2415 "no ipv6 prefix-list WORD description",
2419 "Name of a prefix list\n"
2420 "Prefix-list specific description\n")
2422 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2425 ALIAS (no_ipv6_prefix_list_description
,
2426 no_ipv6_prefix_list_description_arg_cmd
,
2427 "no ipv6 prefix-list WORD description .LINE",
2431 "Name of a prefix list\n"
2432 "Prefix-list specific description\n"
2433 "Up to 80 characters describing this prefix-list\n")
2435 DEFUN (show_ipv6_prefix_list
,
2436 show_ipv6_prefix_list_cmd
,
2437 "show ipv6 prefix-list",
2442 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2445 DEFUN (show_ipv6_prefix_list_name
,
2446 show_ipv6_prefix_list_name_cmd
,
2447 "show ipv6 prefix-list WORD",
2451 "Name of a prefix list\n")
2453 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2456 DEFUN (show_ipv6_prefix_list_name_seq
,
2457 show_ipv6_prefix_list_name_seq_cmd
,
2458 "show ipv6 prefix-list WORD seq <1-4294967295>",
2462 "Name of a prefix list\n"
2463 "sequence number of an entry\n"
2464 "Sequence number\n")
2466 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2469 DEFUN (show_ipv6_prefix_list_prefix
,
2470 show_ipv6_prefix_list_prefix_cmd
,
2471 "show ipv6 prefix-list WORD X:X::X:X/M",
2475 "Name of a prefix list\n"
2476 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2478 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2481 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2482 show_ipv6_prefix_list_prefix_longer_cmd
,
2483 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2487 "Name of a prefix list\n"
2488 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2489 "Lookup longer prefix\n")
2491 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2494 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2495 show_ipv6_prefix_list_prefix_first_match_cmd
,
2496 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2500 "Name of a prefix list\n"
2501 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2502 "First matched prefix\n")
2504 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2507 DEFUN (show_ipv6_prefix_list_summary
,
2508 show_ipv6_prefix_list_summary_cmd
,
2509 "show ipv6 prefix-list summary",
2513 "Summary of prefix lists\n")
2515 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2518 DEFUN (show_ipv6_prefix_list_summary_name
,
2519 show_ipv6_prefix_list_summary_name_cmd
,
2520 "show ipv6 prefix-list summary WORD",
2524 "Summary of prefix lists\n"
2525 "Name of a prefix list\n")
2527 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2530 DEFUN (show_ipv6_prefix_list_detail
,
2531 show_ipv6_prefix_list_detail_cmd
,
2532 "show ipv6 prefix-list detail",
2536 "Detail of prefix lists\n")
2538 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2541 DEFUN (show_ipv6_prefix_list_detail_name
,
2542 show_ipv6_prefix_list_detail_name_cmd
,
2543 "show ipv6 prefix-list detail WORD",
2547 "Detail of prefix lists\n"
2548 "Name of a prefix list\n")
2550 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2553 DEFUN (clear_ipv6_prefix_list
,
2554 clear_ipv6_prefix_list_cmd
,
2555 "clear ipv6 prefix-list",
2560 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2563 DEFUN (clear_ipv6_prefix_list_name
,
2564 clear_ipv6_prefix_list_name_cmd
,
2565 "clear ipv6 prefix-list WORD",
2569 "Name of a prefix list\n")
2571 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2574 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2575 clear_ipv6_prefix_list_name_prefix_cmd
,
2576 "clear ipv6 prefix-list WORD X:X::X:X/M",
2580 "Name of a prefix list\n"
2581 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2583 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2585 #endif /* HAVE_IPV6 */
2587 /* Configuration write function. */
2589 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2591 struct prefix_list
*plist
;
2592 struct prefix_list_entry
*pentry
;
2593 struct prefix_master
*master
;
2596 master
= prefix_master_get (afi
, 0);
2600 if (! master
->seqnum
)
2602 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2603 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2604 vty_out (vty
, "!%s", VTY_NEWLINE
);
2607 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2611 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2612 afi
== AFI_IP
? "" : "v6",
2613 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2617 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2619 vty_out (vty
, "ip%s prefix-list %s ",
2620 afi
== AFI_IP
? "" : "v6",
2624 vty_out (vty
, "seq %u ", pentry
->seq
);
2626 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2629 vty_out (vty
, "any");
2632 struct prefix
*p
= &pentry
->prefix
;
2635 vty_out (vty
, "%s/%d",
2636 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2640 vty_out (vty
, " ge %d", pentry
->ge
);
2642 vty_out (vty
, " le %d", pentry
->le
);
2644 vty_out (vty
, "%s", VTY_NEWLINE
);
2647 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2650 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2654 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2655 afi
== AFI_IP
? "" : "v6",
2656 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2660 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2662 vty_out (vty
, "ip%s prefix-list %s ",
2663 afi
== AFI_IP
? "" : "v6",
2667 vty_out (vty
, "seq %u ", pentry
->seq
);
2669 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2672 vty_out (vty
, " any");
2675 struct prefix
*p
= &pentry
->prefix
;
2678 vty_out (vty
, " %s/%d",
2679 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2683 vty_out (vty
, " ge %d", pentry
->ge
);
2685 vty_out (vty
, " le %d", pentry
->le
);
2687 vty_out (vty
, "%s", VTY_NEWLINE
);
2696 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2697 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2699 struct prefix_list_entry
*pentry
;
2704 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2706 u_char flag
= init_flag
;
2707 struct prefix
*p
= &pentry
->prefix
;
2709 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2710 permit_flag
: deny_flag
);
2711 stream_putc (s
, flag
);
2712 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2713 stream_putc (s
, (u_char
)pentry
->ge
);
2714 stream_putc (s
, (u_char
)pentry
->le
);
2715 stream_put_prefix (s
, p
);
2722 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2723 int permit
, int set
)
2725 struct prefix_list
*plist
;
2726 struct prefix_list_entry
*pentry
;
2728 /* ge and le value check */
2729 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2731 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2733 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2736 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2739 plist
= prefix_list_get (afi
, 1, name
);
2745 pentry
= prefix_list_entry_make (&orfp
->p
,
2746 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2747 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2749 if (prefix_entry_dup_check (plist
, pentry
))
2751 prefix_list_entry_free (pentry
);
2755 prefix_list_entry_add (plist
, pentry
);
2759 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2760 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2761 orfp
->seq
, orfp
->le
, orfp
->ge
);
2766 prefix_list_entry_delete (plist
, pentry
, 1);
2773 prefix_bgp_orf_remove_all (afi_t afi
, char *name
)
2775 struct prefix_list
*plist
;
2777 plist
= prefix_bgp_orf_lookup (afi
, name
);
2779 prefix_list_delete (plist
);
2782 /* return prefix count */
2784 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
, u_char use_json
)
2786 struct prefix_list
*plist
;
2787 struct prefix_list_entry
*pentry
;
2788 json_object
*json
= NULL
;
2789 json_object
*json_prefix
= NULL
;
2790 json_object
*json_list
= NULL
;
2792 plist
= prefix_bgp_orf_lookup (afi
, name
);
2797 return plist
->count
;
2801 json
= json_object_new_object();
2802 json_prefix
= json_object_new_object();
2803 json_list
= json_object_new_object();
2805 json_object_int_add(json_prefix
, "prefixListCounter", plist
->count
);
2806 json_object_string_add(json_prefix
, "prefixListName", plist
->name
);
2808 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2810 struct prefix
*p
= &pentry
->prefix
;
2814 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
),
2817 json_object_int_add(json_list
, "seq", pentry
->seq
);
2818 json_object_string_add(json_list
, "seqPrefixListType", prefix_list_type_str (pentry
));
2821 json_object_int_add(json_list
, "ge", pentry
->ge
);
2823 json_object_int_add(json_list
, "le", pentry
->le
);
2825 json_object_object_add(json_prefix
, buf_a
, json_list
);
2828 json_object_object_add(json
, "ipPrefixList", json_prefix
);
2830 json_object_object_add(json
, "ipv6PrefixList", json_prefix
);
2832 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
2833 json_object_free(json
);
2837 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2838 afi
== AFI_IP
? "" : "v6",
2839 plist
->name
, plist
->count
, VTY_NEWLINE
);
2841 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2843 struct prefix
*p
= &pentry
->prefix
;
2846 vty_out (vty
, " seq %u %s %s/%d", pentry
->seq
,
2847 prefix_list_type_str (pentry
),
2848 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2852 vty_out (vty
, " ge %d", pentry
->ge
);
2854 vty_out (vty
, " le %d", pentry
->le
);
2856 vty_out (vty
, "%s", VTY_NEWLINE
);
2859 return plist
->count
;
2863 prefix_list_reset_afi (afi_t afi
, int orf
)
2865 struct prefix_list
*plist
;
2866 struct prefix_list
*next
;
2867 struct prefix_master
*master
;
2869 master
= prefix_master_get (afi
, orf
);
2873 for (plist
= master
->num
.head
; plist
; plist
= next
)
2876 prefix_list_delete (plist
);
2878 for (plist
= master
->str
.head
; plist
; plist
= next
)
2881 prefix_list_delete (plist
);
2884 assert (master
->num
.head
== NULL
);
2885 assert (master
->num
.tail
== NULL
);
2887 assert (master
->str
.head
== NULL
);
2888 assert (master
->str
.tail
== NULL
);
2891 master
->recent
= NULL
;
2895 /* Prefix-list node. */
2896 static struct cmd_node prefix_node
=
2899 "", /* Prefix list has no interface. */
2904 config_write_prefix_ipv4 (struct vty
*vty
)
2906 return config_write_prefix_afi (AFI_IP
, vty
);
2910 prefix_list_init_ipv4 (void)
2912 install_node (&prefix_node
, config_write_prefix_ipv4
);
2914 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2915 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2916 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2917 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2918 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2919 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2920 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2921 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2922 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2923 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2925 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2926 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2927 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2928 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2929 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2930 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2931 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2932 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2933 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2934 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2935 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2937 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2938 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2939 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2941 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2942 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2944 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2945 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2946 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2947 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2948 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2949 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2950 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2951 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2952 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2953 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2955 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2956 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2957 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2958 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2959 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2960 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2961 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2962 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2963 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2964 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2966 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2967 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2968 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2972 /* Prefix-list node. */
2973 static struct cmd_node prefix_ipv6_node
=
2976 "", /* Prefix list has no interface. */
2981 config_write_prefix_ipv6 (struct vty
*vty
)
2983 return config_write_prefix_afi (AFI_IP6
, vty
);
2987 prefix_list_init_ipv6 (void)
2989 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2991 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2992 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2993 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2994 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
2995 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
2996 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
2997 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
2998 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
2999 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
3000 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
3002 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
3003 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
3004 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
3005 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
3006 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
3007 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
3008 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
3009 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
3010 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
3011 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
3012 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
3014 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
3015 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
3016 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
3018 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
3019 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
3021 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
3022 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
3023 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
3024 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
3025 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
3026 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
3027 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
3028 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
3029 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
3030 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
3032 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
3033 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
3034 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
3035 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
3036 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
3037 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
3038 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
3039 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
3040 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
3041 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
3043 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
3044 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
3045 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
3047 #endif /* HAVE_IPV6 */
3052 prefix_list_init_ipv4 ();
3054 prefix_list_init_ipv6 ();
3055 #endif /* HAVE_IPV6 */
3059 prefix_list_reset ()
3061 prefix_list_reset_afi (AFI_IP
, 0);
3062 prefix_list_reset_afi (AFI_IP6
, 0);
3063 prefix_list_reset_afi (AFI_IP
, 1);
3064 prefix_list_reset_afi (AFI_IP6
, 1);