summaryrefslogtreecommitdiffhomepage
path: root/networking/udhcp/d6_socket.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-04-14 17:01:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-04-14 17:01:10 +0200
commit60bf77f7e7c4513a781e9acc1b9bca64c4051140 (patch)
tree4793854ad401664a10c9bc12f5c371b417fb5712 /networking/udhcp/d6_socket.c
parent0d75e8b7973353f1d034b97bebfd4d2c13a9f5d6 (diff)
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/d6_socket.c')
-rw-r--r--networking/udhcp/d6_socket.c18
1 files changed, 12 insertions, 6 deletions
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 @@
#include <ifaddrs.h>
#include <netpacket/packet.h>
-int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_addr *nip6, uint8_t *mac)
+int FAST_FUNC d6_read_interface(
+ const char *interface,
+ int *ifindex,
+ struct in6_addr *nip6,
+ uint8_t *mac)
{
int retval = 3;
struct ifaddrs *ifap, *ifa;
@@ -22,12 +26,12 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_
if (!ifa->ifa_addr || (strcmp(ifa->ifa_name, interface) != 0))
continue;
- sip6 = (struct sockaddr_in6*)(ifa->ifa_addr);
-
if (ifa->ifa_addr->sa_family == AF_PACKET) {
- struct sockaddr_ll *sll = (struct sockaddr_ll*)(ifa->ifa_addr);
+ struct sockaddr_ll *sll = (void*)(ifa->ifa_addr);
memcpy(mac, sll->sll_addr, 6);
- log2("MAC %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ log2("MAC %02x:%02x:%02x:%02x:%02x:%02x",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
+ );
*ifindex = sll->sll_ifindex;
log2("ifindex %d", *ifindex);
retval &= (3 - (1<<0));
@@ -47,6 +51,8 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_
* is requesting configuration information as the source address in the
* header of the IP datagram."
*/
+ sip6 = (void*)(ifa->ifa_addr);
+
if (ifa->ifa_addr->sa_family == AF_INET6
&& IN6_IS_ADDR_LINKLOCAL(&sip6->sin6_addr)
) {
@@ -96,7 +102,7 @@ int FAST_FUNC d6_read_interface(const char *interface, int *ifindex, struct in6_
bb_error_msg("can't get %s", "MAC");
if (retval & (1<<1))
bb_error_msg("can't get %s", "link-local IPv6 address");
- return -1;
+ return retval;
}
int FAST_FUNC d6_listen_socket(int port, const char *inf)