Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/11751


Change subject: GSUP/SMS: introduce READY-FOR-SM message and IEs
......................................................................

GSUP/SMS: introduce READY-FOR-SM message and IEs

According to 3GPP TS 29.002, section 12.4, MAP-READY-FOR-SM is
used between the MSC and VLR as well as between the VLR and the
HLR to indicate that a subscriber has memory available for SMS.

This change replicates this service in GSUP as READY_FOR_SM_*.
The only mandatory IE for this service (excluding Invoke ID) is
'Alert Reason' which is replicated as OSMO_GSUP_SM_AL_REAS_IE.

Change-Id: Ic37f3b2114b8095cfce22977e67133b9103942e3
---
M include/osmocom/gsm/gsup.h
M include/osmocom/gsm/gsup_sms.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
6 files changed, 46 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/51/11751/1

diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index c4d215a..d67ba07 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -95,6 +95,7 @@
        OSMO_GSUP_SM_RP_DA_IE                   = 0x41,
        OSMO_GSUP_SM_RP_OA_IE                   = 0x42,
        OSMO_GSUP_SM_RP_UI_IE                   = 0x43,
+       OSMO_GSUP_SM_AL_REAS_IE                 = 0x44,
 };

 /*! GSUP message type */
@@ -136,6 +137,10 @@
        OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST    = 0b00101000,
        OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR      = 0b00101001,
        OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT     = 0b00101010,
+
+       OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST     = 0b00101100,
+       OSMO_GSUP_MSGT_READY_FOR_SM_ERROR       = 0b00101101,
+       OSMO_GSUP_MSGT_READY_FOR_SM_RESULT      = 0b00101110,
 };

 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
@@ -244,6 +249,8 @@
        /*! SM-RP-UI (see 3GPP TS 29.002, 7.6.8.4), SMS TPDU */
        const uint8_t                   *sm_rp_ui;
        size_t                          sm_rp_ui_len;
+       /*! Alert reason (see 3GPP TS 29.002, 7.6.8.8) */
+       enum osmo_gsup_sms_sm_al_reas_t sm_al_reas;
 };

 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/include/osmocom/gsm/gsup_sms.h b/include/osmocom/gsm/gsup_sms.h
index 25f1e91..7c579ae 100644
--- a/include/osmocom/gsm/gsup_sms.h
+++ b/include/osmocom/gsm/gsup_sms.h
@@ -48,4 +48,11 @@
        const uint8_t           *smsc_addr_enc;
 };

+/*! Alert reason values, see 7.6.8.8 */
+enum osmo_gsup_sms_sm_al_reas_t {
+       OSMO_GSUP_SMS_SM_AL_REAS_NONE           = 0x00,
+       OSMO_GSUP_SMS_SM_AL_REAS_MS_PRESENT     = 0x01,
+       OSMO_GSUP_SMS_SM_AL_REAS_MEM_AVAIL      = 0x02,
+};
+
 /*! @} */
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index 78b5e7b..64c2e4b 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -86,6 +86,10 @@
        OSMO_VALUE_STRING(OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR),
        OSMO_VALUE_STRING(OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT),

+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_ERROR),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_READY_FOR_SM_RESULT),
+
        { 0, NULL }
 };

@@ -474,6 +478,10 @@
                        gsup_msg->sm_rp_ui_len = value_len;
                        break;

+               case OSMO_GSUP_SM_AL_REAS_IE:
+                       gsup_msg->sm_al_reas = *value;
+                       break;
+
                default:
                        LOGP(DLGSUP, LOGL_NOTICE,
                             "GSUP IE type %d unknown\n", iei);
@@ -692,6 +700,11 @@
                                gsup_msg->sm_rp_ui_len, gsup_msg->sm_rp_ui);
        }

+       if ((u8 = gsup_msg->sm_al_reas)) {
+               msgb_tlv_put(msg, OSMO_GSUP_SM_AL_REAS_IE,
+                               sizeof(u8), &u8);
+       }
+
        return 0;
 }

diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 75ddfcb..2091f87 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -279,6 +279,15 @@
                        0xde, 0xad, 0xbe, 0xef,
        };

+       static const uint8_t send_ready_for_sm_ind[] = {
+               0x2c, /* OSMO_GSUP_MSGT_READY_FOR_SM_REQUEST */
+               TEST_IMSI_IE,
+
+               /* SM related IEs */
+               0x44, 0x01, /* Alert reason */
+                       0x02, /* Memory Available (SMMA) */
+       };
+
        static const struct test {
                char *name;
                const uint8_t *data;
@@ -324,6 +333,8 @@
                        send_mt_forward_sm_req, sizeof(send_mt_forward_sm_req)},
                {"MO-/MT-ForwardSM (SMSC -> MSC) Response",
                        send_mo_mt_forward_sm_rsp, 
sizeof(send_mo_mt_forward_sm_rsp)},
+               {"ReadyForSM (MSC -> SMSC) Indication",
+                       send_ready_for_sm_ind, sizeof(send_ready_for_sm_ind)},
        };

        printf("Test GSUP message decoding/encoding\n");
@@ -391,7 +402,7 @@
                                 * FIXME: share the maximal IE value somehow
                                 * in order to avoid manual updating of this
                                 */
-                               OSMO_ASSERT(t->data[j+0] <= 
OSMO_GSUP_SM_RP_UI_IE);
+                               OSMO_ASSERT(t->data[j+0] <= 
OSMO_GSUP_SM_AL_REAS_IE);
                                OSMO_ASSERT(t->data[j+1] <= ie_end - j - 2);

                                ie_end = j;
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index f4c832c..43d846a 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -58,6 +58,9 @@
   generated message: 2a 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 
03 40 01 fa 43 04 de ad be ef
   original message:  2a 01 08 21 43 65 87 09 21 43 f5 30 04 de ad be ef 31 01 
03 40 01 fa 43 04 de ad be ef
   IMSI:              123456789012345
+  generated message: 2c 01 08 21 43 65 87 09 21 43 f5 44 01 02
+  original message:  2c 01 08 21 43 65 87 09 21 43 f5 44 01 02
+  IMSI:              123456789012345
   message 0: tested 11 truncations, 11 parse failures
   message 1: tested 14 truncations, 13 parse failures
   message 2: tested 83 truncations, 81 parse failures
@@ -78,6 +81,7 @@
   message 17: tested 44 truncations, 38 parse failures
   message 18: tested 52 truncations, 46 parse failures
   message 19: tested 29 truncations, 25 parse failures
+  message 20: tested 14 truncations, 13 parse failures
 DLGSUP Stopping DLGSUP logging
   message 0: tested 2816 modifications, 510 parse failures
   message 1: tested 3584 modifications, 770 parse failures
@@ -99,3 +103,4 @@
   message 17: tested 11264 modifications, 2812 parse failures
   message 18: tested 13312 modifications, 2559 parse failures
   message 19: tested 7424 modifications, 1546 parse failures
+  message 20: tested 3584 modifications, 771 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index 4e53527..177cb8b 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -39,4 +39,6 @@
           MT-ForwardSM (MSC -> SMSC) Request OK
   Testing MO-/MT-ForwardSM (SMSC -> MSC) Response
           MO-/MT-ForwardSM (SMSC -> MSC) Response OK
+  Testing ReadyForSM (MSC -> SMSC) Indication
+          ReadyForSM (MSC -> SMSC) Indication OK
 Done.

--
To view, visit https://gerrit.osmocom.org/11751
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: Ic37f3b2114b8095cfce22977e67133b9103942e3
Gerrit-Change-Number: 11751
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilira...@gmail.com>

Reply via email to