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 vty_out (vty
, "%% Unrecognized AFI (%d)%s", afi
, VTY_NEWLINE
);
968 /* ge and le check. */
969 if (genum
&& (genum
<= p
.prefixlen
))
970 return vty_invalid_prefix_range (vty
, prefix
);
972 if (lenum
&& (lenum
<= p
.prefixlen
))
973 return vty_invalid_prefix_range (vty
, prefix
);
975 if (lenum
&& (genum
> lenum
))
976 return vty_invalid_prefix_range (vty
, prefix
);
978 if (genum
&& (lenum
== (afi
== AFI_IP
? 32 : 128)))
981 /* Get prefix_list with name. */
982 plist
= prefix_list_get (afi
, 0, name
);
984 /* Make prefix entry. */
985 pentry
= prefix_list_entry_make (&p
, type
, seqnum
, lenum
, genum
, any
);
987 /* Check same policy. */
988 dup
= prefix_entry_dup_check (plist
, pentry
);
992 prefix_list_entry_free (pentry
);
993 vty_out (vty
, "%% Insertion failed - prefix-list entry exists:%s",
995 vty_out (vty
, " seq %u %s %s", dup
->seq
, typestr
, prefix
);
997 vty_out (vty
, " ge %d", genum
);
999 vty_out (vty
, " le %d", lenum
);
1000 vty_out (vty
, "%s", VTY_NEWLINE
);
1004 /* Install new filter to the access_list. */
1005 prefix_list_entry_add (plist
, pentry
);
1011 vty_prefix_list_uninstall (struct vty
*vty
, afi_t afi
, const char *name
,
1012 const char *seq
, const char *typestr
,
1013 const char *prefix
, const char *ge
, const char *le
)
1016 enum prefix_list_type type
;
1017 struct prefix_list
*plist
;
1018 struct prefix_list_entry
*pentry
;
1024 /* Check prefix list name. */
1025 plist
= prefix_list_lookup (afi
, name
);
1028 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1032 /* Only prefix-list name specified, delete the entire prefix-list. */
1033 if (seq
== NULL
&& typestr
== NULL
&& prefix
== NULL
&&
1034 ge
== NULL
&& le
== NULL
)
1036 prefix_list_delete (plist
);
1040 /* We must have, at a minimum, both the type and prefix here */
1041 if ((typestr
== NULL
) || (prefix
== NULL
))
1043 vty_out (vty
, "%% Both prefix and type required%s", VTY_NEWLINE
);
1047 /* Check sequence number. */
1049 seqnum
= atoi (seq
);
1051 /* ge and le number */
1057 /* Check of filter type. */
1058 if (strncmp ("permit", typestr
, 1) == 0)
1059 type
= PREFIX_PERMIT
;
1060 else if (strncmp ("deny", typestr
, 1) == 0)
1064 vty_out (vty
, "%% prefix type must be permit or deny%s", VTY_NEWLINE
);
1068 /* "any" is special token for matching any IPv4 addresses. */
1071 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1073 ret
= str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4
*) &p
);
1075 lenum
= IPV4_MAX_BITLEN
;
1078 ret
= str2prefix_ipv4 (prefix
, (struct prefix_ipv4
*) &p
);
1082 vty_out (vty
, "%% Malformed IPv4 prefix%s", VTY_NEWLINE
);
1087 else if (afi
== AFI_IP6
)
1089 if (strncmp ("any", prefix
, strlen (prefix
)) == 0)
1091 ret
= str2prefix_ipv6 ("::/0", (struct prefix_ipv6
*) &p
);
1093 lenum
= IPV6_MAX_BITLEN
;
1096 ret
= str2prefix_ipv6 (prefix
, (struct prefix_ipv6
*) &p
);
1100 vty_out (vty
, "%% Malformed IPv6 prefix%s", VTY_NEWLINE
);
1104 #endif /* HAVE_IPV6 */
1106 /* Lookup prefix entry. */
1107 pentry
= prefix_list_entry_lookup(plist
, &p
, type
, seqnum
, lenum
, genum
);
1111 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1115 /* Install new filter to the access_list. */
1116 prefix_list_entry_delete (plist
, pentry
, 1);
1122 vty_prefix_list_desc_unset (struct vty
*vty
, afi_t afi
, const char *name
)
1124 struct prefix_list
*plist
;
1126 plist
= prefix_list_lookup (afi
, name
);
1129 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1135 XFREE (MTYPE_TMP
, plist
->desc
);
1139 if (plist
->head
== NULL
&& plist
->tail
== NULL
&& plist
->desc
== NULL
)
1140 prefix_list_delete (plist
);
1156 vty_show_prefix_entry (struct vty
*vty
, afi_t afi
, struct prefix_list
*plist
,
1157 struct prefix_master
*master
, enum display_type dtype
,
1160 struct prefix_list_entry
*pentry
;
1162 /* Print the name of the protocol */
1164 vty_out (vty
, "%s: ", zlog_proto_names
[zlog_default
->protocol
]);
1166 if (dtype
== normal_display
)
1168 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
1169 afi
== AFI_IP
? "" : "v6",
1170 plist
->name
, plist
->count
, VTY_NEWLINE
);
1172 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1174 else if (dtype
== summary_display
|| dtype
== detail_display
)
1176 vty_out (vty
, "ip%s prefix-list %s:%s",
1177 afi
== AFI_IP
? "" : "v6", plist
->name
, VTY_NEWLINE
);
1180 vty_out (vty
, " Description: %s%s", plist
->desc
, VTY_NEWLINE
);
1182 vty_out (vty
, " count: %d, range entries: %d, sequences: %u - %u%s",
1183 plist
->count
, plist
->rangecount
,
1184 plist
->head
? plist
->head
->seq
: 0,
1185 plist
->tail
? plist
->tail
->seq
: 0,
1189 if (dtype
!= summary_display
)
1191 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1193 if (dtype
== sequential_display
&& pentry
->seq
!= seqnum
)
1199 vty_out (vty
, "seq %u ", pentry
->seq
);
1201 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
1204 vty_out (vty
, "any");
1207 struct prefix
*p
= &pentry
->prefix
;
1210 vty_out (vty
, "%s/%d",
1211 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1215 vty_out (vty
, " ge %d", pentry
->ge
);
1217 vty_out (vty
, " le %d", pentry
->le
);
1220 if (dtype
== detail_display
|| dtype
== sequential_display
)
1221 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1222 pentry
->hitcnt
, pentry
->refcnt
);
1224 vty_out (vty
, "%s", VTY_NEWLINE
);
1230 vty_show_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1231 const char *seq
, enum display_type dtype
)
1233 struct prefix_list
*plist
;
1234 struct prefix_master
*master
;
1237 master
= prefix_master_get (afi
, 0);
1242 seqnum
= atoi (seq
);
1246 plist
= prefix_list_lookup (afi
, name
);
1249 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1252 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1256 if (dtype
== detail_display
|| dtype
== summary_display
)
1259 vty_out (vty
, "Prefix-list with the last deletion/insertion: %s%s",
1260 master
->recent
->name
, VTY_NEWLINE
);
1263 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1264 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1266 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1267 vty_show_prefix_entry (vty
, afi
, plist
, master
, dtype
, seqnum
);
1274 vty_show_prefix_list_prefix (struct vty
*vty
, afi_t afi
, const char *name
,
1275 const char *prefix
, enum display_type type
)
1277 struct prefix_list
*plist
;
1278 struct prefix_list_entry
*pentry
;
1283 plist
= prefix_list_lookup (afi
, name
);
1286 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1290 ret
= str2prefix (prefix
, &p
);
1293 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1297 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1301 if (type
== normal_display
|| type
== first_match_display
)
1302 if (prefix_same (&p
, &pentry
->prefix
))
1305 if (type
== longer_display
)
1306 if (prefix_match (&p
, &pentry
->prefix
))
1311 vty_out (vty
, " seq %u %s ",
1313 prefix_list_type_str (pentry
));
1316 vty_out (vty
, "any");
1319 struct prefix
*p
= &pentry
->prefix
;
1322 vty_out (vty
, "%s/%d",
1323 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
1327 vty_out (vty
, " ge %d", pentry
->ge
);
1329 vty_out (vty
, " le %d", pentry
->le
);
1332 if (type
== normal_display
|| type
== first_match_display
)
1333 vty_out (vty
, " (hit count: %ld, refcount: %ld)",
1334 pentry
->hitcnt
, pentry
->refcnt
);
1336 vty_out (vty
, "%s", VTY_NEWLINE
);
1338 if (type
== first_match_display
)
1346 vty_clear_prefix_list (struct vty
*vty
, afi_t afi
, const char *name
,
1349 struct prefix_master
*master
;
1350 struct prefix_list
*plist
;
1351 struct prefix_list_entry
*pentry
;
1355 master
= prefix_master_get (afi
, 0);
1359 if (name
== NULL
&& prefix
== NULL
)
1361 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
1362 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1365 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
1366 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1371 plist
= prefix_list_lookup (afi
, name
);
1374 vty_out (vty
, "%% Can't find specified prefix-list%s", VTY_NEWLINE
);
1380 ret
= str2prefix (prefix
, &p
);
1383 vty_out (vty
, "%% prefix is malformed%s", VTY_NEWLINE
);
1388 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
1392 if (prefix_match (&pentry
->prefix
, &p
))
1402 DEFUN (ip_prefix_list
,
1404 "ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1407 "Name of a prefix list\n"
1408 "Specify packets to reject\n"
1409 "Specify packets to forward\n"
1410 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1411 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1413 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
,
1414 argv
[1], argv
[2], NULL
, NULL
);
1417 DEFUN (ip_prefix_list_ge
,
1418 ip_prefix_list_ge_cmd
,
1419 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1422 "Name of a prefix list\n"
1423 "Specify packets to reject\n"
1424 "Specify packets to forward\n"
1425 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1426 "Minimum prefix length to be matched\n"
1427 "Minimum prefix length\n")
1429 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1430 argv
[2], argv
[3], NULL
);
1433 DEFUN (ip_prefix_list_ge_le
,
1434 ip_prefix_list_ge_le_cmd
,
1435 "ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1438 "Name of a prefix list\n"
1439 "Specify packets to reject\n"
1440 "Specify packets to forward\n"
1441 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1442 "Minimum prefix length to be matched\n"
1443 "Minimum prefix length\n"
1444 "Maximum prefix length to be matched\n"
1445 "Maximum prefix length\n")
1447 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1448 argv
[2], argv
[3], argv
[4]);
1451 DEFUN (ip_prefix_list_le
,
1452 ip_prefix_list_le_cmd
,
1453 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32>",
1456 "Name of a prefix list\n"
1457 "Specify packets to reject\n"
1458 "Specify packets to forward\n"
1459 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1460 "Maximum prefix length to be matched\n"
1461 "Maximum prefix length\n")
1463 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1464 argv
[2], NULL
, argv
[3]);
1467 DEFUN (ip_prefix_list_le_ge
,
1468 ip_prefix_list_le_ge_cmd
,
1469 "ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1472 "Name of a prefix list\n"
1473 "Specify packets to reject\n"
1474 "Specify packets to forward\n"
1475 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1476 "Maximum prefix length to be matched\n"
1477 "Maximum prefix length\n"
1478 "Minimum prefix length to be matched\n"
1479 "Minimum prefix length\n")
1481 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1482 argv
[2], argv
[4], argv
[3]);
1485 DEFUN (ip_prefix_list_seq
,
1486 ip_prefix_list_seq_cmd
,
1487 "ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1490 "Name of a prefix list\n"
1491 "sequence number of an entry\n"
1493 "Specify packets to reject\n"
1494 "Specify packets to forward\n"
1495 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1496 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1498 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1499 argv
[3], NULL
, NULL
);
1502 DEFUN (ip_prefix_list_seq_ge
,
1503 ip_prefix_list_seq_ge_cmd
,
1504 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1507 "Name of a prefix list\n"
1508 "sequence number of an entry\n"
1510 "Specify packets to reject\n"
1511 "Specify packets to forward\n"
1512 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1513 "Minimum prefix length to be matched\n"
1514 "Minimum prefix length\n")
1516 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1517 argv
[3], argv
[4], NULL
);
1520 DEFUN (ip_prefix_list_seq_ge_le
,
1521 ip_prefix_list_seq_ge_le_cmd
,
1522 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1525 "Name of a prefix list\n"
1526 "sequence number of an entry\n"
1528 "Specify packets to reject\n"
1529 "Specify packets to forward\n"
1530 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1531 "Minimum prefix length to be matched\n"
1532 "Minimum prefix length\n"
1533 "Maximum prefix length to be matched\n"
1534 "Maximum prefix length\n")
1536 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1537 argv
[3], argv
[4], argv
[5]);
1540 DEFUN (ip_prefix_list_seq_le
,
1541 ip_prefix_list_seq_le_cmd
,
1542 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1545 "Name of a prefix list\n"
1546 "sequence number of an entry\n"
1548 "Specify packets to reject\n"
1549 "Specify packets to forward\n"
1550 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1551 "Maximum prefix length to be matched\n"
1552 "Maximum prefix length\n")
1554 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1555 argv
[3], NULL
, argv
[4]);
1558 DEFUN (ip_prefix_list_seq_le_ge
,
1559 ip_prefix_list_seq_le_ge_cmd
,
1560 "ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1563 "Name of a prefix list\n"
1564 "sequence number of an entry\n"
1566 "Specify packets to reject\n"
1567 "Specify packets to forward\n"
1568 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1569 "Maximum prefix length to be matched\n"
1570 "Maximum prefix length\n"
1571 "Minimum prefix length to be matched\n"
1572 "Minimum prefix length\n")
1574 return vty_prefix_list_install (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1575 argv
[3], argv
[5], argv
[4]);
1578 DEFUN (no_ip_prefix_list
,
1579 no_ip_prefix_list_cmd
,
1580 "no ip prefix-list WORD",
1584 "Name of a prefix list\n")
1586 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, NULL
,
1590 DEFUN (no_ip_prefix_list_prefix
,
1591 no_ip_prefix_list_prefix_cmd
,
1592 "no ip prefix-list WORD (deny|permit) (A.B.C.D/M|any)",
1596 "Name of a prefix list\n"
1597 "Specify packets to reject\n"
1598 "Specify packets to forward\n"
1599 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1600 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1602 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1603 argv
[2], NULL
, NULL
);
1606 DEFUN (no_ip_prefix_list_ge
,
1607 no_ip_prefix_list_ge_cmd
,
1608 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32>",
1612 "Name of a prefix list\n"
1613 "Specify packets to reject\n"
1614 "Specify packets to forward\n"
1615 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1616 "Minimum prefix length to be matched\n"
1617 "Minimum prefix length\n")
1619 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1620 argv
[2], argv
[3], NULL
);
1623 DEFUN (no_ip_prefix_list_ge_le
,
1624 no_ip_prefix_list_ge_le_cmd
,
1625 "no ip prefix-list WORD (deny|permit) A.B.C.D/M ge <0-32> le <0-32>",
1629 "Name of a prefix list\n"
1630 "Specify packets to reject\n"
1631 "Specify packets to forward\n"
1632 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1633 "Minimum prefix length to be matched\n"
1634 "Minimum prefix length\n"
1635 "Maximum prefix length to be matched\n"
1636 "Maximum prefix length\n")
1638 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1639 argv
[2], argv
[3], argv
[4]);
1642 DEFUN (no_ip_prefix_list_le
,
1643 no_ip_prefix_list_le_cmd
,
1644 "no ip prefix-list WORD (deny|permit) A.B.C.D/M 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 "Maximum prefix length to be matched\n"
1653 "Maximum prefix length\n")
1655 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1656 argv
[2], NULL
, argv
[3]);
1659 DEFUN (no_ip_prefix_list_le_ge
,
1660 no_ip_prefix_list_le_ge_cmd
,
1661 "no ip prefix-list WORD (deny|permit) A.B.C.D/M le <0-32> ge <0-32>",
1665 "Name of a prefix list\n"
1666 "Specify packets to reject\n"
1667 "Specify packets to forward\n"
1668 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1669 "Maximum prefix length to be matched\n"
1670 "Maximum prefix length\n"
1671 "Minimum prefix length to be matched\n"
1672 "Minimum prefix length\n")
1674 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], NULL
, argv
[1],
1675 argv
[2], argv
[4], argv
[3]);
1678 DEFUN (no_ip_prefix_list_seq
,
1679 no_ip_prefix_list_seq_cmd
,
1680 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) (A.B.C.D/M|any)",
1684 "Name of a prefix list\n"
1685 "sequence number of an entry\n"
1687 "Specify packets to reject\n"
1688 "Specify packets to forward\n"
1689 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1690 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1692 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1693 argv
[3], NULL
, NULL
);
1696 DEFUN (no_ip_prefix_list_seq_ge
,
1697 no_ip_prefix_list_seq_ge_cmd
,
1698 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32>",
1702 "Name of a prefix list\n"
1703 "sequence number of an entry\n"
1705 "Specify packets to reject\n"
1706 "Specify packets to forward\n"
1707 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1708 "Minimum prefix length to be matched\n"
1709 "Minimum prefix length\n")
1711 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1712 argv
[3], argv
[4], NULL
);
1715 DEFUN (no_ip_prefix_list_seq_ge_le
,
1716 no_ip_prefix_list_seq_ge_le_cmd
,
1717 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M ge <0-32> le <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"
1729 "Maximum prefix length to be matched\n"
1730 "Maximum prefix length\n")
1732 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1733 argv
[3], argv
[4], argv
[5]);
1736 DEFUN (no_ip_prefix_list_seq_le
,
1737 no_ip_prefix_list_seq_le_cmd
,
1738 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32>",
1742 "Name of a prefix list\n"
1743 "sequence number of an entry\n"
1745 "Specify packets to reject\n"
1746 "Specify packets to forward\n"
1747 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\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], NULL
, argv
[4]);
1755 DEFUN (no_ip_prefix_list_seq_le_ge
,
1756 no_ip_prefix_list_seq_le_ge_cmd
,
1757 "no ip prefix-list WORD seq <1-4294967295> (deny|permit) A.B.C.D/M le <0-32> ge <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"
1769 "Minimum prefix length to be matched\n"
1770 "Minimum prefix length\n")
1772 return vty_prefix_list_uninstall (vty
, AFI_IP
, argv
[0], argv
[1], argv
[2],
1773 argv
[3], argv
[5], argv
[4]);
1776 DEFUN (ip_prefix_list_sequence_number
,
1777 ip_prefix_list_sequence_number_cmd
,
1778 "ip prefix-list sequence-number",
1781 "Include/exclude sequence numbers in NVGEN\n")
1783 prefix_master_ipv4
.seqnum
= 1;
1787 DEFUN (no_ip_prefix_list_sequence_number
,
1788 no_ip_prefix_list_sequence_number_cmd
,
1789 "no ip prefix-list sequence-number",
1793 "Include/exclude sequence numbers in NVGEN\n")
1795 prefix_master_ipv4
.seqnum
= 0;
1799 DEFUN (ip_prefix_list_description
,
1800 ip_prefix_list_description_cmd
,
1801 "ip prefix-list WORD description .LINE",
1804 "Name of a prefix list\n"
1805 "Prefix-list specific description\n"
1806 "Up to 80 characters describing this prefix-list\n")
1808 struct prefix_list
*plist
;
1810 plist
= prefix_list_get (AFI_IP
, 0, argv
[0]);
1814 XFREE (MTYPE_TMP
, plist
->desc
);
1817 plist
->desc
= argv_concat(argv
, argc
, 1);
1822 DEFUN (no_ip_prefix_list_description
,
1823 no_ip_prefix_list_description_cmd
,
1824 "no ip prefix-list WORD description",
1828 "Name of a prefix list\n"
1829 "Prefix-list specific description\n")
1831 return vty_prefix_list_desc_unset (vty
, AFI_IP
, argv
[0]);
1834 ALIAS (no_ip_prefix_list_description
,
1835 no_ip_prefix_list_description_arg_cmd
,
1836 "no ip prefix-list WORD description .LINE",
1840 "Name of a prefix list\n"
1841 "Prefix-list specific description\n"
1842 "Up to 80 characters describing this prefix-list\n")
1844 DEFUN (show_ip_prefix_list
,
1845 show_ip_prefix_list_cmd
,
1846 "show ip prefix-list",
1851 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, normal_display
);
1854 DEFUN (show_ip_prefix_list_name
,
1855 show_ip_prefix_list_name_cmd
,
1856 "show ip prefix-list WORD",
1860 "Name of a prefix list\n")
1862 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, normal_display
);
1865 DEFUN (show_ip_prefix_list_name_seq
,
1866 show_ip_prefix_list_name_seq_cmd
,
1867 "show ip prefix-list WORD seq <1-4294967295>",
1871 "Name of a prefix list\n"
1872 "sequence number of an entry\n"
1873 "Sequence number\n")
1875 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1], sequential_display
);
1878 DEFUN (show_ip_prefix_list_prefix
,
1879 show_ip_prefix_list_prefix_cmd
,
1880 "show ip prefix-list WORD A.B.C.D/M",
1884 "Name of a prefix list\n"
1885 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1887 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], normal_display
);
1890 DEFUN (show_ip_prefix_list_prefix_longer
,
1891 show_ip_prefix_list_prefix_longer_cmd
,
1892 "show ip prefix-list WORD A.B.C.D/M longer",
1896 "Name of a prefix list\n"
1897 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1898 "Lookup longer prefix\n")
1900 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], longer_display
);
1903 DEFUN (show_ip_prefix_list_prefix_first_match
,
1904 show_ip_prefix_list_prefix_first_match_cmd
,
1905 "show ip prefix-list WORD A.B.C.D/M first-match",
1909 "Name of a prefix list\n"
1910 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1911 "First matched prefix\n")
1913 return vty_show_prefix_list_prefix (vty
, AFI_IP
, argv
[0], argv
[1], first_match_display
);
1916 DEFUN (show_ip_prefix_list_summary
,
1917 show_ip_prefix_list_summary_cmd
,
1918 "show ip prefix-list summary",
1922 "Summary of prefix lists\n")
1924 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, summary_display
);
1927 DEFUN (show_ip_prefix_list_summary_name
,
1928 show_ip_prefix_list_summary_name_cmd
,
1929 "show ip prefix-list summary WORD",
1933 "Summary of prefix lists\n"
1934 "Name of a prefix list\n")
1936 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, summary_display
);
1940 DEFUN (show_ip_prefix_list_detail
,
1941 show_ip_prefix_list_detail_cmd
,
1942 "show ip prefix-list detail",
1946 "Detail of prefix lists\n")
1948 return vty_show_prefix_list (vty
, AFI_IP
, NULL
, NULL
, detail_display
);
1951 DEFUN (show_ip_prefix_list_detail_name
,
1952 show_ip_prefix_list_detail_name_cmd
,
1953 "show ip prefix-list detail WORD",
1957 "Detail of prefix lists\n"
1958 "Name of a prefix list\n")
1960 return vty_show_prefix_list (vty
, AFI_IP
, argv
[0], NULL
, detail_display
);
1963 DEFUN (clear_ip_prefix_list
,
1964 clear_ip_prefix_list_cmd
,
1965 "clear ip prefix-list",
1970 return vty_clear_prefix_list (vty
, AFI_IP
, NULL
, NULL
);
1973 DEFUN (clear_ip_prefix_list_name
,
1974 clear_ip_prefix_list_name_cmd
,
1975 "clear ip prefix-list WORD",
1979 "Name of a prefix list\n")
1981 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], NULL
);
1984 DEFUN (clear_ip_prefix_list_name_prefix
,
1985 clear_ip_prefix_list_name_prefix_cmd
,
1986 "clear ip prefix-list WORD A.B.C.D/M",
1990 "Name of a prefix list\n"
1991 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
1993 return vty_clear_prefix_list (vty
, AFI_IP
, argv
[0], argv
[1]);
1997 DEFUN (ipv6_prefix_list
,
1998 ipv6_prefix_list_cmd
,
1999 "ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
2002 "Name of a prefix list\n"
2003 "Specify packets to reject\n"
2004 "Specify packets to forward\n"
2005 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2006 "Any prefix match. Same as \"::0/0 le 128\"\n")
2008 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
,
2009 argv
[1], argv
[2], NULL
, NULL
);
2012 DEFUN (ipv6_prefix_list_ge
,
2013 ipv6_prefix_list_ge_cmd
,
2014 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2017 "Name of a prefix list\n"
2018 "Specify packets to reject\n"
2019 "Specify packets to forward\n"
2020 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2021 "Minimum prefix length to be matched\n"
2022 "Minimum prefix length\n")
2024 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2025 argv
[2], argv
[3], NULL
);
2028 DEFUN (ipv6_prefix_list_ge_le
,
2029 ipv6_prefix_list_ge_le_cmd
,
2030 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2033 "Name of a prefix list\n"
2034 "Specify packets to reject\n"
2035 "Specify packets to forward\n"
2036 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2037 "Minimum prefix length to be matched\n"
2038 "Minimum prefix length\n"
2039 "Maximum prefix length to be matched\n"
2040 "Maximum prefix length\n")
2043 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2044 argv
[2], argv
[3], argv
[4]);
2047 DEFUN (ipv6_prefix_list_le
,
2048 ipv6_prefix_list_le_cmd
,
2049 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M 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 "Maximum prefix length to be matched\n"
2057 "Maximum prefix length\n")
2059 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2060 argv
[2], NULL
, argv
[3]);
2063 DEFUN (ipv6_prefix_list_le_ge
,
2064 ipv6_prefix_list_le_ge_cmd
,
2065 "ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2068 "Name of a prefix list\n"
2069 "Specify packets to reject\n"
2070 "Specify packets to forward\n"
2071 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2072 "Maximum prefix length to be matched\n"
2073 "Maximum prefix length\n"
2074 "Minimum prefix length to be matched\n"
2075 "Minimum prefix length\n")
2077 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2078 argv
[2], argv
[4], argv
[3]);
2081 DEFUN (ipv6_prefix_list_seq
,
2082 ipv6_prefix_list_seq_cmd
,
2083 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2086 "Name of a prefix list\n"
2087 "sequence number of an entry\n"
2089 "Specify packets to reject\n"
2090 "Specify packets to forward\n"
2091 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2092 "Any prefix match. Same as \"::0/0 le 128\"\n")
2094 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2095 argv
[3], NULL
, NULL
);
2098 DEFUN (ipv6_prefix_list_seq_ge
,
2099 ipv6_prefix_list_seq_ge_cmd
,
2100 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2103 "Name of a prefix list\n"
2104 "sequence number of an entry\n"
2106 "Specify packets to reject\n"
2107 "Specify packets to forward\n"
2108 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2109 "Minimum prefix length to be matched\n"
2110 "Minimum prefix length\n")
2112 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2113 argv
[3], argv
[4], NULL
);
2116 DEFUN (ipv6_prefix_list_seq_ge_le
,
2117 ipv6_prefix_list_seq_ge_le_cmd
,
2118 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2121 "Name of a prefix list\n"
2122 "sequence number of an entry\n"
2124 "Specify packets to reject\n"
2125 "Specify packets to forward\n"
2126 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2127 "Minimum prefix length to be matched\n"
2128 "Minimum prefix length\n"
2129 "Maximum prefix length to be matched\n"
2130 "Maximum prefix length\n")
2132 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2133 argv
[3], argv
[4], argv
[5]);
2136 DEFUN (ipv6_prefix_list_seq_le
,
2137 ipv6_prefix_list_seq_le_cmd
,
2138 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2141 "Name of a prefix list\n"
2142 "sequence number of an entry\n"
2144 "Specify packets to reject\n"
2145 "Specify packets to forward\n"
2146 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2147 "Maximum prefix length to be matched\n"
2148 "Maximum prefix length\n")
2150 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2151 argv
[3], NULL
, argv
[4]);
2154 DEFUN (ipv6_prefix_list_seq_le_ge
,
2155 ipv6_prefix_list_seq_le_ge_cmd
,
2156 "ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2159 "Name of a prefix list\n"
2160 "sequence number of an entry\n"
2162 "Specify packets to reject\n"
2163 "Specify packets to forward\n"
2164 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2165 "Maximum prefix length to be matched\n"
2166 "Maximum prefix length\n"
2167 "Minimum prefix length to be matched\n"
2168 "Minimum prefix length\n")
2170 return vty_prefix_list_install (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2171 argv
[3], argv
[5], argv
[4]);
2174 DEFUN (no_ipv6_prefix_list
,
2175 no_ipv6_prefix_list_cmd
,
2176 "no ipv6 prefix-list WORD",
2180 "Name of a prefix list\n")
2182 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, NULL
,
2186 DEFUN (no_ipv6_prefix_list_prefix
,
2187 no_ipv6_prefix_list_prefix_cmd
,
2188 "no ipv6 prefix-list WORD (deny|permit) (X:X::X:X/M|any)",
2192 "Name of a prefix list\n"
2193 "Specify packets to reject\n"
2194 "Specify packets to forward\n"
2195 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2196 "Any prefix match. Same as \"::0/0 le 128\"\n")
2198 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2199 argv
[2], NULL
, NULL
);
2202 DEFUN (no_ipv6_prefix_list_ge
,
2203 no_ipv6_prefix_list_ge_cmd
,
2204 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128>",
2208 "Name of a prefix list\n"
2209 "Specify packets to reject\n"
2210 "Specify packets to forward\n"
2211 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2212 "Minimum prefix length to be matched\n"
2213 "Minimum prefix length\n")
2215 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2216 argv
[2], argv
[3], NULL
);
2219 DEFUN (no_ipv6_prefix_list_ge_le
,
2220 no_ipv6_prefix_list_ge_le_cmd
,
2221 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M ge <0-128> le <0-128>",
2225 "Name of a prefix list\n"
2226 "Specify packets to reject\n"
2227 "Specify packets to forward\n"
2228 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2229 "Minimum prefix length to be matched\n"
2230 "Minimum prefix length\n"
2231 "Maximum prefix length to be matched\n"
2232 "Maximum prefix length\n")
2234 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2235 argv
[2], argv
[3], argv
[4]);
2238 DEFUN (no_ipv6_prefix_list_le
,
2239 no_ipv6_prefix_list_le_cmd
,
2240 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M 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 "Maximum prefix length to be matched\n"
2249 "Maximum prefix length\n")
2251 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2252 argv
[2], NULL
, argv
[3]);
2255 DEFUN (no_ipv6_prefix_list_le_ge
,
2256 no_ipv6_prefix_list_le_ge_cmd
,
2257 "no ipv6 prefix-list WORD (deny|permit) X:X::X:X/M le <0-128> ge <0-128>",
2261 "Name of a prefix list\n"
2262 "Specify packets to reject\n"
2263 "Specify packets to forward\n"
2264 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2265 "Maximum prefix length to be matched\n"
2266 "Maximum prefix length\n"
2267 "Minimum prefix length to be matched\n"
2268 "Minimum prefix length\n")
2270 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], NULL
, argv
[1],
2271 argv
[2], argv
[4], argv
[3]);
2274 DEFUN (no_ipv6_prefix_list_seq
,
2275 no_ipv6_prefix_list_seq_cmd
,
2276 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) (X:X::X:X/M|any)",
2280 "Name of a prefix list\n"
2281 "sequence number of an entry\n"
2283 "Specify packets to reject\n"
2284 "Specify packets to forward\n"
2285 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2286 "Any prefix match. Same as \"::0/0 le 128\"\n")
2288 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2289 argv
[3], NULL
, NULL
);
2292 DEFUN (no_ipv6_prefix_list_seq_ge
,
2293 no_ipv6_prefix_list_seq_ge_cmd
,
2294 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128>",
2298 "Name of a prefix list\n"
2299 "sequence number of an entry\n"
2301 "Specify packets to reject\n"
2302 "Specify packets to forward\n"
2303 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2304 "Minimum prefix length to be matched\n"
2305 "Minimum prefix length\n")
2307 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2308 argv
[3], argv
[4], NULL
);
2311 DEFUN (no_ipv6_prefix_list_seq_ge_le
,
2312 no_ipv6_prefix_list_seq_ge_le_cmd
,
2313 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M ge <0-128> le <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"
2325 "Maximum prefix length to be matched\n"
2326 "Maximum prefix length\n")
2328 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2329 argv
[3], argv
[4], argv
[5]);
2332 DEFUN (no_ipv6_prefix_list_seq_le
,
2333 no_ipv6_prefix_list_seq_le_cmd
,
2334 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128>",
2338 "Name of a prefix list\n"
2339 "sequence number of an entry\n"
2341 "Specify packets to reject\n"
2342 "Specify packets to forward\n"
2343 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\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], NULL
, argv
[4]);
2351 DEFUN (no_ipv6_prefix_list_seq_le_ge
,
2352 no_ipv6_prefix_list_seq_le_ge_cmd
,
2353 "no ipv6 prefix-list WORD seq <1-4294967295> (deny|permit) X:X::X:X/M le <0-128> ge <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"
2365 "Minimum prefix length to be matched\n"
2366 "Minimum prefix length\n")
2368 return vty_prefix_list_uninstall (vty
, AFI_IP6
, argv
[0], argv
[1], argv
[2],
2369 argv
[3], argv
[5], argv
[4]);
2372 DEFUN (ipv6_prefix_list_sequence_number
,
2373 ipv6_prefix_list_sequence_number_cmd
,
2374 "ipv6 prefix-list sequence-number",
2377 "Include/exclude sequence numbers in NVGEN\n")
2379 prefix_master_ipv6
.seqnum
= 1;
2383 DEFUN (no_ipv6_prefix_list_sequence_number
,
2384 no_ipv6_prefix_list_sequence_number_cmd
,
2385 "no ipv6 prefix-list sequence-number",
2389 "Include/exclude sequence numbers in NVGEN\n")
2391 prefix_master_ipv6
.seqnum
= 0;
2395 DEFUN (ipv6_prefix_list_description
,
2396 ipv6_prefix_list_description_cmd
,
2397 "ipv6 prefix-list WORD description .LINE",
2400 "Name of a prefix list\n"
2401 "Prefix-list specific description\n"
2402 "Up to 80 characters describing this prefix-list\n")
2404 struct prefix_list
*plist
;
2406 plist
= prefix_list_get (AFI_IP6
, 0, argv
[0]);
2410 XFREE (MTYPE_TMP
, plist
->desc
);
2413 plist
->desc
= argv_concat(argv
, argc
, 1);
2418 DEFUN (no_ipv6_prefix_list_description
,
2419 no_ipv6_prefix_list_description_cmd
,
2420 "no ipv6 prefix-list WORD description",
2424 "Name of a prefix list\n"
2425 "Prefix-list specific description\n")
2427 return vty_prefix_list_desc_unset (vty
, AFI_IP6
, argv
[0]);
2430 ALIAS (no_ipv6_prefix_list_description
,
2431 no_ipv6_prefix_list_description_arg_cmd
,
2432 "no ipv6 prefix-list WORD description .LINE",
2436 "Name of a prefix list\n"
2437 "Prefix-list specific description\n"
2438 "Up to 80 characters describing this prefix-list\n")
2440 DEFUN (show_ipv6_prefix_list
,
2441 show_ipv6_prefix_list_cmd
,
2442 "show ipv6 prefix-list",
2447 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, normal_display
);
2450 DEFUN (show_ipv6_prefix_list_name
,
2451 show_ipv6_prefix_list_name_cmd
,
2452 "show ipv6 prefix-list WORD",
2456 "Name of a prefix list\n")
2458 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, normal_display
);
2461 DEFUN (show_ipv6_prefix_list_name_seq
,
2462 show_ipv6_prefix_list_name_seq_cmd
,
2463 "show ipv6 prefix-list WORD seq <1-4294967295>",
2467 "Name of a prefix list\n"
2468 "sequence number of an entry\n"
2469 "Sequence number\n")
2471 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1], sequential_display
);
2474 DEFUN (show_ipv6_prefix_list_prefix
,
2475 show_ipv6_prefix_list_prefix_cmd
,
2476 "show ipv6 prefix-list WORD X:X::X:X/M",
2480 "Name of a prefix list\n"
2481 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2483 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], normal_display
);
2486 DEFUN (show_ipv6_prefix_list_prefix_longer
,
2487 show_ipv6_prefix_list_prefix_longer_cmd
,
2488 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2492 "Name of a prefix list\n"
2493 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2494 "Lookup longer prefix\n")
2496 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], longer_display
);
2499 DEFUN (show_ipv6_prefix_list_prefix_first_match
,
2500 show_ipv6_prefix_list_prefix_first_match_cmd
,
2501 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2505 "Name of a prefix list\n"
2506 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2507 "First matched prefix\n")
2509 return vty_show_prefix_list_prefix (vty
, AFI_IP6
, argv
[0], argv
[1], first_match_display
);
2512 DEFUN (show_ipv6_prefix_list_summary
,
2513 show_ipv6_prefix_list_summary_cmd
,
2514 "show ipv6 prefix-list summary",
2518 "Summary of prefix lists\n")
2520 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, summary_display
);
2523 DEFUN (show_ipv6_prefix_list_summary_name
,
2524 show_ipv6_prefix_list_summary_name_cmd
,
2525 "show ipv6 prefix-list summary WORD",
2529 "Summary of prefix lists\n"
2530 "Name of a prefix list\n")
2532 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, summary_display
);
2535 DEFUN (show_ipv6_prefix_list_detail
,
2536 show_ipv6_prefix_list_detail_cmd
,
2537 "show ipv6 prefix-list detail",
2541 "Detail of prefix lists\n")
2543 return vty_show_prefix_list (vty
, AFI_IP6
, NULL
, NULL
, detail_display
);
2546 DEFUN (show_ipv6_prefix_list_detail_name
,
2547 show_ipv6_prefix_list_detail_name_cmd
,
2548 "show ipv6 prefix-list detail WORD",
2552 "Detail of prefix lists\n"
2553 "Name of a prefix list\n")
2555 return vty_show_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
, detail_display
);
2558 DEFUN (clear_ipv6_prefix_list
,
2559 clear_ipv6_prefix_list_cmd
,
2560 "clear ipv6 prefix-list",
2565 return vty_clear_prefix_list (vty
, AFI_IP6
, NULL
, NULL
);
2568 DEFUN (clear_ipv6_prefix_list_name
,
2569 clear_ipv6_prefix_list_name_cmd
,
2570 "clear ipv6 prefix-list WORD",
2574 "Name of a prefix list\n")
2576 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], NULL
);
2579 DEFUN (clear_ipv6_prefix_list_name_prefix
,
2580 clear_ipv6_prefix_list_name_prefix_cmd
,
2581 "clear ipv6 prefix-list WORD X:X::X:X/M",
2585 "Name of a prefix list\n"
2586 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2588 return vty_clear_prefix_list (vty
, AFI_IP6
, argv
[0], argv
[1]);
2590 #endif /* HAVE_IPV6 */
2592 /* Configuration write function. */
2594 config_write_prefix_afi (afi_t afi
, struct vty
*vty
)
2596 struct prefix_list
*plist
;
2597 struct prefix_list_entry
*pentry
;
2598 struct prefix_master
*master
;
2601 master
= prefix_master_get (afi
, 0);
2605 if (! master
->seqnum
)
2607 vty_out (vty
, "no ip%s prefix-list sequence-number%s",
2608 afi
== AFI_IP
? "" : "v6", VTY_NEWLINE
);
2609 vty_out (vty
, "!%s", VTY_NEWLINE
);
2612 for (plist
= master
->num
.head
; plist
; plist
= plist
->next
)
2616 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2617 afi
== AFI_IP
? "" : "v6",
2618 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2622 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2624 vty_out (vty
, "ip%s prefix-list %s ",
2625 afi
== AFI_IP
? "" : "v6",
2629 vty_out (vty
, "seq %u ", pentry
->seq
);
2631 vty_out (vty
, "%s ", prefix_list_type_str (pentry
));
2634 vty_out (vty
, "any");
2637 struct prefix
*p
= &pentry
->prefix
;
2640 vty_out (vty
, "%s/%d",
2641 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2645 vty_out (vty
, " ge %d", pentry
->ge
);
2647 vty_out (vty
, " le %d", pentry
->le
);
2649 vty_out (vty
, "%s", VTY_NEWLINE
);
2652 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2655 for (plist
= master
->str
.head
; plist
; plist
= plist
->next
)
2659 vty_out (vty
, "ip%s prefix-list %s description %s%s",
2660 afi
== AFI_IP
? "" : "v6",
2661 plist
->name
, plist
->desc
, VTY_NEWLINE
);
2665 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2667 vty_out (vty
, "ip%s prefix-list %s ",
2668 afi
== AFI_IP
? "" : "v6",
2672 vty_out (vty
, "seq %u ", pentry
->seq
);
2674 vty_out (vty
, "%s", prefix_list_type_str (pentry
));
2677 vty_out (vty
, " any");
2680 struct prefix
*p
= &pentry
->prefix
;
2683 vty_out (vty
, " %s/%d",
2684 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2688 vty_out (vty
, " ge %d", pentry
->ge
);
2690 vty_out (vty
, " le %d", pentry
->le
);
2692 vty_out (vty
, "%s", VTY_NEWLINE
);
2701 prefix_bgp_orf_entry (struct stream
*s
, struct prefix_list
*plist
,
2702 u_char init_flag
, u_char permit_flag
, u_char deny_flag
)
2704 struct prefix_list_entry
*pentry
;
2709 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2711 u_char flag
= init_flag
;
2712 struct prefix
*p
= &pentry
->prefix
;
2714 flag
|= (pentry
->type
== PREFIX_PERMIT
?
2715 permit_flag
: deny_flag
);
2716 stream_putc (s
, flag
);
2717 stream_putl (s
, (u_int32_t
)pentry
->seq
);
2718 stream_putc (s
, (u_char
)pentry
->ge
);
2719 stream_putc (s
, (u_char
)pentry
->le
);
2720 stream_put_prefix (s
, p
);
2727 prefix_bgp_orf_set (char *name
, afi_t afi
, struct orf_prefix
*orfp
,
2728 int permit
, int set
)
2730 struct prefix_list
*plist
;
2731 struct prefix_list_entry
*pentry
;
2733 /* ge and le value check */
2734 if (orfp
->ge
&& orfp
->ge
<= orfp
->p
.prefixlen
)
2736 if (orfp
->le
&& orfp
->le
<= orfp
->p
.prefixlen
)
2738 if (orfp
->le
&& orfp
->ge
> orfp
->le
)
2741 if (orfp
->ge
&& orfp
->le
== (afi
== AFI_IP
? 32 : 128))
2744 plist
= prefix_list_get (afi
, 1, name
);
2750 pentry
= prefix_list_entry_make (&orfp
->p
,
2751 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2752 orfp
->seq
, orfp
->le
, orfp
->ge
, 0);
2754 if (prefix_entry_dup_check (plist
, pentry
))
2756 prefix_list_entry_free (pentry
);
2760 prefix_list_entry_add (plist
, pentry
);
2764 pentry
= prefix_list_entry_lookup (plist
, &orfp
->p
,
2765 (permit
? PREFIX_PERMIT
: PREFIX_DENY
),
2766 orfp
->seq
, orfp
->le
, orfp
->ge
);
2771 prefix_list_entry_delete (plist
, pentry
, 1);
2778 prefix_bgp_orf_remove_all (afi_t afi
, char *name
)
2780 struct prefix_list
*plist
;
2782 plist
= prefix_bgp_orf_lookup (afi
, name
);
2784 prefix_list_delete (plist
);
2787 /* return prefix count */
2789 prefix_bgp_show_prefix_list (struct vty
*vty
, afi_t afi
, char *name
, u_char use_json
)
2791 struct prefix_list
*plist
;
2792 struct prefix_list_entry
*pentry
;
2793 json_object
*json
= NULL
;
2794 json_object
*json_prefix
= NULL
;
2795 json_object
*json_list
= NULL
;
2797 plist
= prefix_bgp_orf_lookup (afi
, name
);
2802 return plist
->count
;
2806 json
= json_object_new_object();
2807 json_prefix
= json_object_new_object();
2808 json_list
= json_object_new_object();
2810 json_object_int_add(json_prefix
, "prefixListCounter", plist
->count
);
2811 json_object_string_add(json_prefix
, "prefixListName", plist
->name
);
2813 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2815 struct prefix
*p
= &pentry
->prefix
;
2819 sprintf(buf_a
, "%s/%d", inet_ntop (p
->family
, &p
->u
.prefix
, buf_b
, BUFSIZ
),
2822 json_object_int_add(json_list
, "seq", pentry
->seq
);
2823 json_object_string_add(json_list
, "seqPrefixListType", prefix_list_type_str (pentry
));
2826 json_object_int_add(json_list
, "ge", pentry
->ge
);
2828 json_object_int_add(json_list
, "le", pentry
->le
);
2830 json_object_object_add(json_prefix
, buf_a
, json_list
);
2833 json_object_object_add(json
, "ipPrefixList", json_prefix
);
2835 json_object_object_add(json
, "ipv6PrefixList", json_prefix
);
2837 vty_out (vty
, "%s%s", json_object_to_json_string(json
), VTY_NEWLINE
);
2838 json_object_free(json
);
2842 vty_out (vty
, "ip%s prefix-list %s: %d entries%s",
2843 afi
== AFI_IP
? "" : "v6",
2844 plist
->name
, plist
->count
, VTY_NEWLINE
);
2846 for (pentry
= plist
->head
; pentry
; pentry
= pentry
->next
)
2848 struct prefix
*p
= &pentry
->prefix
;
2851 vty_out (vty
, " seq %u %s %s/%d", pentry
->seq
,
2852 prefix_list_type_str (pentry
),
2853 inet_ntop (p
->family
, &p
->u
.prefix
, buf
, BUFSIZ
),
2857 vty_out (vty
, " ge %d", pentry
->ge
);
2859 vty_out (vty
, " le %d", pentry
->le
);
2861 vty_out (vty
, "%s", VTY_NEWLINE
);
2864 return plist
->count
;
2868 prefix_list_reset_afi (afi_t afi
, int orf
)
2870 struct prefix_list
*plist
;
2871 struct prefix_list
*next
;
2872 struct prefix_master
*master
;
2874 master
= prefix_master_get (afi
, orf
);
2878 for (plist
= master
->num
.head
; plist
; plist
= next
)
2881 prefix_list_delete (plist
);
2883 for (plist
= master
->str
.head
; plist
; plist
= next
)
2886 prefix_list_delete (plist
);
2889 assert (master
->num
.head
== NULL
);
2890 assert (master
->num
.tail
== NULL
);
2892 assert (master
->str
.head
== NULL
);
2893 assert (master
->str
.tail
== NULL
);
2896 master
->recent
= NULL
;
2900 /* Prefix-list node. */
2901 static struct cmd_node prefix_node
=
2904 "", /* Prefix list has no interface. */
2909 config_write_prefix_ipv4 (struct vty
*vty
)
2911 return config_write_prefix_afi (AFI_IP
, vty
);
2915 prefix_list_init_ipv4 (void)
2917 install_node (&prefix_node
, config_write_prefix_ipv4
);
2919 install_element (CONFIG_NODE
, &ip_prefix_list_cmd
);
2920 install_element (CONFIG_NODE
, &ip_prefix_list_ge_cmd
);
2921 install_element (CONFIG_NODE
, &ip_prefix_list_ge_le_cmd
);
2922 install_element (CONFIG_NODE
, &ip_prefix_list_le_cmd
);
2923 install_element (CONFIG_NODE
, &ip_prefix_list_le_ge_cmd
);
2924 install_element (CONFIG_NODE
, &ip_prefix_list_seq_cmd
);
2925 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_cmd
);
2926 install_element (CONFIG_NODE
, &ip_prefix_list_seq_ge_le_cmd
);
2927 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_cmd
);
2928 install_element (CONFIG_NODE
, &ip_prefix_list_seq_le_ge_cmd
);
2930 install_element (CONFIG_NODE
, &no_ip_prefix_list_cmd
);
2931 install_element (CONFIG_NODE
, &no_ip_prefix_list_prefix_cmd
);
2932 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_cmd
);
2933 install_element (CONFIG_NODE
, &no_ip_prefix_list_ge_le_cmd
);
2934 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_cmd
);
2935 install_element (CONFIG_NODE
, &no_ip_prefix_list_le_ge_cmd
);
2936 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_cmd
);
2937 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_cmd
);
2938 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_ge_le_cmd
);
2939 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_cmd
);
2940 install_element (CONFIG_NODE
, &no_ip_prefix_list_seq_le_ge_cmd
);
2942 install_element (CONFIG_NODE
, &ip_prefix_list_description_cmd
);
2943 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_cmd
);
2944 install_element (CONFIG_NODE
, &no_ip_prefix_list_description_arg_cmd
);
2946 install_element (CONFIG_NODE
, &ip_prefix_list_sequence_number_cmd
);
2947 install_element (CONFIG_NODE
, &no_ip_prefix_list_sequence_number_cmd
);
2949 install_element (VIEW_NODE
, &show_ip_prefix_list_cmd
);
2950 install_element (VIEW_NODE
, &show_ip_prefix_list_name_cmd
);
2951 install_element (VIEW_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2952 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_cmd
);
2953 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2954 install_element (VIEW_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2955 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_cmd
);
2956 install_element (VIEW_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2957 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_cmd
);
2958 install_element (VIEW_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2960 install_element (ENABLE_NODE
, &show_ip_prefix_list_cmd
);
2961 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_cmd
);
2962 install_element (ENABLE_NODE
, &show_ip_prefix_list_name_seq_cmd
);
2963 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_cmd
);
2964 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_longer_cmd
);
2965 install_element (ENABLE_NODE
, &show_ip_prefix_list_prefix_first_match_cmd
);
2966 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_cmd
);
2967 install_element (ENABLE_NODE
, &show_ip_prefix_list_summary_name_cmd
);
2968 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_cmd
);
2969 install_element (ENABLE_NODE
, &show_ip_prefix_list_detail_name_cmd
);
2971 install_element (ENABLE_NODE
, &clear_ip_prefix_list_cmd
);
2972 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_cmd
);
2973 install_element (ENABLE_NODE
, &clear_ip_prefix_list_name_prefix_cmd
);
2977 /* Prefix-list node. */
2978 static struct cmd_node prefix_ipv6_node
=
2981 "", /* Prefix list has no interface. */
2986 config_write_prefix_ipv6 (struct vty
*vty
)
2988 return config_write_prefix_afi (AFI_IP6
, vty
);
2992 prefix_list_init_ipv6 (void)
2994 install_node (&prefix_ipv6_node
, config_write_prefix_ipv6
);
2996 install_element (CONFIG_NODE
, &ipv6_prefix_list_cmd
);
2997 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_cmd
);
2998 install_element (CONFIG_NODE
, &ipv6_prefix_list_ge_le_cmd
);
2999 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_cmd
);
3000 install_element (CONFIG_NODE
, &ipv6_prefix_list_le_ge_cmd
);
3001 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_cmd
);
3002 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_cmd
);
3003 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_ge_le_cmd
);
3004 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_cmd
);
3005 install_element (CONFIG_NODE
, &ipv6_prefix_list_seq_le_ge_cmd
);
3007 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_cmd
);
3008 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_prefix_cmd
);
3009 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_cmd
);
3010 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_ge_le_cmd
);
3011 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_cmd
);
3012 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_le_ge_cmd
);
3013 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_cmd
);
3014 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_cmd
);
3015 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_ge_le_cmd
);
3016 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_cmd
);
3017 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_seq_le_ge_cmd
);
3019 install_element (CONFIG_NODE
, &ipv6_prefix_list_description_cmd
);
3020 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_cmd
);
3021 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_description_arg_cmd
);
3023 install_element (CONFIG_NODE
, &ipv6_prefix_list_sequence_number_cmd
);
3024 install_element (CONFIG_NODE
, &no_ipv6_prefix_list_sequence_number_cmd
);
3026 install_element (VIEW_NODE
, &show_ipv6_prefix_list_cmd
);
3027 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_cmd
);
3028 install_element (VIEW_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
3029 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
3030 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
3031 install_element (VIEW_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
3032 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_cmd
);
3033 install_element (VIEW_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
3034 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_cmd
);
3035 install_element (VIEW_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
3037 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_cmd
);
3038 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_cmd
);
3039 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_name_seq_cmd
);
3040 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_cmd
);
3041 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_longer_cmd
);
3042 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_prefix_first_match_cmd
);
3043 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_cmd
);
3044 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_summary_name_cmd
);
3045 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_cmd
);
3046 install_element (ENABLE_NODE
, &show_ipv6_prefix_list_detail_name_cmd
);
3048 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_cmd
);
3049 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_cmd
);
3050 install_element (ENABLE_NODE
, &clear_ipv6_prefix_list_name_prefix_cmd
);
3052 #endif /* HAVE_IPV6 */
3057 prefix_list_init_ipv4 ();
3059 prefix_list_init_ipv6 ();
3060 #endif /* HAVE_IPV6 */
3064 prefix_list_reset ()
3066 prefix_list_reset_afi (AFI_IP
, 0);
3067 prefix_list_reset_afi (AFI_IP6
, 0);
3068 prefix_list_reset_afi (AFI_IP
, 1);
3069 prefix_list_reset_afi (AFI_IP6
, 1);