- Timestamp:
- Jan 18, 2008 6:49:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_call.c
r1698 r1709 215 215 #define LATE_SDP 0 216 216 217 static pj_bool_t pj_stristr(const pj_str_t *str, const pj_str_t *substr) 218 { 219 int i; 220 221 for (i=0; i<(str->slen-substr->slen); ++i) { 222 pj_str_t s; 223 s.ptr = str->ptr+i; 224 s.slen = substr->slen; 225 226 if (pj_stricmp(&s, substr)==0) 227 return PJ_TRUE; 228 } 229 return PJ_FALSE; 230 } 231 232 /* Get signaling secure level. 233 * Return: 234 * 0: if signaling is not secure 235 * 1: if TLS transport is used for immediate hop 236 * 2: if end-to-end signaling is secure. 237 * 238 * NOTE: 239 * THIS IS WRONG. It should take into account the route-set. 240 */ 241 static int get_secure_level(const pj_str_t *dst_uri) 242 { 243 const pj_str_t tls = pj_str(";transport=tls"); 244 const pj_str_t sips = pj_str("sips:"); 245 246 PJ_TODO(Fix_get_secure_level); 247 248 if (pj_stristr(dst_uri, &sips)) 249 return 2; 250 if (pj_stristr(dst_uri, &tls)) 251 return 1; 252 return 0; 253 } 254 217 255 /* 218 256 * Make outgoing call to the specified URI using the specified account. … … 325 363 326 364 /* Init media channel */ 327 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 365 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 366 get_secure_level(dest_uri)); 328 367 if (status != PJ_SUCCESS) { 329 368 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 482 521 pjsua_call *call; 483 522 int call_id = -1; 523 int secure_level; 484 524 pjmedia_sdp_session *offer, *answer; 485 525 pj_status_t status; … … 580 620 } 581 621 622 /* 623 * Get which account is most likely to be associated with this incoming 624 * call. We need the account to find which contact URI to put for 625 * the call. 626 */ 627 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 628 629 /* Get signaling security level, only when required by SRTP */ 630 if (pjsua_var.acc[acc_id].cfg.srtp_secure_signaling < 2) { 631 secure_level = PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport)!=0; 632 } else { 633 char *uri; 634 int uri_len; 635 pj_str_t dst; 636 637 uri = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE); 638 uri_len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, 639 rdata->msg_info.msg->line.req.uri, 640 uri, PJSIP_MAX_URL_SIZE); 641 if (uri_len < 1) { 642 pjsua_perror(THIS_FILE, "Error analyzing dst URI", 643 PJSIP_EURITOOLONG); 644 uri_len = 0; 645 } 646 647 dst.ptr = uri; 648 dst.slen = uri_len; 649 650 secure_level = get_secure_level(&dst); 651 } 582 652 583 653 /* Init media channel */ 584 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS); 654 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 655 secure_level); 585 656 if (status != PJ_SUCCESS) { 586 657 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, … … 618 689 } 619 690 620 /*621 * Get which account is most likely to be associated with this incoming622 * call. We need the account to find which contact URI to put for623 * the call.624 */625 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata);626 627 691 /* Verify that we can handle the request. */ 628 692 options |= PJSIP_INV_SUPPORT_100REL; … … 1321 1385 1322 1386 /* Init media channel */ 1323 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 1387 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1388 get_secure_level(&dlg->remote.info_str)); 1324 1389 if (status != PJ_SUCCESS) { 1325 1390 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 1390 1455 1391 1456 /* Init media channel */ 1392 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 1457 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1458 get_secure_level(&dlg->remote.info_str)); 1393 1459 if (status != PJ_SUCCESS) { 1394 1460 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2509 2575 status = create_inactive_sdp( call, &answer ); 2510 2576 } else { 2577 int secure_level; 2511 2578 2512 2579 PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", … … 2514 2581 2515 2582 /* Init media channel */ 2516 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS); 2583 secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 2584 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 2585 secure_level); 2517 2586 if (status != PJ_SUCCESS) { 2518 2587 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2562 2631 status = create_inactive_sdp( call, offer ); 2563 2632 } else { 2633 int secure_level; 2564 2634 2565 2635 PJ_LOG(4,(THIS_FILE, "Call %d: asked to send a new offer", … … 2567 2637 2568 2638 /* Init media channel */ 2569 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 2639 secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 2640 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 2641 secure_level); 2570 2642 if (status != PJ_SUCCESS) { 2571 2643 pjsua_perror(THIS_FILE, "Error initializing media channel", status);
Note: See TracChangeset
for help on using the changeset viewer.