Vitezslav Samel <vitezslav(a)samel.cz> writes:
Reorganize and fix VLAN header stripping and accounting. Also fix
network layer protocol after VLAN header stripping.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/packet.c | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/packet.c b/src/packet.c
index 0a1f0ff..1299fbb 100644
--- a/src/packet.c
+++ b/src/packet.c
@@ -53,15 +53,15 @@ static void adjustpacket(char *tpacket, struct sockaddr_ll
*fromaddr,
switch (fromaddr->sll_hatype) {
case ARPHRD_ETHER:
case ARPHRD_LOOPBACK:
- if (fromaddr->sll_protocol == ETH_P_8021Q) {
- /* 0x8100 802.1Q VLAN Extended Header */
- *packet = tpacket + VLAN_ETH_HLEN;
- *readlen -= VLAN_ETH_HLEN;
- break;
- }
-
*packet = tpacket + ETH_HLEN;
*readlen -= ETH_HLEN;
+ if (fromaddr->sll_protocol == ETH_P_8021Q) {
+ /* strip 0x8100 802.1Q VLAN Extended Header */
+ *packet += 4;
+ *readlen -= 4;
in if_vlan.h is
#define VLAN_HLEN 4 /* The additional bytes (on top of the Ethernet header)
* that VLAN requires. */
problem is that, it's hidden under #ifdef __KERNEL__ so it's not visible
from user-space. I'd like to see the inclusion of linux/if_vlan.h header
with
#ifndef VLAN_HLEN
# define VLAN_HLEN 4
#endif
with some explanation why it's not in if_vlan.h.
--
Nikola