From: Hans Dedecker Date: Sun, 1 Dec 2013 17:47:19 +0000 (+0100) Subject: Remove setsockopt error checking X-Git-Tag: debian/1.1+git20160131-1~107^2~12 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=41cdcf25270bc252ab6c48778e27e76898c999cc;p=odhcp6c.git Remove setsockopt error checking --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index b727818..7ae908c 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -145,6 +145,7 @@ int init_dhcpv6(const char *ifname, int request_pd, int sol_timeout) sizeof(ifr.ifr_name)); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) continue; + memcpy(&duid[8], ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); } @@ -169,31 +170,21 @@ int init_dhcpv6(const char *ifname, int request_pd, int sol_timeout) }; odhcp6c_add_state(STATE_ORO, oro, sizeof(oro)); - do { - // Configure IPv6-options - int val = 1; - if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)) < 0) - break; - if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) - break; - if (setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)) < 0) - break; - - val = 0; - if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &val, sizeof(val)) < 0) - break; - if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname)) < 0) - break; - - struct sockaddr_in6 client_addr = { .sin6_family = AF_INET6, - .sin6_port = htons(DHCPV6_CLIENT_PORT), .sin6_flowinfo = 0 }; - if (bind(sock, (struct sockaddr*)&client_addr, sizeof(client_addr)) < 0) - break; - - return 0; - } while (0); + // Configure IPv6-options + int val = 1; + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)); + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); + val = 0; + setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &val, sizeof(val)); + setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname)); + + struct sockaddr_in6 client_addr = { .sin6_family = AF_INET6, + .sin6_port = htons(DHCPV6_CLIENT_PORT), .sin6_flowinfo = 0 }; + if (bind(sock, (struct sockaddr*)&client_addr, sizeof(client_addr)) < 0) + return -1; - return -1; + return 0; }