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