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
This commit is contained in:
Harald Welte 2019-08-16 12:22:29 +02:00 committed by laforge
parent 278a6c8fcf
commit 49ddef610a
5 changed files with 33 additions and 4 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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");

View File

@ -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

View File

@ -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.