pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/38812?usp=email )
Change subject: ipaccess: Use libosmocore API ipa_ccm_send_id_ack() ......................................................................
ipaccess: Use libosmocore API ipa_ccm_send_id_ack()
This allows getting rid of the second use of rmsg variable, and simplify the return paths.
Change-Id: Ib8e84718337d16467726de922b410abbaffdac3a --- M src/input/ipaccess.c 1 file changed, 6 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/12/38812/1
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 9e06857..ab2fec9 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -825,20 +825,6 @@ return nmsg; }
-static struct msgb *ipa_bts_id_ack(void) -{ - struct msgb *nmsg2; - - nmsg2 = ipa_msg_alloc(0); - if (!nmsg2) - return NULL; - - *msgb_put(nmsg2, 1) = IPAC_MSGT_ID_ACK; - ipa_msg_push_header(nmsg2, IPAC_PROTO_IPACCESS); - - return nmsg2; -} - static void ipaccess_bts_updown_cb(struct ipa_client_conn *link, int up) { struct e1inp_line *line = link->line; @@ -869,7 +855,6 @@ if (hh->proto != IPAC_PROTO_IPACCESS) return 0;
- struct msgb *rmsg; int ret = 0; uint8_t *data = msgb_l2(msg); int len = msgb_l2len(msg); @@ -891,6 +876,7 @@
/* this is a request for identification from the BSC. */ if (msg_type == IPAC_MSGT_ID_GET) { + struct msgb *rmsg; int trx_nr = 0;
if (link->ofd->priv_nr >= E1INP_SIGN_RSL) @@ -900,27 +886,23 @@ dev->site_id, dev->bts_id, trx_nr); rmsg = ipa_bts_id_resp(dev, data + 1, len - 1, trx_nr); ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); + msgb_free(rmsg); if (ret != rmsg->len) { LOGP(DLINP, LOGL_ERROR, "cannot send ID_RESP message. Reason: %s\n", strerror(errno)); - goto err_rmsg; + goto err; } - msgb_free(rmsg);
/* send ID_ACK. */ - rmsg = ipa_bts_id_ack(); - ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); - if (ret != rmsg->len) { + ret = ipa_ccm_send_id_ack(link->ofd->fd); + if (ret <= 0) { LOGP(DLINP, LOGL_ERROR, "cannot send ID_ACK message. Reason: %s\n", strerror(errno)); - goto err_rmsg; + goto err; } - msgb_free(rmsg); } return 1;
-err_rmsg: - msgb_free(rmsg); err: ipa_client_conn_close(link); return -1;