00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00037 #ifndef NET_TCP_H_
00038 #define NET_TCP_H_
00039
00040 #include <fibril_synch.h>
00041
00042 #include <net/packet.h>
00043 #include <net/device.h>
00044 #include <socket_core.h>
00045 #include <tl_common.h>
00046
00050 typedef struct tcp_globals tcp_globals_t;
00051
00055 typedef struct tcp_socket_data tcp_socket_data_t;
00056
00060 typedef struct tcp_operation tcp_operation_t;
00061
00065 typedef enum tcp_socket_state tcp_socket_state_t;
00066
00068 enum tcp_socket_state {
00073 TCP_SOCKET_INITIAL,
00074
00081 TCP_SOCKET_LISTEN,
00082
00088 TCP_SOCKET_SYN_SENT,
00089
00095 TCP_SOCKET_SYN_RECEIVED,
00096
00101 TCP_SOCKET_ESTABLISHED,
00102
00112 TCP_SOCKET_FIN_WAIT_1,
00113
00120 TCP_SOCKET_FIN_WAIT_2,
00121
00129 TCP_SOCKET_CLOSING,
00130
00138 TCP_SOCKET_CLOSE_WAIT,
00139
00145 TCP_SOCKET_LAST_ACK,
00146
00152 TCP_SOCKET_TIME_WAIT,
00153
00159 TCP_SOCKET_CLOSED
00160 };
00161
00163 struct tcp_operation {
00165 int result;
00167 fibril_mutex_t mutex;
00169 fibril_condvar_t condvar;
00170 };
00171
00173 struct tcp_socket_data {
00175 tcp_socket_state_t state;
00176
00181 size_t data_fragment_size;
00182
00184 device_id_t device_id;
00185
00190 int backlog;
00191
00196 int listening_socket_id;
00197
00199 size_t treshold;
00201 size_t window;
00203 suseconds_t timeout;
00205 uint32_t acknowledged;
00207 uint32_t next_incoming;
00209 uint32_t fin_incoming;
00211 uint32_t next_outgoing;
00213 uint32_t last_outgoing;
00215 uint32_t fin_outgoing;
00216
00222 uint32_t expected;
00223
00229 int expected_count;
00230
00238 packet_t *incoming;
00239
00248 packet_t *outgoing;
00249
00251 void *pseudo_header;
00253 size_t headerlen;
00255 struct sockaddr *addr;
00257 socklen_t addrlen;
00259 uint16_t dest_port;
00261 socket_cores_t *local_sockets;
00262
00272 fibril_rwlock_t *local_lock;
00273
00275 tcp_operation_t operation;
00276
00281 int timeout_count;
00282 };
00283
00285 struct tcp_globals {
00287 int net_phone;
00289 int ip_phone;
00291 int icmp_phone;
00293 int last_used_port;
00295 socket_ports_t sockets;
00297 packet_dimensions_t dimensions;
00298
00303 fibril_rwlock_t lock;
00304 };
00305
00306 #endif
00307