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 P_CSCF_REGISTRAR_SUBSCRIBE_H_
00058 #define P_CSCF_REGISTRAR_SUBSCRIBE_H_
00059
00060 #include "../../sr_module.h"
00061 #include "../../locking.h"
00062 #include "../tm/tm_load.h"
00063
00064 #include "registrar_storage.h"
00065
00067 enum {
00068 IMS_REGINFO_FULL,
00069 IMS_REGINFO_PARTIAL,
00070 IMS_REGINFO_ACTIVE,
00071 IMS_REGINFO_TERMINATED
00072 }IMS_Reginfo_states;
00073
00075 enum {
00076 IMS_REGINFO_NONE,
00077 IMS_REGINFO_SUBSCRIBE,
00078 IMS_REGINFO_SUBSCRIBE_EXPIRED,
00080 IMS_REGINFO_CONTACT_REGISTERED,
00081 IMS_REGINFO_CONTACT_CREATED,
00082 IMS_REGINFO_CONTACT_REFRESHED,
00083 IMS_REGINFO_CONTACT_SHORTENED,
00084 IMS_REGINFO_CONTACT_EXPIRED,
00085 IMS_REGINFO_CONTACT_DEACTIVATED,
00086 IMS_REGINFO_CONTACT_PROBATION,
00087 IMS_REGINFO_CONTACT_UNREGISTERED,
00088 IMS_REGINFO_CONTACT_REJECTED
00089 }IMS_Registrar_events;
00090
00092 typedef struct _r_subscription {
00093 unsigned int hash;
00094 str req_uri;
00095 int duration;
00096 time_t expires;
00097 char attempts_left;
00099 dlg_t *dialog;
00100
00101 struct _r_subscription *next, *prev;
00102 } r_subscription;
00103
00105 typedef struct {
00106 gen_lock_t *lock;
00107 r_subscription *head;
00108 r_subscription *tail;
00109 } r_subscription_hash_slot;
00110
00111 void subs_lock(unsigned int hash);
00112 void subs_unlock(unsigned int hash);
00113 unsigned int get_subscription_hash(str uri);
00114 int r_subscription_init();
00115 void r_subscription_destroy();
00116
00117
00118 int P_subscribe(struct sip_msg *rpl, char* str1, char* str2);
00119
00120 int r_subscribe(str uri,int duration);
00121
00122
00123 int r_send_subscribe(r_subscription *s,int duration);
00124
00125 void r_subscribe_response(struct cell *t,int type,struct tmcb_params *ps);
00126
00127 int P_notify(struct sip_msg *msg,char *str1,char *str2);
00128
00129 void subscription_timer(unsigned int ticks, void* param);
00130
00131 r_subscription* new_r_subscription(str req_uri,int duration);
00132 void add_r_subscription(r_subscription *s);
00133 int update_r_subscription(r_subscription *s,int expires);
00134 r_subscription* get_r_subscription(str aor);
00135 int is_r_subscription(str aor);
00136 void del_r_subscription(r_subscription *s);
00137 void del_r_subscription_nolock(r_subscription *s);
00138 void free_r_subscription(r_subscription *s);
00139 void print_subs(int log_level);
00140
00142 typedef struct _r_regcontact {
00143 str id;
00144 str uri;
00145 int state;
00146 int event;
00147 int expires;
00148
00149 struct _r_regcontact *next;
00150 } r_regcontact;
00151
00153 typedef struct _r_registration {
00154 str id;
00155 str aor;
00156 int state;
00157
00158 r_regcontact *contact;
00159 struct _r_registration *next;
00160 } r_registration;
00161
00163 typedef struct {
00164 int state;
00165 r_registration *registration;
00166 } r_notification;
00167
00168 int parser_init(char *dtd_filename);
00169 void parser_destroy();
00170
00171 r_notification* r_notification_parse(str xml);
00172 int r_notification_process(r_notification *n,int expires);
00173 void r_notification_print(r_notification *n);
00174 void r_notification_free(r_notification *n);
00175
00176
00177 #endif //P_CSCF_REGISTRAR_SUBSCRIBE_H_