From 703c2d6eb8f82c319d774ed7e2627f86045e0e02 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 16 Jun 2016 03:26:50 +0200 Subject: [PATCH] pcu_sock: add pcu_connected() to query PCU availability Will be used in upcoming dyn PDCH switching. Change-Id: I8031089ad5e9cb9690ca7e22facc53438f28e12a --- include/osmo-bts/pcu_if.h | 2 ++ src/common/pcu_sock.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/osmo-bts/pcu_if.h b/include/osmo-bts/pcu_if.h index 0c4fb6960..3ce4d0b24 100644 --- a/include/osmo-bts/pcu_if.h +++ b/include/osmo-bts/pcu_if.h @@ -19,4 +19,6 @@ int pcu_tx_pch_data_cnf(uint32_t fn, uint8_t *data, uint8_t len); int pcu_sock_init(const char *path); void pcu_sock_exit(void); +bool pcu_connected(void); + #endif /* _PCU_IF_H */ diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c index 7c835fb98..ea4267de4 100644 --- a/src/common/pcu_sock.c +++ b/src/common/pcu_sock.c @@ -922,3 +922,13 @@ int osmo_unixsock_listen(struct osmo_fd *bfd, int type, const char *path) return 0; } +bool pcu_connected(void) { + struct gsm_network *net = &bts_gsmnet; + struct pcu_sock_state *state = net->pcu_state; + + if (!state) + return false; + if (state->conn_bfd.fd <= 0) + return false; + return true; +}