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
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index ad7a2a4..ef33ed0 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -569,6 +569,11 @@
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 @@
}
}
- 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)