[asterisk-commits] oej: branch oej/fixtoheader-1.2 r50158 -
/team/oej/fixtoheader-1.2/channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 9 06:56:32 MST 2007
Author: oej
Date: Tue Jan 9 07:56:31 2007
New Revision: 50158
URL: http://svn.digium.com/view/asterisk?view=rev&rev=50158
Log:
First try at adding DNID to the SIP dial string
dial(SIP/peer!dnid)
dial(SIP/peer/exten!dnid)
dial(SIP/exten at peer!dnid)
The To: header will now contain the DNID given
dial(SIP/olle at edvina.net!olle at voop.com)
will send INVITE to olle at edvina.net with
To: olle at voop.com
dial(SIP/olle at edvina.net!+4612345678)
will send INVITE to olle at edvina.net with
To: +4612345678 at edvina.net
Not tested yet.
Modified:
team/oej/fixtoheader-1.2/channels/chan_sip.c
Modified: team/oej/fixtoheader-1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/fixtoheader-1.2/channels/chan_sip.c?view=diff&rev=50158&r1=50157&r2=50158
==============================================================================
--- team/oej/fixtoheader-1.2/channels/chan_sip.c (original)
+++ team/oej/fixtoheader-1.2/channels/chan_sip.c Tue Jan 9 07:56:31 2007
@@ -637,6 +637,7 @@
char fromdomain[MAXHOSTNAMELEN]; /*!< Domain to show in the from field */
char fromuser[AST_MAX_EXTENSION]; /*!< User to show in the user field */
char fromname[AST_MAX_EXTENSION]; /*!< Name to show in the user field */
+ char todnid[MAXHOSTNAMELEN]; /*!< DNID of this call */
char tohost[MAXHOSTNAMELEN]; /*!< Host we should put in the "to" field */
char language[MAX_LANGUAGE]; /*!< Default language for this call */
char musicclass[MAX_MUSICCLASS]; /*!< Music on Hold class */
@@ -5008,16 +5009,29 @@
if (p->options && p->options->uri_options)
ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
+ /* This is the request URI, which is the next hop of the call
+ which may or may not be the destination of the call.
+ */
ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
- if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) {
- /* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */
- snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->uri, p->theirtag);
- } else if (p->options && p->options->vxml_url) {
- /* If there is a VXML URL append it to the SIP URL */
- snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
+ /* Check if we have a DNID from the dial string for the To: header */
+ if (!ast_strlen_zero(p->todnid)) {
+ if (!strchr(p->todnid, '@')) {
+ /* We have no domain in the dnid */
+ snprintf(to, sizeof(to), "<sip:%s@%s>;tag=%s", p->todnid, p->tohost, p->theirtag);
+ } else {
+ snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->todnid, p->theirtag);
+ }
} else {
- snprintf(to, sizeof(to), "<%s>", p->uri);
+ if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) {
+ /* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */
+ snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->uri, p->theirtag);
+ } else if (p->options && p->options->vxml_url) {
+ /* If there is a VXML URL append it to the SIP URL */
+ snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
+ } else {
+ snprintf(to, sizeof(to), "<%s>", p->uri);
+ }
}
memset(req, 0, sizeof(struct sip_request));
@@ -11860,6 +11874,7 @@
char *ext, *host;
char tmp[256];
char *dest = data;
+ char *dnid;
oldformat = format;
format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1);
@@ -11883,24 +11898,48 @@
return NULL;
}
+ /* Save the destination, the SIP dial string */
ast_copy_string(tmp, dest, sizeof(tmp));
- host = strchr(tmp, '@');
+
+ /* Find at-sign @ */
+ host = strchr(tmp, '@'); /* Host can be peer name or DNS host name or DNS domain (srv enabled) */
+ /* Old Syntax: SIP/exten at host */
+ /* New Syntax: SIP/exten at host!dnid */
if (host) {
*host = '\0';
host++;
ext = tmp;
+ dnid = strchr(tmp, '!');
+ if (dnid) {
+ *dnid++ = '\0';
+ }
} else {
+ /* Old Syntax: SIP/host/exten */
+ /* New Syntax: SIP/host/exten!dnid */
ext = strchr(tmp, '/');
if (ext) {
*ext++ = '\0';
host = tmp;
- }
- else {
+ } else {
+ /* Old Syntax SIP/host */
+ /* New Syntax SIP/host!dnid */
host = tmp;
ext = NULL;
}
- }
-
+ /* Find DNID */
+ dnid = strchr(ext ? ext : host, '!');
+ if (dnid) {
+ *dnid++ = '\0';
+ }
+ }
+
+
+ /* We now have
+ host = peer name, DNS host name or DNS domain
+ ext = extension (user part of URI)
+ dnid = destination of the call (applies to the To: header)
+ */
+ ast_copy_string(p->todnid, dnid, sizeof(p->todnid));
if (create_addr(p, host)) {
*cause = AST_CAUSE_UNREGISTERED;
sip_destroy(p);
@@ -11917,7 +11956,8 @@
/* We have an extension to call, don't use the full contact here */
/* This to enable dialling registered peers with extension dialling,
like SIP/peername/extension
- SIP/peername will still use the full contact */
+ SIP/peername will still use the full contact
+ */
if (ext) {
ast_copy_string(p->username, ext, sizeof(p->username));
p->fullcontact[0] = 0;
More information about the asterisk-commits
mailing list