--- channels/chan_sip.c.orig 2010-06-03 10:34:02.434091122 +0200 +++ channels/chan_sip.c 2010-06-03 10:35:17.184091079 +0200 @@ -10750,8 +10750,6 @@ static void initreqprep(struct sip_reque } if (ast_strlen_zero(l)) l = default_callerid; - if (ast_strlen_zero(n)) - n = l; /* Allow user to be overridden */ if (!ast_strlen_zero(p->fromuser)) l = p->fromuser; @@ -10772,10 +10770,17 @@ static void initreqprep(struct sip_reque } ourport = ntohs(p->ourip.sin_port); - if (!sip_standard_port(p->socket.type, ourport) && ast_strlen_zero(p->fromdomain)) - snprintf(from, sizeof(from), "\"%s\" ;tag=%s", n, l, d, ourport, p->tag); - else - snprintf(from, sizeof(from), "\"%s\" ;tag=%s", n, l, d, p->tag); + if (!sip_standard_port(p->socket.type, ourport) && ast_strlen_zero(p->fromdomain)) { + if (ast_strlen_zero(n)) + snprintf(from, sizeof(from), ";tag=%s", l, d, ourport, p->tag); /* also legal without <> */ + else + snprintf(from, sizeof(from), "\"%s\" ;tag=%s", n, l, d, ourport, p->tag); + } else { + if (ast_strlen_zero(n)) + snprintf(from, sizeof(from), ";tag=%s", l, d, p->tag); /* also legal without <> */ + else + snprintf(from, sizeof(from), "\"%s\" ;tag=%s", n, l, d, p->tag); + } /* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */ if (!ast_strlen_zero(p->fullcontact)) {