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