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
)
138 enum rmap_compile_rets ret
;
140 ret
= route_map_add_match(index
, command
, arg
, type
);
142 case RMAP_RULE_MISSING
:
143 vty_out(vty
, "%% Can't find rule.\n");
144 return CMD_WARNING_CONFIG_FAILED
;
145 case RMAP_COMPILE_ERROR
:
146 vty_out(vty
, "%% Argument is malformed.\n");
147 return CMD_WARNING_CONFIG_FAILED
;
148 case RMAP_COMPILE_SUCCESS
:
150 * Intentionally not handling these cases
158 /* Delete rip route map rule. */
159 static int eigrp_route_match_delete(struct vty
*vty
,
160 struct route_map_index
*index
,
161 const char *command
, const char *arg
)
163 enum rmap_compile_rets ret
;
165 ret
= route_map_delete_match(index
, command
, arg
, type
);
167 case RMAP_RULE_MISSING
:
168 vty_out(vty
, "%% Can't find rule.\n");
169 return CMD_WARNING_CONFIG_FAILED
;
170 case RMAP_COMPILE_ERROR
:
171 vty_out(vty
, "%% Argument is malformed.\n");
172 return CMD_WARNING_CONFIG_FAILED
;
173 case RMAP_COMPILE_SUCCESS
:
175 * These cases intentionally ignored
183 /* Add eigrp route map rule. */
184 static int eigrp_route_set_add(struct vty
*vty
, struct route_map_index
*index
,
185 const char *command
, const char *arg
)
187 enum rmap_compile_rets ret
;
189 ret
= route_map_add_set(index
, command
, arg
);
191 case RMAP_RULE_MISSING
:
192 vty_out(vty
, "%% Can't find rule.\n");
193 return CMD_WARNING_CONFIG_FAILED
;
194 case RMAP_COMPILE_ERROR
:
196 * rip, ripng and other protocols share the set metric command
197 * but only values from 0 to 16 are valid for rip and ripng
198 * if metric is out of range for rip and ripng, it is
199 * not for other protocols. Do not return an error
201 if (strcmp(command
, "metric")) {
202 vty_out(vty
, "%% Argument is malformed.\n");
203 return CMD_WARNING_CONFIG_FAILED
;
206 case RMAP_COMPILE_SUCCESS
:
208 * These cases intentionally left blank here
216 /* Delete eigrp route map rule. */
217 static int eigrp_route_set_delete(struct vty
*vty
,
218 struct route_map_index
*index
,
219 const char *command
, const char *arg
)
221 enum rmap_compile_rets ret
;
223 ret
= route_map_delete_set(index
, command
, arg
);
225 case RMAP_RULE_MISSING
:
226 vty_out(vty
, "%% Can't find rule.\n");
227 return CMD_WARNING_CONFIG_FAILED
;
228 case RMAP_COMPILE_ERROR
:
229 vty_out(vty
, "%% Argument is malformed.\n");
230 return CMD_WARNING_CONFIG_FAILED
;
231 case RMAP_COMPILE_SUCCESS
:
233 * These cases intentionally not handled
241 /* Hook function for updating route_map assignment. */
243 void eigrp_route_map_update(const char *notused
)
250 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
251 if (e
->route_map
[i
].name
)
252 e
->route_map
[i
].map
= route_map_lookup_by_name(
253 e
->route_map
[i
].name
);
259 /* `match metric METRIC' */
260 /* Match function return 1 if match is success else return zero. */
261 static enum route_map_cmd_result_t
262 route_match_metric(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
267 // struct rip_info *rinfo;
268 // struct eigrp_route_descriptor *te;
269 // struct eigrp_prefix_descriptor *pe;
270 // struct listnode *node, *node2, *nnode, *nnode2;
273 // e = eigrp_lookup();
275 // if (type == RMAP_EIGRP)
280 // /* If external metric is available, the route-map should
281 // work on this one (for redistribute purpose) */
282 // /*check = (rinfo->external_metric) ? rinfo->external_metric :
285 // if (check == *metric)
286 // return RMAP_MATCH;
288 // return RMAP_NOMATCH;
293 /* Route map `match metric' match statement. `arg' is METRIC value */
294 static void *route_match_metric_compile(const char *arg
)
298 // metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
299 // *metric = atoi (arg);
304 // XFREE (MTYPE_ROUTE_MAP_COMPILED, metric);
308 /* Free route map's compiled `match metric' value. */
309 static void route_match_metric_free(void *rule
)
311 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
314 /* Route map commands for metric matching. */
315 static const struct route_map_rule_cmd route_match_metric_cmd
= {
318 route_match_metric_compile
,
319 route_match_metric_free
322 /* `match interface IFNAME' */
323 /* Match function return 1 if match is success else return zero. */
324 static enum route_map_cmd_result_t
325 route_match_interface(void *rule
, struct prefix
*prefix
,
326 route_map_object_t type
, void *object
)
328 // struct rip_info *rinfo;
329 // struct interface *ifp;
332 // if (type == RMAP_EIGRP)
335 // ifp = if_lookup_by_name(ifname);
338 // return RMAP_NOMATCH;
342 // /*if (rinfo->ifindex_out == ifp->ifindex || rinfo->ifindex ==
344 // return RMAP_MATCH;
346 // return RMAP_NOMATCH;*/
351 /* Route map `match interface' match statement. `arg' is IFNAME value */
352 /* XXX I don`t know if I need to check does interface exist? */
353 static void *route_match_interface_compile(const char *arg
)
355 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
358 /* Free route map's compiled `match interface' value. */
359 static void route_match_interface_free(void *rule
)
361 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
364 /* Route map commands for interface matching. */
365 static const struct route_map_rule_cmd route_match_interface_cmd
= {
367 route_match_interface
,
368 route_match_interface_compile
,
369 route_match_interface_free
372 /* `match ip next-hop IP_ACCESS_LIST' */
374 /* Match function return 1 if match is success else return zero. */
375 static enum route_map_cmd_result_t
376 route_match_ip_next_hop(void *rule
, struct prefix
*prefix
,
377 route_map_object_t type
, void *object
)
379 // struct access_list *alist;
380 // struct rip_info *rinfo;
381 // struct prefix_ipv4 p;
383 // if (type == RMAP_EIGRP)
386 // p.family = AF_INET;
387 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
389 // p.prefixlen = IPV4_MAX_BITLEN;
391 // alist = access_list_lookup (AFI_IP, (char *) rule);
392 // if (alist == NULL)
393 // return RMAP_NOMATCH;
395 // return (access_list_apply (alist, &p) == FILTER_DENY ?
396 // RMAP_NOMATCH : RMAP_MATCH);
401 /* Route map `ip next-hop' match statement. `arg' should be
403 static void *route_match_ip_next_hop_compile(const char *arg
)
405 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
408 /* Free route map's compiled `. */
409 static void route_match_ip_next_hop_free(void *rule
)
411 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
414 /* Route map commands for ip next-hop matching. */
415 static const struct route_map_rule_cmd route_match_ip_next_hop_cmd
= {
417 route_match_ip_next_hop
,
418 route_match_ip_next_hop_compile
,
419 route_match_ip_next_hop_free
422 /* `match ip next-hop prefix-list PREFIX_LIST' */
424 static enum route_map_cmd_result_t
425 route_match_ip_next_hop_prefix_list(void *rule
, struct prefix
*prefix
,
426 route_map_object_t type
, void *object
)
428 // struct prefix_list *plist;
429 // struct rip_info *rinfo;
430 // struct prefix_ipv4 p;
432 // if (type == RMAP_EIGRP)
435 // p.family = AF_INET;
436 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
438 // p.prefixlen = IPV4_MAX_BITLEN;
440 // plist = prefix_list_lookup (AFI_IP, (char *) rule);
441 // if (plist == NULL)
442 // return RMAP_NOMATCH;
444 // return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
445 // RMAP_NOMATCH : RMAP_MATCH);
450 static void *route_match_ip_next_hop_prefix_list_compile(const char *arg
)
452 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
455 static void route_match_ip_next_hop_prefix_list_free(void *rule
)
457 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
460 static const struct route_map_rule_cmd
461 route_match_ip_next_hop_prefix_list_cmd
= {
462 "ip next-hop prefix-list",
463 route_match_ip_next_hop_prefix_list
,
464 route_match_ip_next_hop_prefix_list_compile
,
465 route_match_ip_next_hop_prefix_list_free
468 /* `match ip address IP_ACCESS_LIST' */
470 /* Match function should return 1 if match is success else return
472 static enum route_map_cmd_result_t
473 route_match_ip_address(void *rule
, struct prefix
*prefix
,
474 route_map_object_t type
, void *object
)
476 struct access_list
*alist
;
478 if (type
== RMAP_EIGRP
) {
479 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
483 return (access_list_apply(alist
, prefix
) == FILTER_DENY
490 /* Route map `ip address' match statement. `arg' should be
492 static void *route_match_ip_address_compile(const char *arg
)
494 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
497 /* Free route map's compiled `ip address' value. */
498 static void route_match_ip_address_free(void *rule
)
500 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
503 /* Route map commands for ip address matching. */
504 static const struct route_map_rule_cmd route_match_ip_address_cmd
= {
506 route_match_ip_address
,
507 route_match_ip_address_compile
,
508 route_match_ip_address_free
511 /* `match ip address prefix-list PREFIX_LIST' */
513 static enum route_map_cmd_result_t
514 route_match_ip_address_prefix_list(void *rule
, struct prefix
*prefix
,
515 route_map_object_t type
, void *object
)
517 struct prefix_list
*plist
;
519 if (type
== RMAP_EIGRP
) {
520 plist
= prefix_list_lookup(AFI_IP
, (char *)rule
);
524 return (prefix_list_apply(plist
, prefix
) == PREFIX_DENY
531 static void *route_match_ip_address_prefix_list_compile(const char *arg
)
533 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
536 static void route_match_ip_address_prefix_list_free(void *rule
)
538 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
541 static const struct route_map_rule_cmd
542 route_match_ip_address_prefix_list_cmd
= {
543 "ip address prefix-list",
544 route_match_ip_address_prefix_list
,
545 route_match_ip_address_prefix_list_compile
,
546 route_match_ip_address_prefix_list_free
549 /* `match tag TAG' */
550 /* Match function return 1 if match is success else return zero. */
551 static enum route_map_cmd_result_t
552 route_match_tag(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
555 // unsigned short *tag;
556 // struct rip_info *rinfo;
558 // if (type == RMAP_EIGRP)
563 // /* The information stored by rinfo is host ordered. */
564 // /*if (rinfo->tag == *tag)
565 // return RMAP_MATCH;
567 // return RMAP_NOMATCH;*/
572 /* Route map `match tag' match statement. `arg' is TAG value */
573 static void *route_match_tag_compile(const char *arg
)
575 // unsigned short *tag;
577 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
578 // *tag = atoi (arg);
583 /* Free route map's compiled `match tag' value. */
584 static void route_match_tag_free(void *rule
)
586 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
589 /* Route map commands for tag matching. */
590 static const struct route_map_rule_cmd route_match_tag_cmd
= {
593 route_match_tag_compile
,
597 /* Set metric to attribute. */
598 static enum route_map_cmd_result_t
599 route_set_metric(void *rule
, struct prefix
*prefix
,
600 route_map_object_t type
, void *object
)
602 // if (type == RMAP_RIP)
604 // struct rip_metric_modifier *mod;
605 // struct rip_info *rinfo;
610 // /*if (mod->type == metric_increment)
611 // rinfo->metric_out += mod->metric;
612 // else if (mod->type == metric_decrement)
613 // rinfo->metric_out -= mod->metric;
614 // else if (mod->type == metric_absolute)
615 // rinfo->metric_out = mod->metric;
617 // if ((signed int)rinfo->metric_out < 1)
618 // rinfo->metric_out = 1;
619 // if (rinfo->metric_out > RIP_METRIC_INFINITY)
620 // rinfo->metric_out = RIP_METRIC_INFINITY;*/
622 // rinfo->metric_set = 1;
627 /* set metric compilation. */
628 static void *route_set_metric_compile(const char *arg
)
634 // char *endptr = NULL;
635 // struct rip_metric_modifier *mod;
637 // len = strlen (arg);
643 // /* Examine first character. */
644 // if (arg[0] == '+')
646 // //type = metric_increment;
649 // else if (arg[0] == '-')
651 // //type = metric_decrement;
655 // type = metric_absolute;*/
657 // /* Check beginning with digit string. */
658 // if (*pnt < '0' || *pnt > '9')
661 // /* Convert string to integer. */
662 // metric = strtol (pnt, &endptr, 10);
664 // if (metric == LONG_MAX || *endptr != '\0')
666 // /*if (metric < 0 || metric > RIP_METRIC_INFINITY)
669 // mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
670 // sizeof(struct rip_metric_modifier));
672 // mod->metric = metric;
677 /* Free route map's compiled `set metric' value. */
678 static void route_set_metric_free(void *rule
)
680 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
683 /* Set metric rule structure. */
684 static const struct route_map_rule_cmd route_set_metric_cmd
= {
687 route_set_metric_compile
,
688 route_set_metric_free
,
691 /* `set ip next-hop IP_ADDRESS' */
693 /* Set nexthop to object. object must be pointer to struct attr. */
694 static enum route_map_cmd_result_t
695 route_set_ip_nexthop(void *rule
, struct prefix
*prefix
,
696 route_map_object_t type
, void *object
)
698 // struct in_addr *address;
699 // struct rip_info *rinfo;
701 // if(type == RMAP_RIP)
703 // /* Fetch routemap's rule information. */
707 // /* Set next hop value. */
708 // rinfo->nexthop_out = *address;
714 /* Route map `ip nexthop' compile function. Given string is converted
715 to struct in_addr structure. */
716 static void *route_set_ip_nexthop_compile(const char *arg
)
719 // struct in_addr *address;
721 // address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(struct
724 // ret = inet_aton (arg, address);
728 // XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
735 /* Free route map's compiled `ip nexthop' value. */
736 static void route_set_ip_nexthop_free(void *rule
)
738 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
741 /* Route map commands for ip nexthop set. */
742 static const struct route_map_rule_cmd route_set_ip_nexthop_cmd
= {
744 route_set_ip_nexthop
,
745 route_set_ip_nexthop_compile
,
746 route_set_ip_nexthop_free
751 /* Set tag to object. object must be pointer to struct attr. */
752 static enum route_map_cmd_result_t
753 route_set_tag(void *rule
, struct prefix
*prefix
,
754 route_map_object_t type
, void *object
)
756 // unsigned short *tag;
757 // struct rip_info *rinfo;
759 // if(type == RMAP_RIP)
761 // /* Fetch routemap's rule information. */
765 // /* Set next hop value. */
766 // rinfo->tag_out = *tag;
772 /* Route map `tag' compile function. Given string is converted
773 to unsigned short. */
774 static void *route_set_tag_compile(const char *arg
)
776 // unsigned short *tag;
778 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
779 // *tag = atoi (arg);
784 /* Free route map's compiled `ip nexthop' value. */
785 static void route_set_tag_free(void *rule
)
787 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
790 /* Route map commands for tag set. */
791 static const struct route_map_rule_cmd route_set_tag_cmd
= {
794 route_set_tag_compile
,
798 #define MATCH_STR "Match values from routing table\n"
799 #define SET_STR "Set values in destination routing protocol\n"
803 "match metric (0-4294967295)",
805 "Match metric of route\n"
808 return eigrp_route_match_add(vty
, vty
->index
, "metric", argv
[0]);
811 DEFUN (no_match_metric
,
816 "Match metric of route\n")
819 return eigrp_route_match_delete(vty
, vty
->index
, "metric",
822 return eigrp_route_match_delete(vty
, vty
->index
, "metric", argv
[0]);
825 ALIAS(no_match_metric
, no_match_metric_val_cmd
,
826 "no match metric (0-4294967295)", NO_STR MATCH_STR
827 "Match metric of route\n"
830 DEFUN (match_interface
,
832 "match interface WORD",
834 "Match first hop interface of route\n"
837 return eigrp_route_match_add(vty
, vty
->index
, "interface", argv
[0]);
840 DEFUN (no_match_interface
,
841 no_match_interface_cmd
,
842 "no match interface",
845 "Match first hop interface of route\n")
848 return eigrp_route_match_delete(vty
, vty
->index
, "interface",
851 return eigrp_route_match_delete(vty
, vty
->index
, "interface", argv
[0]);
854 ALIAS(no_match_interface
, no_match_interface_val_cmd
, "no match interface WORD",
856 "Match first hop interface of route\n"
859 DEFUN (match_ip_next_hop
,
860 match_ip_next_hop_cmd
,
861 "match ip next-hop ACCESSLIST4_NAME",
864 "Match next-hop address of route\n"
865 "IP Access-list name\n")
867 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
870 DEFUN (no_match_ip_next_hop
,
871 no_match_ip_next_hop_cmd
,
872 "no match ip next-hop",
876 "Match next-hop address of route\n")
879 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
882 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
886 ALIAS(no_match_ip_next_hop
, no_match_ip_next_hop_val_cmd
,
887 "no match ip next-hop ACCESSLIST4_NAME", NO_STR MATCH_STR IP_STR
888 "Match next-hop address of route\n"
889 "IP Access-list name\n")
891 DEFUN (match_ip_next_hop_prefix_list
,
892 match_ip_next_hop_prefix_list_cmd
,
893 "match ip next-hop prefix-list PREFIXLIST_NAME",
896 "Match next-hop address of route\n"
897 "Match entries of prefix-lists\n"
898 "IP prefix-list name\n")
900 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop prefix-list",
904 DEFUN (no_match_ip_next_hop_prefix_list
,
905 no_match_ip_next_hop_prefix_list_cmd
,
906 "no match ip next-hop prefix-list",
910 "Match next-hop address of route\n"
911 "Match entries of prefix-lists\n")
914 return eigrp_route_match_delete(
915 vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
917 return eigrp_route_match_delete(vty
, vty
->index
,
918 "ip next-hop prefix-list", argv
[0]);
921 ALIAS(no_match_ip_next_hop_prefix_list
,
922 no_match_ip_next_hop_prefix_list_val_cmd
,
923 "no match ip next-hop prefix-list PREFIXLIST_NAME", NO_STR MATCH_STR IP_STR
924 "Match next-hop address of route\n"
925 "Match entries of prefix-lists\n"
926 "IP prefix-list name\n")
928 DEFUN (match_ip_address
,
929 match_ip_address_cmd
,
930 "match ip address ACCESSLIST4_NAME",
933 "Match address of route\n"
934 "IP Access-list name\n")
936 return eigrp_route_match_add(vty
, vty
->index
, "ip address", argv
[0]);
939 DEFUN (no_match_ip_address
,
940 no_match_ip_address_cmd
,
941 "no match ip address",
945 "Match address of route\n")
948 return eigrp_route_match_delete(vty
, vty
->index
, "ip address",
951 return eigrp_route_match_delete(vty
, vty
->index
, "ip address", argv
[0]);
954 ALIAS(no_match_ip_address
, no_match_ip_address_val_cmd
,
955 "no match ip address ACCESSLIST4_NAME", NO_STR MATCH_STR IP_STR
956 "Match address of route\n"
957 "IP Access-list name\n")
959 DEFUN (match_ip_address_prefix_list
,
960 match_ip_address_prefix_list_cmd
,
961 "match ip address prefix-list PREFIXLIST_NAME",
964 "Match address of route\n"
965 "Match entries of prefix-lists\n"
966 "IP prefix-list name\n")
968 return eigrp_route_match_add(vty
, vty
->index
, "ip address prefix-list",
972 DEFUN (no_match_ip_address_prefix_list
,
973 no_match_ip_address_prefix_list_cmd
,
974 "no match ip address prefix-list",
978 "Match address of route\n"
979 "Match entries of prefix-lists\n")
982 return eigrp_route_match_delete(vty
, vty
->index
,
983 "ip address prefix-list", NULL
);
985 return eigrp_route_match_delete(vty
, vty
->index
,
986 "ip address prefix-list", argv
[0]);
989 ALIAS(no_match_ip_address_prefix_list
, no_match_ip_address_prefix_list_val_cmd
,
990 "no match ip address prefix-list PREFIXLIST_NAME", NO_STR MATCH_STR IP_STR
991 "Match address of route\n"
992 "Match entries of prefix-lists\n"
993 "IP prefix-list name\n")
997 "match tag (0-65535)",
999 "Match tag of route\n"
1002 return eigrp_route_match_add(vty
, vty
->index
, "tag", argv
[0]);
1005 DEFUN (no_match_tag
,
1010 "Match tag of route\n")
1013 return eigrp_route_match_delete(vty
, vty
->index
, "tag", NULL
);
1015 return eigrp_route_match_delete(vty
, vty
->index
, "tag", argv
[0]);
1018 ALIAS(no_match_tag
, no_match_tag_val_cmd
, "no match tag (0-65535)",
1020 "Match tag of route\n"
1027 "set metric (0-4294967295)",
1029 "Metric value for destination routing protocol\n"
1032 return eigrp_route_set_add(vty
, vty
->index
, "metric", argv
[0]);
1035 ALIAS(set_metric
, set_metric_addsub_cmd
, "set metric <+/-metric>", SET_STR
1036 "Metric value for destination routing protocol\n"
1037 "Add or subtract metric\n")
1039 DEFUN (no_set_metric
,
1044 "Metric value for destination routing protocol\n")
1047 return eigrp_route_set_delete(vty
, vty
->index
, "metric", NULL
);
1049 return eigrp_route_set_delete(vty
, vty
->index
, "metric", argv
[0]);
1052 ALIAS(no_set_metric
, no_set_metric_val_cmd
,
1053 "no set metric ((0-4294967295)|<+/-metric>)", NO_STR SET_STR
1054 "Metric value for destination routing protocol\n"
1056 "Add or subtract metric\n")
1058 DEFUN (set_ip_nexthop
,
1060 "set ip next-hop A.B.C.D",
1063 "Next hop address\n"
1064 "IP address of next hop\n")
1069 ret
= str2sockunion(argv
[0], &su
);
1071 vty_out(vty
, "%% Malformed next-hop address\n");
1072 return CMD_WARNING_CONFIG_FAILED
;
1075 return eigrp_route_set_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
1078 DEFUN (no_set_ip_nexthop
,
1079 no_set_ip_nexthop_cmd
,
1080 "no set ip next-hop",
1084 "Next hop address\n")
1087 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop",
1090 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop", argv
[0]);
1093 ALIAS(no_set_ip_nexthop
, no_set_ip_nexthop_val_cmd
,
1094 "no set ip next-hop A.B.C.D", NO_STR SET_STR IP_STR
1095 "Next hop address\n"
1096 "IP address of next hop\n")
1100 "set tag (0-65535)",
1102 "Tag value for routing protocol\n"
1105 return eigrp_route_set_add(vty
, vty
->index
, "tag", argv
[0]);
1113 "Tag value for routing protocol\n")
1116 return eigrp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
1118 return eigrp_route_set_delete(vty
, vty
->index
, "tag", argv
[0]);
1121 ALIAS(no_set_tag
, no_set_tag_val_cmd
, "no set tag (0-65535)", NO_STR SET_STR
1122 "Tag value for routing protocol\n"
1125 DEFUN (eigrp_distribute_list
,
1126 eigrp_distribute_list_cmd
,
1127 "distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
1128 "Filter networks in routing updates\n"
1129 "Specify a prefix\n"
1130 "Access-list name\n"
1131 "Filter incoming routing updates\n"
1132 "Filter outgoing routing updates\n"
1135 const char *ifname
= NULL
;
1136 int prefix
= (argv
[1]->type
== WORD_TKN
) ? 1 : 0;
1138 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1139 ifname
= argv
[argc
- 1]->arg
;
1141 return distribute_list_parser(prefix
, true, argv
[2 + prefix
]->text
,
1142 argv
[1 + prefix
]->arg
, ifname
);
1145 DEFUN (eigrp_no_distribute_list
,
1146 eigrp_no_distribute_list_cmd
,
1147 "no distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
1149 "Filter networks in routing updates\n"
1150 "Specify a prefix\n"
1151 "Access-list name\n"
1152 "Filter incoming routing updates\n"
1153 "Filter outgoing routing updates\n"
1156 const char *ifname
= NULL
;
1157 int prefix
= (argv
[2]->type
== WORD_TKN
) ? 1 : 0;
1159 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1160 ifname
= argv
[argc
- 1]->arg
;
1162 return distribute_list_no_parser(vty
, prefix
, true,
1163 argv
[3 + prefix
]->text
,
1164 argv
[2 + prefix
]->arg
, ifname
);
1168 /* Route-map init */
1169 void eigrp_route_map_init()
1172 route_map_init_vty();
1173 route_map_add_hook(eigrp_route_map_update
);
1174 route_map_delete_hook(eigrp_route_map_update
);
1176 install_element(EIGRP_NODE
, &eigrp_distribute_list_cmd
);
1177 install_element(EIGRP_NODE
, &eigrp_no_distribute_list_cmd
);
1179 /*route_map_install_match (&route_match_metric_cmd);
1180 route_map_install_match (&route_match_interface_cmd);*/
1181 /*route_map_install_match (&route_match_ip_next_hop_cmd);
1182 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
1183 route_map_install_match (&route_match_ip_address_cmd);
1184 route_map_install_match (&route_match_ip_address_prefix_list_cmd);*/
1185 /*route_map_install_match (&route_match_tag_cmd);*/
1187 /*route_map_install_set (&route_set_metric_cmd);
1188 route_map_install_set (&route_set_ip_nexthop_cmd);
1189 route_map_install_set (&route_set_tag_cmd);*/
1191 /*install_element (RMAP_NODE, &route_match_metric_cmd);
1192 install_element (RMAP_NODE, &no_match_metric_cmd);
1193 install_element (RMAP_NODE, &no_match_metric_val_cmd);
1194 install_element (RMAP_NODE, &route_match_interface_cmd);
1195 install_element (RMAP_NODE, &no_match_interface_cmd);
1196 install_element (RMAP_NODE, &no_match_interface_val_cmd);
1197 install_element (RMAP_NODE, &route_match_ip_next_hop_cmd);
1198 install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
1199 install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
1200 install_element (RMAP_NODE, &route_match_ip_next_hop_prefix_list_cmd);
1201 install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
1202 install_element (RMAP_NODE,
1203 &no_match_ip_next_hop_prefix_list_val_cmd);*/
1204 /*install_element (RMAP_NODE, &route_match_ip_address_cmd);
1205 install_element (RMAP_NODE, &no_match_ip_address_cmd);
1206 install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
1207 install_element (RMAP_NODE, &route_match_ip_address_prefix_list_cmd);
1208 install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
1209 install_element (RMAP_NODE,
1210 &no_match_ip_address_prefix_list_val_cmd);*/
1211 /*install_element (RMAP_NODE, &route_match_tag_cmd);
1212 install_element (RMAP_NODE, &no_match_tag_cmd);
1213 install_element (RMAP_NODE, &no_match_tag_val_cmd);*/
1215 /*install_element (RMAP_NODE, &set_metric_cmd);
1216 install_element (RMAP_NODE, &set_metric_addsub_cmd);
1217 install_element (RMAP_NODE, &no_set_metric_cmd);
1218 install_element (RMAP_NODE, &no_set_metric_val_cmd);
1219 install_element (RMAP_NODE, &set_ip_nexthop_cmd);
1220 install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
1221 install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
1222 install_element (RMAP_NODE, &set_tag_cmd);
1223 install_element (RMAP_NODE, &no_set_tag_cmd);
1224 install_element (RMAP_NODE, &no_set_tag_val_cmd);*/