Changeset 881 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
- Timestamp:
- Jan 13, 2007 11:22:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r799 r881 226 226 return status; 227 227 228 229 228 /* Mark account as valid */ 230 229 pjsua_var.acc[acc_id].valid = PJ_TRUE; … … 259 258 260 259 /* Must have a transport */ 261 PJ_TODO(associate_acc_with_transport);262 260 PJ_ASSERT_RETURN(pjsua_var.tpdata[0].data.ptr != NULL, PJ_EINVALIDOP); 263 261 … … 321 319 { 322 320 pjsua_acc_config cfg; 323 structtransport_data *t = &pjsua_var.tpdata[tid];321 pjsua_transport_data *t = &pjsua_var.tpdata[tid]; 324 322 char uri[PJSIP_MAX_URL_SIZE]; 325 323 … … 383 381 } 384 382 385 PJ_TODO(may_need_to_scan_calls); 383 /* Leave the calls intact, as I don't think calls need to 384 * access account once it's created 385 */ 386 386 387 387 388 PJSUA_UNLOCK(); … … 492 493 pj_status_t status; 493 494 495 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 494 496 acc = &pjsua_var.acc[acc_id]; 495 497 … … 539 541 } 540 542 543 /* If account is locked to specific transport, then set transport to 544 * the client registration. 545 */ 546 if (pjsua_var.acc[acc_id].cfg.transport_id != PJSUA_INVALID_ID) { 547 pjsip_tpselector tp_sel; 548 549 pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel); 550 pjsip_regc_set_transport(acc->regc, &tp_sel); 551 } 552 553 541 554 /* Set credentials 542 555 */ … … 641 654 642 655 PJ_ASSERT_RETURN(info != NULL, PJ_EINVAL); 656 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 643 657 644 658 pj_bzero(info, sizeof(pjsua_acc_info)); … … 855 869 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 856 870 857 if ( pj_stricmp(&acc->user_part, &sip_uri->user)==0 &&871 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0 && 858 872 pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) 859 873 { … … 869 883 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 870 884 871 if ( pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) {885 if (acc->valid && pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) { 872 886 /* Match ! */ 873 887 PJSUA_UNLOCK(); … … 876 890 } 877 891 878 /* No matching account, try match user part only. */892 /* No matching account, try match user part (and transport type) only. */ 879 893 for (i=0; i < pjsua_var.acc_cnt; ++i) { 880 894 unsigned acc_id = pjsua_var.acc_ids[i]; 881 895 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 882 896 883 if (pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 897 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 898 899 if (acc->cfg.transport_id != PJSUA_INVALID_ID) { 900 pjsip_transport_type_e type; 901 type = pjsip_transport_get_type_from_name(&sip_uri->transport_param); 902 if (type == PJSIP_TRANSPORT_UNSPECIFIED) 903 type = PJSIP_TRANSPORT_UDP; 904 905 if (pjsua_var.tpdata[acc->cfg.transport_id].type != type) 906 continue; 907 } 908 884 909 /* Match ! */ 885 910 PJSUA_UNLOCK(); … … 904 929 pjsip_transport_type_e tp_type = PJSIP_TRANSPORT_UNSPECIFIED; 905 930 pj_str_t local_addr; 931 pjsip_tpselector tp_sel; 906 932 unsigned flag; 907 933 int secure; 908 934 int local_port; 909 935 936 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 910 937 acc = &pjsua_var.acc[acc_id]; 911 938 … … 946 973 secure = (flag & PJSIP_TRANSPORT_SECURE) != 0; 947 974 975 /* Init transport selector. */ 976 pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel); 977 948 978 /* Get local address suitable to send request from */ 949 979 status = pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 950 pool, tp_type, &local_addr, &local_port); 980 pool, tp_type, &tp_sel, 981 &local_addr, &local_port); 951 982 if (status != PJ_SUCCESS) 952 983 return status; … … 991 1022 pjsip_transport_type_e tp_type = PJSIP_TRANSPORT_UNSPECIFIED; 992 1023 pj_str_t local_addr; 1024 pjsip_tpselector tp_sel; 993 1025 unsigned flag; 994 1026 int secure; 995 1027 int local_port; 996 1028 1029 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 997 1030 acc = &pjsua_var.acc[acc_id]; 998 1031 … … 1039 1072 secure = (flag & PJSIP_TRANSPORT_SECURE) != 0; 1040 1073 1074 /* Init transport selector. */ 1075 pjsua_init_tpselector(pjsua_var.acc[acc_id].cfg.transport_id, &tp_sel); 1076 1041 1077 /* Get local address suitable to send request from */ 1042 1078 status = pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 1043 pool, tp_type, &local_addr, &local_port); 1079 pool, tp_type, &tp_sel, 1080 &local_addr, &local_port); 1044 1081 if (status != PJ_SUCCESS) 1045 1082 return status; … … 1065 1102 1066 1103 1067 1104 PJ_DEF(pj_status_t) pjsua_acc_set_transport( pjsua_acc_id acc_id, 1105 pjsua_transport_id tp_id) 1106 { 1107 pjsua_acc *acc; 1108 1109 PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 1110 acc = &pjsua_var.acc[acc_id]; 1111 1112 PJ_ASSERT_RETURN(tp_id >= 0 && tp_id < PJ_ARRAY_SIZE(pjsua_var.tpdata), 1113 PJ_EINVAL); 1114 1115 acc->cfg.transport_id = tp_id; 1116 1117 return PJ_SUCCESS; 1118 } 1119
Note: See TracChangeset
for help on using the changeset viewer.