summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/arp.c24
-rw-r--r--networking/ftpgetput.c2
-rw-r--r--networking/ip.c19
-rw-r--r--networking/ipcalc.c2
-rw-r--r--networking/libiproute/ip_parse_common_args.c10
-rw-r--r--networking/libiproute/ipaddress.c30
-rw-r--r--networking/libiproute/iplink.c20
-rw-r--r--networking/libiproute/iproute.c93
-rw-r--r--networking/libiproute/iprule.c24
-rw-r--r--networking/libiproute/iptunnel.c41
-rw-r--r--networking/libiproute/rtm_map.c14
-rw-r--r--networking/slattach.c21
-rw-r--r--networking/udhcp/dhcpc.c2
-rw-r--r--networking/udhcp/dumpleases.c2
-rw-r--r--networking/wget.c11
15 files changed, 153 insertions, 162 deletions
diff --git a/networking/arp.c b/networking/arp.c
index e529257..907433b 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -46,17 +46,15 @@ static int sockfd; /* active socket descriptor */
static smallint hw_set; /* flag if hw-type was set (-H) */
static const char *device = ""; /* current device */
-static const char *const options[] = {
- "pub",
- "priv",
- "temp",
- "trail",
- "dontpub",
- "auto",
- "dev",
- "netmask",
- NULL
-};
+static const char options[] =
+ "pub\0"
+ "priv\0"
+ "temp\0"
+ "trail\0"
+ "dontpub\0"
+ "auto\0"
+ "dev\0"
+ "netmask\0";
/* Delete an entry from the ARP cache. */
/* Called only from main, once */
@@ -85,7 +83,7 @@ static int arp_del(char **args)
req.arp_flags = ATF_PERM;
args++;
while (*args != NULL) {
- switch (index_in_str_array(options, *args)) {
+ switch (index_in_strings(options, *args)) {
case 0: /* "pub" */
flags |= 1;
args++;
@@ -239,7 +237,7 @@ static int arp_set(char **args)
/* Check out any modifiers. */
flags = ATF_PERM | ATF_COM;
while (*args != NULL) {
- switch (index_in_str_array(options, *args)) {
+ switch (index_in_strings(options, *args)) {
case 0: /* "pub" */
flags |= ATF_PUBL;
args++;
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 011fbac..02e7c52 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -293,7 +293,7 @@ static const char ftpgetput_longopts[] =
"username\0" Required_argument "u"
"password\0" Required_argument "p"
"port\0" Required_argument "P"
- "\0";
+ ;
#endif
int ftpgetput_main(int argc, char **argv);
diff --git a/networking/ip.c b/networking/ip.c
index 0105bd9..bf7e84c 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -82,14 +82,13 @@ int iptunnel_main(int argc, char **argv)
int ip_main(int argc, char **argv);
int ip_main(int argc, char **argv)
{
- const char * const keywords[] = {
- USE_FEATURE_IP_ADDRESS("address",)
- USE_FEATURE_IP_ROUTE("route",)
- USE_FEATURE_IP_LINK("link",)
- USE_FEATURE_IP_TUNNEL("tunnel", "tunl",)
- USE_FEATURE_IP_RULE("rule",)
- NULL
- };
+ static const char keywords[] =
+ USE_FEATURE_IP_ADDRESS("address\0")
+ USE_FEATURE_IP_ROUTE("route\0")
+ USE_FEATURE_IP_LINK("link\0")
+ USE_FEATURE_IP_TUNNEL("tunnel\0" "tunl\0")
+ USE_FEATURE_IP_RULE("rule\0")
+ ;
enum {
USE_FEATURE_IP_ADDRESS(IP_addr,)
USE_FEATURE_IP_ROUTE(IP_route,)
@@ -101,7 +100,7 @@ int ip_main(int argc, char **argv)
ip_parse_common_args(&argc, &argv);
if (argc > 1) {
- int key = index_in_substr_array(keywords, argv[1]);
+ int key = index_in_substrings(keywords, argv[1]);
argc -= 2;
argv += 2;
#if ENABLE_FEATURE_IP_ADDRESS
@@ -125,7 +124,7 @@ int ip_main(int argc, char **argv)
ip_func = do_iprule;
#endif
}
- return (ip_func(argc, argv));
+ return ip_func(argc, argv);
}
#endif /* any of ENABLE_FEATURE_IP_xxx is 1 */
diff --git a/networking/ipcalc.c b/networking/ipcalc.c
index 32b939f..f3e3ad9 100644
--- a/networking/ipcalc.c
+++ b/networking/ipcalc.c
@@ -72,7 +72,7 @@ int get_prefix(unsigned long netmask);
"hostname\0" No_argument "h"
"silent\0" No_argument "s"
# endif
- "\0";
+ ;
#endif
int ipcalc_main(int argc, char **argv);
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index 2d597ea..0e429a0 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -26,9 +26,9 @@ void ip_parse_common_args(int *argcp, char ***argvp)
{
int argc = *argcp;
char **argv = *argvp;
- static const char * const ip_common_commands[] =
- {"-family", "inet", "inet6", "link",
- "-4", "-6", "-0", "-oneline", 0};
+ static const char ip_common_commands[] =
+ "-family\0""inet\0""inet6\0""link\0"
+ "-4\0""-6\0""-0\0""-oneline\0";
enum {
ARG_family = 1,
ARG_inet,
@@ -53,13 +53,13 @@ void ip_parse_common_args(int *argcp, char ***argvp)
break;
if (opt[1] == '-')
opt++;
- arg = index_in_str_array(ip_common_commands, opt) + 1;
+ arg = index_in_strings(ip_common_commands, opt) + 1;
if (arg == ARG_family) {
argc--;
argv++;
if (!argv[1])
bb_show_usage();
- arg = index_in_str_array(ip_common_commands, argv[1]) + 1;
+ arg = index_in_strings(ip_common_commands, argv[1]) + 1;
if (arg == ARG_inet)
preferred_family = AF_INET;
else if (arg == ARG_inet6)
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 955a9d9..8874fdb 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -412,7 +412,7 @@ static void ipaddr_reset_filter(int _oneline)
/* Return value becomes exitcode. It's okay to not return at all */
int ipaddr_list_or_flush(int argc, char **argv, int flush)
{
- static const char *const option[] = { "to", "scope", "up", "label", "dev", 0 };
+ static const char option[] = "to\0""scope\0""up\0""label\0""dev\0";
struct nlmsg_list *linfo = NULL;
struct nlmsg_list *ainfo = NULL;
@@ -437,7 +437,7 @@ int ipaddr_list_or_flush(int argc, char **argv, int flush)
}
while (argc > 0) {
- const int option_num = index_in_str_array(option, *argv);
+ const int option_num = index_in_strings(option, *argv);
switch (option_num) {
case 0: /* to */
NEXT_ARG();
@@ -599,18 +599,17 @@ static int default_scope(inet_prefix *lcl)
/* Return value becomes exitcode. It's okay to not return at all */
static int ipaddr_modify(int cmd, int argc, char **argv)
{
- static const char *const option[] = {
- "peer", "remote", "broadcast", "brd",
- "anycast", "scope", "dev", "label", "local", 0
- };
+ static const char option[] =
+ "peer\0""remote\0""broadcast\0""brd\0"
+ "anycast\0""scope\0""dev\0""label\0""local\0";
struct rtnl_handle rth;
struct {
- struct nlmsghdr n;
- struct ifaddrmsg ifa;
- char buf[256];
+ struct nlmsghdr n;
+ struct ifaddrmsg ifa;
+ char buf[256];
} req;
- char *d = NULL;
- char *l = NULL;
+ char *d = NULL;
+ char *l = NULL;
inet_prefix lcl;
inet_prefix peer;
int local_len = 0;
@@ -627,7 +626,7 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
req.ifa.ifa_family = preferred_family;
while (argc > 0) {
- const int option_num = index_in_str_array(option, *argv);
+ const int option_num = index_in_strings(option, *argv);
switch (option_num) {
case 0: /* peer */
case 1: /* remote */
@@ -769,14 +768,13 @@ static int ipaddr_modify(int cmd, int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
int do_ipaddr(int argc, char **argv)
{
- static const char *const commands[] = {
- "add", "delete", "list", "show", "lst", "flush", 0
- };
+ static const char commands[] =
+ "add\0""delete\0""list\0""show\0""lst\0""flush\0";
int command_num = 2; /* default command is list */
if (*argv) {
- command_num = index_in_substr_array(commands, *argv);
+ command_num = index_in_substrings(commands, *argv);
}
if (command_num < 0 || command_num > 5)
bb_error_msg_and_die("unknown command %s", *argv);
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 3d3ea2a..69ce84e 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -171,16 +171,15 @@ static int do_set(int argc, char **argv)
struct ifreq ifr0, ifr1;
char *newname = NULL;
int htype, halen;
- static const char * const keywords[] = {
- "up", "down", "name", "mtu", "multicast", "arp", "addr", "dev",
- "on", "off", NULL
- };
+ static const char keywords[] =
+ "up\0""down\0""name\0""mtu\0""multicast\0""arp\0""addr\0""dev\0"
+ "on\0""off\0";
enum { ARG_up = 1, ARG_down, ARG_name, ARG_mtu, ARG_multicast, ARG_arp,
ARG_addr, ARG_dev, PARM_on, PARM_off };
smalluint key;
while (argc > 0) {
- key = index_in_str_array(keywords, *argv) + 1;
+ key = index_in_strings(keywords, *argv) + 1;
if (key == ARG_up) {
mask |= IFF_UP;
flags |= IFF_UP;
@@ -199,7 +198,7 @@ static int do_set(int argc, char **argv)
} else if (key == ARG_multicast) {
NEXT_ARG();
mask |= IFF_MULTICAST;
- key = index_in_str_array(keywords, *argv) + 1;
+ key = index_in_strings(keywords, *argv) + 1;
if (key == PARM_on) {
flags |= IFF_MULTICAST;
} else if (key == PARM_off) {
@@ -209,7 +208,7 @@ static int do_set(int argc, char **argv)
} else if (key == ARG_arp) {
NEXT_ARG();
mask |= IFF_NOARP;
- key = index_in_str_array(keywords, *argv) + 1;
+ key = index_in_strings(keywords, *argv) + 1;
if (key == PARM_on) {
flags &= ~IFF_NOARP;
} else if (key == PARM_off) {
@@ -276,13 +275,12 @@ static int ipaddr_list_link(int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
int do_iplink(int argc, char **argv)
{
- static const char * const keywords[] = {
- "set", "show", "lst", "list", NULL
- };
+ static const char keywords[] =
+ "set\0""show\0""lst\0""list\0";
smalluint key;
if (argc <= 0)
return ipaddr_list_link(0, NULL);
- key = index_in_substr_array(keywords, *argv) + 1;
+ key = index_in_substrings(keywords, *argv) + 1;
if (key == 0)
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
argc--; argv++;
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 75e5293..0d171c7 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -294,6 +294,25 @@ static int print_route(struct sockaddr_nl *who ATTRIBUTE_UNUSED,
/* Return value becomes exitcode. It's okay to not return at all */
static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
{
+ static const char keywords[] =
+ "src\0""via\0""mtu\0""lock\0""protocol\0"USE_FEATURE_IP_RULE("table\0")
+ "dev\0""oif\0""to\0";
+ enum {
+ ARG_src,
+ ARG_via,
+ ARG_mtu, PARM_lock,
+ ARG_protocol,
+USE_FEATURE_IP_RULE(ARG_table,)
+ ARG_dev,
+ ARG_oif,
+ ARG_to
+ };
+ enum {
+ gw_ok = 1 << 0,
+ dst_ok = 1 << 1,
+ proto_ok = 1 << 2,
+ type_ok = 1 << 3
+ };
struct rtnl_handle rth;
struct {
struct nlmsghdr n;
@@ -304,22 +323,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
struct rtattr * mxrta = (void*)mxbuf;
unsigned mxlock = 0;
char *d = NULL;
- enum { gw_ok = 1<<0, dst_ok = 1<<1, proto_ok = 1<<2, type_ok = 1<<3};
smalluint ok = 0;
- static const char * const keywords[] = {
- "src", "via", "mtu", "lock", "protocol", USE_FEATURE_IP_RULE("table",)
- "dev", "oif", "to", NULL
- };
- enum {
- ARG_src,
- ARG_via,
- ARG_mtu, PARM_lock,
- ARG_protocol,
-USE_FEATURE_IP_RULE(ARG_table,)
- ARG_dev,
- ARG_oif,
- ARG_to
- };
int arg;
memset(&req, 0, sizeof(req));
@@ -341,7 +345,7 @@ USE_FEATURE_IP_RULE(ARG_table,)
mxrta->rta_len = RTA_LENGTH(0);
while (argc > 0) {
- arg = index_in_substr_array(keywords, *argv);
+ arg = index_in_substrings(keywords, *argv);
if (arg == ARG_src) {
inet_prefix addr;
NEXT_ARG();
@@ -361,7 +365,7 @@ USE_FEATURE_IP_RULE(ARG_table,)
} else if (arg == ARG_mtu) {
unsigned mtu;
NEXT_ARG();
- if (index_in_str_array(keywords, *argv) == PARM_lock) {
+ if (index_in_strings(keywords, *argv) == PARM_lock) {
mxlock |= (1<<RTAX_MTU);
NEXT_ARG();
}
@@ -513,10 +517,9 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
struct rtnl_handle rth;
char *id = NULL;
char *od = NULL;
- static const char * const keywords[] = {
- "protocol", "all", "dev", "oif", "iif", "via", "table", "cache",/*all,*/
- "from", "root", "match", "exact", "to", /*root,match,exact*/ NULL
- };
+ static const char keywords[] =
+ "protocol\0""all\0""dev\0""oif\0""iif\0""via\0""table\0""cache\0" /*all*/
+ "from\0""root\0""match\0""exact\0""to\0"/*root match exact*/;
enum {
ARG_proto, PARM_all,
ARG_dev,
@@ -535,13 +538,13 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
bb_error_msg_and_die(bb_msg_requires_arg, "\"ip route flush\"");
while (argc > 0) {
- arg = index_in_substr_array(keywords, *argv);
+ arg = index_in_substrings(keywords, *argv);
if (arg == ARG_proto) {
uint32_t prot = 0;
NEXT_ARG();
filter.protocolmask = -1;
if (rtnl_rtprot_a2n(&prot, *argv)) {
- if (index_in_str_array(keywords, *argv) != PARM_all)
+ if (index_in_strings(keywords, *argv) != PARM_all)
invarg(*argv, "protocol");
prot = 0;
filter.protocolmask = 0;
@@ -558,7 +561,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
get_prefix(&filter.rvia, *argv, do_ipv6);
} else if (arg == ARG_table) {
NEXT_ARG();
- parm = index_in_substr_array(keywords, *argv);
+ parm = index_in_substrings(keywords, *argv);
if (parm == PARM_cache)
filter.tb = -1;
else if (parm == PARM_all)
@@ -567,7 +570,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
invarg(*argv, "table");
} else if (arg == ARG_from) {
NEXT_ARG();
- parm = index_in_substr_array(keywords, *argv);
+ parm = index_in_substrings(keywords, *argv);
if (parm == PARM_root) {
NEXT_ARG();
get_prefix(&filter.rsrc, *argv, do_ipv6);
@@ -584,7 +587,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
/* parm = arg; // would be more plausible, we reuse arg here */
if (arg == ARG_to) {
NEXT_ARG();
- arg = index_in_substr_array(keywords, *argv);
+ arg = index_in_substrings(keywords, *argv);
}
if (arg == PARM_root) {
NEXT_ARG();
@@ -645,9 +648,8 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
xrtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE);
filter.flushed = 0;
xrtnl_dump_filter(&rth, print_route, stdout);
- if (filter.flushed == 0) {
+ if (filter.flushed == 0)
return 0;
- }
if (flush_update())
return 1;
}
@@ -655,10 +657,8 @@ static int iproute_list_or_flush(int argc, char **argv, int flush)
if (filter.tb != -1) {
xrtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE);
- } else {
- if (rtnl_rtcache_request(&rth, do_ipv6) < 0) {
- bb_perror_msg_and_die("cannot send dump request");
- }
+ } else if (rtnl_rtcache_request(&rth, do_ipv6) < 0) {
+ bb_perror_msg_and_die("cannot send dump request");
}
xrtnl_dump_filter(&rth, print_route, stdout);
@@ -671,16 +671,16 @@ static int iproute_get(int argc, char **argv)
{
struct rtnl_handle rth;
struct {
- struct nlmsghdr n;
- struct rtmsg r;
- char buf[1024];
+ struct nlmsghdr n;
+ struct rtmsg r;
+ char buf[1024];
} req;
- char *idev = NULL;
- char *odev = NULL;
+ char *idev = NULL;
+ char *odev = NULL;
bool connected = 0;
bool from_ok = 0;
- static const char * const options[] =
- { "from", "iif", "oif", "dev", "notify", "connected", "to", 0 };
+ static const char options[] =
+ "from\0""iif\0""oif\0""dev\0""notify\0""connected\0""to\0";
memset(&req, 0, sizeof(req));
@@ -699,7 +699,7 @@ static int iproute_get(int argc, char **argv)
req.r.rtm_tos = 0;
while (argc > 0) {
- switch (index_in_str_array(options, *argv)) {
+ switch (index_in_strings(options, *argv)) {
case 0: /* from */
{
inet_prefix addr;
@@ -824,19 +824,18 @@ static int iproute_get(int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
int do_iproute(int argc, char **argv)
{
- static const char * const ip_route_commands[] = {
- /*0-3*/ "add", "append", "change", "chg",
- /*4-7*/ "delete", "get", "list", "show",
- /*8..*/ "prepend", "replace", "test", "flush", 0
- };
+ static const char ip_route_commands[] =
+ /*0-3*/ "add\0""append\0""change\0""chg\0"
+ /*4-7*/ "delete\0""get\0""list\0""show\0"
+ /*8..*/ "prepend\0""replace\0""test\0""flush\0";
int command_num = 6;
- unsigned int flags = 0;
+ unsigned flags = 0;
int cmd = RTM_NEWROUTE;
/* "Standard" 'ip r a' treats 'a' as 'add', not 'append' */
/* It probably means that it is using "first match" rule */
if (*argv) {
- command_num = index_in_substr_array(ip_route_commands, *argv);
+ command_num = index_in_substrings(ip_route_commands, *argv);
}
switch (command_num) {
case 0: /* add */
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index a62eae1..8e2a06f 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
@@ -187,6 +187,15 @@ static int iprule_list(int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
static int iprule_modify(int cmd, int argc, char **argv)
{
+ static const char keywords[] =
+ "from\0""to\0""preference\0""order\0""priority\0"
+ "tos\0""fwmark\0""realms\0""table\0""lookup\0""dev\0"
+ "iif\0""nat\0""map-to\0""type\0""help\0";
+ enum {
+ ARG_from = 1, ARG_to, ARG_preference, ARG_order, ARG_priority,
+ ARG_tos, ARG_fwmark, ARG_realms, ARG_table, ARG_lookup, ARG_dev,
+ ARG_iif, ARG_nat, ARG_map_to, ARG_type, ARG_help
+ };
bool table_ok = 0;
struct rtnl_handle rth;
struct {
@@ -194,13 +203,6 @@ static int iprule_modify(int cmd, int argc, char **argv)
struct rtmsg r;
char buf[1024];
} req;
- static const char * const keywords[] =
- { "from", "to", "preference", "order", "priority", "tos", "fwmark",
- "realms", "table", "lookup", "dev", "iif", "nat", "map-to", "type",
- "help", NULL};
- enum { ARG_from = 1, ARG_to, ARG_preference, ARG_order, ARG_priority,
- ARG_tos, ARG_fwmark, ARG_realms, ARG_table, ARG_lookup, ARG_dev,
- ARG_iif, ARG_nat, ARG_map_to, ARG_type, ARG_help };
smalluint key;
memset(&req, 0, sizeof(req));
@@ -220,7 +222,7 @@ static int iprule_modify(int cmd, int argc, char **argv)
}
while (argc > 0) {
- key = index_in_substr_array(keywords, *argv) + 1;
+ key = index_in_substrings(keywords, *argv) + 1;
if (key == 0) /* no match found in keywords array, bail out. */
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
if (key == ARG_from) {
@@ -311,14 +313,14 @@ static int iprule_modify(int cmd, int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
int do_iprule(int argc, char **argv)
{
- static const char * const ip_rule_commands[] =
- {"add", "delete", "list", "show", 0};
+ static const char ip_rule_commands[] =
+ "add\0""delete\0""list\0""show\0";
int cmd = 2; /* list */
if (argc < 1)
return iprule_list(0, NULL);
if (*argv)
- cmd = index_in_substr_array(ip_rule_commands, *argv);
+ cmd = index_in_substrings(ip_rule_commands, *argv);
switch (cmd) {
case 0: /* add */
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 90d0e11..a293387 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -128,16 +128,13 @@ static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
/* Dies on error */
static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
{
- int count = 0;
- char medium[IFNAMSIZ];
- static const char * const keywords[] = {
- "mode", "ipip", "ip/ip", "gre", "gre/ip", "sit", "ipv6/ip",
- "key", "ikey", "okey", "seq", "iseq", "oseq",
- "csum", "icsum", "ocsum", "nopmtudisc", "pmtudisc",
- "remote", "any", "local", "dev",
- "ttl", "inherit", "tos", "dsfield",
- "name", NULL
- };
+ static const char keywords[] =
+ "mode\0""ipip\0""ip/ip\0""gre\0""gre/ip\0""sit\0""ipv6/ip\0"
+ "key\0""ikey\0""okey\0""seq\0""iseq\0""oseq\0"
+ "csum\0""icsum\0""ocsum\0""nopmtudisc\0""pmtudisc\0"
+ "remote\0""any\0""local\0""dev\0"
+ "ttl\0""inherit\0""tos\0""dsfield\0"
+ "name\0";
enum {
ARG_mode, ARG_ipip, ARG_ip_ip, ARG_gre, ARG_gre_ip, ARG_sit, ARG_ip6_ip,
ARG_key, ARG_ikey, ARG_okey, ARG_seq, ARG_iseq, ARG_oseq,
@@ -146,22 +143,25 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
ARG_ttl, ARG_inherit, ARG_tos, ARG_dsfield,
ARG_name
};
+ int count = 0;
+ char medium[IFNAMSIZ];
int key;
+
memset(p, 0, sizeof(*p));
memset(&medium, 0, sizeof(medium));
p->iph.version = 4;
p->iph.ihl = 5;
#ifndef IP_DF
-#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
+#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
#endif
p->iph.frag_off = htons(IP_DF);
while (argc > 0) {
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key == ARG_mode) {
NEXT_ARG();
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key == ARG_ipip ||
key == ARG_ip_ip) {
if (p->iph.protocol && p->iph.protocol != IPPROTO_IPIP) {
@@ -240,12 +240,12 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
p->iph.frag_off = htons(IP_DF);
} else if (key == ARG_remote) {
NEXT_ARG();
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key == ARG_any)
p->iph.daddr = get_addr32(*argv);
} else if (key == ARG_local) {
NEXT_ARG();
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key == ARG_any)
p->iph.saddr = get_addr32(*argv);
} else if (key == ARG_dev) {
@@ -254,7 +254,7 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
} else if (key == ARG_ttl) {
unsigned uval;
NEXT_ARG();
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key != ARG_inherit) {
if (get_unsigned(&uval, *argv, 0))
invarg(*argv, "TTL");
@@ -266,7 +266,7 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
key == ARG_dsfield) {
uint32_t uval;
NEXT_ARG();
- key = index_in_str_array(keywords, *argv);
+ key = index_in_strings(keywords, *argv);
if (key != ARG_inherit) {
if (rtnl_dsfield_a2n(&uval, *argv))
invarg(*argv, "TOS");
@@ -519,14 +519,13 @@ static int do_show(int argc, char **argv)
/* Return value becomes exitcode. It's okay to not return at all */
int do_iptunnel(int argc, char **argv)
{
- static const char *const keywords[] = {
- "add", "change", "delete", "show", "list", "lst", NULL
- };
+ static const char keywords[] =
+ "add\0""change\0""delete\0""show\0""list\0""lst\0";
enum { ARG_add = 0, ARG_change, ARG_del, ARG_show, ARG_list, ARG_lst };
int key;
if (argc) {
- key = index_in_substr_array(keywords, *argv);
+ key = index_in_substrings(keywords, *argv);
if (key < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
--argc;
diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c
index 593017b..96b2d17 100644
--- a/networking/libiproute/rtm_map.c
+++ b/networking/libiproute/rtm_map.c
@@ -51,16 +51,16 @@ const char *rtnl_rtntype_n2a(int id, char *buf, int len)
int rtnl_rtntype_a2n(int *id, char *arg)
{
- static const char * const keywords[] = {
- "local", "nat", "broadcast", "brd", "anycast",
- "multicast", "prohibit", "unreachable", "blackhole",
- "xresolve", "unicast", "throw", NULL
- };
- enum { ARG_local = 1, ARG_nat, ARG_broadcast, ARG_brd, ARG_anycast,
+ static const char keywords[] =
+ "local\0""nat\0""broadcast\0""brd\0""anycast\0"
+ "multicast\0""prohibit\0""unreachable\0""blackhole\0"
+ "xresolve\0""unicast\0""throw\0";
+ enum {
+ ARG_local = 1, ARG_nat, ARG_broadcast, ARG_brd, ARG_anycast,
ARG_multicast, ARG_prohibit, ARG_unreachable, ARG_blackhole,
ARG_xresolve, ARG_unicast, ARG_throw
};
- const smalluint key = index_in_substr_array(keywords, arg) + 1;
+ const smalluint key = index_in_substrings(keywords, arg) + 1;
char *end;
unsigned long res;
diff --git a/networking/slattach.c b/networking/slattach.c
index 1a4423b..4bac879 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -16,16 +16,6 @@
#include "libbb.h"
#include "libiproute/utils.h" /* invarg() */
-/* Line discipline code table */
-static const char *const proto_names[] = {
- "cslip"+1, /* 0 */
- "cslip", /* 1 */
- "cslip6"+1, /* 2 */
- "cslip6", /* 3 */
- "adaptive", /* 8 */
- NULL
-};
-
struct globals {
int handle;
int saved_disc;
@@ -132,6 +122,15 @@ static void sig_handler(int signo)
int slattach_main(int argc, char **argv);
int slattach_main(int argc, char **argv)
{
+ /* Line discipline code table */
+ static const char proto_names[] =
+ "slip\0" /* 0 */
+ "cslip\0" /* 1 */
+ "slip6\0" /* 2 */
+ "cslip6\0" /* 3 */
+ "adaptive\0" /* 8 */
+ ;
+
int i, encap, opt;
struct termios state;
const char *proto = "cslip";
@@ -160,7 +159,7 @@ int slattach_main(int argc, char **argv)
if (!*argv)
bb_show_usage();
- encap = index_in_str_array(proto_names, proto);
+ encap = index_in_strings(proto_names, proto);
if (encap < 0)
invarg(proto, "protocol");
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 2b95c32..b84a678 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -200,7 +200,7 @@ int udhcpc_main(int argc, char **argv)
"timeout\0" Required_argument "T"
"version\0" No_argument "v"
"retries\0" Required_argument "t"
- "\0";
+ ;
#endif
/* Default options. */
client_config.interface = "eth0";
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index fb50d68..f9f9231 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -28,7 +28,7 @@ int dumpleases_main(int argc, char **argv)
"absolute\0" No_argument "a"
"remaining\0" No_argument "r"
"file\0" Required_argument "f"
- "\0";
+ ;
applet_long_options = dumpleases_longopts;
#endif
diff --git a/networking/wget.c b/networking/wget.c
index ad09091..d944f01 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -114,9 +114,8 @@ int wget_main(int argc, char **argv)
bool use_proxy = 1; /* Use proxies if env vars are set */
const char *proxy_flag = "on"; /* Use proxies if env vars are set */
const char *user_agent = "Wget";/* "User-Agent" header field */
- static const char * const keywords[] = {
- "content-length", "transfer-encoding", "chunked", "location", NULL
- };
+ static const char keywords[] =
+ "content-length\0""transfer-encoding\0""chunked\0""location\0";
enum {
KEY_content_length = 1, KEY_transfer_encoding, KEY_chunked, KEY_location
};
@@ -143,7 +142,7 @@ int wget_main(int argc, char **argv)
"user-agent\0" Required_argument "U"
"passive-ftp\0" No_argument "\xff"
"header\0" Required_argument "\xfe"
- "\0";
+ ;
applet_long_options = wget_longopts;
#endif
/* server.allocated = target.allocated = NULL; */
@@ -327,7 +326,7 @@ int wget_main(int argc, char **argv)
*/
while ((str = gethdr(buf, sizeof(buf), sfp, &n)) != NULL) {
/* gethdr did already convert the "FOO:" string to lowercase */
- smalluint key = index_in_str_array(keywords, *&buf) + 1;
+ smalluint key = index_in_strings(keywords, *&buf) + 1;
if (key == KEY_content_length) {
content_len = BB_STRTOOFF(str, NULL, 10);
if (errno || content_len < 0) {
@@ -337,7 +336,7 @@ int wget_main(int argc, char **argv)
continue;
}
if (key == KEY_transfer_encoding) {
- if (index_in_str_array(keywords, str_tolower(str)) + 1 != KEY_chunked)
+ if (index_in_strings(keywords, str_tolower(str)) + 1 != KEY_chunked)
bb_error_msg_and_die("server wants to do %s transfer encoding", str);
chunked = got_clen = 1;
}