1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * EIGRP Filter Functions.
4 * Copyright (C) 2013-2015
16 * Note: This file contains skeleton for all possible matches and sets,
17 * but they are hidden in comment block and not properly implemented.
18 * At this time, the only function we consider useful for our use
19 * in distribute command in EIGRP is matching destination IP (with both
20 * access and prefix list).
33 #include "sockunion.h" /* for inet_aton () */
36 #include "eigrpd/eigrpd.h"
37 #include "eigrpd/eigrp_structs.h"
38 #include "eigrpd/eigrp_const.h"
39 #include "eigrpd/eigrp_macros.h"
40 #include "eigrpd/eigrp_routemap.h"
42 void eigrp_if_rmap_update(struct if_rmap
*if_rmap
)
44 struct interface
*ifp
;
45 struct eigrp_interface
*ei
, *ei2
;
46 struct listnode
*node
, *nnode
;
47 struct route_map
*rmap
;
50 ifp
= if_lookup_by_name(if_rmap
->ifname
);
56 for (ALL_LIST_ELEMENTS(e
->eiflist
, node
, nnode
, ei2
)) {
57 if (strcmp(ei2
->ifp
->name
, ifp
->name
) == 0) {
63 if (if_rmap
->routemap
[IF_RMAP_IN
]) {
64 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_IN
]);
66 ei
->routemap
[IF_RMAP_IN
] = rmap
;
68 ei
->routemap
[IF_RMAP_IN
] = NULL
;
70 ei
->routemap
[EIGRP_FILTER_IN
] = NULL
;
72 if (if_rmap
->routemap
[IF_RMAP_OUT
]) {
73 rmap
= route_map_lookup_by_name(if_rmap
->routemap
[IF_RMAP_OUT
]);
75 ei
->routemap
[IF_RMAP_OUT
] = rmap
;
77 ei
->routemap
[IF_RMAP_OUT
] = NULL
;
79 ei
->routemap
[EIGRP_FILTER_OUT
] = NULL
;
82 void eigrp_if_rmap_update_interface(struct interface
*ifp
)
84 struct if_rmap
*if_rmap
;
86 if_rmap
= if_rmap_lookup(ifp
->name
);
88 eigrp_if_rmap_update(if_rmap
);
91 void eigrp_routemap_update_redistribute(void)
99 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
100 if (e
->route_map
[i
].name
)
101 e
->route_map
[i
].map
= route_map_lookup_by_name(
102 e
->route_map
[i
].name
);
108 void eigrp_rmap_update(const char *notused
)
110 struct interface
*ifp
;
111 struct listnode
*node
, *nnode
;
113 for (ALL_LIST_ELEMENTS(iflist
, node
, nnode
, ifp
))
114 eigrp_if_rmap_update_interface(ifp
);
116 eigrp_routemap_update_redistribute();
119 /* Add eigrp route map rule. */
120 static int eigrp_route_match_add(struct vty
*vty
, struct route_map_index
*index
,
121 const char *command
, const char *arg
)
123 enum rmap_compile_rets ret
;
125 ret
= route_map_add_match(index
, command
, arg
, type
);
127 case RMAP_RULE_MISSING
:
128 vty_out(vty
, "%% Can't find rule.\n");
129 return CMD_WARNING_CONFIG_FAILED
;
130 case RMAP_COMPILE_ERROR
:
131 vty_out(vty
, "%% Argument is malformed.\n");
132 return CMD_WARNING_CONFIG_FAILED
;
133 case RMAP_COMPILE_SUCCESS
:
135 * Intentionally not handling these cases
143 /* Delete rip route map rule. */
144 static int eigrp_route_match_delete(struct vty
*vty
,
145 struct route_map_index
*index
,
146 const char *command
, const char *arg
)
148 enum rmap_compile_rets ret
;
150 ret
= route_map_delete_match(index
, command
, arg
, type
);
152 case RMAP_RULE_MISSING
:
153 vty_out(vty
, "%% Can't find rule.\n");
154 return CMD_WARNING_CONFIG_FAILED
;
155 case RMAP_COMPILE_ERROR
:
156 vty_out(vty
, "%% Argument is malformed.\n");
157 return CMD_WARNING_CONFIG_FAILED
;
158 case RMAP_COMPILE_SUCCESS
:
160 * These cases intentionally ignored
168 /* Add eigrp route map rule. */
169 static int eigrp_route_set_add(struct vty
*vty
, struct route_map_index
*index
,
170 const char *command
, const char *arg
)
172 enum rmap_compile_rets ret
;
174 ret
= route_map_add_set(index
, command
, arg
);
176 case RMAP_RULE_MISSING
:
177 vty_out(vty
, "%% Can't find rule.\n");
178 return CMD_WARNING_CONFIG_FAILED
;
179 case RMAP_COMPILE_ERROR
:
181 * rip, ripng and other protocols share the set metric command
182 * but only values from 0 to 16 are valid for rip and ripng
183 * if metric is out of range for rip and ripng, it is
184 * not for other protocols. Do not return an error
186 if (strcmp(command
, "metric")) {
187 vty_out(vty
, "%% Argument is malformed.\n");
188 return CMD_WARNING_CONFIG_FAILED
;
191 case RMAP_COMPILE_SUCCESS
:
193 * These cases intentionally left blank here
201 /* Delete eigrp route map rule. */
202 static int eigrp_route_set_delete(struct vty
*vty
,
203 struct route_map_index
*index
,
204 const char *command
, const char *arg
)
206 enum rmap_compile_rets ret
;
208 ret
= route_map_delete_set(index
, command
, arg
);
210 case RMAP_RULE_MISSING
:
211 vty_out(vty
, "%% Can't find rule.\n");
212 return CMD_WARNING_CONFIG_FAILED
;
213 case RMAP_COMPILE_ERROR
:
214 vty_out(vty
, "%% Argument is malformed.\n");
215 return CMD_WARNING_CONFIG_FAILED
;
216 case RMAP_COMPILE_SUCCESS
:
218 * These cases intentionally not handled
226 /* Hook function for updating route_map assignment. */
228 void eigrp_route_map_update(const char *notused
)
235 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
236 if (e
->route_map
[i
].name
)
237 e
->route_map
[i
].map
= route_map_lookup_by_name(
238 e
->route_map
[i
].name
);
244 /* `match metric METRIC' */
245 /* Match function return 1 if match is success else return zero. */
246 static enum route_map_cmd_result_t
247 route_match_metric(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
252 // struct rip_info *rinfo;
253 // struct eigrp_route_descriptor *te;
254 // struct eigrp_prefix_descriptor *pe;
255 // struct listnode *node, *node2, *nnode, *nnode2;
258 // e = eigrp_lookup();
260 // if (type == RMAP_EIGRP)
265 // /* If external metric is available, the route-map should
266 // work on this one (for redistribute purpose) */
267 // /*check = (rinfo->external_metric) ? rinfo->external_metric :
270 // if (check == *metric)
271 // return RMAP_MATCH;
273 // return RMAP_NOMATCH;
278 /* Route map `match metric' match statement. `arg' is METRIC value */
279 static void *route_match_metric_compile(const char *arg
)
283 // metric = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
284 // *metric = atoi (arg);
289 // XFREE (MTYPE_ROUTE_MAP_COMPILED, metric);
293 /* Free route map's compiled `match metric' value. */
294 static void route_match_metric_free(void *rule
)
296 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
299 /* Route map commands for metric matching. */
300 static const struct route_map_rule_cmd route_match_metric_cmd
= {
303 route_match_metric_compile
,
304 route_match_metric_free
307 /* `match interface IFNAME' */
308 /* Match function return 1 if match is success else return zero. */
309 static enum route_map_cmd_result_t
310 route_match_interface(void *rule
, struct prefix
*prefix
,
311 route_map_object_t type
, void *object
)
313 // struct rip_info *rinfo;
314 // struct interface *ifp;
317 // if (type == RMAP_EIGRP)
320 // ifp = if_lookup_by_name(ifname);
323 // return RMAP_NOMATCH;
327 // /*if (rinfo->ifindex_out == ifp->ifindex || rinfo->ifindex ==
329 // return RMAP_MATCH;
331 // return RMAP_NOMATCH;*/
336 /* Route map `match interface' match statement. `arg' is IFNAME value */
337 /* XXX I don`t know if I need to check does interface exist? */
338 static void *route_match_interface_compile(const char *arg
)
340 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
343 /* Free route map's compiled `match interface' value. */
344 static void route_match_interface_free(void *rule
)
346 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
349 /* Route map commands for interface matching. */
350 static const struct route_map_rule_cmd route_match_interface_cmd
= {
352 route_match_interface
,
353 route_match_interface_compile
,
354 route_match_interface_free
357 /* `match ip next-hop IP_ACCESS_LIST' */
359 /* Match function return 1 if match is success else return zero. */
360 static enum route_map_cmd_result_t
361 route_match_ip_next_hop(void *rule
, struct prefix
*prefix
,
362 route_map_object_t type
, void *object
)
364 // struct access_list *alist;
365 // struct rip_info *rinfo;
366 // struct prefix_ipv4 p;
368 // if (type == RMAP_EIGRP)
371 // p.family = AF_INET;
372 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
374 // p.prefixlen = IPV4_MAX_BITLEN;
376 // alist = access_list_lookup (AFI_IP, (char *) rule);
377 // if (alist == NULL)
378 // return RMAP_NOMATCH;
380 // return (access_list_apply (alist, &p) == FILTER_DENY ?
381 // RMAP_NOMATCH : RMAP_MATCH);
386 /* Route map `ip next-hop' match statement. `arg' should be
388 static void *route_match_ip_next_hop_compile(const char *arg
)
390 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
393 /* Free route map's compiled `. */
394 static void route_match_ip_next_hop_free(void *rule
)
396 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
399 /* Route map commands for ip next-hop matching. */
400 static const struct route_map_rule_cmd route_match_ip_next_hop_cmd
= {
402 route_match_ip_next_hop
,
403 route_match_ip_next_hop_compile
,
404 route_match_ip_next_hop_free
407 /* `match ip next-hop prefix-list PREFIX_LIST' */
409 static enum route_map_cmd_result_t
410 route_match_ip_next_hop_prefix_list(void *rule
, struct prefix
*prefix
,
411 route_map_object_t type
, void *object
)
413 // struct prefix_list *plist;
414 // struct rip_info *rinfo;
415 // struct prefix_ipv4 p;
417 // if (type == RMAP_EIGRP)
420 // p.family = AF_INET;
421 // /*p.prefix = (rinfo->nexthop.s_addr) ? rinfo->nexthop :
423 // p.prefixlen = IPV4_MAX_BITLEN;
425 // plist = prefix_list_lookup (AFI_IP, (char *) rule);
426 // if (plist == NULL)
427 // return RMAP_NOMATCH;
429 // return (prefix_list_apply (plist, &p) == PREFIX_DENY ?
430 // RMAP_NOMATCH : RMAP_MATCH);
435 static void *route_match_ip_next_hop_prefix_list_compile(const char *arg
)
437 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
440 static void route_match_ip_next_hop_prefix_list_free(void *rule
)
442 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
445 static const struct route_map_rule_cmd
446 route_match_ip_next_hop_prefix_list_cmd
= {
447 "ip next-hop prefix-list",
448 route_match_ip_next_hop_prefix_list
,
449 route_match_ip_next_hop_prefix_list_compile
,
450 route_match_ip_next_hop_prefix_list_free
453 /* `match ip address IP_ACCESS_LIST' */
455 /* Match function should return 1 if match is success else return
457 static enum route_map_cmd_result_t
458 route_match_ip_address(void *rule
, struct prefix
*prefix
,
459 route_map_object_t type
, void *object
)
461 struct access_list
*alist
;
463 if (type
== RMAP_EIGRP
) {
464 alist
= access_list_lookup(AFI_IP
, (char *)rule
);
468 return (access_list_apply(alist
, prefix
) == FILTER_DENY
475 /* Route map `ip address' match statement. `arg' should be
477 static void *route_match_ip_address_compile(const char *arg
)
479 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
482 /* Free route map's compiled `ip address' value. */
483 static void route_match_ip_address_free(void *rule
)
485 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
488 /* Route map commands for ip address matching. */
489 static const struct route_map_rule_cmd route_match_ip_address_cmd
= {
491 route_match_ip_address
,
492 route_match_ip_address_compile
,
493 route_match_ip_address_free
496 /* `match ip address prefix-list PREFIX_LIST' */
498 static enum route_map_cmd_result_t
499 route_match_ip_address_prefix_list(void *rule
, struct prefix
*prefix
,
500 route_map_object_t type
, void *object
)
502 struct prefix_list
*plist
;
504 if (type
== RMAP_EIGRP
) {
505 plist
= prefix_list_lookup(AFI_IP
, (char *)rule
);
509 return (prefix_list_apply(plist
, prefix
) == PREFIX_DENY
516 static void *route_match_ip_address_prefix_list_compile(const char *arg
)
518 return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED
, arg
);
521 static void route_match_ip_address_prefix_list_free(void *rule
)
523 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
526 static const struct route_map_rule_cmd
527 route_match_ip_address_prefix_list_cmd
= {
528 "ip address prefix-list",
529 route_match_ip_address_prefix_list
,
530 route_match_ip_address_prefix_list_compile
,
531 route_match_ip_address_prefix_list_free
534 /* `match tag TAG' */
535 /* Match function return 1 if match is success else return zero. */
536 static enum route_map_cmd_result_t
537 route_match_tag(void *rule
, struct prefix
*prefix
, route_map_object_t type
,
540 // unsigned short *tag;
541 // struct rip_info *rinfo;
543 // if (type == RMAP_EIGRP)
548 // /* The information stored by rinfo is host ordered. */
549 // /*if (rinfo->tag == *tag)
550 // return RMAP_MATCH;
552 // return RMAP_NOMATCH;*/
557 /* Route map `match tag' match statement. `arg' is TAG value */
558 static void *route_match_tag_compile(const char *arg
)
560 // unsigned short *tag;
562 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
563 // *tag = atoi (arg);
568 /* Free route map's compiled `match tag' value. */
569 static void route_match_tag_free(void *rule
)
571 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
574 /* Route map commands for tag matching. */
575 static const struct route_map_rule_cmd route_match_tag_cmd
= {
578 route_match_tag_compile
,
582 /* Set metric to attribute. */
583 static enum route_map_cmd_result_t
584 route_set_metric(void *rule
, struct prefix
*prefix
,
585 route_map_object_t type
, void *object
)
587 // if (type == RMAP_RIP)
589 // struct rip_metric_modifier *mod;
590 // struct rip_info *rinfo;
595 // /*if (mod->type == metric_increment)
596 // rinfo->metric_out += mod->metric;
597 // else if (mod->type == metric_decrement)
598 // rinfo->metric_out -= mod->metric;
599 // else if (mod->type == metric_absolute)
600 // rinfo->metric_out = mod->metric;
602 // if ((signed int)rinfo->metric_out < 1)
603 // rinfo->metric_out = 1;
604 // if (rinfo->metric_out > RIP_METRIC_INFINITY)
605 // rinfo->metric_out = RIP_METRIC_INFINITY;*/
607 // rinfo->metric_set = 1;
612 /* set metric compilation. */
613 static void *route_set_metric_compile(const char *arg
)
619 // char *endptr = NULL;
620 // struct rip_metric_modifier *mod;
622 // len = strlen (arg);
628 // /* Examine first character. */
629 // if (arg[0] == '+')
631 // //type = metric_increment;
634 // else if (arg[0] == '-')
636 // //type = metric_decrement;
640 // type = metric_absolute;*/
642 // /* Check beginning with digit string. */
643 // if (*pnt < '0' || *pnt > '9')
646 // /* Convert string to integer. */
647 // metric = strtol (pnt, &endptr, 10);
649 // if (metric == LONG_MAX || *endptr != '\0')
651 // /*if (metric < 0 || metric > RIP_METRIC_INFINITY)
654 // mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
655 // sizeof(struct rip_metric_modifier));
657 // mod->metric = metric;
662 /* Free route map's compiled `set metric' value. */
663 static void route_set_metric_free(void *rule
)
665 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
668 /* Set metric rule structure. */
669 static const struct route_map_rule_cmd route_set_metric_cmd
= {
672 route_set_metric_compile
,
673 route_set_metric_free
,
676 /* `set ip next-hop IP_ADDRESS' */
678 /* Set nexthop to object. object must be pointer to struct attr. */
679 static enum route_map_cmd_result_t
680 route_set_ip_nexthop(void *rule
, struct prefix
*prefix
,
681 route_map_object_t type
, void *object
)
683 // struct in_addr *address;
684 // struct rip_info *rinfo;
686 // if(type == RMAP_RIP)
688 // /* Fetch routemap's rule information. */
692 // /* Set next hop value. */
693 // rinfo->nexthop_out = *address;
699 /* Route map `ip nexthop' compile function. Given string is converted
700 to struct in_addr structure. */
701 static void *route_set_ip_nexthop_compile(const char *arg
)
704 // struct in_addr *address;
706 // address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(struct
709 // ret = inet_aton (arg, address);
713 // XFREE (MTYPE_ROUTE_MAP_COMPILED, address);
720 /* Free route map's compiled `ip nexthop' value. */
721 static void route_set_ip_nexthop_free(void *rule
)
723 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
726 /* Route map commands for ip nexthop set. */
727 static const struct route_map_rule_cmd route_set_ip_nexthop_cmd
= {
729 route_set_ip_nexthop
,
730 route_set_ip_nexthop_compile
,
731 route_set_ip_nexthop_free
736 /* Set tag to object. object must be pointer to struct attr. */
737 static enum route_map_cmd_result_t
738 route_set_tag(void *rule
, struct prefix
*prefix
,
739 route_map_object_t type
, void *object
)
741 // unsigned short *tag;
742 // struct rip_info *rinfo;
744 // if(type == RMAP_RIP)
746 // /* Fetch routemap's rule information. */
750 // /* Set next hop value. */
751 // rinfo->tag_out = *tag;
757 /* Route map `tag' compile function. Given string is converted
758 to unsigned short. */
759 static void *route_set_tag_compile(const char *arg
)
761 // unsigned short *tag;
763 // tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof(unsigned short));
764 // *tag = atoi (arg);
769 /* Free route map's compiled `ip nexthop' value. */
770 static void route_set_tag_free(void *rule
)
772 XFREE(MTYPE_ROUTE_MAP_COMPILED
, rule
);
775 /* Route map commands for tag set. */
776 static const struct route_map_rule_cmd route_set_tag_cmd
= {
779 route_set_tag_compile
,
783 #define MATCH_STR "Match values from routing table\n"
784 #define SET_STR "Set values in destination routing protocol\n"
788 "match metric (0-4294967295)",
790 "Match metric of route\n"
793 return eigrp_route_match_add(vty
, vty
->index
, "metric", argv
[0]);
796 DEFUN (no_match_metric
,
801 "Match metric of route\n")
804 return eigrp_route_match_delete(vty
, vty
->index
, "metric",
807 return eigrp_route_match_delete(vty
, vty
->index
, "metric", argv
[0]);
810 ALIAS(no_match_metric
, no_match_metric_val_cmd
,
811 "no match metric (0-4294967295)", NO_STR MATCH_STR
812 "Match metric of route\n"
815 DEFUN (match_interface
,
817 "match interface WORD",
819 "Match first hop interface of route\n"
822 return eigrp_route_match_add(vty
, vty
->index
, "interface", argv
[0]);
825 DEFUN (no_match_interface
,
826 no_match_interface_cmd
,
827 "no match interface",
830 "Match first hop interface of route\n")
833 return eigrp_route_match_delete(vty
, vty
->index
, "interface",
836 return eigrp_route_match_delete(vty
, vty
->index
, "interface", argv
[0]);
839 ALIAS(no_match_interface
, no_match_interface_val_cmd
, "no match interface WORD",
841 "Match first hop interface of route\n"
844 DEFUN (match_ip_next_hop
,
845 match_ip_next_hop_cmd
,
846 "match ip next-hop ACCESSLIST4_NAME",
849 "Match next-hop address of route\n"
850 "IP Access-list name\n")
852 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
855 DEFUN (no_match_ip_next_hop
,
856 no_match_ip_next_hop_cmd
,
857 "no match ip next-hop",
861 "Match next-hop address of route\n")
864 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
867 return eigrp_route_match_delete(vty
, vty
->index
, "ip next-hop",
871 ALIAS(no_match_ip_next_hop
, no_match_ip_next_hop_val_cmd
,
872 "no match ip next-hop ACCESSLIST4_NAME", NO_STR MATCH_STR IP_STR
873 "Match next-hop address of route\n"
874 "IP Access-list name\n")
876 DEFUN (match_ip_next_hop_prefix_list
,
877 match_ip_next_hop_prefix_list_cmd
,
878 "match ip next-hop prefix-list PREFIXLIST_NAME",
881 "Match next-hop address of route\n"
882 "Match entries of prefix-lists\n"
883 "IP prefix-list name\n")
885 return eigrp_route_match_add(vty
, vty
->index
, "ip next-hop prefix-list",
889 DEFUN (no_match_ip_next_hop_prefix_list
,
890 no_match_ip_next_hop_prefix_list_cmd
,
891 "no match ip next-hop prefix-list",
895 "Match next-hop address of route\n"
896 "Match entries of prefix-lists\n")
899 return eigrp_route_match_delete(
900 vty
, vty
->index
, "ip next-hop prefix-list", NULL
);
902 return eigrp_route_match_delete(vty
, vty
->index
,
903 "ip next-hop prefix-list", argv
[0]);
906 ALIAS(no_match_ip_next_hop_prefix_list
,
907 no_match_ip_next_hop_prefix_list_val_cmd
,
908 "no match ip next-hop prefix-list PREFIXLIST_NAME", NO_STR MATCH_STR IP_STR
909 "Match next-hop address of route\n"
910 "Match entries of prefix-lists\n"
911 "IP prefix-list name\n")
913 DEFUN (match_ip_address
,
914 match_ip_address_cmd
,
915 "match ip address ACCESSLIST4_NAME",
918 "Match address of route\n"
919 "IP Access-list name\n")
921 return eigrp_route_match_add(vty
, vty
->index
, "ip address", argv
[0]);
924 DEFUN (no_match_ip_address
,
925 no_match_ip_address_cmd
,
926 "no match ip address",
930 "Match address of route\n")
933 return eigrp_route_match_delete(vty
, vty
->index
, "ip address",
936 return eigrp_route_match_delete(vty
, vty
->index
, "ip address", argv
[0]);
939 ALIAS(no_match_ip_address
, no_match_ip_address_val_cmd
,
940 "no match ip address ACCESSLIST4_NAME", NO_STR MATCH_STR IP_STR
941 "Match address of route\n"
942 "IP Access-list name\n")
944 DEFUN (match_ip_address_prefix_list
,
945 match_ip_address_prefix_list_cmd
,
946 "match ip address prefix-list PREFIXLIST_NAME",
949 "Match address of route\n"
950 "Match entries of prefix-lists\n"
951 "IP prefix-list name\n")
953 return eigrp_route_match_add(vty
, vty
->index
, "ip address prefix-list",
957 DEFUN (no_match_ip_address_prefix_list
,
958 no_match_ip_address_prefix_list_cmd
,
959 "no match ip address prefix-list",
963 "Match address of route\n"
964 "Match entries of prefix-lists\n")
967 return eigrp_route_match_delete(vty
, vty
->index
,
968 "ip address prefix-list", NULL
);
970 return eigrp_route_match_delete(vty
, vty
->index
,
971 "ip address prefix-list", argv
[0]);
974 ALIAS(no_match_ip_address_prefix_list
, no_match_ip_address_prefix_list_val_cmd
,
975 "no match ip address prefix-list PREFIXLIST_NAME", NO_STR MATCH_STR IP_STR
976 "Match address of route\n"
977 "Match entries of prefix-lists\n"
978 "IP prefix-list name\n")
982 "match tag (0-65535)",
984 "Match tag of route\n"
987 return eigrp_route_match_add(vty
, vty
->index
, "tag", argv
[0]);
995 "Match tag of route\n")
998 return eigrp_route_match_delete(vty
, vty
->index
, "tag", NULL
);
1000 return eigrp_route_match_delete(vty
, vty
->index
, "tag", argv
[0]);
1003 ALIAS(no_match_tag
, no_match_tag_val_cmd
, "no match tag (0-65535)",
1005 "Match tag of route\n"
1012 "set metric (0-4294967295)",
1014 "Metric value for destination routing protocol\n"
1017 return eigrp_route_set_add(vty
, vty
->index
, "metric", argv
[0]);
1020 ALIAS(set_metric
, set_metric_addsub_cmd
, "set metric <+/-metric>", SET_STR
1021 "Metric value for destination routing protocol\n"
1022 "Add or subtract metric\n")
1024 DEFUN (no_set_metric
,
1029 "Metric value for destination routing protocol\n")
1032 return eigrp_route_set_delete(vty
, vty
->index
, "metric", NULL
);
1034 return eigrp_route_set_delete(vty
, vty
->index
, "metric", argv
[0]);
1037 ALIAS(no_set_metric
, no_set_metric_val_cmd
,
1038 "no set metric ((0-4294967295)|<+/-metric>)", NO_STR SET_STR
1039 "Metric value for destination routing protocol\n"
1041 "Add or subtract metric\n")
1043 DEFUN (set_ip_nexthop
,
1045 "set ip next-hop A.B.C.D",
1048 "Next hop address\n"
1049 "IP address of next hop\n")
1054 ret
= str2sockunion(argv
[0], &su
);
1056 vty_out(vty
, "%% Malformed next-hop address\n");
1057 return CMD_WARNING_CONFIG_FAILED
;
1060 return eigrp_route_set_add(vty
, vty
->index
, "ip next-hop", argv
[0]);
1063 DEFUN (no_set_ip_nexthop
,
1064 no_set_ip_nexthop_cmd
,
1065 "no set ip next-hop",
1069 "Next hop address\n")
1072 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop",
1075 return eigrp_route_set_delete(vty
, vty
->index
, "ip next-hop", argv
[0]);
1078 ALIAS(no_set_ip_nexthop
, no_set_ip_nexthop_val_cmd
,
1079 "no set ip next-hop A.B.C.D", NO_STR SET_STR IP_STR
1080 "Next hop address\n"
1081 "IP address of next hop\n")
1085 "set tag (0-65535)",
1087 "Tag value for routing protocol\n"
1090 return eigrp_route_set_add(vty
, vty
->index
, "tag", argv
[0]);
1098 "Tag value for routing protocol\n")
1101 return eigrp_route_set_delete(vty
, vty
->index
, "tag", NULL
);
1103 return eigrp_route_set_delete(vty
, vty
->index
, "tag", argv
[0]);
1106 ALIAS(no_set_tag
, no_set_tag_val_cmd
, "no set tag (0-65535)", NO_STR SET_STR
1107 "Tag value for routing protocol\n"
1110 DEFUN (eigrp_distribute_list
,
1111 eigrp_distribute_list_cmd
,
1112 "distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
1113 "Filter networks in routing updates\n"
1114 "Specify a prefix\n"
1115 "Access-list name\n"
1116 "Filter incoming routing updates\n"
1117 "Filter outgoing routing updates\n"
1120 const char *ifname
= NULL
;
1121 int prefix
= (argv
[1]->type
== WORD_TKN
) ? 1 : 0;
1123 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1124 ifname
= argv
[argc
- 1]->arg
;
1126 return distribute_list_parser(prefix
, true, argv
[2 + prefix
]->text
,
1127 argv
[1 + prefix
]->arg
, ifname
);
1130 DEFUN (eigrp_no_distribute_list
,
1131 eigrp_no_distribute_list_cmd
,
1132 "no distribute-list [prefix] ACCESSLIST_NAME <in|out> [WORD]",
1134 "Filter networks in routing updates\n"
1135 "Specify a prefix\n"
1136 "Access-list name\n"
1137 "Filter incoming routing updates\n"
1138 "Filter outgoing routing updates\n"
1141 const char *ifname
= NULL
;
1142 int prefix
= (argv
[2]->type
== WORD_TKN
) ? 1 : 0;
1144 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1145 ifname
= argv
[argc
- 1]->arg
;
1147 return distribute_list_no_parser(vty
, prefix
, true,
1148 argv
[3 + prefix
]->text
,
1149 argv
[2 + prefix
]->arg
, ifname
);
1153 /* Route-map init */
1154 void eigrp_route_map_init()
1157 route_map_init_vty();
1158 route_map_add_hook(eigrp_route_map_update
);
1159 route_map_delete_hook(eigrp_route_map_update
);
1161 install_element(EIGRP_NODE
, &eigrp_distribute_list_cmd
);
1162 install_element(EIGRP_NODE
, &eigrp_no_distribute_list_cmd
);
1164 /*route_map_install_match (&route_match_metric_cmd);
1165 route_map_install_match (&route_match_interface_cmd);*/
1166 /*route_map_install_match (&route_match_ip_next_hop_cmd);
1167 route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
1168 route_map_install_match (&route_match_ip_address_cmd);
1169 route_map_install_match (&route_match_ip_address_prefix_list_cmd);*/
1170 /*route_map_install_match (&route_match_tag_cmd);*/
1172 /*route_map_install_set (&route_set_metric_cmd);
1173 route_map_install_set (&route_set_ip_nexthop_cmd);
1174 route_map_install_set (&route_set_tag_cmd);*/
1176 /*install_element (RMAP_NODE, &route_match_metric_cmd);
1177 install_element (RMAP_NODE, &no_match_metric_cmd);
1178 install_element (RMAP_NODE, &no_match_metric_val_cmd);
1179 install_element (RMAP_NODE, &route_match_interface_cmd);
1180 install_element (RMAP_NODE, &no_match_interface_cmd);
1181 install_element (RMAP_NODE, &no_match_interface_val_cmd);
1182 install_element (RMAP_NODE, &route_match_ip_next_hop_cmd);
1183 install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
1184 install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
1185 install_element (RMAP_NODE, &route_match_ip_next_hop_prefix_list_cmd);
1186 install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
1187 install_element (RMAP_NODE,
1188 &no_match_ip_next_hop_prefix_list_val_cmd);*/
1189 /*install_element (RMAP_NODE, &route_match_ip_address_cmd);
1190 install_element (RMAP_NODE, &no_match_ip_address_cmd);
1191 install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
1192 install_element (RMAP_NODE, &route_match_ip_address_prefix_list_cmd);
1193 install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
1194 install_element (RMAP_NODE,
1195 &no_match_ip_address_prefix_list_val_cmd);*/
1196 /*install_element (RMAP_NODE, &route_match_tag_cmd);
1197 install_element (RMAP_NODE, &no_match_tag_cmd);
1198 install_element (RMAP_NODE, &no_match_tag_val_cmd);*/
1200 /*install_element (RMAP_NODE, &set_metric_cmd);
1201 install_element (RMAP_NODE, &set_metric_addsub_cmd);
1202 install_element (RMAP_NODE, &no_set_metric_cmd);
1203 install_element (RMAP_NODE, &no_set_metric_val_cmd);
1204 install_element (RMAP_NODE, &set_ip_nexthop_cmd);
1205 install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
1206 install_element (RMAP_NODE, &no_set_ip_nexthop_val_cmd);
1207 install_element (RMAP_NODE, &set_tag_cmd);
1208 install_element (RMAP_NODE, &no_set_tag_cmd);
1209 install_element (RMAP_NODE, &no_set_tag_val_cmd);*/