diff options
author | Harald Welte <laforge@osmocom.org> | 2020-07-11 10:49:19 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2020-07-11 13:21:14 +0200 |
commit | 73f248fd74661ffc2412629a59c7bb85cdb1c496 (patch) | |
tree | 90168421417b11a175ef30e260b271f47c066c3a | |
parent | 9fbd4e819e3a22b29dedc0033c9193cf63ccef9b (diff) |
Use SOCK_STREAM sockets for E1_TS_MODE_RAW
SEQPACKET is great for preserving message boundaries on signaling
channels that use HDLC. However, its semantics, particularly regarding
truncation, are sub-optimal for RAW slots containing raw user
bitstreams (typically TRAU frames or PCM audio data).
So let's use SOCK_STREAM for RAW and keep SEQPACKET for HDLCFCS.
Closes: OS#4663
Change-Id: I1767ceaa5d2a008db0009b8027667a71c0fdc0f1
-rw-r--r-- | src/ctl.c | 15 | ||||
-rw-r--r-- | src/intf_line.c | 7 |
2 files changed, 15 insertions, 7 deletions
@@ -25,6 +25,7 @@ #include <fcntl.h> #include <unistd.h> #include <string.h> +#include <errno.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> @@ -110,10 +111,22 @@ static int _e1d_ts_start(struct e1_ts *ts, enum e1_ts_mode mode) { int ret, sd[2]; + int sock_type; LOGPTS(ts, DE1D, LOGL_INFO, "Starting in mode %s\n", get_value_string(e1_ts_mode_names, mode)); - ret = socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sd); + switch (mode) { + case E1_TS_MODE_HDLCFCS: + sock_type = SOCK_SEQPACKET; + break; + case E1_TS_MODE_RAW: + sock_type = SOCK_STREAM; + break; + default: + return -EINVAL; + } + + ret = socketpair(AF_UNIX, sock_type, 0, sd); if (ret < 0) return ret; diff --git a/src/intf_line.c b/src/intf_line.c index fe9edbb..5994805 100644 --- a/src/intf_line.c +++ b/src/intf_line.c @@ -251,12 +251,7 @@ e1_line_mux_out(struct e1_line *line, uint8_t *buf, int fts) switch (ts->mode) { case E1_TS_MODE_RAW: - l = recv(ts->fd, buf_ts, fts, MSG_TRUNC); - if (l > fts) { - LOGPTS(ts, DXFR, LOGL_ERROR, "Truncated message: Client tried to " - "send %d bytes but our buffer is limited to %d\n", l, fts); - l = fts; - } + l = read(ts->fd, buf_ts, fts); break; case E1_TS_MODE_HDLCFCS: l = _e1_tx_hdlcfs(ts, buf_ts, fts); |