aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decoding.cpp19
-rw-r--r--src/encoding.cpp38
-rw-r--r--src/rlc.h99
-rw-r--r--tests/edge/EdgeTest.cpp73
4 files changed, 68 insertions, 161 deletions
diff --git a/src/decoding.cpp b/src/decoding.cpp
index 7865be0..7c00ff7 100644
--- a/src/decoding.cpp
+++ b/src/decoding.cpp
@@ -24,6 +24,7 @@
extern "C" {
#include <osmocom/core/utils.h>
#include <osmocom/core/bitcomp.h>
+#include <osmocom/gprs/protocol/gsm_04_60.h>
}
#include <arpa/inet.h>
@@ -381,13 +382,13 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_3(
egprs3 = static_cast < struct gprs_rlc_ul_header_egprs_3 * >
((void *)data);
- cps = (egprs3->cps_a << 0) | (egprs3->cps_b << 2);
+ cps = (egprs3->cps_hi << 0) | (egprs3->cps_lo << 2);
gprs_rlc_mcs_cps_decode(cps, cs, &punct, &punct2, &with_padding);
gprs_rlc_data_info_init_ul(rlc, cs, with_padding);
rlc->r = egprs3->r;
rlc->si = egprs3->si;
- rlc->tfi = (egprs3->tfi_a << 0) | (egprs3->tfi_b << 2);
+ rlc->tfi = (egprs3->tfi_hi << 0) | (egprs3->tfi_lo << 2);
rlc->cps = cps;
rlc->rsb = egprs3->rsb;
@@ -396,7 +397,7 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_3(
rlc->block_info[0].pi = egprs3->pi;
rlc->block_info[0].spb = egprs3->spb;
rlc->block_info[0].bsn =
- (egprs3->bsn1_a << 0) | (egprs3->bsn1_b << 5);
+ (egprs3->bsn1_hi << 0) | (egprs3->bsn1_lo << 5);
cur_bit += rlc->data_offs_bits[0] - 2;
offs = rlc->data_offs_bits[0] / 8;
@@ -423,13 +424,13 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_2(
egprs2 = static_cast < struct gprs_rlc_ul_header_egprs_2 * >
((void *)data);
- cps = (egprs2->cps_a << 0) | (egprs2->cps_b << 2);
+ cps = (egprs2->cps_hi << 0) | (egprs2->cps_lo << 2);
gprs_rlc_mcs_cps_decode(cps, cs, &punct, &punct2, &with_padding);
gprs_rlc_data_info_init_ul(rlc, cs, with_padding);
rlc->r = egprs2->r;
rlc->si = egprs2->si;
- rlc->tfi = (egprs2->tfi_a << 0) | (egprs2->tfi_b << 2);
+ rlc->tfi = (egprs2->tfi_hi << 0) | (egprs2->tfi_lo << 2);
rlc->cps = cps;
rlc->rsb = egprs2->rsb;
@@ -437,7 +438,7 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_2(
rlc->block_info[0].cv = egprs2->cv;
rlc->block_info[0].pi = egprs2->pi;
rlc->block_info[0].bsn =
- (egprs2->bsn1_a << 0) | (egprs2->bsn1_b << 5);
+ (egprs2->bsn1_hi << 0) | (egprs2->bsn1_lo << 5);
cur_bit += rlc->data_offs_bits[0] - 2;
@@ -471,14 +472,14 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_1(
rlc->r = egprs1->r;
rlc->si = egprs1->si;
- rlc->tfi = (egprs1->tfi_a << 0) | (egprs1->tfi_b << 2);
+ rlc->tfi = (egprs1->tfi_hi << 0) | (egprs1->tfi_lo << 2);
rlc->cps = egprs1->cps;
rlc->rsb = egprs1->rsb;
rlc->num_data_blocks = 2;
rlc->block_info[0].cv = egprs1->cv;
rlc->block_info[0].pi = egprs1->pi;
rlc->block_info[0].bsn =
- (egprs1->bsn1_a << 0) | (egprs1->bsn1_b << 5);
+ (egprs1->bsn1_hi << 0) | (egprs1->bsn1_lo << 5);
cur_bit += rlc->data_offs_bits[0] - 2;
offs = rlc->data_offs_bits[0] / 8;
@@ -492,7 +493,7 @@ int Decoding::rlc_parse_ul_data_header_egprs_type_1(
rlc->block_info[1].cv = egprs1->cv;
rlc->block_info[1].pi = egprs1->pi;
rlc->block_info[1].bsn = rlc->block_info[0].bsn +
- ((egprs1->bsn2_a << 0) | (egprs1->bsn2_b << 2));
+ ((egprs1->bsn2_hi << 0) | (egprs1->bsn2_lo << 2));
rlc->block_info[1].bsn = rlc->block_info[1].bsn & (RLC_EGPRS_SNS - 1);
if ((rlc->block_info[1].bsn != rlc->block_info[0].bsn) &&
diff --git a/src/encoding.cpp b/src/encoding.cpp
index e174c80..9f3b31d 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -25,6 +25,10 @@
#include <tbf.h>
#include <gprs_debug.h>
+extern "C" {
+#include <osmocom/gprs/protocol/gsm_04_60.h>
+}
+
#include <errno.h>
#include <string.h>
@@ -745,20 +749,20 @@ int Encoding::rlc_write_dl_data_header(const struct gprs_rlc_data_info *rlc,
egprs1->usf = rlc->usf;
egprs1->es_p = rlc->es_p;
egprs1->rrbp = rlc->rrbp;
- egprs1->tfi_a = rlc->tfi >> 0; /* 1 bit LSB */
- egprs1->tfi_b = rlc->tfi >> 1; /* 4 bits */
+ egprs1->tfi_hi = rlc->tfi >> 0; /* 1 bit LSB */
+ egprs1->tfi_lo = rlc->tfi >> 1; /* 4 bits */
egprs1->pr = rlc->pr;
egprs1->cps = rlc->cps;
- egprs1->bsn1_a = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
- egprs1->bsn1_b = rlc->block_info[0].bsn >> 2; /* 8 bits */
- egprs1->bsn1_c = rlc->block_info[0].bsn >> 10; /* 1 bit */
+ egprs1->bsn1_hi = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
+ egprs1->bsn1_mid = rlc->block_info[0].bsn >> 2; /* 8 bits */
+ egprs1->bsn1_lo = rlc->block_info[0].bsn >> 10; /* 1 bit */
bsn_delta = (rlc->block_info[1].bsn - rlc->block_info[0].bsn) &
(RLC_EGPRS_SNS - 1);
- egprs1->bsn2_a = bsn_delta >> 0; /* 7 bits LSB */
- egprs1->bsn2_b = bsn_delta >> 7; /* 3 bits */
+ egprs1->bsn2_hi = bsn_delta >> 0; /* 7 bits LSB */
+ egprs1->bsn2_lo = bsn_delta >> 7; /* 3 bits */
/* first FBI/E header */
e_fbi_header = rlc->block_info[0].e ? 0x01 : 0;
@@ -784,14 +788,14 @@ int Encoding::rlc_write_dl_data_header(const struct gprs_rlc_data_info *rlc,
egprs2->usf = rlc->usf;
egprs2->es_p = rlc->es_p;
egprs2->rrbp = rlc->rrbp;
- egprs2->tfi_a = rlc->tfi >> 0; /* 1 bit LSB */
- egprs2->tfi_b = rlc->tfi >> 1; /* 4 bits */
+ egprs2->tfi_hi = rlc->tfi >> 0; /* 1 bit LSB */
+ egprs2->tfi_lo = rlc->tfi >> 1; /* 4 bits */
egprs2->pr = rlc->pr;
egprs2->cps = rlc->cps;
- egprs2->bsn1_a = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
- egprs2->bsn1_b = rlc->block_info[0].bsn >> 2; /* 8 bits */
- egprs2->bsn1_c = rlc->block_info[0].bsn >> 10; /* 1 bit */
+ egprs2->bsn1_hi = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
+ egprs2->bsn1_mid = rlc->block_info[0].bsn >> 2; /* 8 bits */
+ egprs2->bsn1_lo = rlc->block_info[0].bsn >> 10; /* 1 bit */
e_fbi_header = rlc->block_info[0].e ? 0x01 : 0;
e_fbi_header |= rlc->block_info[0].cv == 0 ? 0x02 : 0; /* FBI */
@@ -808,14 +812,14 @@ int Encoding::rlc_write_dl_data_header(const struct gprs_rlc_data_info *rlc,
egprs3->usf = rlc->usf;
egprs3->es_p = rlc->es_p;
egprs3->rrbp = rlc->rrbp;
- egprs3->tfi_a = rlc->tfi >> 0; /* 1 bit LSB */
- egprs3->tfi_b = rlc->tfi >> 1; /* 4 bits */
+ egprs3->tfi_hi = rlc->tfi >> 0; /* 1 bit LSB */
+ egprs3->tfi_lo = rlc->tfi >> 1; /* 4 bits */
egprs3->pr = rlc->pr;
egprs3->cps = rlc->cps;
- egprs3->bsn1_a = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
- egprs3->bsn1_b = rlc->block_info[0].bsn >> 2; /* 8 bits */
- egprs3->bsn1_c = rlc->block_info[0].bsn >> 10; /* 1 bit */
+ egprs3->bsn1_hi = rlc->block_info[0].bsn >> 0; /* 2 bits LSB */
+ egprs3->bsn1_mid = rlc->block_info[0].bsn >> 2; /* 8 bits */
+ egprs3->bsn1_lo = rlc->block_info[0].bsn >> 10; /* 1 bit */
egprs3->spb = rlc->block_info[0].spb;
diff --git a/src/rlc.h b/src/rlc.h
index 082db89..057e838 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -324,105 +324,6 @@ struct rlc_li_field_egprs {
uint8_t e:1,
li:7;
} __attribute__ ((packed));
-
-/* TS 44.060 10.3a.4.1.1 */
-struct gprs_rlc_ul_header_egprs_1 {
- uint8_t r:1,
- si:1,
- cv:4,
- tfi_a:2;
- uint8_t tfi_b:3,
- bsn1_a:5;
- uint8_t bsn1_b:6,
- bsn2_a:2;
- uint8_t bsn2_b;
- uint8_t cps:5,
- rsb:1,
- pi:1,
- spare_a:1;
- uint8_t spare_b:6,
- dummy:2;
-} __attribute__ ((packed));
-
-/* TS 44.060 10.3a.4.2.1 */
-struct gprs_rlc_ul_header_egprs_2 {
- uint8_t r:1,
- si:1,
- cv:4,
- tfi_a:2;
- uint8_t tfi_b:3,
- bsn1_a:5;
- uint8_t bsn1_b:6,
- cps_a:2;
- uint8_t cps_b:1,
- rsb:1,
- pi:1,
- spare_a:5;
- uint8_t spare_b:5,
- dummy:3;
-} __attribute__ ((packed));
-
-/* TS 44.060 10.3a.4.3.1 */
-struct gprs_rlc_ul_header_egprs_3 {
- uint8_t r:1,
- si:1,
- cv:4,
- tfi_a:2;
- uint8_t tfi_b:3,
- bsn1_a:5;
- uint8_t bsn1_b:6,
- cps_a:2;
- uint8_t cps_b:2,
- spb:2,
- rsb:1,
- pi:1,
- spare:1,
- dummy:1;
-} __attribute__ ((packed));
-
-struct gprs_rlc_dl_header_egprs_1 {
- uint8_t usf:3,
- es_p:2,
- rrbp:2,
- tfi_a:1;
- uint8_t tfi_b:4,
- pr:2,
- bsn1_a:2;
- uint8_t bsn1_b:8;
- uint8_t bsn1_c:1,
- bsn2_a:7;
- uint8_t bsn2_b:3,
- cps:5;
-} __attribute__ ((packed));
-
-struct gprs_rlc_dl_header_egprs_2 {
- uint8_t usf:3,
- es_p:2,
- rrbp:2,
- tfi_a:1;
- uint8_t tfi_b:4,
- pr:2,
- bsn1_a:2;
- uint8_t bsn1_b:8;
- uint8_t bsn1_c:1,
- cps:3,
- dummy:4;
-} __attribute__ ((packed));
-
-struct gprs_rlc_dl_header_egprs_3 {
- uint8_t usf:3,
- es_p:2,
- rrbp:2,
- tfi_a:1;
- uint8_t tfi_b:4,
- pr:2,
- bsn1_a:2;
- uint8_t bsn1_b:8;
- uint8_t bsn1_c:1,
- cps:4,
- spb:2,
- dummy:1;
-} __attribute__ ((packed));
#else
# error "Only little endian headers are supported yet. TODO: add missing structs"
#endif
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 8b5746a..807102c 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -35,6 +35,7 @@ extern "C" {
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/vty/vty.h>
+#include <osmocom/gprs/protocol/gsm_04_60.h>
}
#include <errno.h>
@@ -1196,12 +1197,12 @@ static void uplink_header_type_2_parsing_test(BTS *the_bts,
egprs2->r = 1;
egprs2->si = 1;
egprs2->cv = 7;
- egprs2->tfi_a = tfi & 0x03;
- egprs2->tfi_b = (tfi & 0x1c) >> 2;
- egprs2->bsn1_a = 0;
- egprs2->bsn1_b = 0;
- egprs2->cps_a = 3;
- egprs2->cps_b = 0;
+ egprs2->tfi_hi = tfi & 0x03;
+ egprs2->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs2->bsn1_hi = 0;
+ egprs2->bsn1_lo = 0;
+ egprs2->cps_hi = 3;
+ egprs2->cps_lo = 0;
egprs2->rsb = 0;
egprs2->pi = 0;
data[4] = 0x20; /* Setting E field */
@@ -1220,12 +1221,12 @@ static void uplink_header_type_2_parsing_test(BTS *the_bts,
egprs2->r = 1;
egprs2->si = 1;
egprs2->cv = 7;
- egprs2->tfi_a = tfi & 0x03;
- egprs2->tfi_b = (tfi & 0x1c) >> 2;
- egprs2->bsn1_a = 0;
- egprs2->bsn1_b = 0;
- egprs2->cps_a = 3;
- egprs2->cps_b = 0;
+ egprs2->tfi_hi = tfi & 0x03;
+ egprs2->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs2->bsn1_hi = 0;
+ egprs2->bsn1_lo = 0;
+ egprs2->cps_hi = 3;
+ egprs2->cps_lo = 0;
egprs2->rsb = 0;
egprs2->pi = 0;
data[10] = 0x20; /* Setting E field */
@@ -1241,12 +1242,12 @@ static void uplink_header_type_2_parsing_test(BTS *the_bts,
egprs2->r = 1;
egprs2->si = 1;
egprs2->cv = 7;
- egprs2->tfi_a = tfi & 0x03;
- egprs2->tfi_b = (tfi & 0x1c) >> 2;
- egprs2->bsn1_a = 1;
- egprs2->bsn1_b = 0;
- egprs2->cps_a = 2;
- egprs2->cps_b = 0;
+ egprs2->tfi_hi = tfi & 0x03;
+ egprs2->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs2->bsn1_hi = 1;
+ egprs2->bsn1_lo = 0;
+ egprs2->cps_hi = 2;
+ egprs2->cps_lo = 0;
egprs2->rsb = 0;
egprs2->pi = 0;
data[10] = 0x20; /* Setting E field */
@@ -1305,12 +1306,12 @@ static void uplink_header_type_1_parsing_test(BTS *the_bts,
egprs1->si = 1;
egprs1->r = 1;
egprs1->cv = 7;
- egprs1->tfi_a = tfi & 0x03;
- egprs1->tfi_b = (tfi & 0x1c) >> 2;
- egprs1->bsn1_a = 0;
- egprs1->bsn1_b = 0;
- egprs1->bsn2_a = 1;
- egprs1->bsn2_b = 0;
+ egprs1->tfi_hi = tfi & 0x03;
+ egprs1->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs1->bsn1_hi = 0;
+ egprs1->bsn1_lo = 0;
+ egprs1->bsn2_hi = 1;
+ egprs1->bsn2_lo = 0;
egprs1->cps = 15;
egprs1->rsb = 0;
egprs1->pi = 0;
@@ -1332,12 +1333,12 @@ static void uplink_header_type_1_parsing_test(BTS *the_bts,
egprs1->si = 1;
egprs1->r = 1;
egprs1->cv = 7;
- egprs1->tfi_a = tfi & 0x03;
- egprs1->tfi_b = (tfi & 0x1c) >> 2;
- egprs1->bsn1_a = 0;
- egprs1->bsn1_b = 0;
- egprs1->bsn2_a = 1;
- egprs1->bsn2_b = 0;
+ egprs1->tfi_hi = tfi & 0x03;
+ egprs1->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs1->bsn1_hi = 0;
+ egprs1->bsn1_lo = 0;
+ egprs1->bsn2_hi = 1;
+ egprs1->bsn2_lo = 0;
egprs1->cps = 15;
egprs1->rsb = 0;
egprs1->pi = 0;
@@ -1359,12 +1360,12 @@ static void uplink_header_type_1_parsing_test(BTS *the_bts,
egprs1->si = 1;
egprs1->r = 1;
egprs1->cv = 7;
- egprs1->tfi_a = tfi & 0x03;
- egprs1->tfi_b = (tfi & 0x1c) >> 2;
- egprs1->bsn1_a = 0;
- egprs1->bsn1_b = 0;
- egprs1->bsn2_a = 1;
- egprs1->bsn2_b = 0;
+ egprs1->tfi_hi = tfi & 0x03;
+ egprs1->tfi_lo = (tfi & 0x1c) >> 2;
+ egprs1->bsn1_hi = 0;
+ egprs1->bsn1_lo = 0;
+ egprs1->bsn2_hi = 1;
+ egprs1->bsn2_lo = 0;
egprs1->cps = 15;
egprs1->rsb = 0;
egprs1->pi = 0;