Changeset 1735 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Jan 23, 2008 8:39:07 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r1717 r1735 256 256 } 257 257 258 static pj_bool_t pj_stristr(const pj_str_t *str, const pj_str_t *substr) 259 { 260 int i; 261 262 for (i=0; i<(str->slen-substr->slen); ++i) { 263 pj_str_t s; 264 s.ptr = str->ptr+i; 265 s.slen = substr->slen; 266 267 if (pj_stricmp(&s, substr)==0) 268 return PJ_TRUE; 269 } 270 return PJ_FALSE; 271 } 272 273 /* Get signaling secure level. 274 * Return: 275 * 0: if signaling is not secure 276 * 1: if TLS transport is used for immediate hop 277 * 2: if end-to-end signaling is secure. 278 * 279 * NOTE: 280 * THIS IS WRONG. It should take into account the route-set. 281 */ 282 static int get_secure_level(const pj_str_t *dst_uri) 283 { 284 const pj_str_t tls = pj_str(";transport=tls"); 285 const pj_str_t sips = pj_str("sips:"); 286 287 PJ_TODO(Fix_get_secure_level); 288 289 if (pj_stristr(dst_uri, &sips)) 290 return 2; 291 if (pj_stristr(dst_uri, &tls)) 292 return 1; 293 return 0; 294 } 295 258 296 /* 259 297 * Make outgoing call to the specified URI using the specified account. … … 363 401 364 402 /* Init media channel */ 365 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 403 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 404 get_secure_level(dest_uri)); 366 405 if (status != PJ_SUCCESS) { 367 406 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 373 412 offer = NULL; 374 413 #else 375 status = pjsua_media_channel_create_sdp(call->index, dlg->pool, &offer);414 status = pjsua_media_channel_create_sdp(call->index, dlg->pool, NULL, &offer); 376 415 if (status != PJ_SUCCESS) { 377 416 pjsua_perror(THIS_FILE, "pjmedia unable to create SDP", status); … … 520 559 pjsua_call *call; 521 560 int call_id = -1; 522 pjmedia_sdp_session *answer; 561 int secure_level; 562 pjmedia_sdp_session *offer, *answer; 523 563 pj_status_t status; 524 564 … … 615 655 } 616 656 617 618 /* Init media channel */619 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS);620 if (status != PJ_SUCCESS) {621 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,622 NULL, NULL);623 PJSUA_UNLOCK();624 return PJ_TRUE;625 }626 627 628 /* Get media capability from media endpoint: */629 status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool, &answer);630 if (status != PJ_SUCCESS) {631 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,632 NULL, NULL);633 pjsua_media_channel_deinit(call->index);634 PJSUA_UNLOCK();635 return PJ_TRUE;636 }637 638 657 /* 639 658 * Get which account is most likely to be associated with this incoming … … 643 662 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 644 663 664 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 665 /* Get signaling security level, only when required by SRTP */ 666 if (pjsua_var.acc[acc_id].cfg.srtp_secure_signaling < 2) { 667 secure_level = PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport)!=0; 668 } else 669 #endif 670 671 { 672 char *uri; 673 int uri_len; 674 pj_str_t dst; 675 676 uri = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE); 677 uri_len = pjsip_uri_print(PJSIP_URI_IN_REQ_URI, 678 rdata->msg_info.msg->line.req.uri, 679 uri, PJSIP_MAX_URL_SIZE); 680 if (uri_len < 1) { 681 pjsua_perror(THIS_FILE, "Error analyzing dst URI", 682 PJSIP_EURITOOLONG); 683 uri_len = 0; 684 } 685 686 dst.ptr = uri; 687 dst.slen = uri_len; 688 689 secure_level = get_secure_level(&dst); 690 } 691 692 /* Init media channel */ 693 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, 697 NULL, NULL); 698 PJSUA_UNLOCK(); 699 return PJ_TRUE; 700 } 701 702 /* Parse SDP from incoming request */ 703 if (rdata->msg_info.msg->body) { 704 status = pjmedia_sdp_parse(rdata->tp_info.pool, 705 rdata->msg_info.msg->body->data, 706 rdata->msg_info.msg->body->len, &offer); 707 if (status != PJ_SUCCESS) { 708 pjsua_perror(THIS_FILE, "Error parsing SDP in incoming INVITE", status); 709 pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 400, NULL, 710 NULL, NULL); 711 pjsua_media_channel_deinit(call->index); 712 PJSUA_UNLOCK(); 713 return PJ_TRUE; 714 } 715 } else { 716 offer = NULL; 717 } 718 719 /* Get media capability from media endpoint: */ 720 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 NULL, NULL); 725 pjsua_media_channel_deinit(call->index); 726 PJSUA_UNLOCK(); 727 return PJ_TRUE; 728 } 729 645 730 /* Verify that we can handle the request. */ 646 731 options |= PJSIP_INV_SUPPORT_100REL; … … 648 733 options |= PJSIP_INV_REQUIRE_100REL; 649 734 650 status = pjsip_inv_verify_request (rdata, &options, answer, NULL,651 pjsua_var.endpt, &response);735 status = pjsip_inv_verify_request2(rdata, &options, offer, answer, NULL, 736 pjsua_var.endpt, &response); 652 737 if (status != PJ_SUCCESS) { 653 738 … … 1339 1424 1340 1425 /* Init media channel */ 1341 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 1426 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1427 get_secure_level(&dlg->remote.info_str)); 1342 1428 if (status != PJ_SUCCESS) { 1343 1429 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 1349 1435 PJ_UNUSED_ARG(unhold); 1350 1436 PJ_TODO(create_active_inactive_sdp_based_on_unhold_arg); 1351 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, &sdp); 1437 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1438 NULL, &sdp); 1352 1439 if (status != PJ_SUCCESS) { 1353 1440 pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", … … 1407 1494 1408 1495 /* Init media channel */ 1409 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 1496 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 1497 get_secure_level(&dlg->remote.info_str)); 1410 1498 if (status != PJ_SUCCESS) { 1411 1499 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 1415 1503 1416 1504 /* Create SDP */ 1417 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, &sdp); 1505 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1506 NULL, &sdp); 1418 1507 if (status != PJ_SUCCESS) { 1419 1508 pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", … … 2356 2445 { 2357 2446 pjsua_call *call; 2358 const pjmedia_sdp_session *local_sdp; 2447 const pjmedia_sdp_session *c_local; 2448 pjmedia_sdp_session *local_sdp; 2359 2449 const pjmedia_sdp_session *remote_sdp; 2360 2450 … … 2385 2475 2386 2476 /* Get local and remote SDP */ 2387 status = pjmedia_sdp_neg_get_active_local(call->inv->neg, & local_sdp);2477 status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &c_local); 2388 2478 if (status != PJ_SUCCESS) { 2389 2479 pjsua_perror(THIS_FILE, … … 2394 2484 return; 2395 2485 } 2486 local_sdp = (pjmedia_sdp_session*) c_local; 2396 2487 2397 2488 status = pjmedia_sdp_neg_get_active_remote(call->inv->neg, &remote_sdp); … … 2525 2616 status = create_inactive_sdp( call, &answer ); 2526 2617 } else { 2618 int secure_level; 2527 2619 2528 2620 PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", … … 2530 2622 2531 2623 /* Init media channel */ 2532 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS); 2624 secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 2625 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 2626 secure_level); 2533 2627 if (status != PJ_SUCCESS) { 2534 2628 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2537 2631 } 2538 2632 2539 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, &answer); 2633 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 2634 offer, &answer); 2540 2635 } 2541 2636 … … 2577 2672 status = create_inactive_sdp( call, offer ); 2578 2673 } else { 2674 int secure_level; 2579 2675 2580 2676 PJ_LOG(4,(THIS_FILE, "Call %d: asked to send a new offer", … … 2582 2678 2583 2679 /* Init media channel */ 2584 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC); 2680 secure_level = get_secure_level(&call->inv->dlg->remote.info_str); 2681 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAC, 2682 secure_level); 2585 2683 if (status != PJ_SUCCESS) { 2586 2684 pjsua_perror(THIS_FILE, "Error initializing media channel", status); … … 2589 2687 } 2590 2688 2591 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, offer); 2689 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 2690 NULL, offer); 2592 2691 } 2593 2692
Note: See TracChangeset
for help on using the changeset viewer.