}
/*--- build_callid: Build SIP CALLID header ---*/
-static void build_callid(char *callid, int len, struct in_addr ourip)
+static void build_callid(char *callid, int len, struct in_addr ourip, char *fromdomain)
{
int res;
int val;
len -= res;
callid += res;
}
+ if (!ast_strlen_zero(fromdomain))
+ snprintf(callid, len, "@%s", fromdomain);
+ else
/* It's not important that we really use our right IP here... */
- snprintf(callid, len, "@%s", ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
+ snprintf(callid, len, "@%s", ast_inet_ntoa(iabuf, sizeof(iabuf), ourip));
}
/*--- sip_alloc: Allocate SIP_PVT structure and set defaults ---*/
ast_rtp_setnat(p->vrtp, (p->nat & SIP_NAT_ROUTE));
}
+ strncpy(p->fromdomain, default_fromdomain, sizeof(p->fromdomain) - 1);
/* z9hG4bK is a magic cookie. See RFC 3261 section 8.1.1.7 */
if (p->nat != SIP_NAT_NEVER)
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
else
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
if (!callid)
- build_callid(p->callid, sizeof(p->callid), p->ourip);
+ build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
else
strncpy(p->callid, callid, sizeof(p->callid) - 1);
/* Assume reinvite OK and via INVITE */
if (p->dtmfmode & SIP_DTMF_RFC2833)
p->noncodeccapability |= AST_RTP_DTMF;
strncpy(p->context, default_context, sizeof(p->context) - 1);
- strncpy(p->fromdomain, default_fromdomain, sizeof(p->fromdomain) - 1);
/* Add to list */
ast_mutex_lock(&iflock);
p->next = iflist;
p = r->call;
} else {
if (!r->callid_valid) {
- build_callid(r->callid, sizeof(r->callid), __ourip);
+ build_callid(r->callid, sizeof(r->callid), __ourip, default_fromdomain);
r->callid_valid = 1;
}
p=sip_alloc( r->callid, NULL, 0);
sip_destroy(p);
return 0;
}
+ /* Copy back Call-ID in case create_addr changed it */
+ strncpy(r->callid, p->callid, sizeof(r->callid) - 1);
if (r->portno)
p->sa.sin_port = htons(r->portno);
p->outgoing = 1;
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
else /* UNIDEN UIP200 bug */
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
- build_callid(p->callid, sizeof(p->callid), p->ourip);
+ build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
/* Send MWI */
p->outgoing = 1;
transmit_notify_with_mwi(p, newmsgs, oldmsgs);
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
else
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
- build_callid(p->callid, sizeof(p->callid), p->ourip);
+ build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
if (peer->pokeexpire > -1)
ast_sched_del(sched, peer->pokeexpire);
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x;rport", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
else /* UNIDEN bug */
snprintf(p->via, sizeof(p->via), "SIP/2.0/UDP %s:%d;branch=z9hG4bK%08x", ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch);
- build_callid(p->callid, sizeof(p->callid), p->ourip);
+ build_callid(p->callid, sizeof(p->callid), p->ourip, p->fromdomain);
if (ext)
strncpy(p->username, ext, sizeof(p->username) - 1);
#if 0