Minor sipredirect fixes (bug #3789)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5213 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2005-03-20 03:43:37 +00:00
parent 87bbe6ee7a
commit d0e9afeb2b
2 changed files with 15 additions and 12 deletions

View File

@@ -29,10 +29,14 @@ static char *app = "Transfer";
static char *synopsis = "Transfer caller to remote extension"; static char *synopsis = "Transfer caller to remote extension";
static char *descrip = static char *descrip =
" Transfer([Tech/]dest): Requests the remote caller be transferred\n" " Transfer([Tech/]dest): Requests the remote caller be transfered\n"
"a given extension. Returns -1 on hangup, or 0 on completion\n" "to a given extension. If TECH (SIP, IAX2, LOCAL etc) is used, only\n"
"regardless of whether the transfer was successful. If the transfer\n" "an incoming call with the same channel technology will be transfered.\n"
"was *not* supported or successful and there exists a priority n + 101,\n" "Note that for SIP, if you transfer before call is setup, a 302 redirect\n"
"SIP message will be returned to the caller.\n"
"Returns -1 on hangup, or 0 on completion regardless of whether the\n"
"transfer was successful. If the transfer was *not* supported or\n"
"successful and there exists a priority n + 101,\n"
"then that priority will be taken next.\n" ; "then that priority will be taken next.\n" ;
STANDARD_LOCAL_USER; STANDARD_LOCAL_USER;

View File

@@ -2078,7 +2078,6 @@ static int sip_transfer(struct ast_channel *ast, char *dest)
res = sip_sipredirect(p, dest); res = sip_sipredirect(p, dest);
else else
res = transmit_refer(p, dest); res = transmit_refer(p, dest);
res = transmit_refer(p, dest);
ast_mutex_unlock(&p->lock); ast_mutex_unlock(&p->lock);
return res; return res;
} }
@@ -10232,16 +10231,16 @@ static int sip_getheader(struct ast_channel *chan, void *data)
#define DEFAULT_MAX_FORWARDS 70 #define DEFAULT_MAX_FORWARDS 70
/* This is 302 sipredirect function coded by Martin Pycko (m78pl@yahoo.com) */ /*--- sip_sipredirect: Transfer call before connect with a 302 redirect ---*/
/* Called by the transfer() dialplan application through the sip_transfer() */
/* pbx interface function if the call is in ringing state */
/* coded by Martin Pycko (m78pl@yahoo.com) */
static int sip_sipredirect(struct sip_pvt *p, char *dest) static int sip_sipredirect(struct sip_pvt *p, char *dest)
{ {
char *cdest; char *cdest;
char *extension, *host, *port; char *extension, *host, *port;
char tmp[80]; char tmp[80];
if (!dest || ast_strlen_zero(dest)) {
ast_log(LOG_WARNING, "This application requires these arguments: SIPRedirect(extension[@host[:port]])\n");
return 0;
}
cdest = ast_strdupa(dest); cdest = ast_strdupa(dest);
if (!cdest) { if (!cdest) {
ast_log(LOG_ERROR, "Problem allocating the memory\n"); ast_log(LOG_ERROR, "Problem allocating the memory\n");
@@ -10268,7 +10267,7 @@ static int sip_sipredirect(struct sip_pvt *p, char *dest)
memset(lhost, 0, sizeof(lhost)); memset(lhost, 0, sizeof(lhost));
memset(lport, 0, sizeof(lport)); memset(lport, 0, sizeof(lport));
localtmp++; localtmp++;
/* This is okay becuase lhost and lport are as big as tmp */ /* This is okey because lhost and lport are as big as tmp */
sscanf(localtmp, "%[^<>:; ]:%[^<>:; ]", lhost, lport); sscanf(localtmp, "%[^<>:; ]:%[^<>:; ]", lhost, lport);
if (!strlen(lhost)) { if (!strlen(lhost)) {
ast_log(LOG_ERROR, "Can't find the host address\n"); ast_log(LOG_ERROR, "Can't find the host address\n");
@@ -10299,7 +10298,7 @@ static int sip_sipredirect(struct sip_pvt *p, char *dest)
p->maxforwards = DEFAULT_MAX_FORWARDS - 1; p->maxforwards = DEFAULT_MAX_FORWARDS - 1;
} }
if (p->maxforwards > -1) { if (p->maxforwards > -1) {
snprintf(p->our_contact, sizeof(p->our_contact), "redirect <sip:%s@%s%s%s>", extension, host, port ? ":" : "", port ? port : ""); snprintf(p->our_contact, sizeof(p->our_contact), "Transfer <sip:%s@%s%s%s>", extension, host, port ? ":" : "", port ? port : "");
transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq, 1); transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq, 1);
} else { } else {
transmit_response(p, "483 Too Many Hops", &p->initreq); transmit_response(p, "483 Too Many Hops", &p->initreq);