- Timestamp:
- Jan 21, 2008 9:20:58 PM (17 years ago)
- Location:
- pjproject/branches/users/nanang
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjmedia/include/pjmedia/config.h
r1664 r1723 496 496 497 497 498 /** 499 * SRTP Transport 500 * By default it is enabled. 501 */ 502 #ifndef PJMEDIA_HAS_SRTP 503 # define PJMEDIA_HAS_SRTP 1 504 #endif 505 498 506 499 507 /** -
pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h
r1710 r1723 58 58 59 59 60 /** 60 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 61 62 /** 61 63 * Mapping from LibSRTP error codes to pjmedia error space. 62 64 */ … … 69 71 #define PJMEDIA_ERRNO_FROM_LIBSRTP(err) (PJMEDIA_LIBSRTP_ERRNO_START+err) 70 72 73 #endif 71 74 72 75 /************************************************************ … … 541 544 542 545 546 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 543 547 /************************************************************ 544 548 * SRTP TRANSPORT ERRORS … … 594 598 */ 595 599 #define PJMEDIA_SRTP_ESDPREQSECTP (PJMEDIA_ERRNO_START+229) /* 220229 */ 600 601 #endif /* PJMEDIA_HAS_SRTP */ 596 602 597 603 -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c
r1712 r1723 146 146 PJ_BUILD_ERR( PJMEDIA_ESNDINSAMPLEFMT, "Invalid sample format for sound device" ), 147 147 148 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 148 149 /* SRTP transport errors: */ 149 150 PJ_BUILD_ERR( PJMEDIA_SRTP_ECRYPTONOTMATCH, "SRTP crypto-suite name not match the offerer tag" ), … … 157 158 PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQCRYPTO, "SRTP crypto attribute required" ), 158 159 PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP, "Secure transport required in SDP media descriptor" ) 160 #endif 161 159 162 }; 160 163 -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_srtp.c
r1722 r1723 26 26 #include <pj/os.h> 27 27 #include <pj/pool.h> 28 29 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 30 28 31 #include <srtp.h> 29 32 … … 1228 1231 return pjmedia_transport_srtp_stop(tp); 1229 1232 } 1233 1234 #endif -
pjproject/branches/users/nanang/pjsip-apps/src/pjsua/pjsua_app.c
r1720 r1723 121 121 puts ("SIP Account options:"); 122 122 puts (" --use-ims Enable 3GPP/IMS related settings on this account"); 123 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 123 124 puts (" --use-srtp=N Use SRTP N= 0: disabled, 1: optional, 2: mandatory"); 125 #endif 124 126 puts (" --registrar=url Set the URL of registrar server"); 125 127 puts (" --id=url Set the URL of local ID (used in From header)"); … … 443 445 { "rtp-port", 1, 0, OPT_RTP_PORT}, 444 446 { "use-ice", 0, 0, OPT_USE_ICE}, 447 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 445 448 { "use-srtp", 1, 0, OPT_USE_SRTP}, 449 #endif 446 450 { "add-codec", 1, 0, OPT_ADD_CODEC}, 447 451 { "dis-codec", 1, 0, OPT_DIS_CODEC}, … … 474 478 pjsua_acc_config *cur_acc; 475 479 char *config_file = NULL; 476 int use_srtp = -1;477 480 unsigned i; 478 481 … … 800 803 break; 801 804 805 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 802 806 case OPT_USE_SRTP: 803 use_srtp = my_atoi(pj_optarg);804 if (!pj_isdigit(*pj_optarg) || use_srtp > 2) {807 app_config.cfg.use_srtp = my_atoi(pj_optarg); 808 if (!pj_isdigit(*pj_optarg) || app_config.cfg.use_srtp > 2) { 805 809 PJ_LOG(1,(THIS_FILE, "Invalid value for --use-srtp option")); 806 810 return -1; 807 811 } 808 app_config.cfg.use_srtp = use_srtp;809 break; 812 break; 813 #endif 810 814 811 815 case OPT_RTP_PORT: … … 1039 1043 for (i=0; i<cfg->acc_cnt; ++i) { 1040 1044 pjsua_acc_config *acfg = &cfg->acc_cfg[i]; 1041 1042 acfg->use_srtp = (pjmedia_srtp_use) use_srtp;1043 1045 1044 1046 if (acfg->cred_info[acfg->cred_count].username.slen) … … 1126 1128 } 1127 1129 1130 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 1128 1131 /* SRTP */ 1129 1132 if (acc_cfg->use_srtp) { … … 1132 1135 pj_strcat2(result, line); 1133 1136 } 1137 #endif 1134 1138 1135 1139 /* Proxy */ -
pjproject/branches/users/nanang/pjsip-apps/src/samples/streamutil.c
r1718 r1723 56 56 " --send-only Set stream direction to send only \n" 57 57 " --recv-only Set stream direction to recv only (default) \n" 58 59 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 58 60 " --use-srtp[=NAME] Enable SRTP with crypto suite NAME \n" 59 61 " e.g: AES_CM_128_HMAC_SHA1_80 (default), \n" … … 63 65 " --srtp-tx-key SRTP key for transmiting \n" 64 66 " --srtp-rx-key SRTP key for receiving \n" 67 #endif 68 65 69 "\n" 66 70 ; … … 133 137 pj_uint16_t local_port, 134 138 const pj_sockaddr_in *rem_addr, 139 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 135 140 pj_bool_t use_srtp, 136 141 const pj_str_t *crypto_suite, 137 142 const pj_str_t *srtp_tx_key, 138 143 const pj_str_t *srtp_rx_key, 144 #endif 139 145 pjmedia_stream **p_stream ) 140 146 { 141 147 pjmedia_stream_info info; 142 148 pjmedia_transport *transport = NULL; 149 pj_status_t status; 150 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 143 151 pjmedia_transport *srtp_tp = NULL; 144 pj_status_t status; 152 #endif 145 153 146 154 … … 174 182 return status; 175 183 184 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 176 185 /* Check if SRTP enabled */ 177 186 if (use_srtp) { … … 194 203 if (status != PJ_SUCCESS) 195 204 return status; 196 } 205 206 transport = srtp_tp; 207 } 208 #endif 197 209 198 210 /* Now that the stream info is initialized, we can create the … … 201 213 202 214 status = pjmedia_stream_create( med_endpt, pool, &info, 203 (use_srtp?srtp_tp:transport),215 transport, 204 216 NULL, p_stream); 205 217 … … 239 251 pj_status_t status; 240 252 253 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 241 254 /* SRTP variables */ 242 255 pj_bool_t use_srtp = PJ_FALSE; … … 247 260 pj_str_t srtp_crypto_suite = {NULL, 0}; 248 261 int tmp_key_len; 262 #endif 249 263 250 264 /* Default values */ … … 266 280 OPT_SEND_ONLY = 's', 267 281 OPT_RECV_ONLY = 'i', 282 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 268 283 OPT_USE_SRTP = 'S', 284 #endif 269 285 OPT_SRTP_TX_KEY = 'x', 270 286 OPT_SRTP_RX_KEY = 'y', … … 281 297 { "send-only", 0, 0, OPT_SEND_ONLY }, 282 298 { "recv-only", 0, 0, OPT_RECV_ONLY }, 299 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 283 300 { "use-srtp", 2, 0, OPT_USE_SRTP }, 284 301 { "srtp-tx-key", 1, 0, OPT_SRTP_TX_KEY }, 285 302 { "srtp-rx-key", 1, 0, OPT_SRTP_RX_KEY }, 303 #endif 286 304 { "help", 0, 0, OPT_HELP }, 287 305 { NULL, 0, 0, 0 }, … … 350 368 break; 351 369 370 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 352 371 case OPT_USE_SRTP: 353 372 use_srtp = PJ_TRUE; … … 368 387 pj_strset(&srtp_rx_key, tmp_rx_key, tmp_key_len/2); 369 388 break; 389 #endif 370 390 371 391 case OPT_HELP: … … 394 414 } 395 415 416 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 417 /* SRTP validation */ 396 418 if (use_srtp) { 397 if (((dir & PJMEDIA_DIR_ENCODING) && !srtp_tx_key.slen) || 398 ((dir & PJMEDIA_DIR_DECODING) && !srtp_rx_key.slen)) 419 if (!srtp_tx_key.slen || !srtp_rx_key.slen) 399 420 { 400 421 printf("Error: Key for each SRTP stream direction must be set\n"); … … 402 423 } 403 424 } 425 #endif 404 426 405 427 /* Must create a pool factory before we can allocate any memory. */ … … 448 470 status = create_stream(pool, med_endpt, codec_info, dir, local_port, 449 471 &remote_addr, 472 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 450 473 use_srtp, &srtp_crypto_suite, 451 474 &srtp_tx_key, &srtp_rx_key, 475 #endif 452 476 &stream); 453 477 if (status != PJ_SUCCESS) -
pjproject/branches/users/nanang/pjsip/include/pjsua-lib/pjsua.h
r1720 r1723 404 404 #endif 405 405 406 406 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 407 408 /** 409 * Default value of SRTP mode usage. Valid values are PJMEDIA_SRTP_DISABLED, 410 * PJMEDIA_SRTP_OPTIONAL, and PJMEDIA_SRTP_MANDATORY. 411 */ 412 #ifndef PJSUA_DEFAULT_USE_SRTP 413 #define PJSUA_DEFAULT_USE_SRTP PJMEDIA_SRTP_DISABLED 414 #endif 415 416 /** 417 * Default value of secure signaling requirement for SRTP. 418 * Valid values are: 419 * 0: SRTP does not require secure signaling 420 * 1: SRTP requires secure transport such as TLS 421 * 2: SRTP requires secure end-to-end transport (SIPS) 422 */ 423 #ifndef PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 424 #define PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 0 425 #endif 426 427 #endif 407 428 408 429 /** … … 1035 1056 pj_str_t user_agent; 1036 1057 1058 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 1037 1059 /** 1038 1060 * Specify default value of secure media transport usage. … … 1043 1065 * configuration (#pjsua_acc_config). 1044 1066 * 1045 * Default: 1046 * PJMEDIA_SRTP_DISABLED 1067 * Default: #PJSUA_DEFAULT_USE_SRTP 1047 1068 */ 1048 1069 pjmedia_srtp_use use_srtp; … … 1060 1081 * configuration (#pjsua_acc_config). 1061 1082 * 1062 * Default: 01083 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 1063 1084 */ 1064 1085 int srtp_secure_signaling; 1086 #endif 1065 1087 1066 1088 } pjsua_config; … … 2001 2023 pj_str_t ka_data; 2002 2024 2025 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 2003 2026 /** 2004 2027 * Specify whether secure media transport should be used for this account. … … 2006 2029 * PJMEDIA_SRTP_MANDATORY. 2007 2030 * 2008 * Default: 2009 * PJMEDIA_SRTP_DISABLED 2031 * Default: #PJSUA_DEFAULT_USE_SRTP 2010 2032 */ 2011 2033 pjmedia_srtp_use use_srtp; … … 2020 2042 * 2: SRTP requires secure end-to-end transport (SIPS) 2021 2043 * 2022 * Default: 02044 * Default: #PJSUA_DEFAULT_SRTP_SECURE_SIGNALING 2023 2045 */ 2024 2046 int srtp_secure_signaling; 2047 #endif 2025 2048 2026 2049 } pjsua_acc_config; -
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_call.c
r1718 r1723 627 627 acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 628 628 629 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 629 630 /* Get signaling security level, only when required by SRTP */ 630 631 if (pjsua_var.acc[acc_id].cfg.srtp_secure_signaling < 2) { 631 632 secure_level = PJSIP_TRANSPORT_IS_SECURE(rdata->tp_info.transport)!=0; 632 } else { 633 } else 634 #endif 635 636 { 633 637 char *uri; 634 638 int uri_len; -
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_core.c
r1720 r1723 88 88 cfg->thread_cnt = 1; 89 89 cfg->nat_type_in_sdp = 1; 90 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 91 cfg->use_srtp = PJSUA_DEFAULT_USE_SRTP; 92 cfg->srtp_secure_signaling = PJSUA_DEFAULT_SRTP_SECURE_SIGNALING; 93 #endif 90 94 } 91 95 … … 143 147 cfg->ka_interval = 15; 144 148 cfg->ka_data = pj_str("\r\n"); 149 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 145 150 cfg->use_srtp = pjsua_var.ua_cfg.use_srtp; 146 151 cfg->srtp_secure_signaling = pjsua_var.ua_cfg.srtp_secure_signaling; 152 #endif 147 153 } 148 154 -
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_media.c
r1720 r1723 750 750 { 751 751 pjsua_call *call = &pjsua_var.calls[call_id]; 752 753 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 752 754 pjsua_acc *acc = &pjsua_var.acc[call->acc_id]; 753 755 pjmedia_srtp_setting srtp_opt; 754 756 pjmedia_transport *srtp; 755 757 pj_status_t status; 758 #endif 756 759 757 760 PJ_UNUSED_ARG(role); … … 767 770 pjmedia_transport_media_stop(call->med_tp); 768 771 772 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 769 773 /* Check if SRTP requires secure signaling */ 770 774 if (acc->cfg.use_srtp != PJMEDIA_SRTP_DISABLED) { … … 787 791 call->med_orig = call->med_tp; 788 792 call->med_tp = srtp; 793 #else 794 call->med_orig = call->med_tp; 795 PJ_UNUSED_ARG(security_level); 796 #endif 789 797 790 798 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.