From 49ddef610a003f1000422284bf31a653249cf09e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 16 Aug 2019 12:22:29 +0200 Subject: 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 --- src/gsm/gsup.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/gsm/gsup.c') 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) -- cgit v1.2.3