Recognize 802.1q frames in Ethernet input and process them.

PR:		kern/101162
Submitted by:	CoolDavid (Tseng Guo-Fu) <cooldavid cdpa.nsysu.edu.tw>
This commit is contained in:
Gleb Smirnoff 2006-10-11 15:27:13 +00:00
parent 68a57ebfad
commit 7801dc7cb3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163247

View file

@ -42,6 +42,7 @@ static const char rcs_id[] =
#include <net/ethernet.h>
#include <net/if_arp.h>
#include <net/if_var.h>
#include <net/if_vlan_var.h>
#include <net/bpf.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@ -514,6 +515,19 @@ ng_netflow_rcvdata (hook_p hook, item_p item)
eh = mtod(m, struct ether_header *);
ip = (struct ip *)(eh + 1);
break;
case ETHERTYPE_VLAN:
{
struct ether_vlan_header *evh;
M_CHECK(sizeof(struct ether_vlan_header) -
sizeof(struct ether_header));
evh = mtod(m, struct ether_vlan_header *);
if (ntohs(evh->evl_proto) == ETHERTYPE_IP) {
M_CHECK(sizeof(struct ip));
ip = (struct ip *)(evh + 1);
break;
}
}
default:
goto bypass; /* pass this frame */
}
@ -551,7 +565,21 @@ ng_netflow_rcvdata (hook_p hook, item_p item)
struct ether_header *eh;
eh = mtod(m, struct ether_header *);
ip = (struct ip *)(eh + 1);
switch (ntohs(eh->ether_type)) {
case ETHERTYPE_IP:
ip = (struct ip *)(eh + 1);
break;
case ETHERTYPE_VLAN:
{
struct ether_vlan_header *evh;
evh = mtod(m, struct ether_vlan_header *);
ip = (struct ip *)(evh + 1);
break;
}
default:
panic("ng_netflow entered deadcode");
}
break;
}
case DLT_RAW: