summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-08-16 12:22:29 +0200
committerlaforge <laforge@osmocom.org>2019-12-09 10:54:30 +0000
commit49ddef610a003f1000422284bf31a653249cf09e (patch)
treee1234acf31e43886976baa9f3ca643f406472f59
parent278a6c8fcfc04084cd459a990ad93077b2a9cab0 (diff)
gsup: Introduce OSMO_GSUP_NUM_VECTORS_REQ_IE
This is a bit of a hack, as we want to maintain binary compatibility without breaking existing users of libosmocore. To do so, we use the 'num_auth_vectors' field in two ways now: * In the existing use case as part of SEND_AUTH_INFO_RESPONSE, it indicates the number of vectors stored in the 'auth_vectors' field * In the new use case as part of SEND_AUTH_INFO_REQUEST, it indicates the number of vectors actually requested by the MSC/SGSN/MME. Change-Id: Iaecc47280f8ce54f3e3a888c1cfc160735483d0f
-rw-r--r--include/osmocom/gsm/gsup.h1
-rw-r--r--src/gsm/gsup.c19
-rw-r--r--tests/gsup/gsup_test.c10
-rw-r--r--tests/gsup/gsup_test.err5
-rw-r--r--tests/gsup/gsup_test.ok2
5 files changed, 33 insertions, 4 deletions
diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 285bc0c6..56d7a309 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -107,6 +107,7 @@ enum osmo_gsup_iei {
OSMO_GSUP_IMEI_IE = 0x50,
OSMO_GSUP_IMEI_RESULT_IE = 0x51,
+ OSMO_GSUP_NUM_VECTORS_REQ_IE = 0x52,
/* Inter-MSC handover related */
OSMO_GSUP_SOURCE_NAME_IE = 0x60,
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index ad7a2a42..ef33ed08 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -569,6 +569,11 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
gsup_msg->cause_sm = value[0];
break;
+ case OSMO_GSUP_NUM_VECTORS_REQ_IE:
+ if (gsup_msg->message_type == OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST)
+ gsup_msg->num_auth_vectors = value[0];
+ break;
+
default:
LOGP(DLGSUP, LOGL_NOTICE,
"GSUP IE type %d unknown\n", iei);
@@ -753,12 +758,18 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
}
}
- for (idx = 0; idx < gsup_msg->num_auth_vectors; idx++) {
- const struct osmo_auth_vector *auth_vector;
+ if (gsup_msg->message_type == OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST) {
+ uint8_t num = gsup_msg->num_auth_vectors;
+ if (num != 0)
+ msgb_tlv_put(msg, OSMO_GSUP_NUM_VECTORS_REQ_IE, 1, &num);
+ } else {
+ for (idx = 0; idx < gsup_msg->num_auth_vectors; idx++) {
+ const struct osmo_auth_vector *auth_vector;
- auth_vector = &gsup_msg->auth_vectors[idx];
+ auth_vector = &gsup_msg->auth_vectors[idx];
- encode_auth_info(msg, OSMO_GSUP_AUTH_TUPLE_IE, auth_vector);
+ encode_auth_info(msg, OSMO_GSUP_AUTH_TUPLE_IE, auth_vector);
+ }
}
if (gsup_msg->auts)
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index b84c88f0..f34ac7a6 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -19,6 +19,7 @@
#define TEST_AN_APDU_IE 0x62, 0x05, 0x01, 0x42, 0x42, 0x42, 0x42
#define TEST_SOURCE_NAME_IE 0x60, 0x05, 'M', 'S', 'C', '-', 'A'
#define TEST_DESTINATION_NAME_IE 0x61, 0x05, 'M', 'S', 'C', '-', 'B'
+#define TEST_NUM_VEC_IE(x) 0x52, 1, x
static void test_gsup_messages_dec_enc(void)
{
@@ -32,6 +33,13 @@ static void test_gsup_messages_dec_enc(void)
TEST_CLASS_SUBSCR_IE
};
+ static const uint8_t send_auth_info_req10[] = {
+ 0x08,
+ TEST_IMSI_IE,
+ TEST_NUM_VEC_IE(10),
+ TEST_CLASS_SUBSCR_IE
+ };
+
static const uint8_t send_auth_info_err[] = {
0x09,
TEST_IMSI_IE,
@@ -612,6 +620,8 @@ static void test_gsup_messages_dec_enc(void)
send_e_abort, sizeof(send_e_abort)},
{"E Routing Error",
send_e_routing_error, sizeof(send_e_routing_error)},
+ {"Send Authentication Info Request (10 Vectors)",
+ send_auth_info_req10, sizeof(send_auth_info_req10)},
};
printf("Test GSUP message decoding/encoding\n");
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 1da39649..7b2fda97 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -115,6 +115,9 @@
generated message: 4e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42
original message: 4e 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 03 0a 01 04 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42
IMSI: 123456789012345
+ generated message: 08 01 08 21 43 65 87 09 21 43 f5 52 01 0a 0a 01 01
+ original message: 08 01 08 21 43 65 87 09 21 43 f5 52 01 0a 0a 01 01
+ IMSI: 123456789012345
message 0: tested 14 truncations, 13 parse failures
message 1: tested 14 truncations, 13 parse failures
message 2: tested 83 truncations, 81 parse failures
@@ -154,6 +157,7 @@
message 36: tested 37 truncations, 32 parse failures
message 37: tested 26 truncations, 22 parse failures
message 38: tested 37 truncations, 32 parse failures
+ message 39: tested 17 truncations, 15 parse failures
DLGSUP Stopping DLGSUP logging
message 0: tested 3584 modifications, 771 parse failures
message 1: tested 3584 modifications, 770 parse failures
@@ -194,3 +198,4 @@ DLGSUP Stopping DLGSUP logging
message 36: tested 9472 modifications, 1803 parse failures
message 37: tested 6656 modifications, 1546 parse failures
message 38: tested 9472 modifications, 1803 parse failures
+ message 39: tested 4352 modifications, 1030 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index db8bc2f6..ef2aec67 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -77,4 +77,6 @@ Test GSUP message decoding/encoding
E Abort OK
Testing E Routing Error
E Routing Error OK
+ Testing Send Authentication Info Request (10 Vectors)
+ Send Authentication Info Request (10 Vectors) OK
Done.