mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-12 13:13:21 +00:00
Minor: Avoid ip_input() call indirection for when only IPv4 or IPv6 are enabled
This commit is contained in:
parent
4bbfc3857a
commit
8e5663a32f
@ -43,7 +43,11 @@
|
|||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
#include "lwip/ip.h"
|
#include "lwip/ip.h"
|
||||||
|
|
||||||
|
/** Global data for both IPv4 and IPv6 */
|
||||||
|
struct ip_globals ip_data;
|
||||||
|
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
#if LWIP_IPV4 && LWIP_IPV6
|
||||||
|
|
||||||
const ip_addr_t ip_addr_any_type = IPADDR_ANY_TYPE_INIT;
|
const ip_addr_t ip_addr_any_type = IPADDR_ANY_TYPE_INIT;
|
||||||
|
|
||||||
/** Convert IP address string (both versions) to numeric.
|
/** Convert IP address string (both versions) to numeric.
|
||||||
@ -79,19 +83,10 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
/* If both IP versions are enabled, this function can dispatch packets to the correct one. */
|
||||||
|
|
||||||
/** Global data for both IPv4 and IPv6 */
|
|
||||||
struct ip_globals ip_data;
|
|
||||||
|
|
||||||
/* If both IP versions are enabled, this function can dispatch packets to the correct one.
|
|
||||||
* If only IPv4 is enabled, this directly maps at ip4_input.
|
|
||||||
* May be used as netif input function.
|
|
||||||
*/
|
|
||||||
err_t
|
err_t
|
||||||
ip_input(struct pbuf *p, struct netif *inp)
|
ip_input(struct pbuf *p, struct netif *inp)
|
||||||
{
|
{
|
||||||
#if LWIP_IPV4 && LWIP_IPV6
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
if (IP_HDR_GET_VERSION(p->payload) == 6) {
|
if (IP_HDR_GET_VERSION(p->payload) == 6) {
|
||||||
return ip6_input(p, inp);
|
return ip6_input(p, inp);
|
||||||
@ -99,15 +94,8 @@ ip_input(struct pbuf *p, struct netif *inp)
|
|||||||
return ip4_input(p, inp);
|
return ip4_input(p, inp);
|
||||||
}
|
}
|
||||||
return ERR_VAL;
|
return ERR_VAL;
|
||||||
#else /* LWIP_IPV4 && LWIP_IPV6 */
|
|
||||||
|
|
||||||
#if LWIP_IPV4
|
|
||||||
return ip4_input(p, inp);
|
|
||||||
#else /* LWIP_IPV4 */
|
|
||||||
return ip6_input(p, inp);
|
|
||||||
#endif /* LWIP_IPV4 */
|
|
||||||
|
|
||||||
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
#endif /* LWIP_IPV4 || LWIP_IPV6 */
|
#endif /* LWIP_IPV4 || LWIP_IPV6 */
|
||||||
|
@ -249,7 +249,11 @@ extern struct ip_globals ip_data;
|
|||||||
ip6_netif_get_local_ip(netif, ip_2_ip6(dest)) : \
|
ip6_netif_get_local_ip(netif, ip_2_ip6(dest)) : \
|
||||||
ip4_netif_get_local_ip(netif))
|
ip4_netif_get_local_ip(netif))
|
||||||
#define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p))
|
#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 */
|
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
#define ip_output(p, src, dest, ttl, tos, proto) \
|
#define ip_output(p, src, dest, ttl, tos, proto) \
|
||||||
ip4_output(p, src, dest, ttl, tos, proto)
|
ip4_output(p, src, dest, ttl, tos, proto)
|
||||||
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
||||||
@ -263,7 +267,11 @@ extern struct ip_globals ip_data;
|
|||||||
#define ip_netif_get_local_ip(netif, dest) \
|
#define ip_netif_get_local_ip(netif, dest) \
|
||||||
ip4_netif_get_local_ip(netif)
|
ip4_netif_get_local_ip(netif)
|
||||||
#define ip_debug_print(is_ipv6, p) ip4_debug_print(p)
|
#define ip_debug_print(is_ipv6, p) ip4_debug_print(p)
|
||||||
|
|
||||||
|
#define ip_input ip4_input
|
||||||
|
|
||||||
#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */
|
#elif LWIP_IPV6 /* LWIP_IPV4 && LWIP_IPV6 */
|
||||||
|
|
||||||
#define ip_output(p, src, dest, ttl, tos, proto) \
|
#define ip_output(p, src, dest, ttl, tos, proto) \
|
||||||
ip6_output(p, src, dest, ttl, tos, proto)
|
ip6_output(p, src, dest, ttl, tos, proto)
|
||||||
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
#define ip_output_if(p, src, dest, ttl, tos, proto, netif) \
|
||||||
@ -277,6 +285,9 @@ extern struct ip_globals ip_data;
|
|||||||
#define ip_netif_get_local_ip(netif, dest) \
|
#define ip_netif_get_local_ip(netif, dest) \
|
||||||
ip6_netif_get_local_ip(netif, dest)
|
ip6_netif_get_local_ip(netif, dest)
|
||||||
#define ip_debug_print(is_ipv6, p) ip6_debug_print(p)
|
#define ip_debug_print(is_ipv6, p) ip6_debug_print(p)
|
||||||
|
|
||||||
|
#define ip_input ip6_input
|
||||||
|
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 */
|
||||||
|
|
||||||
#define ip_route_get_local_ip(src, dest, netif, ipaddr) do { \
|
#define ip_route_get_local_ip(src, dest, netif, ipaddr) do { \
|
||||||
@ -284,8 +295,6 @@ extern struct ip_globals ip_data;
|
|||||||
(ipaddr) = ip_netif_get_local_ip(netif, dest); \
|
(ipaddr) = ip_netif_get_local_ip(netif, dest); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
err_t ip_input(struct pbuf *p, struct netif *inp);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user