tcp.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008 Lukas Mejdrech
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 

Generated on Thu Jun 2 07:45:50 2011 for HelenOS/USB by  doxygen 1.4.7