pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/39041?usp=email )
Change subject: input: Move ipaccess_bts_handle_ccm() ipaccess.c -> ipa.c ...................................................................... input: Move ipaccess_bts_handle_ccm() ipaccess.c -> ipa.c This function is no longer used in ipaccess.c, and actually relates to IPA generic code which still exists in ipa.c, hence move it there. Moreover, the function is declared in the "abis/ipa.h" public header, not the "abis/ipaccess.h" header (which was already deprecated). Once moved and it becomes clear this is not used in the e1_line ipaccess driver and hence the "if (line) { ... ipa pong ... } code branch in the function can be dropped, since it won't ever be executed. Change-Id: I2378227515315e7fc0bd0844a1dc4f85e54b455a --- M src/input/ipa.c M src/input/ipaccess.c 2 files changed, 66 insertions(+), 72 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/41/39041/1 diff --git a/src/input/ipa.c b/src/input/ipa.c index f49d0dc..073c1ff 100644 --- a/src/input/ipa.c +++ b/src/input/ipa.c @@ -582,3 +582,69 @@ msgb_enqueue(&conn->tx_queue, msg); osmo_fd_write_enable(&conn->ofd); } + +/* Kept for bacward compat since this is a public API. Will be deprecated at + * some point withthe rest of ipa_client_conn. */ +int ipaccess_bts_handle_ccm(struct ipa_client_conn *link, + struct ipaccess_unit *dev, struct msgb *msg) +{ + struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; + + /* special handling for IPA CCM. */ + if (hh->proto != IPAC_PROTO_IPACCESS) + return 0; + + int ret = 0; + uint8_t *data = msgb_l2(msg); + int len = msgb_l2len(msg); + OSMO_ASSERT(len > 0); + uint8_t msg_type = *data; + + /* ping, pong and acknowledgment cases. */ + ret = ipa_ccm_rcvmsg_bts_base(msg, link->ofd); + if (ret < 0) + goto err; + + /* this is a request for identification from the BSC. */ + if (msg_type == IPAC_MSGT_ID_GET) { + struct msgb *rmsg; + /* The ipaccess_unit dev holds generic identity for the whole + * line, hence no trx_id. Patch ipaccess_unit during call to + * ipa_ccm_make_id_resp_from_req() to identify this TRX: */ + int store_trx_nr = dev->trx_id; + if (link->ofd->priv_nr >= E1INP_SIGN_RSL) + dev->trx_id = link->ofd->priv_nr - E1INP_SIGN_RSL; + else + dev->trx_id = 0; + LOGP(DLINP, LOGL_NOTICE, "received ID_GET for unit ID %u/%u/%u\n", + dev->site_id, dev->bts_id, dev->trx_id); + rmsg = ipa_ccm_make_id_resp_from_req(dev, data + 1, len - 1); + dev->trx_id = store_trx_nr; + if (!rmsg) { + LOGP(DLINP, LOGL_ERROR, "Failed parsing ID_GET message.\n"); + goto err; + } + + ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); + if (ret != rmsg->len) { + LOGP(DLINP, LOGL_ERROR, "cannot send ID_RESP message. Reason: %s\n", + strerror(errno)); + msgb_free(rmsg); + goto err; + } + msgb_free(rmsg); + + /* send ID_ACK. */ + 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; + } + } + return 1; + +err: + ipa_client_conn_close(link); + return -1; +} diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 6110004..c47c6fb 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -772,78 +772,6 @@ return 0; } -int ipaccess_bts_handle_ccm(struct ipa_client_conn *link, - struct ipaccess_unit *dev, struct msgb *msg) -{ - struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; - - /* special handling for IPA CCM. */ - if (hh->proto != IPAC_PROTO_IPACCESS) - return 0; - - int ret = 0; - uint8_t *data = msgb_l2(msg); - int len = msgb_l2len(msg); - OSMO_ASSERT(len > 0); - uint8_t msg_type = *data; - /* line might not exist if != bsc||bts */ - struct e1inp_line *line = link->line; - - /* peek the pong for our keepalive fsm */ - if (line && msg_type == IPAC_MSGT_PONG) { - struct osmo_fsm_inst *ka_fsm = ipaccess_line_ts(link->ofd, line)->driver.ipaccess.ka_fsm; - ipa_keepalive_fsm_pong_received(ka_fsm); - } - - /* ping, pong and acknowledgment cases. */ - ret = ipa_ccm_rcvmsg_bts_base(msg, link->ofd); - if (ret < 0) - goto err; - - /* this is a request for identification from the BSC. */ - if (msg_type == IPAC_MSGT_ID_GET) { - struct msgb *rmsg; - /* The ipaccess_unit dev holds generic identity for the whole - * line, hence no trx_id. Patch ipaccess_unit during call to - * ipa_ccm_make_id_resp_from_req() to identify this TRX: */ - int store_trx_nr = dev->trx_id; - if (link->ofd->priv_nr >= E1INP_SIGN_RSL) - dev->trx_id = link->ofd->priv_nr - E1INP_SIGN_RSL; - else - dev->trx_id = 0; - LOGP(DLINP, LOGL_NOTICE, "received ID_GET for unit ID %u/%u/%u\n", - dev->site_id, dev->bts_id, dev->trx_id); - rmsg = ipa_ccm_make_id_resp_from_req(dev, data + 1, len - 1); - dev->trx_id = store_trx_nr; - if (!rmsg) { - LOGP(DLINP, LOGL_ERROR, "Failed parsing ID_GET message.\n"); - goto err; - } - - ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); - if (ret != rmsg->len) { - LOGP(DLINP, LOGL_ERROR, "cannot send ID_RESP message. Reason: %s\n", - strerror(errno)); - msgb_free(rmsg); - goto err; - } - msgb_free(rmsg); - - /* send ID_ACK. */ - 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; - } - } - return 1; - -err: - ipa_client_conn_close(link); - return -1; -} - static struct msgb *ipa_bts_id_ack(void) { struct msgb *nmsg2; -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/39041?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I2378227515315e7fc0bd0844a1dc4f85e54b455a Gerrit-Change-Number: 39041 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de>