odhcp6c: reuse md5 from libubox
[project/odhcp6c.git] / src / dhcpv6.c
index f91f2cf16b8c8ff6fe881310433b98b68e2d8780..2a9f8a2f56b7d5bd3fdb059a517732a271feeaec 100644 (file)
 #include <net/ethernet.h>
 
 #include "odhcp6c.h"
+#ifdef LIBUBOX
+#include <libubox/md5.h>
+#else
 #include "md5.h"
+#endif
 
 
 #define ALL_DHCPV6_RELAYS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
@@ -586,12 +590,14 @@ int dhcpv6_request(enum dhcpv6_msg type)
                for (; len < 0 && (round_start < round_end);
                                round_start = odhcp6c_get_milli_time()) {
                        uint8_t buf[1536];
-                       uint8_t cmsg_buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]
-                               __aligned(__alignof__(struct cmsghdr));
+                       union {
+                               struct cmsghdr hdr;
+                               uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+                       } cmsg_buf;
                        struct iovec iov = {buf, sizeof(buf)};
                        struct sockaddr_in6 addr;
                        struct msghdr msg = {.msg_name = &addr, .msg_namelen = sizeof(addr),
-                                       .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cmsg_buf,
+                                       .msg_iov = &iov, .msg_iovlen = 1, .msg_control = cmsg_buf.buf,
                                        .msg_controllen = sizeof(cmsg_buf)};
                        struct in6_pktinfo *pktinfo = NULL;
 
@@ -1000,7 +1006,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
                                if (code != DHCPV6_Success)
                                        continue;
 
-                               dhcpv6_parse_ia(ia_hdr, odata + olen + sizeof(*ia_hdr));
+                               dhcpv6_parse_ia(ia_hdr, odata + olen);
                                passthru = false;
                        } else if (otype == DHCPV6_OPT_STATUS && olen >= 2) {
                                uint8_t *mdata = (olen > 2) ? &odata[2] : NULL;