Skip to content

Commit f4e76bb

Browse files
author
Mika Leppänen
committed
Updated NUC472 mac for lwip 2.0 and IPv6
1 parent 2bad43d commit f4e76bb

File tree

1 file changed

+24
-29
lines changed
  • features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472

1 file changed

+24
-29
lines changed

features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_NUVOTON/TARGET_NUC472/nuc472_netif.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
#include <lwip/stats.h>
5353
#include <lwip/snmp.h>
5454
#include "netif/etharp.h"
55-
#include "netif/ppp_oe.h"
55+
#include "lwip/ethip6.h"
56+
#include "netif/ppp/pppoe.h"
5657
#include "nuc472_eth.h"
5758
#include "string.h"
5859

@@ -129,7 +130,6 @@ void mbed_mac_address(char *mac)
129130

130131
}
131132

132-
133133
/**
134134
* In this function, the hardware should be initialized.
135135
* Called from ethernetif_init().
@@ -142,7 +142,7 @@ low_level_init(struct netif *netif)
142142
{
143143

144144
/* set MAC hardware address length */
145-
netif->hwaddr_len = ETHARP_HWADDR_LEN;
145+
netif->hwaddr_len = ETH_HWADDR_LEN;
146146

147147
/* set MAC hardware address */
148148
#if 1 // set MAC HW address
@@ -174,9 +174,20 @@ low_level_init(struct netif *netif)
174174
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
175175
#ifdef LWIP_IGMP
176176
netif->flags |= NETIF_FLAG_IGMP;
177+
#endif
178+
#if LWIP_IPV6_MLD
179+
netif->flags |= NETIF_FLAG_MLD6;
177180
#endif
178181
// TODO: enable clock & configure GPIO function
179182
ETH_init(netif->hwaddr);
183+
184+
#if LWIP_IGMP
185+
EMAC_ENABLE_RECV_BCASTPKT();
186+
#endif
187+
188+
#if LWIP_IPV6_MLD
189+
EMAC_ENABLE_RECV_MCASTPKT();
190+
#endif
180191
}
181192

182193
/**
@@ -335,32 +346,11 @@ ethernetif_input(u16_t len, u8_t *buf, u32_t s, u32_t ns)
335346
void
336347
ethernetif_loopback_input(struct pbuf *p) // TODO: make sure packet not drop in input()
337348
{
338-
struct eth_hdr *ethhdr;
339-
340-
/* points to packet payload, which starts with an Ethernet header */
341-
ethhdr = p->payload;
342-
343-
switch (htons(ethhdr->type)) {
344-
/* IP or ARP packet? */
345-
case ETHTYPE_IP:
346-
case ETHTYPE_ARP:
347-
#if PPPOE_SUPPORT
348-
/* PPPoE packet? */
349-
case ETHTYPE_PPPOEDISC:
350-
case ETHTYPE_PPPOE:
351-
#endif /* PPPOE_SUPPORT */
352-
/* full packet send to tcpip_thread to process */
353-
if (_netif->input(p, _netif)!=ERR_OK) {
354-
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
355-
pbuf_free(p);
356-
p = NULL;
357-
}
358-
break;
359-
360-
default:
349+
/* pass all packets to ethernet_input, which decides what packets it supports */
350+
if (netif->input(p, netif) != ERR_OK) {
351+
LWIP_DEBUGF(NETIF_DEBUG, ("k64f_enetif_input: input error\n"));
352+
/* Free buffer */
361353
pbuf_free(p);
362-
p = NULL;
363-
break;
364354
}
365355
}
366356

@@ -415,7 +405,12 @@ err_t
415405
* You can instead declare your own function an call etharp_output()
416406
* from it if you have to do some checks before sending (e.g. if link
417407
* is available...) */
408+
#if LWIP_IPV4
418409
netif->output = etharp_output;
410+
#endif
411+
#if LWIP_IPV6
412+
netif->output_ip6 = ethip6_output;
413+
#endif
419414
netif->linkoutput = low_level_output;
420415

421416
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
@@ -523,4 +518,4 @@ static void __packet_rx_task(void *data) {
523518
sys_arch_sem_wait(&RxReadySem, 0);
524519
EMAC_RX_Action();
525520
}
526-
}
521+
}

0 commit comments

Comments
 (0)