aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-11-17 18:09:16 +0100
committerHarald Welte <laforge@gnumonks.org>2016-11-17 18:11:20 +0100
commit7830c0592e259416f6e00b584e6cc775218ce48c (patch)
treef81ec23b8f2d3b368340bbbe85cd116dcaec8f4a
parentc2abdbb2be97f3586ad4a16e047bf28c8c03ffd5 (diff)
pcu_if: make pcu_connected() private
Code like RSL shoudln't have to worry about whether a PCU is connected or not. Hide this behind the API. Change-Id: I9583d2e9b2742516a7e7ca28b045402018ee3a31
-rw-r--r--openbsc/include/openbsc/pcu_if.h3
-rw-r--r--openbsc/src/libbsc/abis_rsl.c6
-rw-r--r--openbsc/src/libbsc/pcu_sock.c30
3 files changed, 19 insertions, 20 deletions
diff --git a/openbsc/include/openbsc/pcu_if.h b/openbsc/include/openbsc/pcu_if.h
index 604d00636..717e077f7 100644
--- a/openbsc/include/openbsc/pcu_if.h
+++ b/openbsc/include/openbsc/pcu_if.h
@@ -44,7 +44,4 @@ int pcu_sock_init(const char *path, struct gsm_bts *bts);
/* Close connection to PCU */
void pcu_sock_exit(struct gsm_bts *bts);
-/* Check if BTS has a PCU connection */
-bool pcu_connected(struct gsm_bts *bts);
-
#endif /* _PCU_IF_H */
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index ee8745d35..a7372a114 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -1740,12 +1740,6 @@ static int rsl_rx_pchan_rqd(struct msgb *msg, struct gsm_bts *bts)
uint8_t rqd_ta;
uint8_t is_11bit;
- /* Bail if no PCU is connected */
- if (!pcu_connected(bts)) {
- LOGP(DRSL, LOGL_ERROR, "BTS %d PCU not availabe!\n",bts->nr);
- return -EINVAL;
- }
-
/* Process rach request and forward contained information to PCU */
if (ra == 0x7F) {
is_11bit = 1;
diff --git a/openbsc/src/libbsc/pcu_sock.c b/openbsc/src/libbsc/pcu_sock.c
index ccc0e9a01..8703d9e9e 100644
--- a/openbsc/src/libbsc/pcu_sock.c
+++ b/openbsc/src/libbsc/pcu_sock.c
@@ -68,6 +68,18 @@ static struct gsm_bts_trx *trx_by_nr(struct gsm_bts *bts, uint8_t trx_nr)
return NULL;
}
+/* Check if BTS has a PCU connection */
+static bool pcu_connected(struct gsm_bts *bts)
+{
+ struct pcu_sock_state *state = bts->pcu_state;
+
+ if (!state)
+ return false;
+ if (state->conn_bfd.fd <= 0)
+ return false;
+ return true;
+}
+
/*
* PCU messages
*/
@@ -318,6 +330,13 @@ int pcu_tx_rach_ind(struct gsm_bts *bts, int16_t qta, uint16_t ra, uint32_t fn,
struct gsm_pcu_if *pcu_prim;
struct gsm_pcu_if_rach_ind *rach_ind;
+ /* Bail if no PCU is connected */
+ if (!pcu_connected(bts)) {
+ LOGP(DRSL, LOGL_ERROR, "BTS %d CHAN RQD(GPRS) but PCU not "
+ "connected!\n", bts->nr);
+ return -ENODEV;
+ }
+
LOGP(DPCU, LOGL_INFO, "Sending RACH indication: qta=%d, ra=%d, "
"fn=%d\n", qta, ra, fn);
@@ -829,14 +848,3 @@ void pcu_sock_exit(struct gsm_bts *bts)
bts->pcu_state = NULL;
}
-/* Check if BTS has a PCU connection */
-bool pcu_connected(struct gsm_bts *bts)
-{
- struct pcu_sock_state *state = bts->pcu_state;
-
- if (!state)
- return false;
- if (state->conn_bfd.fd <= 0)
- return false;
- return true;
-}