Skip to content

Commit 3072c54

Browse files
InterLinked1gtjoseph
authored andcommitted
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
1 parent bbf4f30 commit 3072c54

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

channels/chan_iax2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ struct chan_iax2_pvt {
865865
int calling_ton;
866866
int calling_tns;
867867
int calling_pres;
868+
int calling_ani2;
868869
int amaflags;
869870
AST_LIST_HEAD_NOLOCK(, iax2_dpcache) dpentries;
870871
/*! variables inherited from the user definition */
@@ -5181,6 +5182,7 @@ static int iax2_call(struct ast_channel *c, const char *dest, int timeout)
51815182

51825183
iax_ie_append_byte(&ied, IAX_IE_CALLINGTON, ast_channel_connected(c)->id.number.plan);
51835184
iax_ie_append_short(&ied, IAX_IE_CALLINGTNS, ast_channel_dialed(c)->transit_network_select);
5185+
iax_ie_append_int(&ied, IAX_IE_CALLINGANI2, ast_channel_connected(c)->ani2);
51845186

51855187
if (n)
51865188
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
59415943
ast_channel_redirecting(tmp)->from.number.valid = 1;
59425944
ast_channel_redirecting(tmp)->from.number.str = ast_strdup(i->rdnis);
59435945
}
5946+
ast_channel_caller(tmp)->ani2 = i->calling_ani2;
59445947
ast_channel_caller(tmp)->id.name.presentation = i->calling_pres;
59455948
ast_channel_caller(tmp)->id.number.presentation = i->calling_pres;
59465949
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
78317834
iaxs[callno]->calling_tns = ies->calling_tns;
78327835
if (ies->calling_pres > -1)
78337836
iaxs[callno]->calling_pres = ies->calling_pres;
7837+
if (ies->calling_ani2 > -1)
7838+
iaxs[callno]->calling_ani2 = ies->calling_ani2;
78347839
if (ies->format)
78357840
iaxs[callno]->peerformat = ies->format;
78367841
if (ies->adsicpe)

channels/iax2/include/iax2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ enum iax_frame_subclass {
187187
#define IAX_IE_CAPABILITY2 55 /*!< Actual codec capability - u8 version + integer array */
188188
#define IAX_IE_FORMAT2 56 /*!< Desired codec format - u8 version + integer array */
189189

190+
#define IAX_IE_CALLINGANI2 57 /*!< Calling Originating Line Information (ANI2) digits */
191+
190192
#define IAX_MAX_OSPBLOCK_SIZE 254 /*!< Max OSP token block size, 255 bytes - 1 byte OSP token block index */
191193
#define IAX_MAX_OSPBLOCK_NUM 4
192194
#define IAX_MAX_OSPTOKEN_SIZE (IAX_MAX_OSPBLOCK_SIZE * IAX_MAX_OSPBLOCK_NUM)

channels/iax2/include/parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct iax_ies {
3232
int calling_ton;
3333
int calling_tns;
3434
int calling_pres;
35+
int calling_ani2;
3536
char *called_context;
3637
char *username;
3738
char *password;

channels/iax2/parser.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static struct iax2_ie infoelts[] = {
313313
{ IAX_IE_CALLINGPRES, "CALLING PRESNTN", dump_byte },
314314
{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
315315
{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
316+
{ IAX_IE_CALLINGANI2, "CALLING ANI2", dump_int },
316317
{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
317318
{ IAX_IE_CAUSECODE, "CAUSE CODE", dump_byte },
318319
{ IAX_IE_ENCRYPTION, "ENCRYPTION", dump_short },
@@ -805,6 +806,7 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
805806
ies->calling_ton = -1;
806807
ies->calling_tns = -1;
807808
ies->calling_pres = -1;
809+
ies->calling_ani2 = -1;
808810
ies->samprate = IAX_RATE_8KHZ;
809811
while(datalen >= 2) {
810812
ie = data[0];
@@ -1057,6 +1059,14 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
10571059
errorf(tmp);
10581060
}
10591061
break;
1062+
case IAX_IE_CALLINGANI2:
1063+
if (len == (int)sizeof(unsigned int)) {
1064+
ies->calling_ani2 = ntohl(get_unaligned_uint32(data + 2));
1065+
} else {
1066+
snprintf(tmp, (int)sizeof(tmp), "callingani2 was %d long: %s\n", len, data + 2);
1067+
errorf(tmp);
1068+
}
1069+
break;
10601070
case IAX_IE_CALLINGTNS:
10611071
if (len != (int)sizeof(unsigned short)) {
10621072
snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Subject: chan_iax2
2+
3+
ANI2 (OLI) is now transmitted over IAX2 calls
4+
as an information element.

0 commit comments

Comments
 (0)