[Asterisk-code-review] chan_iax2: Add ANI2/OLI information element (asterisk[master])

George Joseph asteriskteam at digium.com
Thu Sep 2 14:17:12 CDT 2021


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16342 )

Change subject: chan_iax2: Add ANI2/OLI information element
......................................................................

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
---
M channels/chan_iax2.c
M channels/iax2/include/iax2.h
M channels/iax2/include/parser.h
M channels/iax2/parser.c
A doc/CHANGES-staging/chan_iax2_ani2.txt
5 files changed, 22 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index c57434b..e16577e 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -865,6 +865,7 @@
 	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 @@
 
 	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 @@
 		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 @@
 		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)
diff --git a/channels/iax2/include/iax2.h b/channels/iax2/include/iax2.h
index 3deb5db..a661858 100644
--- a/channels/iax2/include/iax2.h
+++ b/channels/iax2/include/iax2.h
@@ -187,6 +187,8 @@
 #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)
diff --git a/channels/iax2/include/parser.h b/channels/iax2/include/parser.h
index d8edc4b..cd64f35 100644
--- a/channels/iax2/include/parser.h
+++ b/channels/iax2/include/parser.h
@@ -32,6 +32,7 @@
 	int calling_ton;
 	int calling_tns;
 	int calling_pres;
+	int calling_ani2;
 	char *called_context;
 	char *username;
 	char *password;
diff --git a/channels/iax2/parser.c b/channels/iax2/parser.c
index 8683938..8a36f17 100644
--- a/channels/iax2/parser.c
+++ b/channels/iax2/parser.c
@@ -313,6 +313,7 @@
 	{ 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 @@
 	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 @@
 				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);
diff --git a/doc/CHANGES-staging/chan_iax2_ani2.txt b/doc/CHANGES-staging/chan_iax2_ani2.txt
new file mode 100644
index 0000000..37c6fa6
--- /dev/null
+++ b/doc/CHANGES-staging/chan_iax2_ani2.txt
@@ -0,0 +1,4 @@
+Subject: chan_iax2
+
+ANI2 (OLI) is now transmitted over IAX2 calls
+as an information element.

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16342
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Iaeacdf6ccde18eaff7f776a0f49fee87dcb549d2
Gerrit-Change-Number: 16342
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210902/b739fdce/attachment-0001.html>


More information about the asterisk-code-review mailing list