| 39 | #include "b2b_entities.h" |
| 40 | |
| 41 | str* _server_new(struct sip_msg* msg, str* local_contact, b2b_notify_t b2b_cback, |
| 42 | str *mod_name, str* logic_key, struct ua_sess_init_params *ua_init_params, |
| 43 | struct b2b_tracer *tracer, void *param, b2b_param_free_cb free_param) |
| 44 | { |
| 45 | b2b_dlg_t* dlg; |
| 46 | unsigned int hash_index; |
| 47 | int ret; |
| 48 | |
| 49 | /* create new entry in hash table */ |
| 50 | dlg = b2b_new_dlg(msg, local_contact, 0, logic_key, mod_name); |
| 51 | if( dlg == NULL ) |
| 52 | { |
| 53 | LM_ERR("failed to create new dialog structure entry\n"); |
| 54 | return NULL; |
| 55 | } |
| 56 | hash_index = core_hash(&dlg->callid, &dlg->tag[CALLER_LEG], server_hsize); |
| 57 | |
| 58 | /* check if record does not exist already */ |
| 59 | |
| 60 | dlg->state = B2B_NEW; |
| 61 | dlg->b2b_cback = b2b_cback; |
| 62 | dlg->param = param; |
| 63 | dlg->free_param = free_param; |
| 64 | dlg->tracer = tracer; |
| 65 | dlg->ua_flags = ua_init_params?ua_init_params->flags:0; |
| 66 | |
| 67 | /* get the pointer to the tm transaction to store it the tuple record */ |
| 68 | dlg->uas_tran = tmb.t_gett(); |
| 69 | if(dlg->uas_tran == NULL || dlg->uas_tran == T_UNDEFINED) |
| 70 | { |
| 71 | ret = tmb.t_newtran(msg); |
| 72 | if(ret < 1) |
| 73 | { |
| 74 | if(ret== 0) |
| 75 | { |
| 76 | LM_DBG("It is a retransmission, drop\n"); |
| 77 | } |
| 78 | else |
| 79 | LM_DBG("Error when creating tm transaction\n"); |
| 80 | goto error; |
| 81 | } |
| 82 | dlg->uas_tran = tmb.t_gett(); |
| 83 | } |
| 84 | |
| 85 | /* start tracing for this transaction */ |
| 86 | b2b_run_tracer( dlg, msg, dlg->uas_tran); |
| 87 | |
| 88 | tmb.ref_cell(dlg->uas_tran); |
| 89 | tmb.t_setkr(REQ_FWDED); |
| 90 | |
| 91 | LM_DBG("new server entity[%p]: callid=[%.*s] tag=[%.*s] param=[%.*s] dlg->uas_tran=[%p]\n", |
| 92 | dlg, dlg->callid.len, dlg->callid.s, |
| 93 | dlg->tag[CALLER_LEG].len, dlg->tag[CALLER_LEG].s, |
| 94 | dlg->logic_key.len, dlg->logic_key.s, dlg->uas_tran); |
| 95 | |
| 96 | /* add the record in hash table */ |
| 97 | dlg->db_flag = INSERTDB_FLAG; |
| 98 | return b2b_htable_insert(server_htable, dlg, hash_index, NULL, B2B_SERVER, 0, 1, |
no test coverage detected