]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Use the address we already know when reloading a peer with nat=yes.
authorEliel C. Sardanons <eliels@gmail.com>
Thu, 28 May 2009 15:21:32 +0000 (15:21 +0000)
committerEliel C. Sardanons <eliels@gmail.com>
Thu, 28 May 2009 15:21:32 +0000 (15:21 +0000)
If we already have an address for a peer, and we are reloading the sip
configuration, try to use that address to contact the peer, instead of
getting it from the Contact.

(closes issue #15194)
Reported by: ibc
Patches:
      sip.patch uploaded by eliel (license 64)
      Tested by: manwe

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@197562 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index b457d4fe28b9e1c7c2bd800fffff0b0daacd4c8b..ce859d7c1c639514304238062478d0858c9113b8 100644 (file)
@@ -17699,8 +17699,11 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
                 * address listed on the entry (or if it's 'dynamic'), then we need to
                 * parse the entry to obtain the IP address, so a dynamic host can be
                 * contacted immediately after reload (as opposed to waiting for it to
-                * register once again). */
-               __set_address_from_contact(fullcontact, &peer->addr);
+                * register once again). But if we have an address for this peer and NAT was
+                * specified, use that address instead. */
+               if (!ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) || !peer->addr.sin_addr.s_addr) {
+                       __set_address_from_contact(fullcontact, &peer->addr);
+               }
        }
 
        if (!ast_test_flag(&global_flags[1], SIP_PAGE2_IGNOREREGEXPIRE) && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC) && realtime) {