Change in libosmo-abis[master]: Add vty show function for e1d driver

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

keith gerrit-no-reply at lists.osmocom.org
Mon May 10 22:39:36 UTC 2021


keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/24197 )


Change subject: Add vty show function for e1d driver
......................................................................

Add vty show function for e1d driver

Each Driver has a vty show function, this commit adds the
function and uses it to query the e1d daemon for timeslot
status.

TS status is then displayed in the application that is making
use of libosmo-abis. This might be useful for debugging, for example,
to ensure that the application has the same state as the osmo-e1d
itself.

Change-Id: I287c82b2c9e4b9b9b30a302e5240d5688b93240c
---
M src/input/e1d.c
1 file changed, 52 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/97/24197/1

diff --git a/src/input/e1d.c b/src/input/e1d.c
index cab219d..5936e68 100644
--- a/src/input/e1d.c
+++ b/src/input/e1d.c
@@ -321,11 +321,22 @@
 	return 0;
 }
 
+static int e1d_daemon_connect(struct e1inp_line *line) {
+	/* Connect to daemon */
+	g_e1d = osmo_e1dp_client_create(NULL, "/tmp/osmo-e1d.ctl");
+	if (!g_e1d) {
+		LOGPIL(line, DLINP, LOGL_ERROR, "Unable to connect to osmo-e1d daemon\n");
+		return -EPIPE;
+	}
+	return 0;
+}
+
 static int
 e1d_line_update(struct e1inp_line *line)
 {
 	int ts;
 	int ret;
+	int rc;
 
 	/* we use higher 4 bits for interface, lower 4 bits for line,
 	 * resulting in max. 16 interfaces with 16 lines each */
@@ -338,12 +349,9 @@
 		return -EINVAL;
 
 	if (!g_e1d) {
-		/* Connect to daemon */
-		g_e1d = osmo_e1dp_client_create(NULL, "/tmp/osmo-e1d.ctl");
-		if (!g_e1d) {
-			LOGPIL(line, DLINP, LOGL_ERROR, "Unable to connect to osmo-e1d daemon\n");
-			return -EPIPE;
-		}
+		rc = e1d_daemon_connect(line);
+		if (rc)
+			return rc;
 	}
 
 	LOGPIL(line, DLINP, LOGL_NOTICE, "Line update %d %d=E1D(%d:%d) %d\n", line->num, line->port_nr,
@@ -468,10 +476,48 @@
 	return 0;
 }
 
+const struct value_string osmo_e1dp_ts_mode_names[] = {
+	{ E1DP_TSMODE_OFF,	"OFF" },
+	{ E1DP_TSMODE_RAW,	"RAW" },
+	{ E1DP_TSMODE_HDLCFCS,	"HDLC-FCS" },
+	{ 0, NULL }
+};
+
+static void e1d_vty_show(struct vty *vty, struct e1inp_line *line)
+{
+	int ts;
+	int ret;
+	uint8_t e1d_intf = (line->port_nr >> 4) & 0xF;
+	uint8_t e1d_line = line->port_nr & 0xF;
+	struct osmo_e1dp_ts_info *ts_info;
+	int num_ts_info;
+
+	if (!g_e1d) {
+		if (e1d_daemon_connect(line))
+			return;
+	}
+
+	ret = osmo_e1dp_client_ts_query(g_e1d, &ts_info, &num_ts_info, e1d_intf, e1d_line, E1DP_INVALID);
+
+	if (ret < 0) {
+		LOGPIL(line, DLINP, LOGL_ERROR, "Cannot query E1D for timeslot information: %d\n", ret);
+		return;
+	}
+
+	for (ts=1; ts<line->num_ts; ts++) {
+		struct e1inp_ts *e1i_ts = &line->ts[ts-1];
+		struct osmo_fd *bfd = &e1i_ts->driver.e1d.fd;
+		vty_out(vty, " TS%02u: Mode %s, FD %d%s",
+			ts, get_value_string(osmo_e1dp_ts_mode_names, ts_info[ts].cfg.mode),
+			bfd->fd, VTY_NEWLINE);
+	}
+}
+
 struct e1inp_driver e1d_driver = {
 	.name        = "e1d",
 	.want_write  = e1d_want_write,
 	.line_update = e1d_line_update,
+	.vty_show    = &e1d_vty_show,
 };
 
 int

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/24197
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I287c82b2c9e4b9b9b30a302e5240d5688b93240c
Gerrit-Change-Number: 24197
Gerrit-PatchSet: 1
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210510/1da4a238/attachment.htm>


More information about the gerrit-log mailing list