Bridge an initial Invite with an existing dialog */ key and entity_no identity the existing call and the which entity from the call * to bridge (0 or 1) */
| 2194 | /* key and entity_no identity the existing call and the which entity from the call |
| 2195 | * to bridge (0 or 1) */ |
| 2196 | int b2bl_bridge_msg(struct sip_msg* msg, str* key, int entity_no, |
| 2197 | unsigned int flags, str *adv_ct) |
| 2198 | { |
| 2199 | b2bl_tuple_t* tuple; |
| 2200 | struct b2b_context *ctx; |
| 2201 | struct b2b_ctx_val *v, *v_old; |
| 2202 | unsigned int hash_index, local_index; |
| 2203 | b2bl_entity_id_t *bridging_entity= NULL; |
| 2204 | b2bl_entity_id_t *old_entity; |
| 2205 | b2bl_entity_id_t *entity; |
| 2206 | str* server_id; |
| 2207 | str body = {0, 0}, new_body = {0, 0}; |
| 2208 | str to_uri={NULL,0}, from_uri, from_dname; |
| 2209 | b2b_req_data_t req_data; |
| 2210 | int ret; |
| 2211 | str local_contact, *ct_hdrs; |
| 2212 | int maxfwd; |
| 2213 | |
| 2214 | if(!msg || !key) |
| 2215 | { |
| 2216 | LM_ERR("Wrong arguments [%p] [%p]\n", msg, key); |
| 2217 | return -1; |
| 2218 | } |
| 2219 | |
| 2220 | ret = b2bl_get_tuple_key(key, &hash_index, &local_index, NULL); |
| 2221 | if(ret < 0) |
| 2222 | { |
| 2223 | if (ret == -1) |
| 2224 | LM_ERR("Failed to parse key or find an entity [%.*s]\n", |
| 2225 | key->len, key->s); |
| 2226 | else |
| 2227 | LM_ERR("Could not find entity [%.*s]\n", |
| 2228 | key->len, key->s); |
| 2229 | return -1; |
| 2230 | } |
| 2231 | |
| 2232 | /* extract the entity and delete the tuple */ |
| 2233 | B2BL_LOCK_GET(hash_index); |
| 2234 | |
| 2235 | tuple = b2bl_search_tuple_safe(hash_index, local_index); |
| 2236 | if(tuple == NULL) |
| 2237 | { |
| 2238 | LM_ERR("No entity found\n"); |
| 2239 | goto error; |
| 2240 | } |
| 2241 | |
| 2242 | /* save tuple in global variable for accesss from local routes */ |
| 2243 | local_ctx_tuple = tuple; |
| 2244 | |
| 2245 | /* update tuple context values with the new ones set in request route */ |
| 2246 | for (v = local_ctx_vals; v; v = v->next) { |
| 2247 | for (v_old = tuple->vals; v_old; v_old = v_old->next) |
| 2248 | if (!str_strcmp(&v->name, &v_old->name)) { |
| 2249 | if (store_ctx_value(&tuple->vals, &v->name, &v->val) < 0) |
| 2250 | LM_ERR("Failed to store context value [%.*s]\n", |
| 2251 | v->name.len, v->name.s); |
| 2252 | |
| 2253 | break; |
no test coverage detected