mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 08:13:22 +00:00
Add transfer ID for potential use in more complex NAT environments
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -348,6 +348,8 @@ struct chan_iax2_pvt {
|
|||||||
|
|
||||||
/* Transferring status */
|
/* Transferring status */
|
||||||
int transferring;
|
int transferring;
|
||||||
|
/* Transfer identifier */
|
||||||
|
int transferid;
|
||||||
/* Already disconnected */
|
/* Already disconnected */
|
||||||
int alreadygone;
|
int alreadygone;
|
||||||
/* Who we are IAX transfering to */
|
/* 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 iax_ie_data ied1;
|
||||||
struct chan_iax2_pvt *p0 = c0->pvt->pvt;
|
struct chan_iax2_pvt *p0 = c0->pvt->pvt;
|
||||||
struct chan_iax2_pvt *p1 = c1->pvt->pvt;
|
struct chan_iax2_pvt *p1 = c1->pvt->pvt;
|
||||||
|
unsigned int transferid = rand();
|
||||||
memset(&ied0, 0, sizeof(ied0));
|
memset(&ied0, 0, sizeof(ied0));
|
||||||
iax_ie_append_addr(&ied0, IAX_IE_APPARENT_ADDR, &p1->addr);
|
iax_ie_append_addr(&ied0, IAX_IE_APPARENT_ADDR, &p1->addr);
|
||||||
iax_ie_append_short(&ied0, IAX_IE_CALLNO, p1->peercallno);
|
iax_ie_append_short(&ied0, IAX_IE_CALLNO, p1->peercallno);
|
||||||
|
iax_ie_append_int(&ied0, IAX_IE_TRANSFERID, transferid);
|
||||||
|
|
||||||
memset(&ied1, 0, sizeof(ied1));
|
memset(&ied1, 0, sizeof(ied1));
|
||||||
iax_ie_append_addr(&ied1, IAX_IE_APPARENT_ADDR, &p0->addr);
|
iax_ie_append_addr(&ied1, IAX_IE_APPARENT_ADDR, &p0->addr);
|
||||||
iax_ie_append_short(&ied1, IAX_IE_CALLNO, p0->peercallno);
|
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);
|
res = send_command(p0, AST_FRAME_IAX, IAX_COMMAND_TXREQ, 0, ied0.buf, ied0.pos, -1);
|
||||||
if (res)
|
if (res)
|
||||||
@@ -2931,9 +2936,11 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
|
|||||||
{
|
{
|
||||||
int newcall = 0;
|
int newcall = 0;
|
||||||
char newip[256] = "";
|
char newip[256] = "";
|
||||||
|
struct iax_ie_data ied;
|
||||||
struct sockaddr_in new;
|
struct sockaddr_in new;
|
||||||
|
|
||||||
|
|
||||||
|
memset(&ied, 0, sizeof(ied));
|
||||||
if (ies->apparent_addr)
|
if (ies->apparent_addr)
|
||||||
memcpy(&new, ies->apparent_addr, sizeof(new));
|
memcpy(&new, ies->apparent_addr, sizeof(new));
|
||||||
if (ies->callno)
|
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);
|
inet_aton(newip, &pvt->transfer.sin_addr);
|
||||||
pvt->transfer.sin_family = AF_INET;
|
pvt->transfer.sin_family = AF_INET;
|
||||||
pvt->transferring = TRANSFER_BEGIN;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -110,6 +110,7 @@ static struct iax2_ie {
|
|||||||
{ IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte },
|
{ IAX_IE_IAX_UNKNOWN, "UNKNOWN IAX CMD", dump_byte },
|
||||||
{ IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short },
|
{ IAX_IE_MSGCOUNT, "MESSAGE COUNT", dump_short },
|
||||||
{ IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" },
|
{ IAX_IE_AUTOANSWER, "AUTO ANSWER REQ" },
|
||||||
|
{ IAX_IE_TRANSFERID, "TRANSFER ID", dump_int },
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *iax_ie2str(int ie)
|
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:
|
case IAX_IE_MUSICONHOLD:
|
||||||
ies->musiconhold = 1;
|
ies->musiconhold = 1;
|
||||||
break;
|
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:
|
default:
|
||||||
snprintf(tmp, sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
|
snprintf(tmp, sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len);
|
||||||
errorf(tmp);
|
errorf(tmp);
|
||||||
|
@@ -41,6 +41,7 @@ struct iax_ies {
|
|||||||
int msgcount;
|
int msgcount;
|
||||||
int autoanswer;
|
int autoanswer;
|
||||||
int musiconhold;
|
int musiconhold;
|
||||||
|
unsigned int transferid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DIRECTION_INGRESS 1
|
#define DIRECTION_INGRESS 1
|
||||||
|
@@ -97,6 +97,7 @@
|
|||||||
#define IAX_IE_MSGCOUNT 24 /* How many messages waiting - short */
|
#define IAX_IE_MSGCOUNT 24 /* How many messages waiting - short */
|
||||||
#define IAX_IE_AUTOANSWER 25 /* Request auto-answering -- none */
|
#define IAX_IE_AUTOANSWER 25 /* Request auto-answering -- none */
|
||||||
#define IAX_IE_MUSICONHOLD 26 /* Request musiconhold with QUELCH -- none or string */
|
#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_PLAINTEXT (1 << 0)
|
||||||
#define IAX_AUTH_MD5 (1 << 1)
|
#define IAX_AUTH_MD5 (1 << 1)
|
||||||
|
2
dsp.c
2
dsp.c
@@ -843,7 +843,7 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
|
|||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int pass;
|
int pass;
|
||||||
int newstate;
|
int newstate = TONE_STATE_SILENCE;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
while(len) {
|
while(len) {
|
||||||
/* Take the lesser of the number of samples we need and what we have */
|
/* Take the lesser of the number of samples we need and what we have */
|
||||||
|
Reference in New Issue
Block a user