| 3129 | } |
| 3130 | |
| 3131 | str* b2b_process_scenario_init(struct sip_msg* msg, b2bl_cback_f cbf, |
| 3132 | void* cb_param, unsigned int cb_mask, str* custom_hdrs, |
| 3133 | struct b2b_params *init_params) |
| 3134 | { |
| 3135 | str* server_id= NULL, *client_id= NULL; |
| 3136 | str body= {NULL, 0}; |
| 3137 | str method = {INVITE, INVITE_LEN}; |
| 3138 | str* b2bl_key = NULL; |
| 3139 | b2bl_tuple_t* tuple= NULL; |
| 3140 | struct b2b_context *ctx; |
| 3141 | b2bl_entity_id_t* client_entity = NULL; |
| 3142 | client_info_t ci; |
| 3143 | unsigned int hash_index; |
| 3144 | str to_uri={NULL, 0}, from_uri, from_dname; |
| 3145 | int eno = 0; |
| 3146 | str *hdrs, *ct_hdrs; |
| 3147 | struct b2bl_new_entity *new_entity; |
| 3148 | struct b2bl_new_entity *e1, *e2; |
| 3149 | int maxfwd; |
| 3150 | |
| 3151 | if(msg == NULL) |
| 3152 | { |
| 3153 | LM_ERR("NO SIP message\n"); |
| 3154 | goto error; |
| 3155 | } |
| 3156 | |
| 3157 | if (!str_match(&method, &msg->first_line.u.request.method)) { |
| 3158 | LM_ERR("Scenario must be initialized on INVITE but got method: %.*s\n", |
| 3159 | msg->first_line.u.request.method.len, |
| 3160 | msg->first_line.u.request.method.s); |
| 3161 | goto error; |
| 3162 | } |
| 3163 | |
| 3164 | if(b2b_msg_get_from(msg, &from_uri, &from_dname)< 0 || |
| 3165 | b2b_msg_get_to(msg, &to_uri, init_params->flags)< 0) |
| 3166 | { |
| 3167 | LM_ERR("Failed to get to or from from the message\n"); |
| 3168 | goto error; |
| 3169 | } |
| 3170 | hash_index = core_hash(&to_uri, &from_uri, b2bl_hsize); |
| 3171 | |
| 3172 | method = msg->first_line.u.request.method; |
| 3173 | |
| 3174 | if(msg->content_length) |
| 3175 | { |
| 3176 | if ( get_body(msg, &body)!=0 ) |
| 3177 | { |
| 3178 | LM_ERR("cannot extract body\n"); |
| 3179 | goto error; |
| 3180 | } |
| 3181 | } |
| 3182 | |
| 3183 | /* create new scenario instance record */ |
| 3184 | tuple = b2bl_insert_new(msg, hash_index, init_params, |
| 3185 | custom_hdrs, -1, &b2bl_key, INSERTDB_FLAG, TUPLE_NO_REPL); |
| 3186 | if(tuple== NULL) |
| 3187 | { |
| 3188 | LM_ERR("Failed to insert new scenario instance record\n"); |
no test coverage detected