]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Assert size for more structs.
authorRoy Marples <roy@marples.name>
Wed, 5 Oct 2016 15:00:35 +0000 (15:00 +0000)
committerRoy Marples <roy@marples.name>
Wed, 5 Oct 2016 15:00:35 +0000 (15:00 +0000)
arp.c
dhcp.c
dhcp6.c

diff --git a/arp.c b/arp.c
index 330ea092684f967f796fce0196cd95d04ec69eb8..456af160294dcea0dec611ee413452b1a209bd24 100644 (file)
--- 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 ef9e333ec4197d0c98c6e5d5941ffec2954d761c..c1d4282a82cea3874f8be9c3c88c46c0197adc10 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
 #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 13f7baa00023d7584dd54a036aa5fbab90183d30..9b1e30cd538cb7d47d89e4921625530643035a29 100644 (file)
--- 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;