Changeset 1774 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Feb 2, 2008 5:07:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r1757 r1774 261 261 * 1: if TLS transport is used for immediate hop 262 262 * 2: if end-to-end signaling is secure. 263 * 264 * NOTE: 265 * THIS IS WRONG. It should take into account the route-set. 266 */ 267 static int get_secure_level(const pj_str_t *dst_uri) 263 */ 264 static int get_secure_level(pjsua_acc_id acc_id, const pj_str_t *dst_uri) 268 265 { 269 266 const pj_str_t tls = pj_str(";transport=tls"); 270 267 const pj_str_t sips = pj_str("sips:"); 271 272 PJ_TODO(Fix_get_secure_level); 268 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 273 269 274 270 if (pj_stristr(dst_uri, &sips)) 275 271 return 2; 276 if (pj_stristr(dst_uri, &tls)) 277 return 1; 272 273 if (!pj_list_empty(&acc->route_set)) { 274 pjsip_route_hdr *r = acc->route_set.next; 275 pjsip_uri *uri = r->name_addr.uri; 276 pjsip_sip_uri *sip_uri; 277 278 sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 279 if (pj_stricmp2(&sip_uri->transport_param, "tls")==0) 280 return 1; 281 282 } else { 283 if (pj_stristr(dst_uri, &tls)) 284 return 1; 285 } 286 278 287 return 0; 279 288 } 289 290 static int call_get_secure_level(pjsua_call *call) 291 { 292 if (call->inv->dlg->secure) 293 return 2; 294 295 if (!pj_list_empty(&call->inv->dlg->route_set)) { 296 pjsip_route_hdr *r = call->inv->dlg->route_set.next; 297 pjsip_uri *uri = r->name_addr.uri; 298 pjsip_sip_uri *sip_uri; 299 300 sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 301 if (pj_stricmp2(&sip_uri->transport_param, "tls")==0) 302 return 1; 303 304 } else { 305 pjsip_sip_uri *sip_uri; 306 307 if (PJSIP_URI_SCHEME_IS_SIPS(call->inv->dlg->target)) 308 return 2; 309 if (!PJSIP_URI_SCHEME_IS_SIP(call->inv->dlg->target)) 310 return 0; 311 312 sip_uri = (pjsip_sip_uri*) pjsip_uri_get_uri(call->inv->dlg->target); 313 if (pj_stricmp2(&sip_uri->transport_param, "tls")==0) 314 return 1; 315 } 316 317 return 0; 318 } 319 280 320 281 321 /* … … 385 425 } 386 426 427 /* Calculate call's secure level */ 428 call->secure_level = get_secure_level(acc_id, dest_uri); 429 387 430 /* Init media channel */ 388 431 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 389 get_secure_level(dest_uri), NULL);432 call->secure_level, NULL); 390 433 if (status != PJ_SUCCESS) { 391 434 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 545 588 pjsua_call *call; 546 589 int call_id = -1; 547 int s ecure_level, sip_err_code;590 int sip_err_code; 548 591 pjmedia_sdp_session *offer, *answer; 549 592 pj_status_t status; … … 648 691 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 649 692 650 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 651 /* Get signaling security level, only when required by SRTP */ 652 if (pjsua_var.acc[acc_id].cfg.srtp_secure_signaling < 2) { 653 secure_level = PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport)!=0; 654 } else 655 #endif 656 657 { 658 char *uri; 659 int uri_len; 660 pj_str_t dst; 661 662 uri = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE); 663 uri_len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, 664 rdata->msg_info.msg->line.req.uri, 665 uri, PJSIP_MAX_URL_SIZE); 666 if (uri_len < 1) { 667 pjsua_perror(THIS_FILE, "Error analyzing dst URI", 668 PJSIP_EURITOOLONG); 669 uri_len = 0; 670 } 671 672 dst.ptr = uri; 673 dst.slen = uri_len; 674 675 secure_level = get_secure_level(&dst); 676 } 693 /* Get call's secure level */ 694 if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) 695 call->secure_level = 2; 696 else if (PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport)) 697 call->secure_level = 1; 698 else 699 call->secure_level = 0; 677 700 678 701 /* Init media channel */ 679 702 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 680 secure_level, &sip_err_code);703 call->secure_level, &sip_err_code); 681 704 if (status != PJ_SUCCESS) { 682 705 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 1413 1436 } 1414 1437 1438 /* Update call secure level */ 1439 call->secure_level = call_get_secure_level(call); 1440 1415 1441 /* Init media channel */ 1416 1442 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1417 get_secure_level(&dlg->remote.info_str), 1418 NULL); 1443 call->secure_level, NULL); 1419 1444 if (status != PJ_SUCCESS) { 1420 1445 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 1484 1509 return status; 1485 1510 1511 /* Update call's secure level */ 1512 call->secure_level = call_get_secure_level(call); 1513 1486 1514 /* Init media channel */ 1487 1515 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1488 get_secure_level(&dlg->remote.info_str), 1489 NULL); 1516 call->secure_level, NULL); 1490 1517 if (status != PJ_SUCCESS) { 1491 1518 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2608 2635 status = create_inactive_sdp( call, &answer ); 2609 2636 } else { 2610 int secure_level;2611 2612 2637 PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", 2613 2638 call->index)); 2614 2639 2640 /* Update call's secure level */ 2641 call->secure_level = call_get_secure_level(call); 2642 2615 2643 /* Init media channel */ 2616 secure_level = get_secure_level(&call->inv->dlg->remote.info_str);2617 2644 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 2618 secure_level, NULL);2645 call->secure_level, NULL); 2619 2646 if (status != PJ_SUCCESS) { 2620 2647 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2664 2691 status = create_inactive_sdp( call, offer ); 2665 2692 } else { 2666 int secure_level;2667 2668 2693 PJ_LOG(4,(THIS_FILE, "Call %d: asked to send a new offer", 2669 2694 call->index)); 2670 2695 2696 /* Update call's secure level */ 2697 call->secure_level = call_get_secure_level(call); 2698 2671 2699 /* Init media channel */ 2672 secure_level = get_secure_level(&call->inv->dlg->remote.info_str);2673 2700 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 2674 secure_level, NULL);2701 call->secure_level, NULL); 2675 2702 if (status != PJ_SUCCESS) { 2676 2703 pjsua_perror(THIS_FILE, "Error initializing media channel", status);
Note: See TracChangeset
for help on using the changeset viewer.