Changeset 5963
- Timestamp:
- Apr 8, 2019 1:18:17 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r5946 r5963 164 164 165 165 /* 166 * Initialize outbound settings. 167 */ 168 static void init_outbound_setting(pjsua_acc *acc) 169 { 170 pjsua_acc_config *acc_cfg = &acc->cfg; 171 if (acc_cfg->rfc5626_instance_id.slen == 0) { 172 const pj_str_t *hostname; 173 pj_uint32_t hval; 174 pj_size_t pos; 175 char instprm[] = ";+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-0000CCDDEEFF>\""; 176 177 hostname = pj_gethostname(); 178 pos = pj_ansi_strlen(instprm) - 10; 179 hval = pj_hash_calc(0, hostname->ptr, (unsigned)hostname->slen); 180 pj_val_to_hex_digit(((char*)&hval)[0], instprm + pos + 0); 181 pj_val_to_hex_digit(((char*)&hval)[1], instprm + pos + 2); 182 pj_val_to_hex_digit(((char*)&hval)[2], instprm + pos + 4); 183 pj_val_to_hex_digit(((char*)&hval)[3], instprm + pos + 6); 184 185 pj_strdup2(acc->pool, &acc->rfc5626_instprm, instprm); 186 } else { 187 const char *prmname = ";+sip.instance=\""; 188 pj_size_t len; 189 190 len = pj_ansi_strlen(prmname) + acc_cfg->rfc5626_instance_id.slen + 1; 191 acc->rfc5626_instprm.ptr = (char*)pj_pool_alloc(acc->pool, len + 1); 192 pj_ansi_snprintf(acc->rfc5626_instprm.ptr, len + 1, 193 "%s%.*s\"", 194 prmname, 195 (int)acc_cfg->rfc5626_instance_id.slen, 196 acc_cfg->rfc5626_instance_id.ptr); 197 acc->rfc5626_instprm.slen = len; 198 } 199 200 if (acc_cfg->rfc5626_reg_id.slen == 0) { 201 acc->rfc5626_regprm = pj_str(";reg-id=1"); 202 } else { 203 const char *prmname = ";reg-id="; 204 pj_size_t len; 205 206 len = pj_ansi_strlen(prmname) + acc_cfg->rfc5626_reg_id.slen; 207 acc->rfc5626_regprm.ptr = (char*)pj_pool_alloc(acc->pool, len + 1); 208 pj_ansi_snprintf(acc->rfc5626_regprm.ptr, len + 1, 209 "%s%.*s\"", 210 prmname, 211 (int)acc_cfg->rfc5626_reg_id.slen, 212 acc_cfg->rfc5626_reg_id.ptr); 213 acc->rfc5626_regprm.slen = len; 214 } 215 216 acc->rfc5626_status = OUTBOUND_WANTED; 217 } 218 219 /* 166 220 * Initialize a new account (after configuration is set). 167 221 */ … … 341 395 */ 342 396 if (acc_cfg->use_rfc5626) { 343 if (acc_cfg->rfc5626_instance_id.slen==0) { 344 const pj_str_t *hostname; 345 pj_uint32_t hval; 346 pj_size_t pos; 347 char instprm[] = ";+sip.instance=\"<urn:uuid:00000000-0000-0000-0000-0000CCDDEEFF>\""; 348 349 hostname = pj_gethostname(); 350 pos = pj_ansi_strlen(instprm) - 10; 351 hval = pj_hash_calc(0, hostname->ptr, (unsigned)hostname->slen); 352 pj_val_to_hex_digit( ((char*)&hval)[0], instprm+pos+0); 353 pj_val_to_hex_digit( ((char*)&hval)[1], instprm+pos+2); 354 pj_val_to_hex_digit( ((char*)&hval)[2], instprm+pos+4); 355 pj_val_to_hex_digit( ((char*)&hval)[3], instprm+pos+6); 356 357 pj_strdup2(acc->pool, &acc->rfc5626_instprm, instprm); 358 } else { 359 const char *prmname = ";+sip.instance=\""; 360 pj_size_t len; 361 362 len = pj_ansi_strlen(prmname) + acc_cfg->rfc5626_instance_id.slen + 1; 363 acc->rfc5626_instprm.ptr = (char*)pj_pool_alloc(acc->pool, len+1); 364 pj_ansi_snprintf(acc->rfc5626_instprm.ptr, len+1, 365 "%s%.*s\"", 366 prmname, 367 (int)acc_cfg->rfc5626_instance_id.slen, 368 acc_cfg->rfc5626_instance_id.ptr); 369 acc->rfc5626_instprm.slen = len; 370 } 371 372 if (acc_cfg->rfc5626_reg_id.slen==0) { 373 acc->rfc5626_regprm = pj_str(";reg-id=1"); 374 } else { 375 const char *prmname = ";reg-id="; 376 pj_size_t len; 377 378 len = pj_ansi_strlen(prmname) + acc_cfg->rfc5626_reg_id.slen; 379 acc->rfc5626_regprm.ptr = (char*)pj_pool_alloc(acc->pool, len+1); 380 pj_ansi_snprintf(acc->rfc5626_regprm.ptr, len+1, 381 "%s%.*s\"", 382 prmname, 383 (int)acc_cfg->rfc5626_reg_id.slen, 384 acc_cfg->rfc5626_reg_id.ptr); 385 acc->rfc5626_regprm.slen = len; 386 } 387 388 acc->rfc5626_status = OUTBOUND_WANTED; 397 init_outbound_setting(acc); 389 398 } 390 399 … … 1305 1314 pj_strcmp(&acc->cfg.rfc5626_instance_id, &cfg->rfc5626_instance_id) || 1306 1315 pj_strcmp(&acc->cfg.rfc5626_reg_id, &cfg->rfc5626_reg_id)) 1307 { 1316 { 1317 if (acc->cfg.use_rfc5626 != cfg->use_rfc5626) 1318 acc->cfg.use_rfc5626 = cfg->use_rfc5626; 1319 1320 if (pj_strcmp(&acc->cfg.rfc5626_instance_id, 1321 &cfg->rfc5626_instance_id)) 1322 { 1323 pj_strdup_with_null(acc->pool, &acc->cfg.rfc5626_instance_id, 1324 &cfg->rfc5626_instance_id); 1325 } 1326 if (pj_strcmp(&acc->cfg.rfc5626_reg_id, &cfg->rfc5626_reg_id)) { 1327 pj_strdup_with_null(acc->pool, &acc->cfg.rfc5626_reg_id, 1328 &cfg->rfc5626_reg_id); 1329 } 1330 init_outbound_setting(acc); 1308 1331 update_reg = PJ_TRUE; 1332 unreg_first = PJ_TRUE; 1309 1333 } 1310 1334
Note: See TracChangeset
for help on using the changeset viewer.