[Asterisk-code-review] chan_dahdi: Add logical group at DAHDIChannel event and CHANNEL function (...asterisk[13])

Cirillo Ferreira asteriskteam at digium.com
Tue Mar 5 08:29:49 CST 2019


Cirillo Ferreira has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/11097


Change subject: chan_dahdi: Add logical group at DAHDIChannel event and CHANNEL function
......................................................................

chan_dahdi: Add logical group at DAHDIChannel event and CHANNEL function

Add logical group at DAHDIChannel event
and create "dahdi_group" at CHANNEL function.

ASTERISK-28317

Change-Id: Ic1f834cd53982a9707a9748395ee746d6575086a
---
M channels/chan_dahdi.c
1 file changed, 18 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/97/11097/1

diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index c40e084..0ef850b 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -189,6 +189,9 @@
 			<enum name="dahdi_span">
 				<para>R/O DAHDI span related to this channel.</para>
 			</enum>
+			<enum name="dahdi_group">
+				<para>R/O DAHDI logical group related to this channel.</para>
+			</enum>
 			<enum name="dahdi_type">
 				<para>R/O DAHDI channel type, one of:</para>
 				<enumlist>
@@ -466,6 +469,9 @@
 			<synopsis>Raised when a DAHDI channel is created or an underlying technology is associated with a DAHDI channel.</synopsis>
 			<syntax>
 				<channel_snapshot/>
+				<parameter name="DAHDIGroup">
+					<para>The DAHDI logical group associated with this channel.</para>
+				</parameter>
 				<parameter name="DAHDISpan">
 					<para>The DAHDI span associated with this channel.</para>
 				</parameter>
@@ -1810,21 +1816,24 @@
 {
 	RAII_VAR(struct ast_str *, channel_string, NULL, ast_free);
 	struct ast_channel_blob *obj = stasis_message_data(msg);
-	struct ast_json *span, *channel;
+	struct ast_json *group, *span, *channel;
 
 	channel_string = ast_manager_build_channel_state_string(obj->snapshot);
 	if (!channel_string) {
 		return NULL;
 	}
 
+	group = ast_json_object_get(obj->blob, "group");
 	span = ast_json_object_get(obj->blob, "span");
 	channel = ast_json_object_get(obj->blob, "channel");
 
 	return ast_manager_event_blob_create(EVENT_FLAG_CALL, "DAHDIChannel",
 		"%s"
+		"DAHDIGroup: %ull\r\n"
 		"DAHDISpan: %u\r\n"
 		"DAHDIChannel: %s\r\n",
 		ast_str_buffer(channel_string),
+		(ast_group_t)ast_json_integer_get(group),
 		(unsigned int)ast_json_integer_get(span),
 		ast_json_string_get(channel));
 }
@@ -1834,13 +1843,14 @@
 	);
 
 /*! \brief Sends a DAHDIChannel channel blob used to produce DAHDIChannel AMI messages */
-static void publish_dahdichannel(struct ast_channel *chan, int span, const char *dahdi_channel)
+static void publish_dahdichannel(struct ast_channel *chan, ast_group_t group, int span, const char *dahdi_channel)
 {
 	RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
 
 	ast_assert(dahdi_channel != NULL);
 
-	blob = ast_json_pack("{s: i, s: s}",
+	blob = ast_json_pack("{s: i, s: i, s: s}",
+		"group", group,
 		"span", span,
 		"channel", dahdi_channel);
 	if (!blob) {
@@ -1876,7 +1886,7 @@
 		/* Real channel */
 		snprintf(ch_name, sizeof(ch_name), "%d", p->channel);
 	}
-	publish_dahdichannel(chan, p->span, ch_name);
+	publish_dahdichannel(chan, p->group, p->span, ch_name);
 }
 
 #ifdef HAVE_PRI
@@ -6759,6 +6769,10 @@
 		ast_mutex_lock(&p->lock);
 		snprintf(buf, len, "%d", p->span);
 		ast_mutex_unlock(&p->lock);
+	} else if (!strcasecmp(data, "dahdi_group")) {
+		ast_mutex_lock(&p->lock);
+		snprintf(buf, len, "%ull", p->group);
+		ast_mutex_unlock(&p->lock);
 	} else if (!strcasecmp(data, "dahdi_type")) {
 		ast_mutex_lock(&p->lock);
 		switch (p->sig) {

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Ic1f834cd53982a9707a9748395ee746d6575086a
Gerrit-Change-Number: 11097
Gerrit-PatchSet: 1
Gerrit-Owner: Cirillo Ferreira <cirillor at lbv.org.br>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190305/d6b5fc8f/attachment.html>


More information about the asterisk-code-review mailing list