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