]> git.proxmox.com Git - mirror_frr.git/blob - lib/plist.c
3714969696ce7d294b90ba99125ab5e4eb37561a
[mirror_frr.git] / lib / plist.c
1 /* Prefix list functions.
2 * Copyright (C) 1999 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
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.
10 *
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.
15 *
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.
20 */
21
22 #include <zebra.h>
23
24 #include "prefix.h"
25 #include "command.h"
26 #include "memory.h"
27 #include "plist.h"
28 #include "sockunion.h"
29 #include "buffer.h"
30 #include "log.h"
31 #include "routemap.h"
32 #include "lib/json.h"
33
34 #include "plist_int.h"
35
36 DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List")
37 DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str")
38 DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry")
39 DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table")
40
41 /* not currently changeable, code assumes bytes further down */
42 #define PLC_BITS 8
43 #define PLC_LEN (1 << PLC_BITS)
44 #define PLC_MAXLEVELV4 2 /* /24 for IPv4 */
45 #define PLC_MAXLEVELV6 4 /* /48 for IPv6 */
46 #define PLC_MAXLEVEL 4 /* max(v4,v6) */
47
48 struct pltrie_entry {
49 union {
50 struct pltrie_table *next_table;
51 struct prefix_list_entry *final_chain;
52 };
53
54 struct prefix_list_entry *up_chain;
55 };
56
57 struct pltrie_table {
58 struct pltrie_entry entries[PLC_LEN];
59 };
60
61 /* List of struct prefix_list. */
62 struct prefix_list_list
63 {
64 struct prefix_list *head;
65 struct prefix_list *tail;
66 };
67
68 /* Master structure of prefix_list. */
69 struct prefix_master
70 {
71 /* List of prefix_list which name is number. */
72 struct prefix_list_list num;
73
74 /* List of prefix_list which name is string. */
75 struct prefix_list_list str;
76
77 /* Whether sequential number is used. */
78 int seqnum;
79
80 /* The latest update. */
81 struct prefix_list *recent;
82
83 /* Hook function which is executed when new prefix_list is added. */
84 void (*add_hook) (struct prefix_list *);
85
86 /* Hook function which is executed when prefix_list is deleted. */
87 void (*delete_hook) (struct prefix_list *);
88
89 /* number of bytes that have a trie level */
90 size_t trie_depth;
91 };
92
93 /* Static structure of IPv4 prefix_list's master. */
94 static struct prefix_master prefix_master_ipv4 =
95 {
96 {NULL, NULL},
97 {NULL, NULL},
98 1,
99 NULL,
100 NULL,
101 NULL,
102 PLC_MAXLEVELV4,
103 };
104
105 /* Static structure of IPv6 prefix-list's master. */
106 static struct prefix_master prefix_master_ipv6 =
107 {
108 {NULL, NULL},
109 {NULL, NULL},
110 1,
111 NULL,
112 NULL,
113 NULL,
114 PLC_MAXLEVELV6,
115 };
116
117 /* Static structure of BGP ORF prefix_list's master. */
118 static struct prefix_master prefix_master_orf_v4 =
119 {
120 {NULL, NULL},
121 {NULL, NULL},
122 1,
123 NULL,
124 NULL,
125 NULL,
126 PLC_MAXLEVELV4,
127 };
128
129 /* Static structure of BGP ORF prefix_list's master. */
130 static struct prefix_master prefix_master_orf_v6 =
131 {
132 {NULL, NULL},
133 {NULL, NULL},
134 1,
135 NULL,
136 NULL,
137 NULL,
138 PLC_MAXLEVELV6,
139 };
140
141 static struct prefix_master *
142 prefix_master_get (afi_t afi, int orf)
143 {
144 if (afi == AFI_IP)
145 return orf ? &prefix_master_orf_v4 : &prefix_master_ipv4;
146 if (afi == AFI_IP6)
147 return orf ? &prefix_master_orf_v6 : &prefix_master_ipv6;
148 return NULL;
149 }
150
151 const char *prefix_list_name (struct prefix_list *plist)
152 {
153 return plist->name;
154 }
155
156 /* Lookup prefix_list from list of prefix_list by name. */
157 static struct prefix_list *
158 prefix_list_lookup_do (afi_t afi, int orf, const char *name)
159 {
160 struct prefix_list *plist;
161 struct prefix_master *master;
162
163 if (name == NULL)
164 return NULL;
165
166 master = prefix_master_get (afi, orf);
167 if (master == NULL)
168 return NULL;
169
170 for (plist = master->num.head; plist; plist = plist->next)
171 if (strcmp (plist->name, name) == 0)
172 return plist;
173
174 for (plist = master->str.head; plist; plist = plist->next)
175 if (strcmp (plist->name, name) == 0)
176 return plist;
177
178 return NULL;
179 }
180
181 struct prefix_list *
182 prefix_list_lookup (afi_t afi, const char *name)
183 {
184 return prefix_list_lookup_do (afi, 0, name);
185 }
186
187 struct prefix_list *
188 prefix_bgp_orf_lookup (afi_t afi, const char *name)
189 {
190 return prefix_list_lookup_do (afi, 1, name);
191 }
192
193 static struct prefix_list *
194 prefix_list_new (void)
195 {
196 struct prefix_list *new;
197
198 new = XCALLOC (MTYPE_PREFIX_LIST, sizeof (struct prefix_list));
199 return new;
200 }
201
202 static void
203 prefix_list_free (struct prefix_list *plist)
204 {
205 XFREE (MTYPE_PREFIX_LIST, plist);
206 }
207
208 static struct prefix_list_entry *
209 prefix_list_entry_new (void)
210 {
211 struct prefix_list_entry *new;
212
213 new = XCALLOC (MTYPE_PREFIX_LIST_ENTRY, sizeof (struct prefix_list_entry));
214 return new;
215 }
216
217 static void
218 prefix_list_entry_free (struct prefix_list_entry *pentry)
219 {
220 XFREE (MTYPE_PREFIX_LIST_ENTRY, pentry);
221 }
222
223 /* Insert new prefix list to list of prefix_list. Each prefix_list
224 is sorted by the name. */
225 static struct prefix_list *
226 prefix_list_insert (afi_t afi, int orf, const char *name)
227 {
228 unsigned int i;
229 long number;
230 struct prefix_list *plist;
231 struct prefix_list *point;
232 struct prefix_list_list *list;
233 struct prefix_master *master;
234
235 master = prefix_master_get (afi, orf);
236 if (master == NULL)
237 return NULL;
238
239 /* Allocate new prefix_list and copy given name. */
240 plist = prefix_list_new ();
241 plist->name = XSTRDUP (MTYPE_MPREFIX_LIST_STR, name);
242 plist->master = master;
243 plist->trie = XCALLOC (MTYPE_PREFIX_LIST_TRIE, sizeof (struct pltrie_table));
244
245 /* If name is made by all digit character. We treat it as
246 number. */
247 for (number = 0, i = 0; i < strlen (name); i++)
248 {
249 if (isdigit ((int) name[i]))
250 number = (number * 10) + (name[i] - '0');
251 else
252 break;
253 }
254
255 /* In case of name is all digit character */
256 if (i == strlen (name))
257 {
258 plist->type = PREFIX_TYPE_NUMBER;
259
260 /* Set prefix_list to number list. */
261 list = &master->num;
262
263 for (point = list->head; point; point = point->next)
264 if (atol (point->name) >= number)
265 break;
266 }
267 else
268 {
269 plist->type = PREFIX_TYPE_STRING;
270
271 /* Set prefix_list to string list. */
272 list = &master->str;
273
274 /* Set point to insertion point. */
275 for (point = list->head; point; point = point->next)
276 if (strcmp (point->name, name) >= 0)
277 break;
278 }
279
280 /* In case of this is the first element of master. */
281 if (list->head == NULL)
282 {
283 list->head = list->tail = plist;
284 return plist;
285 }
286
287 /* In case of insertion is made at the tail of access_list. */
288 if (point == NULL)
289 {
290 plist->prev = list->tail;
291 list->tail->next = plist;
292 list->tail = plist;
293 return plist;
294 }
295
296 /* In case of insertion is made at the head of access_list. */
297 if (point == list->head)
298 {
299 plist->next = list->head;
300 list->head->prev = plist;
301 list->head = plist;
302 return plist;
303 }
304
305 /* Insertion is made at middle of the access_list. */
306 plist->next = point;
307 plist->prev = point->prev;
308
309 if (point->prev)
310 point->prev->next = plist;
311 point->prev = plist;
312
313 return plist;
314 }
315
316 static struct prefix_list *
317 prefix_list_get (afi_t afi, int orf, const char *name)
318 {
319 struct prefix_list *plist;
320
321 plist = prefix_list_lookup_do (afi, orf, name);
322
323 if (plist == NULL)
324 plist = prefix_list_insert (afi, orf, name);
325 return plist;
326 }
327
328 static void prefix_list_trie_del (struct prefix_list *plist,
329 struct prefix_list_entry *pentry);
330
331 /* Delete prefix-list from prefix_list_master and free it. */
332 static void
333 prefix_list_delete (struct prefix_list *plist)
334 {
335 struct prefix_list_list *list;
336 struct prefix_master *master;
337 struct prefix_list_entry *pentry;
338 struct prefix_list_entry *next;
339
340 /* If prefix-list contain prefix_list_entry free all of it. */
341 for (pentry = plist->head; pentry; pentry = next)
342 {
343 next = pentry->next;
344 prefix_list_trie_del (plist, pentry);
345 prefix_list_entry_free (pentry);
346 plist->count--;
347 }
348
349 master = plist->master;
350
351 if (plist->type == PREFIX_TYPE_NUMBER)
352 list = &master->num;
353 else
354 list = &master->str;
355
356 if (plist->next)
357 plist->next->prev = plist->prev;
358 else
359 list->tail = plist->prev;
360
361 if (plist->prev)
362 plist->prev->next = plist->next;
363 else
364 list->head = plist->next;
365
366 if (plist->desc)
367 XFREE (MTYPE_TMP, plist->desc);
368
369 /* Make sure master's recent changed prefix-list information is
370 cleared. */
371 master->recent = NULL;
372
373 route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_DELETED);
374
375 if (master->delete_hook)
376 (*master->delete_hook) (plist);
377
378 if (plist->name)
379 XFREE (MTYPE_MPREFIX_LIST_STR, plist->name);
380
381 XFREE (MTYPE_PREFIX_LIST_TRIE, plist->trie);
382
383 prefix_list_free (plist);
384
385 }
386
387 static struct prefix_list_entry *
388 prefix_list_entry_make (struct prefix *prefix, enum prefix_list_type type,
389 int seq, int le, int ge, int any)
390 {
391 struct prefix_list_entry *pentry;
392
393 pentry = prefix_list_entry_new ();
394
395 if (any)
396 pentry->any = 1;
397
398 prefix_copy (&pentry->prefix, prefix);
399 pentry->type = type;
400 pentry->seq = seq;
401 pentry->le = le;
402 pentry->ge = ge;
403
404 return pentry;
405 }
406
407 /* Add hook function. */
408 void
409 prefix_list_add_hook (void (*func) (struct prefix_list *plist))
410 {
411 prefix_master_ipv4.add_hook = func;
412 prefix_master_ipv6.add_hook = func;
413 }
414
415 /* Delete hook function. */
416 void
417 prefix_list_delete_hook (void (*func) (struct prefix_list *plist))
418 {
419 prefix_master_ipv4.delete_hook = func;
420 prefix_master_ipv6.delete_hook = func;
421 }
422
423 /* Calculate new sequential number. */
424 static int
425 prefix_new_seq_get (struct prefix_list *plist)
426 {
427 int maxseq;
428 int newseq;
429 struct prefix_list_entry *pentry;
430
431 maxseq = newseq = 0;
432
433 for (pentry = plist->head; pentry; pentry = pentry->next)
434 {
435 if (maxseq < pentry->seq)
436 maxseq = pentry->seq;
437 }
438
439 newseq = ((maxseq / 5) * 5) + 5;
440
441 return newseq;
442 }
443
444 /* Return prefix list entry which has same seq number. */
445 static struct prefix_list_entry *
446 prefix_seq_check (struct prefix_list *plist, int seq)
447 {
448 struct prefix_list_entry *pentry;
449
450 for (pentry = plist->head; pentry; pentry = pentry->next)
451 if (pentry->seq == seq)
452 return pentry;
453 return NULL;
454 }
455
456 static struct prefix_list_entry *
457 prefix_list_entry_lookup (struct prefix_list *plist, struct prefix *prefix,
458 enum prefix_list_type type, int seq, int le, int ge)
459 {
460 struct prefix_list_entry *pentry;
461
462 for (pentry = plist->head; pentry; pentry = pentry->next)
463 if (prefix_same (&pentry->prefix, prefix) && pentry->type == type)
464 {
465 if (seq >= 0 && pentry->seq != seq)
466 continue;
467
468 if (pentry->le != le)
469 continue;
470 if (pentry->ge != ge)
471 continue;
472
473 return pentry;
474 }
475
476 return NULL;
477 }
478
479 static void
480 trie_walk_affected (size_t validbits, struct pltrie_table *table, uint8_t byte,
481 struct prefix_list_entry *object,
482 void (*fn)(struct prefix_list_entry *object,
483 struct prefix_list_entry **updptr))
484 {
485 uint8_t mask;
486 uint16_t bwalk;
487
488 if (validbits > PLC_BITS)
489 {
490 fn (object, &table->entries[byte].final_chain);
491 return;
492 }
493
494 mask = (1 << (8 - validbits)) - 1;
495 for (bwalk = byte & ~mask; bwalk <= byte + mask; bwalk++)
496 {
497 fn (object, &table->entries[bwalk].up_chain);
498 }
499 }
500
501 static void trie_uninstall_fn (struct prefix_list_entry *object,
502 struct prefix_list_entry **updptr)
503 {
504 for (; *updptr; updptr = &(*updptr)->next_best)
505 if (*updptr == object)
506 {
507 *updptr = object->next_best;
508 break;
509 }
510 }
511
512 static int
513 trie_table_empty (struct pltrie_table *table)
514 {
515 size_t i;
516 for (i = 0; i < PLC_LEN; i++)
517 if (table->entries[i].next_table || table->entries[i].up_chain)
518 return 0;
519 return 1;
520 }
521
522 static void
523 prefix_list_trie_del (struct prefix_list *plist,
524 struct prefix_list_entry *pentry)
525 {
526 size_t depth, maxdepth = plist->master->trie_depth;
527 uint8_t *bytes = &pentry->prefix.u.prefix;
528 size_t validbits = pentry->prefix.prefixlen;
529 struct pltrie_table *table, **tables[PLC_MAXLEVEL];
530
531 table = plist->trie;
532 for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++)
533 {
534 uint8_t byte = bytes[depth];
535 assert (table->entries[byte].next_table);
536
537 tables[depth + 1] = &table->entries[byte].next_table;
538 table = table->entries[byte].next_table;
539
540 validbits -= PLC_BITS;
541 }
542
543 trie_walk_affected (validbits, table, bytes[depth], pentry, trie_uninstall_fn);
544
545 for (; depth > 0; depth--)
546 if (trie_table_empty (*tables[depth]))
547 {
548 XFREE (MTYPE_PREFIX_LIST_TRIE, *tables[depth]);
549 *tables[depth] = NULL;
550 }
551 }
552
553
554 static void
555 prefix_list_entry_delete (struct prefix_list *plist,
556 struct prefix_list_entry *pentry,
557 int update_list)
558 {
559 if (plist == NULL || pentry == NULL)
560 return;
561
562 prefix_list_trie_del (plist, pentry);
563
564 if (pentry->prev)
565 pentry->prev->next = pentry->next;
566 else
567 plist->head = pentry->next;
568 if (pentry->next)
569 pentry->next->prev = pentry->prev;
570 else
571 plist->tail = pentry->prev;
572
573 prefix_list_entry_free (pentry);
574
575 plist->count--;
576
577 if (update_list)
578 {
579 route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_DELETED);
580 if (plist->master->delete_hook)
581 (*plist->master->delete_hook) (plist);
582
583 if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL)
584 prefix_list_delete (plist);
585 else
586 plist->master->recent = plist;
587 }
588 }
589
590 static void trie_install_fn (struct prefix_list_entry *object,
591 struct prefix_list_entry **updptr)
592 {
593 while (*updptr)
594 {
595 if (*updptr == object)
596 return;
597 if ((*updptr)->prefix.prefixlen < object->prefix.prefixlen)
598 break;
599 if ((*updptr)->seq > object->seq)
600 break;
601 updptr = &(*updptr)->next_best;
602 }
603
604 if (!object->next_best)
605 object->next_best = *updptr;
606 else
607 assert (object->next_best == *updptr || !*updptr);
608
609 *updptr = object;
610 }
611
612 static void
613 prefix_list_trie_add (struct prefix_list *plist,
614 struct prefix_list_entry *pentry)
615 {
616 size_t depth = plist->master->trie_depth;
617 uint8_t *bytes = &pentry->prefix.u.prefix;
618 size_t validbits = pentry->prefix.prefixlen;
619 struct pltrie_table *table;
620
621 table = plist->trie;
622 while (validbits > PLC_BITS && depth > 1)
623 {
624 if (!table->entries[*bytes].next_table)
625 table->entries[*bytes].next_table = XCALLOC (MTYPE_PREFIX_LIST_TRIE,
626 sizeof(struct pltrie_table));
627 table = table->entries[*bytes].next_table;
628 bytes++;
629 depth--;
630 validbits -= PLC_BITS;
631 }
632
633 trie_walk_affected (validbits, table, *bytes, pentry, trie_install_fn);
634 }
635
636 static void
637 prefix_list_entry_add (struct prefix_list *plist,
638 struct prefix_list_entry *pentry)
639 {
640 struct prefix_list_entry *replace;
641 struct prefix_list_entry *point;
642
643 /* Automatic asignment of seq no. */
644 if (pentry->seq == -1)
645 pentry->seq = prefix_new_seq_get (plist);
646
647 if (plist->tail && pentry->seq > plist->tail->seq)
648 point = NULL;
649 else
650 {
651 /* Is there any same seq prefix list entry? */
652 replace = prefix_seq_check (plist, pentry->seq);
653 if (replace)
654 prefix_list_entry_delete (plist, replace, 0);
655
656 /* Check insert point. */
657 for (point = plist->head; point; point = point->next)
658 if (point->seq >= pentry->seq)
659 break;
660 }
661
662 /* In case of this is the first element of the list. */
663 pentry->next = point;
664
665 if (point)
666 {
667 if (point->prev)
668 point->prev->next = pentry;
669 else
670 plist->head = pentry;
671
672 pentry->prev = point->prev;
673 point->prev = pentry;
674 }
675 else
676 {
677 if (plist->tail)
678 plist->tail->next = pentry;
679 else
680 plist->head = pentry;
681
682 pentry->prev = plist->tail;
683 plist->tail = pentry;
684 }
685
686 prefix_list_trie_add (plist, pentry);
687
688 /* Increment count. */
689 plist->count++;
690
691 /* Run hook function. */
692 if (plist->master->add_hook)
693 (*plist->master->add_hook) (plist);
694
695 route_map_notify_dependencies(plist->name, RMAP_EVENT_PLIST_ADDED);
696 plist->master->recent = plist;
697 }
698
699 /* Return string of prefix_list_type. */
700 static const char *
701 prefix_list_type_str (struct prefix_list_entry *pentry)
702 {
703 switch (pentry->type)
704 {
705 case PREFIX_PERMIT:
706 return "permit";
707 case PREFIX_DENY:
708 return "deny";
709 default:
710 return "";
711 }
712 }
713
714 static int
715 prefix_list_entry_match (struct prefix_list_entry *pentry, struct prefix *p)
716 {
717 int ret;
718
719 ret = prefix_match (&pentry->prefix, p);
720 if (! ret)
721 return 0;
722
723 /* In case of le nor ge is specified, exact match is performed. */
724 if (! pentry->le && ! pentry->ge)
725 {
726 if (pentry->prefix.prefixlen != p->prefixlen)
727 return 0;
728 }
729 else
730 {
731 if (pentry->le)
732 if (p->prefixlen > pentry->le)
733 return 0;
734
735 if (pentry->ge)
736 if (p->prefixlen < pentry->ge)
737 return 0;
738 }
739 return 1;
740 }
741
742 enum prefix_list_type
743 prefix_list_apply (struct prefix_list *plist, void *object)
744 {
745 struct prefix_list_entry *pentry, *pbest = NULL;
746
747 struct prefix *p = (struct prefix *) object;
748 uint8_t *byte = &p->u.prefix;
749 size_t depth;
750 size_t validbits = p->prefixlen;
751 struct pltrie_table *table;
752
753 if (plist == NULL)
754 return PREFIX_DENY;
755
756 if (plist->count == 0)
757 return PREFIX_PERMIT;
758
759 depth = plist->master->trie_depth;
760 table = plist->trie;
761 while (1)
762 {
763 for (pentry = table->entries[*byte].up_chain; pentry; pentry = pentry->next_best)
764 {
765 if (pbest && pbest->seq < pentry->seq)
766 continue;
767 if (prefix_list_entry_match (pentry, p))
768 pbest = pentry;
769 }
770
771 if (validbits <= PLC_BITS)
772 break;
773 validbits -= PLC_BITS;
774
775 if (--depth)
776 {
777 if (!table->entries[*byte].next_table)
778 break;
779
780 table = table->entries[*byte].next_table;
781 byte++;
782 continue;
783 }
784
785 for (pentry = table->entries[*byte].final_chain; pentry; pentry = pentry->next_best)
786 {
787 if (pbest && pbest->seq < pentry->seq)
788 continue;
789 if (prefix_list_entry_match (pentry, p))
790 pbest = pentry;
791 }
792 break;
793 }
794
795 if (pbest == NULL)
796 return PREFIX_DENY;
797
798 return pbest->type;
799 }
800
801 static void __attribute__ ((unused))
802 prefix_list_print (struct prefix_list *plist)
803 {
804 struct prefix_list_entry *pentry;
805
806 if (plist == NULL)
807 return;
808
809 printf ("ip prefix-list %s: %d entries\n", plist->name, plist->count);
810
811 for (pentry = plist->head; pentry; pentry = pentry->next)
812 {
813 if (pentry->any)
814 printf ("any %s\n", prefix_list_type_str (pentry));
815 else
816 {
817 struct prefix *p;
818 char buf[BUFSIZ];
819
820 p = &pentry->prefix;
821
822 printf (" seq %u %s %s/%d",
823 pentry->seq,
824 prefix_list_type_str (pentry),
825 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
826 p->prefixlen);
827 if (pentry->ge)
828 printf (" ge %d", pentry->ge);
829 if (pentry->le)
830 printf (" le %d", pentry->le);
831 printf ("\n");
832 }
833 }
834 }
835
836 /* Retrun 1 when plist already include pentry policy. */
837 static struct prefix_list_entry *
838 prefix_entry_dup_check (struct prefix_list *plist,
839 struct prefix_list_entry *new)
840 {
841 size_t depth, maxdepth = plist->master->trie_depth;
842 uint8_t byte, *bytes = &new->prefix.u.prefix;
843 size_t validbits = new->prefix.prefixlen;
844 struct pltrie_table *table;
845 struct prefix_list_entry *pentry;
846 int seq = 0;
847
848 if (new->seq == -1)
849 seq = prefix_new_seq_get (plist);
850 else
851 seq = new->seq;
852
853 table = plist->trie;
854 for (depth = 0; validbits > PLC_BITS && depth < maxdepth - 1; depth++)
855 {
856 byte = bytes[depth];
857 if (!table->entries[byte].next_table)
858 return NULL;
859
860 table = table->entries[byte].next_table;
861 validbits -= PLC_BITS;
862 }
863
864 byte = bytes[depth];
865 if (validbits > PLC_BITS)
866 pentry = table->entries[byte].final_chain;
867 else
868 pentry = table->entries[byte].up_chain;
869
870 for (; pentry; pentry = pentry->next_best)
871 {
872 if (prefix_same (&pentry->prefix, &new->prefix)
873 && pentry->type == new->type
874 && pentry->le == new->le
875 && pentry->ge == new->ge
876 && pentry->seq != seq)
877 return pentry;
878 }
879 return NULL;
880 }
881
882 static int
883 vty_invalid_prefix_range (struct vty *vty, const char *prefix)
884 {
885 vty_out (vty, "%% Invalid prefix range for %s, make sure: len < ge-value <= le-value%s",
886 prefix, VTY_NEWLINE);
887 return CMD_WARNING;
888 }
889
890 static int
891 vty_prefix_list_install (struct vty *vty, afi_t afi, const char *name,
892 const char *seq, const char *typestr,
893 const char *prefix, const char *ge, const char *le)
894 {
895 int ret;
896 enum prefix_list_type type;
897 struct prefix_list *plist;
898 struct prefix_list_entry *pentry;
899 struct prefix_list_entry *dup;
900 struct prefix p, p_tmp;
901 int any = 0;
902 int seqnum = -1;
903 int lenum = 0;
904 int genum = 0;
905
906 /* Sequential number. */
907 if (seq)
908 seqnum = atoi (seq);
909
910 /* ge and le number */
911 if (ge)
912 genum = atoi (ge);
913 if (le)
914 lenum = atoi (le);
915
916 /* Check filter type. */
917 if (strncmp ("permit", typestr, 1) == 0)
918 type = PREFIX_PERMIT;
919 else if (strncmp ("deny", typestr, 1) == 0)
920 type = PREFIX_DENY;
921 else
922 {
923 vty_out (vty, "%% prefix type must be permit or deny%s", VTY_NEWLINE);
924 return CMD_WARNING;
925 }
926
927 /* "any" is special token for matching any IPv4 addresses. */
928 switch (afi)
929 {
930 case AFI_IP:
931 if (strncmp ("any", prefix, strlen (prefix)) == 0)
932 {
933 ret = str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4 *) &p);
934 genum = 0;
935 lenum = IPV4_MAX_BITLEN;
936 any = 1;
937 }
938 else
939 ret = str2prefix_ipv4 (prefix, (struct prefix_ipv4 *) &p);
940
941 if (ret <= 0)
942 {
943 vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE);
944 return CMD_WARNING;
945 }
946
947 /* make a copy to verify prefix matches mask length */
948 prefix_copy (&p_tmp, &p);
949 apply_mask_ipv4 ((struct prefix_ipv4 *) &p_tmp);
950
951 break;
952 case AFI_IP6:
953 if (strncmp ("any", prefix, strlen (prefix)) == 0)
954 {
955 ret = str2prefix_ipv6 ("::/0", (struct prefix_ipv6 *) &p);
956 genum = 0;
957 lenum = IPV6_MAX_BITLEN;
958 any = 1;
959 }
960 else
961 ret = str2prefix_ipv6 (prefix, (struct prefix_ipv6 *) &p);
962
963 if (ret <= 0)
964 {
965 vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE);
966 return CMD_WARNING;
967 }
968
969 /* make a copy to verify prefix matches mask length */
970 prefix_copy (&p_tmp, &p);
971 apply_mask_ipv6 ((struct prefix_ipv6 *) &p_tmp);
972
973 break;
974 case AFI_L2VPN:
975 default:
976 vty_out (vty, "%% Unrecognized AFI (%d)%s", afi, VTY_NEWLINE);
977 return CMD_WARNING;
978 break;
979 }
980
981 /* If prefix has bits not under the mask, adjust it to fit */
982 if (!prefix_same (&p_tmp, &p))
983 {
984 char buf[PREFIX2STR_BUFFER];
985 char buf_tmp[PREFIX2STR_BUFFER];
986 prefix2str(&p, buf, sizeof(buf));
987 prefix2str(&p_tmp, buf_tmp, sizeof(buf_tmp));
988 zlog_warn ("Prefix-list %s prefix changed from %s to %s to match length",
989 name, buf, buf_tmp);
990 p = p_tmp;
991 }
992
993 /* ge and le check. */
994 if (genum && (genum <= p.prefixlen))
995 return vty_invalid_prefix_range (vty, prefix);
996
997 if (lenum && (lenum <= p.prefixlen))
998 return vty_invalid_prefix_range (vty, prefix);
999
1000 if (lenum && (genum > lenum))
1001 return vty_invalid_prefix_range (vty, prefix);
1002
1003 if (genum && (lenum == (afi == AFI_IP ? 32 : 128)))
1004 lenum = 0;
1005
1006 /* Get prefix_list with name. */
1007 plist = prefix_list_get (afi, 0, name);
1008
1009 /* Make prefix entry. */
1010 pentry = prefix_list_entry_make (&p, type, seqnum, lenum, genum, any);
1011
1012 /* Check same policy. */
1013 dup = prefix_entry_dup_check (plist, pentry);
1014
1015 if (dup)
1016 {
1017 prefix_list_entry_free (pentry);
1018 return CMD_SUCCESS;
1019 }
1020
1021 /* Install new filter to the access_list. */
1022 prefix_list_entry_add (plist, pentry);
1023
1024 return CMD_SUCCESS;
1025 }
1026
1027 static int
1028 vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name,
1029 const char *seq, const char *typestr,
1030 const char *prefix, const char *ge, const char *le)
1031 {
1032 int ret;
1033 enum prefix_list_type type;
1034 struct prefix_list *plist;
1035 struct prefix_list_entry *pentry;
1036 struct prefix p;
1037 int seqnum = -1;
1038 int lenum = 0;
1039 int genum = 0;
1040
1041 /* Check prefix list name. */
1042 plist = prefix_list_lookup (afi, name);
1043 if (! plist)
1044 {
1045 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1046 return CMD_WARNING;
1047 }
1048
1049 /* Only prefix-list name specified, delete the entire prefix-list. */
1050 if (seq == NULL && typestr == NULL && prefix == NULL &&
1051 ge == NULL && le == NULL)
1052 {
1053 prefix_list_delete (plist);
1054 return CMD_SUCCESS;
1055 }
1056
1057 /* We must have, at a minimum, both the type and prefix here */
1058 if ((typestr == NULL) || (prefix == NULL))
1059 {
1060 vty_out (vty, "%% Both prefix and type required%s", VTY_NEWLINE);
1061 return CMD_WARNING;
1062 }
1063
1064 /* Check sequence number. */
1065 if (seq)
1066 seqnum = atoi (seq);
1067
1068 /* ge and le number */
1069 if (ge)
1070 genum = atoi (ge);
1071 if (le)
1072 lenum = atoi (le);
1073
1074 /* Check of filter type. */
1075 if (strncmp ("permit", typestr, 1) == 0)
1076 type = PREFIX_PERMIT;
1077 else if (strncmp ("deny", typestr, 1) == 0)
1078 type = PREFIX_DENY;
1079 else
1080 {
1081 vty_out (vty, "%% prefix type must be permit or deny%s", VTY_NEWLINE);
1082 return CMD_WARNING;
1083 }
1084
1085 /* "any" is special token for matching any IPv4 addresses. */
1086 if (afi == AFI_IP)
1087 {
1088 if (strncmp ("any", prefix, strlen (prefix)) == 0)
1089 {
1090 ret = str2prefix_ipv4 ("0.0.0.0/0", (struct prefix_ipv4 *) &p);
1091 genum = 0;
1092 lenum = IPV4_MAX_BITLEN;
1093 }
1094 else
1095 ret = str2prefix_ipv4 (prefix, (struct prefix_ipv4 *) &p);
1096
1097 if (ret <= 0)
1098 {
1099 vty_out (vty, "%% Malformed IPv4 prefix%s", VTY_NEWLINE);
1100 return CMD_WARNING;
1101 }
1102 }
1103 else if (afi == AFI_IP6)
1104 {
1105 if (strncmp ("any", prefix, strlen (prefix)) == 0)
1106 {
1107 ret = str2prefix_ipv6 ("::/0", (struct prefix_ipv6 *) &p);
1108 genum = 0;
1109 lenum = IPV6_MAX_BITLEN;
1110 }
1111 else
1112 ret = str2prefix_ipv6 (prefix, (struct prefix_ipv6 *) &p);
1113
1114 if (ret <= 0)
1115 {
1116 vty_out (vty, "%% Malformed IPv6 prefix%s", VTY_NEWLINE);
1117 return CMD_WARNING;
1118 }
1119 }
1120
1121 /* Lookup prefix entry. */
1122 pentry = prefix_list_entry_lookup(plist, &p, type, seqnum, lenum, genum);
1123
1124 if (pentry == NULL)
1125 {
1126 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1127 return CMD_WARNING;
1128 }
1129
1130 /* Install new filter to the access_list. */
1131 prefix_list_entry_delete (plist, pentry, 1);
1132
1133 return CMD_SUCCESS;
1134 }
1135
1136 static int
1137 vty_prefix_list_desc_unset (struct vty *vty, afi_t afi, const char *name)
1138 {
1139 struct prefix_list *plist;
1140
1141 plist = prefix_list_lookup (afi, name);
1142 if (! plist)
1143 {
1144 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1145 return CMD_WARNING;
1146 }
1147
1148 if (plist->desc)
1149 {
1150 XFREE (MTYPE_TMP, plist->desc);
1151 plist->desc = NULL;
1152 }
1153
1154 if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL)
1155 prefix_list_delete (plist);
1156
1157 return CMD_SUCCESS;
1158 }
1159
1160 enum display_type
1161 {
1162 normal_display,
1163 summary_display,
1164 detail_display,
1165 sequential_display,
1166 longer_display,
1167 first_match_display
1168 };
1169
1170 static void
1171 vty_show_prefix_entry (struct vty *vty, afi_t afi, struct prefix_list *plist,
1172 struct prefix_master *master, enum display_type dtype,
1173 int seqnum)
1174 {
1175 struct prefix_list_entry *pentry;
1176
1177 /* Print the name of the protocol */
1178 vty_out(vty, "%s: ", zlog_protoname());
1179
1180 if (dtype == normal_display)
1181 {
1182 vty_out (vty, "ip%s prefix-list %s: %d entries%s",
1183 afi == AFI_IP ? "" : "v6",
1184 plist->name, plist->count, VTY_NEWLINE);
1185 if (plist->desc)
1186 vty_out (vty, " Description: %s%s", plist->desc, VTY_NEWLINE);
1187 }
1188 else if (dtype == summary_display || dtype == detail_display)
1189 {
1190 vty_out (vty, "ip%s prefix-list %s:%s",
1191 afi == AFI_IP ? "" : "v6", plist->name, VTY_NEWLINE);
1192
1193 if (plist->desc)
1194 vty_out (vty, " Description: %s%s", plist->desc, VTY_NEWLINE);
1195
1196 vty_out (vty, " count: %d, range entries: %d, sequences: %u - %u%s",
1197 plist->count, plist->rangecount,
1198 plist->head ? plist->head->seq : 0,
1199 plist->tail ? plist->tail->seq : 0,
1200 VTY_NEWLINE);
1201 }
1202
1203 if (dtype != summary_display)
1204 {
1205 for (pentry = plist->head; pentry; pentry = pentry->next)
1206 {
1207 if (dtype == sequential_display && pentry->seq != seqnum)
1208 continue;
1209
1210 vty_out (vty, " ");
1211
1212 if (master->seqnum)
1213 vty_out (vty, "seq %u ", pentry->seq);
1214
1215 vty_out (vty, "%s ", prefix_list_type_str (pentry));
1216
1217 if (pentry->any)
1218 vty_out (vty, "any");
1219 else
1220 {
1221 struct prefix *p = &pentry->prefix;
1222 char buf[BUFSIZ];
1223
1224 vty_out (vty, "%s/%d",
1225 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
1226 p->prefixlen);
1227
1228 if (pentry->ge)
1229 vty_out (vty, " ge %d", pentry->ge);
1230 if (pentry->le)
1231 vty_out (vty, " le %d", pentry->le);
1232 }
1233
1234 if (dtype == detail_display || dtype == sequential_display)
1235 vty_out (vty, " (hit count: %ld, refcount: %ld)",
1236 pentry->hitcnt, pentry->refcnt);
1237
1238 vty_out (vty, "%s", VTY_NEWLINE);
1239 }
1240 }
1241 }
1242
1243 static int
1244 vty_show_prefix_list (struct vty *vty, afi_t afi, const char *name,
1245 const char *seq, enum display_type dtype)
1246 {
1247 struct prefix_list *plist;
1248 struct prefix_master *master;
1249 int seqnum = 0;
1250
1251 master = prefix_master_get (afi, 0);
1252 if (master == NULL)
1253 return CMD_WARNING;
1254
1255 if (seq)
1256 seqnum = atoi (seq);
1257
1258 if (name)
1259 {
1260 plist = prefix_list_lookup (afi, name);
1261 if (! plist)
1262 {
1263 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1264 return CMD_WARNING;
1265 }
1266 vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);
1267 }
1268 else
1269 {
1270 if (dtype == detail_display || dtype == summary_display)
1271 {
1272 if (master->recent)
1273 vty_out (vty, "Prefix-list with the last deletion/insertion: %s%s",
1274 master->recent->name, VTY_NEWLINE);
1275 }
1276
1277 for (plist = master->num.head; plist; plist = plist->next)
1278 vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);
1279
1280 for (plist = master->str.head; plist; plist = plist->next)
1281 vty_show_prefix_entry (vty, afi, plist, master, dtype, seqnum);
1282 }
1283
1284 return CMD_SUCCESS;
1285 }
1286
1287 static int
1288 vty_show_prefix_list_prefix (struct vty *vty, afi_t afi, const char *name,
1289 const char *prefix, enum display_type type)
1290 {
1291 struct prefix_list *plist;
1292 struct prefix_list_entry *pentry;
1293 struct prefix p;
1294 int ret;
1295 int match;
1296
1297 plist = prefix_list_lookup (afi, name);
1298 if (! plist)
1299 {
1300 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1301 return CMD_WARNING;
1302 }
1303
1304 ret = str2prefix (prefix, &p);
1305 if (ret <= 0)
1306 {
1307 vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);
1308 return CMD_WARNING;
1309 }
1310
1311 for (pentry = plist->head; pentry; pentry = pentry->next)
1312 {
1313 match = 0;
1314
1315 if (type == normal_display || type == first_match_display)
1316 if (prefix_same (&p, &pentry->prefix))
1317 match = 1;
1318
1319 if (type == longer_display)
1320 if (prefix_match (&p, &pentry->prefix))
1321 match = 1;
1322
1323 if (match)
1324 {
1325 vty_out (vty, " seq %u %s ",
1326 pentry->seq,
1327 prefix_list_type_str (pentry));
1328
1329 if (pentry->any)
1330 vty_out (vty, "any");
1331 else
1332 {
1333 struct prefix *p = &pentry->prefix;
1334 char buf[BUFSIZ];
1335
1336 vty_out (vty, "%s/%d",
1337 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
1338 p->prefixlen);
1339
1340 if (pentry->ge)
1341 vty_out (vty, " ge %d", pentry->ge);
1342 if (pentry->le)
1343 vty_out (vty, " le %d", pentry->le);
1344 }
1345
1346 if (type == normal_display || type == first_match_display)
1347 vty_out (vty, " (hit count: %ld, refcount: %ld)",
1348 pentry->hitcnt, pentry->refcnt);
1349
1350 vty_out (vty, "%s", VTY_NEWLINE);
1351
1352 if (type == first_match_display)
1353 return CMD_SUCCESS;
1354 }
1355 }
1356 return CMD_SUCCESS;
1357 }
1358
1359 static int
1360 vty_clear_prefix_list (struct vty *vty, afi_t afi, const char *name,
1361 const char *prefix)
1362 {
1363 struct prefix_master *master;
1364 struct prefix_list *plist;
1365 struct prefix_list_entry *pentry;
1366 int ret;
1367 struct prefix p;
1368
1369 master = prefix_master_get (afi, 0);
1370 if (master == NULL)
1371 return CMD_WARNING;
1372
1373 if (name == NULL && prefix == NULL)
1374 {
1375 for (plist = master->num.head; plist; plist = plist->next)
1376 for (pentry = plist->head; pentry; pentry = pentry->next)
1377 pentry->hitcnt = 0;
1378
1379 for (plist = master->str.head; plist; plist = plist->next)
1380 for (pentry = plist->head; pentry; pentry = pentry->next)
1381 pentry->hitcnt = 0;
1382 }
1383 else
1384 {
1385 plist = prefix_list_lookup (afi, name);
1386 if (! plist)
1387 {
1388 vty_out (vty, "%% Can't find specified prefix-list%s", VTY_NEWLINE);
1389 return CMD_WARNING;
1390 }
1391
1392 if (prefix)
1393 {
1394 ret = str2prefix (prefix, &p);
1395 if (ret <= 0)
1396 {
1397 vty_out (vty, "%% prefix is malformed%s", VTY_NEWLINE);
1398 return CMD_WARNING;
1399 }
1400 }
1401
1402 for (pentry = plist->head; pentry; pentry = pentry->next)
1403 {
1404 if (prefix)
1405 {
1406 if (prefix_match (&pentry->prefix, &p))
1407 pentry->hitcnt = 0;
1408 }
1409 else
1410 pentry->hitcnt = 0;
1411 }
1412 }
1413 return CMD_SUCCESS;
1414 }
1415
1416 DEFUN (ip_prefix_list,
1417 ip_prefix_list_cmd,
1418 "ip prefix-list WORD <deny|permit> <A.B.C.D/M|any>",
1419 IP_STR
1420 PREFIX_LIST_STR
1421 "Name of a prefix list\n"
1422 "Specify packets to reject\n"
1423 "Specify packets to forward\n"
1424 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1425 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1426 {
1427 int idx_word = 2;
1428 int idx_permit_deny = 3;
1429 int idx_ipv4_any = 4;
1430 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL,
1431 argv[idx_permit_deny]->arg, argv[idx_ipv4_any]->arg, NULL, NULL);
1432 }
1433
1434 DEFUN (ip_prefix_list_ge,
1435 ip_prefix_list_ge_cmd,
1436 "ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32)",
1437 IP_STR
1438 PREFIX_LIST_STR
1439 "Name of a prefix list\n"
1440 "Specify packets to reject\n"
1441 "Specify packets to forward\n"
1442 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1443 "Minimum prefix length to be matched\n"
1444 "Minimum prefix length\n")
1445 {
1446 int idx_word = 2;
1447 int idx_permit_deny = 3;
1448 int idx_ipv4_prefixlen = 4;
1449 int idx_number = 6;
1450 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1451 argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL);
1452 }
1453
1454 DEFUN (ip_prefix_list_ge_le,
1455 ip_prefix_list_ge_le_cmd,
1456 "ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32) le (0-32)",
1457 IP_STR
1458 PREFIX_LIST_STR
1459 "Name of a prefix list\n"
1460 "Specify packets to reject\n"
1461 "Specify packets to forward\n"
1462 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1463 "Minimum prefix length to be matched\n"
1464 "Minimum prefix length\n"
1465 "Maximum prefix length to be matched\n"
1466 "Maximum prefix length\n")
1467 {
1468 int idx_word = 2;
1469 int idx_permit_deny = 3;
1470 int idx_ipv4_prefixlen = 4;
1471 int idx_number = 6;
1472 int idx_number_2 = 8;
1473 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1474 argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
1475 }
1476
1477 DEFUN (ip_prefix_list_le,
1478 ip_prefix_list_le_cmd,
1479 "ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32)",
1480 IP_STR
1481 PREFIX_LIST_STR
1482 "Name of a prefix list\n"
1483 "Specify packets to reject\n"
1484 "Specify packets to forward\n"
1485 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1486 "Maximum prefix length to be matched\n"
1487 "Maximum prefix length\n")
1488 {
1489 int idx_word = 2;
1490 int idx_permit_deny = 3;
1491 int idx_ipv4_prefixlen = 4;
1492 int idx_number = 6;
1493 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1494 argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg);
1495 }
1496
1497 DEFUN (ip_prefix_list_le_ge,
1498 ip_prefix_list_le_ge_cmd,
1499 "ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32) ge (0-32)",
1500 IP_STR
1501 PREFIX_LIST_STR
1502 "Name of a prefix list\n"
1503 "Specify packets to reject\n"
1504 "Specify packets to forward\n"
1505 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1506 "Maximum prefix length to be matched\n"
1507 "Maximum prefix length\n"
1508 "Minimum prefix length to be matched\n"
1509 "Minimum prefix length\n")
1510 {
1511 int idx_word = 2;
1512 int idx_permit_deny = 3;
1513 int idx_ipv4_prefixlen = 4;
1514 int idx_number = 6;
1515 int idx_number_2 = 8;
1516 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1517 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg);
1518 }
1519
1520 DEFUN (ip_prefix_list_seq,
1521 ip_prefix_list_seq_cmd,
1522 "ip prefix-list WORD seq (1-4294967295) <deny|permit> <A.B.C.D/M|any>",
1523 IP_STR
1524 PREFIX_LIST_STR
1525 "Name of a prefix list\n"
1526 "sequence number of an entry\n"
1527 "Sequence number\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 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1532 {
1533 int idx_word = 2;
1534 int idx_number = 4;
1535 int idx_permit_deny = 5;
1536 int idx_ipv4_any = 6;
1537 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1538 argv[idx_ipv4_any]->arg, NULL, NULL);
1539 }
1540
1541 DEFUN (ip_prefix_list_seq_ge,
1542 ip_prefix_list_seq_ge_cmd,
1543 "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32)",
1544 IP_STR
1545 PREFIX_LIST_STR
1546 "Name of a prefix list\n"
1547 "sequence number of an entry\n"
1548 "Sequence number\n"
1549 "Specify packets to reject\n"
1550 "Specify packets to forward\n"
1551 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1552 "Minimum prefix length to be matched\n"
1553 "Minimum prefix length\n")
1554 {
1555 int idx_word = 2;
1556 int idx_number = 4;
1557 int idx_permit_deny = 5;
1558 int idx_ipv4_prefixlen = 6;
1559 int idx_number_2 = 8;
1560 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1561 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL);
1562 }
1563
1564 DEFUN (ip_prefix_list_seq_ge_le,
1565 ip_prefix_list_seq_ge_le_cmd,
1566 "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32) le (0-32)",
1567 IP_STR
1568 PREFIX_LIST_STR
1569 "Name of a prefix list\n"
1570 "sequence number of an entry\n"
1571 "Sequence number\n"
1572 "Specify packets to reject\n"
1573 "Specify packets to forward\n"
1574 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1575 "Minimum prefix length to be matched\n"
1576 "Minimum prefix length\n"
1577 "Maximum prefix length to be matched\n"
1578 "Maximum prefix length\n")
1579 {
1580 int idx_word = 2;
1581 int idx_number = 4;
1582 int idx_permit_deny = 5;
1583 int idx_ipv4_prefixlen = 6;
1584 int idx_number_2 = 8;
1585 int idx_number_3 = 10;
1586 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1587 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
1588 }
1589
1590 DEFUN (ip_prefix_list_seq_le,
1591 ip_prefix_list_seq_le_cmd,
1592 "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32)",
1593 IP_STR
1594 PREFIX_LIST_STR
1595 "Name of a prefix list\n"
1596 "sequence number of an entry\n"
1597 "Sequence number\n"
1598 "Specify packets to reject\n"
1599 "Specify packets to forward\n"
1600 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1601 "Maximum prefix length to be matched\n"
1602 "Maximum prefix length\n")
1603 {
1604 int idx_word = 2;
1605 int idx_number = 4;
1606 int idx_permit_deny = 5;
1607 int idx_ipv4_prefixlen = 6;
1608 int idx_number_2 = 8;
1609 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1610 argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg);
1611 }
1612
1613 DEFUN (ip_prefix_list_seq_le_ge,
1614 ip_prefix_list_seq_le_ge_cmd,
1615 "ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32) ge (0-32)",
1616 IP_STR
1617 PREFIX_LIST_STR
1618 "Name of a prefix list\n"
1619 "sequence number of an entry\n"
1620 "Sequence number\n"
1621 "Specify packets to reject\n"
1622 "Specify packets to forward\n"
1623 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1624 "Maximum prefix length to be matched\n"
1625 "Maximum prefix length\n"
1626 "Minimum prefix length to be matched\n"
1627 "Minimum prefix length\n")
1628 {
1629 int idx_word = 2;
1630 int idx_number = 4;
1631 int idx_permit_deny = 5;
1632 int idx_ipv4_prefixlen = 6;
1633 int idx_number_2 = 8;
1634 int idx_number_3 = 10;
1635 return vty_prefix_list_install (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1636 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg);
1637 }
1638
1639 DEFUN (no_ip_prefix_list,
1640 no_ip_prefix_list_cmd,
1641 "no ip prefix-list WORD",
1642 NO_STR
1643 IP_STR
1644 PREFIX_LIST_STR
1645 "Name of a prefix list\n")
1646 {
1647 int idx_word = 3;
1648 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, NULL,
1649 NULL, NULL, NULL);
1650 }
1651
1652 DEFUN (no_ip_prefix_list_prefix,
1653 no_ip_prefix_list_prefix_cmd,
1654 "no ip prefix-list WORD <deny|permit> <A.B.C.D/M|any>",
1655 NO_STR
1656 IP_STR
1657 PREFIX_LIST_STR
1658 "Name of a prefix list\n"
1659 "Specify packets to reject\n"
1660 "Specify packets to forward\n"
1661 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1662 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1663 {
1664 int idx_word = 3;
1665 int idx_permit_deny = 4;
1666 int idx_ipv4_any = 5;
1667 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1668 argv[idx_ipv4_any]->arg, NULL, NULL);
1669 }
1670
1671 DEFUN (no_ip_prefix_list_ge,
1672 no_ip_prefix_list_ge_cmd,
1673 "no ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32)",
1674 NO_STR
1675 IP_STR
1676 PREFIX_LIST_STR
1677 "Name of a prefix list\n"
1678 "Specify packets to reject\n"
1679 "Specify packets to forward\n"
1680 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1681 "Minimum prefix length to be matched\n"
1682 "Minimum prefix length\n")
1683 {
1684 int idx_word = 3;
1685 int idx_permit_deny = 4;
1686 int idx_ipv4_prefixlen = 5;
1687 int idx_number = 7;
1688 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1689 argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, NULL);
1690 }
1691
1692 DEFUN (no_ip_prefix_list_ge_le,
1693 no_ip_prefix_list_ge_le_cmd,
1694 "no ip prefix-list WORD <deny|permit> A.B.C.D/M ge (0-32) le (0-32)",
1695 NO_STR
1696 IP_STR
1697 PREFIX_LIST_STR
1698 "Name of a prefix list\n"
1699 "Specify packets to reject\n"
1700 "Specify packets to forward\n"
1701 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1702 "Minimum prefix length to be matched\n"
1703 "Minimum prefix length\n"
1704 "Maximum prefix length to be matched\n"
1705 "Maximum prefix length\n")
1706 {
1707 int idx_word = 3;
1708 int idx_permit_deny = 4;
1709 int idx_ipv4_prefixlen = 5;
1710 int idx_number = 7;
1711 int idx_number_2 = 9;
1712 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1713 argv[idx_ipv4_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
1714 }
1715
1716 DEFUN (no_ip_prefix_list_le,
1717 no_ip_prefix_list_le_cmd,
1718 "no ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32)",
1719 NO_STR
1720 IP_STR
1721 PREFIX_LIST_STR
1722 "Name of a prefix list\n"
1723 "Specify packets to reject\n"
1724 "Specify packets to forward\n"
1725 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1726 "Maximum prefix length to be matched\n"
1727 "Maximum prefix length\n")
1728 {
1729 int idx_word = 3;
1730 int idx_permit_deny = 4;
1731 int idx_ipv4_prefixlen = 5;
1732 int idx_number = 7;
1733 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1734 argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number]->arg);
1735 }
1736
1737 DEFUN (no_ip_prefix_list_le_ge,
1738 no_ip_prefix_list_le_ge_cmd,
1739 "no ip prefix-list WORD <deny|permit> A.B.C.D/M le (0-32) ge (0-32)",
1740 NO_STR
1741 IP_STR
1742 PREFIX_LIST_STR
1743 "Name of a prefix list\n"
1744 "Specify packets to reject\n"
1745 "Specify packets to forward\n"
1746 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1747 "Maximum prefix length to be matched\n"
1748 "Maximum prefix length\n"
1749 "Minimum prefix length to be matched\n"
1750 "Minimum prefix length\n")
1751 {
1752 int idx_word = 3;
1753 int idx_permit_deny = 4;
1754 int idx_ipv4_prefixlen = 5;
1755 int idx_number = 7;
1756 int idx_number_2 = 9;
1757 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
1758 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg);
1759 }
1760
1761 DEFUN (no_ip_prefix_list_seq,
1762 no_ip_prefix_list_seq_cmd,
1763 "no ip prefix-list WORD seq (1-4294967295) <deny|permit> <A.B.C.D/M|any>",
1764 NO_STR
1765 IP_STR
1766 PREFIX_LIST_STR
1767 "Name of a prefix list\n"
1768 "sequence number of an entry\n"
1769 "Sequence number\n"
1770 "Specify packets to reject\n"
1771 "Specify packets to forward\n"
1772 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1773 "Any prefix match. Same as \"0.0.0.0/0 le 32\"\n")
1774 {
1775 int idx_word = 3;
1776 int idx_number = 5;
1777 int idx_permit_deny = 6;
1778 int idx_ipv4_any = 7;
1779 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1780 argv[idx_ipv4_any]->arg, NULL, NULL);
1781 }
1782
1783 DEFUN (no_ip_prefix_list_seq_ge,
1784 no_ip_prefix_list_seq_ge_cmd,
1785 "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32)",
1786 NO_STR
1787 IP_STR
1788 PREFIX_LIST_STR
1789 "Name of a prefix list\n"
1790 "sequence number of an entry\n"
1791 "Sequence number\n"
1792 "Specify packets to reject\n"
1793 "Specify packets to forward\n"
1794 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1795 "Minimum prefix length to be matched\n"
1796 "Minimum prefix length\n")
1797 {
1798 int idx_word = 3;
1799 int idx_number = 5;
1800 int idx_permit_deny = 6;
1801 int idx_ipv4_prefixlen = 7;
1802 int idx_number_2 = 9;
1803 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1804 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, NULL);
1805 }
1806
1807 DEFUN (no_ip_prefix_list_seq_ge_le,
1808 no_ip_prefix_list_seq_ge_le_cmd,
1809 "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M ge (0-32) le (0-32)",
1810 NO_STR
1811 IP_STR
1812 PREFIX_LIST_STR
1813 "Name of a prefix list\n"
1814 "sequence number of an entry\n"
1815 "Sequence number\n"
1816 "Specify packets to reject\n"
1817 "Specify packets to forward\n"
1818 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1819 "Minimum prefix length to be matched\n"
1820 "Minimum prefix length\n"
1821 "Maximum prefix length to be matched\n"
1822 "Maximum prefix length\n")
1823 {
1824 int idx_word = 3;
1825 int idx_number = 5;
1826 int idx_permit_deny = 6;
1827 int idx_ipv4_prefixlen = 7;
1828 int idx_number_2 = 9;
1829 int idx_number_3 = 11;
1830 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1831 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
1832 }
1833
1834 DEFUN (no_ip_prefix_list_seq_le,
1835 no_ip_prefix_list_seq_le_cmd,
1836 "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32)",
1837 NO_STR
1838 IP_STR
1839 PREFIX_LIST_STR
1840 "Name of a prefix list\n"
1841 "sequence number of an entry\n"
1842 "Sequence number\n"
1843 "Specify packets to reject\n"
1844 "Specify packets to forward\n"
1845 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1846 "Maximum prefix length to be matched\n"
1847 "Maximum prefix length\n")
1848 {
1849 int idx_word = 3;
1850 int idx_number = 5;
1851 int idx_permit_deny = 6;
1852 int idx_ipv4_prefixlen = 7;
1853 int idx_number_2 = 9;
1854 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1855 argv[idx_ipv4_prefixlen]->arg, NULL, argv[idx_number_2]->arg);
1856 }
1857
1858 DEFUN (no_ip_prefix_list_seq_le_ge,
1859 no_ip_prefix_list_seq_le_ge_cmd,
1860 "no ip prefix-list WORD seq (1-4294967295) <deny|permit> A.B.C.D/M le (0-32) ge (0-32)",
1861 NO_STR
1862 IP_STR
1863 PREFIX_LIST_STR
1864 "Name of a prefix list\n"
1865 "sequence number of an entry\n"
1866 "Sequence number\n"
1867 "Specify packets to reject\n"
1868 "Specify packets to forward\n"
1869 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
1870 "Maximum prefix length to be matched\n"
1871 "Maximum prefix length\n"
1872 "Minimum prefix length to be matched\n"
1873 "Minimum prefix length\n")
1874 {
1875 int idx_word = 3;
1876 int idx_number = 5;
1877 int idx_permit_deny = 6;
1878 int idx_ipv4_prefixlen = 7;
1879 int idx_number_2 = 9;
1880 int idx_number_3 = 11;
1881 return vty_prefix_list_uninstall (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
1882 argv[idx_ipv4_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg);
1883 }
1884
1885 DEFUN (ip_prefix_list_sequence_number,
1886 ip_prefix_list_sequence_number_cmd,
1887 "ip prefix-list sequence-number",
1888 IP_STR
1889 PREFIX_LIST_STR
1890 "Include/exclude sequence numbers in NVGEN\n")
1891 {
1892 prefix_master_ipv4.seqnum = 1;
1893 return CMD_SUCCESS;
1894 }
1895
1896 DEFUN (no_ip_prefix_list_sequence_number,
1897 no_ip_prefix_list_sequence_number_cmd,
1898 "no ip prefix-list sequence-number",
1899 NO_STR
1900 IP_STR
1901 PREFIX_LIST_STR
1902 "Include/exclude sequence numbers in NVGEN\n")
1903 {
1904 prefix_master_ipv4.seqnum = 0;
1905 return CMD_SUCCESS;
1906 }
1907
1908 DEFUN (ip_prefix_list_description,
1909 ip_prefix_list_description_cmd,
1910 "ip prefix-list WORD description LINE...",
1911 IP_STR
1912 PREFIX_LIST_STR
1913 "Name of a prefix list\n"
1914 "Prefix-list specific description\n"
1915 "Up to 80 characters describing this prefix-list\n")
1916 {
1917 int idx_word = 2;
1918 int idx_line = 4;
1919 struct prefix_list *plist;
1920
1921 plist = prefix_list_get (AFI_IP, 0, argv[idx_word]->arg);
1922
1923 if (plist->desc)
1924 {
1925 XFREE (MTYPE_TMP, plist->desc);
1926 plist->desc = NULL;
1927 }
1928 plist->desc = argv_concat(argv, argc, idx_line);
1929
1930 return CMD_SUCCESS;
1931 }
1932
1933 DEFUN (no_ip_prefix_list_description,
1934 no_ip_prefix_list_description_cmd,
1935 "no ip prefix-list WORD description",
1936 NO_STR
1937 IP_STR
1938 PREFIX_LIST_STR
1939 "Name of a prefix list\n"
1940 "Prefix-list specific description\n")
1941 {
1942 int idx_word = 3;
1943 return vty_prefix_list_desc_unset (vty, AFI_IP, argv[idx_word]->arg);
1944 }
1945
1946 /* ALIAS_FIXME */
1947 DEFUN (no_ip_prefix_list_description_comment,
1948 no_ip_prefix_list_description_comment_cmd,
1949 "no ip prefix-list WORD description LINE...",
1950 NO_STR
1951 IP_STR
1952 PREFIX_LIST_STR
1953 "Name of a prefix list\n"
1954 "Prefix-list specific description\n"
1955 "Up to 80 characters describing this prefix-list\n")
1956 {
1957 return no_ip_prefix_list_description (self, vty, argc, argv);
1958 }
1959
1960 DEFUN (show_ip_prefix_list,
1961 show_ip_prefix_list_cmd,
1962 "show ip prefix-list",
1963 SHOW_STR
1964 IP_STR
1965 PREFIX_LIST_STR)
1966 {
1967 return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, normal_display);
1968 }
1969
1970 DEFUN (show_ip_prefix_list_name,
1971 show_ip_prefix_list_name_cmd,
1972 "show ip prefix-list WORD",
1973 SHOW_STR
1974 IP_STR
1975 PREFIX_LIST_STR
1976 "Name of a prefix list\n")
1977 {
1978 int idx_word = 3;
1979 return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, normal_display);
1980 }
1981
1982 DEFUN (show_ip_prefix_list_name_seq,
1983 show_ip_prefix_list_name_seq_cmd,
1984 "show ip prefix-list WORD seq (1-4294967295)",
1985 SHOW_STR
1986 IP_STR
1987 PREFIX_LIST_STR
1988 "Name of a prefix list\n"
1989 "sequence number of an entry\n"
1990 "Sequence number\n")
1991 {
1992 int idx_word = 3;
1993 int idx_number = 5;
1994 return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display);
1995 }
1996
1997 DEFUN (show_ip_prefix_list_prefix,
1998 show_ip_prefix_list_prefix_cmd,
1999 "show ip prefix-list WORD A.B.C.D/M",
2000 SHOW_STR
2001 IP_STR
2002 PREFIX_LIST_STR
2003 "Name of a prefix list\n"
2004 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2005 {
2006 int idx_word = 3;
2007 int idx_ipv4_prefixlen = 4;
2008 return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, normal_display);
2009 }
2010
2011 DEFUN (show_ip_prefix_list_prefix_longer,
2012 show_ip_prefix_list_prefix_longer_cmd,
2013 "show ip prefix-list WORD A.B.C.D/M longer",
2014 SHOW_STR
2015 IP_STR
2016 PREFIX_LIST_STR
2017 "Name of a prefix list\n"
2018 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2019 "Lookup longer prefix\n")
2020 {
2021 int idx_word = 3;
2022 int idx_ipv4_prefixlen = 4;
2023 return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, longer_display);
2024 }
2025
2026 DEFUN (show_ip_prefix_list_prefix_first_match,
2027 show_ip_prefix_list_prefix_first_match_cmd,
2028 "show ip prefix-list WORD A.B.C.D/M first-match",
2029 SHOW_STR
2030 IP_STR
2031 PREFIX_LIST_STR
2032 "Name of a prefix list\n"
2033 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
2034 "First matched prefix\n")
2035 {
2036 int idx_word = 3;
2037 int idx_ipv4_prefixlen = 4;
2038 return vty_show_prefix_list_prefix (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg, first_match_display);
2039 }
2040
2041 DEFUN (show_ip_prefix_list_summary,
2042 show_ip_prefix_list_summary_cmd,
2043 "show ip prefix-list summary",
2044 SHOW_STR
2045 IP_STR
2046 PREFIX_LIST_STR
2047 "Summary of prefix lists\n")
2048 {
2049 return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, summary_display);
2050 }
2051
2052 DEFUN (show_ip_prefix_list_summary_name,
2053 show_ip_prefix_list_summary_name_cmd,
2054 "show ip prefix-list summary WORD",
2055 SHOW_STR
2056 IP_STR
2057 PREFIX_LIST_STR
2058 "Summary of prefix lists\n"
2059 "Name of a prefix list\n")
2060 {
2061 int idx_word = 4;
2062 return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, summary_display);
2063 }
2064
2065
2066 DEFUN (show_ip_prefix_list_detail,
2067 show_ip_prefix_list_detail_cmd,
2068 "show ip prefix-list detail",
2069 SHOW_STR
2070 IP_STR
2071 PREFIX_LIST_STR
2072 "Detail of prefix lists\n")
2073 {
2074 return vty_show_prefix_list (vty, AFI_IP, NULL, NULL, detail_display);
2075 }
2076
2077 DEFUN (show_ip_prefix_list_detail_name,
2078 show_ip_prefix_list_detail_name_cmd,
2079 "show ip prefix-list detail WORD",
2080 SHOW_STR
2081 IP_STR
2082 PREFIX_LIST_STR
2083 "Detail of prefix lists\n"
2084 "Name of a prefix list\n")
2085 {
2086 int idx_word = 4;
2087 return vty_show_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL, detail_display);
2088 }
2089
2090 DEFUN (clear_ip_prefix_list,
2091 clear_ip_prefix_list_cmd,
2092 "clear ip prefix-list",
2093 CLEAR_STR
2094 IP_STR
2095 PREFIX_LIST_STR)
2096 {
2097 return vty_clear_prefix_list (vty, AFI_IP, NULL, NULL);
2098 }
2099
2100 DEFUN (clear_ip_prefix_list_name,
2101 clear_ip_prefix_list_name_cmd,
2102 "clear ip prefix-list WORD",
2103 CLEAR_STR
2104 IP_STR
2105 PREFIX_LIST_STR
2106 "Name of a prefix list\n")
2107 {
2108 int idx_word = 3;
2109 return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, NULL);
2110 }
2111
2112 DEFUN (clear_ip_prefix_list_name_prefix,
2113 clear_ip_prefix_list_name_prefix_cmd,
2114 "clear ip prefix-list WORD A.B.C.D/M",
2115 CLEAR_STR
2116 IP_STR
2117 PREFIX_LIST_STR
2118 "Name of a prefix list\n"
2119 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
2120 {
2121 int idx_word = 3;
2122 int idx_ipv4_prefixlen = 4;
2123 return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg);
2124 }
2125
2126 DEFUN (ipv6_prefix_list,
2127 ipv6_prefix_list_cmd,
2128 "ipv6 prefix-list WORD <deny|permit> <X:X::X:X/M|any>",
2129 IPV6_STR
2130 PREFIX_LIST_STR
2131 "Name of a prefix list\n"
2132 "Specify packets to reject\n"
2133 "Specify packets to forward\n"
2134 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2135 "Any prefix match. Same as \"::0/0 le 128\"\n")
2136 {
2137 int idx_word = 2;
2138 int idx_permit_deny = 3;
2139 int idx_ipv6_any = 4;
2140 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL,
2141 argv[idx_permit_deny]->arg, argv[idx_ipv6_any]->arg, NULL, NULL);
2142 }
2143
2144 DEFUN (ipv6_prefix_list_ge,
2145 ipv6_prefix_list_ge_cmd,
2146 "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128)",
2147 IPV6_STR
2148 PREFIX_LIST_STR
2149 "Name of a prefix list\n"
2150 "Specify packets to reject\n"
2151 "Specify packets to forward\n"
2152 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2153 "Minimum prefix length to be matched\n"
2154 "Minimum prefix length\n")
2155 {
2156 int idx_word = 2;
2157 int idx_permit_deny = 3;
2158 int idx_ipv6_prefixlen = 4;
2159 int idx_number = 6;
2160 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2161 argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL);
2162 }
2163
2164 DEFUN (ipv6_prefix_list_ge_le,
2165 ipv6_prefix_list_ge_le_cmd,
2166 "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128) le (0-128)",
2167 IPV6_STR
2168 PREFIX_LIST_STR
2169 "Name of a prefix list\n"
2170 "Specify packets to reject\n"
2171 "Specify packets to forward\n"
2172 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2173 "Minimum prefix length to be matched\n"
2174 "Minimum prefix length\n"
2175 "Maximum prefix length to be matched\n"
2176 "Maximum prefix length\n")
2177
2178 {
2179 int idx_word = 2;
2180 int idx_permit_deny = 3;
2181 int idx_ipv6_prefixlen = 4;
2182 int idx_number = 6;
2183 int idx_number_2 = 8;
2184 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2185 argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
2186 }
2187
2188 DEFUN (ipv6_prefix_list_le,
2189 ipv6_prefix_list_le_cmd,
2190 "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128)",
2191 IPV6_STR
2192 PREFIX_LIST_STR
2193 "Name of a prefix list\n"
2194 "Specify packets to reject\n"
2195 "Specify packets to forward\n"
2196 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2197 "Maximum prefix length to be matched\n"
2198 "Maximum prefix length\n")
2199 {
2200 int idx_word = 2;
2201 int idx_permit_deny = 3;
2202 int idx_ipv6_prefixlen = 4;
2203 int idx_number = 6;
2204 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2205 argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg);
2206 }
2207
2208 DEFUN (ipv6_prefix_list_le_ge,
2209 ipv6_prefix_list_le_ge_cmd,
2210 "ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128) ge (0-128)",
2211 IPV6_STR
2212 PREFIX_LIST_STR
2213 "Name of a prefix list\n"
2214 "Specify packets to reject\n"
2215 "Specify packets to forward\n"
2216 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2217 "Maximum prefix length to be matched\n"
2218 "Maximum prefix length\n"
2219 "Minimum prefix length to be matched\n"
2220 "Minimum prefix length\n")
2221 {
2222 int idx_word = 2;
2223 int idx_permit_deny = 3;
2224 int idx_ipv6_prefixlen = 4;
2225 int idx_number = 6;
2226 int idx_number_2 = 8;
2227 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2228 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg);
2229 }
2230
2231 DEFUN (ipv6_prefix_list_seq,
2232 ipv6_prefix_list_seq_cmd,
2233 "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> <X:X::X:X/M|any>",
2234 IPV6_STR
2235 PREFIX_LIST_STR
2236 "Name of a prefix list\n"
2237 "sequence number of an entry\n"
2238 "Sequence number\n"
2239 "Specify packets to reject\n"
2240 "Specify packets to forward\n"
2241 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2242 "Any prefix match. Same as \"::0/0 le 128\"\n")
2243 {
2244 int idx_word = 2;
2245 int idx_number = 4;
2246 int idx_permit_deny = 5;
2247 int idx_ipv6_any = 6;
2248 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2249 argv[idx_ipv6_any]->arg, NULL, NULL);
2250 }
2251
2252 DEFUN (ipv6_prefix_list_seq_ge,
2253 ipv6_prefix_list_seq_ge_cmd,
2254 "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128)",
2255 IPV6_STR
2256 PREFIX_LIST_STR
2257 "Name of a prefix list\n"
2258 "sequence number of an entry\n"
2259 "Sequence number\n"
2260 "Specify packets to reject\n"
2261 "Specify packets to forward\n"
2262 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2263 "Minimum prefix length to be matched\n"
2264 "Minimum prefix length\n")
2265 {
2266 int idx_word = 2;
2267 int idx_number = 4;
2268 int idx_permit_deny = 5;
2269 int idx_ipv6_prefixlen = 6;
2270 int idx_number_2 = 8;
2271 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2272 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL);
2273 }
2274
2275 DEFUN (ipv6_prefix_list_seq_ge_le,
2276 ipv6_prefix_list_seq_ge_le_cmd,
2277 "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128) le (0-128)",
2278 IPV6_STR
2279 PREFIX_LIST_STR
2280 "Name of a prefix list\n"
2281 "sequence number of an entry\n"
2282 "Sequence number\n"
2283 "Specify packets to reject\n"
2284 "Specify packets to forward\n"
2285 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2286 "Minimum prefix length to be matched\n"
2287 "Minimum prefix length\n"
2288 "Maximum prefix length to be matched\n"
2289 "Maximum prefix length\n")
2290 {
2291 int idx_word = 2;
2292 int idx_number = 4;
2293 int idx_permit_deny = 5;
2294 int idx_ipv6_prefixlen = 6;
2295 int idx_number_2 = 8;
2296 int idx_number_3 = 10;
2297 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2298 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
2299 }
2300
2301 DEFUN (ipv6_prefix_list_seq_le,
2302 ipv6_prefix_list_seq_le_cmd,
2303 "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128)",
2304 IPV6_STR
2305 PREFIX_LIST_STR
2306 "Name of a prefix list\n"
2307 "sequence number of an entry\n"
2308 "Sequence number\n"
2309 "Specify packets to reject\n"
2310 "Specify packets to forward\n"
2311 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2312 "Maximum prefix length to be matched\n"
2313 "Maximum prefix length\n")
2314 {
2315 int idx_word = 2;
2316 int idx_number = 4;
2317 int idx_permit_deny = 5;
2318 int idx_ipv6_prefixlen = 6;
2319 int idx_number_2 = 8;
2320 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2321 argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg);
2322 }
2323
2324 DEFUN (ipv6_prefix_list_seq_le_ge,
2325 ipv6_prefix_list_seq_le_ge_cmd,
2326 "ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128) ge (0-128)",
2327 IPV6_STR
2328 PREFIX_LIST_STR
2329 "Name of a prefix list\n"
2330 "sequence number of an entry\n"
2331 "Sequence number\n"
2332 "Specify packets to reject\n"
2333 "Specify packets to forward\n"
2334 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2335 "Maximum prefix length to be matched\n"
2336 "Maximum prefix length\n"
2337 "Minimum prefix length to be matched\n"
2338 "Minimum prefix length\n")
2339 {
2340 int idx_word = 2;
2341 int idx_number = 4;
2342 int idx_permit_deny = 5;
2343 int idx_ipv6_prefixlen = 6;
2344 int idx_number_2 = 8;
2345 int idx_number_3 = 10;
2346 return vty_prefix_list_install (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2347 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg);
2348 }
2349
2350 DEFUN (no_ipv6_prefix_list,
2351 no_ipv6_prefix_list_cmd,
2352 "no ipv6 prefix-list WORD",
2353 NO_STR
2354 IPV6_STR
2355 PREFIX_LIST_STR
2356 "Name of a prefix list\n")
2357 {
2358 int idx_word = 3;
2359 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, NULL,
2360 NULL, NULL, NULL);
2361 }
2362
2363 DEFUN (no_ipv6_prefix_list_prefix,
2364 no_ipv6_prefix_list_prefix_cmd,
2365 "no ipv6 prefix-list WORD <deny|permit> <X:X::X:X/M|any>",
2366 NO_STR
2367 IPV6_STR
2368 PREFIX_LIST_STR
2369 "Name of a prefix list\n"
2370 "Specify packets to reject\n"
2371 "Specify packets to forward\n"
2372 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2373 "Any prefix match. Same as \"::0/0 le 128\"\n")
2374 {
2375 int idx_word = 3;
2376 int idx_permit_deny = 4;
2377 int idx_ipv6_any = 5;
2378 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2379 argv[idx_ipv6_any]->arg, NULL, NULL);
2380 }
2381
2382 DEFUN (no_ipv6_prefix_list_ge,
2383 no_ipv6_prefix_list_ge_cmd,
2384 "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128)",
2385 NO_STR
2386 IPV6_STR
2387 PREFIX_LIST_STR
2388 "Name of a prefix list\n"
2389 "Specify packets to reject\n"
2390 "Specify packets to forward\n"
2391 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2392 "Minimum prefix length to be matched\n"
2393 "Minimum prefix length\n")
2394 {
2395 int idx_word = 3;
2396 int idx_permit_deny = 4;
2397 int idx_ipv6_prefixlen = 5;
2398 int idx_number = 7;
2399 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2400 argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, NULL);
2401 }
2402
2403 DEFUN (no_ipv6_prefix_list_ge_le,
2404 no_ipv6_prefix_list_ge_le_cmd,
2405 "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M ge (0-128) le (0-128)",
2406 NO_STR
2407 IPV6_STR
2408 PREFIX_LIST_STR
2409 "Name of a prefix list\n"
2410 "Specify packets to reject\n"
2411 "Specify packets to forward\n"
2412 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2413 "Minimum prefix length to be matched\n"
2414 "Minimum prefix length\n"
2415 "Maximum prefix length to be matched\n"
2416 "Maximum prefix length\n")
2417 {
2418 int idx_word = 3;
2419 int idx_permit_deny = 4;
2420 int idx_ipv6_prefixlen = 5;
2421 int idx_number = 7;
2422 int idx_number_2 = 9;
2423 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2424 argv[idx_ipv6_prefixlen]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
2425 }
2426
2427 DEFUN (no_ipv6_prefix_list_le,
2428 no_ipv6_prefix_list_le_cmd,
2429 "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128)",
2430 NO_STR
2431 IPV6_STR
2432 PREFIX_LIST_STR
2433 "Name of a prefix list\n"
2434 "Specify packets to reject\n"
2435 "Specify packets to forward\n"
2436 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2437 "Maximum prefix length to be matched\n"
2438 "Maximum prefix length\n")
2439 {
2440 int idx_word = 3;
2441 int idx_permit_deny = 4;
2442 int idx_ipv6_prefixlen = 5;
2443 int idx_number = 7;
2444 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2445 argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number]->arg);
2446 }
2447
2448 DEFUN (no_ipv6_prefix_list_le_ge,
2449 no_ipv6_prefix_list_le_ge_cmd,
2450 "no ipv6 prefix-list WORD <deny|permit> X:X::X:X/M le (0-128) ge (0-128)",
2451 NO_STR
2452 IPV6_STR
2453 PREFIX_LIST_STR
2454 "Name of a prefix list\n"
2455 "Specify packets to reject\n"
2456 "Specify packets to forward\n"
2457 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2458 "Maximum prefix length to be matched\n"
2459 "Maximum prefix length\n"
2460 "Minimum prefix length to be matched\n"
2461 "Minimum prefix length\n")
2462 {
2463 int idx_word = 3;
2464 int idx_permit_deny = 4;
2465 int idx_ipv6_prefixlen = 5;
2466 int idx_number = 7;
2467 int idx_number_2 = 9;
2468 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, NULL, argv[idx_permit_deny]->arg,
2469 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number]->arg);
2470 }
2471
2472 DEFUN (no_ipv6_prefix_list_seq,
2473 no_ipv6_prefix_list_seq_cmd,
2474 "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> <X:X::X:X/M|any>",
2475 NO_STR
2476 IPV6_STR
2477 PREFIX_LIST_STR
2478 "Name of a prefix list\n"
2479 "sequence number of an entry\n"
2480 "Sequence number\n"
2481 "Specify packets to reject\n"
2482 "Specify packets to forward\n"
2483 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2484 "Any prefix match. Same as \"::0/0 le 128\"\n")
2485 {
2486 int idx_word = 3;
2487 int idx_number = 5;
2488 int idx_permit_deny = 6;
2489 int idx_ipv6_any = 7;
2490 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2491 argv[idx_ipv6_any]->arg, NULL, NULL);
2492 }
2493
2494 DEFUN (no_ipv6_prefix_list_seq_ge,
2495 no_ipv6_prefix_list_seq_ge_cmd,
2496 "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128)",
2497 NO_STR
2498 IPV6_STR
2499 PREFIX_LIST_STR
2500 "Name of a prefix list\n"
2501 "sequence number of an entry\n"
2502 "Sequence number\n"
2503 "Specify packets to reject\n"
2504 "Specify packets to forward\n"
2505 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2506 "Minimum prefix length to be matched\n"
2507 "Minimum prefix length\n")
2508 {
2509 int idx_word = 3;
2510 int idx_number = 5;
2511 int idx_permit_deny = 6;
2512 int idx_ipv6_prefixlen = 7;
2513 int idx_number_2 = 9;
2514 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2515 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, NULL);
2516 }
2517
2518 DEFUN (no_ipv6_prefix_list_seq_ge_le,
2519 no_ipv6_prefix_list_seq_ge_le_cmd,
2520 "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M ge (0-128) le (0-128)",
2521 NO_STR
2522 IPV6_STR
2523 PREFIX_LIST_STR
2524 "Name of a prefix list\n"
2525 "sequence number of an entry\n"
2526 "Sequence number\n"
2527 "Specify packets to reject\n"
2528 "Specify packets to forward\n"
2529 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2530 "Minimum prefix length to be matched\n"
2531 "Minimum prefix length\n"
2532 "Maximum prefix length to be matched\n"
2533 "Maximum prefix length\n")
2534 {
2535 int idx_word = 3;
2536 int idx_number = 5;
2537 int idx_permit_deny = 6;
2538 int idx_ipv6_prefixlen = 7;
2539 int idx_number_2 = 9;
2540 int idx_number_3 = 11;
2541 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2542 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg);
2543 }
2544
2545 DEFUN (no_ipv6_prefix_list_seq_le,
2546 no_ipv6_prefix_list_seq_le_cmd,
2547 "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128)",
2548 NO_STR
2549 IPV6_STR
2550 PREFIX_LIST_STR
2551 "Name of a prefix list\n"
2552 "sequence number of an entry\n"
2553 "Sequence number\n"
2554 "Specify packets to reject\n"
2555 "Specify packets to forward\n"
2556 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2557 "Maximum prefix length to be matched\n"
2558 "Maximum prefix length\n")
2559 {
2560 int idx_word = 3;
2561 int idx_number = 5;
2562 int idx_permit_deny = 6;
2563 int idx_ipv6_prefixlen = 7;
2564 int idx_number_2 = 9;
2565 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2566 argv[idx_ipv6_prefixlen]->arg, NULL, argv[idx_number_2]->arg);
2567 }
2568
2569 DEFUN (no_ipv6_prefix_list_seq_le_ge,
2570 no_ipv6_prefix_list_seq_le_ge_cmd,
2571 "no ipv6 prefix-list WORD seq (1-4294967295) <deny|permit> X:X::X:X/M le (0-128) ge (0-128)",
2572 NO_STR
2573 IPV6_STR
2574 PREFIX_LIST_STR
2575 "Name of a prefix list\n"
2576 "sequence number of an entry\n"
2577 "Sequence number\n"
2578 "Specify packets to reject\n"
2579 "Specify packets to forward\n"
2580 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2581 "Maximum prefix length to be matched\n"
2582 "Maximum prefix length\n"
2583 "Minimum prefix length to be matched\n"
2584 "Minimum prefix length\n")
2585 {
2586 int idx_word = 3;
2587 int idx_number = 5;
2588 int idx_permit_deny = 6;
2589 int idx_ipv6_prefixlen = 7;
2590 int idx_number_2 = 9;
2591 int idx_number_3 = 11;
2592 return vty_prefix_list_uninstall (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, argv[idx_permit_deny]->arg,
2593 argv[idx_ipv6_prefixlen]->arg, argv[idx_number_3]->arg, argv[idx_number_2]->arg);
2594 }
2595
2596 DEFUN (ipv6_prefix_list_sequence_number,
2597 ipv6_prefix_list_sequence_number_cmd,
2598 "ipv6 prefix-list sequence-number",
2599 IPV6_STR
2600 PREFIX_LIST_STR
2601 "Include/exclude sequence numbers in NVGEN\n")
2602 {
2603 prefix_master_ipv6.seqnum = 1;
2604 return CMD_SUCCESS;
2605 }
2606
2607 DEFUN (no_ipv6_prefix_list_sequence_number,
2608 no_ipv6_prefix_list_sequence_number_cmd,
2609 "no ipv6 prefix-list sequence-number",
2610 NO_STR
2611 IPV6_STR
2612 PREFIX_LIST_STR
2613 "Include/exclude sequence numbers in NVGEN\n")
2614 {
2615 prefix_master_ipv6.seqnum = 0;
2616 return CMD_SUCCESS;
2617 }
2618
2619 DEFUN (ipv6_prefix_list_description,
2620 ipv6_prefix_list_description_cmd,
2621 "ipv6 prefix-list WORD description LINE...",
2622 IPV6_STR
2623 PREFIX_LIST_STR
2624 "Name of a prefix list\n"
2625 "Prefix-list specific description\n"
2626 "Up to 80 characters describing this prefix-list\n")
2627 {
2628 int idx_word = 2;
2629 int iddx_line = 4;
2630 struct prefix_list *plist;
2631
2632 plist = prefix_list_get (AFI_IP6, 0, argv[idx_word]->arg);
2633
2634 if (plist->desc)
2635 {
2636 XFREE (MTYPE_TMP, plist->desc);
2637 plist->desc = NULL;
2638 }
2639 plist->desc = argv_concat(argv, argc, iddx_line);
2640
2641 return CMD_SUCCESS;
2642 }
2643
2644 DEFUN (no_ipv6_prefix_list_description,
2645 no_ipv6_prefix_list_description_cmd,
2646 "no ipv6 prefix-list WORD description",
2647 NO_STR
2648 IPV6_STR
2649 PREFIX_LIST_STR
2650 "Name of a prefix list\n"
2651 "Prefix-list specific description\n")
2652 {
2653 int idx_word = 3;
2654 return vty_prefix_list_desc_unset (vty, AFI_IP6, argv[idx_word]->arg);
2655 }
2656
2657 /* ALIAS_FIXME */
2658 DEFUN (no_ipv6_prefix_list_description_comment,
2659 no_ipv6_prefix_list_description_comment_cmd,
2660 "no ipv6 prefix-list WORD description LINE...",
2661 NO_STR
2662 IPV6_STR
2663 PREFIX_LIST_STR
2664 "Name of a prefix list\n"
2665 "Prefix-list specific description\n"
2666 "Up to 80 characters describing this prefix-list\n")
2667 {
2668 return no_ipv6_prefix_list_description (self, vty, argc, argv);
2669 }
2670
2671
2672 DEFUN (show_ipv6_prefix_list,
2673 show_ipv6_prefix_list_cmd,
2674 "show ipv6 prefix-list",
2675 SHOW_STR
2676 IPV6_STR
2677 PREFIX_LIST_STR)
2678 {
2679 return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, normal_display);
2680 }
2681
2682 DEFUN (show_ipv6_prefix_list_name,
2683 show_ipv6_prefix_list_name_cmd,
2684 "show ipv6 prefix-list WORD",
2685 SHOW_STR
2686 IPV6_STR
2687 PREFIX_LIST_STR
2688 "Name of a prefix list\n")
2689 {
2690 int idx_word = 3;
2691 return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, normal_display);
2692 }
2693
2694 DEFUN (show_ipv6_prefix_list_name_seq,
2695 show_ipv6_prefix_list_name_seq_cmd,
2696 "show ipv6 prefix-list WORD seq (1-4294967295)",
2697 SHOW_STR
2698 IPV6_STR
2699 PREFIX_LIST_STR
2700 "Name of a prefix list\n"
2701 "sequence number of an entry\n"
2702 "Sequence number\n")
2703 {
2704 int idx_word = 3;
2705 int idx_number = 5;
2706 return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_number]->arg, sequential_display);
2707 }
2708
2709 DEFUN (show_ipv6_prefix_list_prefix,
2710 show_ipv6_prefix_list_prefix_cmd,
2711 "show ipv6 prefix-list WORD X:X::X:X/M",
2712 SHOW_STR
2713 IPV6_STR
2714 PREFIX_LIST_STR
2715 "Name of a prefix list\n"
2716 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2717 {
2718 int idx_word = 3;
2719 int idx_ipv6_prefixlen = 4;
2720 return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, normal_display);
2721 }
2722
2723 DEFUN (show_ipv6_prefix_list_prefix_longer,
2724 show_ipv6_prefix_list_prefix_longer_cmd,
2725 "show ipv6 prefix-list WORD X:X::X:X/M longer",
2726 SHOW_STR
2727 IPV6_STR
2728 PREFIX_LIST_STR
2729 "Name of a prefix list\n"
2730 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2731 "Lookup longer prefix\n")
2732 {
2733 int idx_word = 3;
2734 int idx_ipv6_prefixlen = 4;
2735 return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, longer_display);
2736 }
2737
2738 DEFUN (show_ipv6_prefix_list_prefix_first_match,
2739 show_ipv6_prefix_list_prefix_first_match_cmd,
2740 "show ipv6 prefix-list WORD X:X::X:X/M first-match",
2741 SHOW_STR
2742 IPV6_STR
2743 PREFIX_LIST_STR
2744 "Name of a prefix list\n"
2745 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
2746 "First matched prefix\n")
2747 {
2748 int idx_word = 3;
2749 int idx_ipv6_prefixlen = 4;
2750 return vty_show_prefix_list_prefix (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, first_match_display);
2751 }
2752
2753 DEFUN (show_ipv6_prefix_list_summary,
2754 show_ipv6_prefix_list_summary_cmd,
2755 "show ipv6 prefix-list summary",
2756 SHOW_STR
2757 IPV6_STR
2758 PREFIX_LIST_STR
2759 "Summary of prefix lists\n")
2760 {
2761 return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, summary_display);
2762 }
2763
2764 DEFUN (show_ipv6_prefix_list_summary_name,
2765 show_ipv6_prefix_list_summary_name_cmd,
2766 "show ipv6 prefix-list summary WORD",
2767 SHOW_STR
2768 IPV6_STR
2769 PREFIX_LIST_STR
2770 "Summary of prefix lists\n"
2771 "Name of a prefix list\n")
2772 {
2773 int idx_word = 4;
2774 return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, summary_display);
2775 }
2776
2777 DEFUN (show_ipv6_prefix_list_detail,
2778 show_ipv6_prefix_list_detail_cmd,
2779 "show ipv6 prefix-list detail",
2780 SHOW_STR
2781 IPV6_STR
2782 PREFIX_LIST_STR
2783 "Detail of prefix lists\n")
2784 {
2785 return vty_show_prefix_list (vty, AFI_IP6, NULL, NULL, detail_display);
2786 }
2787
2788 DEFUN (show_ipv6_prefix_list_detail_name,
2789 show_ipv6_prefix_list_detail_name_cmd,
2790 "show ipv6 prefix-list detail WORD",
2791 SHOW_STR
2792 IPV6_STR
2793 PREFIX_LIST_STR
2794 "Detail of prefix lists\n"
2795 "Name of a prefix list\n")
2796 {
2797 int idx_word = 4;
2798 return vty_show_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL, detail_display);
2799 }
2800
2801 DEFUN (clear_ipv6_prefix_list,
2802 clear_ipv6_prefix_list_cmd,
2803 "clear ipv6 prefix-list",
2804 CLEAR_STR
2805 IPV6_STR
2806 PREFIX_LIST_STR)
2807 {
2808 return vty_clear_prefix_list (vty, AFI_IP6, NULL, NULL);
2809 }
2810
2811 DEFUN (clear_ipv6_prefix_list_name,
2812 clear_ipv6_prefix_list_name_cmd,
2813 "clear ipv6 prefix-list WORD",
2814 CLEAR_STR
2815 IPV6_STR
2816 PREFIX_LIST_STR
2817 "Name of a prefix list\n")
2818 {
2819 int idx_word = 3;
2820 return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, NULL);
2821 }
2822
2823 DEFUN (clear_ipv6_prefix_list_name_prefix,
2824 clear_ipv6_prefix_list_name_prefix_cmd,
2825 "clear ipv6 prefix-list WORD X:X::X:X/M",
2826 CLEAR_STR
2827 IPV6_STR
2828 PREFIX_LIST_STR
2829 "Name of a prefix list\n"
2830 "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n")
2831 {
2832 int idx_word = 3;
2833 int idx_ipv6_prefixlen = 4;
2834 return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg);
2835 }
2836
2837 /* Configuration write function. */
2838 static int
2839 config_write_prefix_afi (afi_t afi, struct vty *vty)
2840 {
2841 struct prefix_list *plist;
2842 struct prefix_list_entry *pentry;
2843 struct prefix_master *master;
2844 int write = 0;
2845
2846 master = prefix_master_get (afi, 0);
2847 if (master == NULL)
2848 return 0;
2849
2850 if (! master->seqnum)
2851 {
2852 vty_out (vty, "no ip%s prefix-list sequence-number%s",
2853 afi == AFI_IP ? "" : "v6", VTY_NEWLINE);
2854 vty_out (vty, "!%s", VTY_NEWLINE);
2855 }
2856
2857 for (plist = master->num.head; plist; plist = plist->next)
2858 {
2859 if (plist->desc)
2860 {
2861 vty_out (vty, "ip%s prefix-list %s description %s%s",
2862 afi == AFI_IP ? "" : "v6",
2863 plist->name, plist->desc, VTY_NEWLINE);
2864 write++;
2865 }
2866
2867 for (pentry = plist->head; pentry; pentry = pentry->next)
2868 {
2869 vty_out (vty, "ip%s prefix-list %s ",
2870 afi == AFI_IP ? "" : "v6",
2871 plist->name);
2872
2873 if (master->seqnum)
2874 vty_out (vty, "seq %u ", pentry->seq);
2875
2876 vty_out (vty, "%s ", prefix_list_type_str (pentry));
2877
2878 if (pentry->any)
2879 vty_out (vty, "any");
2880 else
2881 {
2882 struct prefix *p = &pentry->prefix;
2883 char buf[BUFSIZ];
2884
2885 vty_out (vty, "%s/%d",
2886 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
2887 p->prefixlen);
2888
2889 if (pentry->ge)
2890 vty_out (vty, " ge %d", pentry->ge);
2891 if (pentry->le)
2892 vty_out (vty, " le %d", pentry->le);
2893 }
2894 vty_out (vty, "%s", VTY_NEWLINE);
2895 write++;
2896 }
2897 /* vty_out (vty, "!%s", VTY_NEWLINE); */
2898 }
2899
2900 for (plist = master->str.head; plist; plist = plist->next)
2901 {
2902 if (plist->desc)
2903 {
2904 vty_out (vty, "ip%s prefix-list %s description %s%s",
2905 afi == AFI_IP ? "" : "v6",
2906 plist->name, plist->desc, VTY_NEWLINE);
2907 write++;
2908 }
2909
2910 for (pentry = plist->head; pentry; pentry = pentry->next)
2911 {
2912 vty_out (vty, "ip%s prefix-list %s ",
2913 afi == AFI_IP ? "" : "v6",
2914 plist->name);
2915
2916 if (master->seqnum)
2917 vty_out (vty, "seq %u ", pentry->seq);
2918
2919 vty_out (vty, "%s", prefix_list_type_str (pentry));
2920
2921 if (pentry->any)
2922 vty_out (vty, " any");
2923 else
2924 {
2925 struct prefix *p = &pentry->prefix;
2926 char buf[BUFSIZ];
2927
2928 vty_out (vty, " %s/%d",
2929 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
2930 p->prefixlen);
2931
2932 if (pentry->ge)
2933 vty_out (vty, " ge %d", pentry->ge);
2934 if (pentry->le)
2935 vty_out (vty, " le %d", pentry->le);
2936 }
2937 vty_out (vty, "%s", VTY_NEWLINE);
2938 write++;
2939 }
2940 }
2941
2942 return write;
2943 }
2944
2945 struct stream *
2946 prefix_bgp_orf_entry (struct stream *s, struct prefix_list *plist,
2947 u_char init_flag, u_char permit_flag, u_char deny_flag)
2948 {
2949 struct prefix_list_entry *pentry;
2950
2951 if (! plist)
2952 return s;
2953
2954 for (pentry = plist->head; pentry; pentry = pentry->next)
2955 {
2956 u_char flag = init_flag;
2957 struct prefix *p = &pentry->prefix;
2958
2959 flag |= (pentry->type == PREFIX_PERMIT ?
2960 permit_flag : deny_flag);
2961 stream_putc (s, flag);
2962 stream_putl (s, (u_int32_t)pentry->seq);
2963 stream_putc (s, (u_char)pentry->ge);
2964 stream_putc (s, (u_char)pentry->le);
2965 stream_put_prefix (s, p);
2966 }
2967
2968 return s;
2969 }
2970
2971 int
2972 prefix_bgp_orf_set (char *name, afi_t afi, struct orf_prefix *orfp,
2973 int permit, int set)
2974 {
2975 struct prefix_list *plist;
2976 struct prefix_list_entry *pentry;
2977
2978 /* ge and le value check */
2979 if (orfp->ge && orfp->ge <= orfp->p.prefixlen)
2980 return CMD_WARNING;
2981 if (orfp->le && orfp->le <= orfp->p.prefixlen)
2982 return CMD_WARNING;
2983 if (orfp->le && orfp->ge > orfp->le)
2984 return CMD_WARNING;
2985
2986 if (orfp->ge && orfp->le == (afi == AFI_IP ? 32 : 128))
2987 orfp->le = 0;
2988
2989 plist = prefix_list_get (afi, 1, name);
2990 if (! plist)
2991 return CMD_WARNING;
2992
2993 if (set)
2994 {
2995 pentry = prefix_list_entry_make (&orfp->p,
2996 (permit ? PREFIX_PERMIT : PREFIX_DENY),
2997 orfp->seq, orfp->le, orfp->ge, 0);
2998
2999 if (prefix_entry_dup_check (plist, pentry))
3000 {
3001 prefix_list_entry_free (pentry);
3002 return CMD_WARNING;
3003 }
3004
3005 prefix_list_entry_add (plist, pentry);
3006 }
3007 else
3008 {
3009 pentry = prefix_list_entry_lookup (plist, &orfp->p,
3010 (permit ? PREFIX_PERMIT : PREFIX_DENY),
3011 orfp->seq, orfp->le, orfp->ge);
3012
3013 if (! pentry)
3014 return CMD_WARNING;
3015
3016 prefix_list_entry_delete (plist, pentry, 1);
3017 }
3018
3019 return CMD_SUCCESS;
3020 }
3021
3022 void
3023 prefix_bgp_orf_remove_all (afi_t afi, char *name)
3024 {
3025 struct prefix_list *plist;
3026
3027 plist = prefix_bgp_orf_lookup (afi, name);
3028 if (plist)
3029 prefix_list_delete (plist);
3030 }
3031
3032 /* return prefix count */
3033 int
3034 prefix_bgp_show_prefix_list (struct vty *vty, afi_t afi, char *name, u_char use_json)
3035 {
3036 struct prefix_list *plist;
3037 struct prefix_list_entry *pentry;
3038 json_object *json = NULL;
3039 json_object *json_prefix = NULL;
3040 json_object *json_list = NULL;
3041
3042 plist = prefix_bgp_orf_lookup (afi, name);
3043 if (! plist)
3044 return 0;
3045
3046 if (! vty)
3047 return plist->count;
3048
3049 if(use_json)
3050 {
3051 json = json_object_new_object();
3052 json_prefix = json_object_new_object();
3053 json_list = json_object_new_object();
3054
3055 json_object_int_add(json_prefix, "prefixListCounter", plist->count);
3056 json_object_string_add(json_prefix, "prefixListName", plist->name);
3057
3058 for (pentry = plist->head; pentry; pentry = pentry->next)
3059 {
3060 struct prefix *p = &pentry->prefix;
3061 char buf_a[BUFSIZ];
3062 char buf_b[BUFSIZ];
3063
3064 sprintf(buf_a, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf_b, BUFSIZ),
3065 p->prefixlen);
3066
3067 json_object_int_add(json_list, "seq", pentry->seq);
3068 json_object_string_add(json_list, "seqPrefixListType", prefix_list_type_str (pentry));
3069
3070 if (pentry->ge)
3071 json_object_int_add(json_list, "ge", pentry->ge);
3072 if (pentry->le)
3073 json_object_int_add(json_list, "le", pentry->le);
3074
3075 json_object_object_add(json_prefix, buf_a, json_list);
3076 }
3077 if (afi == AFI_IP)
3078 json_object_object_add(json, "ipPrefixList", json_prefix);
3079 else
3080 json_object_object_add(json, "ipv6PrefixList", json_prefix);
3081
3082 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3083 json_object_free(json);
3084 }
3085 else
3086 {
3087 vty_out (vty, "ip%s prefix-list %s: %d entries%s",
3088 afi == AFI_IP ? "" : "v6",
3089 plist->name, plist->count, VTY_NEWLINE);
3090
3091 for (pentry = plist->head; pentry; pentry = pentry->next)
3092 {
3093 struct prefix *p = &pentry->prefix;
3094 char buf[BUFSIZ];
3095
3096 vty_out (vty, " seq %u %s %s/%d", pentry->seq,
3097 prefix_list_type_str (pentry),
3098 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
3099 p->prefixlen);
3100
3101 if (pentry->ge)
3102 vty_out (vty, " ge %d", pentry->ge);
3103 if (pentry->le)
3104 vty_out (vty, " le %d", pentry->le);
3105
3106 vty_out (vty, "%s", VTY_NEWLINE);
3107 }
3108 }
3109 return plist->count;
3110 }
3111
3112 static void
3113 prefix_list_reset_afi (afi_t afi, int orf)
3114 {
3115 struct prefix_list *plist;
3116 struct prefix_list *next;
3117 struct prefix_master *master;
3118
3119 master = prefix_master_get (afi, orf);
3120 if (master == NULL)
3121 return;
3122
3123 for (plist = master->num.head; plist; plist = next)
3124 {
3125 next = plist->next;
3126 prefix_list_delete (plist);
3127 }
3128 for (plist = master->str.head; plist; plist = next)
3129 {
3130 next = plist->next;
3131 prefix_list_delete (plist);
3132 }
3133
3134 assert (master->num.head == NULL);
3135 assert (master->num.tail == NULL);
3136
3137 assert (master->str.head == NULL);
3138 assert (master->str.tail == NULL);
3139
3140 master->seqnum = 1;
3141 master->recent = NULL;
3142 }
3143
3144
3145 /* Prefix-list node. */
3146 static struct cmd_node prefix_node =
3147 {
3148 PREFIX_NODE,
3149 "", /* Prefix list has no interface. */
3150 1
3151 };
3152
3153 static int
3154 config_write_prefix_ipv4 (struct vty *vty)
3155 {
3156 return config_write_prefix_afi (AFI_IP, vty);
3157 }
3158
3159 static void
3160 prefix_list_init_ipv4 (void)
3161 {
3162 install_node (&prefix_node, config_write_prefix_ipv4);
3163
3164 install_element (CONFIG_NODE, &ip_prefix_list_cmd);
3165 install_element (CONFIG_NODE, &ip_prefix_list_ge_cmd);
3166 install_element (CONFIG_NODE, &ip_prefix_list_ge_le_cmd);
3167 install_element (CONFIG_NODE, &ip_prefix_list_le_cmd);
3168 install_element (CONFIG_NODE, &ip_prefix_list_le_ge_cmd);
3169 install_element (CONFIG_NODE, &ip_prefix_list_seq_cmd);
3170 install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_cmd);
3171 install_element (CONFIG_NODE, &ip_prefix_list_seq_ge_le_cmd);
3172 install_element (CONFIG_NODE, &ip_prefix_list_seq_le_cmd);
3173 install_element (CONFIG_NODE, &ip_prefix_list_seq_le_ge_cmd);
3174
3175 install_element (CONFIG_NODE, &no_ip_prefix_list_cmd);
3176 install_element (CONFIG_NODE, &no_ip_prefix_list_prefix_cmd);
3177 install_element (CONFIG_NODE, &no_ip_prefix_list_ge_cmd);
3178 install_element (CONFIG_NODE, &no_ip_prefix_list_ge_le_cmd);
3179 install_element (CONFIG_NODE, &no_ip_prefix_list_le_cmd);
3180 install_element (CONFIG_NODE, &no_ip_prefix_list_le_ge_cmd);
3181 install_element (CONFIG_NODE, &no_ip_prefix_list_seq_cmd);
3182 install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_cmd);
3183 install_element (CONFIG_NODE, &no_ip_prefix_list_seq_ge_le_cmd);
3184 install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_cmd);
3185 install_element (CONFIG_NODE, &no_ip_prefix_list_seq_le_ge_cmd);
3186
3187 install_element (CONFIG_NODE, &ip_prefix_list_description_cmd);
3188 install_element (CONFIG_NODE, &no_ip_prefix_list_description_cmd);
3189 install_element (CONFIG_NODE, &no_ip_prefix_list_description_comment_cmd);
3190
3191 install_element (CONFIG_NODE, &ip_prefix_list_sequence_number_cmd);
3192 install_element (CONFIG_NODE, &no_ip_prefix_list_sequence_number_cmd);
3193
3194 install_element (VIEW_NODE, &show_ip_prefix_list_cmd);
3195 install_element (VIEW_NODE, &show_ip_prefix_list_name_cmd);
3196 install_element (VIEW_NODE, &show_ip_prefix_list_name_seq_cmd);
3197 install_element (VIEW_NODE, &show_ip_prefix_list_prefix_cmd);
3198 install_element (VIEW_NODE, &show_ip_prefix_list_prefix_longer_cmd);
3199 install_element (VIEW_NODE, &show_ip_prefix_list_prefix_first_match_cmd);
3200 install_element (VIEW_NODE, &show_ip_prefix_list_summary_cmd);
3201 install_element (VIEW_NODE, &show_ip_prefix_list_summary_name_cmd);
3202 install_element (VIEW_NODE, &show_ip_prefix_list_detail_cmd);
3203 install_element (VIEW_NODE, &show_ip_prefix_list_detail_name_cmd);
3204
3205 install_element (ENABLE_NODE, &clear_ip_prefix_list_cmd);
3206 install_element (ENABLE_NODE, &clear_ip_prefix_list_name_cmd);
3207 install_element (ENABLE_NODE, &clear_ip_prefix_list_name_prefix_cmd);
3208 }
3209
3210 /* Prefix-list node. */
3211 static struct cmd_node prefix_ipv6_node =
3212 {
3213 PREFIX_IPV6_NODE,
3214 "", /* Prefix list has no interface. */
3215 1
3216 };
3217
3218 static int
3219 config_write_prefix_ipv6 (struct vty *vty)
3220 {
3221 return config_write_prefix_afi (AFI_IP6, vty);
3222 }
3223
3224 static void
3225 prefix_list_init_ipv6 (void)
3226 {
3227 install_node (&prefix_ipv6_node, config_write_prefix_ipv6);
3228
3229 install_element (CONFIG_NODE, &ipv6_prefix_list_cmd);
3230 install_element (CONFIG_NODE, &ipv6_prefix_list_ge_cmd);
3231 install_element (CONFIG_NODE, &ipv6_prefix_list_ge_le_cmd);
3232 install_element (CONFIG_NODE, &ipv6_prefix_list_le_cmd);
3233 install_element (CONFIG_NODE, &ipv6_prefix_list_le_ge_cmd);
3234 install_element (CONFIG_NODE, &ipv6_prefix_list_seq_cmd);
3235 install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_cmd);
3236 install_element (CONFIG_NODE, &ipv6_prefix_list_seq_ge_le_cmd);
3237 install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_cmd);
3238 install_element (CONFIG_NODE, &ipv6_prefix_list_seq_le_ge_cmd);
3239
3240 install_element (CONFIG_NODE, &no_ipv6_prefix_list_cmd);
3241 install_element (CONFIG_NODE, &no_ipv6_prefix_list_prefix_cmd);
3242 install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_cmd);
3243 install_element (CONFIG_NODE, &no_ipv6_prefix_list_ge_le_cmd);
3244 install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_cmd);
3245 install_element (CONFIG_NODE, &no_ipv6_prefix_list_le_ge_cmd);
3246 install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_cmd);
3247 install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_cmd);
3248 install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_ge_le_cmd);
3249 install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_cmd);
3250 install_element (CONFIG_NODE, &no_ipv6_prefix_list_seq_le_ge_cmd);
3251
3252 install_element (CONFIG_NODE, &ipv6_prefix_list_description_cmd);
3253 install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_cmd);
3254 install_element (CONFIG_NODE, &no_ipv6_prefix_list_description_comment_cmd);
3255
3256 install_element (CONFIG_NODE, &ipv6_prefix_list_sequence_number_cmd);
3257 install_element (CONFIG_NODE, &no_ipv6_prefix_list_sequence_number_cmd);
3258
3259 install_element (VIEW_NODE, &show_ipv6_prefix_list_cmd);
3260 install_element (VIEW_NODE, &show_ipv6_prefix_list_name_cmd);
3261 install_element (VIEW_NODE, &show_ipv6_prefix_list_name_seq_cmd);
3262 install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_cmd);
3263 install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_longer_cmd);
3264 install_element (VIEW_NODE, &show_ipv6_prefix_list_prefix_first_match_cmd);
3265 install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_cmd);
3266 install_element (VIEW_NODE, &show_ipv6_prefix_list_summary_name_cmd);
3267 install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_cmd);
3268 install_element (VIEW_NODE, &show_ipv6_prefix_list_detail_name_cmd);
3269
3270 install_element (ENABLE_NODE, &clear_ipv6_prefix_list_cmd);
3271 install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_cmd);
3272 install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_prefix_cmd);
3273 }
3274
3275 void
3276 prefix_list_init ()
3277 {
3278 prefix_list_init_ipv4 ();
3279 prefix_list_init_ipv6 ();
3280 }
3281
3282 void
3283 prefix_list_reset ()
3284 {
3285 prefix_list_reset_afi (AFI_IP, 0);
3286 prefix_list_reset_afi (AFI_IP6, 0);
3287 prefix_list_reset_afi (AFI_IP, 1);
3288 prefix_list_reset_afi (AFI_IP6, 1);
3289 }