Change in libosmo-abis[master]: WIP: unixsocket: Add support for TRAU frames

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/.

laforge gerrit-no-reply at lists.osmocom.org
Thu May 14 11:33:06 UTC 2020


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


Change subject: WIP: unixsocket: Add support for TRAU frames
......................................................................

WIP: unixsocket: Add support for TRAU frames

Change-Id: I4baa02f061cc05c8364dc7169cd9b70f07b0615a
---
M include/osmocom/abis/unixsocket_proto.h
M src/input/unixsocket.c
2 files changed, 52 insertions(+), 18 deletions(-)



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

diff --git a/include/osmocom/abis/unixsocket_proto.h b/include/osmocom/abis/unixsocket_proto.h
index 25718ff..08e511e 100644
--- a/include/osmocom/abis/unixsocket_proto.h
+++ b/include/osmocom/abis/unixsocket_proto.h
@@ -11,6 +11,7 @@
  *
  * data:    | 0x1 | 0x0 | lapd ..|
  * control: | 0x1 | 0x1 | control payload |
+ * traffic: | 0x1 | 0x2 | timeslot | rae E1 bitstream data |
  *
  * Atm there is only one control packet:
  *  - set_altc (superchannel or timeslot)
@@ -26,6 +27,7 @@
 enum {
 	UNIXSOCKET_PROTO_DATA = 0x0,
 	UNIXSOCKET_PROTO_CONTROL = 0x1,
+	UNIXSOCKET_PROTO_TRAFFIC = 0x2,
 };
 
 #endif /* UNIXSOCKET_PROTO_H */
diff --git a/src/input/unixsocket.c b/src/input/unixsocket.c
index cfb4979..c99b801 100644
--- a/src/input/unixsocket.c
+++ b/src/input/unixsocket.c
@@ -80,6 +80,7 @@
 {
 	struct e1inp_line *line = bfd->data;
 	struct msgb *msg = msgb_alloc(UNIXSOCKET_ALLOC_SIZE, "UNIXSOCKET TS");
+	uint8_t ts_nr;
 	uint8_t version;
 	uint8_t controldata;
 	int ret;
@@ -117,11 +118,19 @@
 
 	switch (controldata) {
 	case UNIXSOCKET_PROTO_DATA:
+		/* FIXME: don't blindly assume TS0 is the signaling slot */
 		return e1inp_rx_ts_lapd(&line->ts[0], msg);
 	case UNIXSOCKET_PROTO_CONTROL:
 		LOGPIL(line, DLMI, LOGL_ERROR, "received (invalid) control message.");
 		ret = -1;
 		break;
+	case UNIXSOCKET_PROTO_TRAFFIC:
+		ts_nr = msgb_pull_u8(msg);
+		if (ts_nr >= line->num_ts) {
+			ret = -1;
+		} else
+			return e1inp_rx_ts(&line->ts[ts_nr], msg, 0, 0);
+		break;
 	default:
 		LOGPIL(line, DLMI, LOGL_ERROR, "received invalid message.");
 		ret = -1;
@@ -143,29 +152,52 @@
 static int unixsocket_write_cb(struct osmo_fd *bfd)
 {
 	struct e1inp_line *line = bfd->data;
-	struct e1inp_ts *e1i_ts = &line->ts[0];
-	struct msgb *msg;
-	struct e1inp_sign_link *sign_link;
+	int i;
 
 	bfd->when &= ~BSC_FD_WRITE;
 
-	/* get the next msg for this timeslot */
-	msg = e1inp_tx_ts(e1i_ts, &sign_link);
-	if (!msg) {
-		/* no message after tx delay timer */
-		LOGPITS(e1i_ts, DLINP, LOGL_INFO, "no message available (line=%p)\n", line);
-		return 0;
+	for (i = 0; i < line->num_ts; i++) {
+		struct e1inp_ts *e1i_ts = &line->ts[i];
+		struct e1inp_sign_link *sign_link;
+		struct msgb *msg;
+		int rc;
+
+		/* get the next msg for this timeslot */
+		msg = e1inp_tx_ts(e1i_ts, &sign_link);
+		if (!msg) {
+			/* no message after tx delay timer */
+			LOGPITS(e1i_ts, DLINP, LOGL_INFO, "no message available (line=%p)\n", line);
+			continue;
+		}
+
+		LOGPITS(e1i_ts, DLINP, LOGL_DEBUG, "sending: %s (line=%p)\n", msgb_hexdump(msg), line);
+		switch (e1i_ts->type) {
+		case E1INP_TS_TYPE_SIGN:
+			lapd_transmit(e1i_ts->lapd, sign_link->tei, sign_link->sapi, msg);
+			/* set tx delay timer for next event */
+			osmo_timer_setup(&e1i_ts->sign.tx_timer, timeout_ts1_write, e1i_ts);
+			osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
+			break;
+		case E1INP_TS_TYPE_RAW:
+			msgb_push_u8(msg, i); /* timeslot number */
+			msgb_push_u8(msg, UNIXSOCKET_PROTO_TRAFFIC);
+			msgb_push_u8(msg, UNIXSOCKET_PROTO_VERSION);
+			rc = write(bfd->fd, msg->data, msg->len);
+			if (rc < msg->len) {
+				LOGPITS(e1i_ts, DLINP, LOGL_ERROR, "write returne d%d instead of %d\n",
+					rc, msg->len);
+				msgb_free(msg);
+				return 0;
+			}
+			msgb_free(msg);
+			break;
+		default:
+			LOGPITS(e1i_ts, DLINP, LOGL_ERROR, "unsupported timeslot type %s\n",
+				e1inp_tstype_name(e1i_ts->type));
+			break;
+		}
 	}
 
-	/* set tx delay timer for next event */
-	osmo_timer_setup(&e1i_ts->sign.tx_timer, timeout_ts1_write, e1i_ts);
-
-	osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
-
-	LOGPITS(e1i_ts, DLINP, LOGL_DEBUG, "sending: %s (line=%p)\n", msgb_hexdump(msg), line);
-	lapd_transmit(e1i_ts->lapd, sign_link->tei,
-			sign_link->sapi, msg);
-
 	return 0;
 }
 

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

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I4baa02f061cc05c8364dc7169cd9b70f07b0615a
Gerrit-Change-Number: 18248
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200514/49b8ece5/attachment.htm>


More information about the gerrit-log mailing list