Changeset 2316 for pjproject/trunk
- Timestamp:
- Sep 24, 2008 4:52:41 PM (16 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2301 r2316 1358 1358 1359 1359 /* */ 1360 if (acc_cfg->allow_contact_rewrite ==0)1360 if (acc_cfg->allow_contact_rewrite!=1) 1361 1361 { 1362 1362 pj_ansi_sprintf(line, "--auto-update-nat %i\n", -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r2301 r2316 538 538 } 539 539 540 /* Check if IP is private IP address */ 541 static pj_bool_t is_private_ip(const pj_str_t *addr) 542 { 543 const pj_str_t private_net[] = 544 { 545 { "10.", 3 }, 546 { "127.", 4 }, 547 { "172.16.", 7 }, 548 { "192.168.", 8 } 549 }; 550 unsigned i; 551 552 for (i=0; i<PJ_ARRAY_SIZE(private_net); ++i) { 553 if (pj_strncmp(addr, &private_net[i], private_net[i].slen)==0) 554 return PJ_TRUE; 555 } 556 557 return PJ_FALSE; 558 } 540 559 541 560 /* Update NAT address from the REGISTER response */ … … 549 568 pjsip_sip_uri *uri; 550 569 pjsip_via_hdr *via; 570 pj_str_t srv_ip; 551 571 552 572 tp = param->rdata->tp_info.transport; … … 614 634 } 615 635 636 /* Get server IP */ 637 srv_ip = pj_str(param->rdata->pkt_info.src_name); 638 616 639 /* At this point we've detected that the address as seen by registrar. 617 640 * has changed. 618 641 */ 642 643 /* Do not switch if both Contact and server's IP address are 644 * public but response contains private IP. A NAT in the middle 645 * might have messed up with the SIP packets. 646 */ 647 if (!is_private_ip(&uri->host) && !is_private_ip(&srv_ip) && 648 is_private_ip(via_addr)) 649 { 650 /* Don't switch */ 651 pj_pool_release(pool); 652 return PJ_FALSE; 653 } 654 619 655 PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d " 620 656 "(%.*s:%d --> %.*s:%d). Updating registration..",
Note: See TracChangeset
for help on using the changeset viewer.