summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-01-26 10:43:15 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-26 11:01:23 +0100
commita15f05f1b43d8e85d9a3f72a0a804dcbeca5068c (patch)
treede688231359bf70e649ce032c9183dc2b8d3539d /include
parentfdb46676094c50f1d2dcebfcb5e051c2baf984ac (diff)
Add bitvec-related functions from Osmo-PCU
Allocation, pack/unpack, field access and helper routines used extensively by Osmo-PCU. Whenever memory allocation happens, alocator context is passed explicitly by caller.
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/core/bitvec.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index 2415a814..d64d69dc 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -3,6 +3,7 @@
/* bit vector utility routines */
/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
+ * (C) 2012 Ivan Klyuchnikov
*
* All Rights Reserved
*
@@ -39,6 +40,7 @@
*/
#include <stdint.h>
+#include <talloc.h>
/*! \brief A single GSM bit
*
@@ -73,5 +75,12 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value
int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
int bitvec_get_bytes(struct bitvec *bv, uint8_t *bytes, unsigned int count);
int bitvec_set_bytes(struct bitvec *bv, const uint8_t *bytes, unsigned int count);
+struct bitvec *bitvec_alloc(unsigned int size, TALLOC_CTX *bvctx);
+void bitvec_free(struct bitvec *bv);
+int bitvec_unhex(struct bitvec *bv, const char *src);
+unsigned int bitvec_pack(const struct bitvec *bv, uint8_t *buffer);
+unsigned int bitvec_unpack(struct bitvec *bv, const uint8_t *buffer);
+uint64_t bitvec_read_field(struct bitvec *bv, unsigned int read_index, unsigned int len);
+int bitvec_write_field(struct bitvec *bv, unsigned int write_index, uint64_t val, unsigned int len);
/*! @} */