diff options
author | Mark Spencer <markster@digium.com> | 2003-05-14 05:33:06 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2003-05-14 05:33:06 +0000 |
commit | 8f27350e65509ac51e7e922b6934217226664634 (patch) | |
tree | 23b90a95ccbc1acc8ade932120bf3a913ab9b097 /channels | |
parent | 8e280ab712912b526a44021cd84915a491e80faa (diff) |
Add transfer to IAX2, and transfer application
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1016 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_iax2.c | 34 | ||||
-rwxr-xr-x | channels/iax2-parser.c | 5 | ||||
-rwxr-xr-x | channels/iax2-parser.h | 1 | ||||
-rwxr-xr-x | channels/iax2.h | 2 |
4 files changed, 41 insertions, 1 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 6bb2c4817..2316cd686 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -994,7 +994,6 @@ static void iax2_destroy(int callno) retry: ast_pthread_mutex_lock(&iaxsl[callno]); pvt = iaxs[callno]; - iaxs[callno] = NULL; gettimeofday(&lastused[callno], NULL); if (pvt) @@ -1009,6 +1008,7 @@ retry: goto retry; } } + iaxs[callno] = NULL; if (pvt) { pvt->owner = NULL; /* No more pings or lagrq's */ @@ -1918,6 +1918,26 @@ static int iax2_indicate(struct ast_channel *c, int condition) return send_command(pvt, AST_FRAME_CONTROL, condition, 0, NULL, 0, -1); } +static int iax2_transfer(struct ast_channel *c, char *dest) +{ + struct chan_iax2_pvt *pvt = c->pvt->pvt; + struct iax_ie_data ied; + char tmp[256] = "", *context; + strncpy(tmp, dest, sizeof(tmp) - 1); + context = strchr(tmp, '@'); + if (context) { + *context = '\0'; + context++; + } + memset(&ied, 0, sizeof(ied)); + iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, tmp); + if (context) + iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, context); + if (option_debug) + ast_log(LOG_DEBUG, "Transferring '%s' to '%s'\n", c->name, dest); + return send_command(pvt, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1); +} + static int iax2_write(struct ast_channel *c, struct ast_frame *f); @@ -1966,6 +1986,7 @@ static struct ast_channel *ast_iax2_new(struct chan_iax2_pvt *i, int state, int tmp->pvt->indicate = iax2_indicate; tmp->pvt->setoption = iax2_setoption; tmp->pvt->bridge = iax2_bridge; + tmp->pvt->transfer = iax2_transfer; if (strlen(i->callerid)) tmp->callerid = strdup(i->callerid); if (strlen(i->ani)) @@ -3973,6 +3994,17 @@ static int socket_read(int *id, int fd, short events, void *cbdata) send_command_immediate(iaxs[fr.callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr.ts, NULL, 0,fr.iseqno); iax2_destroy_nolock(fr.callno); break; + case IAX_COMMAND_TRANSFER: + if (iaxs[fr.callno]->owner && iaxs[fr.callno]->owner->bridge && ies.called_number) { + if (ast_async_goto(iaxs[fr.callno]->owner->bridge, iaxs[fr.callno]->context, ies.called_number, 1, 1)) + ast_log(LOG_WARNING, "Async goto of '%s' to '%s@%s' failed\n", iaxs[fr.callno]->owner->bridge->name, + ies.called_number, iaxs[fr.callno]->context); + else + ast_log(LOG_DEBUG, "Async goto of '%s' to '%s@%s' started\n", iaxs[fr.callno]->owner->bridge->name, + ies.called_number, iaxs[fr.callno]->context); + } else + ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr.callno); + break; case IAX_COMMAND_ACCEPT: /* Ignore if call is already up or needs authentication or is a TBD */ if (iaxs[fr.callno]->state & (IAX_STATE_STARTED | IAX_STATE_TBD | IAX_STATE_AUTHENTICATED)) diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c index 73fca93e5..2c4ad9c8b 100755 --- a/channels/iax2-parser.c +++ b/channels/iax2-parser.c @@ -116,6 +116,7 @@ static struct iax2_ie { { IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short }, { IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" }, { IAX_IE_TRANSFERID, "TRANSFER ID", dump_int }, + { IAX_IE_RDNIS, "REFERRING DNIS", dump_string }, }; const char *iax_ie2str(int ie) @@ -217,6 +218,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s "PAGE", "MWI", "UNSUPPORTED", + "TRANSFER", }; char *cmds[] = { "(0?)", @@ -420,6 +422,9 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen) case IAX_IE_DNID: ies->dnid = data + 2; break; + case IAX_IE_RDNIS: + ies->rdnis = data + 2; + break; case IAX_IE_AUTHMETHODS: if (len != sizeof(unsigned short)) { snprintf(tmp, sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", sizeof(unsigned short), len); diff --git a/channels/iax2-parser.h b/channels/iax2-parser.h index bdca49686..9f20a1817 100755 --- a/channels/iax2-parser.h +++ b/channels/iax2-parser.h @@ -28,6 +28,7 @@ struct iax_ies { int version; unsigned short adsicpe; char *dnid; + char *rdnis; unsigned int authmethods; char *challenge; char *md5_result; diff --git a/channels/iax2.h b/channels/iax2.h index 570c1e87a..d69459999 100755 --- a/channels/iax2.h +++ b/channels/iax2.h @@ -63,6 +63,7 @@ #define IAX_COMMAND_PAGE 31 /* Paging description */ #define IAX_COMMAND_MWI 32 /* Stand-alone message waiting indicator */ #define IAX_COMMAND_UNSUPPORT 33 /* Unsupported message received */ +#define IAX_COMMAND_TRANSFER 34 /* Request remote transfer */ #define IAX_DEFAULT_REG_EXPIRE 60 /* By default require re-registration once per minute */ @@ -98,6 +99,7 @@ #define IAX_IE_AUTOANSWER 25 /* Request auto-answering -- none */ #define IAX_IE_MUSICONHOLD 26 /* Request musiconhold with QUELCH -- none or string */ #define IAX_IE_TRANSFERID 27 /* Transfer Request Identifier -- int */ +#define IAX_IE_RDNIS 28 /* Referring DNIS -- string */ #define IAX_AUTH_PLAINTEXT (1 << 0) #define IAX_AUTH_MD5 (1 << 1) |