Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,360 +0,0 @@
1
-/*
2
- * Copyright (C) 2001-2003 FhG Fokus
3
- *
4
- * This file is part of Kamailio, a free SIP server.
5
- *
6
- * Kamailio is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version
10
- *
11
- * Kamailio is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
- *
20
- */
21
-
22
-#ifndef _tcp_conn_h
23
-#define _tcp_conn_h
24
-
25
-#include "tcp_init.h"
26
-#include "tcp_options.h"
27
-
28
-#include "ip_addr.h"
29
-#include "locking.h"
30
-#include "atomic_ops.h"
31
-#include "timer_ticks.h"
32
-#include "timer.h"
33
-
34
-/* maximum number of port aliases x search wildcard possibilities */
35
-#define TCP_CON_MAX_ALIASES (4*3) 
36
-
37
-#define TCP_CHILD_TIMEOUT 5 /* after 5 seconds, the child "returns" 
38
-							 the connection to the tcp master process */
39
-#define TCP_MAIN_SELECT_TIMEOUT 5 /* how often "tcp main" checks for timeout*/
40
-#define TCP_CHILD_SELECT_TIMEOUT 2 /* the same as above but for children */
41
-
42
-
43
-/* tcp connection flags */
44
-#define F_CONN_READ_W       2 /* watched for READ ev. in main */
45
-#define F_CONN_WRITE_W      4 /* watched for WRITE (main) */
46
-#define F_CONN_READER       8 /* handled by a tcp reader */
47
-#define F_CONN_HASHED      16 /* in tcp_main hash */
48
-#define F_CONN_FD_CLOSED   32 /* fd was already closed */
49
-#define F_CONN_PENDING     64 /* pending connect  (fd not known yet in main) */
50
-#define F_CONN_MAIN_TIMER 128 /* timer active in the tcp_main process */
51
-#define F_CONN_EOF_SEEN   256 /* FIN or RST have been received */
52
-#define F_CONN_FORCE_EOF  512 /* act as if an EOF was received */
53
-#define F_CONN_OOB_DATA  1024 /* out of band data on the connection */
54
-#define F_CONN_WR_ERROR  2048 /* write error on the fd */
55
-#define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
56
-#define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
57
-#define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
58
-#define F_CONN_CLOSE_EV 32768 /* explicitely call tcpops ev route when closed */
59
-
60
-#ifndef NO_READ_HTTP11
61
-#define READ_HTTP11
62
-#endif
63
-
64
-#ifndef NO_READ_MSRP
65
-#define READ_MSRP
66
-#endif
67
-
68
-#ifndef NO_READ_WS
69
-#define READ_WS
70
-#endif
71
-
72
-enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
73
-						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
74
-enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
75
-		H_SKIP_EMPTY_CRLF_FOUND, H_SKIP_EMPTY_CRLFCR_FOUND,
76
-		H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
77
-		H_CONT_LEN1, H_CONT_LEN2, H_CONT_LEN3, H_CONT_LEN4, H_CONT_LEN5,
78
-		H_CONT_LEN6, H_CONT_LEN7, H_CONT_LEN8, H_CONT_LEN9, H_CONT_LEN10,
79
-		H_CONT_LEN11, H_CONT_LEN12, H_CONT_LEN13, H_L_COLON, 
80
-		H_CONT_LEN_BODY, H_CONT_LEN_BODY_PARSE,
81
-		H_STUN_MSG, H_STUN_READ_BODY, H_STUN_FP, H_STUN_END, H_PING_CRLF
82
-#ifdef READ_HTTP11
83
-		, H_HTTP11_CHUNK_START, H_HTTP11_CHUNK_SIZE,
84
-		H_HTTP11_CHUNK_BODY, H_HTTP11_CHUNK_END, H_HTTP11_CHUNK_FINISH
85
-#endif
86
-#ifdef READ_MSRP
87
-		, H_MSRP_BODY, H_MSRP_BODY_LF, H_MSRP_BODY_END, H_MSRP_FINISH
88
-#endif
89
-	};
90
-
91
-enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
92
-						S_CONN_OK=0, /* established (write or read) */
93
-						S_CONN_INIT, /* initial state (invalid) */
94
-						S_CONN_EOF,
95
-						S_CONN_ACCEPT, S_CONN_CONNECT
96
-					};
97
-
98
-
99
-/* fd communication commands */
100
-enum conn_cmds {
101
-	CONN_DESTROY=-3 /* destroy connection & auto-dec. refcnt */,
102
-	CONN_ERROR=-2   /* error on connection & auto-dec. refcnt */,
103
-	CONN_EOF=-1     /* eof received or conn. closed & auto-dec refcnt */,
104
-	CONN_NOP=0      /* do-nothing (invalid for tcp_main) */,
105
-	CONN_RELEASE    /* release a connection from tcp_read back into tcp_main
106
-					   & auto-dec refcnt */,
107
-	CONN_GET_FD     /* request a fd from tcp_main */,
108
-	CONN_NEW        /* update/set a fd int a new tcp connection; refcnts are
109
-					  not touched */,
110
-	CONN_QUEUED_WRITE /* new write queue: start watching the fd for write &
111
-						 auto-dec refcnt */,
112
-	CONN_NEW_PENDING_WRITE /* like CONN_NEW+CONN_QUEUED_WRITE: set fd and
113
-							  start watching it for write (write queue
114
-							  non-empty); refcnts are not touced */,
115
-	CONN_NEW_COMPLETE  /* like CONN_NEW_PENDING_WRITE, but there is no
116
-						  pending write (the write queue might be empty) */
117
-};
118
-/* CONN_RELEASE, EOF, ERROR, DESTROY can be used by "reader" processes
119
- * CONN_GET_FD, CONN_NEW*, CONN_QUEUED_WRITE only by writers */
120
-
121
-struct tcp_req{
122
-	struct tcp_req* next;
123
-	/* sockaddr ? */
124
-	char* buf; /* bytes read so far (+0-terminator)*/
125
-	char* start; /* where the message starts, after all the empty lines are
126
-					skipped*/
127
-	char* pos; /* current position in buf */
128
-	char* parsed; /* last parsed position */
129
-	char* body; /* body position */
130
-	unsigned int b_size; /* buffer size-1 (extra space for 0-term)*/
131
-	int content_len;
132
-#ifdef READ_HTTP11
133
-	int chunk_size;
134
-#endif
135
-	unsigned short flags; /* F_TCP_REQ_HAS_CLEN | F_TCP_REQ_COMPLETE */
136
-	int bytes_to_go; /* how many bytes we have still to read from the body*/
137
-	enum tcp_req_errors error;
138
-	enum tcp_req_states state;
139
-};
140
-
141
-/* tcp_req flags */
142
-#define F_TCP_REQ_HAS_CLEN 1
143
-#define F_TCP_REQ_COMPLETE 2
144
-#ifdef READ_HTTP11
145
-#define F_TCP_REQ_BCHUNKED 4
146
-#endif
147
-#ifdef READ_MSRP
148
-#define F_TCP_REQ_MSRP_NO     8
149
-#define F_TCP_REQ_MSRP_FRAME  16
150
-#define F_TCP_REQ_MSRP_BODY   32
151
-#endif
152
-
153
-#define TCP_REQ_HAS_CLEN(tr)  ((tr)->flags & F_TCP_REQ_HAS_CLEN)
154
-#define TCP_REQ_COMPLETE(tr)  ((tr)->flags & F_TCP_REQ_COMPLETE)
155
-#ifdef READ_HTTP11
156
-#define TCP_REQ_BCHUNKED(tr)  ((tr)->flags & F_TCP_REQ_BCHUNKED)
157
-#endif
158
-
159
-
160
-struct tcp_connection;
161
-
162
-/* tcp port alias structure */
163
-struct tcp_conn_alias{
164
-	struct tcp_connection* parent;
165
-	struct tcp_conn_alias* next;
166
-	struct tcp_conn_alias* prev;
167
-	unsigned short port; /* alias port */
168
-	unsigned short hash; /* hash index in the address hash */
169
-};
170
-
171
-
172
-#ifdef TCP_ASYNC
173
-	struct tcp_wbuffer{
174
-		struct tcp_wbuffer* next;
175
-		unsigned int b_size;
176
-		char buf[1];
177
-	};
178
-
179
-	struct tcp_wbuffer_queue{
180
-		struct tcp_wbuffer* first;
181
-		struct tcp_wbuffer* last;
182
-		ticks_t wr_timeout; /* write timeout*/
183
-		unsigned int queued; /* total size */
184
-		unsigned int offset; /* offset in the first wbuffer were data
185
-								starts */
186
-		unsigned int last_used; /* how much of the last buffer is used */
187
-	};
188
-#endif
189
-
190
-
191
-struct tcp_connection{
192
-	int s; /*socket, used by "tcp main" */
193
-	int fd; /* used only by "children", don't modify it! private data! */
194
-	gen_lock_t write_lock;
195
-	int id; /* id (unique!) used to retrieve a specific connection when
196
-	           reply-ing*/
197
-	int reader_pid; /* pid of the active reader process */
198
-	struct receive_info rcv; /* src & dst ip, ports, proto a.s.o*/
199
-	struct tcp_req req; /* request data */
200
-	atomic_t refcnt;
201
-	enum sip_protos type; /* PROTO_TCP or a protocol over it, e.g. TLS */
202
-	unsigned short flags; /* connection related flags */
203
-	snd_flags_t send_flags; /* special send flags */
204
-	enum tcp_conn_states state; /* connection state */
205
-	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
206
-	struct timer_ln timer;
207
-	ticks_t timeout;/* connection timeout, after this it will be removed*/
208
-	ticks_t lifetime;/* connection lifetime */
209
-	unsigned id_hash; /* hash index in the id_hash */
210
-	struct tcp_connection* id_next; /* next, prev in id hash table */
211
-	struct tcp_connection* id_prev;
212
-	struct tcp_connection* c_next; /* child next prev (use locally) */
213
-	struct tcp_connection* c_prev;
214
-	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
215
-	int aliases; /* aliases number, at least 1 */
216
-#ifdef TCP_ASYNC
217
-	struct tcp_wbuffer_queue wbuf_q;
218
-#endif
219
-};
220
-
221
-
222
-/* helper macros */
223
-
224
-#define tcpconn_set_send_flags(c, snd_flags) \
225
-	SND_FLAGS_OR(&(c)->send_flags, &(c)->send_flags, &(snd_flags))
226
-
227
-#define tcpconn_close_after_send(c)	((c)->send_flags.f & SND_F_CON_CLOSE)
228
-
229
-#define TCP_RCV_INFO(c) (&(c)->rcv)
230
-
231
-#define TCP_RCV_LADDR(r) (&((r).dst_ip))
232
-#define TCP_RCV_LPORT(r) ((r).dst_port)
233
-#define TCP_RCV_PADDR(r)  (&((r).src_ip))
234
-#define TCP_RCV_PPORT(r)  ((r).src_port)
235
-#define TCP_RCV_PSU(r)   (&(r).src_su)
236
-#define TCP_RCV_SOCK_INFO(r)  ((r).bind_address)
237
-#define TCP_RCV_PROTO(r)      ((r).proto)
238
-#ifdef USE_COMP
239
-#define TCP_RCV_COMP(r)       ((r).comp)
240
-#else
241
-#define TCP_RCV_COMP(r)  0
242
-#endif /* USE_COMP */
243
-
244
-#define TCP_LADDR(c) TCP_RCV_LADDR(c->rcv)
245
-#define TCP_LPORT(c) TCP_RCV_LPORT(c->rcv)
246
-#define TCP_PADDR(c) TCP_RCV_PADDR(c->rcv)
247
-#define TCP_PPORT(c) TCP_RCV_PPORT(c->rcv)
248
-#define TCP_PSU(c)   TCP_RCV_PSU(c->rcv)
249
-#define TCP_SOCK_INFO(c) TCP_RCV_SOCK_INFO(c->rcv)
250
-#define TCP_PROTO(c) TCP_RCV_PROTO(c->rcv)
251
-#define TCP_COMP(c) TCP_RCV_COMP(c->rcv)
252
-
253
-
254
-
255
-#define tcpconn_ref(c) atomic_inc(&((c)->refcnt))
256
-#define tcpconn_put(c) atomic_dec_and_test(&((c)->refcnt))
257
-
258
-
259
-#define init_tcp_req( r, rd_buf, rd_buf_size) \
260
-	do{ \
261
-		memset( (r), 0, sizeof(struct tcp_req)); \
262
-		(r)->buf=(rd_buf) ;\
263
-		(r)->b_size=(rd_buf_size)-1; /* space for 0 term. */ \
264
-		(r)->parsed=(r)->pos=(r)->start=(r)->buf; \
265
-		(r)->error=TCP_REQ_OK;\
266
-		(r)->state=H_SKIP_EMPTY; \
267
-	}while(0)
268
-
269
-
270
-/* add a tcpconn to a list*/
271
-/* list head, new element, next member, prev member */
272
-#define tcpconn_listadd(head, c, next, prev) \
273
-	do{ \
274
-		/* add it at the begining of the list*/ \
275
-		(c)->next=(head); \
276
-		(c)->prev=0; \
277
-		if ((head)) (head)->prev=(c); \
278
-		(head)=(c); \
279
-	} while(0)
280
-
281
-
282
-/* remove a tcpconn from a list*/
283
-#define tcpconn_listrm(head, c, next, prev) \
284
-	do{ \
285
-		if ((head)==(c)) (head)=(c)->next; \
286
-		if ((c)->next) (c)->next->prev=(c)->prev; \
287
-		if ((c)->prev) (c)->prev->next=(c)->next; \
288
-	}while(0)
289
-
290
-
291
-#define TCPCONN_LOCK lock_get(tcpconn_lock);
292
-#define TCPCONN_UNLOCK lock_release(tcpconn_lock);
293
-
294
-#define TCP_ALIAS_HASH_SIZE 4096
295
-#define TCP_ID_HASH_SIZE 1024
296
-
297
-/* hash (dst_ip, dst_port, local_ip, local_port) */
298
-static inline unsigned tcp_addr_hash(	struct ip_addr* ip, 
299
-										unsigned short port,
300
-										struct ip_addr* l_ip,
301
-										unsigned short l_port)
302
-{
303
-	unsigned h;
304
-
305
-	if(ip->len==4)
306
-		h=(ip->u.addr32[0]^port)^(l_ip->u.addr32[0]^l_port);
307
-	else if (ip->len==16) 
308
-		h= (ip->u.addr32[0]^ip->u.addr32[1]^ip->u.addr32[2]^
309
-				ip->u.addr32[3]^port) ^
310
-			(l_ip->u.addr32[0]^l_ip->u.addr32[1]^l_ip->u.addr32[2]^
311
-				l_ip->u.addr32[3]^l_port);
312
-	else{
313
-		LM_CRIT("bad len %d for an ip address\n", ip->len);
314
-		return 0;
315
-	}
316
-	/* make sure the first bits are influenced by all 32
317
-	 * (the first log2(TCP_ALIAS_HASH_SIZE) bits should be a mix of all
318
-	 *  32)*/
319
-	h ^= h>>17;
320
-	h ^= h>>7;
321
-	return h & (TCP_ALIAS_HASH_SIZE-1);
322
-}
323
-
324
-#define tcp_id_hash(id) (id&(TCP_ID_HASH_SIZE-1))
325
-
326
-struct tcp_connection* tcpconn_get(int id, struct ip_addr* ip, int port,
327
-									union sockaddr_union* local_addr,
328
-									ticks_t timeout);
329
-
330
-typedef struct tcp_event_info {
331
-	int type;
332
-	char *buf;
333
-	unsigned int len;
334
-	struct receive_info *rcv;
335
-	struct tcp_connection *con;
336
-} tcp_event_info_t;
337
-
338
-enum tcp_closed_reason {
339
-	TCP_CLOSED_EOF = 0,
340
-	TCP_CLOSED_TIMEOUT,
341
-	TCP_CLOSED_RESET,
342
-
343
-	_TCP_CLOSED_REASON_MAX /* /!\ keep this one always at the end */
344
-};
345
-
346
-typedef struct tcp_closed_event_info {
347
-	enum tcp_closed_reason reason;
348
-	struct tcp_connection *con;
349
-} tcp_closed_event_info_t;
350
-
351
-typedef struct ws_event_info {
352
-	int type;
353
-	char *buf;
354
-	unsigned int len;
355
-	int id;
356
-} ws_event_info_t;
357
-
358
-#endif
359
-
360
-
Browse code

core: dedicated struct for TCP closed events

this will allow to differentiate between the different reasons for
connection closed events

Camille Oudot authored on 06/10/2016 14:42:40
Showing 1 changed files
... ...
@@ -335,6 +335,19 @@ typedef struct tcp_event_info {
335 335
 	struct tcp_connection *con;
336 336
 } tcp_event_info_t;
337 337
 
338
+enum tcp_closed_reason {
339
+	TCP_CLOSED_EOF = 0,
340
+	TCP_CLOSED_TIMEOUT,
341
+	TCP_CLOSED_RESET,
342
+
343
+	_TCP_CLOSED_REASON_MAX /* /!\ keep this one always at the end */
344
+};
345
+
346
+typedef struct tcp_closed_event_info {
347
+	enum tcp_closed_reason reason;
348
+	struct tcp_connection *con;
349
+} tcp_closed_event_info_t;
350
+
338 351
 typedef struct ws_event_info {
339 352
 	int type;
340 353
 	char *buf;
Browse code

tcp: define new flag to control tcpop's tcp:closed

for enhancement #461

Camille Oudot authored on 29/01/2016 17:18:19
Showing 1 changed files
... ...
@@ -55,6 +55,7 @@
55 55
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
56 56
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
57 57
 #define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
58
+#define F_CONN_CLOSE_EV 32768 /* explicitely call tcpops ev route when closed */
58 59
 
59 60
 #ifndef NO_READ_HTTP11
60 61
 #define READ_HTTP11
Browse code

core: add support for per-TCP connection lifetime

Camille Oudot authored on 19/02/2015 15:50:11
Showing 1 changed files
... ...
@@ -204,6 +204,7 @@ struct tcp_connection{
204 204
 	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
205 205
 	struct timer_ln timer;
206 206
 	ticks_t timeout;/* connection timeout, after this it will be removed*/
207
+	ticks_t lifetime;/* connection lifetime */
207 208
 	unsigned id_hash; /* hash index in the id_hash */
208 209
 	struct tcp_connection* id_next; /* next, prev in id hash table */
209 210
 	struct tcp_connection* id_prev;
Browse code

core: Modify doxygen, remove history, remove SVN IDs, change "ser" and "sip-router" to "KAMAILIO"

Olle E. Johansson authored on 16/01/2015 16:38:46
Showing 1 changed files
... ...
@@ -1,21 +1,14 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2001-2003 FhG Fokus
5 3
  *
6
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
7 5
  *
8
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
9 7
  * it under the terms of the GNU General Public License as published by
10 8
  * the Free Software Foundation; either version 2 of the License, or
11 9
  * (at your option) any later version
12 10
  *
13
- * For a license to use the ser software under conditions
14
- * other than those described here, or to purchase support for this
15
- * software, please contact iptel.org by e-mail at the following addresses:
16
- *    info@iptel.org
17
- *
18
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
19 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 14
  * GNU General Public License for more details.
... ...
@@ -24,21 +17,8 @@
24 17
  * along with this program; if not, write to the Free Software
25 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 19
  *
27
- *
28
- * History:
29
- * --------
30
- *  2003-01-29  tcp buffer size ++-ed to allow for 0-terminator
31
- *  2003-06-30  added tcp_connection flags & state (andrei) 
32
- *  2003-10-27  tcp port aliases support added (andrei)
33
- *  2006-10-13  added tcp_req_states for STUN (vlada)
34
- *  2007-07-26  improved tcp connection hash function; increased aliases
35
- *               hash size (andrei)
36
- *  2007-11-26  switched to local_timer (andrei)
37
- *  2007-11-30  buffered write support (andrei)
38 20
  */
39 21
 
40
-
41
-
42 22
 #ifndef _tcp_conn_h
43 23
 #define _tcp_conn_h
44 24
 
Browse code

tcp_conn.h: logging: convert LOG to LM_*

Ovidiu Sas authored on 03/10/2014 20:45:07
Showing 1 changed files
... ...
@@ -328,8 +328,7 @@ static inline unsigned tcp_addr_hash(	struct ip_addr* ip,
328 328
 			(l_ip->u.addr32[0]^l_ip->u.addr32[1]^l_ip->u.addr32[2]^
329 329
 				l_ip->u.addr32[3]^l_port);
330 330
 	else{
331
-		LOG(L_CRIT, "tcp_addr_hash: BUG: bad len %d for an ip address\n",
332
-				ip->len);
331
+		LM_CRIT("bad len %d for an ip address\n", ip->len);
333 332
 		return 0;
334 333
 	}
335 334
 	/* make sure the first bits are influenced by all 32
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -22,7 +22,7 @@
22 22
  *
23 23
  * You should have received a copy of the GNU General Public License
24 24
  * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
26 26
  *
27 27
  *
28 28
  * History:
Browse code

core: Changed WS from being a flag on a TCP/TLS connection to a protocol in its own right

- Also added ;transport=ws parameter parsing for URIs

Peter Dunkley authored on 29/06/2012 16:44:15
Showing 1 changed files
... ...
@@ -75,7 +75,6 @@
75 75
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
76 76
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
77 77
 #define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
78
-#define F_CONN_WS	32768 /* conn. is a websocket */
79 78
 
80 79
 #ifndef NO_READ_HTTP11
81 80
 #define READ_HTTP11
Browse code

core: added events and data-structures so that Kamailio core can transmit through the WebSocket module

Peter Dunkley authored on 23/06/2012 18:10:03
Showing 1 changed files
... ...
@@ -355,6 +355,13 @@ typedef struct tcp_event_info {
355 355
 	struct tcp_connection *con;
356 356
 } tcp_event_info_t;
357 357
 
358
+typedef struct ws_event_info {
359
+	int type;
360
+	char *buf;
361
+	unsigned int len;
362
+	int id;
363
+} ws_event_info_t;
364
+
358 365
 #endif
359 366
 
360 367
 
Browse code

core: Added WS support/events to Kamailio core

Peter Dunkley authored on 16/06/2012 16:06:33
Showing 1 changed files
... ...
@@ -75,6 +75,7 @@
75 75
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
76 76
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
77 77
 #define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
78
+#define F_CONN_WS	32768 /* conn. is a websocket */
78 79
 
79 80
 #ifndef NO_READ_HTTP11
80 81
 #define READ_HTTP11
... ...
@@ -84,6 +85,10 @@
84 85
 #define READ_MSRP
85 86
 #endif
86 87
 
88
+#ifndef NO_READ_WS
89
+#define READ_WS
90
+#endif
91
+
87 92
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
88 93
 						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
89 94
 enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
Browse code

core: two more events for handling http and msrp

- one to be called for http/1.1 end of headers for checking on '100
Continue' request
- one to be called when a msrp message is received

Daniel-Constantin Mierla authored on 13/01/2012 11:46:20
Showing 1 changed files
... ...
@@ -342,6 +342,14 @@ struct tcp_connection* tcpconn_get(int id, struct ip_addr* ip, int port,
342 342
 									union sockaddr_union* local_addr,
343 343
 									ticks_t timeout);
344 344
 
345
+typedef struct tcp_event_info {
346
+	int type;
347
+	char *buf;
348
+	unsigned int len;
349
+	struct receive_info *rcv;
350
+	struct tcp_connection *con;
351
+} tcp_event_info_t;
352
+
345 353
 #endif
346 354
 
347 355
 
Browse code

core/tcp: support for receiving MSRP messages

- controlled by define READ_MSRP, on by default now, can be turned off
by defininf NO_READ_MSRP

Daniel-Constantin Mierla authored on 13/01/2012 11:17:24
Showing 1 changed files
... ...
@@ -80,10 +80,15 @@
80 80
 #define READ_HTTP11
81 81
 #endif
82 82
 
83
+#ifndef NO_READ_MSRP
84
+#define READ_MSRP
85
+#endif
86
+
83 87
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
84 88
 						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
85
-enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND, H_SKIP_EMPTY_CRLF_FOUND, H_SKIP_EMPTY_CRLFCR_FOUND,
86
-			H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
89
+enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND,
90
+		H_SKIP_EMPTY_CRLF_FOUND, H_SKIP_EMPTY_CRLFCR_FOUND,
91
+		H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
87 92
 		H_CONT_LEN1, H_CONT_LEN2, H_CONT_LEN3, H_CONT_LEN4, H_CONT_LEN5,
88 93
 		H_CONT_LEN6, H_CONT_LEN7, H_CONT_LEN8, H_CONT_LEN9, H_CONT_LEN10,
89 94
 		H_CONT_LEN11, H_CONT_LEN12, H_CONT_LEN13, H_L_COLON, 
... ...
@@ -92,6 +97,9 @@ enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND, H_SKIP_EMPTY_CRLF_FOU
92 97
 #ifdef READ_HTTP11
93 98
 		, H_HTTP11_CHUNK_START, H_HTTP11_CHUNK_SIZE,
94 99
 		H_HTTP11_CHUNK_BODY, H_HTTP11_CHUNK_END, H_HTTP11_CHUNK_FINISH
100
+#endif
101
+#ifdef READ_MSRP
102
+		, H_MSRP_BODY, H_MSRP_BODY_LF, H_MSRP_BODY_END, H_MSRP_FINISH
95 103
 #endif
96 104
 	};
97 105
 
... ...
@@ -151,6 +159,11 @@ struct tcp_req{
151 159
 #ifdef READ_HTTP11
152 160
 #define F_TCP_REQ_BCHUNKED 4
153 161
 #endif
162
+#ifdef READ_MSRP
163
+#define F_TCP_REQ_MSRP_NO     8
164
+#define F_TCP_REQ_MSRP_FRAME  16
165
+#define F_TCP_REQ_MSRP_BODY   32
166
+#endif
154 167
 
155 168
 #define TCP_REQ_HAS_CLEN(tr)  ((tr)->flags & F_TCP_REQ_HAS_CLEN)
156 169
 #define TCP_REQ_COMPLETE(tr)  ((tr)->flags & F_TCP_REQ_COMPLETE)
Browse code

core: make READ_HTTP11 on if NO_READ_HTTP11 is defined

- the code is anyhow enabled only when tcp_accept_no_cl is on
- suggested by Andrei

Daniel-Constantin Mierla authored on 01/09/2010 12:31:50
Showing 1 changed files
... ...
@@ -76,6 +76,9 @@
76 76
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
77 77
 #define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
78 78
 
79
+#ifndef NO_READ_HTTP11
80
+#define READ_HTTP11
81
+#endif
79 82
 
80 83
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
81 84
 						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
Browse code

tcp: read http/1.1 chunked body

- fix for xcap_server module that has to deal with PUT commands from
xcap clients
- code withing READ_HTTP11 defines (for now off by default)
- conditioned by tcp_accept_no_cl=yes
- able to handle cases of "Expect: 100-continue" and "Transfer-Encoding:
chunked"

Daniel-Constantin Mierla authored on 30/08/2010 08:35:46
Showing 1 changed files
... ...
@@ -86,6 +86,10 @@ enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND, H_SKIP_EMPTY_CRLF_FOU
86 86
 		H_CONT_LEN11, H_CONT_LEN12, H_CONT_LEN13, H_L_COLON, 
87 87
 		H_CONT_LEN_BODY, H_CONT_LEN_BODY_PARSE,
88 88
 		H_STUN_MSG, H_STUN_READ_BODY, H_STUN_FP, H_STUN_END, H_PING_CRLF
89
+#ifdef READ_HTTP11
90
+		, H_HTTP11_CHUNK_START, H_HTTP11_CHUNK_SIZE,
91
+		H_HTTP11_CHUNK_BODY, H_HTTP11_CHUNK_END, H_HTTP11_CHUNK_FINISH
92
+#endif
89 93
 	};
90 94
 
91 95
 enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
... ...
@@ -129,6 +133,9 @@ struct tcp_req{
129 133
 	char* body; /* body position */
130 134
 	unsigned int b_size; /* buffer size-1 (extra space for 0-term)*/
131 135
 	int content_len;
136
+#ifdef READ_HTTP11
137
+	int chunk_size;
138
+#endif
132 139
 	unsigned short flags; /* F_TCP_REQ_HAS_CLEN | F_TCP_REQ_COMPLETE */
133 140
 	int bytes_to_go; /* how many bytes we have still to read from the body*/
134 141
 	enum tcp_req_errors error;
... ...
@@ -138,9 +145,15 @@ struct tcp_req{
138 145
 /* tcp_req flags */
139 146
 #define F_TCP_REQ_HAS_CLEN 1
140 147
 #define F_TCP_REQ_COMPLETE 2
148
+#ifdef READ_HTTP11
149
+#define F_TCP_REQ_BCHUNKED 4
150
+#endif
141 151
 
142 152
 #define TCP_REQ_HAS_CLEN(tr)  ((tr)->flags & F_TCP_REQ_HAS_CLEN)
143 153
 #define TCP_REQ_COMPLETE(tr)  ((tr)->flags & F_TCP_REQ_COMPLETE)
154
+#ifdef READ_HTTP11
155
+#define TCP_REQ_BCHUNKED(tr)  ((tr)->flags & F_TCP_REQ_BCHUNKED)
156
+#endif
144 157
 
145 158
 
146 159
 struct tcp_connection;
Browse code

tcp: minor cleanups & spelling

- removed F_CONN_NON_BLOCKING (not used anymore)
- spelling & whitespace cleanups

Andrei Pelinescu-Onciul authored on 25/03/2010 19:29:32
Showing 1 changed files
... ...
@@ -61,7 +61,6 @@
61 61
 
62 62
 
63 63
 /* tcp connection flags */
64
-#define F_CONN_NON_BLOCKING 1
65 64
 #define F_CONN_READ_W       2 /* watched for READ ev. in main */
66 65
 #define F_CONN_WRITE_W      4 /* watched for WRITE (main) */
67 66
 #define F_CONN_READER       8 /* handled by a tcp reader */
Browse code

tcp: comments & new internal command

- commented the enum conn_cmds members
- added new cmd. CONN_NOP

Andrei Pelinescu-Onciul authored on 23/03/2010 16:54:12
Showing 1 changed files
... ...
@@ -98,11 +98,26 @@ enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
98 98
 
99 99
 
100 100
 /* fd communication commands */
101
-enum conn_cmds { CONN_DESTROY=-3, CONN_ERROR=-2, CONN_EOF=-1, CONN_RELEASE, 
102
-					CONN_GET_FD, CONN_NEW, CONN_QUEUED_WRITE,
103
-					CONN_NEW_PENDING_WRITE, CONN_NEW_COMPLETE };
101
+enum conn_cmds {
102
+	CONN_DESTROY=-3 /* destroy connection & auto-dec. refcnt */,
103
+	CONN_ERROR=-2   /* error on connection & auto-dec. refcnt */,
104
+	CONN_EOF=-1     /* eof received or conn. closed & auto-dec refcnt */,
105
+	CONN_NOP=0      /* do-nothing (invalid for tcp_main) */,
106
+	CONN_RELEASE    /* release a connection from tcp_read back into tcp_main
107
+					   & auto-dec refcnt */,
108
+	CONN_GET_FD     /* request a fd from tcp_main */,
109
+	CONN_NEW        /* update/set a fd int a new tcp connection; refcnts are
110
+					  not touched */,
111
+	CONN_QUEUED_WRITE /* new write queue: start watching the fd for write &
112
+						 auto-dec refcnt */,
113
+	CONN_NEW_PENDING_WRITE /* like CONN_NEW+CONN_QUEUED_WRITE: set fd and
114
+							  start watching it for write (write queue
115
+							  non-empty); refcnts are not touced */,
116
+	CONN_NEW_COMPLETE  /* like CONN_NEW_PENDING_WRITE, but there is no
117
+						  pending write (the write queue might be empty) */
118
+};
104 119
 /* CONN_RELEASE, EOF, ERROR, DESTROY can be used by "reader" processes
105
- * CONN_GET_FD, NEW, ERROR only by writers */
120
+ * CONN_GET_FD, CONN_NEW*, CONN_QUEUED_WRITE only by writers */
106 121
 
107 122
 struct tcp_req{
108 123
 	struct tcp_req* next;
Browse code

blacklist: ignore mask support

blacklist:
- a blacklist ignore mask (part of the send flags) is now
supported by the blacklist functions
- blacklist add functions don't require anymore checking if the
blacklist is enabled
- added dst_blacklist_force_add_to() and dst_blacklist_force_su_to()
tcp:
- updated to the changed dst_blacklist_su()
- a tcp connection send_flags and blacklist ignore mask are
inherited from the packet that opens the connection
sctp:
- updated to the changed dst_blacklist_su()

Andrei Pelinescu-Onciul authored on 23/12/2009 08:44:12
Showing 1 changed files
... ...
@@ -193,10 +193,7 @@ struct tcp_connection{
193 193
 /* helper macros */
194 194
 
195 195
 #define tcpconn_set_send_flags(c, snd_flags) \
196
-	do{ \
197
-		(c)->send_flags.f|=(snd_flags).f; \
198
-		(c)->send_flags.blst_imask|=(snd_flags).blst_imask; \
199
-	}while(0)
196
+	SND_FLAGS_OR(&(c)->send_flags, &(c)->send_flags, &(snd_flags))
200 197
 
201 198
 #define tcpconn_close_after_send(c)	((c)->send_flags.f & SND_F_CON_CLOSE)
202 199
 
Browse code

core: send_flags preliminary blacklist support

- send_flags_t contains now also a blacklist ignore mask (changed
to a structure).

Andrei Pelinescu-Onciul authored on 17/12/2009 07:39:53
Showing 1 changed files
... ...
@@ -172,7 +172,7 @@ struct tcp_connection{
172 172
 	atomic_t refcnt;
173 173
 	enum sip_protos type; /* PROTO_TCP or a protocol over it, e.g. TLS */
174 174
 	unsigned short flags; /* connection related flags */
175
-	unsigned short send_flags; /* special send flags */
175
+	snd_flags_t send_flags; /* special send flags */
176 176
 	enum tcp_conn_states state; /* connection state */
177 177
 	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
178 178
 	struct timer_ln timer;
... ...
@@ -192,9 +192,13 @@ struct tcp_connection{
192 192
 
193 193
 /* helper macros */
194 194
 
195
-#define tcpconn_set_send_flags(c, snd_flags) ((c)->send_flags|=(snd_flags))
195
+#define tcpconn_set_send_flags(c, snd_flags) \
196
+	do{ \
197
+		(c)->send_flags.f|=(snd_flags).f; \
198
+		(c)->send_flags.blst_imask|=(snd_flags).blst_imask; \
199
+	}while(0)
196 200
 
197
-#define tcpconn_close_after_send(c)	((c)->send_flags & SND_F_CON_CLOSE)
201
+#define tcpconn_close_after_send(c)	((c)->send_flags.f & SND_F_CON_CLOSE)
198 202
 
199 203
 #define TCP_RCV_INFO(c) (&(c)->rcv)
200 204
 
Browse code

tcp: remember which connections were accepted

Use a new flag to remember which connection were passively opened
(accept()) and which were locally initiated (connect).

Andrei Pelinescu-Onciul authored on 21/09/2009 16:39:41
Showing 1 changed files
... ...
@@ -75,6 +75,7 @@
75 75
 #define F_CONN_WR_ERROR  2048 /* write error on the fd */
76 76
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
77 77
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
78
+#define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
78 79
 
79 80
 
80 81
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
Browse code

tcp: send_flags support

Support for SND_F_FORCE_CON_REUSE and SND_F_CON_CLOSE added to the
tcp code.

Andrei Pelinescu-Onciul authored on 15/09/2009 15:45:41
Showing 1 changed files
... ...
@@ -170,7 +170,8 @@ struct tcp_connection{
170 170
 	struct tcp_req req; /* request data */
171 171
 	atomic_t refcnt;
172 172
 	enum sip_protos type; /* PROTO_TCP or a protocol over it, e.g. TLS */
173
-	int flags; /* connection related flags */
173
+	unsigned short flags; /* connection related flags */
174
+	unsigned short send_flags; /* special send flags */
174 175
 	enum tcp_conn_states state; /* connection state */
175 176
 	void* extra_data; /* extra data associated to the connection, 0 for tcp*/
176 177
 	struct timer_ln timer;
... ...
@@ -190,6 +191,10 @@ struct tcp_connection{
190 191
 
191 192
 /* helper macros */
192 193
 
194
+#define tcpconn_set_send_flags(c, snd_flags) ((c)->send_flags|=(snd_flags))
195
+
196
+#define tcpconn_close_after_send(c)	((c)->send_flags & SND_F_CON_CLOSE)
197
+
193 198
 #define TCP_RCV_INFO(c) (&(c)->rcv)
194 199
 
195 200
 #define TCP_RCV_LADDR(r) (&((r).dst_ip))
Browse code

tcp: helper internal macros

- helper macros for getting the local address & port, the peer
address & port, the protocol and the compression from a tcp
connection structure pointer.

Andrei Pelinescu-Onciul authored on 09/04/2009 19:10:31
Showing 1 changed files
... ...
@@ -188,6 +188,31 @@ struct tcp_connection{
188 188
 };
189 189
 
190 190
 
191
+/* helper macros */
192
+
193
+#define TCP_RCV_INFO(c) (&(c)->rcv)
194
+
195
+#define TCP_RCV_LADDR(r) (&((r).dst_ip))
196
+#define TCP_RCV_LPORT(r) ((r).dst_port)
197
+#define TCP_RCV_PADDR(r)  (&((r).src_ip))
198
+#define TCP_RCV_PPORT(r)  ((r).src_port)
199
+#define TCP_RCV_PSU(r)   (&(r).src_su)
200
+#define TCP_RCV_SOCK_INFO(r)  ((r).bind_address)
201
+#define TCP_RCV_PROTO(r)      ((r).proto)
202
+#ifdef USE_COMP
203
+#define TCP_RCV_COMP(r)       ((r).comp)
204
+#else
205
+#define TCP_RCV_COMP(r)  0
206
+#endif /* USE_COMP */
207
+
208
+#define TCP_LADDR(c) TCP_RCV_LADDR(c->rcv)
209
+#define TCP_LPORT(c) TCP_RCV_LPORT(c->rcv)
210
+#define TCP_PADDR(c) TCP_RCV_PADDR(c->rcv)
211
+#define TCP_PPORT(c) TCP_RCV_PPORT(c->rcv)
212
+#define TCP_PSU(c)   TCP_RCV_PSU(c->rcv)
213
+#define TCP_SOCK_INFO(c) TCP_RCV_SOCK_INFO(c->rcv)
214
+#define TCP_PROTO(c) TCP_RCV_PROTO(c->rcv)
215
+#define TCP_COMP(c) TCP_RCV_COMP(c->rcv)
191 216
 
192 217
 
193 218
 
Browse code

tcp: minor optimization

- tcp_req complete & has_content_len transformed into flags
(4 bytes saved per connection)

Andrei Pelinescu-Onciul authored on 20/03/2009 19:59:14
Showing 1 changed files
... ...
@@ -114,13 +114,18 @@ struct tcp_req{
114 114
 	char* body; /* body position */
115 115
 	unsigned int b_size; /* buffer size-1 (extra space for 0-term)*/
116 116
 	int content_len;
117
-	int has_content_len; /* 1 if content_length was parsed ok*/
118
-	int complete; /* 1 if one req has been fully read, 0 otherwise*/
117
+	unsigned short flags; /* F_TCP_REQ_HAS_CLEN | F_TCP_REQ_COMPLETE */
119 118
 	int bytes_to_go; /* how many bytes we have still to read from the body*/
120 119
 	enum tcp_req_errors error;
121 120
 	enum tcp_req_states state;
122 121
 };
123 122
 
123
+/* tcp_req flags */
124
+#define F_TCP_REQ_HAS_CLEN 1
125
+#define F_TCP_REQ_COMPLETE 2
126
+
127
+#define TCP_REQ_HAS_CLEN(tr)  ((tr)->flags & F_TCP_REQ_HAS_CLEN)
128
+#define TCP_REQ_COMPLETE(tr)  ((tr)->flags & F_TCP_REQ_COMPLETE)
124 129
 
125 130
 
126 131
 struct tcp_connection;
Browse code

tcp: config option for the read buffer size

- the read buffer size can now be configured both at runtime and
from ser.cfg (tcp_rd_buf_size). A high value will help
performance for tcp connections with lots of traffic, however it
will increase the memory consumption. As a rule of thumb use
high values(e.g. 32768, 65536) on servers which open only a few
tcp connections and have very heavy traffic on them and a low
value (e.g. 4096, 2048) on servers that are expected to have
lots of open connections (50k - 100k+). Note also that this
value will also limit the maximum sip datagram size that can be
received on tcp. The default value is 4096.

Andrei Pelinescu-Onciul authored on 09/03/2009 13:45:28
Showing 1 changed files
... ...
@@ -54,7 +54,6 @@
54 54
 /* maximum number of port aliases x search wildcard possibilities */
55 55
 #define TCP_CON_MAX_ALIASES (4*3) 
56 56
 
57
-#define TCP_BUF_SIZE	4096 
58 57
 #define TCP_CHILD_TIMEOUT 5 /* after 5 seconds, the child "returns" 
59 58
 							 the connection to the tcp master process */
60 59
 #define TCP_MAIN_SELECT_TIMEOUT 5 /* how often "tcp main" checks for timeout*/
... ...
@@ -107,12 +106,13 @@ enum conn_cmds { CONN_DESTROY=-3, CONN_ERROR=-2, CONN_EOF=-1, CONN_RELEASE,
107 106
 struct tcp_req{
108 107
 	struct tcp_req* next;
109 108
 	/* sockaddr ? */
110
-	char buf[TCP_BUF_SIZE+1]; /* bytes read so far (+0-terminator)*/
109
+	char* buf; /* bytes read so far (+0-terminator)*/
111 110
 	char* start; /* where the message starts, after all the empty lines are
112 111
 					skipped*/
113 112
 	char* pos; /* current position in buf */
114 113
 	char* parsed; /* last parsed position */
115 114
 	char* body; /* body position */
115
+	unsigned int b_size; /* buffer size-1 (extra space for 0-term)*/
116 116
 	int content_len;
117 117
 	int has_content_len; /* 1 if content_length was parsed ok*/
118 118
 	int complete; /* 1 if one req has been fully read, 0 otherwise*/
... ...
@@ -190,9 +190,11 @@ struct tcp_connection{
190 190
 #define tcpconn_put(c) atomic_dec_and_test(&((c)->refcnt))
191 191
 
192 192
 
193
-#define init_tcp_req( r) \
193
+#define init_tcp_req( r, rd_buf, rd_buf_size) \
194 194
 	do{ \
195 195
 		memset( (r), 0, sizeof(struct tcp_req)); \
196
+		(r)->buf=(rd_buf) ;\
197
+		(r)->b_size=(rd_buf_size)-1; /* space for 0 term. */ \
196 198
 		(r)->parsed=(r)->pos=(r)->start=(r)->buf; \
197 199
 		(r)->error=TCP_REQ_OK;\
198 200
 		(r)->state=H_SKIP_EMPTY; \
Browse code

tcp: diff. connect timeout for async & states cleanup

- async mode will now honour tcp_connect_timeout (up to now it
used tcp_send_timeout also for connects)
- internal states cleanup (dropped S_CONN_PENDING, fixed
S_CONN_ACCEPT->S_CONN_OK transition a.s.o)

Andrei Pelinescu-Onciul authored on 06/03/2009 16:54:10
Showing 1 changed files
... ...
@@ -89,9 +89,12 @@ enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND, H_SKIP_EMPTY_CRLF_FOU
89 89
 		H_STUN_MSG, H_STUN_READ_BODY, H_STUN_FP, H_STUN_END, H_PING_CRLF
90 90
 	};
91 91
 
92
-enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, 
93
-						S_CONN_INIT, S_CONN_EOF, 
94
-						S_CONN_ACCEPT, S_CONN_CONNECT, S_CONN_PENDING };
92
+enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1,
93
+						S_CONN_OK=0, /* established (write or read) */
94
+						S_CONN_INIT, /* initial state (invalid) */
95
+						S_CONN_EOF,
96
+						S_CONN_ACCEPT, S_CONN_CONNECT
97
+					};
95 98
 
96 99
 
97 100
 /* fd communication commands */
Browse code

tcp: async mode on by default

- async mode is now on by default (use tcp_async=no in the config
to disable it)
- renamed tcp_buf_write/TCP_BUF_WRITE into tcp_async/TCP_ASYNC in
the code

Andrei Pelinescu-Onciul authored on 05/03/2009 17:21:11
Showing 1 changed files
... ...
@@ -132,7 +132,7 @@ struct tcp_conn_alias{
132 132
 };
133 133
 
134 134
 
135
-#ifdef TCP_BUF_WRITE
135
+#ifdef TCP_ASYNC
136 136
 	struct tcp_wbuffer{
137 137
 		struct tcp_wbuffer* next;
138 138
 		unsigned int b_size;
... ...
@@ -174,7 +174,7 @@ struct tcp_connection{
174 174
 	struct tcp_connection* c_prev;
175 175
 	struct tcp_conn_alias con_aliases[TCP_CON_MAX_ALIASES];
176 176
 	int aliases; /* aliases number, at least 1 */
177
-#ifdef TCP_BUF_WRITE
177
+#ifdef TCP_ASYNC
178 178
 	struct tcp_wbuffer_queue wbuf_q;
179 179
 #endif
180 180
 };
Browse code

tcp: use dynamic config framework, part 2

- added tcp_connect_timeout, tcp_send_timeout,
tcp_connection_lifetime, tcp_max_connections, tcp_accept_aliases
to the config framework.

- added 2 new tcp related variables: tcp alias_flags and tcp
new_conn_alias_flags

Andrei Pelinescu-Onciul authored on 05/03/2009 17:20:42
Showing 1 changed files
... ...
@@ -42,6 +42,7 @@
42 42
 #ifndef _tcp_conn_h
43 43
 #define _tcp_conn_h
44 44
 
45
+#include "tcp_init.h"
45 46
 #include "tcp_options.h"
46 47
 
47 48
 #include "ip_addr.h"
... ...
@@ -54,12 +55,6 @@
54 55
 #define TCP_CON_MAX_ALIASES (4*3) 
55 56
 
56 57
 #define TCP_BUF_SIZE	4096 
57
-#define DEFAULT_TCP_CONNECTION_LIFETIME 120 /* in  seconds */
58
-#define DEFAULT_TCP_SEND_TIMEOUT 10 /* if a send can't write for more then 10s,
59
-									   timeout */
60
-#define DEFAULT_TCP_CONNECT_TIMEOUT 10 /* if a connect doesn't complete in this
61
-										  time, timeout */
62
-#define DEFAULT_TCP_MAX_CONNECTIONS 2048 /* maximum connections */
63 58
 #define TCP_CHILD_TIMEOUT 5 /* after 5 seconds, the child "returns" 
64 59
 							 the connection to the tcp master process */
65 60
 #define TCP_MAIN_SELECT_TIMEOUT 5 /* how often "tcp main" checks for timeout*/
Browse code

- tcp: more flags (no fixes, preparations for next set of changes)

Andrei Pelinescu-Onciul authored on 21/05/2008 10:16:46
Showing 1 changed files
... ...
@@ -79,6 +79,8 @@
79 79
 #define F_CONN_FORCE_EOF  512 /* act as if an EOF was received */
80 80
 #define F_CONN_OOB_DATA  1024 /* out of band data on the connection */
81 81
 #define F_CONN_WR_ERROR  2048 /* write error on the fd */
82
+#define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
83
+#define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
82 84
 
83 85
 
84 86
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
Browse code

added CRLF ping/pong keepalives aka SIP outbound

Alfred E. Heggestad authored on 24/04/2008 13:51:26
Showing 1 changed files
... ...
@@ -83,12 +83,13 @@
83 83
 
84 84
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
85 85
 						TCP_REQ_OVERRUN, TCP_REQ_BAD_LEN };
86
-enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
86
+enum tcp_req_states {	H_SKIP_EMPTY, H_SKIP_EMPTY_CR_FOUND, H_SKIP_EMPTY_CRLF_FOUND, H_SKIP_EMPTY_CRLFCR_FOUND,
87
+			H_SKIP, H_LF, H_LFCR,  H_BODY, H_STARTWS,
87 88
 		H_CONT_LEN1, H_CONT_LEN2, H_CONT_LEN3, H_CONT_LEN4, H_CONT_LEN5,
88 89
 		H_CONT_LEN6, H_CONT_LEN7, H_CONT_LEN8, H_CONT_LEN9, H_CONT_LEN10,
89 90
 		H_CONT_LEN11, H_CONT_LEN12, H_CONT_LEN13, H_L_COLON, 
90 91
 		H_CONT_LEN_BODY, H_CONT_LEN_BODY_PARSE,
91
-		H_STUN_MSG, H_STUN_READ_BODY, H_STUN_FP, H_STUN_END 
92
+		H_STUN_MSG, H_STUN_READ_BODY, H_STUN_FP, H_STUN_END, H_PING_CRLF