9
0
Fork 0

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
This commit is contained in:
Harald Welte 2016-11-17 18:09:16 +01:00
parent c2abdbb2be
commit 7830c0592e
3 changed files with 19 additions and 20 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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;
}