diff options
| author | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-10-06 19:56:13 +0000 | 
|---|---|---|
| committer | Daniel Walton <dwalton@cumulusnetworks.com> | 2016-10-06 19:56:13 +0000 | 
| commit | 82f97584fbc708f4089b1b4f7e6fdc7e07b2db4e (patch) | |
| tree | 2e3540ca88b53f855e03bd4a4e3b1c63d732e5e5 /ripd/rip_routemap.c | |
| parent | cbd7259d95886fe8438fd7d4e3ea75db2dae55f0 (diff) | |
all: removed all DEFUN command stomps
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'ripd/rip_routemap.c')
| -rw-r--r-- | ripd/rip_routemap.c | 433 | 
1 files changed, 31 insertions, 402 deletions
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index e1017cfb27..3cdfd8adfc 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -24,6 +24,7 @@  #include "memory.h"  #include "prefix.h" +#include "vty.h"  #include "routemap.h"  #include "command.h"  #include "filter.h" @@ -45,104 +46,6 @@ struct rip_metric_modifier    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 @@ -735,288 +638,6 @@ static struct route_map_rule_cmd route_set_tag_cmd =  #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 ()  { @@ -1032,6 +653,36 @@ rip_route_map_init ()    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); @@ -1043,26 +694,4 @@ rip_route_map_init ()    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);  }  | 
