diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 14:12:08 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 14:12:08 +0000 |
commit | 703e20235aa0624d3ff4335c1e86edaa6e21efe2 (patch) | |
tree | 49e8451efad93b75c0be74ee553d3b3f8c04a25d /networking/route.c | |
parent | 6cd2d2bcba37a13d0d73326dd7bca64bbccce4f8 (diff) | |
download | busybox-w32-703e20235aa0624d3ff4335c1e86edaa6e21efe2.tar.gz busybox-w32-703e20235aa0624d3ff4335c1e86edaa6e21efe2.tar.bz2 busybox-w32-703e20235aa0624d3ff4335c1e86edaa6e21efe2.zip |
cleanups: unnecessary casts, unified const_1, eliminate cross-.c file
prototypes (heresy!), add spaces in places like "flags&NETSTAT_CONNECTED",
removed unused #defines, #ifdef -> #if, use uint32_t for ipv4 addrs.
Diffstat (limited to 'networking/route.c')
-rw-r--r-- | networking/route.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/networking/route.c b/networking/route.c index d6d9b7dd9..c6fb5a371 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -63,14 +63,14 @@ | |||
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | /* The RTACTION entries must agree with tbl_verb[] below! */ | 65 | /* The RTACTION entries must agree with tbl_verb[] below! */ |
66 | #define RTACTION_ADD 1 | 66 | #define RTACTION_ADD 1 |
67 | #define RTACTION_DEL 2 | 67 | #define RTACTION_DEL 2 |
68 | 68 | ||
69 | /* For the various tbl_*[] arrays, the 1st byte is the offset to | 69 | /* For the various tbl_*[] arrays, the 1st byte is the offset to |
70 | * the next entry and the 2nd byte is return value. */ | 70 | * the next entry and the 2nd byte is return value. */ |
71 | 71 | ||
72 | #define NET_FLAG 1 | 72 | #define NET_FLAG 1 |
73 | #define HOST_FLAG 2 | 73 | #define HOST_FLAG 2 |
74 | 74 | ||
75 | /* We remap '-' to '#' to avoid problems with getopt. */ | 75 | /* We remap '-' to '#' to avoid problems with getopt. */ |
76 | static const char tbl_hash_net_host[] = | 76 | static const char tbl_hash_net_host[] = |
@@ -79,22 +79,22 @@ static const char tbl_hash_net_host[] = | |||
79 | "\007\002#host" /* Since last, we can save a byte. */ | 79 | "\007\002#host" /* Since last, we can save a byte. */ |
80 | ; | 80 | ; |
81 | 81 | ||
82 | #define KW_TAKES_ARG 020 | 82 | #define KW_TAKES_ARG 020 |
83 | #define KW_SETS_FLAG 040 | 83 | #define KW_SETS_FLAG 040 |
84 | 84 | ||
85 | #define KW_IPVx_METRIC 020 | 85 | #define KW_IPVx_METRIC 020 |
86 | #define KW_IPVx_NETMASK 021 | 86 | #define KW_IPVx_NETMASK 021 |
87 | #define KW_IPVx_GATEWAY 022 | 87 | #define KW_IPVx_GATEWAY 022 |
88 | #define KW_IPVx_MSS 023 | 88 | #define KW_IPVx_MSS 023 |
89 | #define KW_IPVx_WINDOW 024 | 89 | #define KW_IPVx_WINDOW 024 |
90 | #define KW_IPVx_IRTT 025 | 90 | #define KW_IPVx_IRTT 025 |
91 | #define KW_IPVx_DEVICE 026 | 91 | #define KW_IPVx_DEVICE 026 |
92 | 92 | ||
93 | #define KW_IPVx_FLAG_ONLY 040 | 93 | #define KW_IPVx_FLAG_ONLY 040 |
94 | #define KW_IPVx_REJECT 040 | 94 | #define KW_IPVx_REJECT 040 |
95 | #define KW_IPVx_MOD 041 | 95 | #define KW_IPVx_MOD 041 |
96 | #define KW_IPVx_DYN 042 | 96 | #define KW_IPVx_DYN 042 |
97 | #define KW_IPVx_REINSTATE 043 | 97 | #define KW_IPVx_REINSTATE 043 |
98 | 98 | ||
99 | static const char tbl_ipvx[] = | 99 | static const char tbl_ipvx[] = |
100 | /* 020 is the "takes an arg" bit */ | 100 | /* 020 is the "takes an arg" bit */ |
@@ -167,7 +167,7 @@ static void INET_setroute(int action, char **args) | |||
167 | } | 167 | } |
168 | 168 | ||
169 | /* Clean out the RTREQ structure. */ | 169 | /* Clean out the RTREQ structure. */ |
170 | memset((char *) &rt, 0, sizeof(struct rtentry)); | 170 | memset(&rt, 0, sizeof(rt)); |
171 | 171 | ||
172 | { | 172 | { |
173 | const char *target = *args++; | 173 | const char *target = *args++; |
@@ -334,7 +334,7 @@ static void INET_setroute(int action, char **args) | |||
334 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); | 334 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); |
335 | } | 335 | } |
336 | 336 | ||
337 | #ifdef CONFIG_FEATURE_IPV6 | 337 | #if ENABLE_FEATURE_IPV6 |
338 | 338 | ||
339 | static void INET6_setroute(int action, char **args) | 339 | static void INET6_setroute(int action, char **args) |
340 | { | 340 | { |
@@ -363,7 +363,7 @@ static void INET6_setroute(int action, char **args) | |||
363 | } | 363 | } |
364 | 364 | ||
365 | /* Clean out the RTREQ structure. */ | 365 | /* Clean out the RTREQ structure. */ |
366 | memset((char *) &rt, 0, sizeof(struct in6_rtmsg)); | 366 | memset(&rt, 0, sizeof(rt)); |
367 | 367 | ||
368 | memcpy(&rt.rtmsg_dst, sa6.sin6_addr.s6_addr, sizeof(struct in6_addr)); | 368 | memcpy(&rt.rtmsg_dst, sa6.sin6_addr.s6_addr, sizeof(struct in6_addr)); |
369 | 369 | ||
@@ -445,7 +445,7 @@ static const unsigned int flagvals[] = { /* Must agree with flagchars[]. */ | |||
445 | RTF_REINSTATE, | 445 | RTF_REINSTATE, |
446 | RTF_DYNAMIC, | 446 | RTF_DYNAMIC, |
447 | RTF_MODIFIED, | 447 | RTF_MODIFIED, |
448 | #ifdef CONFIG_FEATURE_IPV6 | 448 | #if ENABLE_FEATURE_IPV6 |
449 | RTF_DEFAULT, | 449 | RTF_DEFAULT, |
450 | RTF_ADDRCONF, | 450 | RTF_ADDRCONF, |
451 | RTF_CACHE | 451 | RTF_CACHE |
@@ -457,7 +457,7 @@ static const unsigned int flagvals[] = { /* Must agree with flagchars[]. */ | |||
457 | 457 | ||
458 | static const char flagchars[] = /* Must agree with flagvals[]. */ | 458 | static const char flagchars[] = /* Must agree with flagvals[]. */ |
459 | "GHRDM" | 459 | "GHRDM" |
460 | #ifdef CONFIG_FEATURE_IPV6 | 460 | #if ENABLE_FEATURE_IPV6 |
461 | "DAC" | 461 | "DAC" |
462 | #endif | 462 | #endif |
463 | ; | 463 | ; |
@@ -476,7 +476,7 @@ static void set_flags(char *flagstr, int flags) | |||
476 | } | 476 | } |
477 | 477 | ||
478 | /* also used in netstat */ | 478 | /* also used in netstat */ |
479 | void displayroutes(int noresolve, int netstatfmt) | 479 | void bb_displayroutes(int noresolve, int netstatfmt) |
480 | { | 480 | { |
481 | char devname[64], flags[16], sdest[16], sgw[16]; | 481 | char devname[64], flags[16], sdest[16], sgw[16]; |
482 | unsigned long int d, g, m; | 482 | unsigned long int d, g, m; |
@@ -537,7 +537,7 @@ void displayroutes(int noresolve, int netstatfmt) | |||
537 | } | 537 | } |
538 | } | 538 | } |
539 | 539 | ||
540 | #ifdef CONFIG_FEATURE_IPV6 | 540 | #if ENABLE_FEATURE_IPV6 |
541 | 541 | ||
542 | static void INET6_displayroutes(int noresolve) | 542 | static void INET6_displayroutes(int noresolve) |
543 | { | 543 | { |
@@ -589,7 +589,7 @@ static void INET6_displayroutes(int noresolve) | |||
589 | goto ERROR; | 589 | goto ERROR; |
590 | } | 590 | } |
591 | addr6x[i++] = *p++; | 591 | addr6x[i++] = *p++; |
592 | if (!((i+1)%5)) { | 592 | if (!((i+1) % 5)) { |
593 | addr6x[i++] = ':'; | 593 | addr6x[i++] = ':'; |
594 | } | 594 | } |
595 | } while (i < 40+28+7); | 595 | } while (i < 40+28+7); |
@@ -626,10 +626,10 @@ static void INET6_displayroutes(int noresolve) | |||
626 | 626 | ||
627 | #endif | 627 | #endif |
628 | 628 | ||
629 | #define ROUTE_OPT_A 0x01 | 629 | #define ROUTE_OPT_A 0x01 |
630 | #define ROUTE_OPT_n 0x02 | 630 | #define ROUTE_OPT_n 0x02 |
631 | #define ROUTE_OPT_e 0x04 | 631 | #define ROUTE_OPT_e 0x04 |
632 | #define ROUTE_OPT_INET6 0x08 /* Not an actual option. See below. */ | 632 | #define ROUTE_OPT_INET6 0x08 /* Not an actual option. See below. */ |
633 | 633 | ||
634 | /* 1st byte is offset to next entry offset. 2nd byte is return value. */ | 634 | /* 1st byte is offset to next entry offset. 2nd byte is return value. */ |
635 | static const char tbl_verb[] = /* 2nd byte matches RTACTION_* code */ | 635 | static const char tbl_verb[] = /* 2nd byte matches RTACTION_* code */ |
@@ -649,15 +649,15 @@ int route_main(int argc, char **argv) | |||
649 | /* First, remap '-net' and '-host' to avoid getopt problems. */ | 649 | /* First, remap '-net' and '-host' to avoid getopt problems. */ |
650 | p = argv; | 650 | p = argv; |
651 | while (*++p) { | 651 | while (*++p) { |
652 | if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) { | 652 | if (strcmp(*p, "-net") == 0 || strcmp(*p, "-host") == 0) { |
653 | p[0][0] = '#'; | 653 | p[0][0] = '#'; |
654 | } | 654 | } |
655 | } | 655 | } |
656 | 656 | ||
657 | opt = getopt32(argc, argv, "A:ne", &family); | 657 | opt = getopt32(argc, argv, "A:ne", &family); |
658 | 658 | ||
659 | if ((opt & ROUTE_OPT_A) && strcmp(family, "inet")) { | 659 | if ((opt & ROUTE_OPT_A) && strcmp(family, "inet") != 0) { |
660 | #ifdef CONFIG_FEATURE_IPV6 | 660 | #if ENABLE_FEATURE_IPV6 |
661 | if (strcmp(family, "inet6") == 0) { | 661 | if (strcmp(family, "inet6") == 0) { |
662 | opt |= ROUTE_OPT_INET6; /* Set flag for ipv6. */ | 662 | opt |= ROUTE_OPT_INET6; /* Set flag for ipv6. */ |
663 | } else | 663 | } else |
@@ -670,12 +670,12 @@ int route_main(int argc, char **argv) | |||
670 | /* No more args means display the routing table. */ | 670 | /* No more args means display the routing table. */ |
671 | if (!*argv) { | 671 | if (!*argv) { |
672 | int noresolve = (opt & ROUTE_OPT_n) ? 0x0fff : 0; | 672 | int noresolve = (opt & ROUTE_OPT_n) ? 0x0fff : 0; |
673 | #ifdef CONFIG_FEATURE_IPV6 | 673 | #if ENABLE_FEATURE_IPV6 |
674 | if (opt & ROUTE_OPT_INET6) | 674 | if (opt & ROUTE_OPT_INET6) |
675 | INET6_displayroutes(noresolve); | 675 | INET6_displayroutes(noresolve); |
676 | else | 676 | else |
677 | #endif | 677 | #endif |
678 | displayroutes(noresolve, opt & ROUTE_OPT_e); | 678 | bb_displayroutes(noresolve, opt & ROUTE_OPT_e); |
679 | 679 | ||
680 | fflush_stdout_and_exit(EXIT_SUCCESS); | 680 | fflush_stdout_and_exit(EXIT_SUCCESS); |
681 | } | 681 | } |
@@ -686,7 +686,7 @@ int route_main(int argc, char **argv) | |||
686 | bb_show_usage(); | 686 | bb_show_usage(); |
687 | } | 687 | } |
688 | 688 | ||
689 | #ifdef CONFIG_FEATURE_IPV6 | 689 | #if ENABLE_FEATURE_IPV6 |
690 | if (opt & ROUTE_OPT_INET6) | 690 | if (opt & ROUTE_OPT_INET6) |
691 | INET6_setroute(what, argv); | 691 | INET6_setroute(what, argv); |
692 | else | 692 | else |