netif: initialize netif->output with a dummy function for IPv6 only netifs

This commit is contained in:
goldsimon 2018-03-13 20:29:37 +01:00
parent 0074022bb5
commit 08bcfa2b29
3 changed files with 18 additions and 23 deletions

View File

@ -125,6 +125,9 @@ static void netif_issue_reports(struct netif *netif, u8_t report_type);
#if LWIP_IPV6
static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipaddr);
#endif /* LWIP_IPV6 */
#if LWIP_IPV4
static err_t netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr);
#endif /* LWIP_IPV4 */
#if LWIP_HAVE_LOOPIF
#if LWIP_IPV4
@ -300,6 +303,7 @@ netif_add(struct netif *netif,
ip_addr_set_zero_ip4(&netif->ip_addr);
ip_addr_set_zero_ip4(&netif->netmask);
ip_addr_set_zero_ip4(&netif->gw);
netif->output = netif_null_output_ip4;
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
@ -1578,6 +1582,20 @@ netif_null_output_ip6(struct netif *netif, struct pbuf *p, const ip6_addr_t *ipa
}
#endif /* LWIP_IPV6 */
#if LWIP_IPV4
/** Dummy IPv4 output function for netifs not supporting IPv4
*/
static err_t
netif_null_output_ip4(struct netif *netif, struct pbuf *p, const ip4_addr_t *ipaddr)
{
LWIP_UNUSED_ARG(netif);
LWIP_UNUSED_ARG(p);
LWIP_UNUSED_ARG(ipaddr);
return ERR_IF;
}
#endif /* LWIP_IPV4 */
/**
* @ingroup netif
* Return the interface index for the netif with name

View File

@ -778,22 +778,6 @@ lowpan6_set_short_addr(u8_t addr_high, u8_t addr_low)
}
#endif /* LWIP_6LOWPAN_INFER_SHORT_ADDRESS */
#if LWIP_IPV4
/**
* @ingroup sixlowpan
* IPv4 output
*/
err_t
lowpan4_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
{
(void)netif;
(void)q;
(void)ipaddr;
return ERR_IF;
}
#endif /* LWIP_IPV4 */
/* Create IEEE 802.15.4 address from netif address */
static err_t
lowpan6_hwaddr_to_addr(struct netif *netif, struct ieee_802154_addr *addr)
@ -1500,9 +1484,6 @@ lowpan6_if_init(struct netif *netif)
{
netif->name[0] = 'L';
netif->name[1] = '6';
#if LWIP_IPV4
netif->output = lowpan4_output;
#endif /* LWIP_IPV4 */
netif->output_ip6 = lowpan6_output;
MIB2_INIT_NETIF(netif, snmp_ifType_other, 0);

View File

@ -960,10 +960,6 @@ rfc7668_if_init(struct netif *netif)
{
netif->name[0] = 'b';
netif->name[1] = 't';
/* if compiled with LWIP_IPV4 -> set IPv4 output to NULL */
#if LWIP_IPV4
netif->output = NULL;
#endif
/* local function as IPv6 output */
netif->output_ip6 = rfc7668_output;