1
1
#include "lwip/opt.h"
2
2
#include "lwip/tcpip.h"
3
3
#include "netif/etharp.h"
4
+ #include "lwip/ethip6.h"
4
5
#include "mbed_interface.h"
5
6
#include "ethernet_api.h"
6
7
#include "ethernetext_api.h"
@@ -15,13 +16,17 @@ static sys_sem_t recv_ready_sem; /* receive ready semaphore */
15
16
/* function */
16
17
static void rza1_recv_task (void * arg );
17
18
static void rza1_phy_task (void * arg );
18
- static err_t rza1_etharp_output (struct netif * netif , struct pbuf * q , ip_addr_t * ipaddr );
19
+ #if LWIP_IPV4
20
+ static err_t rza1_etharp_output_ipv4 (struct netif * netif , struct pbuf * q , const ip4_addr_t * ipaddr );
21
+ #endif
22
+ #if LWIP_IPV6
23
+ static err_t rza1_etharp_output_ipv6 (struct netif * netif , struct pbuf * q , const ip6_addr_t * ipaddr );
24
+ #endif
19
25
static err_t rza1_low_level_output (struct netif * netif , struct pbuf * p );
20
26
static void rza1_recv_callback (void );
21
27
22
28
static void rza1_recv_task (void * arg ) {
23
29
struct netif * netif = (struct netif * )arg ;
24
- struct eth_hdr * ethhdr ;
25
30
u16_t recv_size ;
26
31
struct pbuf * p ;
27
32
int cnt ;
@@ -34,24 +39,10 @@ static void rza1_recv_task(void *arg) {
34
39
p = pbuf_alloc (PBUF_RAW , recv_size , PBUF_RAM );
35
40
if (p != NULL ) {
36
41
(void )ethernet_read ((char * )p -> payload , p -> len );
37
- ethhdr = p -> payload ;
38
- switch (htons (ethhdr -> type )) {
39
- case ETHTYPE_IP :
40
- case ETHTYPE_ARP :
41
- #if PPPOE_SUPPORT
42
- case ETHTYPE_PPPOEDISC :
43
- case ETHTYPE_PPPOE :
44
- #endif /* PPPOE_SUPPORT */
45
- /* full packet send to tcpip_thread to process */
46
- if (netif -> input (p , netif ) != ERR_OK ) {
47
- /* Free buffer */
48
- pbuf_free (p );
49
- }
50
- break ;
51
- default :
52
- /* Return buffer */
53
- pbuf_free (p );
54
- break ;
42
+ /* full packet send to tcpip_thread to process */
43
+ if (netif -> input (p , netif ) != ERR_OK ) {
44
+ /* Free buffer */
45
+ pbuf_free (p );
55
46
}
56
47
}
57
48
} else {
@@ -94,14 +85,27 @@ static void rza1_phy_task(void *arg) {
94
85
}
95
86
}
96
87
97
- static err_t rza1_etharp_output (struct netif * netif , struct pbuf * q , ip_addr_t * ipaddr ) {
88
+ #if LWIP_IPV4
89
+ static err_t rza1_etharp_output_ipv4 (struct netif * netif , struct pbuf * q , const ip4_addr_t * ipaddr ) {
98
90
/* Only send packet is link is up */
99
91
if (netif -> flags & NETIF_FLAG_LINK_UP ) {
100
92
return etharp_output (netif , q , ipaddr );
101
93
}
102
94
103
95
return ERR_CONN ;
104
96
}
97
+ #endif
98
+
99
+ #if LWIP_IPV6
100
+ static err_t rza1_etharp_output_ipv6 (struct netif * netif , struct pbuf * q , const ip6_addr_t * ipaddr ) {
101
+ /* Only send packet is link is up */
102
+ if (netif -> flags & NETIF_FLAG_LINK_UP ) {
103
+ return ethip6_output (netif , q , ipaddr );
104
+ }
105
+
106
+ return ERR_CONN ;
107
+ }
108
+ #endif
105
109
106
110
static err_t rza1_low_level_output (struct netif * netif , struct pbuf * p ) {
107
111
struct pbuf * q ;
@@ -150,13 +154,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
150
154
#else
151
155
mbed_mac_address ((char * )netif -> hwaddr );
152
156
#endif
153
- netif -> hwaddr_len = ETHARP_HWADDR_LEN ;
157
+ netif -> hwaddr_len = ETH_HWADDR_LEN ;
154
158
155
159
/* maximum transfer unit */
156
160
netif -> mtu = 1500 ;
157
161
158
162
/* device capabilities */
159
- netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP ;
163
+ netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET ;
164
+ #ifdef LWIP_IGMP
165
+ netif -> flags |= NETIF_FLAG_IGMP ;
166
+ #endif
167
+ #if LWIP_IPV6_MLD
168
+ netif -> flags |= NETIF_FLAG_MLD6 ;
169
+ #endif
160
170
161
171
#if LWIP_NETIF_HOSTNAME
162
172
/* Initialize interface hostname */
@@ -166,7 +176,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
166
176
netif -> name [0 ] = 'e' ;
167
177
netif -> name [1 ] = 'n' ;
168
178
169
- netif -> output = rza1_etharp_output ;
179
+ #if LWIP_IPV4
180
+ netif -> output = rza1_etharp_output_ipv4 ;
181
+ #endif
182
+ #if LWIP_IPV6
183
+ netif -> output_ip6 = rza1_etharp_output_ipv6 ;
184
+ #endif
185
+
170
186
netif -> linkoutput = rza1_low_level_output ;
171
187
172
188
/* Initialize the hardware */
0 commit comments