Build tohost on options
authorMark Spencer <markster@digium.com>
Sat, 3 May 2003 03:29:58 +0000 (03:29 +0000)
committerMark Spencer <markster@digium.com>
Sat, 3 May 2003 03:29:58 +0000 (03:29 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@952 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 74ae10c..10f2075 100755 (executable)
@@ -4740,7 +4740,10 @@ static int sip_poke_peer(struct sip_peer *peer)
        }
        memcpy(&p->sa, &peer->addr, sizeof(p->sa));
        memcpy(&p->recv, &peer->addr, sizeof(p->sa));
        }
        memcpy(&p->sa, &peer->addr, sizeof(p->sa));
        memcpy(&p->recv, &peer->addr, sizeof(p->sa));
-       strncpy(p->tohost, peer->tohost, sizeof(p->tohost) - 1);
+       if (strlen(p->tohost))
+               strncpy(p->tohost, peer->tohost, sizeof(p->tohost) - 1);
+       else
+               snprintf(p->tohost, sizeof(p->tohost), "%s", inet_ntoa(p->addr.sin_addr));
 
        /* Recalculate our side, and recalculate Call ID */
        memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));
 
        /* Recalculate our side, and recalculate Call ID */
        memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));