rls.h

Go to the documentation of this file.
00001 /*
00002  * $Id: rls.h 2230 2007-06-06 07:13:20Z anca_vamanu $
00003  *
00004  * rls module - resource list server
00005  *
00006  * Copyright (C) 2007 Voice Sistem S.R.L.
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2007-09-11  initial version (anca)
00027  */
00028 
00029 #ifndef _RLS_H_
00030 #define _RLS_H_
00031 
00032 #include "../../str.h"
00033 #include "../xcap_client/xcap_functions.h"
00034 #include "../pua/send_subscribe.h"
00035 #include "../pua/send_publish.h"
00036 #include "../pua/pidf.h"
00037 #include "../presence/hash.h"
00038 #include "../presence/event_list.h"
00039 #include "../sl/sl_api.h"
00040 #include "../../db/db_con.h"
00041 #include "../../db/db.h"
00042 
00043 #define NO_UPDATE_TYPE     -1 
00044 #define UPDATED_TYPE        1 
00045 
00046 #define NOT_KNOWN_STATE     0
00047 #define ACTIVE_STATE        1<<1
00048 #define PENDING_STATE       1<<2
00049 #define TERMINATED_STATE    1<<3
00050 
00051 typedef struct dialog_id
00052 {
00053    str callid;
00054    str to_tag;
00055    str from_tag;
00056 
00057 }dialog_id_t;
00058 
00059 /*
00060    rls_presentity table structure:
00061 
00062    - LIST URI       (string)
00063    - presentity URI (string)
00064    - presence state (string)
00065    /-- the following ones needed when updating in db on timer --/
00066    - auth_state     (int)
00067    - reason     (string)
00068    - updated        (int)
00069 */
00070 typedef struct rls_resource
00071 {
00072    str pres_uri;
00073    int auth_state;
00074    str reason;
00075    int updated;
00076    str* instance_id;
00077    str* cid;
00078    struct rls_resource* next;
00079    /* the last 2 parameters say if a query in database is needed */
00080 }rls_res_t;
00081 
00082 
00083 extern char* xcap_root;
00084 extern unsigned int xcap_port;
00085 extern str server_address; 
00086 extern int waitn_time; 
00087 extern str rlsubs_table;
00088 extern str rlpres_table;
00089 extern str rls_xcap_table;
00090 extern str db_url;
00091 extern int hash_size;
00092 extern shtable_t rls_table;
00093 extern int pid;
00094 extern int rls_max_expires;
00095 extern int rls_integrated_xcap_server;
00096 extern int rls_events;
00097 extern int to_presence_code;
00098 
00099 /* database connection */
00100 extern db_con_t *rls_db;
00101 extern db_func_t rls_dbf;
00102 
00103 extern struct tm_binds tmb;
00104 extern struct sl_binds slb;
00105 
00106 /** libxml api */
00107 extern xmlDocGetNodeByName_t XMLDocGetNodeByName;
00108 extern xmlNodeGetNodeByName_t XMLNodeGetNodeByName;
00109 extern xmlNodeGetNodeContentByName_t XMLNodeGetNodeContentByName;
00110 extern xmlNodeGetAttrContentByName_t XMLNodeGetAttrContentByName;
00111 
00112 /* functions imported from presence to handle subscribe hash table */
00113 extern new_shtable_t pres_new_shtable;
00114 extern insert_shtable_t pres_insert_shtable;
00115 extern search_shtable_t pres_search_shtable;
00116 extern update_shtable_t pres_update_shtable;
00117 extern delete_shtable_t pres_delete_shtable;
00118 extern destroy_shtable_t pres_destroy_shtable;
00119 extern mem_copy_subs_t  pres_copy_subs;
00120 extern extract_sdialog_info_t pres_extract_sdialog_info;
00121 
00122 /* functions imported from pua module*/
00123 extern send_subscribe_t pua_send_subscribe;
00124 extern get_record_id_t pua_get_record_id;
00125 
00126 /* functions imported from presence module */
00127 extern contains_event_t pres_contains_event;
00128 extern search_event_t pres_search_event;
00129 extern get_event_list_t pres_get_ev_list;
00130 
00131 /* xcap client functions */
00132 extern xcapGetNewDoc_t xcap_GetNewDoc;
00133 extern xcap_nodeSel_init_t xcap_IntNodeSel;
00134 extern xcap_nodeSel_add_step_t xcap_AddStep;
00135 extern xcap_nodeSel_add_terminal_t xcap_AddTerminal;
00136 extern xcap_nodeSel_free_t xcap_FreeNodeSel;
00137 
00138 extern str str_rlsubs_did_col;
00139 extern str str_resource_uri_col;
00140 extern str str_updated_col;
00141 extern str str_auth_state_col;
00142 extern str str_reason_col;
00143 extern str str_content_type_col;
00144 extern str str_presence_state_col;
00145 extern str str_expires_col;
00146 extern str str_presentity_uri_col;
00147 extern str str_event_col;
00148 extern str str_event_id_col;
00149 extern str str_to_user_col;
00150 extern str str_to_domain_col;
00151 extern str str_watcher_username_col;
00152 extern str str_watcher_domain_col;
00153 extern str str_callid_col;
00154 extern str str_to_tag_col;
00155 extern str str_from_tag_col;
00156 extern str str_local_cseq_col;
00157 extern str str_remote_cseq_col;
00158 extern str str_record_route_col;
00159 extern str str_socket_info_col;
00160 extern str str_contact_col;
00161 extern str str_local_contact_col;
00162 extern str str_version_col;
00163 extern str str_status_col;
00164 extern str str_username_col;
00165 extern str str_domain_col;
00166 extern str str_doc_type_col;
00167 extern str str_etag_col;
00168 extern str str_doc_col;
00169 
00170 #define DID_SEP_LEN   strlen(DID_SEP)
00171 #define DID_SEP       ";"
00172 #define DID_INIT_LEN  (2* sizeof(DID_SEP))
00173 
00174 /* did_str= *callid*DID_SEP*from_tag*DID_SEP*to_tag* */
00175 
00176 static inline int CONSTR_RLSUBS_DID(subs_t* subs, str *did)
00177 {
00178    int len;
00179 
00180    len= (DID_INIT_LEN+ subs->callid.len+ subs->to_tag.len+
00181          subs->from_tag.len+ 10)* sizeof(char);
00182    did->s= (char*)pkg_malloc(len);
00183    if(did->s== NULL) 
00184    {
00185       ERR_MEM(PKG_MEM_STR); 
00186    }
00187    
00188    did->len= sprintf(did->s, "%.*s%s%.*s%s%.*s", subs->callid.len, 
00189          subs->callid.s, DID_SEP,subs->from_tag.len, subs->from_tag.s, 
00190          DID_SEP, subs->to_tag.len, subs->to_tag.s);
00191 
00192    if(did->len>= len)
00193    {
00194       LM_ERR("ERROR buffer size overflown\n");
00195       pkg_free(did->s);
00196       return -1;
00197    }
00198    did->s[did->len]= '\0';
00199    
00200    LM_DBG("did= %s\n", did->s);
00201    return 0;
00202 error:
00203    return -1;
00204 }
00205 
00206 #endif

Generated on Thu May 24 12:00:30 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6