2 utcp.h -- Userspace TCP
3 Copyright (C) 2014 Guus Sliepen <guus@tinc-vpn.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #define PREP(l) char pkt[(l) + sizeof struct hdr]; struct hdr *hdr = &pkt;
34 #define DEFAULT_SNDBUFSIZE 4096
35 #define DEFAULT_MAXSNDBUFSIZE 131072
36 #define DEFAULT_RCVBUFSIZE 0
37 #define DEFAULT_MAXRCVBUFSIZE 131072
39 #define DEFAULT_MTU 1000
41 #define DEFAULT_USER_TIMEOUT 60 // s
44 uint16_t src; // Source port
45 uint16_t dst; // Destination port
46 uint32_t seq; // Sequence number
47 uint32_t ack; // Acknowledgement number
48 uint32_t wnd; // Window size
49 uint16_t ctl; // Flags (SYN, ACK, FIN, RST)
50 uint16_t aux; // other stuff
67 static const char *strstate[] __attribute__((unused)) = {
70 [SYN_SENT] = "SYN_SENT",
71 [SYN_RECEIVED] = "SYN_RECEIVED",
72 [ESTABLISHED] = "ESTABLISHED",
73 [FIN_WAIT_1] = "FIN_WAIT_1",
74 [FIN_WAIT_2] = "FIN_WAIT_2",
75 [CLOSE_WAIT] = "CLOSE_WAIT",
76 [CLOSING] = "CLOSING",
77 [LAST_ACK] = "LAST_ACK",
78 [TIME_WAIT] = "TIME_WAIT"
93 struct utcp_connection {
130 struct timeval conn_timeout;
131 struct timeval rtrx_timeout;
135 struct buffer sndbuf;
136 struct buffer rcvbuf;
137 struct sack sacks[NSACKS];
139 // Per-socket options
144 // Congestion avoidance state
146 struct timeval tlast;
155 utcp_accept_t accept;
156 utcp_pre_accept_t pre_accept;
159 // Global socket options
164 // Connection management
166 struct utcp_connection **connections;