tnt has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26816 )
Change subject: mux_demux: Shuffle functions around for consistency ......................................................................
mux_demux: Shuffle functions around for consistency
No functional changes, just making things a bit more organized for the next patch adding an _e1_tx_raw.
The order after the patch is :
_e1_tx_hdlcfs _e1_ts_read _e1_line_mux_out_channelized _e1_line_mux_out_superchan e1_line_mux_out
_e1_rx_raw _e1_rx_hdlcfs _e1_ts_write _e1_line_demux_in_channelized _e1_line_demux_in_superchan _e1_line_demux_in_ts0 e1_line_demux_in
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I2ced3a5ba3cf3cc1f212d8f3e46cfefa15e4af0c --- M src/mux_demux.c 1 file changed, 52 insertions(+), 52 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/16/26816/1
diff --git a/src/mux_demux.c b/src/mux_demux.c index efd7ac8..6d854dd 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -45,37 +45,6 @@ // ---------------------------------------------------------------------------
static int -_e1_rx_hdlcfs(struct e1_ts *ts, const uint8_t *buf, int len) -{ - int rv, cl, oi; - - oi = 0; - - while (oi < len) { - rv = osmo_isdnhdlc_decode(&ts->hdlc.rx, - &buf[oi], len-oi, &cl, - 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->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) { - LOGPTS(ts, DXFR, LOGL_ERROR, "ERR RX: %d %d %d [ %s]\n", - rv,oi,cl, osmo_hexdump(buf, len)); - } - - oi += cl; - } - - return len; -} - -static int _e1_tx_hdlcfs(struct e1_ts *ts, uint8_t *buf, int len) { int rv, oo, cl; @@ -275,6 +244,37 @@ return appended; }
+static int +_e1_rx_hdlcfs(struct e1_ts *ts, const uint8_t *buf, int len) +{ + int rv, cl, oi; + + oi = 0; + + while (oi < len) { + rv = osmo_isdnhdlc_decode(&ts->hdlc.rx, + &buf[oi], len-oi, &cl, + 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->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) { + LOGPTS(ts, DXFR, LOGL_ERROR, "ERR RX: %d %d %d [ %s]\n", + rv,oi,cl, osmo_hexdump(buf, len)); + } + + oi += cl; + } + + return len; +} + /* write data to a timeslot (hardware -> application direction) */ static int _e1_ts_write(struct e1_ts *ts, const uint8_t *buf, size_t len) @@ -306,27 +306,6 @@ }
static int -_e1_line_demux_in_superchan(struct e1_line *line, const uint8_t *buf, int ftr) -{ - struct e1_ts *ts = &line->superchan; - uint8_t sc_buf[ftr*31]; - - OSMO_ASSERT(line->mode == E1_LINE_MODE_SUPERCHANNEL); - - if (ts->mode == E1_TS_MODE_OFF) - return 0; - - /* first gather input data from multiple frames*/ - for (int i = 0; i < ftr; i++) - memcpy(sc_buf + (i*31), buf + (i*32) + 1, 31); - - /* then dispatch to appropriate action */ - _e1_ts_write(ts, sc_buf, ftr*31); - - return 0; -} - -static int _e1_line_demux_in_channelized(struct e1_line *line, const uint8_t *buf, int ftr) { OSMO_ASSERT(line->mode == E1_LINE_MODE_CHANNELIZED); @@ -348,6 +327,27 @@ return 0; }
+static int +_e1_line_demux_in_superchan(struct e1_line *line, const uint8_t *buf, int ftr) +{ + struct e1_ts *ts = &line->superchan; + uint8_t sc_buf[ftr*31]; + + OSMO_ASSERT(line->mode == E1_LINE_MODE_SUPERCHANNEL); + + if (ts->mode == E1_TS_MODE_OFF) + return 0; + + /* first gather input data from multiple frames*/ + for (int i = 0; i < ftr; i++) + memcpy(sc_buf + (i*31), buf + (i*32) + 1, 31); + + /* then dispatch to appropriate action */ + _e1_ts_write(ts, sc_buf, ftr*31); + + return 0; +} + static void _e1_line_demux_in_ts0(struct e1_line *line, const uint8_t *buf, int ftr, uint8_t frame_base) {
Hello Jenkins Builder, laforge,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-e1d/+/26816
to look at the new patch set (#2).
Change subject: mux_demux: Shuffle functions around for consistency ......................................................................
mux_demux: Shuffle functions around for consistency
No functional changes, just making things a bit more organized for the next patch adding an _e1_tx_raw.
The order after the patch is :
_e1_tx_hdlcfs _e1_ts_read _e1_line_mux_out_channelized _e1_line_mux_out_superchan e1_line_mux_out
_e1_rx_raw _e1_rx_hdlcfs _e1_ts_write _e1_line_demux_in_channelized _e1_line_demux_in_superchan _e1_line_demux_in_ts0 e1_line_demux_in
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I2ced3a5ba3cf3cc1f212d8f3e46cfefa15e4af0c --- M src/mux_demux.c 1 file changed, 52 insertions(+), 52 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/16/26816/2
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26816 )
Change subject: mux_demux: Shuffle functions around for consistency ......................................................................
Patch Set 2: Code-Review+2
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/26816 )
Change subject: mux_demux: Shuffle functions around for consistency ......................................................................
mux_demux: Shuffle functions around for consistency
No functional changes, just making things a bit more organized for the next patch adding an _e1_tx_raw.
The order after the patch is :
_e1_tx_hdlcfs _e1_ts_read _e1_line_mux_out_channelized _e1_line_mux_out_superchan e1_line_mux_out
_e1_rx_raw _e1_rx_hdlcfs _e1_ts_write _e1_line_demux_in_channelized _e1_line_demux_in_superchan _e1_line_demux_in_ts0 e1_line_demux_in
Signed-off-by: Sylvain Munaut tnt@246tNt.com Change-Id: I2ced3a5ba3cf3cc1f212d8f3e46cfefa15e4af0c --- M src/mux_demux.c 1 file changed, 52 insertions(+), 52 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/src/mux_demux.c b/src/mux_demux.c index efd7ac8..7513d1e 100644 --- a/src/mux_demux.c +++ b/src/mux_demux.c @@ -45,37 +45,6 @@ // ---------------------------------------------------------------------------
static int -_e1_rx_hdlcfs(struct e1_ts *ts, const uint8_t *buf, int len) -{ - int rv, cl, oi; - - oi = 0; - - while (oi < len) { - rv = osmo_isdnhdlc_decode(&ts->hdlc.rx, - &buf[oi], len-oi, &cl, - 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->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) { - LOGPTS(ts, DXFR, LOGL_ERROR, "ERR RX: %d %d %d [ %s]\n", - rv,oi,cl, osmo_hexdump(buf, len)); - } - - oi += cl; - } - - return len; -} - -static int _e1_tx_hdlcfs(struct e1_ts *ts, uint8_t *buf, int len) { int rv, oo, cl; @@ -275,6 +244,37 @@ return appended; }
+static int +_e1_rx_hdlcfs(struct e1_ts *ts, const uint8_t *buf, int len) +{ + int rv, cl, oi; + + oi = 0; + + while (oi < len) { + rv = osmo_isdnhdlc_decode(&ts->hdlc.rx, + &buf[oi], len-oi, &cl, + 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->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) { + LOGPTS(ts, DXFR, LOGL_ERROR, "ERR RX: %d %d %d [ %s]\n", + rv, oi, cl, osmo_hexdump(buf, len)); + } + + oi += cl; + } + + return len; +} + /* write data to a timeslot (hardware -> application direction) */ static int _e1_ts_write(struct e1_ts *ts, const uint8_t *buf, size_t len) @@ -306,27 +306,6 @@ }
static int -_e1_line_demux_in_superchan(struct e1_line *line, const uint8_t *buf, int ftr) -{ - struct e1_ts *ts = &line->superchan; - uint8_t sc_buf[ftr*31]; - - OSMO_ASSERT(line->mode == E1_LINE_MODE_SUPERCHANNEL); - - if (ts->mode == E1_TS_MODE_OFF) - return 0; - - /* first gather input data from multiple frames*/ - for (int i = 0; i < ftr; i++) - memcpy(sc_buf + (i*31), buf + (i*32) + 1, 31); - - /* then dispatch to appropriate action */ - _e1_ts_write(ts, sc_buf, ftr*31); - - return 0; -} - -static int _e1_line_demux_in_channelized(struct e1_line *line, const uint8_t *buf, int ftr) { OSMO_ASSERT(line->mode == E1_LINE_MODE_CHANNELIZED); @@ -348,6 +327,27 @@ return 0; }
+static int +_e1_line_demux_in_superchan(struct e1_line *line, const uint8_t *buf, int ftr) +{ + struct e1_ts *ts = &line->superchan; + uint8_t sc_buf[ftr*31]; + + OSMO_ASSERT(line->mode == E1_LINE_MODE_SUPERCHANNEL); + + if (ts->mode == E1_TS_MODE_OFF) + return 0; + + /* first gather input data from multiple frames*/ + for (int i = 0; i < ftr; i++) + memcpy(sc_buf + (i*31), buf + (i*32) + 1, 31); + + /* then dispatch to appropriate action */ + _e1_ts_write(ts, sc_buf, ftr*31); + + return 0; +} + static void _e1_line_demux_in_ts0(struct e1_line *line, const uint8_t *buf, int ftr, uint8_t frame_base) {