aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-03-20 05:56:00 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-03-20 05:56:00 +0000
commit6ff1dd3a9faf381313fd257e8c59278fae163c0d (patch)
treeeeb413db61d13c98b0fc09cfc774a8d398f1571a
parent0cca4b7c509deee3a759b637508ec83708798b07 (diff)
Add transfer ID for potential use in more complex NAT environments
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@661 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannels/chan_iax2.c14
-rwxr-xr-xchannels/iax2-parser.c8
-rwxr-xr-xchannels/iax2-parser.h1
-rwxr-xr-xchannels/iax2.h1
-rwxr-xr-xdsp.c2
5 files changed, 23 insertions, 3 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index b1d2402ce..b5212d381 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -348,6 +348,8 @@ struct chan_iax2_pvt {
/* Transferring status */
int transferring;
+ /* Transfer identifier */
+ int transferid;
/* Already disconnected */
int alreadygone;
/* Who we are IAX transfering to */
@@ -1757,13 +1759,16 @@ static int iax2_start_transfer(struct ast_channel *c0, struct ast_channel *c1)
struct iax_ie_data ied1;
struct chan_iax2_pvt *p0 = c0->pvt->pvt;
struct chan_iax2_pvt *p1 = c1->pvt->pvt;
+ unsigned int transferid = rand();
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_addr(&ied0, IAX_IE_APPARENT_ADDR, &p1->addr);
iax_ie_append_short(&ied0, IAX_IE_CALLNO, p1->peercallno);
+ iax_ie_append_int(&ied0, IAX_IE_TRANSFERID, transferid);
memset(&ied1, 0, sizeof(ied1));
iax_ie_append_addr(&ied1, IAX_IE_APPARENT_ADDR, &p0->addr);
iax_ie_append_short(&ied1, IAX_IE_CALLNO, p0->peercallno);
+ iax_ie_append_int(&ied1, IAX_IE_TRANSFERID, transferid);
res = send_command(p0, AST_FRAME_IAX, IAX_COMMAND_TXREQ, 0, ied0.buf, ied0.pos, -1);
if (res)
@@ -2931,9 +2936,11 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
{
int newcall = 0;
char newip[256] = "";
-
+ struct iax_ie_data ied;
struct sockaddr_in new;
+
+ memset(&ied, 0, sizeof(ied));
if (ies->apparent_addr)
memcpy(&new, ies->apparent_addr, sizeof(new));
if (ies->callno)
@@ -2947,7 +2954,10 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
inet_aton(newip, &pvt->transfer.sin_addr);
pvt->transfer.sin_family = AF_INET;
pvt->transferring = TRANSFER_BEGIN;
- send_command_transfer(pvt, AST_FRAME_IAX, IAX_COMMAND_TXCNT, 0, NULL, 0);
+ pvt->transferid = ies->transferid;
+ if (ies->transferid)
+ iax_ie_append_int(&ied, IAX_IE_TRANSFERID, ies->transferid);
+ send_command_transfer(pvt, AST_FRAME_IAX, IAX_COMMAND_TXCNT, 0, ied.buf, ied.pos);
return 0;
}
diff --git a/channels/iax2-parser.c b/channels/iax2-parser.c
index f7020562b..1187a9098 100755
--- a/channels/iax2-parser.c
+++ b/channels/iax2-parser.c
@@ -110,6 +110,7 @@ static struct iax2_ie {
{ IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte },
{ IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short },
{ IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" },
+ { IAX_IE_TRANSFERID, "TRANSFER ID", dump_int },
};
const char *iax_ie2str(int ie)
@@ -478,6 +479,13 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
case IAX_IE_MUSICONHOLD:
ies->musiconhold = 1;
break;
+ case IAX_IE_TRANSFERID:
+ if (len != sizeof(unsigned int)) {
+ snprintf(tmp, sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", sizeof(unsigned int), len);
+ errorf(tmp);
+ } else
+ ies->transferid = ntohl(*((unsigned int *)(data + 2)));
+ break;
default:
snprintf(tmp, sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
errorf(tmp);
diff --git a/channels/iax2-parser.h b/channels/iax2-parser.h
index e34ca1ca7..f23b70d35 100755
--- a/channels/iax2-parser.h
+++ b/channels/iax2-parser.h
@@ -41,6 +41,7 @@ struct iax_ies {
int msgcount;
int autoanswer;
int musiconhold;
+ unsigned int transferid;
};
#define DIRECTION_INGRESS 1
diff --git a/channels/iax2.h b/channels/iax2.h
index 88ffe0ca0..570c1e87a 100755
--- a/channels/iax2.h
+++ b/channels/iax2.h
@@ -97,6 +97,7 @@
#define IAX_IE_MSGCOUNT 24 /* How many messages waiting - short */
#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_AUTH_PLAINTEXT (1 << 0)
#define IAX_AUTH_MD5 (1 << 1)
diff --git a/dsp.c b/dsp.c
index 62e03420f..afcb3fd79 100755
--- a/dsp.c
+++ b/dsp.c
@@ -843,7 +843,7 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
{
int x;
int pass;
- int newstate;
+ int newstate = TONE_STATE_SILENCE;
int res = 0;
while(len) {
/* Take the lesser of the number of samples we need and what we have */