diff options
Diffstat (limited to 'pjsip')
-rw-r--r-- | pjsip/src/pjsip/sip_dialog.c | 30 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_acc.c | 27 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_pres.c | 4 |
3 files changed, 49 insertions, 12 deletions
diff --git a/pjsip/src/pjsip/sip_dialog.c b/pjsip/src/pjsip/sip_dialog.c index 969d0b3d..8df82b7d 100644 --- a/pjsip/src/pjsip/sip_dialog.c +++ b/pjsip/src/pjsip/sip_dialog.c @@ -307,7 +307,8 @@ PJ_DEF(pj_status_t) pjsip_dlg_create_uas( pjsip_user_agent *ua, pjsip_dialog **p_dlg) { pj_status_t status; - pjsip_hdr *contact_hdr; + pjsip_hdr *pos = NULL; + pjsip_contact_hdr *contact_hdr; pjsip_rr_hdr *rr; pjsip_transaction *tsx = NULL; pj_str_t tmp; @@ -416,16 +417,33 @@ PJ_DEF(pj_status_t) pjsip_dlg_create_uas( pjsip_user_agent *ua, pj_strdup(dlg->pool, &dlg->remote.info_str, &tmp); - /* Init remote's contact from Contact header. */ - contact_hdr = (pjsip_hdr*) - pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, - NULL); + /* Init remote's contact from Contact header. + * Iterate the Contact URI until we find sip: or sips: scheme. + */ + do { + contact_hdr = (pjsip_contact_hdr*) + pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, + pos); + if (contact_hdr) { + if (!PJSIP_URI_SCHEME_IS_SIP(contact_hdr->uri) && + !PJSIP_URI_SCHEME_IS_SIPS(contact_hdr->uri)) + { + pos = (pjsip_hdr*)contact_hdr->next; + if (pos == &rdata->msg_info.msg->hdr) + contact_hdr = NULL; + } else { + break; + } + } + } while (contact_hdr); + if (!contact_hdr) { status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_REQUEST); goto on_error; } + dlg->remote.contact = (pjsip_contact_hdr*) - pjsip_hdr_clone(dlg->pool, contact_hdr); + pjsip_hdr_clone(dlg->pool, (pjsip_hdr*)contact_hdr); /* Init remote's CSeq from CSeq header */ dlg->remote.cseq = dlg->remote.first_cseq = rdata->msg_info.cseq->cseq; diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c index a234964c..f2853fa6 100644 --- a/pjsip/src/pjsua-lib/pjsua_acc.c +++ b/pjsip/src/pjsua-lib/pjsua_acc.c @@ -1674,15 +1674,30 @@ PJ_DEF(pj_status_t) pjsua_acc_create_uas_contact( pj_pool_t *pool, sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(rdata->msg_info.record_route->name_addr.uri); } else { + pjsip_hdr *pos = NULL; pjsip_contact_hdr *h_contact; pjsip_uri *uri = NULL; - /* Otherwise URI is Contact URI */ - h_contact = (pjsip_contact_hdr*) - pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, - NULL); - if (h_contact) - uri = (pjsip_uri*) pjsip_uri_get_uri(h_contact->uri); + /* Otherwise URI is Contact URI. + * Iterate the Contact URI until we find sip: or sips: scheme. + */ + do { + h_contact = (pjsip_contact_hdr*) + pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, + pos); + if (h_contact) { + uri = (pjsip_uri*) pjsip_uri_get_uri(h_contact->uri); + if (!PJSIP_URI_SCHEME_IS_SIP(uri) && + !PJSIP_URI_SCHEME_IS_SIPS(uri)) + { + pos = (pjsip_hdr*)h_contact->next; + if (pos == &rdata->msg_info.msg->hdr) + h_contact = NULL; + } else { + break; + } + } + } while (h_contact); /* Or if Contact URI is not present, take the remote URI from diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c index e2c35c1e..23050ff2 100644 --- a/pjsip/src/pjsua-lib/pjsua_pres.c +++ b/pjsip/src/pjsua-lib/pjsua_pres.c @@ -688,6 +688,8 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata) pjsua_perror(THIS_FILE, "Unable to generate Contact header", status); PJSUA_UNLOCK(); + pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL, + NULL, NULL); return PJ_TRUE; } } @@ -700,6 +702,8 @@ static pj_bool_t pres_on_rx_request(pjsip_rx_data *rdata) "Unable to create UAS dialog for subscription", status); PJSUA_UNLOCK(); + pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL, + NULL, NULL); return PJ_TRUE; } |