* Create dialog structure * param msg SIP message * return dialog */
| 125 | * return dialog |
| 126 | */ |
| 127 | static dlg_t* ospCreateDialog( |
| 128 | struct sip_msg* msg, |
| 129 | str* tag) |
| 130 | { |
| 131 | struct to_body* from; |
| 132 | struct to_body* to; |
| 133 | contact_body_t* contact; |
| 134 | str record_route = { 0, 0 }; |
| 135 | dlg_t* dialog = NULL; |
| 136 | |
| 137 | if ((dialog = (dlg_t*)pkg_malloc(sizeof(dlg_t))) != NULL) { |
| 138 | /* Retrieve message info */ |
| 139 | from = msg->from->parsed; |
| 140 | to = msg->to->parsed; |
| 141 | contact = msg->contact->parsed; |
| 142 | |
| 143 | /* Init dialog structure */ |
| 144 | memset(dialog, 0, sizeof(dlg_t)); |
| 145 | |
| 146 | if (uandd_to_uri(from->parsed_uri.user, from->parsed_uri.host, &dialog->rem_uri) < 0) { |
| 147 | LM_ERR("failed to construct from uri\n"); |
| 148 | pkg_free(dialog); |
| 149 | dialog = NULL; |
| 150 | } else if (uandd_to_uri(to->parsed_uri.user, to->parsed_uri.host, &dialog->loc_uri) < 0) { |
| 151 | LM_ERR("failed to construct to uri\n"); |
| 152 | pkg_free(dialog->rem_uri.s); |
| 153 | pkg_free(dialog); |
| 154 | dialog = NULL; |
| 155 | } else { |
| 156 | /* Set From */ |
| 157 | dialog->id.rem_tag = from->tag_value; |
| 158 | |
| 159 | /* Set To*/ |
| 160 | if ((to->tag_value.s == NULL) || (to->tag_value.len == 0)) { |
| 161 | dialog->id.loc_tag = *tag; |
| 162 | } else { |
| 163 | dialog->id.loc_tag = to->tag_value; |
| 164 | } |
| 165 | |
| 166 | /* Set display names */ |
| 167 | if(osp_tmb.dlg_add_extra(dialog, &(from->display), &(to->display)) < 0) { |
| 168 | LM_WARN("failed to add display names\n"); |
| 169 | } |
| 170 | |
| 171 | /* Set Call-ID */ |
| 172 | dialog->id.call_id = msg->callid->body; |
| 173 | |
| 174 | /* Set Contact */ |
| 175 | if ((contact->contacts->uri.len == 0) || (contact->contacts->uri.s == NULL)) { |
| 176 | dialog->rem_target = dialog->rem_uri; |
| 177 | } else { |
| 178 | dialog->rem_target = contact->contacts->uri; |
| 179 | } |
| 180 | |
| 181 | /* Set CSeq */ |
| 182 | dialog->loc_seq.value = 0; |
| 183 | dialog->loc_seq.is_set = 1; |
| 184 |
no test coverage detected