From a1c0b9da7be0014b0f03d60a8d11fcfb0e9c30e6 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 27 Dec 2009 11:40:48 +0000 Subject: [PATCH] Added an additional option LWIP_ETHERNET to support ethernet without ARP (necessary for pure PPPoE) - no changes in the ppp code yet --- src/api/tcpip.c | 4 ++-- src/core/init.c | 3 +++ src/include/lwip/opt.h | 7 +++++++ src/include/netif/etharp.h | 14 +++++++++----- src/netif/etharp.c | 15 ++++++++++----- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/api/tcpip.c b/src/api/tcpip.c index 002df90b..5532e090 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -272,11 +272,11 @@ tcpip_thread(void *arg) case TCPIP_MSG_INPKT: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg)); -#if LWIP_ARP +#if LWIP_ETHERNET if (msg->msg.inp.netif->flags & NETIF_FLAG_ETHARP) { ethernet_input(msg->msg.inp.p, msg->msg.inp.netif); } else -#endif /* LWIP_ARP */ +#endif /* LWIP_ETHERNET */ { ip_input(msg->msg.inp.p, msg->msg.inp.netif); } memp_free(MEMP_TCPIP_MSG_INPKT, msg); diff --git a/src/core/init.c b/src/core/init.c index be0e3582..21b39e33 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -171,6 +171,9 @@ #if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on" #endif +#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) + #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" +#endif /* Compile-time checks for deprecated options. diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index eb99a778..5524ed85 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -376,6 +376,13 @@ #define ETHARP_SUPPORT_VLAN 0 #endif +/** LWIP_ETHERNET==1: enable ethernet support for PPPoE even though ARP + * might be disabled + */ +#ifndef LWIP_ETHERNET +#define LWIP_ETHERNET (LWIP_ARP || PPPOE_SUPPORT) +#endif + /* -------------------------------- ---------- IP options ---------- diff --git a/src/include/netif/etharp.h b/src/include/netif/etharp.h index 72b8d79f..b895a677 100644 --- a/src/include/netif/etharp.h +++ b/src/include/netif/etharp.h @@ -37,7 +37,7 @@ #include "lwip/opt.h" -#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ +#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ #include "lwip/pbuf.h" #include "lwip/ip_addr.h" @@ -139,6 +139,8 @@ PACK_STRUCT_END #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ +#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ + /** ARP message types (opcodes) */ #define ARP_REQUEST 1 #define ARP_REPLY 2 @@ -169,8 +171,6 @@ err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr); * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) -err_t ethernet_input(struct pbuf *p, struct netif *netif); - #if LWIP_AUTOIP err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, const struct eth_addr *ethdst_addr, @@ -179,14 +179,18 @@ err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, const u16_t opcode); #endif /* LWIP_AUTOIP */ +#endif /* LWIP_ARP */ + +err_t ethernet_input(struct pbuf *p, struct netif *netif); + #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) extern const struct eth_addr ethbroadcast, ethzero; +#endif /* LWIP_ARP || LWIP_ETHERNET */ + #ifdef __cplusplus } #endif -#endif /* LWIP_ARP */ - #endif /* __NETIF_ARP_H__ */ diff --git a/src/netif/etharp.c b/src/netif/etharp.c index 8f6872fa..ee4c3800 100644 --- a/src/netif/etharp.c +++ b/src/netif/etharp.c @@ -45,7 +45,7 @@ #include "lwip/opt.h" -#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ +#if LWIP_ARP || LWIP_ETHERNET #include "lwip/inet.h" #include "lwip/ip.h" @@ -61,6 +61,11 @@ #include +const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; +const struct eth_addr ethzero = {{0,0,0,0,0,0}}; + +#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ + /** the time an ARP entry stays valid after its last update, * for ARP_TMR_INTERVAL = 5000, this is * (240 * 5) seconds = 20 minutes. @@ -103,8 +108,6 @@ struct etharp_entry { struct netif *netif; }; -const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; -const struct eth_addr ethzero = {{0,0,0,0,0,0}}; static struct etharp_entry arp_table[ARP_TABLE_SIZE]; #if !LWIP_NETIF_HWADDRHINT static u8_t etharp_cached_entry; @@ -1134,6 +1137,7 @@ etharp_request(struct netif *netif, struct ip_addr *ipaddr) (struct eth_addr *)netif->hwaddr, &netif->ip_addr, ðzero, ipaddr, ARP_REQUEST); } +#endif /* LWIP_ARP */ /** * Process received ethernet frames. Using this function instead of directly @@ -1175,6 +1179,7 @@ ethernet_input(struct pbuf *p, struct netif *netif) #endif /* ETHARP_SUPPORT_VLAN */ switch (type) { +#if LWIP_ARP /* IP packet? */ case ETHTYPE_IP: #if ETHARP_TRUST_IP_MAC @@ -1196,7 +1201,7 @@ ethernet_input(struct pbuf *p, struct netif *netif) /* pass p to ARP module */ etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p); break; - +#endif /* LWIP_ARP */ #if PPPOE_SUPPORT case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */ pppoe_disc_input(netif, p); @@ -1219,4 +1224,4 @@ ethernet_input(struct pbuf *p, struct netif *netif) so the caller doesn't have to free it again */ return ERR_OK; } -#endif /* LWIP_ARP */ +#endif /* LWIP_ARP || LWIP_ETHERNET */