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
This commit is contained in:
parent
17c80e1f55
commit
5d5e47ff3b
|
@ -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[];
|
||||
|
|
|
@ -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);
|
||||
|
|
64
src/ctl.c
64
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;
|
||||
}
|
||||
|
||||
|
@ -272,6 +283,53 @@ _e1d_ctl_ts_query(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -354,6 +412,12 @@ struct osmo_e1dp_server_handler e1d_ctl_handlers[] = {
|
|||
.payload_len = 0,
|
||||
.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,
|
||||
|
|
|
@ -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" },
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -284,6 +285,36 @@ osmo_e1dp_client_ts_query(struct osmo_e1dp_client *clnt,
|
|||
return 0;
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue