tcp_options.h
20c64cc6
 /* 
  * $Id$
  * 
  * Copyright (C) 2007 iptelorg GmbH
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
  *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 /*
  * tcp options
  *
  * History:
  * --------
  *  2007-11-28  created by andrei
  */
 
 #ifndef tcp_options_h
 #define tcp_options_h
 
7ad18de8
 #ifdef USE_TCP
885b9f62
 
76cb799e
 #ifndef NO_TCP_ASYNC
 #define TCP_ASYNC /* enabled async mode */
 #endif
885b9f62
 
76cb799e
 #if !defined(NO_TCP_CONNECT_WAIT) && defined(TCP_ASYNC)
d22b82a0
 #define TCP_CONNECT_WAIT /* enable pending connects support */
 #endif
 
76cb799e
 #if defined(TCP_CONNECT_WAIT) && !defined(TCP_ASYNC)
 /* check for impossible configuration: TCP_CONNECT_WAIT w/o TCP_ASYNC */
 #warning "disabling TCP_CONNECT_WAIT because TCP_ASYNC is not defined"
d22b82a0
 #undef TCP_CONNECT_WAIT
 #endif
 
20c64cc6
 #ifndef NO_TCP_FD_CACHE
 #define TCP_FD_CACHE /* enable fd caching */
 #endif
 
 
 
 /* defer accept */
 #ifndef  NO_TCP_DEFER_ACCEPT
 #ifdef __OS_linux
 #define HAVE_TCP_DEFER_ACCEPT
8b83a926
 #elif defined __OS_freebsd
20c64cc6
 #define HAVE_TCP_ACCEPT_FILTER
 #endif /* __OS_ */
 #endif /* NO_TCP_DEFER_ACCEPT */
 
 
 /* syn count */
 #ifndef NO_TCP_SYNCNT
 #ifdef __OS_linux
 #define HAVE_TCP_SYNCNT
 #endif /* __OS_*/
 #endif /* NO_TCP_SYNCNT */
 
 /* tcp linger2 */
 #ifndef NO_TCP_LINGER2
 #ifdef __OS_linux
 #define HAVE_TCP_LINGER2
 #endif /* __OS_ */
 #endif /* NO_TCP_LINGER2 */
 
 /* keepalive */
 #ifndef NO_TCP_KEEPALIVE
 #define HAVE_SO_KEEPALIVE
 #endif /* NO_TCP_KEEPALIVE */
 
 /* keepintvl */
 #ifndef NO_TCP_KEEPINTVL
 #ifdef __OS_linux
 #define HAVE_TCP_KEEPINTVL
 #endif /* __OS_ */
 #endif /* NO_TCP_KEEPIDLE */
 
 /* keepidle */
 #ifndef NO_TCP_KEEPIDLE
 #ifdef __OS_linux
 #define HAVE_TCP_KEEPIDLE
 #endif /* __OS_*/
 #endif /* NO_TCP_KEEPIDLE */
 
 
 /* keepcnt */
 #ifndef NO_TCP_KEEPCNT
 #ifdef __OS_linux
 #define HAVE_TCP_KEEPCNT
 #endif /* __OS_ */
 #endif /* NO_TCP_KEEPCNT */
 
 
 /* delayed ack (quick_ack) */
 #ifndef NO_TCP_QUICKACK
 #ifdef __OS_linux
 #define HAVE_TCP_QUICKACK
 #endif /* __OS_ */
 #endif /* NO_TCP_QUICKACK */
 
7ad18de8
 #endif /* USE_TCP */
20c64cc6
 
22db42e4
 struct cfg_group_tcp{
3dc4f620
 	/* ser tcp options, low level */
9a74e06a
 	int connect_timeout_s; /* in s */
ffc72fcf
 	int send_timeout; /* in ticks (s fixed to ticks) */
 	int con_lifetime; /* in ticks (s fixed to ticks) */
61f8b970
 	int max_connections; /* max tcp connections (includes tls connections) */
 	int max_tls_connections; /* max tls connections */
de223f01
 	int no_connect; /* do not open any new tcp connection (but accept them) */
20c64cc6
 	int fd_cache; /* on /off */
22db42e4
 	/* tcp async options */
76cb799e
 	int async; /* on / off */
 	int tcp_connect_wait; /* on / off, depends on async */
885b9f62
 	unsigned int tcpconn_wq_max; /* maximum queue len per connection */
 	unsigned int tcp_wq_max; /* maximum overall queued bytes */
 
20c64cc6
 	/* tcp socket options */
 	int defer_accept; /* on / off */
 	int delayed_ack; /* delay ack on connect */ 
 	int syncnt;     /* numbers of SYNs retrs. before giving up connecting */
 	int linger2;    /* lifetime of orphaned  FIN_WAIT2 state sockets */
 	int keepalive;  /* on /off */
 	int keepidle;   /* idle time (s) before tcp starts sending keepalives */
 	int keepintvl;  /* interval between keep alives */
 	int keepcnt;    /* maximum no. of keepalives before giving up */
22db42e4
 	
 	/* other options */
c7337a27
 	int crlf_ping;  /* on/off - reply to double CRLF keepalives */
3dc4f620
 	int accept_aliases;
 	int alias_flags;
 	int new_conn_alias_flags;
90cbe54c
 	int accept_no_cl;  /* on/off - accept messages without content-length */
866a3699
 
3dc4f620
 	/* internal, "fixed" vars */
e655392a
 	unsigned int rd_buf_size; /* read buffer size (should be > max. datagram)*/
 	unsigned int wq_blk_size; /* async write block size (debugging use) */
20c64cc6
 };
 
22db42e4
 extern struct cfg_group_tcp tcp_default_cfg;
 
 /* tcp config handle*/
 extern void* tcp_cfg;
20c64cc6
 
 
abb01fb4
 void init_tcp_options(void);
 void tcp_options_check(void);
 int tcp_register_cfg(void);
22db42e4
 void tcp_options_get(struct cfg_group_tcp* t);
20c64cc6
 
691a3439
 #ifdef USE_TCP
 int tcp_set_clone_rcvbuf(int v);
 #endif /* USE_TCP */
 
20c64cc6
 #endif /* tcp_options_h */