aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmgcp/mgcp_osmux.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-10-02 15:56:35 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-10-12 09:11:25 +0200
commit641d387409b6d11f7166784344701438be1a45e1 (patch)
tree2bc7e13369f0b7eef926f10c1397402b03231c8b /openbsc/src/libmgcp/mgcp_osmux.c
parent2aedfbdfe1dfb4df84418af4bb39c40ca1cc5128 (diff)
osmux: Test cid allocation and de-allocation
* Test that one can get an id * That they are assigned predicatble right now * That returning them will make the number of used ones go down * That allocating more will fail
Diffstat (limited to 'openbsc/src/libmgcp/mgcp_osmux.c')
-rw-r--r--openbsc/src/libmgcp/mgcp_osmux.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c
index 90b73680..b0ef69fd 100644
--- a/openbsc/src/libmgcp/mgcp_osmux.c
+++ b/openbsc/src/libmgcp/mgcp_osmux.c
@@ -532,6 +532,20 @@ int osmux_send_dummy(struct mgcp_endpoint *endp)
/* bsc-nat allocates/releases the Osmux circuit ID */
static uint8_t osmux_cid_bitmap[16];
+int osmux_used_cid(void)
+{
+ int i, j, used = 0;
+
+ for (i = 0; i < sizeof(osmux_cid_bitmap) / 8; i++) {
+ for (j = 0; j < 8; j++) {
+ if (osmux_cid_bitmap[i] & (1 << j))
+ used += 1;
+ }
+ }
+
+ return used;
+}
+
int osmux_get_cid(void)
{
int i, j;