[Asterisk-code-review] chan_pjsip: Add ADSI support (asterisk[master])

N A asteriskteam at digium.com
Wed Dec 8 14:41:22 CST 2021


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


Change subject: chan_pjsip: Add ADSI support
......................................................................

chan_pjsip: Add ADSI support

Adds optional per-channel ADSI support to PJSIP.
ADSI remains disabled by default in PSJIP, so there
is no change in existing behavior.

ASTERISK-29789 #close

Change-Id: Id5a5a3e982d65a14ce55794d60a99f264492302f
---
M channels/chan_pjsip.c
M configs/samples/pjsip.conf.sample
A doc/CHANGES-staging/pjsip_adsi.txt
M include/asterisk/res_pjsip.h
M res/res_adsi.c
M res/res_pjsip.c
M res/res_pjsip/pjsip_configuration.c
7 files changed, 24 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/17642/1

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 3cbbc3b..2980fc2 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -630,7 +630,9 @@
 		ast_channel_rings_set(chan, 1);
 	}
 
-	ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
+	if (!session->endpoint->adsi) {
+		ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
+	}
 
 	ast_party_id_copy(&ast_channel_caller(chan)->id, &session->id);
 	ast_party_id_copy(&ast_channel_caller(chan)->ani, &session->id);
diff --git a/configs/samples/pjsip.conf.sample b/configs/samples/pjsip.conf.sample
index 2d57208..76f6766 100644
--- a/configs/samples/pjsip.conf.sample
+++ b/configs/samples/pjsip.conf.sample
@@ -950,6 +950,7 @@
                            ; sending OPTIONS requests and examining the
                            ; responses.
                            ; (default: no)
+;adsi=no  ; Whether ADSI support is enabled. res_adsi is required. (default: "no")
 
 ;==========================AUTH SECTION OPTIONS=========================
 ;[auth]
diff --git a/doc/CHANGES-staging/pjsip_adsi.txt b/doc/CHANGES-staging/pjsip_adsi.txt
new file mode 100644
index 0000000..f38a4fa
--- /dev/null
+++ b/doc/CHANGES-staging/pjsip_adsi.txt
@@ -0,0 +1,6 @@
+Subject: chan_pjsip
+
+ADSI support can now be optionally enabled by
+setting adsi=yes in an endpoint config. ADSI
+support remains disabled by default, so there
+is no change in existing behavior.
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 9c1594d..d3b1c0b 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -948,6 +948,8 @@
 	unsigned int stir_shaken;
 	/*! Should we authenticate OPTIONS requests per RFC 3261? */
 	unsigned int allow_unauthenticated_options;
+	/*! Whether ADSI is supported or not */
+	unsigned int adsi;
 };
 
 /*! URI parameter for symmetric transport */
diff --git a/res/res_adsi.c b/res/res_adsi.c
index f8a2f56..9fb8aed 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -237,6 +237,7 @@
 	if (ast_channel_adsicpe(chan) == AST_ADSI_UNAVAILABLE) {
 		/* Don't bother if we know they don't support ADSI */
 		errno = ENOSYS;
+		ast_verb(4, "ADSI not available for '%s'\n", ast_channel_name(chan));
 		return -1;
 	}
 
@@ -255,7 +256,7 @@
 			for (;;) {
 				if (((res = ast_waitfor(chan, waittime)) < 1)) {
 					/* Didn't get back DTMF A in time */
-					ast_debug(1, "No ADSI CPE detected (%d)\n", res);
+					ast_verb(4, "No ADSI CPE detected (%d)\n", res);
 					if (!ast_channel_adsicpe(chan)) {
 						ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
 					}
@@ -276,7 +277,7 @@
 						break;
 					} else {
 						if (f->subclass.integer == 'D') {
-							ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
+							ast_verb(4, "Off-hook capable CPE only, not ADSI\n");
 						} else {
 							ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass.integer);
 						}
@@ -291,7 +292,7 @@
 				ast_frfree(f);
 			}
 
-			ast_debug(1, "ADSI Compatible CPE Detected\n");
+			ast_verb(4, "ADSI Compatible CPE Detected\n");
 		} else {
 			ast_debug(1, "Already in data mode\n");
 		}
@@ -453,7 +454,7 @@
 	}
 	if (readformat) {
 		ast_set_read_format(chan, readformat);
-	}
+		}
 
 	if (!res) {
 		res = ast_safe_sleep(chan, 100 );
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 697767d..321fe1a 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1496,6 +1496,12 @@
 						responses.</para>
 					</description>
 				</configOption>
+				<configOption name="adsi" default="no">
+					<synopsis>Whether ADSI support is enabled</synopsis>
+					<description><para>
+						This option can be set to allow ADSI to be used.
+					</para></description>
+				</configOption>
 			</configObject>
 			<configObject name="auth">
 				<synopsis>Authentication type</synopsis>
diff --git a/res/res_pjsip/pjsip_configuration.c b/res/res_pjsip/pjsip_configuration.c
index f324bbb..b616f07 100644
--- a/res/res_pjsip/pjsip_configuration.c
+++ b/res/res_pjsip/pjsip_configuration.c
@@ -2193,6 +2193,7 @@
 		codec_prefs_handler, outgoing_answer_codec_prefs_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register_custom(sip_sorcery, "endpoint", "stir_shaken", "off", stir_shaken_handler, stir_shaken_to_str, NULL, 0, 0);
 	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "allow_unauthenticated_options", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, allow_unauthenticated_options));
+	ast_sorcery_object_field_register(sip_sorcery, "endpoint", "adsi", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_endpoint, adsi));
 
 	if (ast_sip_initialize_sorcery_transport()) {
 		ast_log(LOG_ERROR, "Failed to register SIP transport support with sorcery\n");

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Id5a5a3e982d65a14ce55794d60a99f264492302f
Gerrit-Change-Number: 17642
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/20211208/92a79a99/attachment.html>


More information about the asterisk-code-review mailing list