]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Remove setsockopt error checking
authorHans Dedecker <dedeckeh@gmail.com>
Sun, 1 Dec 2013 17:47:19 +0000 (18:47 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 1 Dec 2013 17:47:19 +0000 (18:47 +0100)
src/dhcpv6.c

index b727818139a1aba2f5fffd9032a9a26856a6be26..7ae908c8a24dfa9f08851563182a53a9cb48e641 100644 (file)
@@ -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;
 }