laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/15321 )

Change subject: gsup: Introduce OSMO_GSUP_NUM_VECTORS_REQ_IE
......................................................................

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
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
5 files changed, 33 insertions(+), 4 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 285bc0c..56d7a30 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -107,6 +107,7 @@

        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 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)
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index b84c88f..f34ac7a 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 @@
                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 @@
                        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 1da3964..7b2fda9 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 @@
   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 db8bc2f..ef2aec6 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -77,4 +77,6 @@
           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.

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15321
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iaecc47280f8ce54f3e3a888c1cfc160735483d0f
Gerrit-Change-Number: 15321
Gerrit-PatchSet: 7
Gerrit-Owner: laforge <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-CC: neels <[email protected]>
Gerrit-MessageType: merged

Reply via email to