| 229 | } |
| 230 | |
| 231 | static void receive_entity_create(enum b2b_entity_type entity_type, |
| 232 | str *entity_key, str *b2bl_key, bin_packet_t *storage) |
| 233 | { |
| 234 | unsigned int hash_index, local_index; |
| 235 | b2bl_tuple_t *tuple = NULL, *old_tuple; |
| 236 | int tuple_repl_type; |
| 237 | str scenario_id; |
| 238 | str sdp; |
| 239 | str extra_headers; |
| 240 | int lifetime; |
| 241 | b2b_dlginfo_t dlginfo; |
| 242 | b2bl_entity_id_t *entity = NULL, **entity_head = NULL; |
| 243 | str entity_sid, to_uri, proxy, from_uri, from_dname, hdrs; |
| 244 | struct b2b_params init_params; |
| 245 | |
| 246 | LM_DBG("Received CREATE event for entity [%.*s]\n", |
| 247 | entity_key->len, entity_key->s); |
| 248 | |
| 249 | if (b2bl_parse_key(b2bl_key, &hash_index, &local_index) < 0) { |
| 250 | LM_ERR("Bad tuple key: %.*s\n", b2bl_key->len, b2bl_key->s); |
| 251 | return; |
| 252 | } |
| 253 | |
| 254 | B2BL_LOCK_GET(hash_index); |
| 255 | |
| 256 | old_tuple = b2bl_search_tuple_safe(hash_index, local_index); |
| 257 | |
| 258 | bin_pop_int(storage, &tuple_repl_type); |
| 259 | |
| 260 | switch (tuple_repl_type) { |
| 261 | case REPL_TUPLE_NEW: |
| 262 | if (!old_tuple) { |
| 263 | bin_pop_str(storage, &scenario_id); |
| 264 | bin_pop_str(storage, &extra_headers); |
| 265 | } else { |
| 266 | LM_DBG("Tuple [%.*s] already created\n", b2bl_key->len, b2bl_key->s); |
| 267 | bin_skip_str(storage, 2); |
| 268 | } |
| 269 | |
| 270 | if (old_tuple) { |
| 271 | tuple = old_tuple; |
| 272 | } else { |
| 273 | memset(&init_params, 0, sizeof init_params); |
| 274 | |
| 275 | if (!scenario_id.s) |
| 276 | init_params.id = B2B_INTERNAL_ID_PTR; |
| 277 | else if (!str_strcmp(&scenario_id, const_str(B2B_TOP_HIDING_SCENARY))) |
| 278 | init_params.id = B2B_TOP_HIDING_ID_PTR; |
| 279 | else |
| 280 | init_params.id = &scenario_id; |
| 281 | |
| 282 | init_params.req_route = global_req_rt_ref; |
| 283 | init_params.reply_route = global_reply_rt_ref; |
| 284 | |
| 285 | tuple = b2bl_insert_new(NULL, hash_index, &init_params, |
| 286 | &extra_headers, |
| 287 | local_index, &b2bl_key, INSERTDB_FLAG, TUPLE_REPL_RECV); |
| 288 | if (!tuple) { |
no test coverage detected