Add check for __Static_assert() and asserts on struct sizes
[tinc] / src / ipv4.h
index 708e5c1..004f4e5 100644 (file)
@@ -83,9 +83,11 @@ struct ip {
        uint8_t ip_p;
        uint16_t ip_sum;
        struct in_addr ip_src, ip_dst;
-} __attribute__((__gcc_struct__)) __attribute((__packed__));
+};
 #endif
 
+STATIC_ASSERT(sizeof(struct ip) == 20, "ip has incorrect size");
+
 #ifndef IP_OFFMASK
 #define IP_OFFMASK 0x1fff
 #endif
@@ -145,7 +147,9 @@ struct icmp {
 #define icmp_radv icmp_dun.id_radv
 #define icmp_mask icmp_dun.id_mask
 #define icmp_data icmp_dun.id_data
-} __attribute__((__gcc_struct__)) __attribute((__packed__));
+};
 #endif
 
+STATIC_ASSERT(sizeof(struct icmp) == 28, "icmp has incorrect size");
+
 #endif