fixed const warning for !IPV6_FRAG_COPYHEADER

This commit is contained in:
sg 2015-09-17 21:59:54 +02:00
parent 2f3dcf7a16
commit 39e32ea7c1
2 changed files with 14 additions and 12 deletions

View File

@ -336,7 +336,8 @@ ip6_reass(struct pbuf *p)
#if IPV6_FRAG_COPYHEADER #if IPV6_FRAG_COPYHEADER
MEMCPY(&ipr->iphdr, ip6_current_header(), IP6_HLEN); MEMCPY(&ipr->iphdr, ip6_current_header(), IP6_HLEN);
#else /* IPV6_FRAG_COPYHEADER */ #else /* IPV6_FRAG_COPYHEADER */
ipr->iphdr = (struct ip6_hdr *)ip6_current_header(); /* need to use the none-const pointer here: */
ipr->iphdr = ip_data.current_ip6_header;
#endif /* IPV6_FRAG_COPYHEADER */ #endif /* IPV6_FRAG_COPYHEADER */
/* copy the fragmented packet id. */ /* copy the fragmented packet id. */
@ -475,7 +476,8 @@ ip6_reass(struct pbuf *p)
MEMCPY(&ipr->iphdr, ip6_current_header(), IP6_HLEN); MEMCPY(&ipr->iphdr, ip6_current_header(), IP6_HLEN);
} }
#else /* IPV6_FRAG_COPYHEADER */ #else /* IPV6_FRAG_COPYHEADER */
ipr->iphdr = (struct ip6_hdr *)ip6_current_header(); /* need to use the none-const pointer here: */
ipr->iphdr = ip_data.current_ip6_header;
#endif /* IPV6_FRAG_COPYHEADER */ #endif /* IPV6_FRAG_COPYHEADER */
} }

View File

@ -131,11 +131,11 @@ struct ip_globals
struct netif *current_input_netif; struct netif *current_input_netif;
#if LWIP_IPV4 #if LWIP_IPV4
/** Header of the input packet currently being processed. */ /** Header of the input packet currently being processed. */
const struct ip_hdr *current_ip4_header; struct ip_hdr *current_ip4_header;
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */
#if LWIP_IPV6 #if LWIP_IPV6
/** Header of the input IPv6 packet currently being processed. */ /** Header of the input IPv6 packet currently being processed. */
const struct ip6_hdr *current_ip6_header; struct ip6_hdr *current_ip6_header;
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
/** Total header length of current_ip4/6_header (i.e. after this, the UDP/TCP header starts) */ /** Total header length of current_ip4/6_header (i.e. after this, the UDP/TCP header starts) */
u16_t current_ip_header_tot_len; u16_t current_ip_header_tot_len;
@ -167,11 +167,11 @@ extern struct ip_globals ip_data;
/** Get the IPv4 header of the current packet. /** Get the IPv4 header of the current packet.
* This function must only be called from a receive callback (udp_recv, * This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */ * raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip4_current_header() (ip_data.current_ip4_header) #define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header))
/** Get the IPv6 header of the current packet. /** Get the IPv6 header of the current packet.
* This function must only be called from a receive callback (udp_recv, * This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */ * raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip6_current_header() (ip_data.current_ip6_header) #define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header))
/** Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4 */ /** Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4 */
#define ip_current_is_v6() (ip6_current_header() != NULL) #define ip_current_is_v6() (ip6_current_header() != NULL)
/** Source IPv6 address of current_header */ /** Source IPv6 address of current_header */
@ -183,8 +183,8 @@ extern struct ip_globals ip_data;
IP6H_NEXTH(ip6_current_header()) :\ IP6H_NEXTH(ip6_current_header()) :\
IPH_PROTO(ip4_current_header())) IPH_PROTO(ip4_current_header()))
/** Get the transport layer header */ /** Get the transport layer header */
#define ip_next_header_ptr() ((void*)((ip_current_is_v6() ? \ #define ip_next_header_ptr() ((const void*)((ip_current_is_v6() ? \
(u8_t*)ip6_current_header() : (u8_t*)ip4_current_header()) + ip_current_header_tot_len())) (const u8_t*)ip6_current_header() : (const u8_t*)ip4_current_header()) + ip_current_header_tot_len()))
/** Set an IP_PCB to IPv6 (IPv4 is the default) */ /** Set an IP_PCB to IPv6 (IPv4 is the default) */
#define ip_set_v6(pcb, val) do{if(pcb != NULL) { pcb->isipv6 = val; }}while(0) #define ip_set_v6(pcb, val) do{if(pcb != NULL) { pcb->isipv6 = val; }}while(0)
@ -199,13 +199,13 @@ extern struct ip_globals ip_data;
/** Get the IPv4 header of the current packet. /** Get the IPv4 header of the current packet.
* This function must only be called from a receive callback (udp_recv, * This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */ * raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip4_current_header() (ip_data.current_ip4_header) #define ip4_current_header() ((const struct ip_hdr*)(ip_data.current_ip4_header))
/** Always returns FALSE when only supporting IPv4 only */ /** Always returns FALSE when only supporting IPv4 only */
#define ip_current_is_v6() 0 #define ip_current_is_v6() 0
/** Get the transport layer protocol */ /** Get the transport layer protocol */
#define ip_current_header_proto() IPH_PROTO(ip4_current_header()) #define ip_current_header_proto() IPH_PROTO(ip4_current_header())
/** Get the transport layer header */ /** Get the transport layer header */
#define ip_next_header_ptr() ((void*)((u8_t*)ip4_current_header() + ip_current_header_tot_len())) #define ip_next_header_ptr() ((const void*)((const u8_t*)ip4_current_header() + ip_current_header_tot_len()))
/** Source IP4 address of current_header */ /** Source IP4 address of current_header */
#define ip4_current_src_addr() (&ip_data.current_iphdr_src) #define ip4_current_src_addr() (&ip_data.current_iphdr_src)
/** Destination IP4 address of current_header */ /** Destination IP4 address of current_header */
@ -216,13 +216,13 @@ extern struct ip_globals ip_data;
/** Get the IPv6 header of the current packet. /** Get the IPv6 header of the current packet.
* This function must only be called from a receive callback (udp_recv, * This function must only be called from a receive callback (udp_recv,
* raw_recv, tcp_accept). It will return NULL otherwise. */ * raw_recv, tcp_accept). It will return NULL otherwise. */
#define ip6_current_header() (ip_data.current_ip6_header) #define ip6_current_header() ((const struct ip6_hdr*)(ip_data.current_ip6_header))
/** Always returns TRUE when only supporting IPv6 only */ /** Always returns TRUE when only supporting IPv6 only */
#define ip_current_is_v6() 1 #define ip_current_is_v6() 1
/** Get the transport layer protocol */ /** Get the transport layer protocol */
#define ip_current_header_proto() IP6H_NEXTH(ip6_current_header()) #define ip_current_header_proto() IP6H_NEXTH(ip6_current_header())
/** Get the transport layer header */ /** Get the transport layer header */
#define ip_next_header_ptr() ((void*)((u8_t*)ip6_current_header())) #define ip_next_header_ptr() ((const void*)((const u8_t*)ip6_current_header()))
/** Source IP6 address of current_header */ /** Source IP6 address of current_header */
#define ip6_current_src_addr() (&ip_data.current_iphdr_src) #define ip6_current_src_addr() (&ip_data.current_iphdr_src)
/** Destination IP6 address of current_header */ /** Destination IP6 address of current_header */