aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2017-02-04 03:10:08 +0100
committerHarald Welte <laforge@gnumonks.org>2017-05-15 12:46:33 +0000
commitccde5c9557382f56a40e0c94fc29eca8bd886c1c (patch)
treee95b2f38979060d05161d7b5f0470a2e8b233669
parent3de6d0602f4c0c70b87d303161e154746a74b50d (diff)
remove pcu own bitvector implementation
The osmocore bitvec is exact the same, but use a pointer instead of a reference. Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bitvector.cpp120
-rw-r--r--src/bitvector.h52
-rw-r--r--src/bts.cpp8
-rw-r--r--src/csn1.cpp210
-rw-r--r--src/csn1.h5
-rw-r--r--src/egprs_rlc_compression.cpp6
-rw-r--r--src/encoding.cpp548
-rw-r--r--src/gprs_bssgp_pcu.cpp2
-rw-r--r--src/gprs_rlcmac.cpp2
-rw-r--r--src/gprs_rlcmac.h2
-rw-r--r--src/gsm_rlcmac.cpp124
-rw-r--r--src/pcu_main.cpp1
-rw-r--r--src/tbf.cpp6
-rw-r--r--src/tbf_ul.cpp2
-rw-r--r--tests/rlcmac/RLCMACTest.cpp24
-rw-r--r--tests/tbf/TbfTest.cpp4
-rw-r--r--tests/types/TypesTest.cpp2
18 files changed, 475 insertions, 645 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7cc239b..97de06d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,7 +46,6 @@ libgprs_la_SOURCES = \
gprs_ms.cpp \
gprs_ms_storage.cpp \
gsm_timer.cpp \
- bitvector.cpp \
pcu_l1_if.cpp \
pcu_vty.c \
pcu_vty_functions.cpp \
@@ -80,7 +79,6 @@ noinst_HEADERS = \
gprs_ms_storage.h \
pcu_l1_if.h \
gsm_timer.h \
- bitvector.h \
pcu_vty.h \
pcu_vty_functions.h \
tbf.h \
diff --git a/src/bitvector.cpp b/src/bitvector.cpp
deleted file mode 100644
index dcb3baf..0000000
--- a/src/bitvector.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* bitvector.cpp
- *
- * Copyright (C) 2012 Ivan Klyuchnikov
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/*! \addtogroup bitvector
- * @{
- */
-
-/*! \file bitvector.cpp
- * \brief Additional functions for Osmocom bit vector abstraction.
- */
-
-#include <bitvector.h>
-extern "C" {
-#include <osmocom/core/talloc.h>
-}
-
-void *bv_tall_ctx;
-
-struct bitvec *bitvec_alloc(unsigned size)
-{
- struct bitvec *bv = talloc_zero(bv_tall_ctx, struct bitvec);
- bv->data_len = size;
- bv->cur_bit = 0;
- bv->data = talloc_zero_array(bv_tall_ctx, uint8_t, size);
- return bv;
-}
-
-void bitvec_free(struct bitvec *bv)
-{
- talloc_free(bv->data);
- talloc_free(bv);
-}
-
-unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer)
-{
- unsigned int i = 0;
- for (i = 0; i < bv->data_len; i++)
- {
- buffer[i] = bv->data[i];
- }
- return i;
-}
-
-unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer)
-{
- unsigned int i = 0;
- for (i = 0; i < bv->data_len; i++)
- {
- bv->data[i] = buffer[i];
- }
- return i;
-}
-
-
-int bitvec_unhex(struct bitvec *bv, const char* src)
-{
- unsigned val;
- unsigned write_index = 0;
- unsigned digits = bv->data_len*2;
- for (unsigned i=0; i<digits; i++) {
- if (sscanf(src+i, "%1x", &val) < 1) {
- return 1;
- }
- bitvec_write_field(bv, write_index,val, 4);
- }
- return 0;
-}
-
-uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len)
-{
- unsigned int i;
- uint64_t ui = 0;
- bv->cur_bit = read_index;
-
- for (i = 0; i < len; i++) {
- int bit = bitvec_get_bit_pos((const struct bitvec *)bv, bv->cur_bit);
- if (bit < 0)
- return bit;
- if (bit)
- ui |= ((uint64_t)1 << (len - i - 1));
- bv->cur_bit++;
- }
- read_index += len;
- return ui;
-}
-
-
-int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index,
- uint64_t val, unsigned len)
-{
- unsigned int i;
- int rc;
- bv->cur_bit = write_index;
- for (i = 0; i < len; i++) {
- bit_value bit = L;
- if (val & ((uint64_t)1 << (len - i - 1)))
- bit = H;
- rc = bitvec_set_bit(bv, bit);
- if (rc)
- return rc;
- }
- write_index += len;
- return 0;
-}
diff --git a/src/bitvector.h b/src/bitvector.h
deleted file mode 100644
index 246824d..0000000
--- a/src/bitvector.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* bitvector.h
- *
- * Copyright (C) 2012 Ivan Klyuchnikov
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef BITVECTOR_H
-#define BITVECTOR_H
-
-/*! \defgroup bitvector Bit vectors
- * @{
- */
-
-/*! \file bitvector.h
- * \brief Additional functions for Osmocom bit vector abstraction.
- */
-
-extern "C" {
-#include <osmocom/core/bitvec.h>
-}
-
-struct bitvec *bitvec_alloc(unsigned size);
-void bitvec_free(struct bitvec *bv);
-int bitvec_unhex(struct bitvec *bv, const char* src);
-unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer);
-unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer);
-uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len);
-int bitvec_write_field_lh(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len);
-
-
-static inline int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len)
-{
- /* Call the libosmocore variant */
- return ::bitvec_write_field(bv, &write_index, val, len);
-}
-
-/*! }@ */
-
-#endif // BITVECTOR_H
diff --git a/src/bts.cpp b/src/bts.cpp
index c36647e..e25c47b 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -666,7 +666,7 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit,
tsc = tbf->tsc();
}
}
- bitvec *immediate_assignment = bitvec_alloc(22) /* without plen */;
+ bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx) /* without plen */;
bitvec_unhex(immediate_assignment,
"2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
@@ -806,7 +806,7 @@ void BTS::snd_dl_ass(gprs_rlcmac_tbf *tbf, uint8_t poll, const char *imsi)
unsigned int ts = tbf->first_ts;
LOGP(DRLCMAC, LOGL_INFO, "TX: START %s Immediate Assignment Downlink (PCH)\n", tbf_name(tbf));
- bitvec *immediate_assignment = bitvec_alloc(22); /* without plen */
+ bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx); /* without plen */
bitvec_unhex(immediate_assignment, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
/* use request reference that has maximum distance to current time,
* so the assignment will not conflict with possible RACH requests. */
@@ -904,7 +904,7 @@ struct msgb *gprs_rlcmac_pdch::packet_paging_request()
talloc_free(pag);
return NULL;
}
- bitvec *pag_vec = bitvec_alloc(23);
+ bitvec *pag_vec = bitvec_alloc(23, tall_pcu_ctx);
if (!pag_vec) {
msgb_free(msg);
talloc_free(pag);
@@ -1625,7 +1625,7 @@ int gprs_rlcmac_pdch::rcv_block_gprs(uint8_t *data, uint32_t fn,
rc = rcv_data_block(data, fn, meas, cs);
break;
case GPRS_RLCMAC_CONTROL_BLOCK:
- block = bitvec_alloc(len);
+ block = bitvec_alloc(len, tall_pcu_ctx);
if (!block)
return -ENOMEM;
bitvec_unpack(block, data);
diff --git a/src/csn1.cpp b/src/csn1.cpp
index a1698a5..6203a44 100644
--- a/src/csn1.cpp
+++ b/src/csn1.cpp
@@ -64,15 +64,15 @@ get_masked_bits8( bitvec *vector, unsigned& readIndex, gint bit_offset, const g
readIndex -= relative_bit_offset;
if (bit_shift >= 0)
{
- result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> bit_shift;
+ result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> bit_shift;
readIndex-= bit_shift;
result &= maskBits[no_of_bits];
}
else
{
- guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) & maskBits[8 - relative_bit_offset];
+ guint8 hight_part = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) & maskBits[8 - relative_bit_offset];
hight_part = (guint8) (hight_part << (-bit_shift));
- result = (0x2B ^ ((guint8)bitvec_read_field(vector, readIndex, 8))) >> (8 + bit_shift);
+ result = (0x2B ^ ((guint8)bitvec_read_field(vector, &readIndex, 8))) >> (8 + bit_shift);
readIndex = readIndex - (8 - (-bit_shift));
result |= hight_part;
}
@@ -133,7 +133,7 @@ ProcessError( unsigned readIndex, const char* sz, gint16 err, const CSN_DESCR* p
static gboolean
existNextElement(bitvec *vector, unsigned& readIndex, guint8 Tag)
{
- guint8 res = bitvec_read_field(vector, readIndex, 1);
+ guint8 res = bitvec_read_field(vector, &readIndex, 1);
if (Tag == STANDARD_TAG)
{
return (res > 0);
@@ -167,7 +167,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (remaining_bits_len > 0)
{
pui8 = pui8DATA(data, pDescr->offset);
- *pui8 = bitvec_read_field(vector, readIndex, 1);
+ *pui8 = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
/* end add the bit value to protocol tree */
}
@@ -202,21 +202,21 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
if (no_of_bits <= 8)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
- guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui16 = pui16DATA(data, pDescr->offset);
*pui16 = ui16;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
- guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32;
LOGPC(DCSN1, LOGL_NOTICE, "%s = 0x%08x | ", pDescr->sz , *pui32);
@@ -264,21 +264,21 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
if (no_of_bits <= 8)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8 + (guint8)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
- guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui16 = pui16DATA(data, pDescr->offset);
*pui16 = ui16 + (guint16)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
- guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32 + (guint16)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
@@ -308,7 +308,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
remaining_bits_len -= no_of_bits;
if (no_of_bits <= 8)
{
- guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits);
+ guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
@@ -347,7 +347,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
pui8 = pui8DATA(data, pDescr->offset);
do
{
- *pui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += no_of_bits;
@@ -401,7 +401,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
if (Status >= 0)
{
pui8 += nSize;
@@ -430,7 +430,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
for(unsigned ib = 0; ib < 4; ib++)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, 8);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, 8);
pui8 = pui8DATA(data, pDescr->offset+ib);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8);
@@ -440,7 +440,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
for(unsigned ib = 0; ib < 8; ib++)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, 8);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, 8);
pui8 = pui8DATA(data, pDescr->offset+ib);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8);
@@ -467,7 +467,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
csnStream_t arT = *ar;
LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset));
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset));
LOGPC(DCSN1, LOGL_NOTICE, ": End %s | ", pDescr->sz);
if (Status >= 0)
{
@@ -493,7 +493,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
while (count > 0)
{
guint8 no_of_bits = pChoice->bits;
- guint8 value = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint8 value = bitvec_read_field(vector, &readIndex, no_of_bits);
if (value == pChoice->value)
{
CSN_DESCR descr[2];
@@ -510,7 +510,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
remaining_bits_len -= no_of_bits;
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, descr, vector, readIndex, data);
+ Status = csnStreamDecoder(&arT, descr, vector, readIndex, data);
if (Status >= 0)
{
@@ -541,7 +541,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
guint8 length_len = pDescr->i;
gint16 Status = -1;
- guint8 length = bitvec_read_field(vector, readIndex, length_len);
+ guint8 length = bitvec_read_field(vector, &readIndex, length_len);
LOGPC(DCSN1, LOGL_NOTICE, "%s length = %d | ", pDescr->sz , (int)length);
bit_offset += length_len;
@@ -550,7 +550,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
csnStreamInit(&arT, bit_offset, length);
arT.direction = 1;
LOGPC(DCSN1, LOGL_NOTICE, "ptr = %p | offset = %d | ", (void *)data, (int)pDescr->offset);
- Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset));
+ Status = serialize(&arT, vector, readIndex, pvDATA(data, pDescr->offset));
if (Status >= 0)
{
@@ -595,7 +595,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
}
else
{
- index |= bitvec_read_field(vector, readIndex, 1);
+ index |= bitvec_read_field(vector, &readIndex, 1);
}
remaining_bits_len--;
bit_offset++;
@@ -618,7 +618,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = 0x00;
- if (bitvec_read_field(vector, readIndex, 1) > 0)
+ if (bitvec_read_field(vector, &readIndex, 1) > 0)
{
*pui8 = 0x01;
}
@@ -644,21 +644,21 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (no_of_bits <= 8)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
- guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui16 = pui16DATA(data, pDescr->offset);
*pui16 = ui16;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
- guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
@@ -686,21 +686,21 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
if (no_of_bits <= 8)
{
- guint8 ui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint8 ui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8 + (guint8)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
- guint16 ui16 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint16 ui16 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui16 = pui16DATA(data, pDescr->offset);
*pui16 = ui16 + (guint16)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
- guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32 + (guint16)pDescr->descr.value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
@@ -728,7 +728,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
if (no_of_bits <= 8)
{
- guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits);
+ guint8 ui8 = get_masked_bits8(vector, readIndex, bit_offset, no_of_bits);
pui8 = pui8DATA(data, pDescr->offset);
*pui8 = ui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
@@ -767,7 +767,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
while (nCount > 0)
{
- *pui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += no_of_bits;
@@ -780,7 +780,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
while (nCount > 0)
{
- *pui16 = bitvec_read_field(vector, readIndex, no_of_bits);
+ *pui16 = bitvec_read_field(vector, &readIndex, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , *pui16);
pui16++;
bit_offset += no_of_bits;
@@ -830,7 +830,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
{
LOGPC(DCSN1, LOGL_NOTICE, "%s | ", pDescr->sz);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
if (Status >= 0)
{
pui8 += nSize;
@@ -856,13 +856,13 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (no_of_bits <= 32)
{
- guint32 ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint32 ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui32 = pui32DATA(data, pDescr->offset);
*pui32 = ui32;
}
else if (no_of_bits <= 64)
{
- guint64 ui64 = bitvec_read_field(vector, readIndex, no_of_bits);
+ guint64 ui64 = bitvec_read_field(vector, &readIndex, no_of_bits);
pui64 = pui64DATA(data, pDescr->offset);
*pui64 = ui64;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64);
@@ -888,7 +888,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
csnStream_t arT = *ar;
LOGPC(DCSN1, LOGL_NOTICE, " : %s | ", pDescr->sz);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset));
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pvDATA(data, pDescr->offset));
LOGPC(DCSN1, LOGL_NOTICE, " : End %s | ", pDescr->sz);
if (Status >= 0)
{
@@ -923,11 +923,11 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (CSN_EXIST_LH == pDescr->type)
{
- fExist = get_masked_bits8(vector, readIndex, bit_offset, 1);
+ fExist = get_masked_bits8(vector, readIndex, bit_offset, 1);
}
else
{
- fExist = bitvec_read_field(vector, readIndex, 1);
+ fExist = bitvec_read_field(vector, &readIndex, 1);
}
*pui8 = fExist;
@@ -966,7 +966,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
/* the "regular" M_NEXT_EXIST description element */
fExist = 0x00;
- if (bitvec_read_field(vector, readIndex, 1))
+ if (bitvec_read_field(vector, &readIndex, 1))
{
fExist = 0x01;
}
@@ -1059,7 +1059,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (nB1 > 0)
{ /* take care of the first byte - it will be right aligned */
- *pui8 = bitvec_read_field(vector, readIndex, nB1);
+ *pui8 = bitvec_read_field(vector, &readIndex, nB1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= nB1;
@@ -1069,7 +1069,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
/* remaining no_of_bits is a multiple of 8 or 0 */
while (no_of_bits > 0)
{
- *pui8 = bitvec_read_field(vector, readIndex, 8);
+ *pui8 = bitvec_read_field(vector, &readIndex, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= 8;
@@ -1113,14 +1113,14 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
while (no_of_bits >= 8)
{
- *pui8 = bitvec_read_field(vector, readIndex, 8);
+ *pui8 = bitvec_read_field(vector, &readIndex, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= 8;
}
if (no_of_bits > 0)
{
- *pui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += no_of_bits;
@@ -1144,13 +1144,13 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
guint8 bits_to_handle = remaining_bits_len%8;
if (bits_to_handle > 0)
{
- LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, bits_to_handle));
+ LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, bits_to_handle));
remaining_bits_len -= bits_to_handle;
bit_offset += bits_to_handle;
}
else if (bits_to_handle == 0)
{
- LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, readIndex, 8));
+ LOGPC(DCSN1, LOGL_NOTICE, "%" PRIu64 "|", bitvec_read_field(vector, &readIndex, 8));
remaining_bits_len -= 8;
bit_offset += 8;
}
@@ -1191,7 +1191,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
while (count > 0)
{
readIndex -= 8;
- *pui8 = bitvec_read_field(vector, readIndex, 8);
+ *pui8 = bitvec_read_field(vector, &readIndex, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += 8;
@@ -1217,14 +1217,14 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
pui8 = pui8DATA(data, pDescr->offset);
- while (existNextElement(vector, readIndex, Tag))
+ while (existNextElement(vector, readIndex, Tag))
{ /* tag control shows existence of next list elements */
LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz);
bit_offset++;
remaining_bits_len--;
/* extract and store no_of_bits long element from bitstream */
- *pui8 = bitvec_read_field(vector, readIndex, no_of_bits);
+ *pui8 = bitvec_read_field(vector, &readIndex, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
remaining_bits_len -= no_of_bits;
@@ -1238,7 +1238,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
bit_offset += no_of_bits;
}
- LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1));
+ LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1));
/* existNextElement() returned FALSE, 1 bit consumed */
bit_offset++;
@@ -1258,7 +1258,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
guint8 ElementCount = 0;
pui8 = pui8DATA(data, pDescr->offset);
- while (existNextElement(vector, readIndex, Tag))
+ while (existNextElement(vector, readIndex, Tag))
{ /* tag control shows existence of next list elements */
LOGPC(DCSN1, LOGL_NOTICE, "%s = Exist | ", pDescr->sz);
/* existNextElement() returned TRUE, 1 bit consumed */
@@ -1270,7 +1270,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
csnStream_t arT = *ar;
gint16 Status;
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
if (Status >= 0)
{ /* successful completion */
@@ -1290,7 +1290,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
}
}
- LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, readIndex, 1));
+ LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)bitvec_read_field(vector, &readIndex, 1));
/* existNextElement() returned FALSE, 1 bit consumed */
bit_offset++;
@@ -1331,7 +1331,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
LOGPC(DCSN1, LOGL_NOTICE, "%s { | ", pDescr->sz);
csnStreamInit(&arT, bit_offset, remaining_bits_len);
- Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
+ Status = csnStreamDecoder(&arT, (const CSN_DESCR*)pDescr->descr.ptr, vector, readIndex, pui8);
if (Status >= 0)
{ /* successful completion */
@@ -1351,7 +1351,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
/* control of next element's tag */
LOGPC(DCSN1, LOGL_NOTICE, "%s } | ", pDescr->sz);
- EndOfList = !(existNextElement(vector, readIndex, Tag));
+ EndOfList = !(existNextElement(vector, readIndex, Tag));
bit_offset++;
remaining_bits_len--; /* 1 bit consumed (tag) */
@@ -1372,7 +1372,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig
if (no_of_bits <= 32)
{
- ui32 = bitvec_read_field(vector, readIndex, no_of_bits);
+ ui32 = bitvec_read_field(vector, &readIndex, no_of_bits);
}
else
{
@@ -1449,7 +1449,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (remaining_bits_len > 0)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, 1);
+ bitvec_write_field(vector, &writeIndex, *pui8, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
/* end add the bit value to protocol tree */
}
@@ -1483,19 +1483,19 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
pui16 = pui16DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui16, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
pui32 = pui32DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui32, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
}
else
@@ -1528,19 +1528,19 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value));
}
else if (no_of_bits <= 16)
{
pui16 = pui16DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value));
}
else if (no_of_bits <= 32)
{
pui32 = pui32DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value));
}
else
@@ -1569,12 +1569,12 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
// TODO : Change get_masked_bits8()
writeIndex -= no_of_bits;
guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits);
writeIndex -= no_of_bits;
- bitvec_write_field(vector, writeIndex, ui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, ui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
@@ -1612,7 +1612,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
pui8 = pui8DATA(data, pDescr->offset);
do
{
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += no_of_bits;
@@ -1697,7 +1697,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
for(unsigned ib = 0; ib < 4; ib++)
{
pui8 = pui8DATA(data, pDescr->offset+ib);
- bitvec_write_field(vector, writeIndex, *pui8, 8);
+ bitvec_write_field(vector, &writeIndex, *pui8, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8);
}
}
@@ -1706,7 +1706,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
for(unsigned ib = 0; ib < 8; ib++)
{
pui8 = pui8DATA(data, pDescr->offset+ib);
- bitvec_write_field(vector, writeIndex, *pui8, 8);
+ bitvec_write_field(vector, &writeIndex, *pui8, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s[%u] = %u | ", pDescr->sz , ib, (unsigned)*pui8);
}
}
@@ -1761,7 +1761,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
guint8 no_of_bits = pChoice->bits;
guint8 value = pChoice->value;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pChoice->descr.sz , (unsigned)value);
- bitvec_write_field(vector, writeIndex, value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, value, no_of_bits);
CSN_DESCR descr[2];
gint16 Status;
@@ -1807,7 +1807,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
csnStreamInit(&arT, bit_offset, remaining_bits_len);
Status = serialize(&arT, vector, writeIndex, pvDATA(data, pDescr->offset));
- bitvec_write_field(vector, lengthIndex, writeIndex-lengthIndex-length_len, length_len);
+ bitvec_write_field(vector, &lengthIndex, writeIndex-lengthIndex-length_len, length_len);
LOGPC(DCSN1, LOGL_NOTICE, "%s length = %u | ", pDescr->sz , (unsigned)(writeIndex-lengthIndex));
if (Status >= 0)
@@ -1846,7 +1846,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
/* Assign UnionType */
pui8 = pui8DATA(data, pDescr->offset);
//read index from data and write to vector
- bitvec_write_field(vector, writeIndex, *pui8, Bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, Bits);
//decode index
writeIndex -= Bits;
@@ -1861,7 +1861,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
else
{
- index |= bitvec_read_field(vector, writeIndex, 1);
+ index |= bitvec_read_field(vector, &writeIndex, 1);
}
remaining_bits_len--;
@@ -1870,7 +1870,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
writeIndex -= Bits;
- bitvec_write_field(vector, writeIndex, index, Bits);
+ bitvec_write_field(vector, &writeIndex, index, Bits);
/* script index to continue on, limited in case we do not have a power of 2 */
@@ -1883,7 +1883,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
case CSN_BIT:
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, 1);
+ bitvec_write_field(vector, &writeIndex, *pui8, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
remaining_bits_len -= 1;
bit_offset++;
@@ -1907,19 +1907,19 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
else if (no_of_bits <= 16)
{
pui16 = pui16DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui16, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui16, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui16);
}
else if (no_of_bits <= 32)
{
pui32 = pui32DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui32, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
}
else
@@ -1946,19 +1946,19 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8 - (guint8)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(*pui8 - (guint8)pDescr->descr.value));
}
else if (no_of_bits <= 16)
{
pui16 = pui16DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui16 - (guint16)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned short)(*pui16 - (guint16)pDescr->descr.value));
}
else if (no_of_bits <= 32)
{
pui32 = pui32DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui32 - (guint16)pDescr->descr.value, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , (unsigned int)(*pui32 - (guint16)pDescr->descr.value));
}
else
@@ -1987,12 +1987,12 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 8)
{
pui8 = pui8DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
// TODO : Change get_masked_bits8()
writeIndex -= no_of_bits;
guint8 ui8 = get_masked_bits8(vector, writeIndex, bit_offset, no_of_bits);
writeIndex -= no_of_bits;
- bitvec_write_field(vector, writeIndex, ui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, ui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
}
@@ -2030,7 +2030,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
pui8 = pui8DATA(data, pDescr->offset);
do
{
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += no_of_bits;
@@ -2112,13 +2112,13 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (no_of_bits <= 32)
{
pui32 = pui32DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui32, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui32, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui32);
}
else if (no_of_bits <= 64)
{
pui64 = pui64DATA(data, pDescr->offset);
- bitvec_write_field(vector, writeIndex, *pui64, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui64, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64);
}
else
@@ -2176,7 +2176,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
unsigned exist = 0;
pui8 = pui8DATA(data, pDescr->offset);
exist = *pui8;
- bitvec_write_field(vector, writeIndex, *pui8, 1);
+ bitvec_write_field(vector, &writeIndex, *pui8, 1);
writeIndex--;
if (CSN_EXIST_LH == pDescr->type)
{
@@ -2184,10 +2184,10 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
else
{
- fExist = bitvec_read_field(vector, writeIndex, 1);
+ fExist = bitvec_read_field(vector, &writeIndex, 1);
}
writeIndex--;
- bitvec_write_field(vector, writeIndex, fExist, 1);
+ bitvec_write_field(vector, &writeIndex, fExist, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz, (unsigned)fExist);
pDescr++;
remaining_bits_len -= 1;
@@ -2217,7 +2217,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
break;
}
- bitvec_write_field(vector, writeIndex, *pui8, 1);
+ bitvec_write_field(vector, &writeIndex, *pui8, 1);
fExist = *pui8;
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
remaining_bits_len -= 1;
@@ -2257,11 +2257,11 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
/* the "regular" M_NEXT_EXIST_LH description element */
- bitvec_write_field(vector, writeIndex, *pui8, 1);
+ bitvec_write_field(vector, &writeIndex, *pui8, 1);
writeIndex--;
fExist = get_masked_bits8(vector,writeIndex, bit_offset, 1);
writeIndex--;
- bitvec_write_field(vector, writeIndex, fExist, 1);
+ bitvec_write_field(vector, &writeIndex, fExist, 1);
pui8++;
remaining_bits_len -= 1;
@@ -2310,7 +2310,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
if (nB1 > 0)
{ /* take care of the first byte - it will be right aligned */
- bitvec_write_field(vector, writeIndex, *pui8, nB1);
+ bitvec_write_field(vector, &writeIndex, *pui8, nB1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= nB1;
@@ -2320,7 +2320,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
/* remaining no_of_bits is a multiple of 8 or 0 */
while (no_of_bits > 0)
{
- bitvec_write_field(vector, writeIndex, *pui8, 8);
+ bitvec_write_field(vector, &writeIndex, *pui8, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= 8;
@@ -2366,14 +2366,14 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
while (no_of_bits > 0)
{
- bitvec_write_field(vector, writeIndex, *pui8, 8);
+ bitvec_write_field(vector, &writeIndex, *pui8, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= 8;
}
if (nB1 > 0)
{
- bitvec_write_field(vector, writeIndex, *pui8, nB1);
+ bitvec_write_field(vector, &writeIndex, *pui8, nB1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
no_of_bits -= nB1;
@@ -2405,14 +2405,14 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
* < padding bits > ::= { null | 0 < spare padding > ! < Ignore : 1 bit** = < no string > > } ;
*/
guint8 fl = filler&(0xff>>(8-bits_to_handle + 1));
- bitvec_write_field(vector, writeIndex, fl, bits_to_handle);
+ bitvec_write_field(vector, &writeIndex, fl, bits_to_handle);
LOGPC(DCSN1, LOGL_NOTICE, "%u|", fl);
remaining_bits_len -= bits_to_handle;
bit_offset += bits_to_handle;
}
else if (bits_to_handle == 0)
{
- bitvec_write_field(vector, writeIndex, filler, 8);
+ bitvec_write_field(vector, &writeIndex, filler, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%u|", filler);
remaining_bits_len -= 8;
bit_offset += 8;
@@ -2453,7 +2453,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
while (count > 0)
{
- bitvec_write_field(vector, writeIndex, *pui8, 8);
+ bitvec_write_field(vector, &writeIndex, *pui8, 8);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
bit_offset += 8;
@@ -2480,13 +2480,13 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
ElementCount = *pui8DATA(data, (gint16)pDescr->descr.value);
while (ElementCount > 0)
{ /* tag control shows existence of next list elements */
- bitvec_write_field(vector, writeIndex, Tag, 1);
+ bitvec_write_field(vector, &writeIndex, Tag, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag);
bit_offset++;
remaining_bits_len--;
/* extract and store no_of_bits long element from bitstream */
- bitvec_write_field(vector, writeIndex, *pui8, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, *pui8, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)*pui8);
pui8++;
remaining_bits_len -= no_of_bits;
@@ -2500,7 +2500,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
bit_offset += no_of_bits;
}
- bitvec_write_field(vector, writeIndex, !Tag, 1);
+ bitvec_write_field(vector, &writeIndex, !Tag, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag));
bit_offset++;
remaining_bits_len--;
@@ -2522,7 +2522,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
while (ElementCount > 0)
{ /* tag control shows existence of next list elements */
- bitvec_write_field(vector, writeIndex, Tag, 1);
+ bitvec_write_field(vector, &writeIndex, Tag, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag);
bit_offset++;
@@ -2553,7 +2553,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
}
- bitvec_write_field(vector, writeIndex, !Tag, 1);
+ bitvec_write_field(vector, &writeIndex, !Tag, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)(!Tag));
bit_offset++;
@@ -2591,7 +2591,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
{ /* get data element */
if (ElementCount != ElementNum)
{
- bitvec_write_field(vector, writeIndex, Tag, 1);
+ bitvec_write_field(vector, &writeIndex, Tag, 1);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)Tag);
bit_offset++;
remaining_bits_len--;
@@ -2618,7 +2618,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
}
}
- bitvec_write_field(vector, writeIndex, !Tag, 1);
+ bitvec_write_field(vector, &writeIndex, !Tag, 1);
bit_offset++;
remaining_bits_len--;
Tag = STANDARD_TAG; /* in case it was set to "reversed" */
@@ -2629,7 +2629,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector
case CSN_FIXED:
{ /* Verify the fixed bits */
guint8 no_of_bits = (guint8) pDescr->i;
- bitvec_write_field(vector, writeIndex, pDescr->offset, no_of_bits);
+ bitvec_write_field(vector, &writeIndex, pDescr->offset, no_of_bits);
LOGPC(DCSN1, LOGL_NOTICE, "%s = %u | ", pDescr->sz , (unsigned)pDescr->offset);
remaining_bits_len -= no_of_bits;
bit_offset += no_of_bits;
diff --git a/src/csn1.h b/src/csn1.h
index 96f7558..3f5b849 100644
--- a/src/csn1.h
+++ b/src/csn1.h
@@ -25,7 +25,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <bitvector.h>
+extern "C" {
+#include <osmocom/core/bitvec.h>
+}
+
#include <iostream>
#include <cstdlib>
#ifndef _PACKET_CSN1_H_
diff --git a/src/egprs_rlc_compression.cpp b/src/egprs_rlc_compression.cpp
index 82605ff..7eeb7d2 100644
--- a/src/egprs_rlc_compression.cpp
+++ b/src/egprs_rlc_compression.cpp
@@ -528,10 +528,10 @@ int egprs_compress::decompress_crbb(
/* put run length of Ones in uncompressed bitmap */
while (run_length != 0) {
if (run_length > 8) {
- bitvec_write_field(dest, wp, data, 8);
+ bitvec_write_field(dest, &wp, data, 8);
run_length = run_length - 8;
} else {
- bitvec_write_field(dest, wp, data, run_length);
+ bitvec_write_field(dest, &wp, data, run_length);
run_length = 0;
}
}
@@ -581,7 +581,7 @@ static void compress_bitmap(
*codewrd_bitmap = t4_term[start][*run_len_cnt];
*codewrd_len = t4_term_length[start][*run_len_cnt];
}
- bitvec_write_field(crbb_vec, writeIndex, *codewrd_bitmap, *codewrd_len);
+ bitvec_write_field(crbb_vec, &writeIndex, *codewrd_bitmap, *codewrd_len);
}
/* Compress received block bitmap */
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 2f052a4..6742efd 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -40,12 +40,12 @@ extern "C" {
static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai)
{
if (tai < 0) { /* No TIMING_ADVANCE_INDEX: */
- bitvec_write_field(dest, wp, 0, 1);
+ bitvec_write_field(dest, &wp, 0, 1);
return false;
}
/* TIMING_ADVANCE_INDEX: */
- bitvec_write_field(dest, wp, 1, 1);
- bitvec_write_field(dest, wp, tai, 4);
+ bitvec_write_field(dest, &wp, 1, 1);
+ bitvec_write_field(dest, &wp, tai, 4);
return true;
}
@@ -53,10 +53,10 @@ static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai)
static inline void write_ta(bitvec *dest, unsigned& wp, int8_t ta)
{
if (ta < 0) /* No TIMING_ADVANCE_VALUE: */
- bitvec_write_field(dest, wp, 0, 1);
+ bitvec_write_field(dest, &wp, 0, 1);
else { /* TIMING_ADVANCE_VALUE: */
- bitvec_write_field(dest, wp, 1, 1);
- bitvec_write_field(dest, wp, ta, 6);
+ bitvec_write_field(dest, &wp, 1, 1);
+ bitvec_write_field(dest, &wp, ta, 6);
}
}
@@ -70,7 +70,7 @@ static inline void write_ta_ie(bitvec *dest, unsigned& wp,
{
write_ta(dest, wp, ta);
if (write_tai(dest, wp, tai)) /* TIMING_ADVANCE_TIMESLOT_NUMBER: */
- bitvec_write_field(dest, wp, ts, 3);
+ bitvec_write_field(dest, &wp, ts, 3);
}
static int write_ia_rest_downlink(
@@ -85,40 +85,40 @@ static int write_ia_rest_downlink(
return -EINVAL;
}
// GSM 04.08 10.5.2.16 IA Rest Octets
- bitvec_write_field_lh(dest, wp, 3, 2); // "HH"
- bitvec_write_field(dest, wp, 1, 2); // "01" Packet Downlink Assignment
- bitvec_write_field(dest, wp,tbf->tlli(),32); // TLLI
- bitvec_write_field(dest, wp,0x1,1); // switch TFI : on
- bitvec_write_field(dest, wp,tbf->tfi(),5); // TFI
- bitvec_write_field(dest, wp,0x0,1); // RLC acknowledged mode
+ bitvec_write_field(dest, &wp, 3, 2); // "HH"
+ bitvec_write_field(dest, &wp, 1, 2); // "01" Packet Downlink Assignment
+ bitvec_write_field(dest, &wp,tbf->tlli(),32); // TLLI
+ bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on
+ bitvec_write_field(dest, &wp,tbf->tfi(),5); // TFI
+ bitvec_write_field(dest, &wp,0x0,1); // RLC acknowledged mode
if (alpha) {
- bitvec_write_field(dest, wp,0x1,1); // ALPHA = present
- bitvec_write_field(dest, wp,alpha,4); // ALPHA
+ bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present
+ bitvec_write_field(dest, &wp,alpha,4); // ALPHA
} else {
- bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present
+ bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present
}
- bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter
- bitvec_write_field(dest, wp,polling,1); // Polling Bit
- bitvec_write_field(dest, wp, ta_valid, 1); // N. B: NOT related to TAI!
+ bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter
+ bitvec_write_field(dest, &wp,polling,1); // Polling Bit
+ bitvec_write_field(dest, &wp, ta_valid, 1); // N. B: NOT related to TAI!
write_tai(dest, wp, ta_idx);
if (polling) {
- bitvec_write_field(dest, wp,0x1,1); // TBF Starting TIME present
- bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1'
- bitvec_write_field(dest, wp,fn % 51,6); // T3
- bitvec_write_field(dest, wp,fn % 26,5); // T2
+ bitvec_write_field(dest, &wp,0x1,1); // TBF Starting TIME present
+ bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1'
+ bitvec_write_field(dest, &wp,fn % 51,6); // T3
+ bitvec_write_field(dest, &wp,fn % 26,5); // T2
} else {
- bitvec_write_field(dest, wp,0x0,1); // TBF Starting TIME present
+ bitvec_write_field(dest, &wp,0x0,1); // TBF Starting TIME present
}
- bitvec_write_field(dest, wp,0x0,1); // P0 not present
- // bitvec_write_field(dest, wp,0x1,1); // P0 not present
- // bitvec_write_field(dest, wp,0xb,4);
+ bitvec_write_field(dest, &wp,0x0,1); // P0 not present
+ // bitvec_write_field(dest, &wp,0x1,1); // P0 not present
+ // bitvec_write_field(dest, &wp,,0xb,4);
if (tbf->is_egprs_enabled()) {
/* see GMS 44.018, 10.5.2.16 */
unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32;
- bitvec_write_field_lh(dest, wp, 1, 1); // "H"
- bitvec_write_field(dest, wp, ws_enc,5); // EGPRS Window Size
- bitvec_write_field(dest, wp, 0x0,2); // LINK_QUALITY_MEASUREMENT_MODE
- bitvec_write_field(dest, wp, 0,1); // BEP_PERIOD2 not present
+ bitvec_write_field(dest, &wp, 1, 1); // "H"
+ bitvec_write_field(dest, &wp, ws_enc, 5); // EGPRS Window Size
+ bitvec_write_field(dest, &wp, 0x0, 2); // LINK_QUALITY_MEASUREMENT_MODE
+ bitvec_write_field(dest, &wp, 0, 1); // BEP_PERIOD2 not present
}
return 0;
@@ -133,40 +133,40 @@ static int write_ia_rest_uplink(
OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled());
// GMS 04.08 10.5.2.37b 10.5.2.16
- bitvec_write_field_lh(dest, wp, 3, 2); // "HH"
- bitvec_write_field(dest, wp, 0, 2); // "0" Packet Uplink Assignment
+ bitvec_write_field(dest, &wp, 3, 2); // "HH"
+ bitvec_write_field(dest, &wp, 0, 2); // "0" Packet Uplink Assignment
if (tbf == NULL) {
- bitvec_write_field(dest, wp, 0, 1); // Block Allocation : Single Block Allocation
+ bitvec_write_field(dest, &wp, 0, 1); // Block Allocation : Single Block Allocation
if (alpha) {
- bitvec_write_field(dest, wp,0x1,1); // ALPHA = present
- bitvec_write_field(dest, wp,alpha,4); // ALPHA = present
+ bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present
+ bitvec_write_field(dest, &wp,alpha,4); // ALPHA = present
} else
- bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present
- bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter
+ bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present
+ bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter
write_tai(dest, wp, ta_idx);
- bitvec_write_field(dest, wp, 1, 1); // TBF_STARTING_TIME_FLAG
- bitvec_write_field(dest, wp,(fn / (26 * 51)) % 32,5); // T1'
- bitvec_write_field(dest, wp,fn % 51,6); // T3
- bitvec_write_field(dest, wp,fn % 26,5); // T2
+ bitvec_write_field(dest, &wp, 1, 1); // TBF_STARTING_TIME_FLAG
+ bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1'
+ bitvec_write_field(dest, &wp,fn % 51,6); // T3
+ bitvec_write_field(dest, &wp,fn % 26,5); // T2
} else {
- bitvec_write_field(dest, wp, 1, 1); // Block Allocation : Not Single Block Allocation
- bitvec_write_field(dest, wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity
- bitvec_write_field(dest, wp, 0, 1); // POLLING
- bitvec_write_field(dest, wp, 0, 1); // ALLOCATION_TYPE: dynamic
- bitvec_write_field(dest, wp, usf, 3); // USF
- bitvec_write_field(dest, wp, 0, 1); // USF_GRANULARITY
- bitvec_write_field(dest, wp, 0, 1); // "0" power control: Not Present
- bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND
- bitvec_write_field(dest, wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING
+ bitvec_write_field(dest, &wp, 1, 1); // Block Allocation : Not Single Block Allocation
+ bitvec_write_field(dest, &wp, tbf->tfi(), 5); // TFI_ASSIGNMENT Temporary Flow Identity
+ bitvec_write_field(dest, &wp, 0, 1); // POLLING
+ bitvec_write_field(dest, &wp, 0, 1); // ALLOCATION_TYPE: dynamic
+ bitvec_write_field(dest, &wp, usf, 3); // USF
+ bitvec_write_field(dest, &wp, 0, 1); // USF_GRANULARITY
+ bitvec_write_field(dest, &wp, 0, 1); // "0" power control: Not Present
+ bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND
+ bitvec_write_field(dest, &wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING
if (alpha) {
- bitvec_write_field(dest, wp,0x1,1); // ALPHA = present
- bitvec_write_field(dest, wp,alpha,4); // ALPHA
+ bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present
+ bitvec_write_field(dest, &wp,alpha,4); // ALPHA
} else
- bitvec_write_field(dest, wp,0x0,1); // ALPHA = not present
- bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter
+ bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present
+ bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter
/* note: there is no choise for TAI and no starting time */
- bitvec_write_field(dest, wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off
- bitvec_write_field(dest, wp, 0, 1); // TBF_STARTING_TIME_FLAG
+ bitvec_write_field(dest, &wp, 0, 1); // switch TIMING_ADVANCE_INDEX = off
+ bitvec_write_field(dest, &wp, 0, 1); // TBF_STARTING_TIME_FLAG
}
return 0;
}
@@ -183,60 +183,60 @@ static int write_ia_rest_egprs_uplink(
extended_ra = (ra & 0x1F);
- bitvec_write_field(dest, wp, 1, 2); /* LH */
- bitvec_write_field(dest, wp, 0, 2); /* 0 EGPRS Uplink Assignment */
- bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */
- bitvec_write_field(dest, wp, 0, 1); /* Access technology Request */
+ bitvec_write_field(dest, &wp, 1, 2); /* LH */
+ bitvec_write_field(dest, &wp, 0, 2); /* 0 EGPRS Uplink Assignment */
+ bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */
+ bitvec_write_field(dest, &wp, 0, 1); /* Access technology Request */
if (tbf == NULL) {
- bitvec_write_field(dest, wp, 0, 1); /* multiblock allocation */
+ bitvec_write_field(dest, &wp, 0, 1); /* multiblock allocation */
if (alpha) {
- bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */
- bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */
+ bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */
+ bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */
} else {
- bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */
+ bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */
}
- bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */
- bitvec_write_field(dest, wp, (fn / (26 * 51)) % 32, 5);/* T1' */
- bitvec_write_field(dest, wp, fn % 51, 6); /* T3 */
- bitvec_write_field(dest, wp, fn % 26, 5); /* T2 */
- bitvec_write_field(dest, wp, 0, 2); /* Radio block allocation */
+ bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */
+ bitvec_write_field(dest, &wp, (fn / (26 * 51)) % 32, 5);/* T1' */
+ bitvec_write_field(dest, &wp, fn % 51, 6); /* T3 */
+ bitvec_write_field(dest, &wp, fn % 26, 5); /* T2 */
+ bitvec_write_field(dest, &wp, 0, 2); /* Radio block allocation */
- bitvec_write_field(dest, wp, 0, 1);
+ bitvec_write_field(dest, &wp, 0, 1);
} else {
ws_enc = (tbf->m_window.ws() - 64) / 32;
- bitvec_write_field(dest, wp, 1, 1); /* single block alloc */
- bitvec_write_field(dest, wp, tbf->tfi(), 5);/* TFI assignment */
- bitvec_write_field(dest, wp, 0, 1); /* polling bit */
- bitvec_write_field(dest, wp, 0, 1); /* constant */
- bitvec_write_field(dest, wp, usf, 3); /* USF bit */
- bitvec_write_field(dest, wp, 0, 1); /* USF granularity */
- bitvec_write_field(dest, wp, 0, 1); /* P0 */
+ bitvec_write_field(dest, &wp, 1, 1); /* single block alloc */
+ bitvec_write_field(dest, &wp, tbf->tfi(), 5);/* TFI assignment */
+ bitvec_write_field(dest, &wp, 0, 1); /* polling bit */
+ bitvec_write_field(dest, &wp, 0, 1); /* constant */
+ bitvec_write_field(dest, &wp, usf, 3); /* USF bit */
+ bitvec_write_field(dest, &wp, 0, 1); /* USF granularity */
+ bitvec_write_field(dest, &wp, 0, 1); /* P0 */
/* MCS */
- bitvec_write_field(dest, wp, tbf->current_cs().to_num()-1, 4);
+ bitvec_write_field(dest, &wp, tbf->current_cs().to_num()-1, 4);
/* tlli channel block */
- bitvec_write_field(dest, wp, tbf->tlli(), 1);
- bitvec_write_field(dest, wp, 0, 1); /* BEP period present */
- bitvec_write_field(dest, wp, 0, 1); /* resegmentation */
- bitvec_write_field(dest, wp, ws_enc, 5);/* egprs window_size */
+ bitvec_write_field(dest, &wp, tbf->tlli(), 1);
+ bitvec_write_field(dest, &wp, 0, 1); /* BEP period present */
+ bitvec_write_field(dest, &wp, 0, 1); /* resegmentation */
+ bitvec_write_field(dest, &wp, ws_enc, 5);/* egprs window_size */
if (alpha) {
- bitvec_write_field(dest, wp, 0x1, 1); /* ALPHA =yes */
- bitvec_write_field(dest, wp, alpha, 4); /* ALPHA */
+ bitvec_write_field(dest, &wp, 0x1, 1); /* ALPHA =yes */
+ bitvec_write_field(dest, &wp, alpha, 4); /* ALPHA */
} else {
- bitvec_write_field(dest, wp, 0x0, 1); /* ALPHA = no */
+ bitvec_write_field(dest, &wp, 0x0, 1); /* ALPHA = no */
}
- bitvec_write_field(dest, wp, gamma, 5); /* GAMMA power contrl */
- bitvec_write_field(dest, wp, 0, 1); /* TIMING_ADVANCE_INDEX */
- bitvec_write_field(dest, wp, 0, 1); /* TBF_STARTING_TIME_FLAG */
- bitvec_write_field(dest, wp, 0, 1); /* NULL */
+ bitvec_write_field(dest, &wp, gamma, 5); /* GAMMA power contrl */
+ bitvec_write_field(dest, &wp, 0, 1); /* TIMING_ADVANCE_INDEX */
+ bitvec_write_field(dest, &wp, 0, 1); /* TBF_STARTING_TIME_FLAG */
+ bitvec_write_field(dest, &wp, 0, 1); /* NULL */
}
return 0;
@@ -255,17 +255,17 @@ int Encoding::write_immediate_assignment_reject(
int plen;
int i;
- bitvec_write_field(dest, wp, 0x0, 4); // Skip Indicator
- bitvec_write_field(dest, wp, 0x6, 4); // Protocol Discriminator
- bitvec_write_field(dest, wp, 0x3A, 8); // Immediate Assign Message Type
+ bitvec_write_field(dest, &wp, 0x0, 4); // Skip Indicator
+ bitvec_write_field(dest, &wp, 0x6, 4); // Protocol Discriminator
+ bitvec_write_field(dest, &wp, 0x3A, 8); // Immediate Assign Message Type
// feature indicator
- bitvec_write_field(dest, wp, 0x0, 1); // spare
- bitvec_write_field(dest, wp, 0x0, 1); // spare
- bitvec_write_field(dest, wp, 0x0, 1); // no cs
- bitvec_write_field(dest, wp, 0x1, 1); // implicit detach for PS
+ bitvec_write_field(dest, &wp, 0x0, 1); // spare
+ bitvec_write_field(dest, &wp, 0x0, 1); // spare
+ bitvec_write_field(dest, &wp, 0x0, 1); // no cs
+ bitvec_write_field(dest, &wp, 0x1, 1); // implicit detach for PS
- bitvec_write_field(dest, wp, 0x0, 4); // Page Mode
+ bitvec_write_field(dest, &wp, 0x0, 4); // Page Mode
/*
* 9.1.20.2 of 44.018 version 11.7.0 Release 11
* Filling of the message
@@ -279,18 +279,18 @@ int Encoding::write_immediate_assignment_reject(
if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
(burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) {
//9.1.20.2a of 44.018 version 11.7.0 Release 11
- bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */
+ bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */
} else {
- bitvec_write_field(dest, wp, ra, 8); /* RACH value */
+ bitvec_write_field(dest, &wp, ra, 8); /* RACH value */
}
- bitvec_write_field(dest, wp,
+ bitvec_write_field(dest, &wp,
(ref_fn / (26 * 51)) % 32, 5); // T1'
- bitvec_write_field(dest, wp, ref_fn % 51, 6); // T3
- bitvec_write_field(dest, wp, ref_fn % 26, 5); // T2
+ bitvec_write_field(dest, &wp, ref_fn % 51, 6); // T3
+ bitvec_write_field(dest, &wp, ref_fn % 26, 5); // T2
/* TODO: Make it configurable */
- bitvec_write_field(dest, wp, 20, 8); //Wait Indication 1
+ bitvec_write_field(dest, &wp, 20, 8); //Wait Indication 1
}
plen = wp / 8;
@@ -308,14 +308,14 @@ int Encoding::write_immediate_assignment_reject(
uint8_t extended_ra = 0;
extended_ra = (ra & 0x1F);
- bitvec_write_field(dest, wp, 0x1, 1);
- bitvec_write_field(dest, wp, extended_ra, 5); /* Extended RA */
+ bitvec_write_field(dest, &wp, 0x1, 1);
+ bitvec_write_field(dest, &wp, extended_ra, 5); /* Extended RA */
} else {
- bitvec_write_field(dest, wp, 0x0, 1);
+ bitvec_write_field(dest, &wp, 0x0, 1);
}
- bitvec_write_field(dest, wp, 0x0, 1);
- bitvec_write_field(dest, wp, 0x0, 1);
- bitvec_write_field(dest, wp, 0x0, 1);
+ bitvec_write_field(dest, &wp, 0x0, 1);
+ bitvec_write_field(dest, &wp, 0x0, 1);
+ bitvec_write_field(dest, &wp, 0x0, 1);
return plen;
}
@@ -342,44 +342,44 @@ int Encoding::write_immediate_assignment(
int plen;
int rc;
- bitvec_write_field(dest, wp,0x0,4); // Skip Indicator
- bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator
- bitvec_write_field(dest, wp,0x3F,8); // Immediate Assignment Message Type
+ bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator
+ bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator
+ bitvec_write_field(dest, &wp,0x3F,8); // Immediate Assignment Message Type
// 10.5.2.25b Dedicated mode or TBF
- bitvec_write_field(dest, wp,0x0,1); // spare
- bitvec_write_field(dest, wp,0x0,1); // TMA : Two-message assignment: No meaning
- bitvec_write_field(dest, wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode
- bitvec_write_field(dest, wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF).
+ bitvec_write_field(dest, &wp,0x0,1); // spare
+ bitvec_write_field(dest, &wp,0x0,1); // TMA : Two-message assignment: No meaning
+ bitvec_write_field(dest, &wp,downlink,1); // Downlink : Downlink assignment to mobile in packet idle mode
+ bitvec_write_field(dest, &wp,0x1,1); // T/D : TBF or dedicated mode: this message assigns a Temporary Block Flow (TBF).
- bitvec_write_field(dest, wp,0x0,4); // Page Mode
+ bitvec_write_field(dest, &wp,0x0,4); // Page Mode
// GSM 04.08 10.5.2.25a Packet Channel Description
- bitvec_write_field(dest, wp,0x1,5); // Channel type
- bitvec_write_field(dest, wp,ts,3); // TN
- bitvec_write_field(dest, wp,tsc,3); // TSC
- bitvec_write_field(dest, wp,0x0,3); // non-hopping RF channel configuraion
- bitvec_write_field(dest, wp,arfcn,10); // ARFCN
+ bitvec_write_field(dest, &wp,0x1,5); // Channel type
+ bitvec_write_field(dest, &wp,ts,3); // TN
+ bitvec_write_field(dest, &wp,tsc,3); // TSC
+ bitvec_write_field(dest, &wp,0x0,3); // non-hopping RF channel configuraion
+ bitvec_write_field(dest, &wp,arfcn,10); // ARFCN
//10.5.2.30 Request Reference
if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
(burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) {
- bitvec_write_field(dest, wp, 0x7f, 8); /* RACH value */
+ bitvec_write_field(dest, &wp, 0x7f, 8); /* RACH value */
} else {
- bitvec_write_field(dest, wp, ra, 8); /* RACH value */
+ bitvec_write_field(dest, &wp, ra, 8); /* RACH value */
}
- bitvec_write_field(dest, wp,(ref_fn / (26 * 51)) % 32,5); // T1'
- bitvec_write_field(dest, wp,ref_fn % 51,6); // T3
- bitvec_write_field(dest, wp,ref_fn % 26,5); // T2
+ bitvec_write_field(dest, &wp,(ref_fn / (26 * 51)) % 32,5); // T1'
+ bitvec_write_field(dest, &wp,ref_fn % 51,6); // T3
+ bitvec_write_field(dest, &wp,ref_fn % 26,5); // T2
// 10.5.2.40 Timing Advance
- bitvec_write_field(dest, wp,0x0,2); // spare
- bitvec_write_field(dest, wp,ta,6); // Timing Advance value
+ bitvec_write_field(dest, &wp,0x0,2); // spare
+ bitvec_write_field(dest, &wp,ta,6); // Timing Advance value
// No mobile allocation in non-hopping systems.
// A zero-length LV. Just write L=0.
- bitvec_write_field(dest, wp,0,8);
+ bitvec_write_field(dest, &wp,0,8);
if ((wp % 8))
log_alert_exit("Length of IMM.ASS without rest octets is not "
@@ -426,83 +426,83 @@ void Encoding::write_packet_uplink_assignment(
/* timeslot assigned for the Continuous Timing Advance procedure */
uint8_t ta_ts = 0; /* FIXME: supply it as parameter from caller */
- bitvec_write_field(dest, wp,0x1,2); // Payload Type
- bitvec_write_field(dest, wp,0x0,2); // Uplink block with TDMA framenumber (N+13)
- bitvec_write_field(dest, wp,poll,1); // Suppl/Polling Bit
- bitvec_write_field(dest, wp,0x0,3); // Uplink state flag
- bitvec_write_field(dest, wp,0xa,6); // MESSAGE TYPE
+ bitvec_write_field(dest, &wp,0x1,2); // Payload Type
+ bitvec_write_field(dest, &wp,0x0,2); // Uplink block with TDMA framenumber (N+13)
+ bitvec_write_field(dest, &wp,poll,1); // Suppl/Polling Bit
+ bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag
+ bitvec_write_field(dest, &wp,0xa,6); // MESSAGE TYPE
- bitvec_write_field(dest, wp,0x0,2); // Page Mode
+ bitvec_write_field(dest, &wp,0x0,2); // Page Mode
- bitvec_write_field(dest, wp,0x0,1); // switch PERSIST_LEVEL: off
+ bitvec_write_field(dest, &wp,0x0,1); // switch PERSIST_LEVEL: off
if (use_tlli) {
- bitvec_write_field(dest, wp,0x2,2); // switch TLLI : on
- bitvec_write_field(dest, wp,tlli,32); // TLLI
+ bitvec_write_field(dest, &wp,0x2,2); // switch TLLI : on
+ bitvec_write_field(dest, &wp,tlli,32); // TLLI
} else {
- bitvec_write_field(dest, wp,0x0,1); // switch TFI : on
- bitvec_write_field(dest, wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI
- bitvec_write_field(dest, wp,old_tfi,5); // TFI
+ bitvec_write_field(dest, &wp,0x0,1); // switch TFI : on
+ bitvec_write_field(dest, &wp,old_downlink,1); // 0=UPLINK TFI, 1=DL TFI
+ bitvec_write_field(dest, &wp,old_tfi,5); // TFI
}
if (!use_egprs) {
- bitvec_write_field(dest, wp,0x0,1); // Message escape
- bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND
- bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
+ bitvec_write_field(dest, &wp,0x0,1); // Message escape
+ bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND
+ bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts);
} else { /* EPGRS */
unsigned int ws_enc = (tbf->m_window.ws() - 64) / 32;
- bitvec_write_field(dest, wp,0x1,1); // Message escape
- bitvec_write_field(dest, wp,0x0,2); // EGPRS message contents
- bitvec_write_field(dest, wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI
- bitvec_write_field(dest, wp,0x0,1); // No COMPACT reduced MA
- bitvec_write_field(dest, wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE
+ bitvec_write_field(dest, &wp,0x1,1); // Message escape
+ bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents
+ bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI
+ bitvec_write_field(dest, &wp,0x0,1); // No COMPACT reduced MA
+ bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE
/* 0: no RESEGMENT, 1: Segmentation*/
- bitvec_write_field(dest, wp, 0x1, 1);
- bitvec_write_field(dest, wp,ws_enc,5); // EGPRS Window Size
- bitvec_write_field(dest, wp,0x0,1); // No Access Technologies Request
- bitvec_write_field(dest, wp,0x0,1); // No ARAC RETRANSMISSION REQUEST
- bitvec_write_field(dest, wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
- bitvec_write_field(dest, wp,0x0,1); // No BEP_PERIOD2
+ bitvec_write_field(dest, &wp, 0x1, 1);
+ bitvec_write_field(dest, &wp,ws_enc,5); // EGPRS Window Size
+ bitvec_write_field(dest, &wp,0x0,1); // No Access Technologies Request
+ bitvec_write_field(dest, &wp,0x0,1); // No ARAC RETRANSMISSION REQUEST
+ bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
+ bitvec_write_field(dest, &wp,0x0,1); // No BEP_PERIOD2
write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts);
- bitvec_write_field(dest, wp,0x0,1); // No Packet Extended Timing Advance
+ bitvec_write_field(dest, &wp,0x0,1); // No Packet Extended Timing Advance
}
#if 1
- bitvec_write_field(dest, wp,0x1,1); // Frequency Parameters information elements = present
- bitvec_write_field(dest, wp,tbf->tsc(),3); // Training Sequence Code (TSC)
- bitvec_write_field(dest, wp,0x0,2); // ARFCN = present
- bitvec_write_field(dest, wp,tbf->trx->arfcn,10); // ARFCN
+ bitvec_write_field(dest, &wp,0x1,1); // Frequency Parameters information elements = present
+ bitvec_write_field(dest, &wp,tbf->tsc(),3); // Training Sequence Code (TSC)
+ bitvec_write_field(dest, &wp,0x0,2); // ARFCN = present
+ bitvec_write_field(dest, &wp,tbf->trx->arfcn,10); // ARFCN
#else
- bitvec_write_field(dest, wp,0x0,1); // Frequency Parameters = off
+ bitvec_write_field(dest, &wp,0x0,1); // Frequency Parameters = off
#endif
- bitvec_write_field(dest, wp,0x1,2); // Dynamic Allocation
+ bitvec_write_field(dest, &wp,0x1,2); // Dynamic Allocation
- bitvec_write_field(dest, wp,0x0,1); // Extended Dynamic Allocation = off
- bitvec_write_field(dest, wp,0x0,1); // P0 = off
+ bitvec_write_field(dest, &wp,0x0,1); // Extended Dynamic Allocation = off
+ bitvec_write_field(dest, &wp,0x0,1); // P0 = off
- bitvec_write_field(dest, wp,0x0,1); // USF_GRANULARITY
- bitvec_write_field(dest, wp,0x1,1); // switch TFI : on
- bitvec_write_field(dest, wp,tbf->tfi(),5);// TFI
+ bitvec_write_field(dest, &wp,0x0,1); // USF_GRANULARITY
+ bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on
+ bitvec_write_field(dest, &wp,tbf->tfi(),5);// TFI
- bitvec_write_field(dest, wp,0x0,1); //
- bitvec_write_field(dest, wp,0x0,1); // TBF Starting Time = off
+ bitvec_write_field(dest, &wp,0x0,1); //
+ bitvec_write_field(dest, &wp,0x0,1); // TBF Starting Time = off
if (alpha || gamma) {
- bitvec_write_field(dest, wp,0x1,1); // Timeslot Allocation with Power Control
- bitvec_write_field(dest, wp,alpha,4); // ALPHA
+ bitvec_write_field(dest, &wp,0x1,1); // Timeslot Allocation with Power Control
+ bitvec_write_field(dest, &wp,alpha,4); // ALPHA
} else
- bitvec_write_field(dest, wp,0x0,1); // Timeslot Allocation
+ bitvec_write_field(dest, &wp,0x0,1); // Timeslot Allocation
for (ts = 0; ts < 8; ts++) {
if (tbf->pdch[ts]) {
- bitvec_write_field(dest, wp,0x1,1); // USF_TN(i): on
- bitvec_write_field(dest, wp,tbf->m_usf[ts],3); // USF_TN(i)
+ bitvec_write_field(dest, &wp,0x1,1); // USF_TN(i): on
+ bitvec_write_field(dest, &wp,tbf->m_usf[ts],3); // USF_TN(i)
if (alpha || gamma)
- bitvec_write_field(dest, wp,gamma,5); // GAMMA power control parameter
+ bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter
} else
- bitvec_write_field(dest, wp,0x0,1); // USF_TN(i): off
+ bitvec_write_field(dest, &wp,0x0,1); // USF_TN(i): off
}
- // bitvec_write_field(dest, wp,0x0,1); // Measurement Mapping struct not present
+ // bitvec_write_field(dest, &wp,0x0,1); // Measurement Mapping struct not present
}
@@ -609,20 +609,20 @@ int Encoding::write_paging_request(bitvec * dest, uint8_t *ptmsi, uint16_t ptmsi
unsigned wp = 0;
int plen;
- bitvec_write_field(dest, wp,0x0,4); // Skip Indicator
- bitvec_write_field(dest, wp,0x6,4); // Protocol Discriminator
- bitvec_write_field(dest, wp,0x21,8); // Paging Request Message Type
+ bitvec_write_field(dest, &wp,0x0,4); // Skip Indicator
+ bitvec_write_field(dest, &wp,0x6,4); // Protocol Discriminator
+ bitvec_write_field(dest, &wp,0x21,8); // Paging Request Message Type
- bitvec_write_field(dest, wp,0x0,4); // Page Mode
- bitvec_write_field(dest, wp,0x0,4); // Channel Needed
+ bitvec_write_field(dest, &wp,0x0,4); // Page Mode
+ bitvec_write_field(dest, &wp,0x0,4); // Channel Needed
// Mobile Identity
- bitvec_write_field(dest, wp,ptmsi_len+1,8); // Mobile Identity length
- bitvec_write_field(dest, wp,0xf,4); // unused
- bitvec_write_field(dest, wp,0x4,4); // PTMSI type
+ bitvec_write_field(dest, &wp,ptmsi_len+1,8); // Mobile Identity length
+ bitvec_write_field(dest, &wp,0xf,4); // unused
+ bitvec_write_field(dest, &wp,0x4,4); // PTMSI type
for (int i = 0; i < ptmsi_len; i++)
{
- bitvec_write_field(dest, wp,ptmsi[i],8); // PTMSI
+ bitvec_write_field(dest, &wp,ptmsi[i],8); // PTMSI
}
if ((wp % 8))
@@ -630,12 +630,12 @@ int Encoding::write_paging_request(bitvec * dest, uint8_t *ptmsi, uint16_t ptmsi
"multiple of 8 bits, PLEASE FIX!\n");
plen = wp / 8;
- bitvec_write_field(dest, wp,0x0,1); // "L" NLN(PCH) = off
- bitvec_write_field(dest, wp,0x0,1); // "L" Priority1 = off
- bitvec_write_field(dest, wp,0x1,1); // "L" Priority2 = off
- bitvec_write_field(dest, wp,0x0,1); // "L" Group Call information = off
- bitvec_write_field(dest, wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure
- bitvec_write_field(dest, wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure
+ bitvec_write_field(dest, &wp,0x0,1); // "L" NLN(PCH) = off
+ bitvec_write_field(dest, &wp,0x0,1); // "L" Priority1 = off
+ bitvec_write_field(dest, &wp,0x1,1); // "L" Priority2 = off
+ bitvec_write_field(dest, &wp,0x0,1); // "L" Group Call information = off
+ bitvec_write_field(dest, &wp,0x0,1); // "H" Packet Page Indication 1 = packet paging procedure
+ bitvec_write_field(dest, &wp,0x1,1); // "H" Packet Page Indication 2 = packet paging procedure
return plen;
}
@@ -673,13 +673,13 @@ static void write_packet_ack_nack_desc_gprs(
LOGP(DRLCMACUL, LOGL_DEBUG, "- V(N): \"%s\" R=Received "
"I=Invalid\n", rbb);
- bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION
- bitvec_write_field(dest, wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER
+ bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION
+ bitvec_write_field(dest, &wp, window->ssn(), 7); // STARTING_SEQUENCE_NUMBER
for (int i = 0; i < 64; i++) {
/* Set bit at the appropriate position (see 3GPP TS 04.60 9.1.8.1) */
bool is_ack = (rbb[i] == 'R');
- bitvec_write_field(dest, wp, is_ack, 1);
+ bitvec_write_field(dest, &wp, is_ack, 1);
}
}
@@ -688,20 +688,20 @@ static void write_packet_uplink_ack_gprs(
struct gprs_rlcmac_ul_tbf *tbf, bool is_final)
{
- bitvec_write_field(dest, wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND
+ bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND
write_packet_ack_nack_desc_gprs(bts, dest, wp, &tbf->m_window, is_final);
- bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
- bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI
-
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits
- bitvec_write_field(dest, wp, 0, 1); // fixed 0
- bitvec_write_field(dest, wp, 1, 1); // 1: have Additions R99
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance
- bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled)
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5
+ bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
+ bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI
+
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits
+ bitvec_write_field(dest, &wp, 0, 1); // fixed 0
+ bitvec_write_field(dest, &wp, 1, 1); // 1: have Additions R99
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance
+ bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled)
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5
};
static void write_packet_ack_nack_desc_egprs(
@@ -816,37 +816,37 @@ static void write_packet_ack_nack_desc_egprs(
/* EGPRS Ack/Nack Description IE */
if (len_coded == false) {
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have length
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have length
} else {
- bitvec_write_field(dest, wp, 1, 1); // 1: have length
- bitvec_write_field(dest, wp, len, 8); // length
+ bitvec_write_field(dest, &wp, 1, 1); // 1: have length
+ bitvec_write_field(dest, &wp, len, 8); // length
}
- bitvec_write_field(dest, wp, is_final, 1); // FINAL_ACK_INDICATION
- bitvec_write_field(dest, wp, bow, 1); // BEGINNING_OF_WINDOW
- bitvec_write_field(dest, wp, eow, 1); // END_OF_WINDOW
- bitvec_write_field(dest, wp, ssn, 11); // STARTING_SEQUENCE_NUMBER
+ bitvec_write_field(dest, &wp, is_final, 1); // FINAL_ACK_INDICATION
+ bitvec_write_field(dest, &wp, bow, 1); // BEGINNING_OF_WINDOW
+ bitvec_write_field(dest, &wp, eow, 1); // END_OF_WINDOW
+ bitvec_write_field(dest, &wp, ssn, 11); // STARTING_SEQUENCE_NUMBER
if (is_compressed) {
- bitvec_write_field(dest, wp, 1, 1); // CRBB_Exist
- bitvec_write_field(dest, wp, crbb_len, 7); // CRBB_LENGTH
+ bitvec_write_field(dest, &wp, 1, 1); // CRBB_Exist
+ bitvec_write_field(dest, &wp, crbb_len, 7); // CRBB_LENGTH
crbb_start_clr_code = (0x80 & ucmp_vec.data[0])>>7;
- bitvec_write_field(dest, wp, crbb_start_clr_code, 1); // CRBB_clr_code
+ bitvec_write_field(dest, &wp, crbb_start_clr_code, 1); // CRBB_clr_code
LOGP(DRLCMACUL, LOGL_DEBUG,
"EGPRS CRBB, crbb_len = %d, crbb_start_clr_code = %d\n",
crbb_len, crbb_start_clr_code);
while (crbb_len != 0) {
if (crbb_len > 8) {
- bitvec_write_field(dest, wp, crbb_bitmap[iter], 8);
+ bitvec_write_field(dest, &wp, crbb_bitmap[iter], 8);
crbb_len = crbb_len - 8;
iter++;
} else {
- bitvec_write_field(dest, wp, crbb_bitmap[iter], crbb_len);
+ bitvec_write_field(dest, &wp, crbb_bitmap[iter], crbb_len);
crbb_len = 0;
}
}
esn_crbb = window->mod_sns(esn_crbb + uclen_crbb);
} else {
- bitvec_write_field(dest, wp, 0, 1); // CRBB_Exist
+ bitvec_write_field(dest, &wp, 0, 1); // CRBB_Exist
}
LOGP(DRLCMACUL, LOGL_DEBUG,
"EGPRS URBB, urbb len = %d, SSN = %d, ESN_CRBB = %d, "
@@ -859,7 +859,7 @@ static void write_packet_ack_nack_desc_egprs(
for (i = urbb_len; i > 0; i--) {
/* Set bit at the appropriate position (see 3GPP TS 04.60 12.3.1) */
bool is_ack = window->m_v_n.is_received(esn_crbb + i);
- bitvec_write_field(dest, wp, is_ack, 1);
+ bitvec_write_field(dest, &wp, is_ack, 1);
}
}
@@ -867,29 +867,29 @@ static void write_packet_uplink_ack_egprs(
struct gprs_rlcmac_bts *bts, bitvec * dest, unsigned& wp,
struct gprs_rlcmac_ul_tbf *tbf, bool is_final)
{
- bitvec_write_field(dest, wp, 0, 2); // fixed 00
+ bitvec_write_field(dest, &wp, 0, 2); // fixed 00
/* CHANNEL_CODING_COMMAND */
- bitvec_write_field(dest, wp,
+ bitvec_write_field(dest, &wp,
tbf->current_cs().to_num() - 1, 4);
/* 0: no RESEGMENT, 1: Segmentation*/
- bitvec_write_field(dest, wp, 1, 1);
- bitvec_write_field(dest, wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it?
- bitvec_write_field(dest, wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify
- bitvec_write_field(dest, wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify
- bitvec_write_field(dest, wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
- bitvec_write_field(dest, wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI
- bitvec_write_field(dest, wp, 1, 1); // TBF_EST (enabled)
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Timing Advance
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Packet Extended Timing Advance
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Power Control Parameters
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have Extension Bits
+ bitvec_write_field(dest, &wp, 1, 1);
+ bitvec_write_field(dest, &wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it?
+ bitvec_write_field(dest, &wp, 0, 1); // 0: no PRR_RETRANSMISSION_REQUEST, TODO: clarify
+ bitvec_write_field(dest, &wp, 0, 1); // 0: no ARAC_RETRANSMISSION_REQUEST, TODO: clarify
+ bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
+ bitvec_write_field(dest, &wp, tbf->tlli(), 32); // CONTENTION_RESOLUTION_TLLI
+ bitvec_write_field(dest, &wp, 1, 1); // TBF_EST (enabled)
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Timing Advance
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Packet Extended Timing Advance
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Power Control Parameters
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have Extension Bits
/* -2 for last bit 0 mandatory and REL5 not supported */
unsigned bits_ack_nack = dest->data_len * 8 - wp - 2;
write_packet_ack_nack_desc_egprs(bts, dest, wp, &tbf->m_window, is_final, bits_ack_nack);
- bitvec_write_field(dest, wp, 0, 1); // fixed 0
- bitvec_write_field(dest, wp, 0, 1); // 0: don't have REL 5
+ bitvec_write_field(dest, &wp, 0, 1); // fixed 0
+ bitvec_write_field(dest, &wp, 0, 1); // 0: don't have REL 5
};
void Encoding::write_packet_uplink_ack(
@@ -902,23 +902,23 @@ void Encoding::write_packet_uplink_ack(
LOGP(DRLCMACUL, LOGL_DEBUG, "Encoding Ack/Nack for %s "
"(final=%d)\n", tbf_name(tbf), is_final);
- bitvec_write_field(dest, wp, 0x1, 2); // Payload Type
- bitvec_write_field(dest, wp, rrbp, 2); // Uplink block with TDMA framenumber
- bitvec_write_field(dest, wp, is_final, 1); // Suppl/Polling Bit
- bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag
- bitvec_write_field(dest, wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack
- bitvec_write_field(dest, wp, 0x0, 2); // Page Mode
+ bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type
+ bitvec_write_field(dest, &wp, rrbp, 2); // Uplink block with TDMA framenumber
+ bitvec_write_field(dest, &wp, is_final, 1); // Suppl/Polling Bit
+ bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag
+ bitvec_write_field(dest, &wp, 0x9, 6); // MESSAGE TYPE Uplink Ack/Nack
+ bitvec_write_field(dest, &wp, 0x0, 2); // Page Mode
- bitvec_write_field(dest, wp, 0x0, 2); // fixed 00
- bitvec_write_field(dest, wp, tbf->tfi(), 5); // Uplink TFI
+ bitvec_write_field(dest, &wp, 0x0, 2); // fixed 00
+ bitvec_write_field(dest, &wp, tbf->tfi(), 5); // Uplink TFI
if (tbf->is_egprs_enabled()) {
/* PU_AckNack_EGPRS = on */
- bitvec_write_field(dest, wp, 1, 1); // 1: EGPRS
+ bitvec_write_field(dest, &wp, 1, 1); // 1: EGPRS
write_packet_uplink_ack_egprs(bts, dest, wp, tbf, is_final);
} else {
/* PU_AckNack_GPRS = on */
- bitvec_write_field(dest, wp, 0, 1); // 0: GPRS
+ bitvec_write_field(dest, &wp, 0, 1); // 0: GPRS
write_packet_uplink_ack_gprs(bts, dest, wp, tbf, is_final);
}
@@ -932,15 +932,15 @@ unsigned Encoding::write_packet_paging_request(bitvec * dest)
{
unsigned wp = 0;
- bitvec_write_field(dest, wp,0x1,2); // Payload Type
- bitvec_write_field(dest, wp,0x0,3); // No polling
- bitvec_write_field(dest, wp,0x0,3); // Uplink state flag
- bitvec_write_field(dest, wp,0x22,6); // MESSAGE TYPE
+ bitvec_write_field(dest, &wp,0x1,2); // Payload Type
+ bitvec_write_field(dest, &wp,0x0,3); // No polling
+ bitvec_write_field(dest, &wp,0x0,3); // Uplink state flag
+ bitvec_write_field(dest, &wp,0x22,6); // MESSAGE TYPE
- bitvec_write_field(dest, wp,0x0,2); // Page Mode
+ bitvec_write_field(dest, &wp,0x0,2); // Page Mode
- bitvec_write_field(dest, wp,0x0,1); // No PERSISTENCE_LEVEL
- bitvec_write_field(dest, wp,0x0,1); // No NLN
+ bitvec_write_field(dest, &wp,0x0,1); // No PERSISTENCE_LEVEL
+ bitvec_write_field(dest, &wp,0x0,1); // No NLN
return wp;
}
@@ -948,24 +948,24 @@ unsigned Encoding::write_packet_paging_request(bitvec * dest)
unsigned Encoding::write_repeated_page_info(bitvec * dest, unsigned& wp, uint8_t len,
uint8_t *identity, uint8_t chan_needed)
{
- bitvec_write_field(dest, wp,0x1,1); // Repeated Page info exists
+ bitvec_write_field(dest, &wp,0x1,1); // Repeated Page info exists
- bitvec_write_field(dest, wp,0x1,1); // RR connection paging
+ bitvec_write_field(dest, &wp,0x1,1); // RR connection paging
if ((identity[0] & 0x07) == 4) {
- bitvec_write_field(dest, wp,0x0,1); // TMSI
+ bitvec_write_field(dest, &wp,0x0,1); // TMSI
identity++;
len--;
} else {
- bitvec_write_field(dest, wp,0x0,1); // MI
- bitvec_write_field(dest, wp,len,4); // MI len
+ bitvec_write_field(dest, &wp,0x0,1); // MI
+ bitvec_write_field(dest, &wp,len,4); // MI len
}
while (len) {
- bitvec_write_field(dest, wp,*identity++,8); // MI data
+ bitvec_write_field(dest, &wp,*identity++,8); // MI data
len--;
}
- bitvec_write_field(dest, wp,chan_needed,2); // CHANNEL_NEEDED
- bitvec_write_field(dest, wp,0x0,1); // No eMLPP_PRIORITY
+ bitvec_write_field(dest, &wp,chan_needed,2); // CHANNEL_NEEDED
+ bitvec_write_field(dest, &wp,0x0,1); // No eMLPP_PRIORITY
return wp;
}
@@ -1496,17 +1496,17 @@ void Encoding::write_packet_access_reject(
{
unsigned wp = 0;
- bitvec_write_field(dest, wp, 0x1, 2); // Payload Type
- bitvec_write_field(dest, wp, 0x0, 2); // Uplink block with TDMA FN
- bitvec_write_field(dest, wp, 0, 1); // No Polling Bit
- bitvec_write_field(dest, wp, 0x0, 3); // Uplink state flag
- bitvec_write_field(dest, wp,
+ bitvec_write_field(dest, &wp, 0x1, 2); // Payload Type
+ bitvec_write_field(dest, &wp, 0x0, 2); // Uplink block with TDMA FN
+ bitvec_write_field(dest, &wp, 0, 1); // No Polling Bit
+ bitvec_write_field(dest, &wp, 0x0, 3); // Uplink state flag
+ bitvec_write_field(dest, &wp,
MT_PACKET_ACCESS_REJECT, 6); // MESSAGE TYPE
- bitvec_write_field(dest, wp, 0, 2); // fixed 00
- bitvec_write_field(dest, wp, 0x0, 1); // TLLI / G-RNTI : bit (32)
- bitvec_write_field(dest, wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI
- bitvec_write_field(dest, wp, 1, 1); // WAIT_INDICATION size in seconds
+ bitvec_write_field(dest, &wp, 0, 2); // fixed 00
+ bitvec_write_field(dest, &wp, 0x0, 1); // TLLI / G-RNTI : bit (32)
+ bitvec_write_field(dest, &wp, tlli, 32); // CONTENTION_RESOLUTION_TLLI
+ bitvec_write_field(dest, &wp, 1, 1); // WAIT_INDICATION size in seconds
/* TODO: make it configurable */
- bitvec_write_field(dest, wp, 5, 8); // WAIT_INDICATION value
- bitvec_write_field(dest, wp, 0, 1); // WAIT_INDICATION size in seconds
+ bitvec_write_field(dest, &wp, 5, 8); // WAIT_INDICATION value
+ bitvec_write_field(dest, &wp, 0, 1); // WAIT_INDICATION size in seconds
}
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index c4ff402..7c325ae 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -90,7 +90,7 @@ static int parse_ra_cap(struct tlv_parsed *tp, MS_Radio_Access_capability_t *rac
LOGP(DBSSGP, LOGL_DEBUG, "Got BSSGP RA Capability of size %d\n", cap_len);
- block = bitvec_alloc(cap_len);
+ block = bitvec_alloc(cap_len, tall_pcu_ctx);
bitvec_unpack(block, cap);
/* TS 24.008, 10.5.5.12a */
diff --git a/src/gprs_rlcmac.cpp b/src/gprs_rlcmac.cpp
index ac8f2d1..16870c3 100644
--- a/src/gprs_rlcmac.cpp
+++ b/src/gprs_rlcmac.cpp
@@ -33,7 +33,7 @@ int gprs_rlcmac_paging_request(uint8_t *ptmsi, uint16_t ptmsi_len,
const char *imsi)
{
LOGP(DRLCMAC, LOGL_NOTICE, "TX: [PCU -> BTS] Paging Request (CCCH)\n");
- bitvec *paging_request = bitvec_alloc(23);
+ bitvec *paging_request = bitvec_alloc(23, tall_pcu_ctx);
bitvec_unhex(paging_request, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
int plen = Encoding::write_paging_request(paging_request, ptmsi, ptmsi_len);
pcu_l1if_tx_pch(paging_request, plen, (char *)imsi);
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 589bd8f..be1e686 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -22,13 +22,13 @@
#define GPRS_RLCMAC_H
#ifdef __cplusplus
-#include <bitvector.h>
#include <gsm_rlcmac.h>
#include <gsm_timer.h>
extern "C" {
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/timer.h>
+#include <osmocom/core/bitvec.h>
}
#endif
diff --git a/src/gsm_rlcmac.cpp b/src/gsm_rlcmac.cpp
index 6b43aa6..6323b09 100644
--- a/src/gsm_rlcmac.cpp
+++ b/src/gsm_rlcmac.cpp
@@ -4799,7 +4799,7 @@ void decode_gsm_rlcmac_uplink(bitvec * vector, RlcMacUplink_t * data)
{
csnStream_t ar;
unsigned readIndex = 0;
- guint8 payload_type = bitvec_read_field(vector, readIndex, 2);
+ guint8 payload_type = bitvec_read_field(vector, &readIndex, 2);
if (payload_type == PAYLOAD_TYPE_DATA)
{
@@ -4814,7 +4814,7 @@ void decode_gsm_rlcmac_uplink(bitvec * vector, RlcMacUplink_t * data)
data->NrOfBits = 23 * 8;
csnStreamInit(&ar, 0, data->NrOfBits);
readIndex += 6;
- data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6);
+ data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6);
readIndex = 0;
switch (data->u.MESSAGE_TYPE)
{
@@ -4907,10 +4907,10 @@ void decode_gsm_rlcmac_downlink(bitvec * vector, RlcMacDownlink_t * data)
gint bit_offset = 0;
gint bit_length;
unsigned readIndex = 0;
- data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2);
- data->RRBP = bitvec_read_field(vector, readIndex, 2);
- data->SP = bitvec_read_field(vector, readIndex, 1);
- data->USF = bitvec_read_field(vector, readIndex, 3);
+ data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2);
+ data->RRBP = bitvec_read_field(vector, &readIndex, 2);
+ data->SP = bitvec_read_field(vector, &readIndex, 1);
+ data->USF = bitvec_read_field(vector, &readIndex, 3);
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA)
{
@@ -4929,27 +4929,27 @@ void decode_gsm_rlcmac_downlink(bitvec * vector, RlcMacDownlink_t * data)
bit_offset = 8;
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET)
{
- data->RBSN = bitvec_read_field(vector, readIndex, 1);
- data->RTI = bitvec_read_field(vector, readIndex, 5);
- data->FS = bitvec_read_field(vector, readIndex, 1);
- data->AC = bitvec_read_field(vector, readIndex, 1);
+ data->RBSN = bitvec_read_field(vector, &readIndex, 1);
+ data->RTI = bitvec_read_field(vector, &readIndex, 5);
+ data->FS = bitvec_read_field(vector, &readIndex, 1);
+ data->AC = bitvec_read_field(vector, &readIndex, 1);
bit_offset += 8;
if (data->AC == 1)
{
- data->PR = bitvec_read_field(vector, readIndex, 2);
- data->TFI = bitvec_read_field(vector, readIndex, 5);
- data->D = bitvec_read_field(vector, readIndex, 1);
+ data->PR = bitvec_read_field(vector, &readIndex, 2);
+ data->TFI = bitvec_read_field(vector, &readIndex, 5);
+ data->D = bitvec_read_field(vector, &readIndex, 1);
bit_offset += 8;
}
if ((data->RBSN == 1) && (data->FS == 0))
{
- data->RBSNe = bitvec_read_field(vector, readIndex, 3);
- data->FSe = bitvec_read_field(vector, readIndex, 1);
- data->spare = bitvec_read_field(vector, readIndex, 4);
+ data->RBSNe = bitvec_read_field(vector, &readIndex, 3);
+ data->FSe = bitvec_read_field(vector, &readIndex, 1);
+ data->spare = bitvec_read_field(vector, &readIndex, 4);
bit_offset += 8;
}
}
- data->u.MESSAGE_TYPE = bitvec_read_field(vector, readIndex, 6);
+ data->u.MESSAGE_TYPE = bitvec_read_field(vector, &readIndex, 6);
}
/* Initialize the contexts */
@@ -5206,30 +5206,30 @@ void encode_gsm_rlcmac_downlink(bitvec * vector, RlcMacDownlink_t * data)
else
{
/* First print the message type and create a tree item */
- bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2);
- bitvec_write_field(vector, writeIndex, data->RRBP, 2);
- bitvec_write_field(vector, writeIndex, data->SP, 1);
- bitvec_write_field(vector, writeIndex, data->USF, 3);
+ bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2);
+ bitvec_write_field(vector, &writeIndex, data->RRBP, 2);
+ bitvec_write_field(vector, &writeIndex, data->SP, 1);
+ bitvec_write_field(vector, &writeIndex, data->USF, 3);
bit_offset = 8;
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_CTRL_OPT_OCTET)
{
- bitvec_write_field(vector, writeIndex, data->RBSN, 1);
- bitvec_write_field(vector, writeIndex, data->RTI, 5);
- bitvec_write_field(vector, writeIndex, data->FS, 1);
- bitvec_write_field(vector, writeIndex, data->AC, 1);
+ bitvec_write_field(vector, &writeIndex, data->RBSN, 1);
+ bitvec_write_field(vector, &writeIndex, data->RTI, 5);
+ bitvec_write_field(vector, &writeIndex, data->FS, 1);
+ bitvec_write_field(vector, &writeIndex, data->AC, 1);
bit_offset += 8;
if (data->AC == 1)
{
- bitvec_write_field(vector, writeIndex, data->PR, 2);
- bitvec_write_field(vector, writeIndex, data->TFI, 5);
- bitvec_write_field(vector, writeIndex, data->D, 1);
+ bitvec_write_field(vector, &writeIndex, data->PR, 2);
+ bitvec_write_field(vector, &writeIndex, data->TFI, 5);
+ bitvec_write_field(vector, &writeIndex, data->D, 1);
bit_offset += 8;
}
if ((data->RBSN == 1) && (data->FS == 0))
{
- bitvec_write_field(vector, writeIndex, data->RBSNe, 3);
- bitvec_write_field(vector, writeIndex, data->FSe, 1);
- bitvec_write_field(vector, writeIndex, data->spare, 4);
+ bitvec_write_field(vector, &writeIndex, data->RBSNe, 3);
+ bitvec_write_field(vector, &writeIndex, data->FSe, 1);
+ bitvec_write_field(vector, &writeIndex, data->spare, 4);
bit_offset += 8;
}
}
@@ -5378,32 +5378,32 @@ void decode_gsm_rlcmac_uplink_data(bitvec * vector, RlcMacUplinkDataBlock_t * da
{
unsigned readIndex = 0;
//unsigned dataLen = 0;
- guint8 payload_type = bitvec_read_field(vector, readIndex, 2);
+ guint8 payload_type = bitvec_read_field(vector, &readIndex, 2);
if (payload_type == PAYLOAD_TYPE_DATA)
{
readIndex = 0;
// MAC header
- data->PAYLOAD_TYPE = bitvec_read_field(vector, readIndex, 2);
- data->CV = bitvec_read_field(vector, readIndex, 4);
- data->SI = bitvec_read_field(vector, readIndex, 1);
- data->R = bitvec_read_field(vector, readIndex, 1);
+ data->PAYLOAD_TYPE = bitvec_read_field(vector, &readIndex, 2);
+ data->CV = bitvec_read_field(vector, &readIndex, 4);
+ data->SI = bitvec_read_field(vector, &readIndex, 1);
+ data->R = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "CV = %u ", (unsigned)(data->CV));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "SI = %u ", (unsigned)(data->SI));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "R = %u ", (unsigned)(data->R));
// Octet 1
- data->spare = bitvec_read_field(vector, readIndex, 1);
- data->PI = bitvec_read_field(vector, readIndex, 1);
- data->TFI = bitvec_read_field(vector, readIndex, 5);
- data->TI = bitvec_read_field(vector, readIndex, 1);
+ data->spare = bitvec_read_field(vector, &readIndex, 1);
+ data->PI = bitvec_read_field(vector, &readIndex, 1);
+ data->TFI = bitvec_read_field(vector, &readIndex, 5);
+ data->TI = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "spare = %u ", (unsigned)(data->spare));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "PI = %u ", (unsigned)(data->PI));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "TI = %u ", (unsigned)(data->TI));
// Octet 2
- data->BSN = bitvec_read_field(vector, readIndex, 7);
- data->E_1 = bitvec_read_field(vector, readIndex, 1);
+ data->BSN = bitvec_read_field(vector, &readIndex, 7);
+ data->E_1 = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
@@ -5414,9 +5414,9 @@ void decode_gsm_rlcmac_uplink_data(bitvec * vector, RlcMacUplinkDataBlock_t * da
unsigned i = 0;
do
{
- data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, readIndex, 6);
- data->M[i] = bitvec_read_field(vector, readIndex, 1);
- data->E[i] = bitvec_read_field(vector, readIndex, 1);
+ data->LENGTH_INDICATOR[i] = bitvec_read_field(vector, &readIndex, 6);
+ data->M[i] = bitvec_read_field(vector, &readIndex, 1);
+ data->E[i] = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
@@ -5425,12 +5425,12 @@ void decode_gsm_rlcmac_uplink_data(bitvec * vector, RlcMacUplinkDataBlock_t * da
}
if(data->TI == 1) // TLLI field is present
{
- data->TLLI = bitvec_read_field(vector, readIndex, 32);
+ data->TLLI = bitvec_read_field(vector, &readIndex, 32);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "TLLI = %08x ", data->TLLI);
if (data->PI == 1) // PFI is present if TI field indicates presence of TLLI
{
- data->PFI = bitvec_read_field(vector, readIndex, 7);
- data->E_2 = bitvec_read_field(vector, readIndex, 1);
+ data->PFI = bitvec_read_field(vector, &readIndex, 7);
+ data->E_2 = bitvec_read_field(vector, &readIndex, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "PFI = %u ", (unsigned)(data->PFI));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_2 = %u ", (unsigned)(data->E_2));
}
@@ -5440,7 +5440,7 @@ void decode_gsm_rlcmac_uplink_data(bitvec * vector, RlcMacUplinkDataBlock_t * da
assert(dataLen <= 20);
for (unsigned i = 0; i < dataLen; i++)
{
- data->RLC_DATA[i] = bitvec_read_field(vector, readIndex, 8);
+ data->RLC_DATA[i] = bitvec_read_field(vector, &readIndex, 8);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
}
LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n");
@@ -5459,26 +5459,26 @@ void encode_gsm_rlcmac_downlink_data(bitvec * vector, RlcMacDownlinkDataBlock_t
if (data->PAYLOAD_TYPE == PAYLOAD_TYPE_DATA)
{
// MAC header
- bitvec_write_field(vector, writeIndex, data->PAYLOAD_TYPE, 2);
- bitvec_write_field(vector, writeIndex, data->RRBP, 2);
- bitvec_write_field(vector, writeIndex, data->SP, 1);
- bitvec_write_field(vector, writeIndex, data->USF, 3);
+ bitvec_write_field(vector, &writeIndex, data->PAYLOAD_TYPE, 2);
+ bitvec_write_field(vector, &writeIndex, data->RRBP, 2);
+ bitvec_write_field(vector, &writeIndex, data->SP, 1);
+ bitvec_write_field(vector, &writeIndex, data->USF, 3);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "PAYLOAD_TYPE = %u ", (unsigned)(data->PAYLOAD_TYPE));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "RRBP = %u ", (unsigned)(data->RRBP));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "SP = %u ", (unsigned)(data->SP));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "USF = %u ", (unsigned)(data->USF));
// Octet 1
- bitvec_write_field(vector, writeIndex, data->PR, 2);
- bitvec_write_field(vector, writeIndex, data->TFI, 5);
- bitvec_write_field(vector, writeIndex, data->FBI, 1);
+ bitvec_write_field(vector, &writeIndex, data->PR, 2);
+ bitvec_write_field(vector, &writeIndex, data->TFI, 5);
+ bitvec_write_field(vector, &writeIndex, data->FBI, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "PR = %u ", (unsigned)(data->PR));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "TFI = %u ", (unsigned)(data->TFI));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "FBI = %u ", (unsigned)(data->FBI));
// Octet 2
- bitvec_write_field(vector, writeIndex, data->BSN, 7);
- bitvec_write_field(vector, writeIndex, data->E_1, 1);
+ bitvec_write_field(vector, &writeIndex, data->BSN, 7);
+ bitvec_write_field(vector, &writeIndex, data->E_1, 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "BSN = %u ", (unsigned)(data->BSN));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "E_1 = %u ", (unsigned)(data->E_1));
@@ -5488,9 +5488,9 @@ void encode_gsm_rlcmac_downlink_data(bitvec * vector, RlcMacDownlinkDataBlock_t
unsigned i = 0;
do
{
- bitvec_write_field(vector, writeIndex, data->LENGTH_INDICATOR[i], 6);
- bitvec_write_field(vector, writeIndex, data->M[i], 1);
- bitvec_write_field(vector, writeIndex, data->E[i], 1);
+ bitvec_write_field(vector, &writeIndex, data->LENGTH_INDICATOR[i], 6);
+ bitvec_write_field(vector, &writeIndex, data->M[i], 1);
+ bitvec_write_field(vector, &writeIndex, data->E[i], 1);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "LENGTH_INDICATOR[%u] = %u ", i, (unsigned)(data->LENGTH_INDICATOR[i]));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "M[%u] = %u ", i, (unsigned)(data->M[i]));
LOGPC(DRLCMACDATA, LOGL_NOTICE, "E[%u] = %u ", i, (unsigned)(data->E[i]));
@@ -5503,7 +5503,7 @@ void encode_gsm_rlcmac_downlink_data(bitvec * vector, RlcMacDownlinkDataBlock_t
assert(dataNumOctets <= 20);
for (unsigned i = 0; i < dataNumOctets; i++)
{
- bitvec_write_field(vector, writeIndex, data->RLC_DATA[i], 8);
+ bitvec_write_field(vector, &writeIndex, data->RLC_DATA[i], 8);
LOGPC(DRLCMACDATA, LOGL_NOTICE, "%02x", (unsigned)(data->RLC_DATA[i]));
}
LOGPC(DRLCMACDATA, LOGL_NOTICE, "\n");
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 338096b..b69e446 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -168,7 +168,6 @@ int main(int argc, char *argv[])
tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context");
if (!tall_pcu_ctx)
return -ENOMEM;
- bv_tall_ctx = tall_pcu_ctx;
bts = bts_main_data();
bts->fc_interval = 1;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 99ad30a..70b8d61 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1112,7 +1112,7 @@ struct msgb *gprs_rlcmac_tbf::create_dl_ass(uint32_t fn, uint8_t ts)
msg = msgb_alloc(23, "rlcmac_dl_ass");
if (!msg)
return NULL;
- bitvec *ass_vec = bitvec_alloc(23);
+ bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx);
if (!ass_vec) {
msgb_free(msg);
return NULL;
@@ -1159,7 +1159,7 @@ struct msgb *gprs_rlcmac_tbf::create_packet_access_reject()
msg = msgb_alloc(23, "rlcmac_ul_ass_rej");
- bitvec *packet_access_rej = bitvec_alloc(23);
+ bitvec *packet_access_rej = bitvec_alloc(23, tall_pcu_ctx);
bitvec_unhex(packet_access_rej,
"2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
@@ -1216,7 +1216,7 @@ struct msgb *gprs_rlcmac_tbf::create_ul_ass(uint32_t fn, uint8_t ts)
if (!msg)
return NULL;
LOGP(DRLCMAC, LOGL_INFO, "%ss start Packet Uplink Assignment (PACCH)\n", tbf_name(new_tbf));
- bitvec *ass_vec = bitvec_alloc(23);
+ bitvec *ass_vec = bitvec_alloc(23, tall_pcu_ctx);
if (!ass_vec) {
msgb_free(msg);
return NULL;
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 2598174..1eee41a 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -121,7 +121,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts)
msg = msgb_alloc(23, "rlcmac_ul_ack");
if (!msg)
return NULL;
- bitvec *ack_vec = bitvec_alloc(23);
+ bitvec *ack_vec = bitvec_alloc(23, tall_pcu_ctx);
if (!ack_vec) {
msgb_free(msg);
return NULL;
diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp
index 97e5e60..9155809 100644
--- a/tests/rlcmac/RLCMACTest.cpp
+++ b/tests/rlcmac/RLCMACTest.cpp
@@ -83,9 +83,9 @@ void printSizeofRLCMAC()
cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl;
}
-void testRlcMacDownlink()
+void testRlcMacDownlink(void *test_ctx)
{
- struct bitvec *resultVector = bitvec_alloc(23);
+ struct bitvec *resultVector = bitvec_alloc(23, test_ctx);
bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
std::string testData[] = {
@@ -106,7 +106,7 @@ void testRlcMacDownlink()
cout << " DOWNLINK " << endl;
for (int i = 0; i < testDataSize; i++)
{
- bitvec *vector = bitvec_alloc(23);
+ bitvec *vector = bitvec_alloc(23, test_ctx);
bitvec_unhex(vector, testData[i].c_str());
cout << "vector1 = ";
for (int i = 0; i < 23; i++)
@@ -150,9 +150,9 @@ void testRlcMacDownlink()
}
-void testRlcMacUplink()
+void testRlcMacUplink(void *test_ctx)
{
- struct bitvec *resultVector = bitvec_alloc(23);
+ struct bitvec *resultVector = bitvec_alloc(23, test_ctx);
bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
std::string testData[] = {
@@ -169,7 +169,7 @@ void testRlcMacUplink()
cout << " UPLINK " << endl;
for (int i = 0; i < testDataSize; i++)
{
- bitvec *vector = bitvec_alloc(23);
+ bitvec *vector = bitvec_alloc(23, test_ctx);
bitvec_unhex(vector, testData[i].c_str());
cout << "vector1 = ";
for (int i = 0; i < 23; i++)
@@ -212,9 +212,9 @@ void testRlcMacUplink()
bitvec_free(resultVector);
}
-void testCsnLeftAlignedVarBmpBounds()
+void testCsnLeftAlignedVarBmpBounds(void *test_ctx)
{
- bitvec *vector = bitvec_alloc(23);
+ bitvec *vector = bitvec_alloc(23, test_ctx);
bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000");
RlcMacUplink_t data;
@@ -229,10 +229,12 @@ void testCsnLeftAlignedVarBmpBounds()
int main(int argc, char *argv[])
{
+ void *ctx = talloc_named_const(NULL, 1, "RLCMACTest");
osmo_init_logging(&gprs_log_info);
//printSizeofRLCMAC();
- testRlcMacDownlink();
- testRlcMacUplink();
- testCsnLeftAlignedVarBmpBounds();
+ testRlcMacDownlink(ctx);
+ testRlcMacUplink(ctx);
+ testCsnLeftAlignedVarBmpBounds(ctx);
+ talloc_free(ctx);
}
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 00aa4a8..496437d 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -595,7 +595,7 @@ static void send_ul_mac_block(BTS *the_bts, unsigned trx_no, unsigned ts_no,
meas.set_rssi(31);
- rlc_block = bitvec_alloc(23);
+ rlc_block = bitvec_alloc(23, tall_pcu_ctx);
encode_gsm_rlcmac_uplink(rlc_block, ulreq);
num_bytes = bitvec_pack(rlc_block, &buf[0]);
@@ -2555,7 +2555,7 @@ static void test_tbf_epdan_out_of_rx_window(void)
OSMO_ASSERT(dl_tbf->state_is(GPRS_RLCMAC_FLOW));
- block = bitvec_alloc(23);
+ block = bitvec_alloc(23, tall_pcu_ctx);
bitvec_unpack(block, data_msg);
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index ee1c817..7d09108 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -430,7 +430,7 @@ static void test_rlc_dl_ul_basic()
void test_immediate_assign_rej()
{
uint8_t plen;
- bitvec *immediate_assignment_rej = bitvec_alloc(22);
+ bitvec *immediate_assignment_rej = bitvec_alloc(22, tall_pcu_ctx);
bitvec_unhex(immediate_assignment_rej,
"2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");