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