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