e1_input: rework configuration of virtual E1 line operations
struct e1inp_line_ops {
- enum e1inp_line_role role;
- char *addr;
- void *data;
+ union {
+ struct {
+ enum e1inp_line_role role; /* BSC or BTS mode. */
+ const char *addr; /* IP address .*/
+ void *dev; /* device parameters. */
+ } ipa;
+ struct {
+ const char *port; /* e.g. /dev/ttyUSB0 */
+ unsigned int delay;
+ } rs232;
+ } cfg;
Now this structure contains the configuration details for the
virtual E1 line, instead of using a pointer.
This also get the line_update callback to its original layout:
+ int (*line_update)(struct e1inp_line *line);
diff --git a/src/input/dahdi.c b/src/input/dahdi.c
index 1b366e1..e4e4905 100644
--- a/src/input/dahdi.c
+++ b/src/input/dahdi.c
@@ -385,8 +385,7 @@
return rc;
}
-static int dahdi_e1_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr);
+static int dahdi_e1_line_update(struct e1inp_line *line);
struct e1inp_driver dahdi_driver = {
.name = "dahdi",
@@ -501,8 +500,7 @@
return 0;
}
-static int dahdi_e1_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr)
+static int dahdi_e1_line_update(struct e1inp_line *line)
{
if (line->driver != &dahdi_driver)
return -EINVAL;
diff --git a/src/input/hsl.c b/src/input/hsl.c
index ab822c0..dc7532b 100644
--- a/src/input/hsl.c
+++ b/src/input/hsl.c
@@ -318,8 +318,7 @@
}
}
-static int hsl_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr);
+static int hsl_line_update(struct e1inp_line *line);
struct e1inp_driver hsl_driver = {
.name = "hsl",
@@ -421,7 +420,7 @@
struct msgb *msg;
uint8_t *serno;
char serno_buf[16];
- struct hsl_unit *unit = link->line->ops->data;
+ struct hsl_unit *unit = link->line->ops->cfg.ipa.dev;
struct e1inp_sign_link *sign_link;
/* send the minimal message to identify this BTS. */
@@ -457,17 +456,17 @@
return 0;
}
-static int hsl_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr)
+static int hsl_line_update(struct e1inp_line *line)
{
int ret = -ENOENT;
- switch(role) {
+ switch(line->ops->cfg.ipa.role) {
case E1INP_LINE_R_BSC:
LOGP(DLINP, LOGL_NOTICE, "enabling hsl BSC mode\n");
ret = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP,
- addr, HSL_TCP_PORT, OSMO_SOCK_F_BIND);
+ line->ops->cfg.ipa.addr,
+ HSL_TCP_PORT, OSMO_SOCK_F_BIND);
if (ret < 0)
return ret;
@@ -489,7 +488,8 @@
link = ipa_client_link_create(tall_hsl_ctx,
&line->ts[E1INP_SIGN_OML-1],
"hsl", E1INP_SIGN_OML,
- addr, HSL_TCP_PORT,
+ line->ops->cfg.ipa.addr,
+ HSL_TCP_PORT,
hsl_bts_connect,
hsl_bts_process,
hsl_bts_write,
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 13b3cb1..5f35ab6 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -551,8 +551,7 @@
return rc;
}
-static int ipaccess_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr);
+static int ipaccess_line_update(struct e1inp_line *line);
struct e1inp_driver ipaccess_driver = {
.name = "ipa",
@@ -778,7 +777,7 @@
link->ofd->fd = -1;
return -EINVAL;
}
- rmsg = ipa_bts_id_resp(link->line->ops->data,
+ rmsg = ipa_bts_id_resp(link->line->ops->cfg.ipa.dev,
data + 1, len - 1);
ipaccess_send(link->ofd->fd, rmsg->data, rmsg->len);
msgb_free(rmsg);
@@ -814,12 +813,11 @@
return 0;
}
-static int ipaccess_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr)
+static int ipaccess_line_update(struct e1inp_line *line)
{
int ret = -ENOENT;
- switch(role) {
+ switch(line->ops->cfg.ipa.role) {
case E1INP_LINE_R_BSC: {
struct ipa_server_link *oml_link, *rsl_link;
@@ -864,7 +862,8 @@
link = ipa_client_link_create(tall_ipa_ctx,
&line->ts[E1INP_SIGN_OML-1],
"ipa", E1INP_SIGN_OML,
- addr, IPA_TCP_PORT_OML,
+ line->ops->cfg.ipa.addr,
+ IPA_TCP_PORT_OML,
NULL,
ipaccess_bts_cb,
ipaccess_bts_write_cb,
@@ -884,7 +883,8 @@
rsl_link = ipa_client_link_create(tall_ipa_ctx,
&line->ts[E1INP_SIGN_RSL-1],
"ipa", E1INP_SIGN_RSL,
- addr, IPA_TCP_PORT_RSL,
+ line->ops->cfg.ipa.addr,
+ IPA_TCP_PORT_RSL,
NULL,
ipaccess_bts_cb,
ipaccess_bts_write_cb,
diff --git a/src/input/misdn.c b/src/input/misdn.c
index 7adcaa6..bb9145f 100644
--- a/src/input/misdn.c
+++ b/src/input/misdn.c
@@ -380,8 +380,7 @@
return ret;
}
-static int mi_e1_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr);
+static int mi_e1_line_update(struct e1inp_line *line);
struct e1inp_driver misdn_driver = {
.name = "misdn",
@@ -479,8 +478,7 @@
return 0;
}
-static int mi_e1_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr)
+static int mi_e1_line_update(struct e1inp_line *line)
{
struct mISDN_devinfo devinfo;
int sk, ret, cnt;
diff --git a/src/input/rs232.c b/src/input/rs232.c
index eb6b5d0..2fd2a09 100644
--- a/src/input/rs232.c
+++ b/src/input/rs232.c
@@ -277,8 +277,7 @@
return 0;
}
-static int rs232_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr);
+static int rs232_line_update(struct e1inp_line *line);
static struct e1inp_driver rs232_driver = {
.name = "rs232",
@@ -286,13 +285,13 @@
.line_update = rs232_line_update,
};
-static int rs232_line_update(struct e1inp_line *line,
- enum e1inp_line_role role, const char *addr)
+static int rs232_line_update(struct e1inp_line *line)
{
if (line->driver != &rs232_driver)
return -EINVAL;
- return rs232_setup(line, addr, 0);
+ return rs232_setup(line, line->ops->cfg.rs232.port,
+ line->ops->cfg.rs232.delay);
}
int e1inp_rs232_init(void)