This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgPau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11203
Change subject: ipaccess: Simplify handling of e1line ts
......................................................................
ipaccess: Simplify handling of e1line ts
Handle encoding specifics behind a macro to make code easier to
understand and follow.
Change-Id: Ibf251673bff95b7a0b066b19ef4dc6c0f94fff6b
---
M include/osmocom/abis/e1_input.h
M src/input/ipaccess.c
M tests/e1inp_ipa_bsc_test.c
M tests/e1inp_ipa_bts_test.c
4 files changed, 36 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/03/11203/1
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index 79455e1..3d0c820 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -195,6 +195,8 @@
/* array of timestlots */
struct e1inp_ts ts[NUM_E1_TS];
unsigned int num_ts;
+ #define e1inp_line_oml_ts(line) (&line->ts[0])
+ #define e1inp_line_rsl_ts(line, trx_id) (&line->ts[1 + (trx_id)])
const struct e1inp_line_ops *ops;
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index f8e8e09..cce09c3 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -62,8 +62,11 @@
static int ipaccess_drop(struct osmo_fd *bfd, struct e1inp_line *line)
{
int ret = 1;
- unsigned int ts_nr = bfd->priv_nr;
- struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
+ struct e1inp_ts *e1i_ts;
+ if (bfd->priv_nr == E1INP_SIGN_OML)
+ e1i_ts = e1inp_line_oml_ts(line);
+ else
+ e1i_ts = e1inp_line_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL);
/* Error case: we did not see any ID_RESP yet for this socket. */
if (bfd->fd != -1) {
@@ -185,7 +188,7 @@
* this RSL link, attach it to this socket. */
bfd->data = new_line = sign_link->ts->line;
e1inp_line_get(new_line);
- ts = &new_line->ts[E1INP_SIGN_RSL+unit_data.trx_id-1];
+ ts = e1inp_line_rsl_ts(new_line, unit_data.trx_id);
newbfd = &ts->driver.ipaccess.fd;
/* get rid of our old temporary bfd */
@@ -223,12 +226,17 @@
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
- struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
+ struct e1inp_ts *e1i_ts;
struct e1inp_sign_link *link;
struct ipaccess_head *hh;
struct msgb *msg = NULL;
int ret, rc;
+ if (bfd->priv_nr == E1INP_SIGN_OML)
+ e1i_ts = e1inp_line_oml_ts(line);
+ else
+ e1i_ts = e1inp_line_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL);
+
ret = ipa_msg_recv_buffered(bfd->fd, &msg, &e1i_ts->pending_msg);
if (ret < 0) {
if (ret == -EAGAIN)
@@ -312,11 +320,16 @@
static int __handle_ts1_write(struct osmo_fd *bfd, struct e1inp_line *line)
{
unsigned int ts_nr = bfd->priv_nr;
- struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
+ struct e1inp_ts *e1i_ts;
struct e1inp_sign_link *sign_link;
struct msgb *msg;
int ret;
+ if (bfd->priv_nr == E1INP_SIGN_OML)
+ e1i_ts = e1inp_line_oml_ts(line);
+ else
+ e1i_ts = e1inp_line_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL);
+
bfd->when &= ~BSC_FD_WRITE;
/* get the next msg for this timeslot */
@@ -454,7 +467,6 @@
static int ipaccess_bsc_oml_cb(struct ipa_server_link *link, int fd)
{
int ret;
- int idx = 0;
int i;
struct e1inp_line *line;
struct e1inp_ts *e1i_ts;
@@ -468,13 +480,13 @@
}
/* create virrtual E1 timeslots for signalling */
- e1inp_ts_config_sign(&line->ts[E1INP_SIGN_OML-1], line);
+ e1inp_ts_config_sign(e1inp_line_oml_ts(line), line);
/* initialize the fds */
for (i = 0; i < ARRAY_SIZE(line->ts); ++i)
line->ts[i].driver.ipaccess.fd.fd = -1;
- e1i_ts = &line->ts[idx];
+ e1i_ts = e1inp_line_oml_ts(line);
bfd = &e1i_ts->driver.ipaccess.fd;
osmo_fd_setup(bfd, fd, BSC_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_OML);
@@ -524,9 +536,9 @@
/* we need this to initialize this in case to avoid crashes in case
* that the socket is closed before we've seen an ID_RESP. */
- e1inp_ts_config_sign(&line->ts[E1INP_SIGN_OML-1], line);
+ e1inp_ts_config_sign(e1inp_line_oml_ts(line), line);
- e1i_ts = &line->ts[E1INP_SIGN_RSL-1];
+ e1i_ts = e1inp_line_rsl_ts(line, 0);
bfd = &e1i_ts->driver.ipaccess.fd;
osmo_fd_setup(bfd, fd, BSC_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_RSL);
@@ -763,9 +775,9 @@
msgb_free(msg);
return ret;
} else if (link->port == IPA_TCP_PORT_OML)
- e1i_ts = &link->line->ts[0];
+ e1i_ts = e1inp_line_oml_ts(link->line);
else if (link->port == IPA_TCP_PORT_RSL)
- e1i_ts = &link->line->ts[link->ofd->priv_nr-1];
+ e1i_ts = e1inp_line_rsl_ts(link->line, link->ofd->priv_nr - E1INP_SIGN_RSL);
OSMO_ASSERT(e1i_ts != NULL);
@@ -870,7 +882,7 @@
IPA_TCP_PORT_OML);
link = ipa_client_conn_create(tall_ipa_ctx,
- &line->ts[E1INP_SIGN_OML-1],
+ e1inp_line_oml_ts(line),
E1INP_SIGN_OML,
line->ops->cfg.ipa.addr,
IPA_TCP_PORT_OML,
@@ -920,7 +932,7 @@
}
rsl_link = ipa_client_conn_create(tall_ipa_ctx,
- &line->ts[E1INP_SIGN_RSL+trx_nr-1],
+ e1inp_line_rsl_ts(line, trx_nr),
E1INP_SIGN_RSL+trx_nr,
rem_addr, rem_port,
ipaccess_bts_updown_cb,
diff --git a/tests/e1inp_ipa_bsc_test.c b/tests/e1inp_ipa_bsc_test.c
index 9064d0a..9eb3674 100644
--- a/tests/e1inp_ipa_bsc_test.c
+++ b/tests/e1inp_ipa_bsc_test.c
@@ -30,9 +30,9 @@
switch(type) {
case E1INP_SIGN_OML:
LOGP(DBSCTEST, LOGL_NOTICE, "OML link up request received.\n");
- e1inp_ts_config_sign(&line->ts[E1INP_SIGN_OML - 1], line);
+ e1inp_ts_config_sign(e1inp_line_oml_ts(line), line);
sign_link = oml_sign_link =
- e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML - 1],
+ e1inp_sign_link_create(e1inp_line_oml_ts(line),
E1INP_SIGN_OML, NULL, 255, 0);
break;
case E1INP_SIGN_RSL:
@@ -45,10 +45,10 @@
/* We have to use the same line that the OML link. */
oml_line = oml_sign_link->ts->line;
- e1inp_ts_config_sign(&oml_line->ts[E1INP_SIGN_RSL - 1],
+ e1inp_ts_config_sign(e1inp_line_rsl_ts(oml_line, 0),
oml_line);
sign_link = rsl_sign_link =
- e1inp_sign_link_create(&oml_line->ts[E1INP_SIGN_RSL - 1],
+ e1inp_sign_link_create(e1inp_line_rsl_ts(oml_line, 0),
E1INP_SIGN_RSL, NULL, 0, 0);
break;
default:
diff --git a/tests/e1inp_ipa_bts_test.c b/tests/e1inp_ipa_bts_test.c
index 48a5c59..7ebdf56 100644
--- a/tests/e1inp_ipa_bts_test.c
+++ b/tests/e1inp_ipa_bts_test.c
@@ -51,9 +51,9 @@
case E1INP_SIGN_OML:
LOGP(DBTSTEST, LOGL_NOTICE, "OML link up request received.\n");
- e1inp_ts_config_sign(&line->ts[E1INP_SIGN_OML - 1], line);
+ e1inp_ts_config_sign(e1inp_line_oml_ts(line), line);
sign_link = oml_sign_link =
- e1inp_sign_link_create(&line->ts[E1INP_SIGN_OML - 1],
+ e1inp_sign_link_create(e1inp_line_oml_ts(line),
E1INP_SIGN_OML, NULL, 255, 0);
if (!oml_sign_link) {
LOGP(DBTSTEST, LOGL_ERROR,
@@ -76,10 +76,10 @@
case E1INP_SIGN_RSL:
LOGP(DBTSTEST, LOGL_NOTICE, "RSL link up request received.\n");
- e1inp_ts_config_sign(&line->ts[E1INP_SIGN_RSL - 1], line);
+ e1inp_ts_config_sign(e1inp_line_rsl_ts(line, 0), line);
sign_link = rsl_sign_link =
- e1inp_sign_link_create(&line->ts[E1INP_SIGN_RSL - 1],
+ e1inp_sign_link_create(e1inp_line_rsl_ts(line, 0),
E1INP_SIGN_RSL, NULL, 0, 0);
if (!rsl_sign_link) {
LOGP(DBTSTEST, LOGL_ERROR,
--
To view, visit https://gerrit.osmocom.org/11203
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf251673bff95b7a0b066b19ef4dc6c0f94fff6b
Gerrit-Change-Number: 11203
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181002/bc1b2823/attachment.htm>