allow for custom URI options to be set (issue #4927 with mods)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6499 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
14c769230b
commit
6b76015469
2 changed files with 41 additions and 31 deletions
|
@ -442,6 +442,7 @@ struct sip_invite_param {
|
||||||
char *distinctive_ring;
|
char *distinctive_ring;
|
||||||
char *osptoken;
|
char *osptoken;
|
||||||
int addsipheaders;
|
int addsipheaders;
|
||||||
|
char *uri_options;
|
||||||
char *vxml_url;
|
char *vxml_url;
|
||||||
char *auth;
|
char *auth;
|
||||||
char *authheader;
|
char *authheader;
|
||||||
|
@ -1941,6 +1942,8 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
|
||||||
/* Check whether there is a VXML_URL variable */
|
/* Check whether there is a VXML_URL variable */
|
||||||
if (!p->options->vxml_url && !strcasecmp(ast_var_name(current), "VXML_URL")) {
|
if (!p->options->vxml_url && !strcasecmp(ast_var_name(current), "VXML_URL")) {
|
||||||
p->options->vxml_url = ast_var_value(current);
|
p->options->vxml_url = ast_var_value(current);
|
||||||
|
} else if (!p->options->uri_options && !strcasecmp(ast_var_name(current), "SIP_URI_OPTIONS")) {
|
||||||
|
p->options->uri_options = ast_var_value(current);
|
||||||
} else if (!p->options->distinctive_ring && !strcasecmp(ast_var_name(current), "ALERT_INFO")) {
|
} else if (!p->options->distinctive_ring && !strcasecmp(ast_var_name(current), "ALERT_INFO")) {
|
||||||
/* Check whether there is a ALERT_INFO variable */
|
/* Check whether there is a ALERT_INFO variable */
|
||||||
p->options->distinctive_ring = ast_var_value(current);
|
p->options->distinctive_ring = ast_var_value(current);
|
||||||
|
@ -4388,9 +4391,11 @@ static void build_contact(struct sip_pvt *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--- initreqprep: Initiate new SIP request to peer/user ---*/
|
/*--- initreqprep: Initiate new SIP request to peer/user ---*/
|
||||||
static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, char *vxml_url)
|
static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod)
|
||||||
{
|
{
|
||||||
char invite[256] = "";
|
char invite_buf[256] = "";
|
||||||
|
char *invite = invite_buf;
|
||||||
|
size_t invite_max = sizeof(invite_buf);
|
||||||
char from[256];
|
char from[256];
|
||||||
char to[256];
|
char to[256];
|
||||||
char tmp[BUFSIZ/2];
|
char tmp[BUFSIZ/2];
|
||||||
|
@ -4460,41 +4465,45 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, int sipmetho
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ourport != 5060) && ast_strlen_zero(p->fromdomain)) /* Needs to be 5060 */
|
if ((ourport != 5060) && ast_strlen_zero(p->fromdomain)) /* Needs to be 5060 */
|
||||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=as%08x", tmp, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, ourport, p->tag);
|
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s:%d>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, ourport, p->tag);
|
||||||
else
|
else
|
||||||
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, p->tag);
|
snprintf(from, sizeof(from), "\"%s\" <sip:%s@%s>;tag=as%08x", n, l, ast_strlen_zero(p->fromdomain) ? ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip) : p->fromdomain, p->tag);
|
||||||
|
|
||||||
/* If we're calling a registred SIP peer, use the fullcontact to dial to the peer */
|
/* If we're calling a registered SIP peer, use the fullcontact to dial to the peer */
|
||||||
if (!ast_strlen_zero(p->fullcontact)) {
|
if (!ast_strlen_zero(p->fullcontact)) {
|
||||||
/* If we have full contact, trust it */
|
/* If we have full contact, trust it */
|
||||||
ast_copy_string(invite, p->fullcontact, sizeof(invite));
|
ast_build_string(&invite, &invite_max, "%s", p->fullcontact);
|
||||||
|
} else {
|
||||||
/* Otherwise, use the username while waiting for registration */
|
/* Otherwise, use the username while waiting for registration */
|
||||||
} else if (!ast_strlen_zero(p->username)) {
|
ast_build_string(&invite, &invite_max, "sip:");
|
||||||
|
if (!ast_strlen_zero(p->username)) {
|
||||||
n = p->username;
|
n = p->username;
|
||||||
if (pedanticsipchecking) {
|
if (pedanticsipchecking) {
|
||||||
ast_uri_encode(n, tmp, sizeof(tmp), 0);
|
ast_uri_encode(n, tmp, sizeof(tmp), 0);
|
||||||
n = tmp;
|
n = tmp;
|
||||||
}
|
}
|
||||||
if (ntohs(p->sa.sin_port) != 5060) { /* Needs to be 5060 */
|
ast_build_string(&invite, &invite_max, "%s@", n);
|
||||||
snprintf(invite, sizeof(invite), "sip:%s@%s:%d%s", n, p->tohost, ntohs(p->sa.sin_port), urioptions);
|
|
||||||
} else {
|
|
||||||
snprintf(invite, sizeof(invite), "sip:%s@%s%s", n, p->tohost, urioptions);
|
|
||||||
}
|
}
|
||||||
} else if (ntohs(p->sa.sin_port) != 5060) { /* Needs to be 5060 */
|
ast_build_string(&invite, &invite_max, "%s", p->tohost);
|
||||||
snprintf(invite, sizeof(invite), "sip:%s:%d%s", p->tohost, ntohs(p->sa.sin_port), urioptions);
|
if (ntohs(p->sa.sin_port) != 5060) /* Needs to be 5060 */
|
||||||
} else {
|
ast_build_string(&invite, &invite_max, ":%d", ntohs(p->sa.sin_port));
|
||||||
snprintf(invite, sizeof(invite), "sip:%s%s", p->tohost, urioptions);
|
ast_build_string(&invite, &invite_max, "%s", urioptions);
|
||||||
}
|
}
|
||||||
ast_copy_string(p->uri, invite, sizeof(p->uri));
|
|
||||||
|
/* If custom URI options have been provided, append them */
|
||||||
|
if (p->options && p->options->uri_options)
|
||||||
|
ast_build_string(&invite, &invite_max, ";%s", p->options->uri_options);
|
||||||
|
|
||||||
|
ast_copy_string(p->uri, invite_buf, sizeof(p->uri));
|
||||||
|
|
||||||
/* If there is a VXML URL append it to the SIP URL */
|
/* If there is a VXML URL append it to the SIP URL */
|
||||||
if (vxml_url) {
|
if (p->options && p->options->vxml_url) {
|
||||||
snprintf(to, sizeof(to), "<%s>;%s", invite, vxml_url);
|
snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
|
||||||
} else {
|
} else {
|
||||||
snprintf(to, sizeof(to), "<%s>", invite);
|
snprintf(to, sizeof(to), "<%s>", p->uri);
|
||||||
}
|
}
|
||||||
memset(req, 0, sizeof(struct sip_request));
|
memset(req, 0, sizeof(struct sip_request));
|
||||||
init_req(req, sipmethod, invite);
|
init_req(req, sipmethod, p->uri);
|
||||||
snprintf(tmp, sizeof(tmp), "%d %s", ++p->ocseq, sip_methods[sipmethod].text);
|
snprintf(tmp, sizeof(tmp), "%d %s", ++p->ocseq, sip_methods[sipmethod].text);
|
||||||
|
|
||||||
add_header(req, "Via", p->via);
|
add_header(req, "Via", p->via);
|
||||||
|
@ -4520,7 +4529,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
|
||||||
/* Bump branch even on initial requests */
|
/* Bump branch even on initial requests */
|
||||||
p->branch ^= rand();
|
p->branch ^= rand();
|
||||||
build_via(p, p->via, sizeof(p->via));
|
build_via(p, p->via, sizeof(p->via));
|
||||||
initreqprep(&req, p, sipmethod, p->options ? p->options->vxml_url : (char *) NULL);
|
initreqprep(&req, p, sipmethod);
|
||||||
} else
|
} else
|
||||||
reqprep(&req, p, sipmethod, 0, 1);
|
reqprep(&req, p, sipmethod, 0, 1);
|
||||||
|
|
||||||
|
@ -4783,7 +4792,7 @@ static int transmit_notify_with_mwi(struct sip_pvt *p, int newmsgs, int oldmsgs,
|
||||||
char *t = tmp;
|
char *t = tmp;
|
||||||
size_t maxbytes = sizeof(tmp);
|
size_t maxbytes = sizeof(tmp);
|
||||||
|
|
||||||
initreqprep(&req, p, SIP_NOTIFY, NULL);
|
initreqprep(&req, p, SIP_NOTIFY);
|
||||||
add_header(&req, "Event", "message-summary");
|
add_header(&req, "Event", "message-summary");
|
||||||
add_header(&req, "Content-Type", default_notifymime);
|
add_header(&req, "Content-Type", default_notifymime);
|
||||||
|
|
||||||
|
@ -8272,7 +8281,7 @@ static int sip_notify(int fd, int argc, char *argv[])
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
initreqprep(&req, p, SIP_NOTIFY, NULL);
|
initreqprep(&req, p, SIP_NOTIFY);
|
||||||
|
|
||||||
for (var = varlist; var; var = var->next)
|
for (var = varlist; var; var = var->next)
|
||||||
add_header(&req, var->name, var->value);
|
add_header(&req, var->name, var->value);
|
||||||
|
|
|
@ -628,13 +628,14 @@ ${CALLINGSUBADDR} * Called PRI Subaddress
|
||||||
${FAXEXTEN} * The extension called before being redirected to "fax"
|
${FAXEXTEN} * The extension called before being redirected to "fax"
|
||||||
${PRIREDIRECTREASON} * Reason for redirect, if a call was directed
|
${PRIREDIRECTREASON} * Reason for redirect, if a call was directed
|
||||||
|
|
||||||
The SIP channel sets the following variables:
|
The SIP channel uses the following variables:
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
${SIPCALLID} * SIP Call-ID: header verbatim (for logging or CDR matching)
|
${SIPCALLID} * SIP Call-ID: header verbatim (for logging or CDR matching)
|
||||||
${SIPDOMAIN} * SIP destination domain of an inbound call (if appropriate)
|
${SIPDOMAIN} * SIP destination domain of an inbound call (if appropriate)
|
||||||
${SIPUSERAGENT} * SIP user agent
|
${SIPUSERAGENT} * SIP user agent
|
||||||
${SIPURI} * SIP uri
|
${SIPURI} * SIP uri
|
||||||
${SIP_CODEC} Set the SIP codec for a call
|
${SIP_CODEC} Set the SIP codec for a call
|
||||||
|
${SIP_URI_OPTIONS} * additional options to add to the URI for an outgoing call
|
||||||
|
|
||||||
The Agent channel uses the following variables:
|
The Agent channel uses the following variables:
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue