/* BGP route print out function. */
DEFUN (show_ip_bgp_ipv4,
show_ip_bgp_ipv4_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4 [unicast]|ipv6 [unicast]|encap [unicast]|ipv4 multicast|vpnv4 unicast>] [<cidr-only|community|dampening <flap-statistics|dampened-paths>|regexp .LINE|route-map WORD|prefix-list WORD|filter-list WORD|community <AA:NN|local-AS|no-advertise|no-export> [exact-match]|community-list <(1-500)|WORD> [exact-match]|A.B.C.D/M longer-prefixes|X:X::X:X/M longer-prefixes>] [json]",
+ "show [ip] bgp [<view|vrf> WORD] [<ipv4 [unicast]|ipv6 [unicast]|encap [unicast]|ipv4 multicast|vpnv4 unicast>] [<cidr-only|community|dampening <flap-statistics|dampened-paths>|route-map WORD|prefix-list WORD|filter-list WORD|community <AA:NN|local-AS|no-advertise|no-export> [exact-match]|community-list <(1-500)|WORD> [exact-match]|A.B.C.D/M longer-prefixes|X:X::X:X/M longer-prefixes>] [json]",
SHOW_STR
IP_STR
BGP_STR
"Display detailed information about dampening\n"
"Display flap statistics of routes\n"
"Display paths suppressed due to dampening\n"
- "Display routes matching the AS path regular expression\n"
- "A regular-expression to match the BGP AS paths\n"
"Display routes matching the route-map\n"
"A route-map to match on\n"
"Display routes conforming to the prefix-list\n"
#include "prefix.h"
#include "filter.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "linklist.h"
return CMD_SUCCESS;
}
-/* Add bgp route map rule. */
-static int
-bgp_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Delete bgp route map rule. */
-static int
-bgp_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
/*
* This is the workhorse routine for processing in/out routemap
* modifications.
}
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 3;
- return bgp_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg,
- RMAP_EVENT_FILTER_ADDED);
-}
-
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_word = 4;
- if (argc <= idx_word)
- return bgp_route_match_delete (vty, vty->index, "ip address", NULL,
- RMAP_EVENT_FILTER_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip address", argv[idx_word]->arg,
- RMAP_EVENT_FILTER_DELETED);
-}
-
-
-DEFUN (match_ip_next_hop,
- match_ip_next_hop_cmd,
- "match ip next-hop <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 3;
- return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg,
- RMAP_EVENT_FILTER_ADDED);
-}
-
-
-DEFUN (no_match_ip_next_hop,
- no_match_ip_next_hop_cmd,
- "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_word = 4;
- if (argc <= idx_word)
- return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL,
- RMAP_EVENT_FILTER_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[idx_word]->arg,
- RMAP_EVENT_FILTER_DELETED);
-}
-
-
/* match probability */
DEFUN (match_probability,
match_probability_cmd,
}
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return bgp_route_match_add (vty, vty->index, "ip address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
-}
-
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 5;
- if (argc <= idx_word)
- return bgp_route_match_delete (vty, vty->index, "ip address prefix-list",
- NULL, RMAP_EVENT_PLIST_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
-}
-
-
-DEFUN (match_ip_next_hop_prefix_list,
- match_ip_next_hop_prefix_list_cmd,
- "match ip next-hop prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_cmd,
- "no match ip next-hop prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 5;
- if (argc <= idx_word)
- return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list",
- NULL, RMAP_EVENT_PLIST_DELETED);
- return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
-}
-
-
DEFUN (match_ip_route_source_prefix_list,
match_ip_route_source_prefix_list_cmd,
"match ip route-source prefix-list WORD",
}
-DEFUN (match_metric,
- match_metric_cmd,
- "match metric (0-4294967295)",
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return bgp_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
-
-
-DEFUN (no_match_metric,
- no_match_metric_cmd,
- "no match metric [(0-4294967295)]",
- NO_STR
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- int idx_number = 3;
- if (argc <= idx_number)
- return bgp_route_match_delete (vty, vty->index, "metric",
- NULL, RMAP_EVENT_MATCH_DELETED);
- return bgp_route_match_delete (vty, vty->index, "metric",
- argv[idx_number]->arg,
- RMAP_EVENT_MATCH_DELETED);
-}
-
-
DEFUN (match_local_pref,
match_local_pref_cmd,
"match local-preference (0-4294967295)",
RMAP_EVENT_MATCH_DELETED);
}
-
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- int idx_word = 2;
- return bgp_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
-
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface [WORD]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- return bgp_route_match_delete (vty, vty->index, "interface", argv[3]->arg,
- RMAP_EVENT_MATCH_DELETED);
-}
-
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-65535)",
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return bgp_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
-
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag [(1-65535)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- return bgp_route_match_delete (vty, vty->index, "tag", argv[3]->arg,
- RMAP_EVENT_MATCH_DELETED);
-}
-
-
-DEFUN (set_ip_nexthop,
- set_ip_nexthop_cmd,
- "set ip next-hop A.B.C.D",
- SET_STR
- IP_STR
- "Next hop address\n"
- "IP address of next hop\n")
-{
- int idx_ipv4 = 3;
- union sockunion su;
- int ret;
-
- ret = str2sockunion (argv[idx_ipv4]->arg, &su);
- if (ret < 0)
- {
- vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (su.sin.sin_addr.s_addr == 0 ||
- IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
- {
- vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast "
- "or reserved%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg);
-}
-
DEFUN (set_ip_nexthop_peer,
set_ip_nexthop_peer_cmd,
"set ip next-hop peer-address",
"Next hop address\n"
"Use peer address (for BGP only)\n")
{
- return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address");
+ return generic_set_add (vty, vty->index, "ip next-hop", "peer-address");
}
DEFUN (set_ip_nexthop_unchanged,
"Next hop address\n"
"Don't modify existing Next hop address\n")
{
- return bgp_route_set_add (vty, vty->index, "ip next-hop", "unchanged");
-}
-
-
-DEFUN (no_set_ip_nexthop,
- no_set_ip_nexthop_cmd,
- "no set ip next-hop [<peer-address|A.B.C.D>]",
- NO_STR
- SET_STR
- "Next hop address\n"
- "Use peer address (for BGP only)\n"
- "IP address of next hop\n")
-{
- int idx_peer = 4;
- if (argc <= idx_peer)
- return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL);
- return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[idx_peer]->arg);
-}
-
-
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>",
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n"
- "Assign round trip time\n"
- "Add round trip time\n"
- "Subtract round trip time\n"
- "Add metric\n"
- "Subtract metric\n")
-{
- int idx_number = 2;
- return bgp_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
-}
-
-
-DEFUN (no_set_metric,
- no_set_metric_cmd,
- "no set metric [(0-4294967295)]",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- int idx_number = 3;
- if (argc <= idx_number)
- return bgp_route_set_delete (vty, vty->index, "metric", NULL);
- return bgp_route_set_delete (vty, vty->index, "metric", argv[idx_number]->arg);
+ return generic_set_add (vty, vty->index, "ip next-hop", "unchanged");
}
"Preference value\n")
{
int idx_number = 2;
- return bgp_route_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg);
+ return generic_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg);
}
{
int idx_localpref = 3;
if (argc <= idx_localpref)
- return bgp_route_set_delete (vty, vty->index, "local-preference", NULL);
- return bgp_route_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg);
+ return generic_set_delete (vty, vty->index, "local-preference", NULL);
+ return generic_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg);
}
"Weight value\n")
{
int idx_number = 2;
- return bgp_route_set_add (vty, vty->index, "weight", argv[idx_number]->arg);
+ return generic_set_add (vty, vty->index, "weight", argv[idx_number]->arg);
}
{
int idx_weight = 3;
if (argc <= idx_weight)
- return bgp_route_set_delete (vty, vty->index, "weight", NULL);
- return bgp_route_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg);
+ return generic_set_delete (vty, vty->index, "weight", NULL);
+ return generic_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg);
}
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str);
+ ret = generic_set_add (vty, vty->index, "as-path prepend", str);
XFREE (MTYPE_TMP, str);
return ret;
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str);
+ ret = generic_set_delete (vty, vty->index, "as-path prepend", str);
XFREE (MTYPE_TMP, str);
return ret;
}
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str);
+ ret = generic_set_add (vty, vty->index, "as-path exclude", str);
XFREE (MTYPE_TMP, str);
return ret;
}
char *str;
str = argv_concat (argv, argc, idx_asn);
- ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str);
+ ret = generic_set_delete (vty, vty->index, "as-path exclude", str);
XFREE (MTYPE_TMP, str);
return ret;
}
argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1);
strcpy (argstr, str);
strcpy (argstr + strlen (str), " additive");
- ret = bgp_route_set_add (vty, vty->index, "community", argstr);
+ ret = generic_set_add (vty, vty->index, "community", argstr);
XFREE (MTYPE_TMP, argstr);
}
else
- ret = bgp_route_set_add (vty, vty->index, "community", str);
+ ret = generic_set_add (vty, vty->index, "community", str);
community_free (com);
"BGP community attribute\n"
"No community attribute\n")
{
- return bgp_route_set_add (vty, vty->index, "community", "none");
+ return generic_set_add (vty, vty->index, "community", "none");
}
DEFUN (no_set_community,
SET_STR
"BGP community attribute\n")
{
- return bgp_route_set_delete (vty, vty->index, "community", NULL);
+ return generic_set_delete (vty, vty->index, "community", NULL);
}
strcpy (str, argv[idx_comm_list]->arg);
strcpy (str + strlen (argv[idx_comm_list]->arg), " delete");
- bgp_route_set_add (vty, vty->index, "comm-list", str);
+ generic_set_add (vty, vty->index, "comm-list", str);
XFREE (MTYPE_TMP, str);
return CMD_SUCCESS;
SET_STR
"set BGP community list (for deletion)\n")
{
- return bgp_route_set_delete (vty, vty->index, "comm-list", NULL);
+ return generic_set_delete (vty, vty->index, "comm-list", NULL);
}
char *str;
str = argv_concat (argv, argc, idx_asn_nn);
- ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str);
+ ret = generic_set_add (vty, vty->index, "extcommunity rt", str);
XFREE (MTYPE_TMP, str);
return ret;
"BGP extended community attribute\n"
"Route Target extended community\n")
{
- return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL);
+ return generic_set_delete (vty, vty->index, "extcommunity rt", NULL);
}
char *str;
str = argv_concat (argv, argc, idx_asn_nn);
- ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str);
+ ret = generic_set_add (vty, vty->index, "extcommunity soo", str);
XFREE (MTYPE_TMP, str);
return ret;
}
"BGP extended community attribute\n"
"Site-of-Origin extended community\n")
{
- return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL);
+ return generic_set_delete (vty, vty->index, "extcommunity soo", NULL);
}
{
int idx_origin = 2;
if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0)
- return bgp_route_set_add (vty, vty->index, "origin", "igp");
+ return generic_set_add (vty, vty->index, "origin", "igp");
if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0)
- return bgp_route_set_add (vty, vty->index, "origin", "egp");
+ return generic_set_add (vty, vty->index, "origin", "egp");
if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0)
- return bgp_route_set_add (vty, vty->index, "origin", "incomplete");
+ return generic_set_add (vty, vty->index, "origin", "incomplete");
return CMD_WARNING;
}
SET_STR
"BGP origin code\n")
{
- return bgp_route_set_delete (vty, vty->index, "origin", NULL);
+ return generic_set_delete (vty, vty->index, "origin", NULL);
}
SET_STR
"BGP atomic aggregate attribute\n" )
{
- return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL);
+ return generic_set_add (vty, vty->index, "atomic-aggregate", NULL);
}
DEFUN (no_set_atomic_aggregate,
SET_STR
"BGP atomic aggregate attribute\n" )
{
- return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL);
+ return generic_set_delete (vty, vty->index, "atomic-aggregate", NULL);
}
DEFUN (set_aggregator_as,
sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg);
- ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr);
+ ret = generic_set_add (vty, vty->index, "aggregator as", argstr);
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
char *argstr;
if (argc <= idx_asn)
- return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL);
+ return generic_set_delete (vty, vty->index, "aggregator as", NULL);
ret = inet_aton (argv[idx_ip]->arg, &address);
if (ret == 0)
sprintf (argstr, "%s %s", argv[idx_asn]->arg, argv[idx_ip]->arg);
- ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr);
+ ret = generic_set_delete (vty, vty->index, "aggregator as", argstr);
XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr);
}
-DEFUN (set_tag,
- set_tag_cmd,
- "set tag (1-65535)",
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return bgp_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-
-DEFUN (no_set_tag,
- no_set_tag_cmd,
- "no set tag [(1-65535)]",
- NO_STR
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- int idx_number = 3;
- if (argc <= idx_number)
- return bgp_route_set_delete (vty, vty->index, "tag", NULL);
- return bgp_route_set_delete (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-
-
#ifdef HAVE_IPV6
-DEFUN (match_ipv6_address,
- match_ipv6_address_cmd,
- "match ipv6 address WORD",
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
-{
- int idx_word = 3;
- return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
- RMAP_EVENT_FILTER_ADDED);
-}
-
-DEFUN (no_match_ipv6_address,
- no_match_ipv6_address_cmd,
- "no match ipv6 address WORD",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
-{
- int idx_word = 4;
- return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
- RMAP_EVENT_FILTER_DELETED);
-}
-
DEFUN (match_ipv6_next_hop,
match_ipv6_next_hop_cmd,
"match ipv6 next-hop X:X::X:X",
RMAP_EVENT_MATCH_DELETED);
}
-DEFUN (match_ipv6_address_prefix_list,
- match_ipv6_address_prefix_list_cmd,
- "match ipv6 address prefix-list WORD",
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ipv6_address_prefix_list,
- no_match_ipv6_address_prefix_list_cmd,
- "no match ipv6 address prefix-list WORD",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 5;
- return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
-}
DEFUN (set_ipv6_nexthop_peer,
set_ipv6_nexthop_peer_cmd,
"Next hop address\n"
"Use peer address (for BGP only)\n")
{
- return bgp_route_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL);
+ return generic_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL);
}
DEFUN (no_set_ipv6_nexthop_peer,
"IPv6 next-hop address\n"
"Use peer address (for BGP only)\n")
{
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL);
+ return generic_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL);
}
DEFUN (set_ipv6_nexthop_prefer_global,
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
- return bgp_route_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);;
+ return generic_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);;
}
DEFUN (no_set_ipv6_nexthop_prefer_global,
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL);
+ return generic_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL);
}
DEFUN (set_ipv6_nexthop_global,
return CMD_WARNING;
}
- return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
+ return generic_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
}
{
int idx_ipv6 = 5;
if (argc <= idx_ipv6)
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL);
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
-}
-
-
-DEFUN (set_ipv6_nexthop_local,
- set_ipv6_nexthop_local_cmd,
- "set ipv6 next-hop local X:X::X:X",
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 local address\n"
- "IPv6 address of next hop\n")
-{
- int idx_ipv6 = 4;
- struct in6_addr addr;
- int ret;
-
- ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
- if (!ret)
- {
- vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (!IN6_IS_ADDR_LINKLOCAL(&addr))
- {
- vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
-}
-
-
-DEFUN (no_set_ipv6_nexthop_local,
- no_set_ipv6_nexthop_local_cmd,
- "no set ipv6 next-hop local [X:X::X:X]",
- NO_STR
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 local address\n"
- "IPv6 address of next hop\n")
-{
- int idx_ipv6 = 5;
- if (argc <= idx_ipv6)
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL);
- return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[5]->arg);
+ return generic_set_delete (vty, vty->index, "ipv6 next-hop global", NULL);
+ return generic_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg);
}
-
#endif /* HAVE_IPV6 */
DEFUN (set_vpnv4_nexthop,
"IP address of next hop\n")
{
int idx_ipv4 = 3;
- return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
+ return generic_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
}
{
int idx_ipv4 = 4;
if (argc <= idx_ipv4)
- return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL);
- return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
+ return generic_set_delete (vty, vty->index, "vpnv4 next-hop", NULL);
+ return generic_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg);
}
"IP address of originator\n")
{
int idx_ipv4 = 2;
- return bgp_route_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg);
+ return generic_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg);
}
{
int idx_id = 3;
if (argc < idx_id)
- return bgp_route_set_delete (vty, vty->index, "originator-id", NULL);
- return bgp_route_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg);
+ return generic_set_delete (vty, vty->index, "originator-id", NULL);
+ return generic_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg);
}
route_map_delete_hook (bgp_route_map_delete);
route_map_event_hook (bgp_route_map_event);
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
+
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ipv6_address_hook (generic_match_add);
+ route_map_no_match_ipv6_address_hook (generic_match_delete);
+
+ route_map_match_ipv6_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_metric_hook (generic_match_add);
+ route_map_no_match_metric_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
+ route_map_set_ip_nexthop_hook (generic_set_add);
+ route_map_no_set_ip_nexthop_hook (generic_set_delete);
+
+ route_map_set_ipv6_nexthop_local_hook (generic_set_add);
+ route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete);
+
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
+
+ route_map_set_tag_hook (generic_set_add);
+ route_map_no_set_tag_hook (generic_set_delete);
+
route_map_install_match (&route_match_peer_cmd);
route_map_install_match (&route_match_local_pref_cmd);
route_map_install_match (&route_match_ip_address_cmd);
install_element (RMAP_NODE, &match_peer_cmd);
install_element (RMAP_NODE, &match_peer_local_cmd);
install_element (RMAP_NODE, &no_match_peer_cmd);
- install_element (RMAP_NODE, &match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
install_element (RMAP_NODE, &match_ip_route_source_cmd);
install_element (RMAP_NODE, &no_match_ip_route_source_cmd);
- install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd);
install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd);
install_element (RMAP_NODE, &match_aspath_cmd);
install_element (RMAP_NODE, &no_match_aspath_cmd);
- install_element (RMAP_NODE, &match_metric_cmd);
- install_element (RMAP_NODE, &no_match_metric_cmd);
install_element (RMAP_NODE, &match_local_pref_cmd);
install_element (RMAP_NODE, &no_match_local_pref_cmd);
install_element (RMAP_NODE, &match_community_cmd);
install_element (RMAP_NODE, &no_match_origin_cmd);
install_element (RMAP_NODE, &match_probability_cmd);
install_element (RMAP_NODE, &no_match_probability_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
- install_element (RMAP_NODE, &set_ip_nexthop_cmd);
install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd);
install_element (RMAP_NODE, &set_ip_nexthop_unchanged_cmd);
- install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
install_element (RMAP_NODE, &set_local_pref_cmd);
install_element (RMAP_NODE, &no_set_local_pref_cmd);
install_element (RMAP_NODE, &set_weight_cmd);
install_element (RMAP_NODE, &no_set_weight_cmd);
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &set_aspath_prepend_asn_cmd);
install_element (RMAP_NODE, &set_aspath_prepend_lastas_cmd);
install_element (RMAP_NODE, &set_aspath_exclude_cmd);
install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd);
install_element (RMAP_NODE, &set_originator_id_cmd);
install_element (RMAP_NODE, &no_set_originator_id_cmd);
- install_element (RMAP_NODE, &set_tag_cmd);
- install_element (RMAP_NODE, &no_set_tag_cmd);
#ifdef HAVE_IPV6
route_map_install_match (&route_match_ipv6_address_cmd);
route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
route_map_install_set (&route_set_ipv6_nexthop_peer_cmd);
- install_element (RMAP_NODE, &match_ipv6_address_cmd);
- install_element (RMAP_NODE, &no_match_ipv6_address_cmd);
install_element (RMAP_NODE, &match_ipv6_next_hop_cmd);
install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd);
- install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_prefer_global_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd);
- install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
- install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd);
#endif /* HAVE_IPV6 */
route_set_metric_free
};
-/* ------------------------------------------------------------*/
-
-static int
-isis_route_match_add(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-static int
-isis_route_match_delete(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-static int
-isis_route_set_add(struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set(index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- return CMD_SUCCESS;
-}
-
-static int
-isis_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- return CMD_SUCCESS;
-}
-
-/* ------------------------------------------------------------*/
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 3;
- return isis_route_match_add(vty, vty->index, "ip address", argv[idx_acl]->arg);
-}
-
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_val_cmd,
- "no match ip address [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 4;
- if (argc == 4)
- return isis_route_match_delete(vty, vty->index, "ip address", NULL);
- return isis_route_match_delete(vty, vty->index, "ip address", argv[idx_acl]->arg);
-}
-
-
-/* ------------------------------------------------------------*/
-
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
-}
-
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 5;
- if (argc == 5)
- return isis_route_match_delete (vty, vty->index, "ip address prefix-list", NULL);
- return isis_route_match_delete (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
-}
-
-
-/* ------------------------------------------------------------*/
-
-DEFUN (match_ipv6_address,
- match_ipv6_address_cmd,
- "match ipv6 address WORD",
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
-{
- int idx_word = 3;
- return isis_route_match_add(vty, vty->index, "ipv6 address", argv[idx_word]->arg);
-}
-
-
-DEFUN (no_match_ipv6_address,
- no_match_ipv6_address_val_cmd,
- "no match ipv6 address [WORD]",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
-{
- int idx_word = 4;
- if (argc == 4)
- return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL);
- return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[idx_word]->arg);
-}
-
-
-/* ------------------------------------------------------------*/
-
-DEFUN (match_ipv6_address_prefix_list,
- match_ipv6_address_prefix_list_cmd,
- "match ipv6 address prefix-list WORD",
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_ipv6_address_prefix_list,
- no_match_ipv6_address_prefix_list_cmd,
- "no match ipv6 address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
+void
+isis_route_map_init(void)
{
- int idx_word = 5;
- if (argc == 5)
- return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", NULL);
- return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg);
-}
+ route_map_init();
+ route_map_init_vty();
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
-/* ------------------------------------------------------------*/
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
-/* set metric already exists e.g. in the ospf routemap. vtysh doesn't cope well with different
- * commands at the same node, therefore add set metric with the same 32-bit range as ospf and
- * verify that the input is a valid isis metric */
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric (0-4294967295)",
- SET_STR
- "Metric vale for destination routing protocol\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return isis_route_set_add(vty, vty->index, "metric", argv[idx_number]->arg);
-}
+ route_map_match_ipv6_address_hook (generic_match_add);
+ route_map_no_match_ipv6_address_hook (generic_match_delete);
-DEFUN (no_set_metric,
- no_set_metric_val_cmd,
- "no set metric [(0-4294967295)]",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- int idx_number = 3;
- if (argc == 3)
- return isis_route_set_delete(vty, vty->index, "metric", NULL);
- return isis_route_set_delete(vty, vty->index, "metric", argv[idx_number]->arg);
-}
+ route_map_match_ipv6_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete);
-void
-isis_route_map_init(void)
-{
- route_map_init();
- route_map_init_vty();
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
route_map_install_match(&route_match_ip_address_cmd);
- install_element(RMAP_NODE, &match_ip_address_cmd);
- install_element(RMAP_NODE, &no_match_ip_address_val_cmd);
-
route_map_install_match(&route_match_ip_address_prefix_list_cmd);
- install_element(RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element(RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
-
route_map_install_match(&route_match_ipv6_address_cmd);
- install_element(RMAP_NODE, &match_ipv6_address_cmd);
- install_element(RMAP_NODE, &no_match_ipv6_address_val_cmd);
-
route_map_install_match(&route_match_ipv6_address_prefix_list_cmd);
- install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
- install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
-
route_map_install_set(&route_set_metric_cmd);
- install_element(RMAP_NODE, &set_metric_cmd);
- install_element(RMAP_NODE, &no_set_metric_val_cmd);
}
#include "memory.h"
#include "vector.h"
#include "prefix.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
-#include "vty.h"
#include "log.h"
#include "hash.h"
/* Vector for route set rules. */
static vector route_set_vec;
+struct route_map_match_set_hooks
+{
+ /* match interface */
+ int (*match_interface) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match interface */
+ int (*no_match_interface) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match ip address */
+ int (*match_ip_address) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ip address */
+ int (*no_match_ip_address) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match ip address prefix list */
+ int (*match_ip_address_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ip address prefix list */
+ int (*no_match_ip_address_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match ip next hop */
+ int (*match_ip_next_hop) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ip next hop */
+ int (*no_match_ip_next_hop) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match ip next hop prefix list */
+ int (*match_ip_next_hop_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ip next hop prefix list */
+ int (*no_match_ip_next_hop_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match ipv6 address */
+ int (*match_ipv6_address) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ipv6 address */
+ int (*no_match_ipv6_address) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+
+ /* match ipv6 address prefix list */
+ int (*match_ipv6_address_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match ipv6 address prefix list */
+ int (*no_match_ipv6_address_prefix_list) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match metric */
+ int (*match_metric) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match metric */
+ int (*no_match_metric) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* match tag */
+ int (*match_tag) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* no match tag */
+ int (*no_match_tag) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+ /* set ip nexthop */
+ int (*set_ip_nexthop) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* no set ip nexthop */
+ int (*no_set_ip_nexthop) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* set ipv6 nexthop local */
+ int (*set_ipv6_nexthop_local) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* no set ipv6 nexthop local */
+ int (*no_set_ipv6_nexthop_local) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* set metric */
+ int (*set_metric) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* no set metric */
+ int (*no_set_metric) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* set tag */
+ int (*set_tag) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+ /* no set tag */
+ int (*no_set_tag) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg);
+
+};
+
+struct route_map_match_set_hooks rmap_match_set_hook;
+
+/* match interface */
+void
+route_map_match_interface_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_interface = func;
+}
+
+/* no match interface */
+void
+route_map_no_match_interface_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_interface = func;
+}
+
+/* match ip address */
+void
+route_map_match_ip_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ip_address = func;
+}
+
+/* no match ip address */
+void
+route_map_no_match_ip_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ip_address = func;
+}
+
+/* match ip address prefix list */
+void
+route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ip_address_prefix_list = func;
+}
+
+/* no match ip address prefix list */
+void
+route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ip_address_prefix_list = func;
+}
+
+/* match ip next hop */
+void
+route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ip_next_hop = func;
+}
+
+/* no match ip next hop */
+void
+route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ip_next_hop = func;
+}
+
+/* match ip next hop prefix list */
+void
+route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ip_next_hop_prefix_list = func;
+}
+
+/* no match ip next hop prefix list */
+void
+route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func;
+}
+
+/* match ipv6 address */
+void
+route_map_match_ipv6_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ipv6_address = func;
+}
+
+/* no match ipv6 address */
+void
+route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ipv6_address = func;
+}
+
+
+/* match ipv6 address prefix list */
+void
+route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_ipv6_address_prefix_list = func;
+}
+
+/* no match ipv6 address prefix list */
+void
+route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_ipv6_address_prefix_list = func;
+}
+
+/* match metric */
+void
+route_map_match_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_metric = func;
+}
+
+/* no match metric */
+void
+route_map_no_match_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_metric = func;
+}
+
+/* match tag */
+void
+route_map_match_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.match_tag = func;
+}
+
+/* no match tag */
+void
+route_map_no_match_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type))
+{
+ rmap_match_set_hook.no_match_tag = func;
+}
+
+/* set ip nexthop */
+void
+route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.set_ip_nexthop = func;
+}
+
+/* no set ip nexthop */
+void
+route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.no_set_ip_nexthop = func;
+}
+
+/* set ipv6 nexthop local */
+void
+route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.set_ipv6_nexthop_local = func;
+}
+
+/* no set ipv6 nexthop local */
+void
+route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.no_set_ipv6_nexthop_local = func;
+}
+
+/* set metric */
+void
+route_map_set_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.set_metric = func;
+}
+
+/* no set metric */
+void
+route_map_no_set_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.no_set_metric = func;
+}
+
+/* set tag */
+void
+route_map_set_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.set_tag = func;
+}
+
+/* no set tag */
+void
+route_map_no_set_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.no_set_tag = func;
+}
+
+int
+generic_match_add (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type)
+{
+ int ret;
+
+ ret = route_map_add_match (index, command, arg);
+ if (ret)
+ {
+ switch (ret)
+ {
+ case RMAP_RULE_MISSING:
+ vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ case RMAP_COMPILE_ERROR:
+ vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+
+ if (type != RMAP_EVENT_MATCH_ADDED)
+ {
+ route_map_upd8_dependency (type, arg, index->map->name);
+ }
+ return CMD_SUCCESS;
+}
+
+int
+generic_match_delete (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type)
+{
+ int ret;
+ char *dep_name = NULL;
+ const char *tmpstr;
+ char *rmap_name = NULL;
+
+ if (type != RMAP_EVENT_MATCH_DELETED)
+ {
+ /* ignore the mundane, the types without any dependency */
+ if (arg == NULL)
+ {
+ if ((tmpstr = route_map_get_match_arg(index, command)) != NULL)
+ dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
+ }
+ else
+ {
+ dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg);
+ }
+ rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
+ }
+
+ ret = route_map_delete_match (index, command, dep_name);
+ if (ret)
+ {
+ switch (ret)
+ {
+ case RMAP_RULE_MISSING:
+ vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE);
+ break;
+ case RMAP_COMPILE_ERROR:
+ vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE);
+ break;
+ }
+ if (dep_name)
+ XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
+ if (rmap_name)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
+ return CMD_WARNING;
+ }
+
+ if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
+ route_map_upd8_dependency(type, dep_name, rmap_name);
+
+ if (dep_name)
+ XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
+ if (rmap_name)
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
+
+ return CMD_SUCCESS;
+}
+
+int
+generic_set_add (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg)
+{
+ int ret;
+
+ ret = route_map_add_set (index, command, arg);
+ if (ret)
+ {
+ switch (ret)
+ {
+ case RMAP_RULE_MISSING:
+ vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ case RMAP_COMPILE_ERROR:
+ vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+ return CMD_SUCCESS;
+}
+
+int
+generic_set_delete (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg)
+{
+ int ret;
+
+ ret = route_map_delete_set (index, command, arg);
+ if (ret)
+ {
+ switch (ret)
+ {
+ case RMAP_RULE_MISSING:
+ vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ case RMAP_COMPILE_ERROR:
+ vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+ return CMD_SUCCESS;
+}
+
+
/* Route map rule. This rule has both `match' rule and `set' rule. */
struct route_map_rule
{
XFREE (MTYPE_ROUTE_MAP_NAME, name);
}
+
/* VTY related functions. */
+DEFUN (match_interface,
+ match_interface_cmd,
+ "match interface WORD",
+ MATCH_STR
+ "match first hop interface of route\n"
+ "Interface name\n")
+{
+ int idx_word = 2;
+
+ if (rmap_match_set_hook.match_interface)
+ return rmap_match_set_hook.match_interface (vty, vty->index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_match_interface,
+ no_match_interface_cmd,
+ "no match interface [INTERFACE]",
+ NO_STR
+ MATCH_STR
+ "Match first hop interface of route\n"
+ "Interface name\n")
+{
+ char *iface = (argc == 4) ? argv[3]->arg : NULL;
+
+ if (rmap_match_set_hook.no_match_interface)
+ return rmap_match_set_hook.no_match_interface (vty, vty->index, "interface", iface, RMAP_EVENT_MATCH_DELETED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ip_address,
+ match_ip_address_cmd,
+ "match ip address <(1-199)|(1300-2699)|WORD>",
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
+{
+ int idx_acl = 3;
+
+ if (rmap_match_set_hook.match_ip_address)
+ return rmap_match_set_hook.match_ip_address (vty, vty->index, "ip address", argv[idx_acl]->arg,
+ RMAP_EVENT_FILTER_ADDED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_match_ip_address,
+ no_match_ip_address_cmd,
+ "no match ip address [<(1-199)|(1300-2699)|WORD>]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
+{
+ int idx_word = 4;
+
+ if (rmap_match_set_hook.no_match_ip_address)
+ {
+ if (argc <= idx_word)
+ return rmap_match_set_hook.no_match_ip_address (vty, vty->index, "ip address", NULL,
+ RMAP_EVENT_FILTER_DELETED);
+ return rmap_match_set_hook.no_match_ip_address (vty, vty->index, "ip address", argv[idx_word]->arg,
+ RMAP_EVENT_FILTER_DELETED);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ip_address_prefix_list,
+ match_ip_address_prefix_list_cmd,
+ "match ip address prefix-list WORD",
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 4;
+ if (rmap_match_set_hook.match_ip_address_prefix_list)
+ return rmap_match_set_hook.match_ip_address_prefix_list (vty, vty->index, "ip address prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_match_ip_address_prefix_list,
+ no_match_ip_address_prefix_list_cmd,
+ "no match ip address prefix-list [WORD]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 5;
+
+ if (rmap_match_set_hook.no_match_ip_address_prefix_list)
+ {
+ if (argc <= idx_word)
+ return rmap_match_set_hook.no_match_ip_address_prefix_list (vty, vty->index, "ip address prefix-list",
+ NULL, RMAP_EVENT_PLIST_DELETED);
+ return rmap_match_set_hook.no_match_ip_address_prefix_list(vty, vty->index, "ip address prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ip_next_hop,
+ match_ip_next_hop_cmd,
+ "match ip next-hop <(1-199)|(1300-2699)|WORD>",
+ MATCH_STR
+ IP_STR
+ "Match next-hop address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
+{
+ int idx_acl = 3;
+ if (rmap_match_set_hook.match_ip_next_hop)
+ return rmap_match_set_hook.match_ip_next_hop (vty, vty->index, "ip next-hop", argv[idx_acl]->arg,
+ RMAP_EVENT_FILTER_ADDED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_match_ip_next_hop,
+ no_match_ip_next_hop_cmd,
+ "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match next-hop address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
+{
+ int idx_word = 4;
+
+ if (rmap_match_set_hook.no_match_ip_next_hop)
+ {
+ if (argc <= idx_word)
+ return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop", NULL,
+ RMAP_EVENT_FILTER_DELETED);
+ return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop", argv[idx_word]->arg,
+ RMAP_EVENT_FILTER_DELETED);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ip_next_hop_prefix_list,
+ match_ip_next_hop_prefix_list_cmd,
+ "match ip next-hop prefix-list WORD",
+ MATCH_STR
+ IP_STR
+ "Match next-hop address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 4;
+ if (rmap_match_set_hook.match_ip_next_hop_prefix_list)
+ return rmap_match_set_hook.match_ip_next_hop_prefix_list (vty, vty->index, "ip next-hop prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_match_ip_next_hop_prefix_list,
+ no_match_ip_next_hop_prefix_list_cmd,
+ "no match ip next-hop prefix-list [WORD]",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match next-hop address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 5;
+
+ if (rmap_match_set_hook.no_match_ip_next_hop)
+ {
+ if (argc <= idx_word)
+ return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop prefix-list",
+ NULL, RMAP_EVENT_PLIST_DELETED);
+ return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ipv6_address,
+ match_ipv6_address_cmd,
+ "match ipv6 address WORD",
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 address of route\n"
+ "IPv6 access-list name\n")
+{
+ int idx_word = 3;
+ if (rmap_match_set_hook.match_ipv6_address)
+ return rmap_match_set_hook.match_ipv6_address (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
+ RMAP_EVENT_FILTER_ADDED);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_match_ipv6_address,
+ no_match_ipv6_address_cmd,
+ "no match ipv6 address WORD",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 address of route\n"
+ "IPv6 access-list name\n")
+{
+ int idx_word = 4;
+ if (rmap_match_set_hook.no_match_ipv6_address)
+ return rmap_match_set_hook.no_match_ipv6_address (vty, vty->index, "ipv6 address", argv[idx_word]->arg,
+ RMAP_EVENT_FILTER_DELETED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_ipv6_address_prefix_list,
+ match_ipv6_address_prefix_list_cmd,
+ "match ipv6 address prefix-list WORD",
+ MATCH_STR
+ IPV6_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 4;
+ if (rmap_match_set_hook.match_ipv6_address_prefix_list)
+ return rmap_match_set_hook.match_ipv6_address_prefix_list (vty, vty->index, "ipv6 address prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_match_ipv6_address_prefix_list,
+ no_match_ipv6_address_prefix_list_cmd,
+ "no match ipv6 address prefix-list WORD",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
+{
+ int idx_word = 5;
+ if (rmap_match_set_hook.no_match_ipv6_address_prefix_list)
+ return rmap_match_set_hook.no_match_ipv6_address_prefix_list(vty, vty->index, "ipv6 address prefix-list",
+ argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_metric,
+ match_metric_cmd,
+ "match metric (0-4294967295)",
+ MATCH_STR
+ "Match metric of route\n"
+ "Metric value\n")
+{
+ int idx_number = 2;
+ if (rmap_match_set_hook.match_metric)
+ return rmap_match_set_hook.match_metric(vty, vty->index, "metric", argv[idx_number]->arg,
+ RMAP_EVENT_MATCH_ADDED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_match_metric,
+ no_match_metric_cmd,
+ "no match metric [(0-4294967295)]",
+ NO_STR
+ MATCH_STR
+ "Match metric of route\n"
+ "Metric value\n")
+{
+ int idx_number = 3;
+ if (rmap_match_set_hook.no_match_metric)
+ {
+ if (argc <= idx_number)
+ return rmap_match_set_hook.no_match_metric (vty, vty->index, "metric",
+ NULL, RMAP_EVENT_MATCH_DELETED);
+ return rmap_match_set_hook.no_match_metric(vty, vty->index, "metric",
+ argv[idx_number]->arg,
+ RMAP_EVENT_MATCH_DELETED);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (match_tag,
+ match_tag_cmd,
+ "match tag (1-65535)",
+ MATCH_STR
+ "Match tag of route\n"
+ "Tag value\n")
+{
+ int idx_number = 2;
+ if (rmap_match_set_hook.match_tag)
+ return rmap_match_set_hook.match_tag(vty, vty->index, "tag", argv[idx_number]->arg,
+ RMAP_EVENT_MATCH_ADDED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_match_tag,
+ no_match_tag_cmd,
+ "no match tag [(1-65535)]",
+ NO_STR
+ MATCH_STR
+ "Match tag of route\n"
+ "Tag value\n")
+{
+ if (rmap_match_set_hook.no_match_tag)
+ return rmap_match_set_hook.no_match_tag (vty, vty->index, "tag", argv[3]->arg,
+ RMAP_EVENT_MATCH_DELETED);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (set_ip_nexthop,
+ set_ip_nexthop_cmd,
+ "set ip next-hop A.B.C.D",
+ SET_STR
+ IP_STR
+ "Next hop address\n"
+ "IP address of next hop\n")
+{
+ int idx_ipv4 = 3;
+ union sockunion su;
+ int ret;
+
+ ret = str2sockunion (argv[idx_ipv4]->arg, &su);
+ if (ret < 0)
+ {
+ vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if (su.sin.sin_addr.s_addr == 0 ||
+ IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
+ {
+ vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast "
+ "or reserved%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (rmap_match_set_hook.set_ip_nexthop)
+ return rmap_match_set_hook.set_ip_nexthop(vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_set_ip_nexthop,
+ no_set_ip_nexthop_cmd,
+ "no set ip next-hop [<peer-address|A.B.C.D>]",
+ NO_STR
+ SET_STR
+ "Next hop address\n"
+ "Use peer address (for BGP only)\n"
+ "IP address of next hop\n")
+{
+ int idx_peer = 4;
+
+ if (rmap_match_set_hook.no_set_ip_nexthop)
+ {
+ if (argc <= idx_peer)
+ return rmap_match_set_hook.no_set_ip_nexthop (vty, vty->index, "ip next-hop", NULL);
+ return rmap_match_set_hook.no_set_ip_nexthop (vty, vty->index, "ip next-hop", argv[idx_peer]->arg);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (set_ipv6_nexthop_local,
+ set_ipv6_nexthop_local_cmd,
+ "set ipv6 next-hop local X:X::X:X",
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "IPv6 local address\n"
+ "IPv6 address of next hop\n")
+{
+ int idx_ipv6 = 4;
+ struct in6_addr addr;
+ int ret;
+
+ ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr);
+ if (!ret)
+ {
+ vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if (!IN6_IS_ADDR_LINKLOCAL(&addr))
+ {
+ vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (rmap_match_set_hook.set_ipv6_nexthop_local)
+ return rmap_match_set_hook.set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_set_ipv6_nexthop_local,
+ no_set_ipv6_nexthop_local_cmd,
+ "no set ipv6 next-hop local [X:X::X:X]",
+ NO_STR
+ SET_STR
+ IPV6_STR
+ "IPv6 next-hop address\n"
+ "IPv6 local address\n"
+ "IPv6 address of next hop\n")
+{
+ int idx_ipv6 = 5;
+ if (rmap_match_set_hook.no_set_ipv6_nexthop_local)
+ {
+ if (argc <= idx_ipv6)
+ return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", NULL);
+ return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", argv[5]->arg);
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN (set_metric,
+ set_metric_cmd,
+ "set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>",
+ SET_STR
+ "Metric value for destination routing protocol\n"
+ "Metric value\n"
+ "Assign round trip time\n"
+ "Add round trip time\n"
+ "Subtract round trip time\n"
+ "Add metric\n"
+ "Subtract metric\n")
+{
+ int idx_number = 2;
+ if (rmap_match_set_hook.set_metric)
+ return rmap_match_set_hook.set_metric (vty, vty->index, "metric", argv[idx_number]->arg);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_set_metric,
+ no_set_metric_cmd,
+ "no set metric [(0-4294967295)]",
+ NO_STR
+ SET_STR
+ "Metric value for destination routing protocol\n"
+ "Metric value\n")
+{
+ int idx_number = 3;
+ if (rmap_match_set_hook.no_set_metric)
+ {
+ if (argc <= idx_number)
+ return rmap_match_set_hook.no_set_metric (vty, vty->index, "metric", NULL);
+ return rmap_match_set_hook.no_set_metric (vty, vty->index, "metric", argv[idx_number]->arg);
+ }
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (set_tag,
+ set_tag_cmd,
+ "set tag (1-65535)",
+ SET_STR
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+{
+ int idx_number = 2;
+ if (rmap_match_set_hook.set_tag)
+ return rmap_match_set_hook.set_tag (vty, vty->index, "tag", argv[idx_number]->arg);
+ return CMD_SUCCESS;
+}
+
+
+DEFUN (no_set_tag,
+ no_set_tag_cmd,
+ "no set tag [(1-65535)]",
+ NO_STR
+ SET_STR
+ "Tag value for routing protocol\n"
+ "Tag value\n")
+{
+ int idx_number = 3;
+ if (rmap_match_set_hook.no_set_tag)
+ {
+ if (argc <= idx_number)
+ return rmap_match_set_hook.no_set_tag (vty, vty->index, "tag", NULL);
+ return rmap_match_set_hook.no_set_tag (vty, vty->index, "tag", argv[idx_number]->arg);
+ }
+ return CMD_SUCCESS;
+}
+
+
+
DEFUN (route_map,
route_map_cmd,
"route-map WORD <deny|permit> (1-65535)",
/* Install show command */
install_element (ENABLE_NODE, &rmap_show_name_cmd);
+
+ install_element (RMAP_NODE, &match_interface_cmd);
+ install_element (RMAP_NODE, &no_match_interface_cmd);
+
+ install_element (RMAP_NODE, &match_ip_address_cmd);
+ install_element (RMAP_NODE, &no_match_ip_address_cmd);
+
+ install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
+ install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
+
+ install_element (RMAP_NODE, &match_ip_next_hop_cmd);
+ install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
+
+ install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
+ install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
+
+ install_element (RMAP_NODE, &match_ipv6_address_cmd);
+ install_element (RMAP_NODE, &no_match_ipv6_address_cmd);
+
+ install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
+ install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
+
+ install_element (RMAP_NODE, &match_metric_cmd);
+ install_element (RMAP_NODE, &no_match_metric_cmd);
+
+ install_element (RMAP_NODE, &match_tag_cmd);
+ install_element (RMAP_NODE, &no_match_tag_cmd);
+
+ install_element (RMAP_NODE, &set_ip_nexthop_cmd);
+ install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
+
+ install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
+ install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
+
+ install_element (RMAP_NODE, &set_metric_cmd);
+ install_element (RMAP_NODE, &no_set_metric_cmd);
+
+ install_element (RMAP_NODE, &set_tag_cmd);
+ install_element (RMAP_NODE, &no_set_tag_cmd);
+
}
extern void route_map_notify_dependencies (const char *affected_name,
route_map_event_t event);
+extern int generic_match_add (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+
+extern int generic_match_delete (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type);
+extern int generic_set_add (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg);
+extern int generic_set_delete (struct vty *vty, struct route_map_index *index,
+ const char *command, const char *arg);
+
+
+/* match interface */
+extern void route_map_match_interface_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match interface */
+extern void route_map_no_match_interface_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ip address */
+extern void route_map_match_ip_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ip address */
+extern void route_map_no_match_ip_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ip address prefix list */
+extern void route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ip address prefix list */
+extern void route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ip next hop */
+extern void route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ip next hop */
+extern void route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ip next hop prefix list */
+extern void route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ip next hop prefix list */
+extern void route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ipv6 address */
+extern void route_map_match_ipv6_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ipv6 address */
+extern void route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match ipv6 address prefix list */
+extern void route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match ipv6 address prefix list */
+extern void route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match metric */
+extern void route_map_match_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match metric */
+extern void route_map_no_match_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* match tag */
+extern void route_map_match_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* no match tag */
+extern void route_map_no_match_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg,
+ route_map_event_t type));
+/* set ip nexthop */
+extern void route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* no set ip nexthop */
+extern void route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* set ipv6 nexthop local */
+extern void route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* no set ipv6 nexthop local */
+extern void route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* set metric */
+extern void route_map_set_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* no set metric */
+extern void route_map_no_set_metric_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* set tag */
+extern void route_map_set_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
+/* no set tag */
+extern void route_map_no_set_tag_hook (int (*func) (struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg));
#endif /* _ZEBRA_ROUTEMAP_H */
return route_map_command_status (vty, ret);
}
-
/* add "set metric-type" */
DEFUN (ospf6_routemap_set_metric_type,
ospf6_routemap_set_metric_type_cmd,
return route_map_command_status (vty, ret);
}
-/* add "set metric" */
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric (0-4294967295)",
- "Set value\n"
- "Metric value\n"
- "Metric value\n")
-{
- int idx_number = 2;
- int ret = route_map_add_set ((struct route_map_index *) vty->index,
- "metric", argv[idx_number]->arg);
- return route_map_command_status (vty, ret);
-}
-
-/* delete "set metric" */
-DEFUN (no_set_metric,
- no_set_metric_cmd,
- "no set metric [(0-4294967295)]",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n")
-{
- int idx_number = 3;
- int ret = 0;
-
- if (argc == 3)
- ret = route_map_delete_set ((struct route_map_index *) vty->index,
- "metric", NULL);
- else
- ret = route_map_delete_set ((struct route_map_index *) vty->index,
- "metric", argv[idx_number]->arg);
- return route_map_command_status (vty, ret);
-}
-
-
/* add "set forwarding-address" */
DEFUN (ospf6_routemap_set_forwarding,
ospf6_routemap_set_forwarding_cmd,
route_map_add_hook (ospf6_asbr_routemap_update);
route_map_delete_hook (ospf6_asbr_routemap_update);
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
+
route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd);
route_map_install_match (&ospf6_routemap_rule_match_interface_cmd);
install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
- /* ASE Metric */
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &no_set_metric_cmd);
-
/* ASE Metric */
install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
return CMD_SUCCESS;
}
-DEFUN (router_zebra,
- router_zebra_cmd,
- "router zebra",
- "Enable a routing process\n"
- "Make connection to zebra daemon\n")
-{
- vty->node = ZEBRA_NODE;
- zclient->enable = 1;
- zclient_start (zclient);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_router_zebra,
- no_router_zebra_cmd,
- "no router zebra",
- NO_STR
- "Configure routing process\n"
- "Disable connection to zebra daemon\n")
-{
- zclient->enable = 0;
- zclient_stop (zclient);
- return CMD_SUCCESS;
-}
-
/* Zebra configuration write function. */
static int
config_write_ospf6_zebra (struct vty *vty)
/* Install command element for zebra node. */
install_element (VIEW_NODE, &show_zebra_cmd);
install_element (ENABLE_NODE, &show_zebra_cmd);
- install_element (CONFIG_NODE, &router_zebra_cmd);
- install_element (CONFIG_NODE, &no_router_zebra_cmd);
-
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &redistribute_ospf6_cmd);
install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd);
u_int32_t id = 0;
u_int32_t adv_router = 0;
- // dwalton is this needed?
OSPF6_CMD_CHECK_RUNNING ();
type = parse_type_spec (idx_lsa, argc, argv);
#include "memory.h"
#include "prefix.h"
#include "table.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "log.h"
return CMD_SUCCESS;
}
-static int
-ospf_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- return CMD_SUCCESS;
-}
-
-/* Delete rip route map rule. */
-static int
-ospf_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- return CMD_SUCCESS;
-}
-
/* `match ip netxthop ' */
/* Match function return 1 if match is success else return zero. */
static route_map_result_t
}
-DEFUN (match_ip_next_hop_prefix_list,
- match_ip_next_hop_prefix_list_cmd,
- "match ip next-hop prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list",
- argv[idx_word]->arg);
-}
-
-DEFUN (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_cmd,
- "no match ip next-hop prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *pl = (argc == 6) ? argv[5]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list", pl);
-}
-
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP access-list name\n")
-{
- int idx_acl = 3;
- return ospf_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg);
-}
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP access-list name\n")
-{
- char *al = (argc == 5) ? argv[4]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "ip address", al);
-}
-
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return ospf_route_match_add (vty, vty->index, "ip address prefix-list",
- argv[idx_word]->arg);
-}
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *pl = (argc == 6) ? argv[5]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "ip address prefix-list", pl);
-}
-
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- int idx_word = 2;
- return ospf_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface [INTERFACE]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- char *iface = (argc == 4) ? argv[3]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "interface", iface);
-}
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-65535)",
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return ospf_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag [(1-65535)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- char *tag = (argc == 4) ? argv[3]->arg : NULL;
- return ospf_route_match_delete (vty, vty->index, "tag", tag);
-}
-
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric (0-4294967295)",
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return ospf_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
-}
-
-DEFUN (no_set_metric,
- no_set_metric_cmd,
- "no set metric [(0-4294967295)]",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return ospf_route_set_delete (vty, vty->index, "metric", mval);
-}
-
DEFUN (set_metric_type,
set_metric_type_cmd,
"set metric-type <type-1|type-2>",
"OSPF[6] external type 2 metric\n")
{
char *ext = argv[2]->text;
- return ospf_route_set_add (vty, vty->index, "metric-type", ext);
+ return generic_set_add (vty, vty->index, "metric-type", ext);
}
DEFUN (no_set_metric_type,
"OSPF[6] external type 2 metric\n")
{
char *ext = (argc == 4) ? argv[3]->text : NULL;
- return ospf_route_set_delete (vty, vty->index, "metric-type", ext);
-}
-
-DEFUN (set_tag,
- set_tag_cmd,
- "set tag (1-65535)",
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return ospf_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_set_tag,
- no_set_tag_cmd,
- "no set tag [(1-65535)]",
- NO_STR
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- char *tag = (argc == 4) ? argv[3]->arg : NULL;
- return ospf_route_set_delete (vty, vty->index, "tag", tag);
+ return generic_set_delete (vty, vty->index, "metric-type", ext);
}
-
/* Route-map init */
void
ospf_route_map_init (void)
route_map_add_hook (ospf_route_map_update);
route_map_delete_hook (ospf_route_map_update);
route_map_event_hook (ospf_route_map_event);
+
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
+
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
+
+ route_map_set_tag_hook (generic_set_add);
+ route_map_no_set_tag_hook (generic_set_delete);
route_map_install_match (&route_match_ip_nexthop_cmd);
route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
install_element (RMAP_NODE, &match_ip_nexthop_cmd);
install_element (RMAP_NODE, &no_match_ip_nexthop_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_cmd);
- install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
-
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &no_set_metric_cmd);
+
install_element (RMAP_NODE, &set_metric_type_cmd);
install_element (RMAP_NODE, &no_set_metric_type_cmd);
- install_element (RMAP_NODE, &set_tag_cmd);
- install_element (RMAP_NODE, &no_set_tag_cmd);
}
};
/* Prototypes */
-extern void ospf_zclient_start (void);
-
extern void ospf_zebra_add (struct prefix_ipv4 *, struct ospf_route *);
extern void ospf_zebra_delete (struct prefix_ipv4 *, struct ospf_route *);
#include <zebra.h>
#include "if.h"
+#include "vty.h"
#include "routemap.h"
#include "pimd.h"
#include "memory.h"
#include "prefix.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "filter.h"
u_char metric;
};
-/* Add rip route map rule. */
-static int
-rip_route_match_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Delete rip route map rule. */
-static int
-rip_route_match_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Add rip route map rule. */
-static int
-rip_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- /* rip, ripng and other protocols share the set metric command
- but only values from 0 to 16 are valid for rip and ripng
- if metric is out of range for rip and ripng, it is not for
- other protocols. Do not return an error */
- if (strcmp(command, "metric")) {
- vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Delete rip route map rule. */
-static int
-rip_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
/* Hook function for updating route_map assignment. */
/* ARGSUSED */
static void
#define MATCH_STR "Match values from routing table\n"
#define SET_STR "Set values in destination routing protocol\n"
-DEFUN (match_metric,
- match_metric_cmd,
- "match metric (0-4294967295)",
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return rip_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg);
-}
-
-DEFUN (no_match_metric,
- no_match_metric_cmd,
- "no match metric [(0-4294967295)]",
- NO_STR
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "metric", mval);
-}
-
-
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- int idx_word = 2;
- return rip_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface [INTERFACE]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- char *iface = (argc == 4) ? argv[3]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "interface", iface);
-}
-
-DEFUN (match_ip_next_hop,
- match_ip_next_hop_cmd,
- "match ip next-hop <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 3;
- return rip_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg);
-}
-
-DEFUN (no_match_ip_next_hop,
- no_match_ip_next_hop_cmd,
- "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- char *al = (argc == 5) ? argv[4]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "ip next-hop", al);
-}
-
-DEFUN (match_ip_next_hop_prefix_list,
- match_ip_next_hop_prefix_list_cmd,
- "match ip next-hop prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_cmd,
- "no match ip next-hop prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *plist = (argc == 6) ? argv[5]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", plist);
-}
-
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-
-{
- int idx_acl = 3;
- return rip_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg);
-}
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- char *al = (argc == 5) ? argv[4]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "ip address", al);
-}
-
-
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *plist = (argc == 6) ? argv[5]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "ip address prefix-list", plist);
-}
-
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-65535)",
- MATCH_STR
- "Match tag of route\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return rip_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag [(1-65535)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return rip_route_match_delete (vty, vty->index, "tag", mval);
-}
-
-
-/* set functions */
-
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric <(0-4294967295)|+metric|-metric>",
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n"
- "Add metric\n"
- "Subtract metric\n")
-{
- char *metric = argv[2]->type == WORD_TKN ? argv[2]->text : argv[2]->arg;
- return rip_route_set_add (vty, vty->index, "metric", metric);
-}
-
-DEFUN (no_set_metric,
- no_set_metric_cmd,
- "no set metric <(0-4294967295)|+metric|-metric>",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n"
- "Add metric\n"
- "Subtract metric\n")
-{
- char *metric = argv[3]->type == WORD_TKN ? argv[3]->text : argv[3]->arg;
- return rip_route_set_delete (vty, vty->index, "metric", metric);
-}
-
-DEFUN (set_ip_nexthop,
- set_ip_nexthop_cmd,
- "set ip next-hop A.B.C.D",
- SET_STR
- IP_STR
- "Next hop address\n"
- "IP address of next hop\n")
-{
- int idx_ipv4 = 3;
- union sockunion su;
- int ret;
-
- ret = str2sockunion (argv[idx_ipv4]->arg, &su);
- if (ret < 0)
- {
- vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (su.sin.sin_addr.s_addr == 0 ||
- IPV4_CLASS_DE(su.sin.sin_addr.s_addr))
- {
- vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast "
- "or reserved%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- return rip_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg);
-}
-
-DEFUN (no_set_ip_nexthop,
- no_set_ip_nexthop_cmd,
- "no set ip next-hop [A.B.C.D]",
- NO_STR
- SET_STR
- IP_STR
- "Next hop address\n"
- "IP address of next hop\n")
-{
- char *addr = (argc == 5) ? argv[4]->arg : NULL;
- return rip_route_set_delete (vty, vty->index, "ip next-hop", addr);
-}
-
-
-DEFUN (set_tag,
- set_tag_cmd,
- "set tag (1-65535)",
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return rip_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_set_tag,
- no_set_tag_cmd,
- "no set tag [(1-65535)]",
- NO_STR
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- char *tag = (argc == 4) ? argv[3]->arg : NULL;
- return rip_route_set_delete (vty, vty->index, "tag", tag);
-}
-
void
rip_route_map_reset ()
{
route_map_add_hook (rip_route_map_update);
route_map_delete_hook (rip_route_map_update);
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
+
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
+
+ route_map_match_metric_hook (generic_match_add);
+ route_map_no_match_metric_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
+ route_map_set_ip_nexthop_hook (generic_set_add);
+ route_map_no_set_ip_nexthop_hook (generic_set_delete);
+
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
+
+ route_map_set_tag_hook (generic_set_add);
+ route_map_no_set_tag_hook (generic_set_delete);
+
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_ip_next_hop_cmd);
route_map_install_set (&route_set_metric_cmd);
route_map_install_set (&route_set_ip_nexthop_cmd);
route_map_install_set (&route_set_tag_cmd);
-
- install_element (RMAP_NODE, &match_metric_cmd);
- install_element (RMAP_NODE, &no_match_metric_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_cmd);
- install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
-
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &no_set_metric_cmd);
- install_element (RMAP_NODE, &set_ip_nexthop_cmd);
- install_element (RMAP_NODE, &no_set_ip_nexthop_cmd);
- install_element (RMAP_NODE, &set_tag_cmd);
- install_element (RMAP_NODE, &no_set_tag_cmd);
}
{0, 0, NULL}
};
-DEFUN (router_zebra,
- router_zebra_cmd,
- "router zebra",
- "Enable a routing process\n"
- "Make connection to zebra daemon\n")
-{
- vty->node = ZEBRA_NODE;
- zclient->enable = 1;
- zclient_start (zclient);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_router_zebra,
- no_router_zebra_cmd,
- "no router zebra",
- NO_STR
- "Enable a routing process\n"
- "Make connection to zebra daemon\n")
-{
- zclient->enable = 0;
- zclient_stop (zclient);
- return CMD_SUCCESS;
-}
-
-#if 0
-static int
-rip_redistribute_set (int type)
-{
- if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT))
- return CMD_SUCCESS;
-
- vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT);
-
- if (zclient->sock > 0)
- zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type);
-
- return CMD_SUCCESS;
-}
-#endif
-
static int
rip_redistribute_unset (int type)
{
install_node (&zebra_node, config_write_zebra);
/* Install command elements to zebra node. */
- install_element (CONFIG_NODE, &router_zebra_cmd);
- install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd);
install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd);
extern void rip_route_map_reset (void);
extern void rip_snmp_init (void);
extern void rip_zclient_init(struct thread_master *);
-extern void rip_zclient_start (void);
extern void rip_zclient_reset (void);
extern void rip_offset_init (void);
extern int if_check_address (struct in_addr addr);
#include "if.h"
#include "memory.h"
#include "prefix.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "sockunion.h"
u_char metric;
};
-
-static int
-ripng_route_match_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-static int
-ripng_route_match_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_match (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-static int
-ripng_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-static int
-ripng_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
/* `match metric METRIC' */
/* Match function return 1 if match is success else return zero. */
static route_map_result_t
#define MATCH_STR "Match values from routing table\n"
#define SET_STR "Set values in destination routing protocol\n"
-DEFUN (match_metric,
- match_metric_cmd,
- "match metric (0-4294967295)",
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return ripng_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg);
-}
-
-DEFUN (no_match_metric,
- no_match_metric_cmd,
- "no match metric [(0-4294967295)]",
- NO_STR
- MATCH_STR
- "Match metric of route\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return ripng_route_match_delete (vty, vty->index, "metric", mval);
-}
-
-
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- int idx_word = 2;
- return ripng_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg);
-}
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface [INTERFACE]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- char *iface = (argc == 4) ? argv[3]->arg : NULL;
- return ripng_route_match_delete (vty, vty->index, "interface", iface);
-}
-
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-65535)",
- MATCH_STR
- "Match tag of route\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return ripng_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag [(1-65535)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return ripng_route_match_delete (vty, vty->index, "tag", mval);
-}
-
-
-/* set functions */
-
-DEFUN (set_metric,
- set_metric_cmd,
- "set metric (0-4294967295)",
- "Set value\n"
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- int idx_number = 2;
- return ripng_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg);
-}
-
-DEFUN (no_set_metric,
- no_set_metric_cmd,
- "no set metric [(0-4294967295)]",
- NO_STR
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-{
- char *mval = (argc == 4) ? argv[3]->arg : NULL;
- return ripng_route_set_delete (vty, vty->index, "metric", mval);
-}
-
-
-DEFUN (set_ipv6_nexthop_local,
- set_ipv6_nexthop_local_cmd,
- "set ipv6 next-hop local X:X::X:X",
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 local address\n"
- "IPv6 address of next hop\n")
-{
- int idx_ipv6 = 4;
- union sockunion su;
- int ret;
-
- ret = str2sockunion (argv[idx_ipv6]->arg, &su);
- if (ret < 0)
- {
- vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- if (!IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr))
- {
- vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
-
- return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg);
-}
-
-DEFUN (no_set_ipv6_nexthop_local,
- no_set_ipv6_nexthop_local_cmd,
- "no set ipv6 next-hop local [X:X::X:X]",
- NO_STR
- SET_STR
- IPV6_STR
- "IPv6 next-hop address\n"
- "IPv6 local address\n"
- "IPv6 address of next hop\n")
-{
- char *addr = (argc == 6) ? argv[5]->arg : NULL;
- return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", addr);
-}
-
-
-DEFUN (set_tag,
- set_tag_cmd,
- "set tag (1-65535)",
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return ripng_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg);
-}
-
-DEFUN (no_set_tag,
- no_set_tag_cmd,
- "no set tag [(1-65535)]",
- NO_STR
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- char *tag = (argc == 4) ? argv[3]->arg : NULL;
- return ripng_route_set_delete (vty, vty->index, "tag", tag);
-}
-
-
void
ripng_route_map_reset ()
{
route_map_init ();
route_map_init_vty ();
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_metric_hook (generic_match_add);
+ route_map_no_match_metric_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
+ route_map_set_ipv6_nexthop_local_hook (generic_set_add);
+ route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete);
+
+ route_map_set_metric_hook (generic_set_add);
+ route_map_no_set_metric_hook (generic_set_delete);
+
+ route_map_set_tag_hook (generic_set_add);
+ route_map_no_set_tag_hook (generic_set_delete);
+
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_tag_cmd);
-
route_map_install_set (&route_set_metric_cmd);
route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
route_map_install_set (&route_set_tag_cmd);
-
- install_element (RMAP_NODE, &match_metric_cmd);
- install_element (RMAP_NODE, &no_match_metric_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
-
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &no_set_metric_cmd);
- install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
- install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
- install_element (RMAP_NODE, &set_tag_cmd);
- install_element (RMAP_NODE, &no_set_tag_cmd);
}
}
}
-DEFUN (router_zebra,
- router_zebra_cmd,
- "router zebra",
- "Enable a routing process\n"
- "Make connection to zebra daemon\n")
-{
- vty->node = ZEBRA_NODE;
- zclient->enable = 1;
- zclient_start (zclient);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_router_zebra,
- no_router_zebra_cmd,
- "no router zebra",
- NO_STR
- "Disable a routing process\n"
- "Stop connection to zebra daemon\n")
-{
- zclient->enable = 0;
- zclient_stop (zclient);
- return CMD_SUCCESS;
-}
-
DEFUN (ripng_redistribute_ripng,
ripng_redistribute_ripng_cmd,
"redistribute ripng",
install_node (&zebra_node, zebra_config_write);
/* Install command element for zebra node. */
- install_element (CONFIG_NODE, &router_zebra_cmd);
- install_element (CONFIG_NODE, &no_router_zebra_cmd);
install_default (ZEBRA_NODE);
install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd);
install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd);
extern void ripng_terminate (void);
/* zclient_init() is done by ripng_zebra.c:zebra_init() */
extern void zebra_init(struct thread_master *);
-extern void ripng_zclient_start (void);
extern void ripng_zclient_reset (void);
extern void ripng_offset_init (void);
}
}
-my $bad_cli_stomps = 71;
-# Currently we have $bad_cli_stomps. This was determined by
-# running this script and counting up the collisions from what
-# was returned.
-#
# When we have cli commands that map to the same function name, we
# can introduce subtle bugs due to code not being called when
# we think it is.
# If extract.pl fails with a error message and you've been
# modifying the cli, then go back and fix your code to
# not have cli command function collisions.
-#
-# If you've removed a cli overwrite, you can safely subtract
-# one from $bad_cli_stomps. If you've added to the problem
# please fix your code before submittal
-if ($cli_stomp != $bad_cli_stomps) {
- warn "Expected $bad_cli_stomps command line stomps, but got $cli_stomp instead\n";
+if ($cli_stomp) {
+ warn "There are $cli_stomp command line stomps\n";
exit $cli_stomp;
}
#include "memory.h"
#include "zebra_memory.h"
+#include "vty.h"
#include "zebra/debug.h"
#include "zebra/zserv.h"
#include "zebra/redistribute.h"
#include <zebra.h>
#include <log.h>
+#include "vty.h"
#include "zebra/zserv.h"
#include "zebra/rt.h"
#include "zebra/redistribute.h"
*/
#include <zebra.h>
+#include "vty.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "log.h"
#include "rib.h"
+#include "vty.h"
#include "zserv.h"
#include "zebra_ns.h"
#include <zebra.h>
+#include "vty.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "zebra/zebra_rnh.h"
#include "zebra_memory.h"
#include "prefix.h"
#include "rib.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "filter.h"
static void zebra_route_map_set_delay_timer(u_int32_t value);
+
+
/* Add zebra route map rule */
static int
zebra_route_match_add(struct vty *vty, struct route_map_index *index,
return CMD_SUCCESS;
}
-/* Add zebra route map rule. */
-static int
-zebra_route_set_add (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Delete zebra route map rule. */
-static int
-zebra_route_set_delete (struct vty *vty, struct route_map_index *index,
- const char *command, const char *arg)
-{
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
/* 'match tag TAG'
* Match function return 1 if match is success else return 0
*/
route_match_interface_free
};
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "match first hop interface of route\n"
- "Interface name\n")
-{
- int idx_word = 2;
- return zebra_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface [WORD]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- char *iface = (argc == 4) ? argv[3]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index, "interface", iface, RMAP_EVENT_MATCH_DELETED);
-}
-
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-65535)",
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- int idx_number = 2;
- return zebra_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_ADDED);
-}
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag [(1-65535)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n")
-{
- char *tag = (argc == 4) ? argv[3]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index, "tag", tag, RMAP_EVENT_MATCH_DELETED);
-}
-
-
-DEFUN (match_ip_next_hop,
- match_ip_next_hop_cmd,
- "match ip next-hop <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- int idx_acl = 3;
- return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED);
-}
-
-DEFUN (no_match_ip_next_hop,
- no_match_ip_next_hop_cmd,
- "no match ip next-hop [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- char *al = (argc == 5) ? argv[4]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index, "ip next-hop", al, RMAP_EVENT_FILTER_DELETED);
-}
-
-
-DEFUN (match_ip_next_hop_prefix_list,
- match_ip_next_hop_prefix_list_cmd,
- "match ip next-hop prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return zebra_route_match_add (vty, vty->index, "ip next-hop prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_cmd,
- "no match ip next-hop prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *plist = (argc == 6) ? argv[5]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index,
- "ip next-hop prefix-list", plist,
- RMAP_EVENT_PLIST_DELETED);
-}
-
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address <(1-199)|(1300-2699)|WORD>",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-
-{
- int idx_acl = 3;
- return zebra_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg,
- RMAP_EVENT_FILTER_ADDED);
-}
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address [<(1-199)|(1300-2699)|WORD>]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- char *al = (argc == 5) ? argv[4]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index, "ip address", al, RMAP_EVENT_FILTER_DELETED);
-}
-
-
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- int idx_word = 4;
- return zebra_route_match_add (vty, vty->index, "ip address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list [WORD]",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- char *plist = (argc == 6) ? argv[5]->arg : NULL;
- return zebra_route_match_delete (vty, vty->index,
- "ip address prefix-list", plist,
- RMAP_EVENT_PLIST_DELETED);
-}
-
-
DEFUN (match_ip_address_prefix_len,
match_ip_address_prefix_len_cmd,
"match ip address prefix-len (0-32)",
vty_out (vty, "%% not a local address%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return zebra_route_set_add (vty, vty->index, "src", argv[idx_ip]->arg);
+ return generic_set_add (vty, vty->index, "src", argv[idx_ip]->arg);
}
DEFUN (no_set_src,
"Source address for route\n")
{
char *ip = (argc == 4) ? argv[3]->arg : NULL;
- return zebra_route_set_delete (vty, vty->index, "src", ip);
+ return generic_set_delete (vty, vty->index, "src", ip);
}
DEFUN (zebra_route_map_timer,
route_map_delete_hook (zebra_route_map_delete);
route_map_event_hook (zebra_route_map_event);
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
+
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
route_map_install_match (&route_match_tag_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_ip_next_hop_cmd);
/* */
route_map_install_set (&route_set_src_cmd);
/* */
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_cmd);
- install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
install_element (RMAP_NODE, &match_ip_nexthop_prefix_len_cmd);
install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd);
install_element (RMAP_NODE, &match_ip_address_prefix_len_cmd);
#include <lib/nexthop.h>
#include <lib/memory.h>
+#include "vty.h"
#include "zebra/debug.h"
#include "zebra/rib.h"
#include "zebra/zserv.h"
#include "linklist.h"
#include "memory.h"
+#include "vty.h"
#include "zebra/debug.h"
#include "zebra/zserv.h"
#include "zebra/rib.h"
#include "rib.h"
#include "if.h"
#include "workqueue.h"
+#include "vrf.h"
#include "routemap.h"
#include "vty.h"
#include "zclient.h"
-#include "vrf.h"
#include "zebra/zebra_ns.h"
/* Default port information. */
#include <zebra.h>
#include <vrf.h>
+#include <vty.h>
#include <zserv.h>
#include <zebra_ns.h>