From 641d387409b6d11f7166784344701438be1a45e1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 2 Oct 2015 15:56:35 +0200 Subject: 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 --- openbsc/src/libmgcp/mgcp_osmux.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'openbsc/src/libmgcp') diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c index 90b73680b..b0ef69fd4 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; -- cgit v1.2.3