diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-14 17:01:10 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-14 17:01:10 +0200 |
commit | 60bf77f7e7c4513a781e9acc1b9bca64c4051140 (patch) | |
tree | 4793854ad401664a10c9bc12f5c371b417fb5712 /networking/udhcp | |
parent | 0d75e8b7973353f1d034b97bebfd4d2c13a9f5d6 (diff) | |
download | busybox-w32-60bf77f7e7c4513a781e9acc1b9bca64c4051140.tar.gz busybox-w32-60bf77f7e7c4513a781e9acc1b9bca64c4051140.tar.bz2 busybox-w32-60bf77f7e7c4513a781e9acc1b9bca64c4051140.zip |
udhcpc6: code shrink
function old new delta
d6_read_interface 593 582 -11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/d6_common.h | 7 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 3 | ||||
-rw-r--r-- | networking/udhcp/d6_socket.c | 18 |
3 files changed, 18 insertions, 10 deletions
diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h index d0506e2bb..2178cb9d6 100644 --- a/networking/udhcp/d6_common.h +++ b/networking/udhcp/d6_common.h | |||
@@ -145,7 +145,12 @@ struct client6_data_t { | |||
145 | 145 | ||
146 | #define client6_data (*(struct client6_data_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE - sizeof(struct client6_data_t)])) | 146 | #define client6_data (*(struct client6_data_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE - sizeof(struct client6_data_t)])) |
147 | 147 | ||
148 | int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_addr *nip6, uint8_t *mac); | 148 | int FAST_FUNC d6_read_interface( |
149 | const char *interface, | ||
150 | int *ifindex, | ||
151 | struct in6_addr *nip6, | ||
152 | uint8_t *mac | ||
153 | ); | ||
149 | 154 | ||
150 | int FAST_FUNC d6_listen_socket(int port, const char *inf); | 155 | int FAST_FUNC d6_listen_socket(int port, const char *inf); |
151 | 156 | ||
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 112f12df2..3562988fd 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -204,7 +204,6 @@ static void *d6_copy_option(uint8_t *option, uint8_t *option_end, unsigned code) | |||
204 | return xmemdup(opt, opt[3] + 4); | 204 | return xmemdup(opt, opt[3] + 4); |
205 | } | 205 | } |
206 | 206 | ||
207 | |||
208 | /*** Script execution code ***/ | 207 | /*** Script execution code ***/ |
209 | 208 | ||
210 | static char** new_env(void) | 209 | static char** new_env(void) |
@@ -902,7 +901,6 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac | |||
902 | return bytes; | 901 | return bytes; |
903 | } | 902 | } |
904 | 903 | ||
905 | |||
906 | /*** Main ***/ | 904 | /*** Main ***/ |
907 | 905 | ||
908 | static int sockfd = -1; | 906 | static int sockfd = -1; |
@@ -1146,7 +1144,6 @@ static void client_background(void) | |||
1146 | //usage: "\n USR1 Renew lease" | 1144 | //usage: "\n USR1 Renew lease" |
1147 | //usage: "\n USR2 Release lease" | 1145 | //usage: "\n USR2 Release lease" |
1148 | 1146 | ||
1149 | |||
1150 | int udhcpc6_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 1147 | int udhcpc6_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
1151 | int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | 1148 | int udhcpc6_main(int argc UNUSED_PARAM, char **argv) |
1152 | { | 1149 | { |
diff --git a/networking/udhcp/d6_socket.c b/networking/udhcp/d6_socket.c index fe46e5f1d..25e622d6f 100644 --- a/networking/udhcp/d6_socket.c +++ b/networking/udhcp/d6_socket.c | |||
@@ -10,7 +10,11 @@ | |||
10 | #include <ifaddrs.h> | 10 | #include <ifaddrs.h> |
11 | #include <netpacket/packet.h> | 11 | #include <netpacket/packet.h> |
12 | 12 | ||
13 | int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_addr *nip6, uint8_t *mac) | 13 | int FAST_FUNC d6_read_interface( |
14 | const char *interface, | ||
15 | int *ifindex, | ||
16 | struct in6_addr *nip6, | ||
17 | uint8_t *mac) | ||
14 | { | 18 | { |
15 | int retval = 3; | 19 | int retval = 3; |
16 | struct ifaddrs *ifap, *ifa; | 20 | struct ifaddrs *ifap, *ifa; |
@@ -22,12 +26,12 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_ | |||
22 | if (!ifa->ifa_addr || (strcmp(ifa->ifa_name, interface) != 0)) | 26 | if (!ifa->ifa_addr || (strcmp(ifa->ifa_name, interface) != 0)) |
23 | continue; | 27 | continue; |
24 | 28 | ||
25 | sip6 = (struct sockaddr_in6*)(ifa->ifa_addr); | ||
26 | |||
27 | if (ifa->ifa_addr->sa_family == AF_PACKET) { | 29 | if (ifa->ifa_addr->sa_family == AF_PACKET) { |
28 | struct sockaddr_ll *sll = (struct sockaddr_ll*)(ifa->ifa_addr); | 30 | struct sockaddr_ll *sll = (void*)(ifa->ifa_addr); |
29 | memcpy(mac, sll->sll_addr, 6); | 31 | memcpy(mac, sll->sll_addr, 6); |
30 | log2("MAC %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | 32 | log2("MAC %02x:%02x:%02x:%02x:%02x:%02x", |
33 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] | ||
34 | ); | ||
31 | *ifindex = sll->sll_ifindex; | 35 | *ifindex = sll->sll_ifindex; |
32 | log2("ifindex %d", *ifindex); | 36 | log2("ifindex %d", *ifindex); |
33 | retval &= (3 - (1<<0)); | 37 | retval &= (3 - (1<<0)); |
@@ -47,6 +51,8 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_ | |||
47 | * is requesting configuration information as the source address in the | 51 | * is requesting configuration information as the source address in the |
48 | * header of the IP datagram." | 52 | * header of the IP datagram." |
49 | */ | 53 | */ |
54 | sip6 = (void*)(ifa->ifa_addr); | ||
55 | |||
50 | if (ifa->ifa_addr->sa_family == AF_INET6 | 56 | if (ifa->ifa_addr->sa_family == AF_INET6 |
51 | && IN6_IS_ADDR_LINKLOCAL(&sip6->sin6_addr) | 57 | && IN6_IS_ADDR_LINKLOCAL(&sip6->sin6_addr) |
52 | ) { | 58 | ) { |
@@ -96,7 +102,7 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_ | |||
96 | bb_error_msg("can't get %s", "MAC"); | 102 | bb_error_msg("can't get %s", "MAC"); |
97 | if (retval & (1<<1)) | 103 | if (retval & (1<<1)) |
98 | bb_error_msg("can't get %s", "link-local IPv6 address"); | 104 | bb_error_msg("can't get %s", "link-local IPv6 address"); |
99 | return -1; | 105 | return retval; |
100 | } | 106 | } |
101 | 107 | ||
102 | int FAST_FUNC d6_listen_socket(int port, const char *inf) | 108 | int FAST_FUNC d6_listen_socket(int port, const char *inf) |