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
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
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
00114 char *s;
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_