Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/13576


Change subject: GSUP: add Kind IE
......................................................................

GSUP: add Kind IE

osmo-msc and osmo-hlr have distinct subsystems handling incoming GSUP messages.
So far we decide entirely by message type which code path should handle a GSUP
message. Thus no GSUP message type may be re-used across subsystems.

If we add a GSUP message to indicate a routing error, it would have to be a
distinct message type for subscriber management, another one for SMS, another
one for USSD...

To allow introducing common message types, introduce a GSUP Kind IE.

In the presence of this IE, GSUP handlers can trivially direct a received
message to the right code path. If it is missing, handlers can fall back to the
previous switch(message_type) method.

Change-Id: Ic397a9f2c4a7224e47cab944c72e75ca5592efef
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M src/gsm/libosmogsm.map
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
5 files changed, 47 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/13576/1

diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 29ea11a..d123da5 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -68,6 +68,7 @@
        OSMO_GSUP_FREEZE_PTMSI_IE               = 0x07,
        OSMO_GSUP_MSISDN_IE                     = 0x08,
        OSMO_GSUP_HLR_NUMBER_IE                 = 0x09,
+       OSMO_GSUP_KIND_IE                       = 0x0a,
        OSMO_GSUP_PDP_CONTEXT_ID_IE             = 0x10,
        OSMO_GSUP_PDP_TYPE_IE                   = 0x11,
        OSMO_GSUP_ACCESS_POINT_NAME_IE          = 0x12,
@@ -229,6 +230,21 @@
        size_t                          pdp_charg_enc_len;
 };

+enum osmo_gsup_kind {
+       OSMO_GSUP_KIND_UNSET = 0,
+       OSMO_GSUP_KIND_SUBSCRIBER_MANAGEMENT = 1,
+       OSMO_GSUP_KIND_SMS = 2,
+       OSMO_GSUP_KIND_USSD = 3,
+       OSMO_GSUP_KIND_INTER_MSC = 4,
+       /* Keep this as last entry with a value of max(enum osmo_gsup_kind) + 1.
+        * This value shall serve as the size for an array to aid de-muxing all 
known GSUP kinds. */
+       OSMO_GSUP_KIND_ARRAYSIZE
+};
+
+extern const struct value_string osmo_gsup_kind_names[];
+static inline const char *osmo_gsup_kind_name(enum osmo_gsup_kind val)
+{ return get_value_string(osmo_gsup_kind_names, val); }
+
 /*! parsed/decoded GSUP protocol message */
 struct osmo_gsup_message {
        enum osmo_gsup_message_type     message_type;
@@ -286,6 +302,11 @@
        const uint8_t                   *imei_enc;
        size_t                          imei_enc_len;
        enum osmo_gsup_imei_result      imei_result;
+
+       /*! Indicate the subsystem kind to trivially dispatch incoming GSUP 
messages to the right code paths.
+        * Inter-MSC messages are *required* to set a kind = 
OSMO_GSUP_KIND_INTER_MSC. For older message kinds, this may
+        * be omitted (for backwards compatibility only -- if in doubt, include 
it). */
+       enum osmo_gsup_kind             kind;
 };

 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index a089322..ea79e91 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -477,6 +477,10 @@
                        gsup_msg->imei_result = osmo_decode_big_endian(value, 
value_len) + 1;
                        break;

+               case OSMO_GSUP_KIND_IE:
+                       gsup_msg->kind = osmo_decode_big_endian(value, 
value_len);
+                       break;
+
                default:
                        LOGP(DLGSUP, LOGL_NOTICE,
                             "GSUP IE type %d unknown\n", iei);
@@ -718,7 +722,21 @@
                msgb_tlv_put(msg, OSMO_GSUP_IMEI_RESULT_IE, sizeof(u8), &u8);
        }

+       if (gsup_msg->kind != OSMO_GSUP_KIND_UNSET) {
+               u8 = gsup_msg->kind;
+               msgb_tlv_put(msg, OSMO_GSUP_KIND_IE, sizeof(u8), &u8);
+       }
+
        return 0;
 }

+const struct value_string osmo_gsup_kind_names[] = {
+       { OSMO_GSUP_KIND_UNSET, "unset" },
+       { OSMO_GSUP_KIND_SUBSCRIBER_MANAGEMENT, "Subscriber-Management" },
+       { OSMO_GSUP_KIND_SMS, "SMS" },
+       { OSMO_GSUP_KIND_USSD, "USSD" },
+       { OSMO_GSUP_KIND_INTER_MSC, "Inter-MSC" },
+       {}
+};
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index a69fb60..659cfe6 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -567,6 +567,7 @@
 osmo_gsup_decode;
 osmo_gsup_message_type_names;
 osmo_gsup_session_state_names;
+osmo_gsup_kind_names;
 osmo_gsup_get_err_msg_type;

 osmo_gsup_sms_encode_sm_rp_da;
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 4ad7431..3e27e99 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -11,6 +11,7 @@

 #define TEST_IMSI_IE 0x01, 0x08, 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
 #define TEST_IMSI_STR "123456789012345"
+#define TEST_KIND_SUBSCR_IE 0xa, 0x1, 0x1

 static void test_gsup_messages_dec_enc(void)
 {
@@ -20,7 +21,8 @@

        static const uint8_t send_auth_info_req[] = {
                0x08,
-               TEST_IMSI_IE
+               TEST_IMSI_IE,
+               TEST_KIND_SUBSCR_IE
        };

        static const uint8_t send_auth_info_err[] = {
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 225735e..9283823 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -1,5 +1,5 @@
-  generated message: 08 01 08 21 43 65 87 09 21 43 f5
-  original message:  08 01 08 21 43 65 87 09 21 43 f5
+  generated message: 08 01 08 21 43 65 87 09 21 43 f5 0a 01 01
+  original message:  08 01 08 21 43 65 87 09 21 43 f5 0a 01 01
   IMSI:              123456789012345
   generated message: 09 01 08 21 43 65 87 09 21 43 f5 02 01 07
   original message:  09 01 08 21 43 65 87 09 21 43 f5 02 01 07 
@@ -73,7 +73,7 @@
   generated message: 32 01 08 21 43 65 87 09 21 43 f5 51 01 00
   original message:  32 01 08 21 43 65 87 09 21 43 f5 51 01 00
   IMSI:              123456789012345
-  message 0: tested 11 truncations, 11 parse failures
+  message 0: tested 14 truncations, 13 parse failures
   message 1: tested 14 truncations, 13 parse failures
   message 2: tested 83 truncations, 81 parse failures
   message 3: tested 11 truncations, 11 parse failures
@@ -99,7 +99,7 @@
   message 23: tested 14 truncations, 13 parse failures
   message 24: tested 14 truncations, 13 parse failures
 DLGSUP Stopping DLGSUP logging
-  message 0: tested 2816 modifications, 510 parse failures
+  message 0: tested 3584 modifications, 771 parse failures
   message 1: tested 3584 modifications, 770 parse failures
   message 2: tested 21248 modifications, 2575 parse failures
   message 3: tested 2816 modifications, 510 parse failures

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic397a9f2c4a7224e47cab944c72e75ca5592efef
Gerrit-Change-Number: 13576
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>

Reply via email to