Cleanup: Create new file ip.c and move dual-stack code from ipv4 and ipv6 folder in there

This commit is contained in:
Dirk Ziegelmeier
2016-02-26 23:04:51 +01:00
parent 2dc8f59bf4
commit 70f3e5ed05
6 changed files with 114 additions and 79 deletions

View File

@@ -59,11 +59,6 @@
#include "lwip/debug.h"
#include "lwip/stats.h"
#if !LWIP_IPV4
/** Global data for IPv6 only */
struct ip_globals ip_data;
#endif /* !LWIP_IPV4 */
/**
* Finds the appropriate network interface for a given IPv6 address. It tries to select
* a netif following a sequence of heuristics:
@@ -374,18 +369,6 @@ 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
* an IPv6 packet is received. The function does the basic checks of the

View File

@@ -289,39 +289,4 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
return buf;
}
#if LWIP_IPV4
/** Convert IP address string (both versions) to numeric.
* The version is auto-detected from the string.
*
* @param cp IP address string to convert
* @param addr conversion result is stored here
* @return 1 on success, 0 on error
*/
int
ipaddr_aton(const char *cp, ip_addr_t *addr)
{
if (cp != NULL) {
const char* c;
for (c = cp; *c != 0; c++) {
if (*c == ':') {
/* contains a colon: IPv6 address */
if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V6);
}
return ip6addr_aton(cp, ip_2_ip6(addr));
} else if (*c == '.') {
/* contains a dot: IPv4 address */
break;
}
}
/* call ip4addr_aton as fallback or if IPv4 was found */
if (addr) {
IP_SET_TYPE_VAL(*addr, IPADDR_TYPE_V4);
}
return ip4addr_aton(cp, ip_2_ip4(addr));
}
return 0;
}
#endif /* LWIP_IPV4 */
#endif /* LWIP_IPV6 */