From 039fe3264f10751e5d35d112f4af38bcc7c256b4 Mon Sep 17 00:00:00 2001 From: czichy Date: Fri, 17 Jun 2022 11:31:47 +0300 Subject: [PATCH] RIC-920 fix gNB ID translation gNB identies that had bit lengths not dividable by eight are now correctly handled as we take bits_unused into consideration when doing the translation from bits to hex Signed-off-by: czichy Change-Id: Ib88605754ed722ab220defe5bde5b1519fa1bef9 --- RIC-E2-TERMINATION/BuildRunName.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/RIC-E2-TERMINATION/BuildRunName.h b/RIC-E2-TERMINATION/BuildRunName.h index a80d860..98c640e 100644 --- a/RIC-E2-TERMINATION/BuildRunName.h +++ b/RIC-E2-TERMINATION/BuildRunName.h @@ -74,12 +74,19 @@ static int translateBitStringToChar(char *ranName, BIT_STRING_t &data) { unsigned b1 = 0; unsigned b2 = 0; + unsigned tmp_digit=0; for (auto i = 0; i < (int)data.size; i++) { - b1 = data.buf[i] & (unsigned)0xF0; + // + // we need to shift trailing zeros in the bit string (from asn1c) to leading zeros + // + tmp_digit = (0==i ? (uint8_t) 0: (uint8_t) data.buf[i-1])<<(8-data.bits_unused); + tmp_digit = tmp_digit | ((unsigned) data.buf[i] >> data.bits_unused); + + b1 = tmp_digit & (unsigned)0xF0; b1 = b1 >> (unsigned)4; j = snprintf(buffer, 256, "%s%1x", ranName, b1); memcpy(ranName, buffer, j); - b2 = data.buf[i] & (unsigned)0x0F; + b2 = tmp_digit & (unsigned)0x0F; j = snprintf(buffer, 256, "%s%1x", ranName, b2); memcpy(ranName, buffer, j); } -- 2.16.6