aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/if_packet.h
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-07-15 01:50:15 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-15 01:50:15 -0400
commitbbd6ef87c544d88c30e4b762b1b61ef267a7d279 (patch)
treedd9fdfbde65332d3212290d1b8783666475bd861 /include/linux/if_packet.h
parentbc1d0411b804ad190cdadabac48a10067f17b9e6 (diff)
packet: support extensible, 64 bit clean mmaped ring structure
The tpacket_hdr is not 64 bit clean due to use of an unsigned long and can't be extended because the following struct sockaddr_ll needs to be at a fixed offset. Add support for a version 2 tpacket protocol that removes these limitations. Userspace can query the header size through a new getsockopt option and change the protocol version through a setsockopt option. The changes needed to switch to the new protocol version are: 1. replace struct tpacket_hdr by struct tpacket2_hdr 2. query header len and save 3. set protocol version to 2 - set up ring as usual 4. for getting the sockaddr_ll, use (void *)hdr + TPACKET_ALIGN(hdrlen) instead of (void *)hdr + TPACKET_ALIGN(sizeof(struct tpacket_hdr)) Steps 2 and 4 can be omitted if the struct sockaddr_ll isn't needed. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_packet.h')
-rw-r--r--include/linux/if_packet.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index ad09609227ff..d4d3c82448f5 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -43,6 +43,8 @@ struct sockaddr_ll
43#define PACKET_COPY_THRESH 7 43#define PACKET_COPY_THRESH 7
44#define PACKET_AUXDATA 8 44#define PACKET_AUXDATA 8
45#define PACKET_ORIGDEV 9 45#define PACKET_ORIGDEV 9
46#define PACKET_VERSION 10
47#define PACKET_HDRLEN 11
46 48
47struct tpacket_stats 49struct tpacket_stats
48{ 50{
@@ -79,6 +81,25 @@ struct tpacket_hdr
79#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1)) 81#define TPACKET_ALIGN(x) (((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1))
80#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll)) 82#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
81 83
84struct tpacket2_hdr
85{
86 __u32 tp_status;
87 __u32 tp_len;
88 __u32 tp_snaplen;
89 __u16 tp_mac;
90 __u16 tp_net;
91 __u32 tp_sec;
92 __u32 tp_nsec;
93};
94
95#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
96
97enum tpacket_versions
98{
99 TPACKET_V1,
100 TPACKET_V2,
101};
102
82/* 103/*
83 Frame structure: 104 Frame structure:
84 105