pua/hash.h
Go to the documentation of this file.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 #ifndef _PU_HASH_H_
00027 #define _PU_HASH_H_
00028
00029 #include <stdlib.h>
00030 #include <string.h>
00031 #include <stdio.h>
00032 #include "../../str.h"
00033 #include "../../lock_ops.h"
00034 #include "../../dprint.h"
00035 #include "../../parser/msg_parser.h"
00036
00037 #define PRESENCE_EVENT 1<<0
00038 #define PWINFO_EVENT 1<<1
00039 #define BLA_EVENT 1<<2
00040 #define MSGSUM_EVENT 1<<3
00041 #define CONFERENCE_EVENT 1<<4
00042 #define DIALOG_EVENT 1<<5
00043
00044 #define UL_PUBLISH 1<<0
00045 #define BLA_PUBLISH 1<<1
00046 #define BLA_SUBSCRIBE 1<<2
00047 #define XMPP_PUBLISH 1<<3
00048 #define XMPP_SUBSCRIBE 1<<4
00049 #define XMPP_INITIAL_SUBS 1<<5
00050 #define MI_PUBLISH 1<<6
00051 #define MI_ASYN_PUBLISH 1<<7
00052 #define MI_SUBSCRIBE 1<<8
00053 #define RLS_SUBSCRIBE 1<<9
00054 #define DIALOG_PUBLISH 1<<10
00055 #define PURPLE_PUBLISH 1<<11
00056
00057 #define NO_UPDATEDB_FLAG 1<<0
00058 #define UPDATEDB_FLAG 1<<1
00059 #define INSERTDB_FLAG 1<<2
00060
00061 #define MAX_FORWARD 70
00062
00063 typedef struct ua_pres{
00064
00065
00066 str id;
00067 str* pres_uri;
00068 int event;
00069 unsigned int expires;
00070 unsigned int desired_expires;
00071 int flag;
00072 int db_flag;
00073 void* cb_param;
00074 struct ua_pres* next;
00075 int ua_flag;
00076
00077
00078 str etag;
00079 str tuple_id;
00080 str* body;
00081 str content_type;
00082
00083
00084 str* watcher_uri;
00085 str call_id;
00086 str to_tag;
00087 str from_tag;
00088 int cseq;
00089 int version;
00090 int watcher_count;
00091 str* outbound_proxy;
00092 str* extra_headers;
00093 str record_route;
00094 str remote_contact;
00095 str contact;
00096
00097
00098 }ua_pres_t;
00099
00100 typedef struct hash_entry
00101 {
00102 ua_pres_t* entity;
00103 gen_lock_t lock;
00104 }hash_entry_t;
00105
00106 typedef struct htable{
00107 hash_entry_t* p_records;
00108 }htable_t;
00109
00110 htable_t* new_htable(void);
00111
00112 ua_pres_t* search_htable(ua_pres_t* pres, unsigned int hash_code);
00113
00114 void insert_htable(ua_pres_t* presentity );
00115
00116 void update_htable(ua_pres_t* presentity,time_t desired_expires,
00117 int expires, str* etag, unsigned int hash_code, str* contact);
00118
00119 void delete_htable(ua_pres_t* presentity, unsigned int hash_code);
00120
00121 void destroy_htable(void);
00122 int is_dialog(ua_pres_t* dialog);
00123
00124 ua_pres_t* get_dialog(ua_pres_t* dialog, unsigned int hash_code);
00125
00126 int get_record_id(ua_pres_t* dialog, str** rec_id);
00127 typedef int (*get_record_id_t)(ua_pres_t* dialog, str** rec_id);
00128
00129
00130 void print_ua_pres(ua_pres_t* p);
00131
00132 typedef int (*query_dialog_t)(ua_pres_t* presentity);
00133
00134 static inline int get_event_flag(str* event)
00135 {
00136 switch (event->len)
00137 {
00138 case 6:
00139 if (strncmp(event->s, "dialog", 6) == 0)
00140 return DIALOG_EVENT;
00141 break;
00142 case 8:
00143 if (strncmp(event->s, "presence", 8) == 0)
00144 return PRESENCE_EVENT;
00145 break;
00146 case 10:
00147 if (strncmp(event->s, "dialog;sla", 10) == 0)
00148 return BLA_EVENT;
00149 if (strncmp(event->s, "conference", 10) == 0)
00150 return CONFERENCE_EVENT;
00151 break;
00152 case 14:
00153 if (strncmp(event->s, "presence;winfo", 14) == 0)
00154 return PWINFO_EVENT;
00155 break;
00156 case 15:
00157 if (strncmp(event->s, "message-summary", 15) == 0)
00158 return MSGSUM_EVENT;
00159 }
00160
00161 LM_ERR("Unknown event string\n");
00162 return -1;
00163 }
00164
00165 int update_contact(struct sip_msg* msg, char* str1, char* str2);
00166
00167 #endif