| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#ifndef _NET_OVPN_DCO_SKB_H_ |
| 11 |
#define _NET_OVPN_DCO_SKB_H_ |
| 12 |
|
| 13 |
#include <linux/in.h> |
| 14 |
#include <linux/in6.h> |
| 15 |
#include <linux/ip.h> |
| 16 |
#include <linux/skbuff.h> |
| 17 |
#include <linux/socket.h> |
| 18 |
#include <linux/types.h> |
| 19 |
|
| 20 |
#define OVPN_SKB_CB(skb) ((struct ovpn_skb_cb *)&((skb)->cb)) |
| 21 |
|
| 22 |
struct ovpn_skb_cb { |
| 23 |
union { |
| 24 |
struct in_addr ipv4; |
| 25 |
struct in6_addr ipv6; |
| 26 |
} local; |
| 27 |
sa_family_t sa_fam; |
| 28 |
}; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
static inline __be16 ovpn_ip_check_protocol(struct sk_buff *skb) |
| 34 |
{ |
| 35 |
__be16 proto = 0; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) |
| 41 |
return 0; |
| 42 |
|
| 43 |
if (ip_hdr(skb)->version == 4) |
| 44 |
proto = htons(ETH_P_IP); |
| 45 |
else if (ip_hdr(skb)->version == 6) |
| 46 |
proto = htons(ETH_P_IPV6); |
| 47 |
|
| 48 |
return proto; |
| 49 |
} |
| 50 |
|
| 51 |
#endif |