ws_conn.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 Crocodile RCS Ltd
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #ifndef _WS_CONN_H
  24. #define _WS_CONN_H
  25. #include "../../lib/kcore/kstats_wrapper.h"
  26. #include "../../lib/kmi/tree.h"
  27. typedef enum
  28. {
  29. WS_S_CONNECTING = 0, /* Never used - included for completeness */
  30. WS_S_OPEN,
  31. WS_S_CLOSING,
  32. WS_S_CLOSED /* Never used - included for completeness */
  33. } ws_conn_state_t;
  34. typedef struct ws_connection
  35. {
  36. ws_conn_state_t state;
  37. int awaiting_pong;
  38. int last_used;
  39. struct ws_connection *used_prev;
  40. struct ws_connection *used_next;
  41. int id; /* id and id_hash are identical to the values */
  42. unsigned id_hash; /* for the corresponding TCP/TLS connection */
  43. struct ws_connection *id_prev;
  44. struct ws_connection *id_next;
  45. struct receive_info rcv;
  46. unsigned int sub_protocol;
  47. } ws_connection_t;
  48. typedef struct
  49. {
  50. ws_connection_t *head;
  51. ws_connection_t *tail;
  52. } ws_connection_used_list_t;
  53. typedef enum
  54. {
  55. WSCONN_EVENTROUTE_NO = 0,
  56. WSCONN_EVENTROUTE_YES
  57. } ws_conn_eventroute_t;
  58. extern ws_connection_used_list_t *wsconn_used_list;
  59. extern char *wsconn_state_str[];
  60. extern stat_var *ws_current_connections;
  61. extern stat_var *ws_max_concurrent_connections;
  62. int wsconn_init(void);
  63. void wsconn_destroy(void);
  64. int wsconn_add(struct receive_info rcv, unsigned int sub_protocol);
  65. int wsconn_rm(ws_connection_t *wsc, ws_conn_eventroute_t run_event_route);
  66. int wsconn_update(ws_connection_t *wsc);
  67. void wsconn_close_now(ws_connection_t *wsc);
  68. ws_connection_t *wsconn_get(int id);
  69. struct mi_root *ws_mi_dump(struct mi_root *cmd, void *param);
  70. #endif /* _WS_CONN_H */