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