jolly has uploaded this change for review.
e1d: Add support for HDLC type channels
Change-Id: I2f4b9f7ed6430804ca511c7f5283a16bc13bc2fc
---
M src/input/e1d.c
1 file changed, 71 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/02/31502/1
diff --git a/src/input/e1d.c b/src/input/e1d.c
index 8e8d66f..f16e955 100644
--- a/src/input/e1d.c
+++ b/src/input/e1d.c
@@ -242,6 +242,62 @@
return ret;
}
+/* write to a hdlc channel TS */
+static int handle_ts_hdlc_write(struct osmo_fd *bfd)
+{
+ struct e1inp_line *line = bfd->data;
+ unsigned int ts_nr = bfd->priv_nr;
+ struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
+ struct msgb *msg;
+ int ret;
+
+ /* get the next msg for this timeslot */
+ msg = e1inp_tx_ts(e1i_ts, NULL);
+ if (!msg) {
+ osmo_fd_write_disable(bfd);
+ return 0;
+ }
+
+ LOGPITS(e1i_ts, DLMIB, LOGL_DEBUG, "HDLC CHAN TX: %s\n", osmo_hexdump(msg->data, msg->len));
+
+ ret = write(bfd->fd, msg->data, msg->len);
+ if (ret < msg->len)
+ LOGPITS(e1i_ts, DLINP, LOGL_NOTICE, "send returns %d instead of %d\n", ret, msg->len);
+ msgb_free(msg);
+
+ return ret;
+}
+
+#define TSX_ALLOC_SIZE 4096
+
+/* read from a hdlc channel TS */
+static int handle_ts_hdlc_read(struct osmo_fd *bfd)
+{
+ struct e1inp_line *line = bfd->data;
+ unsigned int ts_nr = bfd->priv_nr;
+ struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
+ struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE, "E1D HDLC TS");
+ int ret;
+
+ if (!msg)
+ return -ENOMEM;
+
+ ret = read(bfd->fd, msg->data, TSX_ALLOC_SIZE);
+ if (ret < 0) {
+ LOGPITS(e1i_ts, DLINP, LOGL_NOTICE, "read error %d %s\n", ret, strerror(errno));
+ msgb_free(msg);
+ return ret;
+ }
+
+ msgb_put(msg, ret);
+
+ msg->l2h = msg->data;
+ LOGPITS(e1i_ts, DLMIB, LOGL_DEBUG, "HDLC CHAN RX: %s\n", msgb_hexdump_l2(msg));
+ ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
+
+ return ret;
+}
+
static void
e1d_write_msg(struct msgb *msg, void *cbdata)
{
@@ -283,6 +339,12 @@
if (what & OSMO_FD_WRITE)
ret = handle_ts_raw_write(bfd);
break;
+ case E1INP_TS_TYPE_HDLC:
+ if (what & OSMO_FD_READ)
+ ret = handle_ts_hdlc_read(bfd);
+ if (what & OSMO_FD_WRITE)
+ ret = handle_ts_hdlc_write(bfd);
+ break;
default:
LOGPITS(e1i_ts, DLINP, LOGL_NOTICE, "unknown/unsupported E1 TS type %u\n", e1i_ts->type);
break;
To view, visit change 31502. To unsubscribe, or for help writing mail filters, visit settings.