aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2020-07-14 13:10:26 +0200
committerlaforge <laforge@osmocom.org>2020-07-15 10:26:15 +0000
commit5d5e47ff3b05f32a3d30d201c6bc7dc57fc9307f (patch)
tree016c0872991a538ae81f0842fe2d58b018930148
parent17c80e1f557784c2a431f441ecdc772c9c30346c (diff)
Add new E1DP_CMD_LINE_CONFIG for switching channelized/superchannel
This adds the related code to the server and client side of the CTL interface to switch a line between CHANNELIZED and SUPERCHANNEL. Change-Id: I765b5c3bc9e07b2353f8647e8260ff95df3727e6
-rw-r--r--include/osmocom/e1d/proto.h19
-rw-r--r--include/osmocom/e1d/proto_clnt.h2
-rw-r--r--src/ctl.c64
-rw-r--r--src/proto.c6
-rw-r--r--src/proto_clnt.c31
5 files changed, 122 insertions, 0 deletions
diff --git a/include/osmocom/e1d/proto.h b/include/osmocom/e1d/proto.h
index 6711332..d8bce1f 100644
--- a/include/osmocom/e1d/proto.h
+++ b/include/osmocom/e1d/proto.h
@@ -2,6 +2,7 @@
* proto.h
*
* (C) 2019 by Sylvain Munaut <tnt@246tNt.com>
+ * (C) 2020 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -44,6 +45,11 @@
* in: n/a
* out: array of osmo_e1dp_ts_info
*
+ * E1DP_CMD_LINE_CONFIG
+ * filter: intf (required), line (required)
+ * in: osmo_e1dp_line_config
+ * out: osmo_e1dp_line_info
+ *
* E1DP_CMD_TS_OPEN
* filter: intf (required), line (required), ts (required)
* in: osmo_e1dp_ts_config
@@ -55,6 +61,7 @@ enum osmo_e1dp_msg_type {
E1DP_CMD_INTF_QUERY = 0x00,
E1DP_CMD_LINE_QUERY = 0x01,
E1DP_CMD_TS_QUERY = 0x02,
+ E1DP_CMD_LINE_CONFIG = 0x03,
E1DP_CMD_TS_OPEN = 0x04,
E1DP_EVT_TYPE = 0x40,
E1DP_RESP_TYPE = 0x80,
@@ -62,6 +69,12 @@ enum osmo_e1dp_msg_type {
E1DP_TYPE_MSK = 0xc0,
};
+enum osmo_e1dp_line_mode {
+ E1DP_LMODE_OFF = 0x00,
+ E1DP_LMODE_CHANNELIZED = 0x20,
+ E1DP_LMODE_SUPERCHANNEL = 0x21,
+};
+
enum osmo_e1dp_ts_mode {
E1DP_TSMODE_OFF = 0x00,
E1DP_TSMODE_RAW = 0x10,
@@ -91,8 +104,13 @@ struct osmo_e1dp_intf_info {
uint8_t n_lines;
} __attribute__((packed));
+struct osmo_e1dp_line_config {
+ uint8_t mode;
+} __attribute__((packed));
+
struct osmo_e1dp_line_info {
uint8_t id;
+ struct osmo_e1dp_line_config cfg;
uint8_t status; /* TBD */
} __attribute__((packed));
@@ -111,4 +129,5 @@ struct msgb *osmo_e1dp_recv(struct osmo_fd *ofd, int *fd);
int osmo_e1dp_send(struct osmo_fd *ofd, struct msgb *msgb, int fd);
extern const struct value_string osmo_e1dp_msg_type_names[];
+extern const struct value_string osmo_e1dp_line_mode_names[];
extern const struct value_string osmo_e1dp_ts_mode_names[];
diff --git a/include/osmocom/e1d/proto_clnt.h b/include/osmocom/e1d/proto_clnt.h
index 0914de7..ff2cebf 100644
--- a/include/osmocom/e1d/proto_clnt.h
+++ b/include/osmocom/e1d/proto_clnt.h
@@ -41,6 +41,8 @@ int osmo_e1dp_client_line_query(struct osmo_e1dp_client *clnt,
int osmo_e1dp_client_ts_query(struct osmo_e1dp_client *clnt,
struct osmo_e1dp_ts_info **ti, int *n,
uint8_t intf, uint8_t line, uint8_t ts);
+int osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
+ uint8_t intf, uint8_t line, enum osmo_e1dp_line_mode mode);
int osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
uint8_t intf, uint8_t line, uint8_t ts,
enum osmo_e1dp_ts_mode mode);
diff --git a/src/ctl.c b/src/ctl.c
index 5322ab4..4e74485 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -2,6 +2,7 @@
* ctl.c
*
* (C) 2019 by Sylvain Munaut <tnt@246tNt.com>
+ * (C) 2020 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -87,6 +88,16 @@ static void
_e1d_fill_line_info(struct osmo_e1dp_line_info *li, struct e1_line *line)
{
li->id = line->id;
+ switch (line->mode) {
+ case E1_LINE_MODE_CHANNELIZED:
+ li->cfg.mode = E1DP_LMODE_CHANNELIZED;
+ break;
+ case E1_LINE_MODE_SUPERCHANNEL:
+ li->cfg.mode = E1DP_LMODE_SUPERCHANNEL;
+ break;
+ default:
+ OSMO_ASSERT(0);
+ }
li->status = 0x00;
}
@@ -273,6 +284,53 @@ _e1d_ctl_ts_query(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
}
static int
+_e1d_ctl_line_config(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
+{
+ struct e1_daemon *e1d = (struct e1_daemon *)data;
+ struct osmo_e1dp_msg_hdr *hdr = msgb_l1(msgb);
+ struct osmo_e1dp_line_config *cfg = msgb_l2(msgb);
+ struct osmo_e1dp_line_info *info;
+ struct e1_intf *intf = NULL;
+ struct e1_line *line = NULL;
+
+ /* Process query and find timeslot */
+ intf = e1d_find_intf(e1d, hdr->intf);
+ if (!intf)
+ return 0;
+
+ line = e1_intf_find_line(intf, hdr->line);
+ if (!line)
+ return 0;
+
+ LOGPLI(line, DE1D, LOGL_NOTICE, "Setting line mode from %s to %s\n",
+ get_value_string(e1_line_mode_names, line->mode),
+ get_value_string(osmo_e1dp_line_mode_names, cfg->mode));
+ /* Select mode */
+ switch (cfg->mode) {
+ case E1DP_LMODE_CHANNELIZED:
+ line->mode = E1_LINE_MODE_CHANNELIZED;
+ break;
+ case E1DP_LMODE_SUPERCHANNEL:
+ line->mode = E1_LINE_MODE_SUPERCHANNEL;
+ break;
+ default:
+ return 0;
+ }
+
+ /* Allocate response */
+ rmsgb->l2h = msgb_put(rmsgb, sizeof(struct osmo_e1dp_line_info));
+ info = msgb_l2(rmsgb);
+
+ memset(info, 0x00, sizeof(struct osmo_e1dp_line_info));
+
+ /* Fill reponse */
+ _e1d_fill_line_info(info, line);
+
+ return 0;
+}
+
+
+static int
_e1d_ctl_ts_open(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
{
struct e1_daemon *e1d = (struct e1_daemon *)data;
@@ -355,6 +413,12 @@ struct osmo_e1dp_server_handler e1d_ctl_handlers[] = {
.fn = _e1d_ctl_ts_query,
},
{
+ .type = E1DP_CMD_LINE_CONFIG,
+ .flags = E1DP_SF_INTF_REQ | E1DP_SF_LINE_REQ,
+ .payload_len = sizeof(struct osmo_e1dp_line_config),
+ .fn = _e1d_ctl_line_config,
+ },
+ {
.type = E1DP_CMD_TS_OPEN,
.flags = E1DP_SF_INTF_REQ | E1DP_SF_LINE_REQ | E1DP_SF_TS_REQ,
.payload_len = sizeof(struct osmo_e1dp_ts_config),
diff --git a/src/proto.c b/src/proto.c
index 85f5115..479175a 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -46,6 +46,12 @@ const struct value_string osmo_e1dp_msg_type_names[] = {
{ E1DP_ERR_TYPE, "ERR_TYPE" },
{ 0, NULL }
};
+const struct value_string osmo_e1dp_line_mode_names[] = {
+ { E1DP_LMODE_OFF, "OFF" },
+ { E1DP_LMODE_CHANNELIZED, "CHANNELIZED" },
+ { E1DP_LMODE_SUPERCHANNEL, "SUPERCHANNEL" },
+ { 0, NULL }
+};
const struct value_string osmo_e1dp_ts_mode_names[] = {
{ E1DP_TSMODE_OFF, "OFF" },
{ E1DP_TSMODE_RAW, "RAW" },
diff --git a/src/proto_clnt.c b/src/proto_clnt.c
index 7c6df27..ca62abe 100644
--- a/src/proto_clnt.c
+++ b/src/proto_clnt.c
@@ -2,6 +2,7 @@
* proto_clnt.c
*
* (C) 2019 by Sylvain Munaut <tnt@246tNt.com>
+ * (C) 2020 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@@ -285,6 +286,36 @@ osmo_e1dp_client_ts_query(struct osmo_e1dp_client *clnt,
}
int
+osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
+ uint8_t intf, uint8_t line, enum osmo_e1dp_line_mode mode)
+{
+ struct msgb *msgb;
+ struct osmo_e1dp_msg_hdr hdr;
+ struct osmo_e1dp_line_config cfg;
+ int rc;
+
+ memset(&hdr, 0x00, sizeof(struct osmo_e1dp_msg_hdr));
+ hdr.type = E1DP_CMD_LINE_CONFIG;
+ hdr.intf = intf;
+ hdr.line = line;
+ hdr.ts = E1DP_INVALID;
+
+ memset(&cfg, 0x00, sizeof(struct osmo_e1dp_line_config));
+ cfg.mode = mode;
+
+ rc = _e1dp_client_query_base(clnt, &hdr, &cfg, sizeof(struct osmo_e1dp_line_config), &msgb, NULL);
+ if (rc)
+ return rc;
+
+ if (msgb_l2len(msgb) != sizeof(struct osmo_e1dp_line_info))
+ return -EPIPE;
+
+ msgb_free(msgb);
+
+ return 0;
+}
+
+int
osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
uint8_t intf, uint8_t line, uint8_t ts,
enum osmo_e1dp_ts_mode mode)