aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/tcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/tcp.h')
-rw-r--r--include/linux/tcp.h72
1 files changed, 62 insertions, 10 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 61723a7c21fe..7fee8a4df931 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -81,6 +81,12 @@ enum {
81 TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000) 81 TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000)
82}; 82};
83 83
84/*
85 * TCP general constants
86 */
87#define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */
88#define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */
89
84/* TCP socket options */ 90/* TCP socket options */
85#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */ 91#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
86#define TCP_MAXSEG 2 /* Limit MSS */ 92#define TCP_MAXSEG 2 /* Limit MSS */
@@ -96,14 +102,15 @@ enum {
96#define TCP_QUICKACK 12 /* Block/reenable quick acks */ 102#define TCP_QUICKACK 12 /* Block/reenable quick acks */
97#define TCP_CONGESTION 13 /* Congestion control algorithm */ 103#define TCP_CONGESTION 13 /* Congestion control algorithm */
98#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ 104#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
105#define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */
99 106
107/* for TCP_INFO socket option */
100#define TCPI_OPT_TIMESTAMPS 1 108#define TCPI_OPT_TIMESTAMPS 1
101#define TCPI_OPT_SACK 2 109#define TCPI_OPT_SACK 2
102#define TCPI_OPT_WSCALE 4 110#define TCPI_OPT_WSCALE 4
103#define TCPI_OPT_ECN 8 111#define TCPI_OPT_ECN 8
104 112
105enum tcp_ca_state 113enum tcp_ca_state {
106{
107 TCP_CA_Open = 0, 114 TCP_CA_Open = 0,
108#define TCPF_CA_Open (1<<TCP_CA_Open) 115#define TCPF_CA_Open (1<<TCP_CA_Open)
109 TCP_CA_Disorder = 1, 116 TCP_CA_Disorder = 1,
@@ -116,8 +123,7 @@ enum tcp_ca_state
116#define TCPF_CA_Loss (1<<TCP_CA_Loss) 123#define TCPF_CA_Loss (1<<TCP_CA_Loss)
117}; 124};
118 125
119struct tcp_info 126struct tcp_info {
120{
121 __u8 tcpi_state; 127 __u8 tcpi_state;
122 __u8 tcpi_ca_state; 128 __u8 tcpi_ca_state;
123 __u8 tcpi_retransmits; 129 __u8 tcpi_retransmits;
@@ -170,6 +176,30 @@ struct tcp_md5sig {
170 __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */ 176 __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */
171}; 177};
172 178
179/* for TCP_COOKIE_TRANSACTIONS (TCPCT) socket option */
180#define TCP_COOKIE_MIN 8 /* 64-bits */
181#define TCP_COOKIE_MAX 16 /* 128-bits */
182#define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX)
183
184/* Flags for both getsockopt and setsockopt */
185#define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */
186#define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies,
187 * supercedes everything. */
188
189/* Flags for getsockopt */
190#define TCP_S_DATA_IN (1 << 2) /* Was data received? */
191#define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */
192
193/* TCP_COOKIE_TRANSACTIONS data */
194struct tcp_cookie_transactions {
195 __u16 tcpct_flags; /* see above */
196 __u8 __tcpct_pad1; /* zero */
197 __u8 tcpct_cookie_desired; /* bytes */
198 __u16 tcpct_s_data_desired; /* bytes of variable data */
199 __u16 tcpct_used; /* bytes in value */
200 __u8 tcpct_value[TCP_MSS_DEFAULT];
201};
202
173#ifdef __KERNEL__ 203#ifdef __KERNEL__
174 204
175#include <linux/skbuff.h> 205#include <linux/skbuff.h>
@@ -217,26 +247,38 @@ struct tcp_options_received {
217 sack_ok : 4, /* SACK seen on SYN packet */ 247 sack_ok : 4, /* SACK seen on SYN packet */
218 snd_wscale : 4, /* Window scaling received from sender */ 248 snd_wscale : 4, /* Window scaling received from sender */
219 rcv_wscale : 4; /* Window scaling to send to receiver */ 249 rcv_wscale : 4; /* Window scaling to send to receiver */
220/* SACKs data */ 250 u8 cookie_plus:6, /* bytes in authenticator/cookie option */
251 cookie_out_never:1,
252 cookie_in_always:1;
221 u8 num_sacks; /* Number of SACK blocks */ 253 u8 num_sacks; /* Number of SACK blocks */
222 u16 user_mss; /* mss requested by user in ioctl */ 254 u16 user_mss; /* mss requested by user in ioctl */
223 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ 255 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
224}; 256};
225 257
258static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
259{
260 rx_opt->tstamp_ok = rx_opt->sack_ok = 0;
261 rx_opt->wscale_ok = rx_opt->snd_wscale = 0;
262 rx_opt->cookie_plus = 0;
263}
264
226/* This is the max number of SACKS that we'll generate and process. It's safe 265/* This is the max number of SACKS that we'll generate and process. It's safe
227 * to increse this, although since: 266 * to increase this, although since:
228 * size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8) 267 * size = TCPOLEN_SACK_BASE_ALIGNED (4) + n * TCPOLEN_SACK_PERBLOCK (8)
229 * only four options will fit in a standard TCP header */ 268 * only four options will fit in a standard TCP header */
230#define TCP_NUM_SACKS 4 269#define TCP_NUM_SACKS 4
231 270
271struct tcp_cookie_values;
272struct tcp_request_sock_ops;
273
232struct tcp_request_sock { 274struct tcp_request_sock {
233 struct inet_request_sock req; 275 struct inet_request_sock req;
234#ifdef CONFIG_TCP_MD5SIG 276#ifdef CONFIG_TCP_MD5SIG
235 /* Only used by TCP MD5 Signature so far. */ 277 /* Only used by TCP MD5 Signature so far. */
236 const struct tcp_request_sock_ops *af_specific; 278 const struct tcp_request_sock_ops *af_specific;
237#endif 279#endif
238 u32 rcv_isn; 280 u32 rcv_isn;
239 u32 snt_isn; 281 u32 snt_isn;
240}; 282};
241 283
242static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req) 284static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
@@ -406,6 +448,12 @@ struct tcp_sock {
406/* TCP MD5 Signature Option information */ 448/* TCP MD5 Signature Option information */
407 struct tcp_md5sig_info *md5sig_info; 449 struct tcp_md5sig_info *md5sig_info;
408#endif 450#endif
451
452 /* When the cookie options are generated and exchanged, then this
453 * object holds a reference to them (cookie_values->kref). Also
454 * contains related tcp_cookie_transactions fields.
455 */
456 struct tcp_cookie_values *cookie_values;
409}; 457};
410 458
411static inline struct tcp_sock *tcp_sk(const struct sock *sk) 459static inline struct tcp_sock *tcp_sk(const struct sock *sk)
@@ -424,6 +472,10 @@ struct tcp_timewait_sock {
424 u16 tw_md5_keylen; 472 u16 tw_md5_keylen;
425 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN]; 473 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN];
426#endif 474#endif
475 /* Few sockets in timewait have cookies; in that case, then this
476 * object holds a reference to them (tw_cookie_values->kref).
477 */
478 struct tcp_cookie_values *tw_cookie_values;
427}; 479};
428 480
429static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk) 481static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
@@ -431,6 +483,6 @@ static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
431 return (struct tcp_timewait_sock *)sk; 483 return (struct tcp_timewait_sock *)sk;
432} 484}
433 485
434#endif 486#endif /* __KERNEL__ */
435 487
436#endif /* _LINUX_TCP_H */ 488#endif /* _LINUX_TCP_H */