patch #7993: Added support for transmitting packets with VLAN headers via hook function LWIP_HOOK_VLAN_SET and to check them via hook function LWIP_HOOK_VLAN_CHECK

This commit is contained in:
Simon Goldschmidt
2014-02-20 21:08:50 +01:00
parent a375ea4ee2
commit 6dcc85dcf4
4 changed files with 103 additions and 16 deletions

View File

@@ -496,7 +496,9 @@
#endif
/**
* ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header.
* ETHARP_SUPPORT_VLAN==1: support receiving and sending ethernet packets with
* VLAN header. See the description of LWIP_HOOK_VLAN_CHECK and
* LWIP_HOOK_VLAN_SET hooks to check/set VLAN headers.
* Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check.
* If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted.
* If ETHARP_VLAN_CHECK is not defined, all traffic is accepted.
@@ -1145,7 +1147,11 @@
* Ethernet.
*/
#ifndef PBUF_LINK_HLEN
#ifdef LWIP_HOOK_VLAN_SET
#define PBUF_LINK_HLEN (18 + ETH_PAD_SIZE)
#else /* LWIP_HOOK_VLAN_SET */
#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE)
#endif /* LWIP_HOOK_VLAN_SET */
#endif
/**
@@ -2213,6 +2219,29 @@
* that case, ip_route() continues as normal.
*/
/**
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
* - called from ethernet_input() if VLAN support is enabled
* - netif: struct netif on which the packet has been received
* - eth_hdr: struct eth_hdr of the packet
* - vlan_hdr: struct eth_vlan_hdr of the packet
* Return values:
* - 0: Packet must be dropped.
* - != 0: Packet must be accepted.
*/
/**
* LWIP_HOOK_VLAN_SET(netif, eth_hdr, vlan_hdr):
* - called from etharp_raw() and etharp_send_ip() if VLAN support is enabled
* - netif: struct netif that the packet will be sent through
* - eth_hdr: struct eth_hdr of the packet
* - vlan_hdr: struct eth_vlan_hdr of the packet
* Return values:
* - 0: Packet shall not contain VLAN header.
* - != 0: Packet shall contain VLAN header.
* Hook can be used to set prio_vid field of vlan_hdr.
*/
/*
---------------------------------------
---------- Debugging options ----------

View File

@@ -129,7 +129,13 @@ PACK_STRUCT_END
#endif
#define SIZEOF_ETHARP_HDR 28
#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR)
#if ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET)
#define SIZEOF_ETHARP_PACKET_TX (SIZEOF_ETHARP_PACKET + SIZEOF_VLAN_HDR)
#else /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
#define SIZEOF_ETHARP_PACKET_TX SIZEOF_ETHARP_PACKET
#endif /* ETHARP_SUPPORT_VLAN && defined(LWIP_HOOK_VLAN_SET) */
/** 5 seconds period */
#define ARP_TMR_INTERVAL 5000