fixeria submitted this change.

View Change

Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified
proxy: implement TRXC SETFORMAT

Change-Id: I9c453e7ba2a799a8c4ce037afef14037b596a29d
Related: OS#6672
---
M proxy/src/ctrl_cmd.c
1 file changed, 33 insertions(+), 0 deletions(-)

diff --git a/proxy/src/ctrl_cmd.c b/proxy/src/ctrl_cmd.c
index ca6ac7b..1f8c543 100644
--- a/proxy/src/ctrl_cmd.c
+++ b/proxy/src/ctrl_cmd.c
@@ -28,6 +28,7 @@

#include <osmocom/trx/ep.h>
#include <osmocom/trx/trxc.h>
+#include <osmocom/trx/trxd.h>

#include <osmocom/proxy/proxy.h>
#include <osmocom/proxy/trx.h>
@@ -184,6 +185,36 @@
trx->chans[chan].ts[ss.tn].valid = true;
}

+/* SETFORMAT negotiates the TRXD PDU version used on the data socket: the
+ * response status carries the version to use (the requested one, or our
+ * preferred version if out of range), not a plain ACK/NACK. */
+static void ctrl_cmd_setformat(struct proxy_trx *trx, unsigned int chan,
+ const struct osmo_trxc_msg *cmd, struct osmo_trxc_msg *rsp)
+{
+ int ver_req;
+
+ if (osmo_trxc_msg_params_scan(cmd, "%d", &ver_req) != 1 || ver_req < 0) {
+ LOGP_TRXCH(trx, chan, DTRXC, LOGL_ERROR,
+ "%s(): Failed to parse command arguments: '%s'\n",
+ __func__, osmo_trxc_msg_name(cmd));
+ /* -1 is the reserved status for "no suitable version" / malformed
+ * request (see trx_if.adoc); clear params, there is no valid
+ * <ver_req> to echo back. */
+ rsp->status = -1;
+ rsp->params[0] = '\0';
+ return;
+ }
+
+ if (ver_req > OSMO_TRXD_PDU_VER_MAX)
+ ver_req = OSMO_TRXD_PDU_VER_MAX;
+
+ osmo_trx_ep_set_pdu_ver(trx->ep, chan, ver_req);
+ rsp->status = ver_req;
+
+ LOGP_TRXCH(trx, chan, DTRXC, LOGL_INFO,
+ "TRXD header version set to %d\n", ver_req);
+}
+
/* FAKE_TOA/FAKE_RSSI/FAKE_CI: "<delta>" adjusts the current value by delta;
* "<value> <threshold>" sets an absolute value with a +/-threshold random
* jitter applied on every forwarded burst (see path_sim_apply()). */
@@ -340,6 +371,8 @@
ctrl_cmd_rfmute(trx, chan, cmd, &rsp);
} else if (!strcmp(cmd->cmd, OSMO_TRXC_CMD_SETSLOT)) {
ctrl_cmd_setslot(trx, chan, cmd, &rsp);
+ } else if (!strcmp(cmd->cmd, OSMO_TRXC_CMD_SETFORMAT)) {
+ ctrl_cmd_setformat(trx, chan, cmd, &rsp);
} else if (!strcmp(cmd->cmd, CTRL_CMD_SETTA)) {
ctrl_cmd_setta(trx, chan, cmd, &rsp);
} else if (!strcmp(cmd->cmd, CTRL_CMD_MEASURE)) {

To view, visit change 43610. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I9c453e7ba2a799a8c4ce037afef14037b596a29d
Gerrit-Change-Number: 43610
Gerrit-PatchSet: 6
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>