modules_k/usrloc/usrloc.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00028 #ifndef USRLOC_H
00029 #define USRLOC_H
00030 
00031 #include <time.h>
00032 #include "ul_callback.h"
00033 #include "../../qvalue.h"
00034 #include "../../str.h"
00035 
00036 #define NO_DB         0
00037 #define WRITE_THROUGH 1
00038 #define WRITE_BACK    2
00039 #define DB_ONLY       3
00040 
00041 /*forward declaration necessary for udomain*/
00042 
00043 struct udomain;
00044 typedef struct udomain udomain_t;
00045 
00049 typedef enum cstate {
00050         CS_NEW,        
00051         CS_SYNC,       
00052         CS_DIRTY       
00053 } cstate_t;
00054 
00055 
00057 typedef enum flags {
00058         FL_NONE        = 0,          
00059         FL_MEM         = 1 << 0,     
00060         FL_ALL         = (int)0xFFFFFFFF  
00061 } flags_t;
00062 
00064 #define VALID_CONTACT(c, t)   ((c->expires>t) || (c->expires==0))
00065 
00066 struct hslot; 
00067 struct socket_info;
00069 typedef struct ucontact {
00070         str* domain;            
00071         str ruid;               
00072         str* aor;               
00073         str c;                  
00074         str received;           
00075         str path;               
00076         time_t expires;         
00077         qvalue_t q;             
00078         str callid;             
00079         int cseq;               
00080         cstate_t state;         
00081         unsigned int flags;     
00082         unsigned int cflags;    
00083         str user_agent;         
00084         struct socket_info *sock; 
00085         time_t last_modified;   
00086         unsigned int methods;   
00087         str instance;           
00088         unsigned int reg_id;    
00089         struct ucontact* next;  
00090         struct ucontact* prev;  
00091 } ucontact_t;
00092 
00093 
00095 typedef struct ucontact_info {
00096         str ruid;                 
00097         str received;             
00098         str* path;                
00099         time_t expires;           
00100         qvalue_t q;               
00101         str* callid;              
00102         int cseq;                 
00103         unsigned int flags;       
00104         unsigned int cflags;      
00105         str *user_agent;          
00106         struct socket_info *sock; 
00107         unsigned int methods;     
00108         str instance;             
00109         unsigned int reg_id;      
00110         time_t last_modified;     
00111 } ucontact_info_t;
00112 
00113 typedef struct udomain_head{
00114     str* name;
00115 } udomain_head_t;
00116 
00120 typedef struct urecord {
00121         str* domain;                   
00123         str aor;                       
00124         unsigned int aorhash;          
00125         ucontact_t* contacts;          
00127         struct hslot* slot;            
00129         struct urecord* prev;          
00130         struct urecord* next;          
00131 } urecord_t;
00132 
00133 typedef int (*insert_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r);
00134 
00135 typedef int (*get_urecord_t)(struct udomain* _d, str* _aor, struct urecord** _r);
00136 
00137 typedef int (*get_urecord_by_ruid_t)(udomain_t* _d, unsigned int _aorhash,
00138                 str *_ruid, struct urecord** _r, struct ucontact** _c);
00139 
00140 typedef int  (*delete_urecord_t)(struct udomain* _d, str* _aor, struct urecord* _r);
00141 
00142 typedef int (*update_ucontact_t)(struct urecord* _r, struct ucontact* _c,
00143                 struct ucontact_info* _ci);
00144 typedef void (*release_urecord_t)(struct urecord* _r);
00145 
00146 typedef int (*insert_ucontact_t)(struct urecord* _r, str* _contact,
00147                 struct ucontact_info* _ci, struct ucontact** _c);
00148 
00149 typedef int (*delete_ucontact_t)(struct urecord* _r, struct ucontact* _c);
00150 
00151 typedef int (*get_ucontact_t)(struct urecord* _r, str* _c, str* _callid,
00152                 str* _path, int _cseq,
00153                 struct ucontact** _co);
00154 
00155 typedef int (*get_ucontact_by_instance_t)(struct urecord* _r, str* _c,
00156                 ucontact_info_t* _ci, ucontact_t** _co);
00157 
00158 typedef void (*lock_udomain_t)(struct udomain* _d, str *_aor);
00159 
00160 typedef void (*unlock_udomain_t)(struct udomain* _d, str *_aor);
00161 
00162 typedef int (*register_udomain_t)(const char* _n, struct udomain** _d);
00163 
00164 typedef int  (*get_all_ucontacts_t) (void* buf, int len, unsigned int flags,
00165                 unsigned int part_idx, unsigned int part_max);
00166 
00167 typedef int (*get_udomain_t)(const char* _n, udomain_t** _d);
00168 
00169 typedef unsigned int (*ul_get_aorhash_t)(str *_aor);
00170 unsigned int ul_get_aorhash(str *_aor);
00171 
00173 typedef struct usrloc_api {
00174         int           use_domain; 
00175         int           db_mode;    
00176         unsigned int  nat_flag;   
00178         register_udomain_t   register_udomain;
00179         get_udomain_t        get_udomain;
00180         get_all_ucontacts_t  get_all_ucontacts;
00181 
00182         insert_urecord_t     insert_urecord;
00183         delete_urecord_t     delete_urecord;
00184         get_urecord_t        get_urecord;
00185         lock_udomain_t       lock_udomain;
00186         unlock_udomain_t     unlock_udomain;
00187 
00188         release_urecord_t    release_urecord;
00189         insert_ucontact_t    insert_ucontact;
00190         delete_ucontact_t    delete_ucontact;
00191         get_ucontact_t       get_ucontact;
00192 
00193         get_urecord_by_ruid_t       get_urecord_by_ruid;
00194         get_ucontact_by_instance_t  get_ucontact_by_instance;
00195 
00196         update_ucontact_t    update_ucontact;
00197 
00198         register_ulcb_t      register_ulcb;
00199         ul_get_aorhash_t     get_aorhash;
00200 } usrloc_api_t;
00201 
00202 
00204 typedef int (*bind_usrloc_t)(usrloc_api_t* api);
00205 
00206 #endif