registrar_storage.h

Go to the documentation of this file.
00001 /*
00002  * $Id: registrar_storage.h 336 2007-06-21 23:07:09Z flp $
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 
00055 #ifndef P_CSCF_REGISTRAR_STORAGE_H_
00056 #define P_CSCF_REGISTRAR_STORAGE_H_
00057 
00058 #include "../../sr_module.h"
00059 #include "../../locking.h"
00060 
00062 typedef struct _r_nat_dest{
00063     struct ip_addr nat_addr;    
00064     unsigned short nat_port;    
00065 }r_nat_dest;
00066 
00068 typedef struct _r_public {
00069     str aor;                    
00070     char is_default;            
00072     struct _r_public *next;     
00073     struct _r_public *prev;     
00074 } r_public;
00075 
00077 enum Reg_States {
00078     NOT_REGISTERED=0,           
00079     REGISTERED=1,               
00080     REG_PENDING=-1,             
00081     DEREGISTERED=-2             
00082 } ;
00083 
00085 typedef struct _r_ipsec {
00086     int spi_uc;                 
00087     int spi_us;                 
00088     int spi_pc;                 
00089     int spi_ps;                 
00090     unsigned short port_uc;     
00091     unsigned short port_us;     
00093     str ealg;                   
00094     str r_ealg;                 
00095     str ck;                     
00096     str alg;                    
00097     str r_alg;              
00098     str ik;                     
00099 } r_ipsec;
00100 
00102 typedef struct _r_tls {
00103     unsigned short port_tls;    
00104     unsigned long session_hash;
00105 } r_tls;
00106 
00107 typedef enum _r_sec_type {
00108     SEC_NONE    =0,
00109     SEC_IPSEC   =1,
00110     SEC_TLS     =2,
00111 } r_security_type;
00112 
00113 typedef struct _r_security {
00114     str sec_header;             
00115     r_security_type type;       
00116     union {
00117         r_ipsec *ipsec;         
00118         r_tls *tls;             
00119     } data;
00120     float q;
00121 } r_security;
00122 
00124 typedef struct _r_contact {
00125     unsigned int hash;          
00127     str host;                   
00128     unsigned short port;        
00129     char transport;             
00131     r_security *security_temp;  
00132     r_security *security;       
00134     str uri;                    
00136     enum Reg_States reg_state;  
00137     time_t expires;             
00139     unsigned short service_route_cnt;
00140     str *service_route;         
00142     r_nat_dest * pinhole;       
00144     r_public *head;             
00145     r_public *tail;             
00147     struct _r_contact *next;    
00148     struct _r_contact *prev;    
00149 } r_contact;
00150 
00152 typedef struct {
00153     r_contact *head;            
00154     r_contact *tail;            
00155     gen_lock_t *lock;           
00156 } r_hash_slot;
00157 
00158 
00159 void r_act_time();
00160 inline int r_valid_contact(r_contact *c);
00161 inline int r_reg_contact(r_contact *c);
00162 
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 unsigned int get_contact_hash(str aor,int port,int transport,int hash_size);
00171 
00172 r_public* new_r_public(str aor, int is_default);
00173 r_public* get_r_public(r_contact *c, str aor);
00174 r_public* add_r_public(r_contact *c,str aor,int is_default);
00175 r_public* update_r_public(r_contact *c,str aor,int *is_default);
00176 void del_r_public(r_contact *c,r_public *p);
00177 void free_r_public(r_public *p);
00178 
00179 r_ipsec* new_r_ipsec(int spi_uc,int spi_us,int spi_pc,int spi_ps,int port_uc,int port_us,
00180     str ealg_setkey,str r_ealg, str ck_esp,str alg_setkey,str r_alg, str ik_esp);
00181 void free_r_ipsec(r_ipsec *ipsec);
00182 
00183 r_tls* new_r_tls(int port_tls, unsigned long session_hash);
00184 void free_r_tls(r_tls *tls);
00185 
00186 r_security *new_r_security(str sec_header,r_security_type type,float q);
00187 void free_r_security(r_security *s);
00188 
00189 r_contact* new_r_contact(str host,int port,int transport,str uri,enum Reg_States reg_state,int expires,
00190     str *service_route,int service_route_cnt);  
00191 r_contact* get_r_contact(str host,int port,int transport);
00192 r_contact* add_r_contact(str host,int port,int transport,str uri,
00193     enum Reg_States reg_state,int expires,str *service_route,int service_route_cnt, r_nat_dest * pinhole);
00194 r_contact* update_r_contact(str host,int port,int transport,
00195     str *uri,enum Reg_States  *reg_state,int *expires,str **service_route,int *service_route_cnt, r_nat_dest ** pinhole);
00196 r_contact* update_r_contact_sec(str host,int port,int transport,
00197     str *uri,enum Reg_States *reg_state,int *expires,
00198     r_security *s);
00199 void del_r_contact(r_contact *c);
00200 void free_r_contact(r_contact *c);
00201 
00202 r_nat_dest * get_r_nat_pinhole(str host, int port, int transport);
00203 
00204 
00205 
00206 void print_r(int log_level);
00207 
00208 
00209 
00210 #endif //P_CSCF_REGISTRAR_STORAGE_H_

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