From 8bab5435313d248fd9ac05b41189c3d82bed8588 Mon Sep 17 00:00:00 2001 From: Ivan Delamer Date: Fri, 17 Aug 2012 10:56:14 -0600 Subject: [PATCH] Add a "NULL" output function for ipv6 by default, to avoid NULL dereferencing in case of non-IPv6-enabled netifs (e.g. PPP). Change-Id: I45f08ca89bfa0b8d61962f7052b11cc81a5e3cd1 --- src/core/netif.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/netif.c b/src/core/netif.c index 90bbff48..7a8968a2 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -84,6 +84,10 @@ struct netif *netif_default; static u8_t netif_num; +#if LWIP_IPV6 +static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr); +#endif /* LWIP_IPV6 */ + #if LWIP_HAVE_LOOPIF static struct netif loop_netif; @@ -161,6 +165,7 @@ netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip6_addr_set_zero(&netif->ip6_addr[i]); netif_ip6_addr_set_state(netif, i, IP6_ADDR_INVALID); } + netif->output_ip6 = netif_null_output_ip6; #endif /* LWIP_IPV6 */ netif->flags = 0; #if LWIP_DHCP @@ -878,4 +883,14 @@ netif_create_ip6_linklocal_address(struct netif * netif, u8_t from_mac_48bit) netif->ip6_addr_state[0] = IP6_ADDR_PREFERRED; #endif /* LWIP_IPV6_AUTOCONFIG */ } + +static err_t +netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) +{ + (void)netif; + (void)pbuf; + (void)ipaddr; + + return ERR_IF; +} #endif /* LWIP_IPV6 */