make sure a given timeslot can only be opened once (by default)
Align the behavior of osmo-e1d with that of DAHDI: If a timeslot is opened once, it cannot be opened again by anyone until it is closed by the current owner. This way we'd have the same failure semantics in DAHDI vs. osmo-e1d, which is very useful in case of misconfiguration when osmo-bsc + osmo-mgw would "fight" over a timeslot. Add a osmo_e1dp_client_ts_open_force() function that allows to override and get back the original behavior. Closes: OS#4654 Change-Id: Ib25adf827ec41e74de15e0e4fdcfc9bcc9a32e58
This commit is contained in:
parent
ead2e020f0
commit
9e137aff1d
|
@ -0,0 +1 @@
|
|||
* bump protocol version as 'flags' member was added to osmo_d1dp_ts_config
|
|
@ -81,6 +81,8 @@ enum osmo_e1dp_ts_mode {
|
|||
E1DP_TSMODE_HDLCFCS = 0x11,
|
||||
};
|
||||
|
||||
/* osmo_e1dp_ts_config.flags */
|
||||
#define E1DP_TS_OPEN_F_FORCE 0x80
|
||||
|
||||
/* the idea here is to use the first byte as a version number, to prevent incompatible
|
||||
* clients from connecting to e1d */
|
||||
|
@ -118,6 +120,7 @@ struct osmo_e1dp_line_info {
|
|||
|
||||
struct osmo_e1dp_ts_config {
|
||||
uint8_t mode;
|
||||
uint8_t flags;
|
||||
uint16_t read_bufsize;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
|
|
@ -46,3 +46,6 @@ int osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
|
|||
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, uint16_t read_bufsize);
|
||||
int osmo_e1dp_client_ts_open_force(struct osmo_e1dp_client *clnt,
|
||||
uint8_t intf, uint8_t line, uint8_t ts,
|
||||
enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize);
|
||||
|
|
12
src/ctl.c
12
src/ctl.c
|
@ -395,8 +395,16 @@ _e1d_ctl_ts_open(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* If already open, close previous */
|
||||
e1_ts_stop(ts);
|
||||
if (ts->fd >= 0) {
|
||||
/* we only force-reopen a busy timeslot if the flag is set */
|
||||
if (cfg->flags & E1DP_TS_OPEN_F_FORCE) {
|
||||
e1_ts_stop(ts);
|
||||
} else {
|
||||
LOGPTS(ts, DE1D, LOGL_ERROR,
|
||||
"Timeslot already open, rejecting re-open without F_FORCE\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Init */
|
||||
ret = _e1d_ts_start(ts, mode, cfg->read_bufsize);
|
||||
|
|
|
@ -315,10 +315,10 @@ osmo_e1dp_client_line_config(struct osmo_e1dp_client *clnt,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
|
||||
static int
|
||||
_client_ts_open(struct osmo_e1dp_client *clnt,
|
||||
uint8_t intf, uint8_t line, uint8_t ts,
|
||||
enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
|
||||
enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize, uint8_t flags)
|
||||
{
|
||||
struct msgb *msgb;
|
||||
struct osmo_e1dp_msg_hdr hdr;
|
||||
|
@ -333,6 +333,7 @@ osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
|
|||
|
||||
memset(&cfg, 0x00, sizeof(struct osmo_e1dp_ts_config));
|
||||
cfg.mode = mode;
|
||||
cfg.flags = flags;
|
||||
cfg.read_bufsize = read_bufsize;
|
||||
|
||||
tsfd = -1;
|
||||
|
@ -348,3 +349,19 @@ osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt,
|
|||
|
||||
return tsfd;
|
||||
}
|
||||
|
||||
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, uint16_t read_bufsize)
|
||||
{
|
||||
return _client_ts_open(clnt, intf, line, ts, mode, read_bufsize, 0);
|
||||
}
|
||||
|
||||
int
|
||||
osmo_e1dp_client_ts_open_force(struct osmo_e1dp_client *clnt,
|
||||
uint8_t intf, uint8_t line, uint8_t ts,
|
||||
enum osmo_e1dp_ts_mode mode, uint16_t read_bufsize)
|
||||
{
|
||||
return _client_ts_open(clnt, intf, line, ts, mode, read_bufsize, E1DP_TS_OPEN_F_FORCE);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue