2 * EIGRP Filter Functions.
3 * Copyright (C) 2013-2015
15 * Note: This file contains skeleton for all possible matches and sets,
16 * but they are hidden in comment block and not properly implemented.
17 * At this time, the only function we consider useful for our use
18 * in distribute command in EIGRP is matching destination IP (with both
19 * access and prefix list).
22 * This file is part of GNU Zebra.
24 * GNU Zebra is free software; you can redistribute it and/or modify it
25 * under the terms of the GNU General Public License as published by the
26 * Free Software Foundation; either version 2, or (at your option) any
29 * GNU Zebra is distributed in the hope that it will be useful, but
30 * WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 * General Public License for more details.
34 * You should have received a copy of the GNU General Public License along
35 * with this program; see the file COPYING; if not, write to the Free Software
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
48 #include "sockunion.h" /* for inet_aton () */
51 #include "eigrpd/eigrpd.h"
52 #include "eigrpd/eigrp_structs.h"
53 #include "eigrpd/eigrp_const.h"
54 #include "eigrpd/eigrp_macros.h"
55 #include "eigrpd/eigrp_routemap.h"
57 void eigrp_if_rmap_update(struct if_rmap
*if_rmap
)
59 struct interface
*ifp
;
60 struct eigrp_interface
*ei
, *ei2
;
61 struct listnode
*node
, *nnode
;
62 struct route_map
*rmap
;
65 ifp
= if_lookup_by_name(if_rmap
->ifname
);
71 for (ALL_LIST_ELEMENTS(e
->eiflist
, node
, nnode
, ei2
)) {
72 if (strcmp(ei2
->ifp
->name
, ifp
->name
) == 0) {
78 if (if_rmap
->routemap
[IF_RMAP_IN
]) {
79 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_IN
]);
81 ei
->routemap
[IF_RMAP_IN
] = rmap
;
83 ei
->routemap
[IF_RMAP_IN
] = NULL
;
85 ei
->routemap
[EIGRP_FILTER_IN
] = NULL
;
87 if (if_rmap
->routemap
[IF_RMAP_OUT
]) {
88 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_OUT
]);
90 ei
->routemap
[IF_RMAP_OUT
] = rmap
;
92 ei
->routemap
[IF_RMAP_OUT
] = NULL
;
94 ei
->routemap
[EIGRP_FILTER_OUT
] = NULL
;
97 void eigrp_if_rmap_update_interface(struct interface
*ifp
)
99 struct if_rmap
*if_rmap
;
101 if_rmap
= if_rmap_lookup(ifp
->name
);
103 eigrp_if_rmap_update(if_rmap
);
106 void eigrp_routemap_update_redistribute(void)
114 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
115 if (e
->route_map
[i
].name
)
116 e
->route_map
[i
].map
= route_map_lookup_by_name(
117 e
->route_map
[i
].name
);
123 void eigrp_rmap_update(const char *notused
)
125 struct interface
*ifp
;
126 struct listnode
*node
, *nnode
;
128 for (ALL_LIST_ELEMENTS(iflist
, node
, nnode
, ifp
))
129 eigrp_if_rmap_update_interface(ifp
);
131 eigrp_routemap_update_redistribute();
134 /* Add eigrp route map rule. */
135 static int eigrp_route_match_add(struct vty
*vty
, struct route_map_index
*index
,
136 const char *command
, const char *arg
)
139 ret
= route_map_add_match(index
, command
, arg
, type
);
141 case RMAP_RULE_MISSING
:
142 vty_out(vty
, "%% Can't find rule.\n");
143 return CMD_WARNING_CONFIG_FAILED
;
145 case RMAP_COMPILE_ERROR
:
146 vty_out(vty
, "%% Argument is malformed.\n");
147 return CMD_WARNING_CONFIG_FAILED
;
149 case RMAP_COMPILE_SUCCESS
:
156 /* Delete rip route map rule. */
157 static int eigrp_route_match_delete(struct vty
*vty
,
158 struct route_map_index
*index
,
159 const char *command
, const char *arg
)
162 ret
= route_map_delete_match(index
, command
, arg
);
164 case RMAP_RULE_MISSING
:
165 vty_out(vty
, "%% Can't find rule.\n");
166 return CMD_WARNING_CONFIG_FAILED
;
168 case RMAP_COMPILE_ERROR
:
169 vty_out(vty
, "%% Argument is malformed.\n");
170 return CMD_WARNING_CONFIG_FAILED
;
172 case RMAP_COMPILE_SUCCESS
:
179 /* Add eigrp route map rule. */
180 static int eigrp_route_set_add(struct vty
*vty
, struct route_map_index
*index
,
181 const char *command
, const char *arg
)
185 ret
= route_map_add_set(index
, command
, arg
);
187 case RMAP_RULE_MISSING
:
188 vty_out(vty
, "%% Can't find rule.\n");
189 return CMD_WARNING_CONFIG_FAILED
;
191 case RMAP_COMPILE_ERROR
:
193 * rip, ripng and other protocols share the set metric command
194 * but only values from 0 to 16 are valid for rip and ripng
195 * if metric is out of range for rip and ripng, it is
196 * not for other protocols. Do not return an error
198 if (strcmp(command
, "metric")) {
199 vty_out(vty
, "%% Argument is malformed.\n");
200 return CMD_WARNING_CONFIG_FAILED
;
203 case RMAP_COMPILE_SUCCESS
:
210 /* Delete eigrp route map rule. */
211 static int eigrp_route_set_delete(struct vty
*vty
,
212 struct route_map_index
*index
,
213 const char *command
, const char *arg
)
217 ret
= route_map_delete_set(index
, command
, arg
);
219 case RMAP_RULE_MISSING
:
220 vty_out(vty
, "%% Can't find rule.\n");
221 return CMD_WARNING_CONFIG_FAILED
;
223 case RMAP_COMPILE_ERROR
:
224 vty_out(vty
, "%% Argument is malformed.\n");
225 return CMD_WARNING_CONFIG_FAILED
;
227 case RMAP_COMPILE_SUCCESS
:
234 /* Hook function for updating route_map assignment. */
236 void eigrp_route_map_update(const char *notused
)
243 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
244 if (e
->route_map
[i
].name
)
245 e
->route_map
[i
].map
= route_map_lookup_by_name(
246 e
->route_map
[i
].name
);
252 /* `match metric METRIC' */
253 /* Match function return 1 if match is success else return zero. */
254 static enum route_map_match_result_t
255 route_match_metric(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
260 // struct rip_info *rinfo;
261 // struct eigrp_nexthop_entry *te;
262 // struct eigrp_prefix_entry *pe;
263 // struct listnode *node, *node2, *nnode, *nnode2;
266 // e = eigrp_lookup();
268 // if (type == RMAP_EIGRP)
273 // /* If external metric is available, the route-map should
274 // work on this one (for redistribute purpose) */
275 // /*check = (rinfo->external_metric) ? rinfo->external_metric :
278 // if (check == *metric)
279 // return RMAP_MATCH;
281 // return RMAP_NOMATCH;
286 /* Route map `match metric' match statement. `arg' is METRIC value */
287 static void *route_match_metric_compile(const char *arg
)
291 // metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (uint32_t));
292 // *metric = atoi (arg);
297 // XFREE (MTYPE_ROUTE_MAP_COMPILED, metric);
301 /* Free route map's compiled `match metric' value. */
302 static void route_match_metric_free(void *rule
)
304 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
307 /* Route map commands for metric matching. */
308 struct route_map_rule_cmd route_match_metric_cmd
= {
309 "metric", route_match_metric
, route_match_metric_compile
,
310 route_match_metric_free
};
312 /* `match interface IFNAME' */
313 /* Match function return 1 if match is success else return zero. */
314 static enum route_map_match_result_t
315 route_match_interface(void *rule
, struct prefix
*prefix
,
316 route_map_object_t type
, void *object
)
318 // struct rip_info *rinfo;
319 // struct interface *ifp;
322 // if (type == RMAP_EIGRP)
325 // ifp = if_lookup_by_name(ifname);
328 // return RMAP_NOMATCH;
332 // /*if (rinfo->ifindex_out == ifp->ifindex || rinfo->ifindex ==
334 // return RMAP_MATCH;
336 // return RMAP_NOMATCH;*/
341 /* Route map `match interface' match statement. `arg' is IFNAME value */
342 /* XXX I don`t know if I need to check does interface exist? */
343 static void *route_match_interface_compile(const char *arg
)
345 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
348 /* Free route map's compiled `match interface' value. */
349 static void route_match_interface_free(void *rule
)
351 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
354 /* Route map commands for interface matching. */
355 struct route_map_rule_cmd route_match_interface_cmd
= {
356 "interface", route_match_interface
, route_match_interface_compile
,
357 route_match_interface_free
};
359 /* `match ip next-hop IP_ACCESS_LIST' */
361 /* Match function return 1 if match is success else return zero. */
362 static enum route_map_match_result_t
363 route_match_ip_next_hop(void *rule
, struct prefix
*prefix
,
364 route_map_object_t type
, void *object
)
366 // struct access_list *alist;
367 // struct rip_info *rinfo;
368 // struct prefix_ipv4 p;
370 // if (type == RMAP_EIGRP)
373 // p.family = AF_INET;
374 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
376 // p.prefixlen = IPV4_MAX_BITLEN;
378 // alist = access_list_lookup (AFI_IP, (char *) rule);
379 // if (alist == NULL)
380 // return RMAP_NOMATCH;
382 // return (access_list_apply (alist, &p) == FILTER_DENY ?
383 // RMAP_NOMATCH : RMAP_MATCH);
388 /* Route map `ip next-hop' match statement. `arg' should be
390 static void *route_match_ip_next_hop_compile(const char *arg
)
392 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
395 /* Free route map's compiled `. */
396 static void route_match_ip_next_hop_free(void *rule
)
398 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
401 /* Route map commands for ip next-hop matching. */
402 static struct route_map_rule_cmd route_match_ip_next_hop_cmd
= {
403 "ip next-hop", route_match_ip_next_hop
, route_match_ip_next_hop_compile
,
404 route_match_ip_next_hop_free
};
406 /* `match ip next-hop prefix-list PREFIX_LIST' */
408 static enum route_map_match_result_t
409 route_match_ip_next_hop_prefix_list(void *rule
, struct prefix
*prefix
,
410 route_map_object_t type
, void *object
)
412 // struct prefix_list *plist;
413 // struct rip_info *rinfo;
414 // struct prefix_ipv4 p;
416 // if (type == RMAP_EIGRP)
419 // p.family = AF_INET;
420 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
422 // p.prefixlen = IPV4_MAX_BITLEN;
424 // plist = prefix_list_lookup (AFI_IP, (char *) rule);
425 // if (plist == NULL)
426 // return RMAP_NOMATCH;
428 // return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
429 // RMAP_NOMATCH : RMAP_MATCH);
434 static void *route_match_ip_next_hop_prefix_list_compile(const char *arg
)
436 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
439 static void route_match_ip_next_hop_prefix_list_free(void *rule
)
441 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
444 static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd
= {
445 "ip next-hop prefix-list", route_match_ip_next_hop_prefix_list
,
446 route_match_ip_next_hop_prefix_list_compile
,
447 route_match_ip_next_hop_prefix_list_free
};
449 /* `match ip address IP_ACCESS_LIST' */
451 /* Match function should return 1 if match is success else return
453 static enum route_map_match_result_t
454 route_match_ip_address(void *rule
, struct prefix
*prefix
,
455 route_map_object_t type
, void *object
)
457 struct access_list
*alist
;
459 if (type
== RMAP_EIGRP
) {
460 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
464 return (access_list_apply(alist
, prefix
) == FILTER_DENY
471 /* Route map `ip address' match statement. `arg' should be
473 static void *route_match_ip_address_compile(const char *arg
)
475 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
478 /* Free route map's compiled `ip address' value. */
479 static void route_match_ip_address_free(void *rule
)
481 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
484 /* Route map commands for ip address matching. */
485 static struct route_map_rule_cmd route_match_ip_address_cmd
= {
486 "ip address", route_match_ip_address
, route_match_ip_address_compile
,
487 route_match_ip_address_free
};
489 /* `match ip address prefix-list PREFIX_LIST' */
491 static enum route_map_match_result_t
492 route_match_ip_address_prefix_list(void *rule
, struct prefix
*prefix
,
493 route_map_object_t type
, void *object
)
495 struct prefix_list
*plist
;
497 if (type
== RMAP_EIGRP
) {
498 plist
= prefix_list_lookup(AFI_IP
, (char *)rule
);
502 return (prefix_list_apply(plist
, prefix
) == PREFIX_DENY
509 static void *route_match_ip_address_prefix_list_compile(const char *arg
)
511 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
514 static void route_match_ip_address_prefix_list_free(void *rule
)
516 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
519 static struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd
= {
520 "ip address prefix-list", route_match_ip_address_prefix_list
,
521 route_match_ip_address_prefix_list_compile
,
522 route_match_ip_address_prefix_list_free
};
524 /* `match tag TAG' */
525 /* Match function return 1 if match is success else return zero. */
526 static enum route_map_match_result_t
527 route_match_tag(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
530 // unsigned short *tag;
531 // struct rip_info *rinfo;
533 // if (type == RMAP_EIGRP)
538 // /* The information stored by rinfo is host ordered. */
539 // /*if (rinfo->tag == *tag)
540 // return RMAP_MATCH;
542 // return RMAP_NOMATCH;*/
547 /* Route map `match tag' match statement. `arg' is TAG value */
548 static void *route_match_tag_compile(const char *arg
)
550 // unsigned short *tag;
552 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short));
553 // *tag = atoi (arg);
558 /* Free route map's compiled `match tag' value. */
559 static void route_match_tag_free(void *rule
)
561 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
564 /* Route map commands for tag matching. */
565 struct route_map_rule_cmd route_match_tag_cmd
= {
566 "tag", route_match_tag
, route_match_tag_compile
, route_match_tag_free
};
568 /* Set metric to attribute. */
569 static enum route_map_match_result_t
570 route_set_metric(void *rule
, struct prefix
*prefix
,
571 route_map_object_t type
, void *object
)
573 // if (type == RMAP_RIP)
575 // struct rip_metric_modifier *mod;
576 // struct rip_info *rinfo;
581 // /*if (mod->type == metric_increment)
582 // rinfo->metric_out += mod->metric;
583 // else if (mod->type == metric_decrement)
584 // rinfo->metric_out -= mod->metric;
585 // else if (mod->type == metric_absolute)
586 // rinfo->metric_out = mod->metric;
588 // if ((signed int)rinfo->metric_out < 1)
589 // rinfo->metric_out = 1;
590 // if (rinfo->metric_out > RIP_METRIC_INFINITY)
591 // rinfo->metric_out = RIP_METRIC_INFINITY;*/
593 // rinfo->metric_set = 1;
598 /* set metric compilation. */
599 static void *route_set_metric_compile(const char *arg
)
605 // char *endptr = NULL;
606 // struct rip_metric_modifier *mod;
608 // len = strlen (arg);
614 // /* Examine first character. */
615 // if (arg[0] == '+')
617 // //type = metric_increment;
620 // else if (arg[0] == '-')
622 // //type = metric_decrement;
626 // type = metric_absolute;*/
628 // /* Check beginning with digit string. */
629 // if (*pnt < '0' || *pnt > '9')
632 // /* Convert string to integer. */
633 // metric = strtol (pnt, &endptr, 10);
635 // if (metric == LONG_MAX || *endptr != '\0')
637 // /*if (metric < 0 || metric > RIP_METRIC_INFINITY)
640 // mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
641 // sizeof (struct rip_metric_modifier));
643 // mod->metric = metric;
648 /* Free route map's compiled `set metric' value. */
649 static void route_set_metric_free(void *rule
)
651 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
654 /* Set metric rule structure. */
655 static struct route_map_rule_cmd route_set_metric_cmd
= {
656 "metric", route_set_metric
, route_set_metric_compile
,
657 route_set_metric_free
,
660 /* `set ip next-hop IP_ADDRESS' */
662 /* Set nexthop to object. ojbect must be pointer to struct attr. */
663 static enum route_map_match_result_t
664 route_set_ip_nexthop(void *rule
, struct prefix
*prefix
,
665 route_map_object_t type
, void *object
)
667 // struct in_addr *address;
668 // struct rip_info *rinfo;
670 // if(type == RMAP_RIP)
672 // /* Fetch routemap's rule information. */
676 // /* Set next hop value. */
677 // rinfo->nexthop_out = *address;
683 /* Route map `ip nexthop' compile function. Given string is converted
684 to struct in_addr structure. */
685 static void *route_set_ip_nexthop_compile(const char *arg
)
688 // struct in_addr *address;
690 // address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct
693 // ret = inet_aton (arg, address);
697 // XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
704 /* Free route map's compiled `ip nexthop' value. */
705 static void route_set_ip_nexthop_free(void *rule
)
707 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
710 /* Route map commands for ip nexthop set. */
711 static struct route_map_rule_cmd route_set_ip_nexthop_cmd
= {
712 "ip next-hop", route_set_ip_nexthop
, route_set_ip_nexthop_compile
,
713 route_set_ip_nexthop_free
};
717 /* Set tag to object. ojbect must be pointer to struct attr. */
718 static enum route_map_match_result_t
719 route_set_tag(void *rule
, struct prefix
*prefix
,
720 route_map_object_t type
, void *object
)
722 // unsigned short *tag;
723 // struct rip_info *rinfo;
725 // if(type == RMAP_RIP)
727 // /* Fetch routemap's rule information. */
731 // /* Set next hop value. */
732 // rinfo->tag_out = *tag;
738 /* Route map `tag' compile function. Given string is converted
739 to unsigned short. */
740 static void *route_set_tag_compile(const char *arg
)
742 // unsigned short *tag;
744 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (unsigned short));
745 // *tag = atoi (arg);
750 /* Free route map's compiled `ip nexthop' value. */
751 static void route_set_tag_free(void *rule
)
753 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
756 /* Route map commands for tag set. */
757 static struct route_map_rule_cmd route_set_tag_cmd
= {
758 "tag", route_set_tag
, route_set_tag_compile
, route_set_tag_free
};
760 #define MATCH_STR "Match values from routing table\n"
761 #define SET_STR "Set values in destination routing protocol\n"
765 "match metric <0-4294967295>",
767 "Match metric of route\n"
770 return eigrp_route_match_add(vty
, vty
->index
, "metric", argv
[0]);
773 DEFUN (no_match_metric
,
778 "Match metric of route\n")
781 return eigrp_route_match_delete(vty
, vty
->index
, "metric",
784 return eigrp_route_match_delete(vty
, vty
->index
, "metric", argv
[0]);
787 ALIAS(no_match_metric
, no_match_metric_val_cmd
,
788 "no match metric <0-4294967295>", NO_STR MATCH_STR
789 "Match metric of route\n"
792 DEFUN (match_interface
,
794 "match interface WORD",
796 "Match first hop interface of route\n"
799 return eigrp_route_match_add(vty
, vty
->index
, "interface", argv
[0]);
802 DEFUN (no_match_interface
,
803 no_match_interface_cmd
,
804 "no match interface",
807 "Match first hop interface of route\n")
810 return eigrp_route_match_delete(vty
, vty
->index
, "interface",
813 return eigrp_route_match_delete(vty
, vty
->index
, "interface", argv
[0]);
816 ALIAS(no_match_interface
, no_match_interface_val_cmd
, "no match interface WORD",
818 "Match first hop interface of route\n"
821 DEFUN (match_ip_next_hop
,
822 match_ip_next_hop_cmd
,
823 "match ip next-hop (<1-199>|<1300-2699>|WORD)",
826 "Match next-hop address of route\n"
827 "IP access-list number\n"
828 "IP access-list number (expanded range)\n"
829 "IP Access-list name\n")
831 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
834 DEFUN (no_match_ip_next_hop
,
835 no_match_ip_next_hop_cmd
,
836 "no match ip next-hop",
840 "Match next-hop address of route\n")
843 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
846 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
850 ALIAS(no_match_ip_next_hop
, no_match_ip_next_hop_val_cmd
,
851 "no match ip next-hop (<1-199>|<1300-2699>|WORD)", NO_STR MATCH_STR IP_STR
852 "Match next-hop address of route\n"
853 "IP access-list number\n"
854 "IP access-list number (expanded range)\n"
855 "IP Access-list name\n")
857 DEFUN (match_ip_next_hop_prefix_list
,
858 match_ip_next_hop_prefix_list_cmd
,
859 "match ip next-hop prefix-list WORD",
862 "Match next-hop address of route\n"
863 "Match entries of prefix-lists\n"
864 "IP prefix-list name\n")
866 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop prefix-list",
870 DEFUN (no_match_ip_next_hop_prefix_list
,
871 no_match_ip_next_hop_prefix_list_cmd
,
872 "no match ip next-hop prefix-list",
876 "Match next-hop address of route\n"
877 "Match entries of prefix-lists\n")
880 return eigrp_route_match_delete(
881 vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
883 return eigrp_route_match_delete(vty
, vty
->index
,
884 "ip next-hop prefix-list", argv
[0]);
887 ALIAS(no_match_ip_next_hop_prefix_list
,
888 no_match_ip_next_hop_prefix_list_val_cmd
,
889 "no match ip next-hop prefix-list WORD", NO_STR MATCH_STR IP_STR
890 "Match next-hop address of route\n"
891 "Match entries of prefix-lists\n"
892 "IP prefix-list name\n")
894 DEFUN (match_ip_address
,
895 match_ip_address_cmd
,
896 "match ip address (<1-199>|<1300-2699>|WORD)",
899 "Match address of route\n"
900 "IP access-list number\n"
901 "IP access-list number (expanded range)\n"
902 "IP Access-list name\n")
904 return eigrp_route_match_add(vty
, vty
->index
, "ip address", argv
[0]);
907 DEFUN (no_match_ip_address
,
908 no_match_ip_address_cmd
,
909 "no match ip address",
913 "Match address of route\n")
916 return eigrp_route_match_delete(vty
, vty
->index
, "ip address",
919 return eigrp_route_match_delete(vty
, vty
->index
, "ip address", argv
[0]);
922 ALIAS(no_match_ip_address
, no_match_ip_address_val_cmd
,
923 "no match ip address (<1-199>|<1300-2699>|WORD)", NO_STR MATCH_STR IP_STR
924 "Match address of route\n"
925 "IP access-list number\n"
926 "IP access-list number (expanded range)\n"
927 "IP Access-list name\n")
929 DEFUN (match_ip_address_prefix_list
,
930 match_ip_address_prefix_list_cmd
,
931 "match ip address prefix-list WORD",
934 "Match address of route\n"
935 "Match entries of prefix-lists\n"
936 "IP prefix-list name\n")
938 return eigrp_route_match_add(vty
, vty
->index
, "ip address prefix-list",
942 DEFUN (no_match_ip_address_prefix_list
,
943 no_match_ip_address_prefix_list_cmd
,
944 "no match ip address prefix-list",
948 "Match address of route\n"
949 "Match entries of prefix-lists\n")
952 return eigrp_route_match_delete(vty
, vty
->index
,
953 "ip address prefix-list", NULL
);
955 return eigrp_route_match_delete(vty
, vty
->index
,
956 "ip address prefix-list", argv
[0]);
959 ALIAS(no_match_ip_address_prefix_list
, no_match_ip_address_prefix_list_val_cmd
,
960 "no match ip address prefix-list WORD", NO_STR MATCH_STR IP_STR
961 "Match address of route\n"
962 "Match entries of prefix-lists\n"
963 "IP prefix-list name\n")
967 "match tag <0-65535>",
969 "Match tag of route\n"
972 return eigrp_route_match_add(vty
, vty
->index
, "tag", argv
[0]);
980 "Match tag of route\n")
983 return eigrp_route_match_delete(vty
, vty
->index
, "tag", NULL
);
985 return eigrp_route_match_delete(vty
, vty
->index
, "tag", argv
[0]);
988 ALIAS(no_match_tag
, no_match_tag_val_cmd
, "no match tag <0-65535>",
990 "Match tag of route\n"
997 "set metric <0-4294967295>",
999 "Metric value for destination routing protocol\n"
1002 return eigrp_route_set_add(vty
, vty
->index
, "metric", argv
[0]);
1005 ALIAS(set_metric
, set_metric_addsub_cmd
, "set metric <+/-metric>", SET_STR
1006 "Metric value for destination routing protocol\n"
1007 "Add or subtract metric\n")
1009 DEFUN (no_set_metric
,
1014 "Metric value for destination routing protocol\n")
1017 return eigrp_route_set_delete(vty
, vty
->index
, "metric", NULL
);
1019 return eigrp_route_set_delete(vty
, vty
->index
, "metric", argv
[0]);
1022 ALIAS(no_set_metric
, no_set_metric_val_cmd
,
1023 "no set metric (<0-4294967295>|<+/-metric>)", NO_STR SET_STR
1024 "Metric value for destination routing protocol\n"
1026 "Add or subtract metric\n")
1028 DEFUN (set_ip_nexthop
,
1030 "set ip next-hop A.B.C.D",
1033 "Next hop address\n"
1034 "IP address of next hop\n")
1039 ret
= str2sockunion(argv
[0], &su
);
1041 vty_out(vty
, "%% Malformed next-hop address\n");
1042 return CMD_WARNING_CONFIG_FAILED
;
1045 return eigrp_route_set_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
1048 DEFUN (no_set_ip_nexthop
,
1049 no_set_ip_nexthop_cmd
,
1050 "no set ip next-hop",
1054 "Next hop address\n")
1057 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop",
1060 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop", argv
[0]);
1063 ALIAS(no_set_ip_nexthop
, no_set_ip_nexthop_val_cmd
,
1064 "no set ip next-hop A.B.C.D", NO_STR SET_STR IP_STR
1065 "Next hop address\n"
1066 "IP address of next hop\n")
1070 "set tag <0-65535>",
1072 "Tag value for routing protocol\n"
1075 return eigrp_route_set_add(vty
, vty
->index
, "tag", argv
[0]);
1083 "Tag value for routing protocol\n")
1086 return eigrp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
1088 return eigrp_route_set_delete(vty
, vty
->index
, "tag", argv
[0]);
1091 ALIAS(no_set_tag
, no_set_tag_val_cmd
, "no set tag <0-65535>", NO_STR SET_STR
1092 "Tag value for routing protocol\n"
1096 /* Route-map init */
1097 void eigrp_route_map_init()
1100 route_map_init_vty();
1101 route_map_add_hook(eigrp_route_map_update
);
1102 route_map_delete_hook(eigrp_route_map_update
);
1104 /*route_map_install_match (&route_match_metric_cmd);
1105 route_map_install_match (&route_match_interface_cmd);*/
1106 /*route_map_install_match (&route_match_ip_next_hop_cmd);
1107 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
1108 route_map_install_match (&route_match_ip_address_cmd);
1109 route_map_install_match (&route_match_ip_address_prefix_list_cmd);*/
1110 /*route_map_install_match (&route_match_tag_cmd);*/
1112 /*route_map_install_set (&route_set_metric_cmd);
1113 route_map_install_set (&route_set_ip_nexthop_cmd);
1114 route_map_install_set (&route_set_tag_cmd);*/
1116 /*install_element (RMAP_NODE, &route_match_metric_cmd);
1117 install_element (RMAP_NODE, &no_match_metric_cmd);
1118 install_element (RMAP_NODE, &no_match_metric_val_cmd);
1119 install_element (RMAP_NODE, &route_match_interface_cmd);
1120 install_element (RMAP_NODE, &no_match_interface_cmd);
1121 install_element (RMAP_NODE, &no_match_interface_val_cmd);
1122 install_element (RMAP_NODE, &route_match_ip_next_hop_cmd);
1123 install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
1124 install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
1125 install_element (RMAP_NODE, &route_match_ip_next_hop_prefix_list_cmd);
1126 install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
1127 install_element (RMAP_NODE,
1128 &no_match_ip_next_hop_prefix_list_val_cmd);*/
1129 /*install_element (RMAP_NODE, &route_match_ip_address_cmd);
1130 install_element (RMAP_NODE, &no_match_ip_address_cmd);
1131 install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
1132 install_element (RMAP_NODE, &route_match_ip_address_prefix_list_cmd);
1133 install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
1134 install_element (RMAP_NODE,
1135 &no_match_ip_address_prefix_list_val_cmd);*/
1136 /*install_element (RMAP_NODE, &route_match_tag_cmd);
1137 install_element (RMAP_NODE, &no_match_tag_cmd);
1138 install_element (RMAP_NODE, &no_match_tag_val_cmd);*/
1140 /*install_element (RMAP_NODE, &set_metric_cmd);
1141 install_element (RMAP_NODE, &set_metric_addsub_cmd);
1142 install_element (RMAP_NODE, &no_set_metric_cmd);
1143 install_element (RMAP_NODE, &no_set_metric_val_cmd);
1144 install_element (RMAP_NODE, &set_ip_nexthop_cmd);
1145 install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
1146 install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
1147 install_element (RMAP_NODE, &set_tag_cmd);
1148 install_element (RMAP_NODE, &no_set_tag_cmd);
1149 install_element (RMAP_NODE, &no_set_tag_val_cmd);*/