31
31
#include "lwip/stats.h"
32
32
#include "lwip/snmp.h"
33
33
#include "netif/etharp.h"
34
- #include "netif/ppp_oe.h"
34
+ #include "lwip/ethip6.h"
35
+ #include "netif/ppp/pppoe.h"
35
36
36
37
#include "lpc17xx_emac.h"
37
38
#include "eth_arch.h"
@@ -409,29 +410,12 @@ void lpc_enetif_input(struct netif *netif)
409
410
if (p == NULL )
410
411
return ;
411
412
412
- /* points to packet payload, which starts with an Ethernet header */
413
- ethhdr = p -> payload ;
414
-
415
- switch (htons (ethhdr -> type )) {
416
- case ETHTYPE_IP :
417
- case ETHTYPE_ARP :
418
- #if PPPOE_SUPPORT
419
- case ETHTYPE_PPPOEDISC :
420
- case ETHTYPE_PPPOE :
421
- #endif /* PPPOE_SUPPORT */
422
- /* full packet send to tcpip_thread to process */
423
- if (netif -> input (p , netif ) != ERR_OK ) {
424
- LWIP_DEBUGF (NETIF_DEBUG , ("lpc_enetif_input: IP input error\n" ));
425
- /* Free buffer */
426
- pbuf_free (p );
427
- }
428
- break ;
429
-
430
- default :
431
- /* Return buffer */
432
- pbuf_free (p );
433
- break ;
434
- }
413
+ /* full packet send to tcpip_thread to process */
414
+ if (netif -> input (p , netif ) != ERR_OK ) {
415
+ LWIP_DEBUGF (NETIF_DEBUG , ("lpc_enetif_input: IP input error\n" ));
416
+ /* Free buffer */
417
+ pbuf_free (p );
418
+ }
435
419
}
436
420
437
421
/** \brief Determine if the passed address is usable for the ethernet
@@ -920,23 +904,46 @@ void lpc_emac_set_speed(int mbs_100)
920
904
}
921
905
922
906
/**
923
- * This function is the ethernet packet send function. It calls
907
+ * This function is the ethernet IPv4 packet send function. It calls
924
908
* etharp_output after checking link status.
925
909
*
926
910
* \param[in] netif the lwip network interface structure for this lpc_enetif
927
911
* \param[in] q Pointer to pbug to send
928
912
* \param[in] ipaddr IP address
929
913
* \return ERR_OK or error code
930
914
*/
931
- err_t lpc_etharp_output (struct netif * netif , struct pbuf * q ,
932
- ip_addr_t * ipaddr )
915
+ #if LWIP_IPV4
916
+ err_t lpc_etharp_output_ipv4 (struct netif * netif , struct pbuf * q ,
917
+ const ip4_addr_t * ipaddr )
933
918
{
934
919
/* Only send packet is link is up */
935
920
if (netif -> flags & NETIF_FLAG_LINK_UP )
936
921
return etharp_output (netif , q , ipaddr );
937
922
938
923
return ERR_CONN ;
939
924
}
925
+ #endif
926
+
927
+ /**
928
+ * This function is the ethernet IPv6 packet send function. It calls
929
+ * etharp_output after checking link status.
930
+ *
931
+ * \param[in] netif the lwip network interface structure for this lpc_enetif
932
+ * \param[in] q Pointer to pbug to send
933
+ * \param[in] ipaddr IP address
934
+ * \return ERR_OK or error code
935
+ */
936
+ #if LWIP_IPV6
937
+ err_t lpc_etharp_output_ipv6 (struct netif * netif , struct pbuf * q ,
938
+ const ip6_addr_t * ipaddr )
939
+ {
940
+ /* Only send packet is link is up */ s
941
+ if (netif -> flags & NETIF_FLAG_LINK_UP )
942
+ return ethip6_output (netif , q , ipaddr );
943
+
944
+ return ERR_CONN ;
945
+ }
946
+ #endif
940
947
941
948
#if NO_SYS == 0
942
949
/* periodic PHY status update */
@@ -976,13 +983,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
976
983
#else
977
984
mbed_mac_address ((char * )netif -> hwaddr );
978
985
#endif
979
- netif -> hwaddr_len = ETHARP_HWADDR_LEN ;
986
+ netif -> hwaddr_len = ETH_HWADDR_LEN ;
980
987
981
988
/* maximum transfer unit */
982
989
netif -> mtu = 1500 ;
983
990
984
991
/* device capabilities */
985
- netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP ;
992
+ netif -> flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET ;
993
+ #ifdef LWIP_IGMP
994
+ netif -> flags |= NETIF_FLAG_IGMP ;
995
+ #endif
996
+ #if LWIP_IPV6_MLD
997
+ netif -> flags |= NETIF_FLAG_MLD6 ;
998
+ #endif
986
999
987
1000
/* Initialize the hardware */
988
1001
netif -> state = & lpc_enetdata ;
@@ -998,7 +1011,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
998
1011
netif -> name [0 ] = 'e' ;
999
1012
netif -> name [1 ] = 'n' ;
1000
1013
1001
- netif -> output = lpc_etharp_output ;
1014
+ #if LWIP_IPV4
1015
+ netif -> output = lpc_etharp_output_ipv4 ;
1016
+ #endif
1017
+ #if LWIP_IPV6
1018
+ netif -> output_ip6 = lpc_etharp_output_ipv6 ;
1019
+ #endif
1020
+
1002
1021
netif -> linkoutput = lpc_low_level_output ;
1003
1022
1004
1023
/* CMSIS-RTOS, start tasks */
0 commit comments