registrar_storage.h

Go to the documentation of this file.
00001 /*
00002  * $Id: registrar_storage.h 591 2008-10-15 12:46:34Z vingarzan $
00003  *  
00004  * Copyright (C) 2004-2006 FhG Fokus
00005  *
00006  * This file is part of Open IMS Core - an open source IMS CSCFs & HSS
00007  * implementation
00008  *
00009  * Open IMS Core 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  * For a license to use the Open IMS Core software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact Fraunhofer FOKUS by e-mail at the following
00017  * addresses:
00018  *     info@open-ims.org
00019  *
00020  * Open IMS Core is distributed in the hope that it will be useful,
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  * GNU General Public License for more details.
00024  * 
00025  * It has to be noted that this Open Source IMS Core System is not 
00026  * intended to become or act as a product in a commercial context! Its 
00027  * sole purpose is to provide an IMS core reference implementation for 
00028  * IMS technology testing and IMS application prototyping for research 
00029  * purposes, typically performed in IMS test-beds.
00030  * 
00031  * Users of the Open Source IMS Core System have to be aware that IMS
00032  * technology may be subject of patents and licence terms, as being 
00033  * specified within the various IMS-related IETF, ITU-T, ETSI, and 3GPP
00034  * standards. Thus all Open IMS Core users have to take notice of this 
00035  * fact and have to agree to check out carefully before installing, 
00036  * using and extending the Open Source IMS Core System, if related 
00037  * patents and licences may become applicable to the intended usage 
00038  * context.  
00039  *
00040  * You should have received a copy of the GNU General Public License
00041  * along with this program; if not, write to the Free Software
00042  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00043  * 
00044  */
00045  
00057 #ifndef S_CSCF_REGISTRAR_STORAGE_H_
00058 #define S_CSCF_REGISTRAR_STORAGE_H_
00059 
00060 #include "../../sr_module.h"
00061 #include "../../locking.h"
00062 #include "../tm/tm_load.h"
00063 #include "../../qvalue.h"
00064 
00065 
00066 #include "registrar_parser.h"
00067 #include "registrar_notify.h"
00068 
00069 
00070 /* REGISTRAR Structures */
00071 
00072 
00074 enum {
00075     IMS_EVENT_NONE,             
00076     IMS_EVENT_REG               
00077 }IMS_Events;
00078 
00080 typedef struct _r_subscriber {
00081     str subscriber;             
00082     char event;
00083 
00084     time_t expires;             
00085     dlg_t *dialog;              
00087     int version;                
00089     struct _r_subscriber *next;
00090     struct _r_subscriber *prev;
00091 } r_subscriber;
00092 
00094 typedef struct _r_contact {
00095     str uri;                    
00096     time_t expires;             
00097     str ua;                     
00098     str path;                   
00099     qvalue_t qvalue;                
00101     struct _r_contact *next;    
00102     struct _r_contact *prev;    
00103 } r_contact;
00104 
00106 enum Reg_States {
00107     NOT_REGISTERED=0,           
00108     REGISTERED=1,               
00109     UNREGISTERED=-1             
00110 } ;
00111 
00112 typedef struct _t_regexp_unit {
00113     //regex_t exp; this is apearently useless
00114     char *s; // it is null terminated
00115     struct _t_regexp_unit *next,*prev;
00116 } t_regexp_unit;
00117 
00118 typedef struct _t_regexp_list {
00119     t_regexp_unit *head;
00120     t_regexp_unit *tail;
00121 } t_regexp_list;
00122 
00123 
00125 typedef struct _r_public {
00126     unsigned int hash;          
00127     str aor;                    
00128     str early_ims_ip;           
00129     enum Reg_States reg_state;  
00130     ims_subscription *s;        
00131     t_regexp_list *regexp;      
00132     str ccf1,ccf2,ecf1,ecf2;    
00134     r_contact *head,*tail;      
00135     r_subscriber *shead,*stail; 
00137     struct _r_public *next,*prev; 
00138 } r_public;
00139 
00140 
00142 typedef struct {
00143     r_public *head;                 
00144     r_public *tail;                 
00145     gen_lock_t *lock;               
00146 } r_hash_slot;
00147 
00148 
00149 
00151 typedef r_public* (*get_r_public_f)(str aor);
00153 typedef void (*r_unlock_f)(int hash);
00155 typedef int (*get_r_public_expires_f)(str aor);
00156 
00157 
00158 void r_act_time();
00159 inline int r_valid_contact(r_contact *c);
00160 inline int r_valid_subscriber(r_subscriber *c);
00161 
00162 inline unsigned int get_aor_hash(str aor,int hash_size);
00163 
00164 int r_storage_init(int hash_size);
00165 void r_storage_destroy();
00166 
00167 inline void r_lock(unsigned int hash);
00168 inline void r_unlock(unsigned int hash);
00169 
00170 
00171 
00172 r_subscriber* new_r_subscriber(str subscriber,int event,int expires,dlg_t *dialog);
00173 r_subscriber* get_r_subscriber(r_public *p, str subscriber,int event);
00174 r_subscriber* add_r_subscriber(r_public  *p,str subscriber,int event,int expires,dlg_t *dialog);
00175 r_subscriber* update_r_subscriber(r_public *p,str subscriber,int event,int* expires,dlg_t *dialog);
00176 void del_r_subscriber(r_public *p,r_subscriber *s);
00177 void free_r_subscriber(r_subscriber *s);
00178 
00179 r_contact* new_r_contact(str uri,int expires,str ua,str path,qvalue_t qvalue);
00180 r_contact* get_r_contact(r_public *p, str uri);
00181 r_contact* add_r_contact(r_public *p,str uri,int expires,str ua,str path,qvalue_t qvalue);
00182 r_contact* update_r_contact(r_public *p,str uri,int *expires, str *ua,str *path,qvalue_t qvalue);
00183 void del_r_contact(r_public *p,r_contact *c);
00184 void free_r_contact(r_contact *c);
00185 
00186 r_public* new_r_public(str aor, enum Reg_States reg_state, ims_subscription *s);
00187 r_public* get_r_public(str aor);
00188 int get_r_public_expires(str aor);
00189 r_public* get_r_public_nolock(str aor);
00190 r_public* get_r_public_previous_lock(str aor,int locked_hash);
00191 r_public* add_r_public(str aor,enum Reg_States reg_state,ims_subscription *s);
00192 r_public* add_r_public_previous_lock(str aor,int locked_hash,enum Reg_States reg_state,ims_subscription *s);
00193 r_public* update_r_public(str aor,enum Reg_States *reg_state,ims_subscription **s,
00194     str *ccf1, str *ccf2, str *ecf1, str *ecf2);
00195 r_public* update_r_public_previous_lock(str aor,int locked_hash,enum Reg_States *reg_state,ims_subscription **s,
00196     str *ccf1, str *ccf2, str *ecf1, str *ecf2);    
00197 void r_public_expire(str public_id);
00198 void r_private_expire(str private_id);
00199 void del_r_public(r_public *p);
00200 void free_r_public(r_public *p);
00201 
00202 void print_r(int log_level);
00203 
00204 
00205 
00206 #endif //S_CSCF_REGISTRAR_STORAGE_H_

Generated on Thu Oct 23 04:14:38 2008 for Open IMS Core CSCFs by  doxygen 1.5.2