dlg_db_handler.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2007 Voice System SRL
  5. * Copyright (C) 2011 Carsten Bock, [email protected]
  6. *
  7. * This file is part of Kamailio, a free SIP server.
  8. *
  9. * Kamailio is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * Kamailio is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. * History:
  24. * --------
  25. * 2007-05-10 initial version (ancuta)
  26. */
  27. #ifndef _DLG_DB_HANDLER_H_
  28. #define _DLG_DB_HANDLER_H_
  29. #include "../../str.h"
  30. #include "../../lib/srdb1/db.h"
  31. #define ID_COL "id"
  32. #define HASH_ENTRY_COL "hash_entry"
  33. #define HASH_ID_COL "hash_id"
  34. #define DID_COL "did"
  35. #define CALL_ID_COL "callid"
  36. #define FROM_URI_COL "from_uri"
  37. #define FROM_TAG_COL "from_tag"
  38. #define CALLER_ORIGINAL_CSEQ_COL "caller_original_cseq"
  39. #define REQ_URI_COL "req_uri"
  40. #define CALLER_ROUTESET_COL "caller_route_set"
  41. #define CALLER_CONTACT_COL "caller_contact"
  42. #define CALLER_SOCK "caller_sock"
  43. #define STATE_COL "state"
  44. #define START_TIME_COL "start_time"
  45. #define TIMEOUT_COL "timeout"
  46. #define SFLAGS_COL "sflags"
  47. #define TOROUTE_NAME_COL "toroute_name"
  48. #define TOROUTE_INDEX_COL "toroute_index"
  49. // dialog_out exclusive columns
  50. #define TO_URI_COL "to_uri"
  51. #define TO_TAG_COL "to_tag"
  52. #define CALLER_CSEQ_COL "caller_cseq"
  53. #define CALLEE_CSEQ_COL "callee_cseq"
  54. #define CALLEE_CONTACT_COL "callee_contact"
  55. #define CALLEE_ROUTESET_COL "callee_route_set"
  56. #define CALLEE_SOCK "callee_sock"
  57. //#define XDATA_COL "xdata"
  58. #define DIALOG_IN_TABLE_NAME "dialog_in"
  59. #define DIALOG_OUT_TABLE_NAME "dialog_out"
  60. #define DLG_TABLE_VERSION 7
  61. #define DIALOG_IN_TABLE_COL_NO 18
  62. #define DIALOG_OUT_TABLE_COL_NO 11
  63. #define VARS_HASH_ID_COL "hash_id"
  64. #define VARS_HASH_ENTRY_COL "hash_entry"
  65. #define VARS_KEY_COL "dialog_key"
  66. #define VARS_VALUE_COL "dialog_value"
  67. #define DIALOG_VARS_TABLE_NAME "dialog_vars"
  68. #define DLG_VARS_TABLE_VERSION 1
  69. #define DIALOG_VARS_TABLE_COL_NO 4
  70. /*every minute the dialogs' information will be refreshed*/
  71. #define DB_DEFAULT_UPDATE_PERIOD 60
  72. #define DB_MODE_NONE 0
  73. #define DB_MODE_REALTIME 1
  74. #define DB_MODE_DELAYED 2
  75. #define DB_MODE_SHUTDOWN 3
  76. /* Dialog table */
  77. extern str call_id_column;
  78. extern str from_uri_column;
  79. extern str from_tag_column;
  80. extern str to_uri_column;
  81. extern str to_tag_column;
  82. extern str h_id_column;
  83. extern str h_entry_column;
  84. extern str state_column;
  85. extern str start_time_column;
  86. extern str timeout_column;
  87. extern str to_cseq_column;
  88. extern str from_cseq_column;
  89. extern str to_route_column;
  90. extern str from_route_column;
  91. extern str to_contact_column;
  92. extern str from_contact_column;
  93. extern str to_sock_column;
  94. extern str from_sock_column;
  95. extern str sflags_column;
  96. extern str toroute_name_column;
  97. extern str dialog_in_table_name;
  98. extern int dlg_db_mode;
  99. /* Dialog-Vars Table */
  100. extern str vars_h_id_column;
  101. extern str vars_h_entry_column;
  102. extern str vars_key_column;
  103. extern str vars_value_column;
  104. extern str dialog_vars_table_name;
  105. int init_dlg_db(const str *db_url, int dlg_hash_size, int db_update_period, int fetch_num_rows);
  106. int dlg_connect_db(const str *db_url);
  107. void destroy_dlg_db(void);
  108. int remove_dialog_in_from_db(struct dlg_cell * cell);
  109. int update_dialog_dbinfo(struct dlg_cell * cell);
  110. void dialog_update_db(unsigned int ticks, void * param);
  111. #endif