[Asterisk-code-review] res_pjsip_caller_id: Add ANI2/OLI parsing (asterisk[master])

N A asteriskteam at digium.com
Tue Jun 8 15:48:22 CDT 2021


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/16041 )


Change subject: res_pjsip_caller_id: Add ANI2/OLI parsing
......................................................................

res_pjsip_caller_id: Add ANI2/OLI parsing

Adds parsing of ANI II digits (Originating
Line Information) to PJSIP, on par with
what currently exists in chan_sip.

ASTERISK-29472

Change-Id: Ifc938a7a7d45ce33999ebf3656a542226f6d3847
---
M res/res_pjsip_caller_id.c
1 file changed, 40 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/16041/1

diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 0b16665..620c0f4 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -33,6 +33,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/module.h"
 #include "asterisk/callerid.h"
+#include "asterisk/conversions.h"
 
 /*!
  * \internal
@@ -121,6 +122,38 @@
 
 /*!
  * \internal
+ * \brief Set an ANI2 integer based on OLI data in a From header
+ *
+ * This uses the contents of a From header in order to set Originating Line information.
+ *
+ * \param rdata The incoming message
+ * \param ani2 The ANI2 field to set
+ * \retval 0 Successfully parsed From header
+ * \retval non-zero Could not parse From header
+ */
+static int set_id_from_oli(pjsip_rx_data *rdata, int *ani2)
+{
+	static const pj_str_t from = { "From", 4 };
+	static const pj_str_t oli_str1 = { "oli", 3 };
+	static const pj_str_t oli_str2 = { "isup-oli", 8 };
+	static const pj_str_t oli_str3 = { "ss7-oli", 7 };
+	const pjsip_param *oli1, *oli2, *oli3;
+	pjsip_fromto_hdr *from_hdr = get_id_header(rdata, &from);
+	if (!from_hdr) {
+		return -1;
+	}
+	if ((oli1 = pjsip_param_find(&from_hdr->other_param, &oli_str1))) {
+		return ast_str_to_int(oli1->value.ptr, ani2);
+	} else if ((oli2 = pjsip_param_find(&from_hdr->other_param, &oli_str2))) {
+		return ast_str_to_int(oli2->value.ptr, ani2);
+	} else if ((oli3 = pjsip_param_find(&from_hdr->other_param, &oli_str3))) {
+		return ast_str_to_int(oli3->value.ptr, ani2);
+	}
+	return 0;
+}
+
+/*!
+ * \internal
  * \brief Set an ast_party_id structure based on data in a P-Asserted-Identity header
  *
  * This makes use of \ref set_id_from_hdr for setting name and number. It uses
@@ -371,11 +404,18 @@
 static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
 {
 	if (!session->channel) {
+		struct ast_party_caller caller;
+		int ani2;
 		/*
 		 * Since we have no channel this must be the initial inbound
 		 * INVITE.  Set the session ID directly because the channel
 		 * has not been created yet.
 		 */
+		
+		if (!set_id_from_oli(rdata, &ani2)) {
+			ast_party_caller_init(&caller);
+			ast_channel_caller(session->channel)->ani2 = ani2;
+		}
 		if (session->endpoint->id.trust_inbound
 			&& (!set_id_from_pai(rdata, &session->id)
 				|| !set_id_from_rpid(rdata, &session->id))) {

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ifc938a7a7d45ce33999ebf3656a542226f6d3847
Gerrit-Change-Number: 16041
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210608/abe23cea/attachment.html>


More information about the asterisk-code-review mailing list