Skip to content

Commit

Permalink
chan_iax2: Add ANI2/OLI information element
Browse files Browse the repository at this point in the history
Adds an information element for ANI2 so that
Originating Line Information can be transmitted
over IAX2 channels.

ASTERISK-29605 #close

Change-Id: Iaeacdf6ccde18eaff7f776a0f49fee87dcb549d2
  • Loading branch information
InterLinked1 authored and gtjoseph committed Sep 2, 2021
1 parent bbf4f30 commit 3072c54
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions channels/chan_iax2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions channels/iax2/include/iax2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions channels/iax2/include/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions channels/iax2/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions doc/CHANGES-staging/chan_iax2_ani2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Subject: chan_iax2

ANI2 (OLI) is now transmitted over IAX2 calls
as an information element.

0 comments on commit 3072c54

Please sign in to comment.