From f163d23bf66b76037645f5a1bdc3333cc88f1ad1 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 25 Jun 2011 18:42:55 +0200 Subject: e1_input: minor API changes to adapt it to openbsc While working on the openbsc over libosmo-abis port, I noticed several API changes that we need to perform for better adaptation. --- src/e1_input.c | 24 ++++++++++++++---------- src/input/dahdi.c | 8 ++++---- src/input/hsl.c | 17 +++++++++-------- src/input/ipaccess.c | 29 ++++++++++++++--------------- src/input/misdn.c | 8 ++++---- 5 files changed, 45 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/e1_input.c b/src/e1_input.c index 1781f18..78b593b 100644 --- a/src/e1_input.c +++ b/src/e1_input.c @@ -306,8 +306,7 @@ struct e1inp_line *e1inp_line_get(uint8_t e1_nr) } struct e1inp_line * -e1inp_line_create(uint8_t e1_nr, const char *driver_name, - const struct e1inp_line_ops *ops) +e1inp_line_create(uint8_t e1_nr, const char *driver_name) { struct e1inp_driver *driver; struct e1inp_line *line; @@ -332,7 +331,6 @@ e1inp_line_create(uint8_t e1_nr, const char *driver_name, return NULL; line->driver = driver; - memcpy(&line->ops, ops, sizeof(struct e1inp_line_ops)); line->num = e1_nr; for (i = 0; i < NUM_E1_TS; i++) { @@ -344,6 +342,12 @@ e1inp_line_create(uint8_t e1_nr, const char *driver_name, return line; } +void +e1inp_line_bind_ops(struct e1inp_line *line, const struct e1inp_line_ops *ops) +{ + line->ops = ops; +} + #if 0 struct e1inp_line *e1inp_line_get_create(uint8_t e1_nr) { @@ -467,12 +471,12 @@ int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, "tei %d, sapi %d\n", tei, sapi); return -EINVAL; } - if (!ts->line->ops.sign_link) { + if (!ts->line->ops->sign_link) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set for signalling messages.\n"); return -ENOENT; } - ts->line->ops.sign_link(msg, link); + ts->line->ops->sign_link(msg, ts->line, link); break; case E1INP_TS_TYPE_TRAU: ret = subch_demux_in(&ts->trau.demux, msg->l2h, msgb_l2len(msg)); @@ -560,8 +564,7 @@ struct e1inp_driver *e1inp_driver_find(const char *name) return NULL; } -int e1inp_line_update(struct e1inp_line *line, - enum e1inp_line_role role, const char *addr) +int e1inp_line_update(struct e1inp_line *line) { struct input_signal_data isd; int rc; @@ -570,9 +573,10 @@ int e1inp_line_update(struct e1inp_line *line, if (++line->refcnt > 1) return 0; - if (line->driver && line->driver->line_update) - rc = line->driver->line_update(line, role, addr); - else + if (line->driver && line->ops && line->driver->line_update) { + rc = line->driver->line_update(line, line->ops->role, + line->ops->addr); + } else rc = 0; /* Send a signal to anyone who is interested in new lines being diff --git a/src/input/dahdi.c b/src/input/dahdi.c index bf73f97..20c2a09 100644 --- a/src/input/dahdi.c +++ b/src/input/dahdi.c @@ -122,8 +122,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) idata = lapd_receive(e1i_ts->driver.dahdi.lapd, msg->data, msg->len, &ilen, &prim); if (!idata && prim == 0) { - if (line->ops.error) - line->ops.error(NULL, -EBADMSG); + if (line->ops->error) + line->ops->error(NULL, -EBADMSG); return -EIO; } @@ -152,8 +152,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) ret = e1inp_rx_ts(e1i_ts, msg, tei, sapi); break; default: - if (line->ops.error) - line->ops.error(NULL, -EBADMSG); + if (line->ops->error) + line->ops->error(NULL, -EBADMSG); break; } diff --git a/src/input/hsl.c b/src/input/hsl.c index 0b6b078..a9a9a78 100644 --- a/src/input/hsl.c +++ b/src/input/hsl.c @@ -86,8 +86,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) error = ipa_msg_recv(bfd->fd, &msg); if (error <= 0) { - if (e1i_ts->line->ops.error) - e1i_ts->line->ops.error(NULL, error); + if (e1i_ts->line->ops->error) + e1i_ts->line->ops->error(NULL, line, ts_nr, error); if (error == 0) { osmo_fd_unregister(bfd); close(bfd->fd); @@ -106,17 +106,18 @@ static int handle_ts1_read(struct osmo_fd *bfd) /* HSL proprietary RSL extension */ if (hh->proto == 0 && (msg->l2h[0] == 0x81 || msg->l2h[0] == 0x80)) { - if (!line->ops.sign_link_up) { + if (!line->ops->sign_link_up) { LOGP(DINP, LOGL_ERROR, "Fix your application, no " "action set if the signalling link " "becomes ready.\n"); return -EINVAL; } - ret = line->ops.sign_link_up(msg, line); + ret = line->ops->sign_link_up(msg, line, E1INP_SIGN_RSL); if (ret < 0) { /* FIXME: close connection */ - if (line->ops.error) - line->ops.error(msg, -EBADMSG); + if (line->ops->error) + line->ops->error(msg, line, + E1INP_SIGN_RSL, -EBADMSG); return ret; } else if (ret == 1) return 0; @@ -138,12 +139,12 @@ static int handle_ts1_read(struct osmo_fd *bfd) msg->dst = link; /* XXX: better use e1inp_ts_rx? */ - if (!e1i_ts->line->ops.sign_link) { + if (!e1i_ts->line->ops->sign_link) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set for signalling messages.\n"); return -ENOENT; } - e1i_ts->line->ops.sign_link(msg, link); + e1i_ts->line->ops->sign_link(msg, line, link); return ret; } diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 8ce10ab..20d275b 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -45,9 +45,6 @@ #include #include -#define PRIV_OML 1 -#define PRIV_RSL 2 - static void *tall_ipa_ctx; #define TS1_ALLOC_SIZE 900 @@ -140,13 +137,13 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, switch (msg_type) { case IPAC_MSGT_ID_RESP: DEBUGP(DMI, "ID_RESP\n"); - if (!line->ops.sign_link_up) { + if (!line->ops->sign_link_up) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set if the signalling link " "becomes ready\n"); return -EINVAL; } - line->ops.sign_link_up(msg, line); + line->ops->sign_link_up(msg, line, bfd->priv_nr); break; } return 0; @@ -165,8 +162,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) error = ipa_msg_recv(bfd->fd, &msg); if (error <= 0) { /* skip if RSL line is not set yet. */ - if (e1i_ts && e1i_ts->line->ops.error) - e1i_ts->line->ops.error(NULL, error); + if (e1i_ts && e1i_ts->line->ops->error) + e1i_ts->line->ops->error(NULL, line, ts_nr, error); if (error == 0) { osmo_fd_unregister(bfd); close(bfd->fd); @@ -199,12 +196,12 @@ static int handle_ts1_read(struct osmo_fd *bfd) msg->dst = link; /* XXX better use e1inp_ts_rx? */ - if (!e1i_ts->line->ops.sign_link) { + if (!e1i_ts->line->ops->sign_link) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set for signalling messages.\n"); return -ENOENT; } - e1i_ts->line->ops.sign_link(msg, link); + e1i_ts->line->ops->sign_link(msg, line, link); return ret; } @@ -353,7 +350,7 @@ static int ipaccess_bsc_oml_cb(struct ipa_server_link *link, int fd) bfd->fd = fd; bfd->data = line; - bfd->priv_nr = PRIV_OML; + bfd->priv_nr = E1INP_SIGN_OML; bfd->cb = ipaccess_fd_cb; bfd->when = BSC_FD_READ; ret = osmo_fd_register(bfd); @@ -380,7 +377,7 @@ static int ipaccess_bsc_rsl_cb(struct ipa_server_link *link, int fd) return -ENOMEM; bfd->fd = fd; - bfd->priv_nr = PRIV_RSL; + bfd->priv_nr = E1INP_SIGN_RSL; bfd->cb = ipaccess_fd_cb; bfd->when = BSC_FD_READ; ret = osmo_fd_register(bfd); @@ -412,13 +409,15 @@ static int ipaccess_bts_cb(struct ipa_client_link *link, struct msgb *msg) /* this is a request for identification from the BSC. */ if (msg_type == IPAC_MSGT_ID_GET) { LOGP(DINP, LOGL_NOTICE, "received ID get\n"); - if (!link->line->ops.sign_link_up) { + if (!link->line->ops->sign_link_up) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set if the signalling link " "becomes ready\n"); return -EINVAL; } - link->line->ops.sign_link_up(msg, link->line); + link->line->ops->sign_link_up(msg, link->line, + link->port == IPA_TCP_PORT_OML ? + E1INP_SIGN_OML : E1INP_SIGN_RSL); } return 0; } else if (link->port == IPA_TCP_PORT_OML) @@ -437,12 +436,12 @@ static int ipaccess_bts_cb(struct ipa_client_link *link, struct msgb *msg) msg->dst = sign_link; /* XXX better use e1inp_ts_rx? */ - if (!link->line->ops.sign_link) { + if (!link->line->ops->sign_link) { LOGP(DINP, LOGL_ERROR, "Fix your application, " "no action set for signalling messages.\n"); return -ENOENT; } - link->line->ops.sign_link(msg, sign_link); + link->line->ops->sign_link(msg, link->line, sign_link); return 0; } diff --git a/src/input/misdn.c b/src/input/misdn.c index 3ccfc4d..cf8b5d9 100644 --- a/src/input/misdn.c +++ b/src/input/misdn.c @@ -109,8 +109,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) } if (alen != sizeof(l2addr)) { - if (line->ops.error) - line->ops.error(NULL, -EBADMSG); + if (line->ops->error) + line->ops->error(NULL, line, ts_nr, -EBADMSG); return -EINVAL; } @@ -173,8 +173,8 @@ static int handle_ts1_read(struct osmo_fd *bfd) l2addr.channel, l2addr.sapi, l2addr.tei); break; default: - if (line->ops.error) - line->ops.error(NULL, -EBADMSG); + if (line->ops->error) + line->ops->error(NULL, line, ts_nr, -EBADMSG); break; } return ret; -- cgit v1.2.3-55-g7522