more debug output
[linux-2.4.git] / include / net / inet_ecn.h
1 #ifndef _INET_ECN_H_
2 #define _INET_ECN_H_
3
4 enum {
5         INET_ECN_NOT_ECT = 0,
6         INET_ECN_ECT_1 = 1,
7         INET_ECN_ECT_0 = 2,
8         INET_ECN_CE = 3,
9         INET_ECN_MASK = 3,
10 };
11
12 static inline int INET_ECN_is_ce(__u8 dsfield)
13 {
14         return (dsfield&3) == 3;
15 }
16
17 static inline int INET_ECN_is_not_ce(__u8 dsfield)
18 {
19         return (dsfield&3) == 2;
20 }
21
22 static inline int INET_ECN_is_capable(__u8 dsfield)
23 {
24         return (dsfield&2);
25 }
26
27 static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
28 {
29         outer &= ~3;
30         if (INET_ECN_is_capable(inner))
31                 outer |= (inner & 3);
32         return outer;
33 }
34
35 #define INET_ECN_xmit(sk) do { (sk)->protinfo.af_inet.tos |= 2; } while (0)
36 #define INET_ECN_dontxmit(sk) do { (sk)->protinfo.af_inet.tos &= ~3; } while (0)
37
38 #define IP6_ECN_flow_init(label) do {   \
39       (label) &= ~htonl(3<<20);         \
40     } while (0)
41
42 #define IP6_ECN_flow_xmit(sk, label) do {                       \
43         if (INET_ECN_is_capable((sk)->protinfo.af_inet.tos))    \
44                 (label) |= __constant_htons(2 << 4);            \
45     } while (0)
46
47 static inline void IP_ECN_set_ce(struct iphdr *iph)
48 {
49         u32 check = iph->check;
50         check += __constant_htons(0xFFFE);
51         iph->check = check + (check>=0xFFFF);
52         iph->tos |= 1;
53 }
54
55 struct ipv6hdr;
56
57 static inline void IP6_ECN_set_ce(struct ipv6hdr *iph)
58 {
59         *(u32*)iph |= htonl(1<<20);
60 }
61
62 #define ip6_get_dsfield(iph) ((ntohs(*(u16*)(iph)) >> 4) & 0xFF)
63
64 #endif