dlg_db_handler.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2007 Voice System SRL
00005  * Copyright (C) 2011 Carsten Bock, carsten@ng-voice.com
00006  *
00007  * This file is part of Kamailio, a free SIP server.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License 
00020  * along with this program; if not, write to the Free Software 
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  * History:
00024  * --------
00025  * 2007-05-10  initial version (ancuta)
00026  */
00027 
00028 
00029 #ifndef _DLG_DB_HANDLER_H_
00030 #define _DLG_DB_HANDLER_H_
00031 
00032 #include "../../str.h"
00033 #include "../../lib/srdb1/db.h"
00034 
00035 #define CALL_ID_COL                             "callid"
00036 #define FROM_URI_COL                    "from_uri"
00037 #define FROM_TAG_COL                    "from_tag"
00038 #define TO_URI_COL                              "to_uri"
00039 #define TO_TAG_COL                              "to_tag"
00040 #define HASH_ID_COL                             "hash_id"
00041 #define HASH_ENTRY_COL                  "hash_entry"
00042 #define STATE_COL                               "state"
00043 #define START_TIME_COL                  "start_time"
00044 #define TIMEOUT_COL                             "timeout"
00045 #define TO_CSEQ_COL                             "callee_cseq"
00046 #define FROM_CSEQ_COL                   "caller_cseq"
00047 #define TO_ROUTE_COL                    "callee_route_set"
00048 #define FROM_ROUTE_COL                  "caller_route_set"
00049 #define TO_CONTACT_COL                  "callee_contact"
00050 #define FROM_CONTACT_COL                "caller_contact"
00051 #define FROM_SOCK_COL                   "caller_sock"
00052 #define TO_SOCK_COL                             "callee_sock"
00053 #define IFLAGS_COL                              "iflags"
00054 #define SFLAGS_COL                              "sflags"
00055 #define TOROUTE_NAME_COL                "toroute_name"
00056 #define REQ_URI_COL                             "req_uri"
00057 #define XDATA_COL                               "xdata"
00058 #define DIALOG_TABLE_NAME               "dialog"
00059 #define DLG_TABLE_VERSION               7
00060 
00061 #define DIALOG_TABLE_COL_NO             23
00062 
00063 #define VARS_HASH_ID_COL                "hash_id"
00064 #define VARS_HASH_ENTRY_COL             "hash_entry"
00065 #define VARS_KEY_COL                    "dialog_key"
00066 #define VARS_VALUE_COL                  "dialog_value"
00067 #define DIALOG_VARS_TABLE_NAME          "dialog_vars"
00068 #define DLG_VARS_TABLE_VERSION          1
00069 
00070 #define DIALOG_VARS_TABLE_COL_NO 4
00071 
00072 
00073 /*every minute the dialogs' information will be refreshed*/
00074 #define DB_DEFAULT_UPDATE_PERIOD        60
00075 #define DB_MODE_NONE                            0
00076 #define DB_MODE_REALTIME                        1
00077 #define DB_MODE_DELAYED                         2
00078 #define DB_MODE_SHUTDOWN                        3
00079 
00080 
00081 /* Dialog table */
00082 extern str call_id_column; 
00083 extern str from_uri_column;
00084 extern str from_tag_column;
00085 extern str to_uri_column;
00086 extern str to_tag_column;
00087 extern str h_id_column;
00088 extern str h_entry_column;
00089 extern str state_column;
00090 extern str start_time_column;
00091 extern str timeout_column;
00092 extern str to_cseq_column;
00093 extern str from_cseq_column;
00094 extern str to_route_column;
00095 extern str from_route_column;
00096 extern str to_contact_column;
00097 extern str from_contact_column;
00098 extern str to_sock_column;
00099 extern str from_sock_column;
00100 extern str iflags_column;
00101 extern str sflags_column;
00102 extern str toroute_name_column;
00103 extern str dialog_table_name;
00104 extern int dlg_db_mode;
00105 
00106 /* Dialog-Vars Table */
00107 extern str vars_h_id_column;
00108 extern str vars_h_entry_column;
00109 extern str vars_key_column;
00110 extern str vars_value_column;
00111 extern str dialog_vars_table_name;
00112 
00113 
00114 int init_dlg_db(const str *db_url, int dlg_hash_size, int db_update_period, int fetch_num_rows);
00115 int dlg_connect_db(const str *db_url);
00116 void destroy_dlg_db(void);
00117 
00118 int remove_dialog_from_db(struct dlg_cell * cell);
00119 int update_dialog_dbinfo(struct dlg_cell * cell);
00120 void dialog_update_db(unsigned int ticks, void * param);
00121 
00122 #endif