Skip to content

Commit f270fcb

Browse files
author
Mika Leppänen
committed
Updated LPC17 mac for lwip 2.0 and IPv6
1 parent f4e76bb commit f270fcb

File tree

1 file changed

+49
-30
lines changed
  • features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_NXP

1 file changed

+49
-30
lines changed

features/net/FEATURE_IPV4/lwip-interface/lwip-eth/arch/TARGET_NXP/lpc17_emac.c

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
#include "lwip/stats.h"
3232
#include "lwip/snmp.h"
3333
#include "netif/etharp.h"
34-
#include "netif/ppp_oe.h"
34+
#include "lwip/ethip6.h"
35+
#include "netif/ppp/pppoe.h"
3536

3637
#include "lpc17xx_emac.h"
3738
#include "eth_arch.h"
@@ -409,29 +410,12 @@ void lpc_enetif_input(struct netif *netif)
409410
if (p == NULL)
410411
return;
411412

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+
}
435419
}
436420

437421
/** \brief Determine if the passed address is usable for the ethernet
@@ -920,23 +904,46 @@ void lpc_emac_set_speed(int mbs_100)
920904
}
921905

922906
/**
923-
* This function is the ethernet packet send function. It calls
907+
* This function is the ethernet IPv4 packet send function. It calls
924908
* etharp_output after checking link status.
925909
*
926910
* \param[in] netif the lwip network interface structure for this lpc_enetif
927911
* \param[in] q Pointer to pbug to send
928912
* \param[in] ipaddr IP address
929913
* \return ERR_OK or error code
930914
*/
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)
933918
{
934919
/* Only send packet is link is up */
935920
if (netif->flags & NETIF_FLAG_LINK_UP)
936921
return etharp_output(netif, q, ipaddr);
937922

938923
return ERR_CONN;
939924
}
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
940947

941948
#if NO_SYS == 0
942949
/* periodic PHY status update */
@@ -976,13 +983,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
976983
#else
977984
mbed_mac_address((char *)netif->hwaddr);
978985
#endif
979-
netif->hwaddr_len = ETHARP_HWADDR_LEN;
986+
netif->hwaddr_len = ETH_HWADDR_LEN;
980987

981988
/* maximum transfer unit */
982989
netif->mtu = 1500;
983990

984991
/* 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
986999

9871000
/* Initialize the hardware */
9881001
netif->state = &lpc_enetdata;
@@ -998,7 +1011,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
9981011
netif->name[0] = 'e';
9991012
netif->name[1] = 'n';
10001013

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+
10021021
netif->linkoutput = lpc_low_level_output;
10031022

10041023
/* CMSIS-RTOS, start tasks */

0 commit comments

Comments
 (0)