odhcpd: switch to libubox container_of implementation
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 12 Dec 2018 17:48:30 +0000 (18:48 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 12 Dec 2018 18:00:49 +0000 (19:00 +0100)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/dhcpv6-ia.c
src/odhcpd.h

index fb1c22860fe571e4c8e00f3c7d3810799d4af51e..3b2dfaf149adde96f041636bd9b4da1b1418d102 100644 (file)
@@ -521,7 +521,8 @@ static void set_border_assignment_size(struct interface *iface, struct dhcpv6_as
 /* More data was received from TCP connection */
 static void managed_handle_pd_data(struct ustream *s, _unused int bytes_new)
 {
-       struct dhcpv6_assignment *c = container_of(s, struct dhcpv6_assignment, managed_sock);
+       struct ustream_fd *fd = container_of(s, struct ustream_fd, stream);
+       struct dhcpv6_assignment *c = container_of(fd, struct dhcpv6_assignment, managed_sock);
        time_t now = odhcpd_time();
        bool first = c->managed_size < 0;
 
@@ -592,7 +593,8 @@ static void managed_handle_pd_data(struct ustream *s, _unused int bytes_new)
 /* TCP transmission has ended, either because of success or timeout or other error */
 static void managed_handle_pd_done(struct ustream *s)
 {
-       struct dhcpv6_assignment *c = container_of(s, struct dhcpv6_assignment, managed_sock);
+       struct ustream_fd *fd = container_of(s, struct ustream_fd, stream);
+       struct dhcpv6_assignment *c = container_of(fd, struct dhcpv6_assignment, managed_sock);
 
        if (!(c->flags & OAF_STATIC))
                c->valid_until = odhcpd_time() + 15;
index 423deaa1c5c7ed55994af882e734b583e520ab47..80dbb40f3463bbc8ed4e4484fc377075f2557a7a 100644 (file)
 #include <syslog.h>
 
 #include <libubox/blobmsg.h>
-
-#ifndef typeof
-#define typeof __typeof
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) (           \
-    (type *)( (char *)ptr - offsetof(type,member) ))
-#endif
-
 #include <libubox/list.h>
 #include <libubox/uloop.h>