source: mainline/uspace/srv/net/tl/tcp/tcp_type.h@ 2a3214e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 2a3214e was 2a3214e, checked in by Jiri Svoboda <jiri@…>, 14 years ago

Fibril timer primitive.
TCP Time-Wait timeout.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup tcp
30 * @{
31 */
32/** @file TCP type definitions
33 */
34
35#ifndef TCP_TYPE_H
36#define TCP_TYPE_H
37
38#include <adt/list.h>
39#include <bool.h>
40#include <fibril_synch.h>
41#include <sys/types.h>
42
43struct tcp_conn;
44
45typedef enum {
46 /** Listen */
47 st_listen,
48 /** Syn-sent */
49 st_syn_sent,
50 /** Syn-received */
51 st_syn_received,
52 /** Established */
53 st_established,
54 /** Fin-wait-1 */
55 st_fin_wait_1,
56 /** Fin-wait-2 */
57 st_fin_wait_2,
58 /** Close-wait */
59 st_close_wait,
60 /** Closing */
61 st_closing,
62 /** Last-ack */
63 st_last_ack,
64 /** Time-wait */
65 st_time_wait,
66 /** Closed */
67 st_closed
68} tcp_cstate_t;
69
70typedef enum {
71 XF_PUSH = 0x1,
72 XF_URGENT = 0x2
73} xflags_t;
74
75typedef enum {
76 CTL_SYN = 0x1,
77 CTL_FIN = 0x2,
78 CTL_RST = 0x4,
79 CTL_ACK = 0x8
80} tcp_control_t;
81
82typedef struct {
83 uint32_t ipv4;
84} netaddr_t;
85
86typedef struct {
87 netaddr_t addr;
88 uint16_t port;
89} tcp_sock_t;
90
91typedef struct {
92 tcp_sock_t local;
93 tcp_sock_t foreign;
94} tcp_sockpair_t;
95
96typedef struct {
97 struct tcp_conn *conn;
98 list_t list;
99} tcp_iqueue_t;
100
101typedef struct {
102 struct tcp_conn *conn;
103 list_t list;
104} tcp_tqueue_t;
105
106typedef struct tcp_conn {
107 link_t link;
108
109 /** Connection identification (local and foreign socket) */
110 tcp_sockpair_t ident;
111
112 /** Connection state */
113 tcp_cstate_t cstate;
114
115 /** Set when FIN is removed from the retransmission queue */
116 bool fin_is_acked;
117
118 /** Queue of incoming segments */
119 tcp_iqueue_t incoming;
120
121 /** Retransmission queue */
122 tcp_tqueue_t retransmit;
123
124 /** Time-Wait timeout timer */
125 fibril_timer_t *tw_timer;
126
127 /** Receive buffer */
128 uint8_t *rcv_buf;
129 /** Receive buffer size */
130 size_t rcv_buf_size;
131 /** Receive buffer number of bytes used */
132 size_t rcv_buf_used;
133 /** Receive buffer contains FIN */
134 bool rcv_buf_fin;
135 /** Receive buffer lock */
136 fibril_mutex_t rcv_buf_lock;
137 /** Receive buffer CV. Broadcast when new data is inserted */
138 fibril_condvar_t rcv_buf_cv;
139
140 /** Send buffer */
141 uint8_t *snd_buf;
142 /** Send buffer size */
143 size_t snd_buf_size;
144 /** Send buffer number of bytes used */
145 size_t snd_buf_used;
146 /** Send buffer contains FIN */
147 bool snd_buf_fin;
148
149 /** Send unacknowledged */
150 uint32_t snd_una;
151 /** Send next */
152 uint32_t snd_nxt;
153 /** Send window */
154 uint32_t snd_wnd;
155 /** Send urgent pointer */
156 uint32_t snd_up;
157 /** Segment sequence number used for last window update */
158 uint32_t snd_wl1;
159 /** Segment acknowledgement number used for last window update */
160 uint32_t snd_wl2;
161 /** Initial send sequence number */
162 uint32_t iss;
163
164 /** Receive next */
165 uint32_t rcv_nxt;
166 /** Receive window */
167 uint32_t rcv_wnd;
168 /** Receive urgent pointer */
169 uint32_t rcv_up;
170 /** Initial receive sequence number */
171 uint32_t irs;
172} tcp_conn_t;
173
174typedef struct {
175 unsigned dummy;
176} tcp_conn_status_t;
177
178typedef struct {
179 /** SYN, FIN */
180 tcp_control_t ctrl;
181
182 /** Segment sequence number */
183 uint32_t seq;
184 /** Segment acknowledgement number */
185 uint32_t ack;
186 /** Segment length in sequence space */
187 uint32_t len;
188 /** Segment window */
189 uint32_t wnd;
190 /** Segment urgent pointer */
191 uint32_t up;
192
193 /** Segment data, may be moved when trimming segment */
194 void *data;
195 /** Segment data, original pointer used to free data */
196 void *dfptr;
197} tcp_segment_t;
198
199typedef enum {
200 ap_active,
201 ap_passive
202} acpass_t;
203
204typedef struct {
205 link_t link;
206 tcp_sockpair_t sp;
207 tcp_segment_t *seg;
208} tcp_rqueue_entry_t;
209
210typedef struct {
211 link_t link;
212 tcp_segment_t *seg;
213} tcp_iqueue_entry_t;
214
215typedef struct {
216 link_t link;
217 tcp_segment_t *seg;
218} tcp_tqueue_entry_t;
219
220typedef enum {
221 cp_continue,
222 cp_done
223} cproc_t;
224
225#endif
226
227/** @}
228 */
Note: See TracBrowser for help on using the repository browser.