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