Changeset 1454 for pjproject/trunk
- Timestamp:
- Sep 27, 2007 2:07:07 PM (17 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/build/pjsua_lib.dsp
r1098 r1454 41 41 # PROP Intermediate_Dir ".\output\pjsua-lib-i386-win32-vc6-release" 42 42 # PROP Target_Dir "" 43 F90=df.exe 43 44 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 45 # ADD CPP /nologo /MD /W4 /GX /Zi /O2 /I "../include" /I "../../pjmedia/include" /I "../../pjlib-util/include" /I "../../pjlib/include" /I "../../pjnath/include" /D "NDEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_MBCS" /D "_LIB" /FR /FD /c … … 65 66 # PROP Intermediate_Dir ".\output\pjsua-lib-i386-win32-vc6-debug" 66 67 # PROP Target_Dir "" 68 F90=df.exe 67 69 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 70 # ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "../include" /I "../../pjmedia/include" /I "../../pjlib-util/include" /I "../../pjlib/include" /I "../../pjnath/include" /D "_DEBUG" /D PJ_WIN32=1 /D PJ_M_I386=1 /D "WIN32" /D "_MBCS" /D "_LIB" /FR /FD /GZ /c -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r1435 r1454 1848 1848 pjsua_transport_id transport_id; 1849 1849 1850 /** 1851 * This option is useful for keeping the UDP transport address up to 1852 * date with the NAT public mapped address. When this option is 1853 * enabled and STUN is configured, the library will keep track of 1854 * the public IP address from the response of REGISTER request. Once 1855 * it detects that the address has changed, it will unregister current 1856 * Contact, update the UDP transport address, and register a new 1857 * Contact to the registrar. 1858 * 1859 * Default: 1 (yes) 1860 */ 1861 pj_bool_t auto_update_nat; 1862 1850 1863 } pjsua_acc_config; 1851 1864 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r1424 r1454 455 455 456 456 457 /* Update NAT address from the REGISTER response */ 458 static pj_bool_t acc_check_nat_addr(pjsua_acc *acc, 459 struct pjsip_regc_cbparam *param) 460 { 461 pjsip_transport *tp; 462 const pj_str_t *via_addr; 463 int rport; 464 pjsip_via_hdr *via; 465 466 tp = param->rdata->tp_info.transport; 467 468 /* Only update if account is configured to auto-update */ 469 if (acc->cfg.auto_update_nat == PJ_FALSE) 470 return PJ_FALSE; 471 472 /* Only update if registration uses UDP transport */ 473 if (tp->key.type != PJSIP_TRANSPORT_UDP) 474 return PJ_FALSE; 475 476 /* Only update if STUN is enabled (for now) */ 477 if (pjsua_var.ua_cfg.stun_domain.slen == 0 && 478 pjsua_var.ua_cfg.stun_host.slen == 0) 479 { 480 return PJ_FALSE; 481 } 482 483 /* Get the received and rport info */ 484 via = param->rdata->msg_info.via; 485 if (via->rport_param < 1) { 486 /* Remote doesn't support rport */ 487 rport = via->sent_by.port; 488 } else 489 rport = via->rport_param; 490 491 if (via->recvd_param.slen != 0) 492 via_addr = &via->recvd_param; 493 else 494 via_addr = &via->sent_by.host; 495 496 /* Compare received and rport with transport published address */ 497 if (tp->local_name.port == rport && 498 pj_stricmp(&tp->local_name.host, via_addr)==0) 499 { 500 /* Address doesn't change */ 501 return PJ_FALSE; 502 } 503 504 /* At this point we've detected that the address as seen by registrar. 505 * has changed. 506 */ 507 PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d " 508 "(%.*s:%d --> %.*s:%d). Updating registration..", 509 acc->index, 510 (int)tp->local_name.host.slen, 511 tp->local_name.host.ptr, 512 tp->local_name.port, 513 (int)via_addr->slen, 514 via_addr->ptr, 515 rport)); 516 517 /* Unregister current contact */ 518 pjsua_acc_set_registration(acc->index, PJ_FALSE); 519 if (acc->regc != NULL) { 520 pjsip_regc_destroy(acc->regc); 521 acc->regc = NULL; 522 } 523 524 /* Update transport address */ 525 pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr); 526 tp->local_name.port = rport; 527 528 /* Perform new registration */ 529 pjsua_acc_set_registration(acc->index, PJ_TRUE); 530 531 return PJ_TRUE; 532 } 533 457 534 /* 458 535 * This callback is called by pjsip_regc when outgoing register … … 463 540 464 541 pjsua_acc *acc = (pjsua_acc*) param->token; 542 543 if (param->regc != acc->regc) 544 return; 465 545 466 546 PJSUA_LOCK(); … … 490 570 pjsua_var.acc[acc->index].cfg.id.ptr)); 491 571 } else { 572 /* Check NAT bound address */ 573 if (acc_check_nat_addr(acc, param)) { 574 /* Update address, don't notify application yet */ 575 PJSUA_UNLOCK(); 576 return; 577 } 578 492 579 PJ_LOG(3, (THIS_FILE, 493 580 "%s: registration success, status=%d (%.*s), " -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r1426 r1454 141 141 cfg->reg_timeout = PJSUA_REG_INTERVAL; 142 142 cfg->transport_id = PJSUA_INVALID_ID; 143 cfg->auto_update_nat = PJ_TRUE; 143 144 } 144 145
Note: See TracChangeset
for help on using the changeset viewer.