diff -Naur asterisk-old/channels/chan_sip.c asterisk/channels/chan_sip.c --- asterisk-old/channels/chan_sip.c 2004-07-16 12:26:24.394003037 -0500 +++ asterisk/channels/chan_sip.c 2004-07-16 12:39:56.301883800 -0500 @@ -3596,7 +3596,7 @@ { char iabuf[INET_ADDRSTRLEN]; /* Construct Contact: header */ - if (ourport != 5060) + if ((ourport != 5060) && (ourport != 0)) snprintf(p->our_contact, sizeof(p->our_contact), "", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport); else snprintf(p->our_contact, sizeof(p->our_contact), "", p->exten, ast_strlen_zero(p->exten) ? "" : "@", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip)); @@ -3635,18 +3635,18 @@ if (!ast_strlen_zero(p->fromuser)) l = p->fromuser; - if ((ourport != 5060) && ast_strlen_zero(p->fromdomain)) + if ((ourport != 5060) && (ourport != 0) && ast_strlen_zero(p->fromdomain)) snprintf(from, sizeof(from), "\"%s\" ;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, ourport, p->tag); else snprintf(from, sizeof(from), "\"%s\" ;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, p->tag); if (!ast_strlen_zero(p->username)) { - if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT) { + if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT && ntohs(p->sa.sin_port) != 0) { snprintf(invite, sizeof(invite), "sip:%s@%s:%d",p->username, p->tohost, ntohs(p->sa.sin_port)); } else { snprintf(invite, sizeof(invite), "sip:%s@%s",p->username, p->tohost); } - } else if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT) { + } else if (ntohs(p->sa.sin_port) != DEFAULT_SIP_PORT && ntohs(p->sa.sin_port) != 0) { snprintf(invite, sizeof(invite), "sip:%s:%d", p->tohost, ntohs(p->sa.sin_port)); } else { snprintf(invite, sizeof(invite), "sip:%s", p->tohost);