summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/gsm0408/gsm0408_test.c37
-rw-r--r--tests/gsm0408/gsm0408_test.ok16
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index ad455075..a0e740aa 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -159,6 +159,33 @@ static inline void check_ra(const struct gprs_ra_id *raid)
printf("passed\n");
}
+static inline void check_lai(const struct gprs_ra_id *raid)
+{
+ int rc;
+ struct gsm48_loc_area_id lai = {};
+ struct gprs_ra_id decoded = {};
+ struct gprs_ra_id _laid = *raid;
+ struct gprs_ra_id *laid = &_laid;
+ laid->rac = 0;
+
+ printf("- gsm48_generate_lai() from "); dump_ra(laid);
+
+ gsm48_generate_lai(&lai, laid->mcc, laid->mnc, laid->lac);
+ printf(" Encoded %s\n", osmo_hexdump((unsigned char*)&lai, sizeof(lai)));
+ rc = gsm48_decode_lai(&lai, &decoded.mcc, &decoded.mnc, &decoded.lac);
+ if (rc) {
+ printf(" gsm48_decode_lai() returned %d --> FAIL\n", rc);
+ return;
+ }
+ printf(" gsm48_decode_lai() gives "); dump_ra(&decoded);
+ if (decoded.mcc == laid->mcc
+ && decoded.mnc == laid->mnc
+ && decoded.lac == laid->lac)
+ printf(" passed\n");
+ else
+ printf(" FAIL\n");
+}
+
static struct gprs_ra_id test_ra_cap_items[] = {
{
.mcc = 77,
@@ -194,6 +221,15 @@ static void test_ra_cap(void)
check_ra(&test_ra_cap_items[i]);
}
+static void test_lai_encode_decode(void)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(test_ra_cap_items); i++) {
+ check_lai(&test_ra_cap_items[i]);
+ }
+}
+
static void test_mid_from_tmsi(void)
{
static const uint8_t res[] = { 0x17, 0x05, 0xf4, 0xaa, 0xbb, 0xcc, 0xdd };
@@ -229,6 +265,7 @@ int main(int argc, char **argv)
test_mid_from_tmsi();
test_mid_from_imsi();
test_ra_cap();
+ test_lai_encode_decode();
return EXIT_SUCCESS;
}
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index dc19eeaa..7612c12f 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -22,3 +22,19 @@ Constructed RA:
MCC+MNC in BCD: 99 99 99
999-999-65535-255
RA test...passed
+- gsm48_generate_lai() from 077-121-666-0
+ Encoded 70 17 21 02 9a
+ gsm48_decode_lai() gives 077-121-666-0
+ passed
+- gsm48_generate_lai() from 084-98-11-0
+ Encoded 80 f4 89 00 0b
+ gsm48_decode_lai() gives 084-98-11-0
+ passed
+- gsm48_generate_lai() from 000-00-0-0
+ Encoded 00 f0 00 00 00
+ gsm48_decode_lai() gives 000-00-0-0
+ passed
+- gsm48_generate_lai() from 999-999-65535-0
+ Encoded 99 99 99 ff ff
+ gsm48_decode_lai() gives 999-999-65535-0
+ passed