diff --git a/src/icmp.c b/src/icmp.c index 644da95..3ed6d81 100644 --- a/src/icmp.c +++ b/src/icmp.c @@ -130,8 +130,8 @@ int icmp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, IPPROTO_ICMPV6, (unsigned char *) icmp); /* copy the payload data (with new checksum) */ - memcpy(packet + sizeof(struct s_ethernet) + sizeof(struct s_ipv6), payload, - payload_size); + memcpy(packet + sizeof(struct s_ethernet) + sizeof(struct s_ipv6), + payload, payload_size); /* send translated packet */ transmit_raw(packet, sizeof(struct s_ethernet) + sizeof(struct s_ipv6) + diff --git a/src/icmp.h b/src/icmp.h index 82ca9f7..f64a1c3 100644 --- a/src/icmp.h +++ b/src/icmp.h @@ -49,19 +49,19 @@ struct s_icmp { unsigned char type; /* 8 b; ICMP type */ unsigned char code; /* 8 b; subtype of ICMP type */ unsigned short checksum; /* 16 b */ -}; +} __attribute__ ((__packed__)); /* ICMP echo structure */ struct s_icmp_echo { unsigned short id; /* 16 b; ID value */ unsigned short seq; /* 16 b; sequence number */ -}; +} __attribute__ ((__packed__)); /* ICMP NDP NS structure */ struct s_icmp_ndp_ns { unsigned int zeros; /* 32 b; reserved section */ struct s_ipv6_addr target; /* 128 b; target IP address */ -}; +} __attribute__ ((__packed__)); /* ICMP NDP NA structure */ struct s_icmp_ndp_na { @@ -72,7 +72,7 @@ struct s_icmp_ndp_na { unsigned char opt_len; /* 8 b; option -- length */ struct s_mac_addr opt_tlla; /* 48 b; option -- target link-layer address */ -}; +} __attribute__ ((__packed__)); int icmp_ipv4(struct s_ethernet *eth, struct s_ipv4 *ip4, char *payload, unsigned short payload_size);