-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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_interface)
- return rmap_match_set_hook.match_interface(
- 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 [WORD]",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-{
- char *iface = (argc == 4) ? argv[3]->arg : NULL;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_interface)
- return rmap_match_set_hook.no_match_interface(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ip_address)
- return rmap_match_set_hook.match_ip_address(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_ip_address) {
- if (argc <= idx_word)
- return rmap_match_set_hook.no_match_ip_address(
- vty, index, "ip address", NULL,
- RMAP_EVENT_FILTER_DELETED);
- return rmap_match_set_hook.no_match_ip_address(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ip_address_prefix_list)
- return rmap_match_set_hook.match_ip_address_prefix_list(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "ip address prefix-list",
- NULL, RMAP_EVENT_PLIST_DELETED);
- return rmap_match_set_hook.no_match_ip_address_prefix_list(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ip_next_hop)
- return rmap_match_set_hook.match_ip_next_hop(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "ip next-hop", NULL,
- RMAP_EVENT_FILTER_DELETED);
- return rmap_match_set_hook.no_match_ip_next_hop(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ip_next_hop_prefix_list)
- return rmap_match_set_hook.match_ip_next_hop_prefix_list(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "ip next-hop prefix-list", NULL,
- RMAP_EVENT_PLIST_DELETED);
- return rmap_match_set_hook.no_match_ip_next_hop(
- vty, index, "ip next-hop prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
- }
- return CMD_SUCCESS;
-}
-
-DEFUN(match_ip_next_hop_type, match_ip_next_hop_type_cmd,
- "match ip next-hop type <blackhole>",
- MATCH_STR IP_STR
- "Match next-hop address of route\n"
- "Match entries by type\n"
- "Blackhole\n")
-{
- int idx_word = 4;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ip_next_hop_type)
- return rmap_match_set_hook.match_ip_next_hop_type(
- vty, index, "ip next-hop type", argv[idx_word]->arg,
- RMAP_EVENT_MATCH_ADDED);
- return CMD_SUCCESS;
-}
-
-DEFUN(no_match_ip_next_hop_type, no_match_ip_next_hop_type_cmd,
- "no match ip next-hop type [<blackhole>]",
- NO_STR MATCH_STR IP_STR
- "Match next-hop address of route\n"
- "Match entries by type\n"
- "Blackhole\n")
-{
- int idx_word = 5;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "ip next-hop type", NULL,
- RMAP_EVENT_MATCH_DELETED);
- return rmap_match_set_hook.no_match_ip_next_hop(
- vty, index, "ip next-hop type", argv[idx_word]->arg,
- RMAP_EVENT_MATCH_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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ipv6_address)
- return rmap_match_set_hook.match_ipv6_address(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_ipv6_address)
- return rmap_match_set_hook.no_match_ipv6_address(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ipv6_address_prefix_list)
- return rmap_match_set_hook.match_ipv6_address_prefix_list(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_ipv6_address_prefix_list)
- return rmap_match_set_hook.no_match_ipv6_address_prefix_list(
- vty, index, "ipv6 address prefix-list",
- argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED);
- return CMD_SUCCESS;
-}
-
-DEFUN(match_ipv6_next_hop_type, match_ipv6_next_hop_type_cmd,
- "match ipv6 next-hop type <blackhole>",
- MATCH_STR IPV6_STR
- "Match next-hop address of route\n"
- "Match entries by type\n"
- "Blackhole\n")
-{
- int idx_word = 4;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_ipv6_next_hop_type)
- return rmap_match_set_hook.match_ipv6_next_hop_type(
- vty, index, "ipv6 next-hop type", argv[idx_word]->arg,
- RMAP_EVENT_MATCH_ADDED);
- return CMD_SUCCESS;
-}
-
-DEFUN(no_match_ipv6_next_hop_type, no_match_ipv6_next_hop_type_cmd,
- "no match ipv6 next-hop type [<blackhole>]",
- NO_STR MATCH_STR IPV6_STR
- "Match address of route\n"
- "Match entries by type\n"
- "Blackhole\n")
-{
- int idx_word = 5;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_ipv6_next_hop_type)
- return rmap_match_set_hook.no_match_ipv6_next_hop_type(
- vty, index, "ipv6 next-hop type",
- (argc <= idx_word) ? NULL : argv[idx_word]->arg,
- RMAP_EVENT_MATCH_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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_metric)
- return rmap_match_set_hook.match_metric(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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_match_metric) {
- if (argc <= idx_number)
- return rmap_match_set_hook.no_match_metric(
- vty, index, "metric", NULL,
- RMAP_EVENT_MATCH_DELETED);
- return rmap_match_set_hook.no_match_metric(
- vty, index, "metric", argv[idx_number]->arg,
- RMAP_EVENT_MATCH_DELETED);
- }
- return CMD_SUCCESS;
-}
-
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag (1-4294967295)",
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- int idx_number = 2;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.match_tag)
- return rmap_match_set_hook.match_tag(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-4294967295)]",
- NO_STR
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- int idx = 0;
- char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
- ? argv[idx]->arg
- : NULL;
-
- if (rmap_match_set_hook.no_match_tag)
- return rmap_match_set_hook.no_match_tag(
- vty, index, "tag", 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- ret = str2sockunion(argv[idx_ipv4]->arg, &su);
- if (ret < 0) {
- vty_out(vty, "%% Malformed nexthop address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- if (su.sin.sin_addr.s_addr == 0
- || IPV4_CLASS_DE(ntohl(su.sin.sin_addr.s_addr))) {
- vty_out(vty,
- "%% nexthop address cannot be 0.0.0.0, multicast or reserved\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- if (rmap_match_set_hook.set_ip_nexthop)
- return rmap_match_set_hook.set_ip_nexthop(
- 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 [A.B.C.D]",
- NO_STR
- SET_STR
- IP_STR
- "Next hop address\n"
- "IP address of next hop\n")
-{
- int idx = 0;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
- const char *arg = NULL;
-
- if (argv_find(argv, argc, "A.B.C.D", &idx))
- arg = argv[idx]->arg;
-
- if (rmap_match_set_hook.no_set_ip_nexthop)
- return rmap_match_set_hook.no_set_ip_nexthop(
- vty, index, "ip next-hop", 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- ret = inet_pton(AF_INET6, argv[idx_ipv6]->arg, &addr);
- if (!ret) {
- vty_out(vty, "%% Malformed nexthop address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- if (!IN6_IS_ADDR_LINKLOCAL(&addr)) {
- vty_out(vty, "%% Invalid link-local nexthop address\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- if (rmap_match_set_hook.set_ipv6_nexthop_local)
- return rmap_match_set_hook.set_ipv6_nexthop_local(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "ipv6 next-hop local", NULL);
- return rmap_match_set_hook.no_set_ipv6_nexthop_local(
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- const char *pass = (argv[idx_number]->type == RANGE_TKN)
- ? argv[idx_number]->arg
- : argv[idx_number]->text;
-
- if (rmap_match_set_hook.set_metric)
- return rmap_match_set_hook.set_metric(vty, index, "metric",
- pass);
- 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;
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- if (rmap_match_set_hook.no_set_metric) {
- if (argc <= idx_number)
- return rmap_match_set_hook.no_set_metric(
- vty, index, "metric", NULL);
- return rmap_match_set_hook.no_set_metric(vty, index, "metric",
- argv[idx_number]->arg);
- }
- return CMD_SUCCESS;
-}
-
-
-DEFUN (set_tag,
- set_tag_cmd,
- "set tag (1-4294967295)",
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- int idx_number = 2;
- if (rmap_match_set_hook.set_tag)
- return rmap_match_set_hook.set_tag(vty, index, "tag",
- argv[idx_number]->arg);
- return CMD_SUCCESS;
-}
-
-
-DEFUN (no_set_tag,
- no_set_tag_cmd,
- "no set tag [(1-4294967295)]",
- NO_STR
- SET_STR
- "Tag value for routing protocol\n"
- "Tag value\n")
-{
- VTY_DECLVAR_CONTEXT(route_map_index, index);
-
- 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, index, "tag",
- NULL);
- return rmap_match_set_hook.no_set_tag(vty, index, "tag",
- argv[idx_number]->arg);
- }
- return CMD_SUCCESS;
-}
-
-
-DEFUN_NOSH (route_map,
- route_map_cmd,
- "route-map WORD <deny|permit> (1-65535)",
- "Create route-map or enter route-map command mode\n"
- "Route map tag\n"
- "Route map denies set operations\n"
- "Route map permits set operations\n"
- "Sequence to insert to/delete from existing route-map entry\n")
-{
- int idx_word = 1;
- int idx_permit_deny = 2;
- int idx_number = 3;
- struct route_map *map;
- struct route_map_index *index;
- char *endptr = NULL;
- int permit =
- argv[idx_permit_deny]->arg[0] == 'p' ? RMAP_PERMIT : RMAP_DENY;
- unsigned long pref = strtoul(argv[idx_number]->arg, &endptr, 10);
- const char *mapname = argv[idx_word]->arg;
-
- /* Get route map. */
- map = route_map_get(mapname);
- index = route_map_index_get(map, permit, pref);
-
- VTY_PUSH_CONTEXT(RMAP_NODE, index);
- return CMD_SUCCESS;
-}
-
-DEFUN (no_route_map_all,
- no_route_map_all_cmd,
- "no route-map WORD",
- NO_STR
- "Create route-map or enter route-map command mode\n"
- "Route map tag\n")
-{
- int idx_word = 2;
- const char *mapname = argv[idx_word]->arg;
- struct route_map *map;
-
- map = route_map_lookup_by_name(mapname);
- if (map == NULL) {
- vty_out(vty, "%% Could not find route-map %s\n", mapname);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- route_map_delete(map);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_route_map,
- no_route_map_cmd,
- "no route-map WORD <deny|permit> (1-65535)",
- NO_STR
- "Create route-map or enter route-map command mode\n"
- "Route map tag\n"
- "Route map denies set operations\n"
- "Route map permits set operations\n"
- "Sequence to insert to/delete from existing route-map entry\n")
-{
- int idx_word = 2;
- int idx_permit_deny = 3;
- int idx_number = 4;
- struct route_map *map;
- struct route_map_index *index;
- char *endptr = NULL;
- int permit = strmatch(argv[idx_permit_deny]->text, "permit")
- ? RMAP_PERMIT
- : RMAP_DENY;
- const char *prefstr = argv[idx_number]->arg;
- const char *mapname = argv[idx_word]->arg;
- unsigned long pref = strtoul(prefstr, &endptr, 10);
-
- /* Existence check. */
- map = route_map_lookup_by_name(mapname);
- if (map == NULL) {
- vty_out(vty, "%% Could not find route-map %s\n", mapname);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /* Lookup route map index. */
- index = route_map_index_lookup(map, permit, pref);
- if (index == NULL) {
- vty_out(vty, "%% Could not find route-map entry %s %s\n",
- mapname, prefstr);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- /* Delete index from route map. */
- route_map_index_delete(index, 1);
-
- /* If this route rule is the last one, delete route map itself. */
- if (route_map_empty(map))
- route_map_delete(map);
-
- return CMD_SUCCESS;
-}
-
-DEFUN (rmap_onmatch_next,
- rmap_onmatch_next_cmd,
- "on-match next",
- "Exit policy on matches\n"
- "Next clause\n")
-{
- struct route_map_index *index = VTY_GET_CONTEXT(route_map_index);
-
- if (index) {
- if (index->type == RMAP_DENY) {
- /* Under a deny clause, match means it's finished. No
- * need to set next */
- vty_out(vty,
- "on-match next not supported under route-map deny\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
- index->exitpolicy = RMAP_NEXT;
- }
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rmap_onmatch_next,
- no_rmap_onmatch_next_cmd,
- "no on-match next",
- NO_STR
- "Exit policy on matches\n"
- "Next clause\n")
-{
- struct route_map_index *index = VTY_GET_CONTEXT(route_map_index);
-
- if (index)
- index->exitpolicy = RMAP_EXIT;
-
- return CMD_SUCCESS;
-}
-
-DEFUN (rmap_onmatch_goto,
- rmap_onmatch_goto_cmd,
- "on-match goto (1-65535)",
- "Exit policy on matches\n"
- "Goto Clause number\n"
- "Number\n")
-{
- int idx = 0;
- char *num = argv_find(argv, argc, "(1-65535)", &idx) ? argv[idx]->arg
- : NULL;
-
- struct route_map_index *index = VTY_GET_CONTEXT(route_map_index);
- int d = 0;
-
- if (index) {
- if (index->type == RMAP_DENY) {
- /* Under a deny clause, match means it's finished. No
- * need to go anywhere */
- vty_out(vty,
- "on-match goto not supported under route-map deny\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- if (num)
- d = strtoul(num, NULL, 10);
- else
- d = index->pref + 1;
-
- if (d <= index->pref) {
- /* Can't allow you to do that, Dave */
- vty_out(vty, "can't jump backwards in route-maps\n");
- return CMD_WARNING_CONFIG_FAILED;
- } else {
- index->exitpolicy = RMAP_GOTO;
- index->nextpref = d;
- }
- }
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rmap_onmatch_goto,
- no_rmap_onmatch_goto_cmd,
- "no on-match goto",
- NO_STR
- "Exit policy on matches\n"
- "Goto Clause number\n")
-{
- struct route_map_index *index = VTY_GET_CONTEXT(route_map_index);
-
- if (index)
- index->exitpolicy = RMAP_EXIT;
-
- return CMD_SUCCESS;
-}
-
-/* Cisco/GNU Zebra compatibility aliases */
-/* ALIAS_FIXME */
-DEFUN (rmap_continue,
- rmap_continue_cmd,
- "continue (1-65535)",
- "Continue on a different entry within the route-map\n"
- "Route-map entry sequence number\n")
-{
- return rmap_onmatch_goto(self, vty, argc, argv);
-}
-
-/* ALIAS_FIXME */
-DEFUN (no_rmap_continue,
- no_rmap_continue_cmd,
- "no continue [(1-65535)]",
- NO_STR
- "Continue on a different entry within the route-map\n"
- "Route-map entry sequence number\n")
-{
- return no_rmap_onmatch_goto(self, vty, argc, argv);
-}
-