tcp_init.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef tcp_init_h
  21. #define tcp_init_h
  22. #include "ip_addr.h"
  23. #define DEFAULT_TCP_CONNECTION_LIFETIME_S 120 /* in seconds */
  24. /* maximum accepted lifetime in ticks (maximum possible is ~ MAXINT/2) */
  25. #define MAX_TCP_CON_LIFETIME ((1U<<(sizeof(ticks_t)*8-1))-1)
  26. #define DEFAULT_TCP_SEND_TIMEOUT 10 /* if a send can't write for more then 10s,
  27. timeout */
  28. #define DEFAULT_TCP_CONNECT_TIMEOUT 10 /* if a connect doesn't complete in this
  29. time, timeout */
  30. #define DEFAULT_TCP_MAX_CONNECTIONS 2048 /* maximum tcp connections */
  31. #define DEFAULT_TLS_MAX_CONNECTIONS 2048 /* maximum tls connections */
  32. #define DEFAULT_TCP_BUF_SIZE 16384 /* 16k - buffer size used for reads */
  33. #define DEFAULT_TCP_WBUF_SIZE 2100 /* after debugging switch to 4-16k */
  34. struct tcp_child{
  35. pid_t pid;
  36. int proc_no; /* ser proc_no, for debugging */
  37. int unix_sock; /* unix "read child" sock fd */
  38. int busy;
  39. struct socket_info *mysocket; /* listen socket to handle traffic on it */
  40. int n_reqs; /* number of requests serviced so far */
  41. };
  42. #define TCP_ALIAS_FORCE_ADD 1
  43. #define TCP_ALIAS_REPLACE 2
  44. int init_tcp(void);
  45. void destroy_tcp(void);
  46. int tcp_init(struct socket_info* sock_info);
  47. int tcp_init_children(void);
  48. void tcp_main_loop(void);
  49. void tcp_receive_loop(int unix_sock);
  50. int tcp_fix_child_sockets(int* fd);
  51. /* sets source address used when opening new sockets and no source is specified
  52. * (by default the address is choosen by the kernel)
  53. * Should be used only on init.
  54. * returns -1 on error */
  55. int tcp_set_src_addr(struct ip_addr* ip);
  56. #endif