Skip to content

Commit

Permalink
Merge pull request #10 from qlyoung/fix-proto_redistnum
Browse files Browse the repository at this point in the history
all: use ->text when parsing protocol argument
  • Loading branch information
donaldsharp authored Jan 7, 2017
2 parents 9648f98 + b84aada commit 3324ef9
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 182 deletions.
48 changes: 24 additions & 24 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -9167,8 +9167,8 @@ DEFUN (bgp_redistribute_ipv4,
int idx_protocol = 1;
int type;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand All @@ -9191,8 +9191,8 @@ DEFUN (bgp_redistribute_ipv4_rmap,
int type;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand All @@ -9218,8 +9218,8 @@ DEFUN (bgp_redistribute_ipv4_metric,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9249,8 +9249,8 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9281,8 +9281,8 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9496,8 +9496,8 @@ DEFUN (no_bgp_redistribute_ipv4,
int idx_protocol = 2;
int type;

type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand All @@ -9516,8 +9516,8 @@ DEFUN (bgp_redistribute_ipv6,
int idx_protocol = 1;
int type;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand All @@ -9541,8 +9541,8 @@ DEFUN (bgp_redistribute_ipv6_rmap,
int type;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand All @@ -9568,8 +9568,8 @@ DEFUN (bgp_redistribute_ipv6_metric,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9599,8 +9599,8 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9631,8 +9631,8 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap,
u_int32_t metric;
struct bgp_redist *red;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down Expand Up @@ -9660,8 +9660,8 @@ DEFUN (no_bgp_redistribute_ipv6,
int idx_protocol = 2;
int type;

type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_BGP)
type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
if (type < 0)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
Expand Down
8 changes: 4 additions & 4 deletions isisd/isis_redist.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,16 +564,16 @@ DEFUN (isis_redistribute,
unsigned long metric;
const char *routemap = NULL;

family = str2family(argv[idx_afi]->arg);
family = str2family(argv[idx_afi]->text);
if (family < 0)
return CMD_WARNING;

afi = family2afi(family);
if (!afi)
return CMD_WARNING;

type = proto_redistnum(afi, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_ISIS)
type = proto_redistnum(afi, argv[idx_protocol]->text);
if (type < 0)
return CMD_WARNING;

if (!strcmp("level-1", argv[idx_level]->arg))
Expand Down Expand Up @@ -637,7 +637,7 @@ DEFUN (no_isis_redistribute,
return CMD_WARNING;

type = proto_redistnum(afi, argv[idx_protocol]->text);
if (type < 0 || type == ZEBRA_ROUTE_ISIS)
if (type < 0)
return CMD_WARNING;

level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2;
Expand Down
44 changes: 22 additions & 22 deletions lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,49 +1061,49 @@ proto_redistnum(int afi, const char *s)

if (afi == AFI_IP)
{
if (strncmp (s, "k", 1) == 0)
if (strmatch (s, "kernel"))
return ZEBRA_ROUTE_KERNEL;
else if (strncmp (s, "c", 1) == 0)
else if (strmatch (s, "connected"))
return ZEBRA_ROUTE_CONNECT;
else if (strncmp (s, "s", 1) == 0)
else if (strmatch (s, "static"))
return ZEBRA_ROUTE_STATIC;
else if (strncmp (s, "r", 1) == 0)
else if (strmatch (s, "rip"))
return ZEBRA_ROUTE_RIP;
else if (strncmp (s, "o", 1) == 0)
else if (strmatch (s, "ospf"))
return ZEBRA_ROUTE_OSPF;
else if (strncmp (s, "i", 1) == 0)
else if (strmatch (s, "isis"))
return ZEBRA_ROUTE_ISIS;
else if (strncmp (s, "bg", 2) == 0)
else if (strmatch (s, "bgp"))
return ZEBRA_ROUTE_BGP;
else if (strncmp (s, "ta", 2) == 0)
else if (strmatch (s, "table"))
return ZEBRA_ROUTE_TABLE;
else if (strcmp (s, "vnc-direct") == 0)
return ZEBRA_ROUTE_VNC_DIRECT;
else if (strcmp (s, "vnc") == 0)
else if (strmatch (s, "vnc"))
return ZEBRA_ROUTE_VNC;
else if (strmatch (s, "vnc-direct"))
return ZEBRA_ROUTE_VNC_DIRECT;
}
if (afi == AFI_IP6)
{
if (strncmp (s, "k", 1) == 0)
if (strmatch (s, "kernel"))
return ZEBRA_ROUTE_KERNEL;
else if (strncmp (s, "c", 1) == 0)
else if (strmatch (s, "connected"))
return ZEBRA_ROUTE_CONNECT;
else if (strncmp (s, "s", 1) == 0)
else if (strmatch (s, "static"))
return ZEBRA_ROUTE_STATIC;
else if (strncmp (s, "r", 1) == 0)
else if (strmatch (s, "ripng"))
return ZEBRA_ROUTE_RIPNG;
else if (strncmp (s, "o", 1) == 0)
else if (strmatch (s, "ospf6"))
return ZEBRA_ROUTE_OSPF6;
else if (strncmp (s, "i", 1) == 0)
else if (strmatch (s, "isis"))
return ZEBRA_ROUTE_ISIS;
else if (strncmp (s, "bg", 2) == 0)
else if (strmatch (s, "bgp"))
return ZEBRA_ROUTE_BGP;
else if (strncmp (s, "ta", 2) == 0)
else if (strmatch (s, "table"))
return ZEBRA_ROUTE_TABLE;
else if (strcmp (s, "vnc-direct") == 0)
return ZEBRA_ROUTE_VNC_DIRECT;
else if (strcmp (s, "vnc") == 0)
else if (strmatch (s, "vnc"))
return ZEBRA_ROUTE_VNC;
else if (strmatch (s, "vnc-direct"))
return ZEBRA_ROUTE_VNC_DIRECT;
}
return -1;
}
Expand Down
15 changes: 9 additions & 6 deletions ospf6d/ospf6_asbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,9 @@ DEFUN (ospf6_redistribute,
{
int type;

type = proto_redistnum(AFI_IP6, argv[2]->arg);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
char *proto = argv[argc - 1]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING;

ospf6_asbr_redistribute_unset (type);
Expand All @@ -713,8 +714,9 @@ DEFUN (ospf6_redistribute_routemap,
int idx_word = 3;
int type;

type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING;

ospf6_asbr_redistribute_unset (type);
Expand All @@ -735,8 +737,9 @@ DEFUN (no_ospf6_redistribute,
int idx_protocol = 2;
int type;

type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text);
if (type < 0 || type == ZEBRA_ROUTE_OSPF6)
char *proto = argv[idx_protocol]->text;
type = proto_redistnum(AFI_IP6, proto);
if (type < 0)
return CMD_WARNING;

ospf6_asbr_redistribute_unset (type);
Expand Down
Loading

0 comments on commit 3324ef9

Please sign in to comment.