Changeset 1742


Ignore:
Timestamp:
Jan 24, 2008 7:20:54 PM (16 years ago)
Author:
bennylp
Message:

Return 406/Not Acceptable if SRTP negotiation failed instead of 500

Location:
pjproject/trunk/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r1735 r1742  
    316316pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, 
    317317                                     pjsip_role_e role, 
    318                                      int security_level); 
     318                                     int security_level, 
     319                                     int *sip_err_code); 
    319320pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,  
    320321                                           pj_pool_t *pool, 
    321322                                           const pjmedia_sdp_session *rem_sdp, 
    322                                            pjmedia_sdp_session **p_sdp); 
     323                                           pjmedia_sdp_session **p_sdp, 
     324                                           int *sip_err_code); 
    323325pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, 
    324326                                       pjmedia_sdp_session *local_sdp, 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r1735 r1742  
    402402    /* Init media channel */ 
    403403    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC,  
    404                                       get_secure_level(dest_uri)); 
     404                                      get_secure_level(dest_uri), NULL); 
    405405    if (status != PJ_SUCCESS) { 
    406406        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     
    412412    offer = NULL; 
    413413#else 
    414     status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL, &offer); 
     414    status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL,  
     415                                            &offer, NULL); 
    415416    if (status != PJ_SUCCESS) { 
    416417        pjsua_perror(THIS_FILE, "pjmedia unable to create SDP", status); 
     
    559560    pjsua_call *call; 
    560561    int call_id = -1; 
    561     int secure_level; 
     562    int secure_level, sip_err_code; 
    562563    pjmedia_sdp_session *offer, *answer; 
    563564    pj_status_t status; 
     
    692693    /* Init media channel */ 
    693694    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,  
    694                                       secure_level); 
    695     if (status != PJ_SUCCESS) { 
    696         pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 
     695                                      secure_level, &sip_err_code); 
     696    if (status != PJ_SUCCESS) { 
     697        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     698        pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,  
     699                                      sip_err_code, NULL, 
    697700                                      NULL, NULL); 
    698701        PJSUA_UNLOCK(); 
     
    719722    /* Get media capability from media endpoint: */ 
    720723    status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,  
    721                                             offer, &answer); 
    722     if (status != PJ_SUCCESS) { 
    723         pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 
     724                                            offer, &answer, &sip_err_code); 
     725    if (status != PJ_SUCCESS) { 
     726        pjsua_perror(THIS_FILE, "Error creating SDP answer", status); 
     727        pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata,  
     728                                      sip_err_code, NULL, 
    724729                                      NULL, NULL); 
    725730        pjsua_media_channel_deinit(call->index); 
     
    14251430    /* Init media channel */ 
    14261431    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 
    1427                                       get_secure_level(&dlg->remote.info_str)); 
     1432                                      get_secure_level(&dlg->remote.info_str), 
     1433                                      NULL); 
    14281434    if (status != PJ_SUCCESS) { 
    14291435        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     
    14361442    PJ_TODO(create_active_inactive_sdp_based_on_unhold_arg); 
    14371443    status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,  
    1438                                             NULL, &sdp); 
     1444                                            NULL, &sdp, NULL); 
    14391445    if (status != PJ_SUCCESS) { 
    14401446        pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",  
     
    14951501    /* Init media channel */ 
    14961502    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 
    1497                                       get_secure_level(&dlg->remote.info_str)); 
     1503                                      get_secure_level(&dlg->remote.info_str), 
     1504                                      NULL); 
    14981505    if (status != PJ_SUCCESS) { 
    14991506        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     
    15041511    /* Create SDP */ 
    15051512    status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,  
    1506                                             NULL, &sdp); 
     1513                                            NULL, &sdp, NULL); 
    15071514    if (status != PJ_SUCCESS) { 
    15081515        pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint",  
     
    26242631        secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 
    26252632        status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 
    2626                                           secure_level); 
     2633                                          secure_level, NULL); 
    26272634        if (status != PJ_SUCCESS) { 
    26282635            pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     
    26322639 
    26332640        status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,  
    2634                                                 offer, &answer); 
     2641                                                offer, &answer, NULL); 
    26352642    } 
    26362643 
     
    26802687        secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 
    26812688        status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 
    2682                                           secure_level); 
     2689                                          secure_level, NULL); 
    26832690        if (status != PJ_SUCCESS) { 
    26842691            pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     
    26882695 
    26892696        status = pjsua_media_channel_create_sdp(call->index, call->inv->pool,  
    2690                                                 NULL, offer); 
     2697                                                NULL, offer, NULL); 
    26912698    } 
    26922699 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r1735 r1742  
    747747pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, 
    748748                                     pjsip_role_e role, 
    749                                      int security_level) 
     749                                     int security_level, 
     750                                     int *sip_err_code) 
    750751{ 
    751752    pjsua_call *call = &pjsua_var.calls[call_id]; 
     
    774775    if (acc->cfg.use_srtp != PJMEDIA_SRTP_DISABLED) { 
    775776        if (security_level < acc->cfg.srtp_secure_signaling) { 
     777            if (sip_err_code) 
     778                *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE; 
    776779            return PJSIP_ESESSIONINSECURE; 
    777780        } 
     
    785788                                           call->med_tp, 
    786789                                           &srtp_opt, &srtp); 
    787     if (status != PJ_SUCCESS) 
    788         return status; 
     790    if (status != PJ_SUCCESS) { 
     791        if (sip_err_code) 
     792            *sip_err_code = PJSIP_SC_INTERNAL_SERVER_ERROR; 
     793        return status; 
     794    } 
    789795 
    790796    /* Set SRTP as current media transport */ 
     
    802808                                           pj_pool_t *pool, 
    803809                                           const pjmedia_sdp_session *rem_sdp, 
    804                                            pjmedia_sdp_session **p_sdp) 
     810                                           pjmedia_sdp_session **p_sdp, 
     811                                           int *sip_status_code) 
    805812{ 
    806813    enum { MAX_MEDIA = 1, MEDIA_IDX = 0 }; 
     
    823830    status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, pool, MAX_MEDIA, 
    824831                                      &skinfo, &sdp); 
    825     if (status != PJ_SUCCESS) 
     832    if (status != PJ_SUCCESS) { 
     833        if (sip_status_code) *sip_status_code = 500; 
    826834        goto on_error; 
     835    } 
    827836 
    828837    /* Add NAT info in the SDP */ 
     
    853862    status = pjmedia_transport_media_create(call->med_tp, pool,  
    854863                                            sdp, rem_sdp, MEDIA_IDX); 
    855     if (status != PJ_SUCCESS) 
     864    if (status != PJ_SUCCESS) { 
     865        if (sip_status_code) *sip_status_code = PJSIP_SC_NOT_ACCEPTABLE; 
    856866        goto on_error; 
     867    } 
    857868 
    858869    *p_sdp = sdp; 
Note: See TracChangeset for help on using the changeset viewer.