52
52
#include <lwip/stats.h>
53
53
#include <lwip/snmp.h>
54
54
#include "netif/etharp.h"
55
- #include "netif/ppp_oe.h"
55
+ #include "lwip/ethip6.h"
56
+ #include "netif/ppp/pppoe.h"
56
57
#include "nuc472_eth.h"
57
58
#include "string.h"
58
59
@@ -129,7 +130,6 @@ void mbed_mac_address(char *mac)
129
130
130
131
}
131
132
132
-
133
133
/**
134
134
* In this function, the hardware should be initialized.
135
135
* Called from ethernetif_init().
@@ -142,7 +142,7 @@ low_level_init(struct netif *netif)
142
142
{
143
143
144
144
/* set MAC hardware address length */
145
- netif -> hwaddr_len = ETHARP_HWADDR_LEN ;
145
+ netif -> hwaddr_len = ETH_HWADDR_LEN ;
146
146
147
147
/* set MAC hardware address */
148
148
#if 1 // set MAC HW address
@@ -174,9 +174,20 @@ low_level_init(struct netif *netif)
174
174
netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET ;
175
175
#ifdef LWIP_IGMP
176
176
netif -> flags |= NETIF_FLAG_IGMP ;
177
+ #endif
178
+ #if LWIP_IPV6_MLD
179
+ netif -> flags |= NETIF_FLAG_MLD6 ;
177
180
#endif
178
181
// TODO: enable clock & configure GPIO function
179
182
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
180
191
}
181
192
182
193
/**
@@ -335,32 +346,11 @@ ethernetif_input(u16_t len, u8_t *buf, u32_t s, u32_t ns)
335
346
void
336
347
ethernetif_loopback_input (struct pbuf * p ) // TODO: make sure packet not drop in input()
337
348
{
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 */
361
353
pbuf_free (p );
362
- p = NULL ;
363
- break ;
364
354
}
365
355
}
366
356
@@ -415,7 +405,12 @@ err_t
415
405
* You can instead declare your own function an call etharp_output()
416
406
* from it if you have to do some checks before sending (e.g. if link
417
407
* is available...) */
408
+ #if LWIP_IPV4
418
409
netif -> output = etharp_output ;
410
+ #endif
411
+ #if LWIP_IPV6
412
+ netif -> output_ip6 = ethip6_output ;
413
+ #endif
419
414
netif -> linkoutput = low_level_output ;
420
415
421
416
ethernetif -> ethaddr = (struct eth_addr * )& (netif -> hwaddr [0 ]);
@@ -523,4 +518,4 @@ static void __packet_rx_task(void *data) {
523
518
sys_arch_sem_wait (& RxReadySem , 0 );
524
519
EMAC_RX_Action ();
525
520
}
526
- }
521
+ }
0 commit comments