~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/net/tcp_ecn.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _NET_TCP_ECN_H_
  2 #define _NET_TCP_ECN_H_ 1
  3 
  4 #include <linux/config.h>
  5 
  6 #ifdef CONFIG_INET_ECN
  7 
  8 #include <net/inet_ecn.h>
  9 
 10 #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)|TCP_FLAG_ECE|TCP_FLAG_CWR)
 11 
 12 #define TCP_ECN_OK              1
 13 #define TCP_ECN_QUEUE_CWR       2
 14 #define TCP_ECN_DEMAND_CWR      4
 15 
 16 static __inline__ void
 17 TCP_ECN_queue_cwr(struct tcp_opt *tp)
 18 {
 19         if (tp->ecn_flags&TCP_ECN_OK)
 20                 tp->ecn_flags |= TCP_ECN_QUEUE_CWR;
 21 }
 22 
 23 
 24 /* Output functions */
 25 
 26 static __inline__ void
 27 TCP_ECN_send_synack(struct tcp_opt *tp, struct sk_buff *skb)
 28 {
 29         TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
 30         if (!(tp->ecn_flags&TCP_ECN_OK))
 31                 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
 32 }
 33 
 34 static __inline__ void
 35 TCP_ECN_send_syn(struct tcp_opt *tp, struct sk_buff *skb)
 36 {
 37         tp->ecn_flags = 0;
 38         if (sysctl_tcp_ecn) {
 39                 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
 40                 tp->ecn_flags = TCP_ECN_OK;
 41         }
 42 }
 43 
 44 static __inline__ void
 45 TCP_ECN_make_synack(struct open_request *req, struct tcphdr *th)
 46 {
 47         if (req->ecn_ok)
 48                 th->ece = 1;
 49 }
 50 
 51 static __inline__ void
 52 TCP_ECN_send(struct sock *sk, struct tcp_opt *tp, struct sk_buff *skb, int tcp_header_len)
 53 {
 54         if (tp->ecn_flags & TCP_ECN_OK) {
 55                 /* Not-retransmitted data segment: set ECT and inject CWR. */
 56                 if (skb->len != tcp_header_len &&
 57                     !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
 58                         INET_ECN_xmit(sk);
 59                         if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
 60                                 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
 61                                 skb->h.th->cwr = 1;
 62                         }
 63                 } else {
 64                         /* ACK or retransmitted segment: clear ECT|CE */
 65                         INET_ECN_dontxmit(sk);
 66                 }
 67                 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
 68                         skb->h.th->ece = 1;
 69         }
 70 }
 71 
 72 /* Input functions */
 73 
 74 static __inline__ void
 75 TCP_ECN_accept_cwr(struct tcp_opt *tp, struct sk_buff *skb)
 76 {
 77         if (skb->h.th->cwr)
 78                 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
 79 }
 80 
 81 static __inline__ void
 82 TCP_ECN_withdraw_cwr(struct tcp_opt *tp)
 83 {
 84         tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
 85 }
 86 
 87 static __inline__ void
 88 TCP_ECN_check_ce(struct tcp_opt *tp, struct sk_buff *skb)
 89 {
 90         if (tp->ecn_flags&TCP_ECN_OK) {
 91                 if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
 92                         tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
 93                 /* Funny extension: if ECT is not set on a segment,
 94                  * it is surely retransmit. It is not in ECN RFC,
 95                  * but Linux follows this rule. */
 96                 else if (!INET_ECN_is_capable((TCP_SKB_CB(skb)->flags)))
 97                         tcp_enter_quickack_mode(tp);
 98         }
 99 }
100 
101 static __inline__ void
102 TCP_ECN_rcv_synack(struct tcp_opt *tp, struct tcphdr *th)
103 {
104         if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr))
105                 tp->ecn_flags &= ~TCP_ECN_OK;
106 }
107 
108 static __inline__ void
109 TCP_ECN_rcv_syn(struct tcp_opt *tp, struct tcphdr *th)
110 {
111         if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr))
112                 tp->ecn_flags &= ~TCP_ECN_OK;
113 }
114 
115 static __inline__ int
116 TCP_ECN_rcv_ecn_echo(struct tcp_opt *tp, struct tcphdr *th)
117 {
118         if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK))
119                 return 1;
120         return 0;
121 }
122 
123 static __inline__ void
124 TCP_ECN_openreq_child(struct tcp_opt *tp, struct open_request *req)
125 {
126         tp->ecn_flags = req->ecn_ok ? TCP_ECN_OK : 0;
127 }
128 
129 static __inline__ void
130 TCP_ECN_create_request(struct open_request *req, struct tcphdr *th)
131 {
132         if (sysctl_tcp_ecn && th->ece && th->cwr)
133                 req->ecn_ok = 1;
134 }
135 
136 
137 
138 #else
139 
140 #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
141 
142 
143 #define TCP_ECN_send_syn(x...)          do { } while (0)
144 #define TCP_ECN_send_synack(x...)       do { } while (0)
145 #define TCP_ECN_make_synack(x...)       do { } while (0)
146 #define TCP_ECN_send(x...)              do { } while (0)
147 
148 #define TCP_ECN_queue_cwr(x...)         do { } while (0)
149 
150 #define TCP_ECN_accept_cwr(x...)        do { } while (0)
151 #define TCP_ECN_check_ce(x...)          do { } while (0)
152 #define TCP_ECN_rcv_synack(x...)        do { } while (0)
153 #define TCP_ECN_rcv_syn(x...)           do { } while (0)
154 #define TCP_ECN_rcv_ecn_echo(x...)      (0)
155 #define TCP_ECN_openreq_child(x...)     do { } while (0)
156 #define TCP_ECN_create_request(x...)    do { } while (0)
157 #define TCP_ECN_withdraw_cwr(x...)      do { } while (0)
158 
159 
160 #endif
161 
162 #endif
163 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.