summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-01-24 19:20:54 +0000
committerBenny Prijono <bennylp@teluu.com>2008-01-24 19:20:54 +0000
commit66c935c6d8de646d93fc4ae33c974ac668dc464f (patch)
treec7aebb033a2702ff2c4370aad3510ef94e7e10e8 /pjsip
parent1724cfe4c1b0cc812b890ae648a923ad591996d6 (diff)
Return 406/Not Acceptable if SRTP negotiation failed instead of 500
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1742 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsua-lib/pjsua_internal.h6
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c37
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c21
3 files changed, 42 insertions, 22 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index 261cea0e..c6cd4aee 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -315,11 +315,13 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata);
*/
pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
pjsip_role_e role,
- int security_level);
+ int security_level,
+ int *sip_err_code);
pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
pj_pool_t *pool,
const pjmedia_sdp_session *rem_sdp,
- pjmedia_sdp_session **p_sdp);
+ pjmedia_sdp_session **p_sdp,
+ int *sip_err_code);
pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
pjmedia_sdp_session *local_sdp,
const pjmedia_sdp_session *remote_sdp);
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 6cff391c..3d030841 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -401,7 +401,7 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
/* Init media channel */
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,
- get_secure_level(dest_uri));
+ get_secure_level(dest_uri), NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
goto on_error;
@@ -411,7 +411,8 @@ PJ_DEF(pj_status_t) pjsua_call_make_call( pjsua_acc_id acc_id,
#if LATE_SDP
offer = NULL;
#else
- status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL, &offer);
+ status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL,
+ &offer, NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "pjmedia unable to create SDP", status);
goto on_error;
@@ -558,7 +559,7 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
int acc_id;
pjsua_call *call;
int call_id = -1;
- int secure_level;
+ int secure_level, sip_err_code;
pjmedia_sdp_session *offer, *answer;
pj_status_t status;
@@ -691,9 +692,11 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
/* Init media channel */
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,
- secure_level);
+ secure_level, &sip_err_code);
if (status != PJ_SUCCESS) {
- pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
+ pjsua_perror(THIS_FILE, "Error initializing media channel", status);
+ pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,
+ sip_err_code, NULL,
NULL, NULL);
PJSUA_UNLOCK();
return PJ_TRUE;
@@ -718,9 +721,11 @@ pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata)
/* Get media capability from media endpoint: */
status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,
- offer, &answer);
+ offer, &answer, &sip_err_code);
if (status != PJ_SUCCESS) {
- pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
+ pjsua_perror(THIS_FILE, "Error creating SDP answer", status);
+ pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,
+ sip_err_code, NULL,
NULL, NULL);
pjsua_media_channel_deinit(call->index);
PJSUA_UNLOCK();
@@ -1424,7 +1429,8 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
/* Init media channel */
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,
- get_secure_level(&dlg->remote.info_str));
+ get_secure_level(&dlg->remote.info_str),
+ NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
pjsip_dlg_dec_lock(dlg);
@@ -1435,7 +1441,7 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id,
PJ_UNUSED_ARG(unhold);
PJ_TODO(create_active_inactive_sdp_based_on_unhold_arg);
status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,
- NULL, &sdp);
+ NULL, &sdp, NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",
status);
@@ -1494,7 +1500,8 @@ PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id,
/* Init media channel */
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,
- get_secure_level(&dlg->remote.info_str));
+ get_secure_level(&dlg->remote.info_str),
+ NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
pjsip_dlg_dec_lock(dlg);
@@ -1503,7 +1510,7 @@ PJ_DEF(pj_status_t) pjsua_call_update( pjsua_call_id call_id,
/* Create SDP */
status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,
- NULL, &sdp);
+ NULL, &sdp, NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",
status);
@@ -2623,7 +2630,7 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv,
/* Init media channel */
secure_level = get_secure_level(&call->inv->dlg->remote.info_str);
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,
- secure_level);
+ secure_level, NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
PJSUA_UNLOCK();
@@ -2631,7 +2638,7 @@ static void pjsua_call_on_rx_offer(pjsip_inv_session *inv,
}
status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,
- offer, &answer);
+ offer, &answer, NULL);
}
if (status != PJ_SUCCESS) {
@@ -2679,7 +2686,7 @@ static void pjsua_call_on_create_offer(pjsip_inv_session *inv,
/* Init media channel */
secure_level = get_secure_level(&call->inv->dlg->remote.info_str);
status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,
- secure_level);
+ secure_level, NULL);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error initializing media channel", status);
PJSUA_UNLOCK();
@@ -2687,7 +2694,7 @@ static void pjsua_call_on_create_offer(pjsip_inv_session *inv,
}
status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,
- NULL, offer);
+ NULL, offer, NULL);
}
if (status != PJ_SUCCESS) {
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index eab0b524..e1aec508 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -746,7 +746,8 @@ PJ_DEF(pj_status_t) pjsua_media_transports_create(
pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
pjsip_role_e role,
- int security_level)
+ int security_level,
+ int *sip_err_code)
{
pjsua_call *call = &pjsua_var.calls[call_id];
@@ -773,6 +774,8 @@ pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
/* Check if SRTP requires secure signaling */
if (acc->cfg.use_srtp != PJMEDIA_SRTP_DISABLED) {
if (security_level < acc->cfg.srtp_secure_signaling) {
+ if (sip_err_code)
+ *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE;
return PJSIP_ESESSIONINSECURE;
}
}
@@ -784,8 +787,11 @@ pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
status = pjmedia_transport_srtp_create(pjsua_var.med_endpt,
call->med_tp,
&srtp_opt, &srtp);
- if (status != PJ_SUCCESS)
+ if (status != PJ_SUCCESS) {
+ if (sip_err_code)
+ *sip_err_code = PJSIP_SC_INTERNAL_SERVER_ERROR;
return status;
+ }
/* Set SRTP as current media transport */
call->med_orig = call->med_tp;
@@ -801,7 +807,8 @@ pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
pj_pool_t *pool,
const pjmedia_sdp_session *rem_sdp,
- pjmedia_sdp_session **p_sdp)
+ pjmedia_sdp_session **p_sdp,
+ int *sip_status_code)
{
enum { MAX_MEDIA = 1, MEDIA_IDX = 0 };
pjmedia_sdp_session *sdp;
@@ -822,8 +829,10 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
/* Create SDP */
status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, MAX_MEDIA,
&skinfo, &sdp);
- if (status != PJ_SUCCESS)
+ if (status != PJ_SUCCESS) {
+ if (sip_status_code) *sip_status_code = 500;
goto on_error;
+ }
/* Add NAT info in the SDP */
if (pjsua_var.ua_cfg.nat_type_in_sdp) {
@@ -852,8 +861,10 @@ pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
/* Give the SDP to media transport */
status = pjmedia_transport_media_create(call->med_tp, pool,
sdp, rem_sdp, MEDIA_IDX);
- if (status != PJ_SUCCESS)
+ if (status != PJ_SUCCESS) {
+ if (sip_status_code) *sip_status_code = PJSIP_SC_NOT_ACCEPTABLE;
goto on_error;
+ }
*p_sdp = sdp;
return PJ_SUCCESS;