MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / _client_new

Function _client_new

modules/b2b_entities/client.c:81–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80#define HASH_SIZE 1<<23
81str* _client_new(client_info_t* ci,b2b_notify_t b2b_cback,
82 b2b_add_dlginfo_t add_dlginfo, str *mod_name, str* logic_key,
83 struct ua_sess_init_params *init_params, struct b2b_tracer *tracer,
84 void *param, b2b_param_free_cb free_param)
85{
86 int result;
87 b2b_dlg_t* dlg;
88 unsigned int hash_index;
89 str* callid = NULL;
90 int size;
91 str ehdr = {0, 0};
92 str* b2b_key_shm = NULL;
93 dlg_t td;
94 str from_tag;
95 str random_info = {0, 0};
96
97 if(ci == NULL || (!init_params && (b2b_cback == NULL || logic_key == NULL)))
98 {
99 LM_ERR("Wrong parameters.\n");
100 return NULL;
101 }
102
103 hash_index = core_hash(&ci->from_uri, &ci->to_uri, client_hsize);
104
105 if(ci->from_tag)
106 from_tag = *ci->from_tag;
107 else
108 generate_tag(&from_tag, &ci->from_uri, ci->extra_headers);
109
110 /* create a dummy b2b dialog structure to be inserted in the hash table*/
111 size = sizeof(b2b_dlg_t) + ci->to_uri.len + ci->from_uri.len
112 + ci->from_dname.len + ci->to_dname.len + ci->dst_uri.len +
113 from_tag.len + ci->local_contact.len + B2B_MAX_KEY_SIZE +
114 mod_name->len;
115
116 /* create record in hash table */
117 dlg = (b2b_dlg_t*)shm_malloc(size);
118 if(dlg == NULL)
119 {
120 LM_ERR("No more shared memory\n");
121 return 0;
122 }
123 memset(dlg, 0, size);
124 size = sizeof(b2b_dlg_t);
125
126 CONT_COPY(dlg, dlg->from_uri, ci->from_uri);
127 CONT_COPY(dlg, dlg->to_uri, ci->to_uri);
128 if(ci->to_dname.s)
129 CONT_COPY(dlg, dlg->to_dname, ci->to_dname);
130 if(ci->from_dname.s)
131 CONT_COPY(dlg, dlg->from_dname, ci->from_dname);
132 if(ci->dst_uri.s)
133 CONT_COPY(dlg, dlg->proxy, ci->dst_uri);
134 CONT_COPY(dlg, dlg->tag[CALLER_LEG], from_tag);
135 CONT_COPY(dlg, dlg->contact[CALLER_LEG], ci->local_contact);
136
137 if(logic_key && logic_key->s && shm_str_dup(&dlg->logic_key, logic_key) < 0) {
138 LM_ERR("not enough shm memory\n");

Callers 2

client_newFunction · 0.85

Calls 9

core_hashFunction · 0.85
generate_tagFunction · 0.85
shm_mallocFunction · 0.85
parse_methodFunction · 0.85
int2strFunction · 0.85
b2b_htable_insertFunction · 0.85
b2breq_complete_ehdrFunction · 0.85
b2b_key_copy_shmFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected