Change in osmo-e1d[master]: cosmetic: create HDLC specific sub-structure within e1_ts

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
Wed Jul 22 07:38:40 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/19344 )

Change subject: cosmetic: create HDLC specific sub-structure within e1_ts
......................................................................

cosmetic: create HDLC specific sub-structure within e1_ts

This groups all HDLC-specific members together, in preparation
of adding more fields for other modes.

Change-Id: Ide0577c25836252862153b4f24da550bee013687
---
M src/ctl.c
M src/e1d.h
M src/intf_line.c
3 files changed, 30 insertions(+), 28 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  tnt: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/ctl.c b/src/ctl.c
index 4e74485..697af01 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -150,8 +150,8 @@
 	ts->mode = mode;
 
 	if (mode == E1_TS_MODE_HDLCFCS) {
-		osmo_isdnhdlc_out_init(&ts->hdlc_tx, OSMO_HDLC_F_BITREVERSE);
-		osmo_isdnhdlc_rcv_init(&ts->hdlc_rx, OSMO_HDLC_F_BITREVERSE);
+		osmo_isdnhdlc_out_init(&ts->hdlc.tx, OSMO_HDLC_F_BITREVERSE);
+		osmo_isdnhdlc_rcv_init(&ts->hdlc.rx, OSMO_HDLC_F_BITREVERSE);
 	}
 
 	int flags = fcntl(ts->fd, F_GETFL);
diff --git a/src/e1d.h b/src/e1d.h
index fca7d3e..98c3ddc 100644
--- a/src/e1d.h
+++ b/src/e1d.h
@@ -43,13 +43,15 @@
 	enum e1_ts_mode mode;
 
 	/* HDLC handling */
-	struct osmo_isdnhdlc_vars hdlc_tx;
-	struct osmo_isdnhdlc_vars hdlc_rx;
+	struct {
+		struct osmo_isdnhdlc_vars tx;
+		struct osmo_isdnhdlc_vars rx;
 
-	uint8_t rx_buf[264];
-	uint8_t tx_buf[264];
-	int tx_ofs;
-	int tx_len;
+		uint8_t rx_buf[264];
+		uint8_t tx_buf[264];
+		int tx_ofs;
+		int tx_len;
+	} hdlc;
 
 	/* Remote end */
 	int fd;
diff --git a/src/intf_line.c b/src/intf_line.c
index af0d45d..6213151 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -157,16 +157,16 @@
 	oi = 0;
 
 	while (oi < len) {
-		rv = osmo_isdnhdlc_decode(&ts->hdlc_rx,
+		rv = osmo_isdnhdlc_decode(&ts->hdlc.rx,
 			&buf[oi], len-oi, &cl,
-			ts->rx_buf, sizeof(ts->rx_buf)
+			ts->hdlc.rx_buf, sizeof(ts->hdlc.rx_buf)
 		);
 
 		if (rv > 0) {
 			int bytes_to_write = rv;
 			LOGPTS(ts, DXFR, LOGL_DEBUG, "RX Message: %d [ %s]\n",
-				rv, osmo_hexdump(ts->rx_buf, rv));
-			rv = write(ts->fd, ts->rx_buf, bytes_to_write);
+				rv, osmo_hexdump(ts->hdlc.rx_buf, rv));
+			rv = write(ts->fd, ts->hdlc.rx_buf, bytes_to_write);
 			if (rv < 0)
 				return rv;
 		} else  if (rv < 0 && ts->id == 4) {
@@ -189,44 +189,44 @@
 
 	while (oo < len) {
 		/* Pending message ? */
-		if (!ts->tx_len) {
-			rv = recv(ts->fd, ts->tx_buf, sizeof(ts->tx_buf), MSG_TRUNC);
+		if (!ts->hdlc.tx_len) {
+			rv = recv(ts->fd, ts->hdlc.tx_buf, sizeof(ts->hdlc.tx_buf), MSG_TRUNC);
 			if (rv > 0) {
-				if (rv > sizeof(ts->tx_buf)) {
+				if (rv > sizeof(ts->hdlc.tx_buf)) {
 					LOGPTS(ts, DXFR, LOGL_ERROR, "Truncated message: Client tried to "
 						"send %d bytes but our buffer is limited to %lu\n",
-						rv, sizeof(ts->tx_buf));
-					rv = sizeof(ts->tx_buf);
+						rv, sizeof(ts->hdlc.tx_buf));
+					rv = sizeof(ts->hdlc.tx_buf);
 				}
 				LOGPTS(ts, DXFR, LOGL_DEBUG, "TX Message: %d [ %s]\n",
-					rv, osmo_hexdump(ts->tx_buf, rv));
-				ts->tx_len = rv; 
-				ts->tx_ofs = 0;
+					rv, osmo_hexdump(ts->hdlc.tx_buf, rv));
+				ts->hdlc.tx_len = rv; 
+				ts->hdlc.tx_ofs = 0;
 			} else if (rv < 0 && errno != EAGAIN)
 				return rv;
 		}
 
 		/* */
-		rv = osmo_isdnhdlc_encode(&ts->hdlc_tx,
-			&ts->tx_buf[ts->tx_ofs], ts->tx_len - ts->tx_ofs, &cl,
+		rv = osmo_isdnhdlc_encode(&ts->hdlc.tx,
+			&ts->hdlc.tx_buf[ts->hdlc.tx_ofs], ts->hdlc.tx_len - ts->hdlc.tx_ofs, &cl,
 			&buf[oo], len - oo
 		);
 
 		if (rv < 0)
 			LOGPTS(ts, DXFR, LOGL_ERROR, "ERR TX: %d\n", rv);
 
-		if (ts->tx_ofs < ts->tx_len) {
+		if (ts->hdlc.tx_ofs < ts->hdlc.tx_len) {
 			LOGPTS(ts, DXFR, LOGL_DEBUG, "TX chunk %d/%d %d [ %s]\n",
-				ts->tx_ofs, ts->tx_len, cl, osmo_hexdump(&buf[ts->tx_ofs], rv));
+				ts->hdlc.tx_ofs, ts->hdlc.tx_len, cl, osmo_hexdump(&buf[ts->hdlc.tx_ofs], rv));
 		}
 
 		if (rv > 0)
 			oo += rv;
 
-		ts->tx_ofs += cl;
-		if (ts->tx_ofs >= ts->tx_len) {
-			ts->tx_len = 0;
-			ts->tx_ofs = 0;
+		ts->hdlc.tx_ofs += cl;
+		if (ts->hdlc.tx_ofs >= ts->hdlc.tx_len) {
+			ts->hdlc.tx_len = 0;
+			ts->hdlc.tx_ofs = 0;
 		}
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/19344
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: Ide0577c25836252862153b4f24da550bee013687
Gerrit-Change-Number: 19344
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200722/04b1fd9b/attachment.htm>


More information about the gerrit-log mailing list