worked on task #13480: added LWIP_IPV4 define - IPv4 can be disabled, leaving an IPv6-only stack (SNMP is still missing)

This commit is contained in:
sg
2015-04-12 10:43:46 +02:00
parent 89d666155d
commit c1c65777b6
11 changed files with 98 additions and 58 deletions

View File

@@ -48,6 +48,6 @@
/** This variable is initialized by the system to contain the wildcard IPv6 address.
*/
const struct ip6_addr in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
#endif /* LWIP_IPV6 */

View File

@@ -94,7 +94,9 @@ static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip
#endif /* LWIP_IPV6 */
#if LWIP_HAVE_LOOPIF
#if LWIP_IPV4
static err_t netif_loop_output_ipv4(struct netif *netif, struct pbuf *p, const ip4_addr_t* addr);
#endif
#if LWIP_IPV6
static err_t netif_loop_output_ipv6(struct netif *netif, struct pbuf *p, const ip6_addr_t* addr);
#endif
@@ -119,7 +121,9 @@ netif_loopif_init(struct netif *netif)
netif->name[0] = 'l';
netif->name[1] = 'o';
#if LWIP_IPV4
netif->output = netif_loop_output_ipv4;
#endif
#if LWIP_IPV6
netif->output_ip6 = netif_loop_output_ipv6;
#endif
@@ -131,15 +135,20 @@ void
netif_init(void)
{
#if LWIP_HAVE_LOOPIF
#if LWIP_IPV4
#define LOOPIF_ADDRINIT &loop_ipaddr, &loop_netmask, &loop_gw,
ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
IP4_ADDR(&loop_gw, 127,0,0,1);
IP4_ADDR(&loop_ipaddr, 127,0,0,1);
IP4_ADDR(&loop_netmask, 255,0,0,0);
#else /* LWIP_IPV4 */
#define LOOPIF_ADDRINIT
#endif /* LWIP_IPV4 */
#if NO_SYS
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, ip_input);
netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, ip_input);
#else /* NO_SYS */
netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input);
netif_add(&loop_netif, LOOPIF_ADDRINIT NULL, netif_loopif_init, tcpip_input);
#endif /* NO_SYS */
#if LWIP_IPV6
@@ -173,8 +182,6 @@ struct netif *
netif_add(struct netif *netif,
#if LWIP_IPV4
const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
#else /* LWIP_IPV4 */
const void *ipaddr, const void *netmask, const void *gw,
#endif /* LWIP_IPV4 */
void *state, netif_init_fn init, netif_input_fn input)
{

View File

@@ -238,17 +238,21 @@ udp_input(struct pbuf *p, struct netif *inp)
if (pcb->local_port == dest) {
if (
#if LWIP_IPV6
((PCB_ISIPV6(pcb) && (ip_current_is_v6()) &&
(PCB_ISIPV6(pcb) && (ip_current_is_v6()) &&
(ip6_addr_isany(ip_2_ip6(&pcb->local_ip)) ||
#if LWIP_IPV6_MLD
ip6_addr_ismulticast(ip6_current_dest_addr()) ||
#endif /* LWIP_IPV6_MLD */
ip6_addr_cmp(ip_2_ip6(&pcb->local_ip), ip6_current_dest_addr()))) ||
(!PCB_ISIPV6(pcb) &&
(ip4_current_header() != NULL) &&
#else /* LWIP_IPV6 */
((
ip6_addr_cmp(ip_2_ip6(&pcb->local_ip), ip6_current_dest_addr())))
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
|| (!PCB_ISIPV6(pcb) &&
(ip4_current_header() != NULL) &&
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
#if !LWIP_IPV6
(
#endif /* !LWIP_IPV6 */
((!broadcast && ip_addr_isany(&pcb->local_ip)) ||
ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr()) ||
#if LWIP_IGMP
@@ -257,12 +261,14 @@ udp_input(struct pbuf *p, struct netif *inp)
#if IP_SOF_BROADCAST_RECV
(broadcast && ip_get_option(pcb, SOF_BROADCAST) &&
(ip_addr_isany(&pcb->local_ip) ||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))))))) {
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))))
#else /* IP_SOF_BROADCAST_RECV */
(broadcast &&
(ip_addr_isany(&pcb->local_ip) ||
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask))))))) {
#endif /* IP_SOF_BROADCAST_RECV */
ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))))
#endif /* IP_SOF_BROADCAST_RECV */
#endif /* LWIP_IPV4 */
) {
local_match = 1;
if ((uncon_pcb == NULL) &&
((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) {