summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-10-18 13:48:10 +0200
committerMax <msuraev@sysmocom.de>2017-10-24 08:22:02 +0000
commit0b3db5039d25fca3d15ec3375ede77161257db4a (patch)
treee22295c5483ff5c8d7225c0bbcfdf6ddddf444e3 /include
parent9818664315a514b187719792d77723ad9e18dcdf (diff)
Replace bitvec_set_uint() with bitvec_set_u64()
Old bitvec_set_uint() uses "unsigned int" as input parameter which length is not guaranteed. It does not allow to specify which bit_value to set and does not check for incorrect length. Overall this makes it harder to re-use and more error-prone. Let's replace it with extended implementation which uses fixed type length parameters and extra checks. The additional parameter allows caller to explicitly indicate the need to use L/H instead of 0/1 for bit vector elements. It's necessary to properly encode some of the messages from 3GPP TS 44.018, for example ยง10.5.2.16 IA Rest Octets. The old function is left for backward compatibility as a tiny wrapper around new function and will be deprecated in follow-up patches. Change-Id: I1b670dacb55fb3063271d045f9faa10fccba10a6 Related: OS#1526
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/core/bitvec.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h
index d4c7d680..19466abb 100644
--- a/include/osmocom/core/bitvec.h
+++ b/include/osmocom/core/bitvec.h
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/defs.h>
#include <stdbool.h>
/*! A single GSM bit
@@ -57,6 +58,7 @@ int bitvec_set_bit_pos(struct bitvec *bv, unsigned int bitnum,
int bitvec_set_bit(struct bitvec *bv, enum bit_value bit);
int bitvec_get_bit_high(struct bitvec *bv);
int bitvec_set_bits(struct bitvec *bv, const enum bit_value *bits, unsigned int count);
+int bitvec_set_u64(struct bitvec *bv, uint64_t v, uint8_t num_bits, bool use_lh);
int bitvec_set_uint(struct bitvec *bv, unsigned int in, unsigned int count);
int bitvec_get_uint(struct bitvec *bv, unsigned int num_bits);
int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value val);