@@ -44,6 +44,8 @@
#include <talloc.h>
#include <stdbool.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+
/*! \brief A single GSM bit
*
* In GSM mac blocks, every bit can be 0 or 1, or L or H. L/H are
@@ -75,6 +77,7 @@ int bitvec_set_uint(struct bitvec *bv, uint32_t 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);
int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit);
+void bitvec_add_range1024(struct bitvec *bv, const struct gsm48_range_1024 *r);
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);
@@ -38,6 +38,7 @@
#include <osmocom/core/bits.h>
#include <osmocom/core/bitvec.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
#define BITNUM_FROM_COMP(byte, bit) ((byte*8)+bit)
@@ -523,6 +524,41 @@ static inline unsigned leading_bits(uint8_t x, bool b)
}
return 7;
}
+
+/*! \brief append range1024 encoded data to bit vector */
+void bitvec_add_range1024(struct bitvec *bv, const struct gsm48_range_1024 *r)
+{
+ bitvec_set_uint(bv, r->w1_hi, 2);
+ bitvec_set_uint(bv, r->w1_lo, 8);
+ bitvec_set_uint(bv, r->w2_hi, 8);
+ bitvec_set_uint(bv, r->w2_lo, 1);
+ bitvec_set_uint(bv, r->w3_hi, 7);
+ bitvec_set_uint(bv, r->w3_lo, 2);
+ bitvec_set_uint(bv, r->w4_hi, 6);
+ bitvec_set_uint(bv, r->w4_lo, 2);
+ bitvec_set_uint(bv, r->w5_hi, 6);
+ bitvec_set_uint(bv, r->w5_lo, 2);
+ bitvec_set_uint(bv, r->w6_hi, 6);
+ bitvec_set_uint(bv, r->w6_lo, 2);
+ bitvec_set_uint(bv, r->w7_hi, 6);
+ bitvec_set_uint(bv, r->w7_lo, 2);
+ bitvec_set_uint(bv, r->w8_hi, 6);
+ bitvec_set_uint(bv, r->w8_lo, 1);
+ bitvec_set_uint(bv, r->w9, 7);
+ bitvec_set_uint(bv, r->w10, 7);
+ bitvec_set_uint(bv, r->w11_hi, 1);
+ bitvec_set_uint(bv, r->w11_lo, 6);
+ bitvec_set_uint(bv, r->w12_hi, 2);
+ bitvec_set_uint(bv, r->w12_lo, 5);
+ bitvec_set_uint(bv, r->w13_hi, 3);
+ bitvec_set_uint(bv, r->w13_lo, 4);
+ bitvec_set_uint(bv, r->w14_hi, 4);
+ bitvec_set_uint(bv, r->w14_lo, 3);
+ bitvec_set_uint(bv, r->w15_hi, 5);
+ bitvec_set_uint(bv, r->w15_lo, 2);
+ bitvec_set_uint(bv, r->w16, 6);
+}
+
/*! \brief force bit vector to all 0 and current bit to the beginnig of the vector */
void bitvec_zero(struct bitvec *bv)
{
From: Max <msuraev@sysmocom.de> Add convenience function to append range1024 encoded data (see 3GPP TS 44.018 Annex J) to a given bitvec. --- include/osmocom/core/bitvec.h | 3 +++ src/bitvec.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)