From 4035d840ddab6e44f68d0dd97d6551b50114bce9 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 17 Oct 2018 15:57:39 +0200 Subject: [PATCH] Rework uip.h buffer definitions --- os/net/ipv6/uip.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/os/net/ipv6/uip.h b/os/net/ipv6/uip.h index 35f0d9cfd..213081a91 100755 --- a/os/net/ipv6/uip.h +++ b/os/net/ipv6/uip.h @@ -79,16 +79,19 @@ /** * Direct access to IPv6 header */ -#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN]) +#define UIP_IP_BUF_CHAR ((unsigned char *)uip_buf + UIP_LLH_LEN) +#define UIP_IP_BUF ((struct uip_ip_hdr *)UIP_IP_BUF_CHAR) +#define UIP_IP_PAYLOAD(ext) ((unsigned char *)UIP_IP_BUF_CHAR + UIP_IPH_LEN + (ext)) /** - * Direct access to ICMP, UDP, and TCP headers and payload + * Direct access to ICMP, UDP, and TCP headers and payload, with implicit ext header offset */ -#define UIP_IP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_hdr_len]) -#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)UIP_IP_PAYLOAD) -#define UIP_ICMP_PAYLOAD ((unsigned char *)&uip_buf[uip_l2_l3_icmp_hdr_len]) -#define UIP_UDP_BUF ((struct uip_udp_hdr *)UIP_IP_PAYLOAD) -#define UIP_TCP_BUF ((struct uip_tcp_hdr *)UIP_IP_PAYLOAD) +#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)UIP_IP_PAYLOAD(uip_ext_len)) +#define UIP_ICMP_PAYLOAD ((unsigned char *)UIP_IP_PAYLOAD(uip_ext_len) + UIP_ICMPH_LEN) +#define UIP_UDP_BUF ((struct uip_udp_hdr *)UIP_IP_PAYLOAD(uip_ext_len)) +#define UIP_UDP_PAYLOAD ((unsigned char *)UIP_IP_PAYLOAD(uip_ext_len) + UIP_UDPH_LEN) +#define UIP_TCP_BUF ((struct uip_tcp_hdr *)UIP_IP_PAYLOAD(uip_ext_len)) +#define UIP_TCP_PAYLOAD ((unsigned char *)UIP_IP_PAYLOAD(uip_ext_len) + UIP_TCPH_LEN) #include "net/ipv6/uipopt.h" #include "net/ipv6/uipbuf.h"