]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* RIPng routemap. |
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 it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * 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 Free | |
18 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | * 02111-1307, USA. | |
20 | */ | |
21 | ||
22 | #include <zebra.h> | |
23 | ||
24 | #include "if.h" | |
25 | #include "memory.h" | |
26 | #include "prefix.h" | |
27 | #include "routemap.h" | |
28 | #include "command.h" | |
a94434b6 | 29 | #include "sockunion.h" |
718e3744 | 30 | |
31 | #include "ripngd/ripngd.h" | |
6b0655a2 | 32 | |
a94434b6 | 33 | struct rip_metric_modifier |
34 | { | |
35 | enum | |
36 | { | |
37 | metric_increment, | |
38 | metric_decrement, | |
39 | metric_absolute | |
40 | } type; | |
41 | ||
42 | u_char metric; | |
43 | }; | |
44 | ||
6b0655a2 | 45 | |
6ac29a51 | 46 | static int |
a94434b6 | 47 | ripng_route_match_add (struct vty *vty, struct route_map_index *index, |
98b718a9 | 48 | const char *command, const char *arg) |
a94434b6 | 49 | { |
50 | int ret; | |
51 | ||
52 | ret = route_map_add_match (index, command, arg); | |
53 | if (ret) | |
54 | { | |
55 | switch (ret) | |
56 | { | |
57 | case RMAP_RULE_MISSING: | |
5e3edbf5 | 58 | vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); |
a94434b6 | 59 | return CMD_WARNING; |
a94434b6 | 60 | case RMAP_COMPILE_ERROR: |
5e3edbf5 | 61 | vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); |
a94434b6 | 62 | return CMD_WARNING; |
a94434b6 | 63 | } |
64 | } | |
65 | return CMD_SUCCESS; | |
66 | } | |
67 | ||
6ac29a51 | 68 | static int |
a94434b6 | 69 | ripng_route_match_delete (struct vty *vty, struct route_map_index *index, |
98b718a9 | 70 | const char *command, const char *arg) |
a94434b6 | 71 | { |
72 | int ret; | |
73 | ||
74 | ret = route_map_delete_match (index, command, arg); | |
75 | if (ret) | |
76 | { | |
77 | switch (ret) | |
78 | { | |
79 | case RMAP_RULE_MISSING: | |
5e3edbf5 | 80 | vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); |
a94434b6 | 81 | return CMD_WARNING; |
a94434b6 | 82 | case RMAP_COMPILE_ERROR: |
5e3edbf5 | 83 | vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); |
a94434b6 | 84 | return CMD_WARNING; |
a94434b6 | 85 | } |
86 | } | |
87 | return CMD_SUCCESS; | |
88 | } | |
89 | ||
6ac29a51 | 90 | static int |
a94434b6 | 91 | ripng_route_set_add (struct vty *vty, struct route_map_index *index, |
98b718a9 | 92 | const char *command, const char *arg) |
a94434b6 | 93 | { |
94 | int ret; | |
95 | ||
96 | ret = route_map_add_set (index, command, arg); | |
97 | if (ret) | |
98 | { | |
99 | switch (ret) | |
100 | { | |
101 | case RMAP_RULE_MISSING: | |
5e3edbf5 | 102 | vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); |
a94434b6 | 103 | return CMD_WARNING; |
a94434b6 | 104 | case RMAP_COMPILE_ERROR: |
5e3edbf5 | 105 | vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); |
a94434b6 | 106 | return CMD_WARNING; |
a94434b6 | 107 | } |
108 | } | |
109 | return CMD_SUCCESS; | |
110 | } | |
111 | ||
6ac29a51 | 112 | static int |
a94434b6 | 113 | ripng_route_set_delete (struct vty *vty, struct route_map_index *index, |
98b718a9 | 114 | const char *command, const char *arg) |
a94434b6 | 115 | { |
116 | int ret; | |
117 | ||
118 | ret = route_map_delete_set (index, command, arg); | |
119 | if (ret) | |
120 | { | |
121 | switch (ret) | |
122 | { | |
123 | case RMAP_RULE_MISSING: | |
5e3edbf5 | 124 | vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); |
a94434b6 | 125 | return CMD_WARNING; |
a94434b6 | 126 | case RMAP_COMPILE_ERROR: |
5e3edbf5 | 127 | vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); |
a94434b6 | 128 | return CMD_WARNING; |
a94434b6 | 129 | } |
130 | } | |
131 | return CMD_SUCCESS; | |
132 | } | |
6b0655a2 | 133 | |
a94434b6 | 134 | /* `match metric METRIC' */ |
135 | /* Match function return 1 if match is success else return zero. */ | |
6ac29a51 | 136 | static route_map_result_t |
a94434b6 | 137 | route_match_metric (void *rule, struct prefix *prefix, |
138 | route_map_object_t type, void *object) | |
139 | { | |
140 | u_int32_t *metric; | |
141 | struct ripng_info *rinfo; | |
142 | ||
143 | if (type == RMAP_RIPNG) | |
144 | { | |
145 | metric = rule; | |
146 | rinfo = object; | |
147 | ||
148 | if (rinfo->metric == *metric) | |
149 | return RMAP_MATCH; | |
150 | else | |
151 | return RMAP_NOMATCH; | |
152 | } | |
153 | return RMAP_NOMATCH; | |
154 | } | |
155 | ||
156 | /* Route map `match metric' match statement. `arg' is METRIC value */ | |
6ac29a51 | 157 | static void * |
98b718a9 | 158 | route_match_metric_compile (const char *arg) |
a94434b6 | 159 | { |
160 | u_int32_t *metric; | |
161 | ||
162 | metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); | |
163 | *metric = atoi (arg); | |
164 | ||
165 | if(*metric > 0) | |
166 | return metric; | |
167 | ||
168 | XFREE (MTYPE_ROUTE_MAP_COMPILED, metric); | |
169 | return NULL; | |
170 | } | |
171 | ||
172 | /* Free route map's compiled `match metric' value. */ | |
6ac29a51 | 173 | static void |
a94434b6 | 174 | route_match_metric_free (void *rule) |
175 | { | |
176 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); | |
177 | } | |
178 | ||
179 | /* Route map commands for metric matching. */ | |
6ac29a51 | 180 | static struct route_map_rule_cmd route_match_metric_cmd = |
a94434b6 | 181 | { |
182 | "metric", | |
183 | route_match_metric, | |
184 | route_match_metric_compile, | |
185 | route_match_metric_free | |
186 | }; | |
6b0655a2 | 187 | |
718e3744 | 188 | /* `match interface IFNAME' */ |
a94434b6 | 189 | /* Match function return 1 if match is success else return zero. */ |
6ac29a51 | 190 | static route_map_result_t |
718e3744 | 191 | route_match_interface (void *rule, struct prefix *prefix, |
192 | route_map_object_t type, void *object) | |
193 | { | |
194 | struct ripng_info *rinfo; | |
195 | struct interface *ifp; | |
196 | char *ifname; | |
197 | ||
a94434b6 | 198 | if (type == RMAP_RIPNG) |
718e3744 | 199 | { |
200 | ifname = rule; | |
201 | ifp = if_lookup_by_name(ifname); | |
202 | ||
203 | if (!ifp) | |
a94434b6 | 204 | return RMAP_NOMATCH; |
718e3744 | 205 | |
206 | rinfo = object; | |
207 | ||
208 | if (rinfo->ifindex == ifp->ifindex) | |
a94434b6 | 209 | return RMAP_MATCH; |
718e3744 | 210 | else |
a94434b6 | 211 | return RMAP_NOMATCH; |
718e3744 | 212 | } |
a94434b6 | 213 | return RMAP_NOMATCH; |
718e3744 | 214 | } |
215 | ||
a94434b6 | 216 | /* Route map `match interface' match statement. `arg' is IFNAME value */ |
6ac29a51 | 217 | static void * |
98b718a9 | 218 | route_match_interface_compile (const char *arg) |
718e3744 | 219 | { |
220 | return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg); | |
221 | } | |
222 | ||
6ac29a51 | 223 | static void |
718e3744 | 224 | route_match_interface_free (void *rule) |
225 | { | |
226 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); | |
227 | } | |
228 | ||
6ac29a51 | 229 | static struct route_map_rule_cmd route_match_interface_cmd = |
718e3744 | 230 | { |
231 | "interface", | |
232 | route_match_interface, | |
233 | route_match_interface_compile, | |
234 | route_match_interface_free | |
235 | }; | |
a94434b6 | 236 | |
237 | /* `match tag TAG' */ | |
238 | /* Match function return 1 if match is success else return zero. */ | |
6ac29a51 | 239 | static route_map_result_t |
a94434b6 | 240 | route_match_tag (void *rule, struct prefix *prefix, |
241 | route_map_object_t type, void *object) | |
718e3744 | 242 | { |
a94434b6 | 243 | u_short *tag; |
244 | struct ripng_info *rinfo; | |
718e3744 | 245 | |
a94434b6 | 246 | if (type == RMAP_RIPNG) |
247 | { | |
248 | tag = rule; | |
249 | rinfo = object; | |
250 | ||
251 | /* The information stored by rinfo is host ordered. */ | |
252 | if (rinfo->tag == *tag) | |
253 | return RMAP_MATCH; | |
254 | else | |
255 | return RMAP_NOMATCH; | |
256 | } | |
257 | return RMAP_NOMATCH; | |
258 | } | |
259 | ||
260 | /* Route map `match tag' match statement. `arg' is TAG value */ | |
6ac29a51 | 261 | static void * |
98b718a9 | 262 | route_match_tag_compile (const char *arg) |
a94434b6 | 263 | { |
264 | u_short *tag; | |
265 | ||
266 | tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short)); | |
267 | *tag = atoi (arg); | |
268 | ||
269 | return tag; | |
270 | } | |
271 | ||
272 | /* Free route map's compiled `match tag' value. */ | |
6ac29a51 | 273 | static void |
a94434b6 | 274 | route_match_tag_free (void *rule) |
275 | { | |
276 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); | |
277 | } | |
278 | ||
279 | /* Route map commands for tag matching. */ | |
6ac29a51 | 280 | static struct route_map_rule_cmd route_match_tag_cmd = |
a94434b6 | 281 | { |
282 | "tag", | |
283 | route_match_tag, | |
284 | route_match_tag_compile, | |
285 | route_match_tag_free | |
718e3744 | 286 | }; |
6b0655a2 | 287 | |
a94434b6 | 288 | /* `set metric METRIC' */ |
718e3744 | 289 | |
a94434b6 | 290 | /* Set metric to attribute. */ |
6ac29a51 | 291 | static route_map_result_t |
718e3744 | 292 | route_set_metric (void *rule, struct prefix *prefix, |
293 | route_map_object_t type, void *object) | |
294 | { | |
295 | if (type == RMAP_RIPNG) | |
296 | { | |
297 | struct rip_metric_modifier *mod; | |
298 | struct ripng_info *rinfo; | |
299 | ||
300 | mod = rule; | |
301 | rinfo = object; | |
302 | ||
303 | if (mod->type == metric_increment) | |
a94434b6 | 304 | rinfo->metric_out += mod->metric; |
718e3744 | 305 | else if (mod->type == metric_decrement) |
a94434b6 | 306 | rinfo->metric_out-= mod->metric; |
718e3744 | 307 | else if (mod->type == metric_absolute) |
a94434b6 | 308 | rinfo->metric_out = mod->metric; |
718e3744 | 309 | |
a94434b6 | 310 | if (rinfo->metric_out < 1) |
311 | rinfo->metric_out = 1; | |
312 | if (rinfo->metric_out > RIPNG_METRIC_INFINITY) | |
313 | rinfo->metric_out = RIPNG_METRIC_INFINITY; | |
718e3744 | 314 | |
315 | rinfo->metric_set = 1; | |
316 | } | |
317 | return RMAP_OKAY; | |
318 | } | |
319 | ||
a94434b6 | 320 | /* set metric compilation. */ |
6ac29a51 | 321 | static void * |
98b718a9 | 322 | route_set_metric_compile (const char *arg) |
718e3744 | 323 | { |
324 | int len; | |
98b718a9 | 325 | const char *pnt; |
718e3744 | 326 | int type; |
327 | long metric; | |
328 | char *endptr = NULL; | |
329 | struct rip_metric_modifier *mod; | |
330 | ||
331 | len = strlen (arg); | |
332 | pnt = arg; | |
333 | ||
334 | if (len == 0) | |
335 | return NULL; | |
336 | ||
337 | /* Examine first character. */ | |
338 | if (arg[0] == '+') | |
339 | { | |
340 | type = metric_increment; | |
341 | pnt++; | |
342 | } | |
343 | else if (arg[0] == '-') | |
344 | { | |
345 | type = metric_decrement; | |
346 | pnt++; | |
347 | } | |
348 | else | |
349 | type = metric_absolute; | |
350 | ||
351 | /* Check beginning with digit string. */ | |
352 | if (*pnt < '0' || *pnt > '9') | |
353 | return NULL; | |
354 | ||
355 | /* Convert string to integer. */ | |
356 | metric = strtol (pnt, &endptr, 10); | |
357 | ||
358 | if (metric == LONG_MAX || *endptr != '\0') | |
359 | return NULL; | |
73ffb25b | 360 | /* Commented out by Hasso Tepper, to avoid problems in vtysh. */ |
361 | /* if (metric < 0 || metric > RIPNG_METRIC_INFINITY) */ | |
362 | if (metric < 0) | |
718e3744 | 363 | return NULL; |
364 | ||
365 | mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, | |
366 | sizeof (struct rip_metric_modifier)); | |
367 | mod->type = type; | |
368 | mod->metric = metric; | |
369 | ||
370 | return mod; | |
371 | } | |
372 | ||
a94434b6 | 373 | /* Free route map's compiled `set metric' value. */ |
6ac29a51 | 374 | static void |
718e3744 | 375 | route_set_metric_free (void *rule) |
376 | { | |
377 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); | |
378 | } | |
379 | ||
6ac29a51 | 380 | static struct route_map_rule_cmd route_set_metric_cmd = |
718e3744 | 381 | { |
382 | "metric", | |
383 | route_set_metric, | |
384 | route_set_metric_compile, | |
385 | route_set_metric_free, | |
386 | }; | |
a94434b6 | 387 | |
388 | /* `set ipv6 next-hop local IP_ADDRESS' */ | |
389 | ||
390 | /* Set nexthop to object. ojbect must be pointer to struct attr. */ | |
6ac29a51 | 391 | static route_map_result_t |
a94434b6 | 392 | route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, |
393 | route_map_object_t type, void *object) | |
718e3744 | 394 | { |
a94434b6 | 395 | struct in6_addr *address; |
396 | struct ripng_info *rinfo; | |
718e3744 | 397 | |
a94434b6 | 398 | if(type == RMAP_RIPNG) |
718e3744 | 399 | { |
a94434b6 | 400 | /* Fetch routemap's rule information. */ |
401 | address = rule; | |
402 | rinfo = object; | |
403 | ||
404 | /* Set next hop value. */ | |
405 | rinfo->nexthop_out = *address; | |
718e3744 | 406 | } |
a94434b6 | 407 | |
408 | return RMAP_OKAY; | |
718e3744 | 409 | } |
410 | ||
a94434b6 | 411 | /* Route map `ipv6 nexthop local' compile function. Given string is converted |
412 | to struct in6_addr structure. */ | |
6ac29a51 | 413 | static void * |
98b718a9 | 414 | route_set_ipv6_nexthop_local_compile (const char *arg) |
718e3744 | 415 | { |
416 | int ret; | |
a94434b6 | 417 | struct in6_addr *address; |
718e3744 | 418 | |
7a559cbe | 419 | address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in6_addr)); |
a94434b6 | 420 | |
421 | ret = inet_pton (AF_INET6, arg, address); | |
422 | ||
423 | if (ret == 0) | |
718e3744 | 424 | { |
a94434b6 | 425 | XFREE (MTYPE_ROUTE_MAP_COMPILED, address); |
426 | return NULL; | |
718e3744 | 427 | } |
a94434b6 | 428 | |
429 | return address; | |
718e3744 | 430 | } |
431 | ||
a94434b6 | 432 | /* Free route map's compiled `ipv6 nexthop local' value. */ |
6ac29a51 | 433 | static void |
a94434b6 | 434 | route_set_ipv6_nexthop_local_free (void *rule) |
718e3744 | 435 | { |
a94434b6 | 436 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); |
437 | } | |
718e3744 | 438 | |
a94434b6 | 439 | /* Route map commands for ipv6 nexthop local set. */ |
6ac29a51 | 440 | static struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = |
a94434b6 | 441 | { |
442 | "ipv6 next-hop local", | |
443 | route_set_ipv6_nexthop_local, | |
444 | route_set_ipv6_nexthop_local_compile, | |
445 | route_set_ipv6_nexthop_local_free | |
446 | }; | |
447 | ||
448 | /* `set tag TAG' */ | |
449 | ||
450 | /* Set tag to object. ojbect must be pointer to struct attr. */ | |
6ac29a51 | 451 | static route_map_result_t |
a94434b6 | 452 | route_set_tag (void *rule, struct prefix *prefix, |
453 | route_map_object_t type, void *object) | |
454 | { | |
455 | u_short *tag; | |
456 | struct ripng_info *rinfo; | |
457 | ||
458 | if(type == RMAP_RIPNG) | |
718e3744 | 459 | { |
a94434b6 | 460 | /* Fetch routemap's rule information. */ |
461 | tag = rule; | |
462 | rinfo = object; | |
463 | ||
464 | /* Set next hop value. */ | |
465 | rinfo->tag_out = *tag; | |
718e3744 | 466 | } |
a94434b6 | 467 | |
468 | return RMAP_OKAY; | |
718e3744 | 469 | } |
470 | ||
a94434b6 | 471 | /* Route map `tag' compile function. Given string is converted |
472 | to u_short. */ | |
6ac29a51 | 473 | static void * |
98b718a9 | 474 | route_set_tag_compile (const char *arg) |
718e3744 | 475 | { |
a94434b6 | 476 | u_short *tag; |
718e3744 | 477 | |
a94434b6 | 478 | tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short)); |
479 | *tag = atoi (arg); | |
480 | ||
481 | return tag; | |
482 | } | |
483 | ||
484 | /* Free route map's compiled `ip nexthop' value. */ | |
6ac29a51 | 485 | static void |
a94434b6 | 486 | route_set_tag_free (void *rule) |
487 | { | |
488 | XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); | |
718e3744 | 489 | } |
a94434b6 | 490 | |
491 | /* Route map commands for tag set. */ | |
6ac29a51 | 492 | static struct route_map_rule_cmd route_set_tag_cmd = |
a94434b6 | 493 | { |
494 | "tag", | |
495 | route_set_tag, | |
496 | route_set_tag_compile, | |
497 | route_set_tag_free | |
498 | }; | |
6b0655a2 | 499 | |
a94434b6 | 500 | #define MATCH_STR "Match values from routing table\n" |
501 | #define SET_STR "Set values in destination routing protocol\n" | |
502 | ||
f412b39a | 503 | DEFUN (match_metric, |
a94434b6 | 504 | match_metric_cmd, |
6147e2c6 | 505 | "match metric (0-4294967295)", |
a94434b6 | 506 | MATCH_STR |
507 | "Match metric of route\n" | |
508 | "Metric value\n") | |
509 | { | |
dd4f9f99 | 510 | return ripng_route_match_add (vty, vty->index, "metric", argv[2]->arg); |
a94434b6 | 511 | } |
512 | ||
f412b39a DW |
513 | /* |
514 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
515 | * "no match metric <0-4294967295>", | |
516 | * NO_STR | |
517 | * MATCH_STR | |
518 | * "Match metric of route\n" | |
519 | * "Metric value\n" | |
520 | * | |
521 | */ | |
a94434b6 | 522 | DEFUN (no_match_metric, |
523 | no_match_metric_cmd, | |
524 | "no match metric", | |
525 | NO_STR | |
526 | MATCH_STR | |
527 | "Match metric of route\n") | |
528 | { | |
dd4f9f99 | 529 | return ripng_route_match_delete (vty, vty->index, "metric", argv[3]->arg); |
a94434b6 | 530 | } |
531 | ||
a94434b6 | 532 | |
718e3744 | 533 | DEFUN (match_interface, |
534 | match_interface_cmd, | |
535 | "match interface WORD", | |
a94434b6 | 536 | MATCH_STR |
537 | "Match first hop interface of route\n" | |
718e3744 | 538 | "Interface name\n") |
539 | { | |
dd4f9f99 | 540 | return ripng_route_match_add (vty, vty->index, "interface", argv[2]->arg); |
718e3744 | 541 | } |
542 | ||
f412b39a DW |
543 | /* |
544 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
545 | * "no match interface WORD", | |
546 | * NO_STR | |
547 | * MATCH_STR | |
548 | * "Match first hop interface of route\n" | |
549 | * "Interface name\n" | |
550 | * | |
551 | */ | |
718e3744 | 552 | DEFUN (no_match_interface, |
553 | no_match_interface_cmd, | |
a94434b6 | 554 | "no match interface", |
555 | NO_STR | |
556 | MATCH_STR | |
557 | "Match first hop interface of route\n") | |
558 | { | |
dd4f9f99 | 559 | return ripng_route_match_delete (vty, vty->index, "interface", argv[3]->arg); |
a94434b6 | 560 | } |
561 | ||
a94434b6 | 562 | |
563 | DEFUN (match_tag, | |
564 | match_tag_cmd, | |
6147e2c6 | 565 | "match tag (1-65535)", |
a94434b6 | 566 | MATCH_STR |
567 | "Match tag of route\n" | |
568 | "Metric value\n") | |
718e3744 | 569 | { |
dd4f9f99 | 570 | return ripng_route_match_add (vty, vty->index, "tag", argv[2]->arg); |
a94434b6 | 571 | } |
572 | ||
f412b39a DW |
573 | /* |
574 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
575 | * "no match tag <1-65535>", | |
576 | * NO_STR | |
577 | * MATCH_STR | |
578 | * "Match tag of route\n" | |
579 | * "Metric value\n" | |
580 | * | |
581 | */ | |
a94434b6 | 582 | DEFUN (no_match_tag, |
583 | no_match_tag_cmd, | |
584 | "no match tag", | |
585 | NO_STR | |
586 | MATCH_STR | |
587 | "Match tag of route\n") | |
588 | { | |
dd4f9f99 | 589 | return ripng_route_match_delete (vty, vty->index, "tag", argv[3]->arg); |
718e3744 | 590 | } |
a94434b6 | 591 | |
a94434b6 | 592 | |
593 | /* set functions */ | |
718e3744 | 594 | |
595 | DEFUN (set_metric, | |
596 | set_metric_cmd, | |
6147e2c6 | 597 | "set metric (0-4294967295)", |
718e3744 | 598 | "Set value\n" |
a94434b6 | 599 | "Metric value for destination routing protocol\n" |
600 | "Metric value\n") | |
718e3744 | 601 | { |
dd4f9f99 | 602 | return ripng_route_set_add (vty, vty->index, "metric", argv[2]->arg); |
718e3744 | 603 | } |
604 | ||
f412b39a DW |
605 | /* |
606 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
607 | * "no set metric <0-4294967295>", | |
608 | * NO_STR | |
609 | * SET_STR | |
610 | * "Metric value for destination routing protocol\n" | |
611 | * "Metric value\n" | |
612 | * | |
613 | */ | |
718e3744 | 614 | DEFUN (no_set_metric, |
615 | no_set_metric_cmd, | |
73ffb25b | 616 | "no set metric", |
718e3744 | 617 | NO_STR |
73ffb25b | 618 | SET_STR |
619 | "Metric value for destination routing protocol\n") | |
718e3744 | 620 | { |
dd4f9f99 | 621 | return ripng_route_set_delete (vty, vty->index, "metric", argv[3]->arg); |
718e3744 | 622 | } |
623 | ||
73ffb25b | 624 | |
a94434b6 | 625 | DEFUN (set_ipv6_nexthop_local, |
626 | set_ipv6_nexthop_local_cmd, | |
627 | "set ipv6 next-hop local X:X::X:X", | |
628 | SET_STR | |
629 | IPV6_STR | |
630 | "IPv6 next-hop address\n" | |
631 | "IPv6 local address\n" | |
632 | "IPv6 address of next hop\n") | |
633 | { | |
634 | union sockunion su; | |
635 | int ret; | |
636 | ||
dd4f9f99 | 637 | ret = str2sockunion (argv[4]->arg, &su); |
a94434b6 | 638 | if (ret < 0) |
639 | { | |
640 | vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE); | |
641 | return CMD_WARNING; | |
642 | } | |
643 | ||
bf8b3d27 DS |
644 | if (!IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr)) |
645 | { | |
646 | vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); | |
647 | return CMD_WARNING; | |
648 | } | |
649 | ||
dd4f9f99 | 650 | return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[4]->arg); |
a94434b6 | 651 | } |
652 | ||
f412b39a DW |
653 | /* |
654 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
655 | * "no set ipv6 next-hop local X:X::X:X", | |
656 | * NO_STR | |
657 | * SET_STR | |
658 | * IPV6_STR | |
659 | * "IPv6 next-hop address\n" | |
660 | * "IPv6 local address\n" | |
661 | * "IPv6 address of next hop\n" | |
662 | * | |
663 | */ | |
a94434b6 | 664 | DEFUN (no_set_ipv6_nexthop_local, |
665 | no_set_ipv6_nexthop_local_cmd, | |
666 | "no set ipv6 next-hop local", | |
667 | NO_STR | |
668 | SET_STR | |
669 | IPV6_STR | |
670 | "IPv6 next-hop address\n" | |
671 | "IPv6 local address\n") | |
672 | { | |
dd4f9f99 | 673 | return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[5]->arg); |
a94434b6 | 674 | } |
675 | ||
a94434b6 | 676 | |
677 | DEFUN (set_tag, | |
678 | set_tag_cmd, | |
6147e2c6 | 679 | "set tag (1-65535)", |
a94434b6 | 680 | SET_STR |
681 | "Tag value for routing protocol\n" | |
682 | "Tag value\n") | |
683 | { | |
dd4f9f99 | 684 | return ripng_route_set_add (vty, vty->index, "tag", argv[2]->arg); |
a94434b6 | 685 | } |
686 | ||
f412b39a DW |
687 | /* |
688 | * CHECK ME - The following ALIASes need to be implemented in this DEFUN | |
689 | * "no set tag <1-65535>", | |
690 | * NO_STR | |
691 | * SET_STR | |
692 | * "Tag value for routing protocol\n" | |
693 | * "Tag value\n" | |
694 | * | |
695 | */ | |
a94434b6 | 696 | DEFUN (no_set_tag, |
697 | no_set_tag_cmd, | |
698 | "no set tag", | |
699 | NO_STR | |
700 | SET_STR | |
701 | "Tag value for routing protocol\n") | |
702 | { | |
dd4f9f99 | 703 | return ripng_route_set_delete (vty, vty->index, "tag", argv[3]->arg); |
a94434b6 | 704 | } |
705 | ||
a94434b6 | 706 | |
707 | void | |
708 | ripng_route_map_reset () | |
709 | { | |
710 | /* XXX ??? */ | |
711 | ; | |
712 | } | |
713 | ||
718e3744 | 714 | void |
715 | ripng_route_map_init () | |
716 | { | |
717 | route_map_init (); | |
718 | route_map_init_vty (); | |
719 | ||
a94434b6 | 720 | route_map_install_match (&route_match_metric_cmd); |
721 | route_map_install_match (&route_match_interface_cmd); | |
722 | route_map_install_match (&route_match_tag_cmd); | |
723 | ||
718e3744 | 724 | route_map_install_set (&route_set_metric_cmd); |
a94434b6 | 725 | route_map_install_set (&route_set_ipv6_nexthop_local_cmd); |
726 | route_map_install_set (&route_set_tag_cmd); | |
718e3744 | 727 | |
a94434b6 | 728 | install_element (RMAP_NODE, &match_metric_cmd); |
729 | install_element (RMAP_NODE, &no_match_metric_cmd); | |
718e3744 | 730 | install_element (RMAP_NODE, &match_interface_cmd); |
731 | install_element (RMAP_NODE, &no_match_interface_cmd); | |
a94434b6 | 732 | install_element (RMAP_NODE, &match_tag_cmd); |
733 | install_element (RMAP_NODE, &no_match_tag_cmd); | |
718e3744 | 734 | |
735 | install_element (RMAP_NODE, &set_metric_cmd); | |
736 | install_element (RMAP_NODE, &no_set_metric_cmd); | |
a94434b6 | 737 | install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); |
738 | install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); | |
a94434b6 | 739 | install_element (RMAP_NODE, &set_tag_cmd); |
740 | install_element (RMAP_NODE, &no_set_tag_cmd); | |
718e3744 | 741 | } |