chan_iax2: Add ANI2/OLI information element

Adds an information element for ANI2 so that
Originating Line Information can be transmitted
over IAX2 channels.

ASTERISK-29605 #close

Change-Id: Iaeacdf6ccde18eaff7f776a0f49fee87dcb549d2
This commit is contained in:
Naveen Albert 2021-08-18 19:44:17 +00:00 committed by George Joseph
parent 185321066f
commit 29770520b3
5 changed files with 22 additions and 0 deletions

View File

@ -865,6 +865,7 @@ struct chan_iax2_pvt {
int calling_ton;
int calling_tns;
int calling_pres;
int calling_ani2;
int amaflags;
AST_LIST_HEAD_NOLOCK(, iax2_dpcache) dpentries;
/*! variables inherited from the user definition */
@ -5181,6 +5182,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
iax_ie_append_byte(&ied, IAX_IE_CALLINGTON, ast_channel_connected(c)->id.number.plan);
iax_ie_append_short(&ied, IAX_IE_CALLINGTNS, ast_channel_dialed(c)->transit_network_select);
iax_ie_append_int(&ied, IAX_IE_CALLINGANI2, ast_channel_connected(c)->ani2);
if (n)
iax_ie_append_str(&ied, IAX_IE_CALLING_NAME, n);
@ -5941,6 +5943,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
ast_channel_redirecting(tmp)->from.number.valid = 1;
ast_channel_redirecting(tmp)->from.number.str = ast_strdup(i->rdnis);
}
ast_channel_caller(tmp)->ani2 = i->calling_ani2;
ast_channel_caller(tmp)->id.name.presentation = i->calling_pres;
ast_channel_caller(tmp)->id.number.presentation = i->calling_pres;
ast_channel_caller(tmp)->id.number.plan = i->calling_ton;
@ -7831,6 +7834,8 @@ static int check_access(int callno, struct ast_sockaddr *addr, struct iax_ies *i
iaxs[callno]->calling_tns = ies->calling_tns;
if (ies->calling_pres > -1)
iaxs[callno]->calling_pres = ies->calling_pres;
if (ies->calling_ani2 > -1)
iaxs[callno]->calling_ani2 = ies->calling_ani2;
if (ies->format)
iaxs[callno]->peerformat = ies->format;
if (ies->adsicpe)

View File

@ -187,6 +187,8 @@ enum iax_frame_subclass {
#define IAX_IE_CAPABILITY2 55 /*!< Actual codec capability - u8 version + integer array */
#define IAX_IE_FORMAT2 56 /*!< Desired codec format - u8 version + integer array */
#define IAX_IE_CALLINGANI2 57 /*!< Calling Originating Line Information (ANI2) digits */
#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
#define IAX_MAX_OSPBLOCK_NUM 4
#define IAX_MAX_OSPTOKEN_SIZE (IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)

View File

@ -32,6 +32,7 @@ struct iax_ies {
int calling_ton;
int calling_tns;
int calling_pres;
int calling_ani2;
char *called_context;
char *username;
char *password;

View File

@ -313,6 +313,7 @@ static struct iax2_ie infoelts[] = {
{ IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte },
{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
{ IAX_IE_CALLINGANI2, "CALLING ANI2", dump_int },
{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
{ IAX_IE_CAUSECODE, "CAUSE CODE", dump_byte },
{ IAX_IE_ENCRYPTION, "ENCRYPTION", dump_short },
@ -805,6 +806,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
ies->calling_ton = -1;
ies->calling_tns = -1;
ies->calling_pres = -1;
ies->calling_ani2 = -1;
ies->samprate = IAX_RATE_8KHZ;
while(datalen >= 2) {
ie = data[0];
@ -1057,6 +1059,14 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
errorf(tmp);
}
break;
case IAX_IE_CALLINGANI2:
if (len == (int)sizeof(unsigned int)) {
ies->calling_ani2 = ntohl(get_unaligned_uint32(data + 2));
} else {
snprintf(tmp, (int)sizeof(tmp), "callingani2 was %d long: %s\n", len, data + 2);
errorf(tmp);
}
break;
case IAX_IE_CALLINGTNS:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);

View File

@ -0,0 +1,4 @@
Subject: chan_iax2
ANI2 (OLI) is now transmitted over IAX2 calls
as an information element.