From f1643267bc1f278a0c7e8347c283535c2cfa7d19 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 5 Oct 2004 12:51:10 -0300 Subject: [SKBUFF] introduce eth_hdr(skb) This is the start of a series of patches to remove protocol specific stuff out of include/linux/skbuff.h and to make the struct sk_buff header pointers private, i.e. they will only be accessible thru foo_hdr(skb) and some other accessor functions. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/if_ether.h | 12 ++++++++++-- include/linux/if_vlan.h | 10 ++++++++-- include/linux/netfilter_bridge/ebt_802_3.h | 9 +++++++++ include/linux/skbuff.h | 1 - 4 files changed, 27 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h index d62b4dfd8305..4037aaab7aa9 100644 --- a/include/linux/if_ether.h +++ b/include/linux/if_ether.h @@ -96,11 +96,19 @@ * This is an Ethernet frame header. */ -struct ethhdr -{ +struct ethhdr { unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ unsigned char h_source[ETH_ALEN]; /* source ether addr */ unsigned short h_proto; /* packet type ID field */ } __attribute__((packed)); +#ifdef __KERNEL__ +#include + +static inline struct ethhdr *eth_hdr(const struct sk_buff *skb) +{ + return (struct ethhdr *)skb->mac.raw; +} +#endif + #endif /* _LINUX_IF_ETHER_H */ diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 529c401a9a86..29b6e104657e 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -18,7 +18,6 @@ /* externally defined structs */ struct vlan_group; struct net_device; -struct sk_buff; struct packet_type; struct vlan_collection; struct vlan_dev_info; @@ -48,6 +47,13 @@ struct vlan_ethhdr { unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */ }; +#include + +static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb) +{ + return (struct vlan_ethhdr *)skb->mac.raw; +} + struct vlan_hdr { unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID */ unsigned short h_vlan_encapsulated_proto; /* packet type ID field (or len) */ @@ -180,7 +186,7 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb, * This allows the VLAN to have a different MAC than the underlying * device, and still route correctly. */ - if (!memcmp(skb->mac.ethernet->h_dest, skb->dev->dev_addr, ETH_ALEN)) + if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN)) skb->pkt_type = PACKET_HOST; break; }; diff --git a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h index b3d6c3219075..b9f712c14a0a 100644 --- a/include/linux/netfilter_bridge/ebt_802_3.h +++ b/include/linux/netfilter_bridge/ebt_802_3.h @@ -49,6 +49,15 @@ struct ebt_802_3_hdr { } llc; }; +#ifdef __KERNEL__ +#include + +static inline struct ebt_802_3_hdr *ebt_802_3_hdr(const struct sk_buff *skb) +{ + return (struct ebt_802_3_hdr *)skb->mac.raw; +} +#endif + struct ebt_802_3_info { uint8_t sap; diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index b6c6ef59ab16..71fc2bdc0cd6 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -219,7 +219,6 @@ struct sk_buff { } nh; union { - struct ethhdr *ethernet; unsigned char *raw; } mac; -- cgit v1.2.3