More Makefile cleanups, otherwise mainly noticeable are the netfilter fix
[davej-history.git] / include / net / inet_ecn.h
blob2ddf7675aa1cf8b79884f34de524f43a63132b2e
1 #ifndef _INET_ECN_H_
2 #define _INET_ECN_H_
4 #include <linux/config.h>
6 #ifdef CONFIG_INET_ECN
8 static inline int INET_ECN_is_ce(__u8 dsfield)
10 return (dsfield&3) == 3;
13 static inline int INET_ECN_is_not_ce(__u8 dsfield)
15 return (dsfield&3) == 2;
18 static inline int INET_ECN_is_capable(__u8 dsfield)
20 return (dsfield&2);
23 static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
25 outer &= ~3;
26 if (INET_ECN_is_capable(inner))
27 outer |= (inner & 3);
28 return outer;
31 #define INET_ECN_xmit(sk) do { (sk)->protinfo.af_inet.tos |= 2; } while (0)
32 #define INET_ECN_dontxmit(sk) do { (sk)->protinfo.af_inet.tos &= ~3; } while (0)
34 #define IP6_ECN_flow_init(label) do { \
35 (label) &= ~htonl(3<<20); \
36 } while (0)
38 #define IP6_ECN_flow_xmit(sk, label) do { \
39 if (INET_ECN_is_capable((sk)->protinfo.af_inet.tos)) \
40 (label) |= __constant_htons(2 << 4); \
41 } while (0)
44 #else
45 #define INET_ECN_is_ce(x...) (0)
46 #define INET_ECN_is_not_ce(x...) (0)
47 #define INET_ECN_is_capable(x...) (0)
48 #define INET_ECN_encapsulate(x, y) (x)
49 #define IP6_ECN_flow_init(x...) do { } while (0)
50 #define IP6_ECN_flow_xmit(x...) do { } while (0)
51 #define INET_ECN_xmit(x...) do { } while (0)
52 #define INET_ECN_dontxmit(x...) do { } while (0)
53 #endif
55 static inline void IP_ECN_set_ce(struct iphdr *iph)
57 u32 check = iph->check;
58 check += __constant_htons(0xFFFE);
59 iph->check = check + (check>=0xFFFF);
60 iph->tos |= 1;
63 struct ipv6hdr;
65 static inline void IP6_ECN_set_ce(struct ipv6hdr *iph)
67 *(u32*)iph |= htonl(1<<20);
70 #define ip6_get_dsfield(iph) ((ntohs(*(u16*)(iph)) >> 4) & 0xFF)
72 #endif