Added an additional option LWIP_ETHERNET to support ethernet without ARP (necessary for pure PPPoE) - no changes in the ppp code yet

This commit is contained in:
goldsimon 2009-12-27 11:40:48 +00:00
parent bf261f4f13
commit a1c0b9da7b
5 changed files with 31 additions and 12 deletions

View File

@ -272,11 +272,11 @@ tcpip_thread(void *arg)
case TCPIP_MSG_INPKT: case TCPIP_MSG_INPKT:
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: PACKET %p\n", (void *)msg)); 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) { if (msg->msg.inp.netif->flags & NETIF_FLAG_ETHARP) {
ethernet_input(msg->msg.inp.p, msg->msg.inp.netif); ethernet_input(msg->msg.inp.p, msg->msg.inp.netif);
} else } else
#endif /* LWIP_ARP */ #endif /* LWIP_ETHERNET */
{ ip_input(msg->msg.inp.p, msg->msg.inp.netif); { ip_input(msg->msg.inp.p, msg->msg.inp.netif);
} }
memp_free(MEMP_TCPIP_MSG_INPKT, msg); memp_free(MEMP_TCPIP_MSG_INPKT, msg);

View File

@ -171,6 +171,9 @@
#if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT #if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT
#error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on" #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on"
#endif #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. /* Compile-time checks for deprecated options.

View File

@ -376,6 +376,13 @@
#define ETHARP_SUPPORT_VLAN 0 #define ETHARP_SUPPORT_VLAN 0
#endif #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 ---------- ---------- IP options ----------

View File

@ -37,7 +37,7 @@
#include "lwip/opt.h" #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/pbuf.h"
#include "lwip/ip_addr.h" #include "lwip/ip_addr.h"
@ -139,6 +139,8 @@ PACK_STRUCT_END
#define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */
#define ETHTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session 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) */ /** ARP message types (opcodes) */
#define ARP_REQUEST 1 #define ARP_REQUEST 1
#define ARP_REPLY 2 #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. */ * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */
#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) #define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr)
err_t ethernet_input(struct pbuf *p, struct netif *netif);
#if LWIP_AUTOIP #if LWIP_AUTOIP
err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
const struct eth_addr *ethdst_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); const u16_t opcode);
#endif /* LWIP_AUTOIP */ #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) #define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0)
extern const struct eth_addr ethbroadcast, ethzero; extern const struct eth_addr ethbroadcast, ethzero;
#endif /* LWIP_ARP || LWIP_ETHERNET */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* LWIP_ARP */
#endif /* __NETIF_ARP_H__ */ #endif /* __NETIF_ARP_H__ */

View File

@ -45,7 +45,7 @@
#include "lwip/opt.h" #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/inet.h"
#include "lwip/ip.h" #include "lwip/ip.h"
@ -61,6 +61,11 @@
#include <string.h> #include <string.h>
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, /** the time an ARP entry stays valid after its last update,
* for ARP_TMR_INTERVAL = 5000, this is * for ARP_TMR_INTERVAL = 5000, this is
* (240 * 5) seconds = 20 minutes. * (240 * 5) seconds = 20 minutes.
@ -103,8 +108,6 @@ struct etharp_entry {
struct netif *netif; 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]; static struct etharp_entry arp_table[ARP_TABLE_SIZE];
#if !LWIP_NETIF_HWADDRHINT #if !LWIP_NETIF_HWADDRHINT
static u8_t etharp_cached_entry; 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, &ethzero, (struct eth_addr *)netif->hwaddr, &netif->ip_addr, &ethzero,
ipaddr, ARP_REQUEST); ipaddr, ARP_REQUEST);
} }
#endif /* LWIP_ARP */
/** /**
* Process received ethernet frames. Using this function instead of directly * 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 */ #endif /* ETHARP_SUPPORT_VLAN */
switch (type) { switch (type) {
#if LWIP_ARP
/* IP packet? */ /* IP packet? */
case ETHTYPE_IP: case ETHTYPE_IP:
#if ETHARP_TRUST_IP_MAC #if ETHARP_TRUST_IP_MAC
@ -1196,7 +1201,7 @@ ethernet_input(struct pbuf *p, struct netif *netif)
/* pass p to ARP module */ /* pass p to ARP module */
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p); etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p);
break; break;
#endif /* LWIP_ARP */
#if PPPOE_SUPPORT #if PPPOE_SUPPORT
case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */ case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */
pppoe_disc_input(netif, p); 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 */ so the caller doesn't have to free it again */
return ERR_OK; return ERR_OK;
} }
#endif /* LWIP_ARP */ #endif /* LWIP_ARP || LWIP_ETHERNET */