summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath2002-12-02 00:54:10 +0000
committerGlenn L McGrath2002-12-02 00:54:10 +0000
commit18eae0031adc86edc81cf398437f2716ef393bd3 (patch)
tree08e4a55e6f746fa0afb8a4649eb452d1d20ec6b3
parentc82f2324bd28fe065bbde8a981caad6aebf289ae (diff)
downloadbusybox-18eae0031adc86edc81cf398437f2716ef393bd3.zip
busybox-18eae0031adc86edc81cf398437f2716ef393bd3.tar.gz
Save a few more bytes
-rw-r--r--networking/libiproute/iproute.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index cef67c3..f29a515 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -534,6 +534,7 @@ static int iproute_get(int argc, char **argv)
char *odev = NULL;
int connected = 0;
int from_ok = 0;
+ const char *options[] = { "from", "iif", "oif", "dev", "notify", "connected", "to", 0 };
memset(&req, 0, sizeof(req));
@@ -552,40 +553,53 @@ static int iproute_get(int argc, char **argv)
req.r.rtm_tos = 0;
while (argc > 0) {
- if (matches(*argv, "from") == 0) {
- inet_prefix addr;
- NEXT_ARG();
- from_ok = 1;
- get_prefix(&addr, *argv, req.r.rtm_family);
- if (req.r.rtm_family == AF_UNSPEC)
- req.r.rtm_family = addr.family;
- if (addr.bytelen)
- addattr_l(&req.n, sizeof(req), RTA_SRC, &addr.data, addr.bytelen);
- req.r.rtm_src_len = addr.bitlen;
- } else if (matches(*argv, "iif") == 0) {
- NEXT_ARG();
- idev = *argv;
- } else if (matches(*argv, "oif") == 0 ||
- strcmp(*argv, "dev") == 0) {
- NEXT_ARG();
- odev = *argv;
- } else if (matches(*argv, "notify") == 0) {
- req.r.rtm_flags |= RTM_F_NOTIFY;
- } else if (matches(*argv, "connected") == 0) {
- connected = 1;
- } else {
- inet_prefix addr;
- if (strcmp(*argv, "to") == 0) {
+ switch (compare_string_array(options, *argv)) {
+ case 0: /* from */
+ {
+ inet_prefix addr;
+ NEXT_ARG();
+ from_ok = 1;
+ get_prefix(&addr, *argv, req.r.rtm_family);
+ if (req.r.rtm_family == AF_UNSPEC) {
+ req.r.rtm_family = addr.family;
+ }
+ if (addr.bytelen) {
+ addattr_l(&req.n, sizeof(req), RTA_SRC, &addr.data, addr.bytelen);
+ }
+ req.r.rtm_src_len = addr.bitlen;
+ break;
+ }
+ case 1: /* iif */
+ NEXT_ARG();
+ idev = *argv;
+ break;
+ case 2: /* oif */
+ case 3: /* dev */
+ NEXT_ARG();
+ odev = *argv;
+ break;
+ case 4: /* notify */
+ req.r.rtm_flags |= RTM_F_NOTIFY;
+ break;
+ case 5: /* connected */
+ connected = 1;
+ break;
+ case 6: /* to */
NEXT_ARG();
+ default:
+ {
+ inet_prefix addr;
+ get_prefix(&addr, *argv, req.r.rtm_family);
+ if (req.r.rtm_family == AF_UNSPEC) {
+ req.r.rtm_family = addr.family;
+ }
+ if (addr.bytelen) {
+ addattr_l(&req.n, sizeof(req), RTA_DST, &addr.data, addr.bytelen);
+ }
+ req.r.rtm_dst_len = addr.bitlen;
}
- get_prefix(&addr, *argv, req.r.rtm_family);
- if (req.r.rtm_family == AF_UNSPEC)
- req.r.rtm_family = addr.family;
- if (addr.bytelen)
- addattr_l(&req.n, sizeof(req), RTA_DST, &addr.data, addr.bytelen);
- req.r.rtm_dst_len = addr.bitlen;
+ argc--; argv++;
}
- argc--; argv++;
}
if (req.r.rtm_dst_len == 0) {