From: Roy Marples Date: Wed, 5 Oct 2016 15:00:35 +0000 (+0000) Subject: Assert size for more structs. X-Git-Tag: v7.0.0-beta1~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33ca59c08e81d13dd2033e03ccc1cd866929aeae;p=thirdparty%2Fdhcpcd.git Assert size for more structs. --- diff --git a/arp.c b/arp.c index 330ea092..456af160 100644 --- a/arp.c +++ b/arp.c @@ -55,6 +55,9 @@ #define ARP_LEN \ (sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN)) +/* Assert the correct structure size for on wire */ +__CTASSERT(sizeof(struct arphdr) == 8); + ssize_t arp_request(const struct interface *ifp, in_addr_t sip, in_addr_t tip) { diff --git a/dhcp.c b/dhcp.c index ef9e333e..c1d4282a 100644 --- a/dhcp.c +++ b/dhcp.c @@ -83,8 +83,10 @@ #define IPDEFTTL 64 /* RFC1340 */ #endif -/* Assert the bootp structure is correct size. */ -__CTASSERT(sizeof(struct bootp) == 300); +/* Assert the correct structure size for on wire */ +__CTASSERT(sizeof(struct ip) == 20); +__CTASSERT(sizeof(struct udphdr) == 8); +__CTASSERT(sizeof(struct bootp) == 300); struct dhcp_op { uint8_t value; diff --git a/dhcp6.c b/dhcp6.c index 13f7baa0..9b1e30cd 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -75,6 +75,7 @@ #ifdef DHCP6 +/* Assert the correct structure size for on wire */ struct dhcp6_message { uint8_t type; uint8_t xid[3]; @@ -103,6 +104,8 @@ struct dhcp6_ia_addr { }; __CTASSERT(sizeof(struct dhcp6_ia_addr) == 16 + 8); +/* XXX FIXME: This is the only packed structure and it does not align. + * Maybe manually decode it? */ struct dhcp6_pd_addr { uint32_t pltime; uint32_t vltime;