00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
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_