1
1
#include "lwip/opt.h"
2
2
3
- #include "lwip/timers.h"
4
3
#include "netif/etharp.h"
5
4
#include "lwip/tcpip.h"
5
+ #include "lwip/ethip6.h"
6
6
#include <string.h>
7
7
#include "cmsis_os.h"
8
8
#include "mbed_interface.h"
@@ -40,7 +40,14 @@ static sys_mutex_t tx_lock_mutex;
40
40
/* function */
41
41
static void _eth_arch_rx_task (void * arg );
42
42
static void _eth_arch_phy_task (void * arg );
43
- static err_t _eth_arch_netif_output (struct netif * netif , struct pbuf * q , ip_addr_t * ipaddr );
43
+
44
+ #if LWIP_IPV4
45
+ static err_t _eth_arch_netif_output_ipv4 (struct netif * netif , struct pbuf * q , const ip4_addr_t * ipaddr );
46
+ #endif
47
+ #if LWIP_IPV6
48
+ static err_t _eth_arch_netif_output_ipv6 (struct netif * netif , struct pbuf * q , const ip6_addr_t * ipaddr );
49
+ #endif
50
+
44
51
static err_t _eth_arch_low_level_output (struct netif * netif , struct pbuf * p );
45
52
static struct pbuf * _eth_arch_low_level_input (struct netif * netif );
46
53
@@ -112,7 +119,7 @@ static void _eth_arch_low_level_init(struct netif *netif)
112
119
113
120
#if LWIP_ARP || LWIP_ETHERNET
114
121
/* set MAC hardware address length */
115
- netif -> hwaddr_len = ETHARP_HWADDR_LEN ;
122
+ netif -> hwaddr_len = ETH_HWADDR_LEN ;
116
123
117
124
/* set MAC hardware address */
118
125
netif -> hwaddr [0 ] = EthHandle .Init .MACAddr [0 ];
@@ -356,22 +363,44 @@ static void _eth_arch_phy_task(void *arg)
356
363
}
357
364
358
365
/**
359
- * This function is the ethernet packet send function. It calls
366
+ * This function is the ethernet IPv4 packet send function. It calls
360
367
* etharp_output after checking link status.
361
368
*
362
369
* \param[in] netif the lwip network interface structure for this lpc_enetif
363
370
* \param[in] q Pointer to pbug to send
364
371
* \param[in] ipaddr IP address
365
372
* \return ERR_OK or error code
366
373
*/
367
- static err_t _eth_arch_netif_output (struct netif * netif , struct pbuf * q , ip_addr_t * ipaddr )
374
+ #if LWIP_IPV4
375
+ static err_t _eth_arch_netif_output_ipv4 (struct netif * netif , struct pbuf * q , const ip4_addr_t * ipaddr )
368
376
{
369
377
/* Only send packet is link is up */
370
378
if (netif -> flags & NETIF_FLAG_LINK_UP ) {
371
379
return etharp_output (netif , q , ipaddr );
372
380
}
373
381
return ERR_CONN ;
374
382
}
383
+ #endif
384
+
385
+ /**
386
+ * This function is the ethernet packet send function. It calls
387
+ * etharp_output after checking link status.
388
+ *
389
+ * \param[in] netif the lwip network IPv6 interface structure for this lpc_enetif
390
+ * \param[in] q Pointer to pbug to send
391
+ * \param[in] ipaddr IP address
392
+ * \return ERR_OK or error code
393
+ */
394
+ #if LWIP_IPV6
395
+ static err_t _eth_arch_netif_output_ipv6 (struct netif * netif , struct pbuf * q , const ip6_addr_t * ipaddr )
396
+ {
397
+ /* Only send packet is link is up */
398
+ if (netif -> flags & NETIF_FLAG_LINK_UP ) {
399
+ return ethip6_output (netif , q , ipaddr );
400
+ }
401
+ return ERR_CONN ;
402
+ }
403
+ #endif
375
404
376
405
/**
377
406
* Should be called at the beginning of the program to set up the
@@ -387,13 +416,13 @@ static err_t _eth_arch_netif_output(struct netif *netif, struct pbuf *q, ip_addr
387
416
err_t eth_arch_enetif_init (struct netif * netif )
388
417
{
389
418
/* set MAC hardware address */
390
- netif -> hwaddr_len = ETHARP_HWADDR_LEN ;
419
+ netif -> hwaddr_len = ETH_HWADDR_LEN ;
391
420
392
421
/* maximum transfer unit */
393
422
netif -> mtu = 1500 ;
394
423
395
424
/* device capabilities */
396
- netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP ;
425
+ netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET ;
397
426
398
427
#if LWIP_NETIF_HOSTNAME
399
428
/* Initialize interface hostname */
@@ -403,7 +432,15 @@ err_t eth_arch_enetif_init(struct netif *netif)
403
432
netif -> name [0 ] = 'e' ;
404
433
netif -> name [1 ] = 'n' ;
405
434
406
- netif -> output = _eth_arch_netif_output ;
435
+ #if LWIP_IPV4
436
+ netif -> output = _eth_arch_netif_output_ipv4 ;
437
+ netif -> flags |= NETIF_FLAG_IGMP ;
438
+ #endif
439
+ #if LWIP_IPV6
440
+ netif -> output_ip6 = _eth_arch_netif_output_ipv6 ;
441
+ netif -> flags |= NETIF_FLAG_MLD6 ;
442
+ #endif
443
+
407
444
netif -> linkoutput = _eth_arch_low_level_output ;
408
445
409
446
/* semaphore */
0 commit comments