Import 2.3.25pre1
[davej-history.git] / include / linux / tcp.h
blob73796d6c431a60c70b23ebd4b652ff5d4a29f77c
1 /*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
6 * Definitions for the TCP protocol.
8 * Version: @(#)tcp.h 1.0.2 04/28/93
10 * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 #ifndef _LINUX_TCP_H
18 #define _LINUX_TCP_H
20 #include <linux/types.h>
21 #include <asm/byteorder.h>
23 struct tcphdr {
24 __u16 source;
25 __u16 dest;
26 __u32 seq;
27 __u32 ack_seq;
28 #if defined(__LITTLE_ENDIAN_BITFIELD)
29 __u16 res1:4,
30 doff:4,
31 fin:1,
32 syn:1,
33 rst:1,
34 psh:1,
35 ack:1,
36 urg:1,
37 res2:2;
38 #elif defined(__BIG_ENDIAN_BITFIELD)
39 __u16 doff:4,
40 res1:4,
41 res2:2,
42 urg:1,
43 ack:1,
44 psh:1,
45 rst:1,
46 syn:1,
47 fin:1;
48 #else
49 #error "Adjust your <asm/byteorder.h> defines"
50 #endif
51 __u16 window;
52 __u16 check;
53 __u16 urg_ptr;
57 enum {
58 TCP_ESTABLISHED = 1,
59 TCP_SYN_SENT,
60 TCP_SYN_RECV,
61 TCP_FIN_WAIT1,
62 TCP_FIN_WAIT2,
63 TCP_TIME_WAIT,
64 TCP_CLOSE,
65 TCP_CLOSE_WAIT,
66 TCP_LAST_ACK,
67 TCP_LISTEN,
68 TCP_CLOSING, /* now a valid state */
70 TCP_MAX_STATES /* Leave at the end! */
73 #define TCP_STATE_MASK 0xF
74 #define TCP_ACTION_FIN (1 << 7)
76 enum {
77 TCPF_ESTABLISHED = (1 << 1),
78 TCPF_SYN_SENT = (1 << 2),
79 TCPF_SYN_RECV = (1 << 3),
80 TCPF_FIN_WAIT1 = (1 << 4),
81 TCPF_FIN_WAIT2 = (1 << 5),
82 TCPF_TIME_WAIT = (1 << 6),
83 TCPF_CLOSE = (1 << 7),
84 TCPF_CLOSE_WAIT = (1 << 8),
85 TCPF_LAST_ACK = (1 << 9),
86 TCPF_LISTEN = (1 << 10),
87 TCPF_CLOSING = (1 << 11)
91 * The union cast uses a gcc extension to avoid aliasing problems
92 * (union is compatible to any of its members)
93 * This means this part of the code is -fstrict-aliasing safe now.
95 union tcp_word_hdr {
96 struct tcphdr hdr;
97 __u32 words[5];
98 };
100 #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
102 enum {
103 TCP_FLAG_URG = __constant_htonl(0x00200000),
104 TCP_FLAG_ACK = __constant_htonl(0x00100000),
105 TCP_FLAG_PSH = __constant_htonl(0x00080000),
106 TCP_FLAG_RST = __constant_htonl(0x00040000),
107 TCP_FLAG_SYN = __constant_htonl(0x00020000),
108 TCP_FLAG_FIN = __constant_htonl(0x00010000),
109 TCP_RESERVED_BITS = __constant_htonl(0x0FC00000),
110 TCP_DATA_OFFSET = __constant_htonl(0xF0000000)
113 #endif /* _LINUX_TCP_H */