From 68a1ec2eb187eb57d2777d0f830569a2330c0e29 Mon Sep 17 00:00:00 2001 From: sg Date: Wed, 16 Sep 2015 22:09:54 +0200 Subject: [PATCH] Fixed passing ip_input() to netif_add() for single-IP-version NO_SYS configurations --- src/core/ipv4/ip4.c | 11 +++++++---- src/core/ipv6/ip6.c | 11 +++++++++++ src/include/lwip/ip.h | 5 ++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 8778cca9..714cb9ef 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -349,13 +349,14 @@ return_noroute: } #endif /* IP_FORWARD */ -#if LWIP_IPV6 /* If both IP versions are enabled, this function can dispatch packets to the correct one. -* May be used as netif input function. -*/ + * If only IPv4 is enabled, this directly maps at ip4_input. + * May be used as netif input function. + */ err_t ip_input(struct pbuf *p, struct netif *inp) { +#if LWIP_IPV6 if (p != NULL) { if (IP_HDR_GET_VERSION(p->payload) == 6) { return ip6_input(p, inp); @@ -363,8 +364,10 @@ ip_input(struct pbuf *p, struct netif *inp) return ip4_input(p, inp); } return ERR_VAL; +#else /* LWIP_IPV6 */ + return ip4_input(p, inp); +#endif /* LWIP_IPV6 */ } -#endif /** * This function is called by the network interface device driver when diff --git a/src/core/ipv6/ip6.c b/src/core/ipv6/ip6.c index 577745ff..eca72cde 100644 --- a/src/core/ipv6/ip6.c +++ b/src/core/ipv6/ip6.c @@ -375,6 +375,17 @@ ip6_forward(struct pbuf *p, struct ip6_hdr *iphdr, struct netif *inp) } #endif /* LWIP_IPV6_FORWARD */ +#if !LWIP_IPV4 +/* If both IP versions are enabled, this function can dispatch packets to the correct one. + * If only IPv6 is enabled, this directly maps at ip6_input. + * May be used as netif input function. + */ +err_t +ip_input(struct pbuf *p, struct netif *inp) +{ + return ip6_input(p, inp); +} +#endif /* !LWIP_IPV4 */ /** * This function is called by the network interface device driver when diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h index f43b5ec9..2e454ff0 100644 --- a/src/include/lwip/ip.h +++ b/src/include/lwip/ip.h @@ -267,7 +267,6 @@ extern struct ip_globals ip_data; ip6_2_ip(ip6_netif_get_local_ip(netif, ip_2_ip6(dest)), storage) : \ ip4_2_ip(ip4_netif_get_local_ip(netif), storage)) #define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p)) -err_t ip_input(struct pbuf *p, struct netif *inp); #elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */ #define ip_output(isipv6, p, src, dest, ttl, tos, proto) \ ip4_output(p, src, dest, ttl, tos, proto) @@ -282,7 +281,6 @@ err_t ip_input(struct pbuf *p, struct netif *inp); #define ip_netif_get_local_ip(isipv6, netif, dest, storage) \ ip4_netif_get_local_ip(netif) #define ip_debug_print(is_ipv6, p) ip4_debug_print(p) -#define ip_input(p, inp) ip4_input(p, inp) #elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */ #define ip_output(isipv6, p, src, dest, ttl, tos, proto) \ ip6_output(p, src, dest, ttl, tos, proto) @@ -297,7 +295,6 @@ err_t ip_input(struct pbuf *p, struct netif *inp); #define ip_netif_get_local_ip(isipv6, netif, dest, storage) \ ip6_netif_get_local_ip(netif, dest) #define ip_debug_print(is_ipv6, p) ip6_debug_print(p) -#define ip_input(p, inp) ip6_input(p, inp) #endif /* LWIP_IPV6 */ #define ip_route_get_local_ip(isipv6, src, dest, netif, ipaddr, storage) do { \ @@ -305,6 +302,8 @@ err_t ip_input(struct pbuf *p, struct netif *inp); (ipaddr) = ip_netif_get_local_ip(isipv6, netif, dest, storage); \ }while(0) +err_t ip_input(struct pbuf *p, struct netif *inp); + #ifdef __cplusplus } #endif