]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
IPv6ND: Use generic initialisers rather than inet_pton
authorRoy Marples <roy@marples.name>
Wed, 24 Apr 2019 11:18:25 +0000 (12:18 +0100)
committerRoy Marples <roy@marples.name>
Wed, 24 Apr 2019 11:18:25 +0000 (12:18 +0100)
src/ipv6.h
src/ipv6nd.c

index bc48d42e280a6e5c3f78e4234c50b74b480bab95..8762603d7f37e7fb6ad91fb94e3f3437c8319ed3 100644 (file)
@@ -44,9 +44,6 @@
 #  endif
 #endif
 
-#define        ALLNODES                "ff02::1"
-#define        ALLROUTERS              "ff02::2"
-
 #define EUI64_GBIT             0x01
 #define EUI64_UBIT             0x02
 #define EUI64_TO_IFID(in6)     do {(in6)->s6_addr[8] ^= EUI64_UBIT; } while (0)
index e8a0618267f19f249efd577dc64bfcd59edc373b..076f18646753af75c7dbc38bbb931e6b45063bf8 100644 (file)
@@ -332,7 +332,11 @@ ipv6nd_sendrsprobe(void *arg)
 {
        struct interface *ifp = arg;
        struct rs_state *state = RS_STATE(ifp);
-       struct sockaddr_in6 dst = { .sin6_family = AF_INET6 };
+       struct sockaddr_in6 dst = {
+               .sin6_family = AF_INET6,
+               .sin6_addr = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT,
+               .sin6_scope_id = ifp->index,
+       };
        struct iovec iov = { .iov_base = state->rs, .iov_len = state->rslen };
        unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 };
        struct msghdr msg = {
@@ -354,11 +358,6 @@ ipv6nd_sendrsprobe(void *arg)
 #ifdef HAVE_SA_LEN
        dst.sin6_len = sizeof(dst);
 #endif
-       dst.sin6_scope_id = ifp->index;
-       if (inet_pton(AF_INET6, ALLROUTERS, &dst.sin6_addr) != 1) {
-               logerr(__func__);
-               return;
-       }
 
        /* Set the outbound interface */
        cm = CMSG_FIRSTHDR(&msg);
@@ -403,6 +402,7 @@ ipv6nd_sendadvertisement(void *arg)
        struct dhcpcd_ctx *ctx = ifp->ctx;
        struct sockaddr_in6 dst = {
            .sin6_family = AF_INET6,
+           .sin6_addr = IN6ADDR_LINKLOCAL_ALLNODES_INIT,
            .sin6_scope_id = ifp->index,
        };
        struct iovec iov = { .iov_base = ia->na, .iov_len = ia->na_len };
@@ -423,10 +423,6 @@ ipv6nd_sendadvertisement(void *arg)
 #ifdef SIN6_LEN
        dst.sin6_len = sizeof(dst);
 #endif
-       if (inet_pton(AF_INET6, ALLNODES, &dst.sin6_addr) != 1) {
-               logerr(__func__);
-               return;
-       }
 
        /* Set the outbound interface. */
        cm = CMSG_FIRSTHDR(&msg);