Changeset 5838
- Timestamp:
- Jul 25, 2018 9:58:37 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r5833 r5838 2994 2994 pjsip_sip_uri *sip_uri; 2995 2995 pjsua_acc_id id = PJSUA_INVALID_ID; 2996 int max_score; 2996 2997 unsigned i; 2997 2998 … … 3026 3027 sip_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(uri); 3027 3028 3028 /* Find account which has matching username and domain. */ 3029 /* Select account by weighted score. Matching priority order is: 3030 * transport type (matched or not set), domain part, and user part. 3031 * Note that the transport type has higher priority as unmatched 3032 * transport type may cause failure in sending response. 3033 */ 3034 max_score = 0; 3029 3035 for (i=0; i < pjsua_var.acc_cnt; ++i) { 3030 3036 unsigned acc_id = pjsua_var.acc_ids[i]; 3031 3037 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 3032 3033 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0 && 3034 pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) 3038 int score = 0; 3039 3040 if (!acc->valid) 3041 continue; 3042 3043 /* Match transport type */ 3044 if (acc->tp_type == rdata->tp_info.transport->key.type || 3045 acc->tp_type == PJSIP_TRANSPORT_UNSPECIFIED) 3035 3046 { 3036 /* Match ! */ 3047 score |= 4; 3048 } 3049 3050 /* Match domain */ 3051 if (pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) { 3052 score |= 2; 3053 } 3054 3055 /* Match username */ 3056 if (pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 3057 score |= 1; 3058 } 3059 3060 if (score > max_score) { 3037 3061 id = acc_id; 3038 goto on_return; 3039 } 3040 } 3041 3042 /* No matching account, try match domain part only. */ 3043 for (i=0; i < pjsua_var.acc_cnt; ++i) { 3044 unsigned acc_id = pjsua_var.acc_ids[i]; 3045 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 3046 3047 if (acc->valid && pj_stricmp(&acc->srv_domain, &sip_uri->host)==0) { 3048 /* Match ! */ 3049 id = acc_id; 3050 goto on_return; 3051 } 3052 } 3053 3054 /* No matching account, try match user part (and transport type) only. */ 3055 for (i=0; i < pjsua_var.acc_cnt; ++i) { 3056 unsigned acc_id = pjsua_var.acc_ids[i]; 3057 pjsua_acc *acc = &pjsua_var.acc[acc_id]; 3058 3059 if (acc->valid && pj_stricmp(&acc->user_part, &sip_uri->user)==0) { 3060 if (acc->tp_type != PJSIP_TRANSPORT_UNSPECIFIED && 3061 acc->tp_type != rdata->tp_info.transport->key.type) 3062 { 3063 continue; 3064 } 3065 3066 /* Match ! */ 3067 id = acc_id; 3068 goto on_return; 3062 max_score = score; 3069 3063 } 3070 3064 }
Note: See TracChangeset
for help on using the changeset viewer.