osmith has uploaded this change for review. ( https://gerrit.osmocom.org/12860


Change subject: GSUP: add inter-MSC handover related msgs and IEs
......................................................................

GSUP: add inter-MSC handover related msgs and IEs

Based on a draft created by Neels, which is the result of reading a MAP
trace of two MSCs negotiating inter-MSC handovers, and of reading the
TS 29.002, TS 29.010 and related specs:
https://lists.osmocom.org/pipermail/openbsc/2019-January/012653.html

I figured out that the "Handover Number" mentioned in the specifications
is the same as the MSISDN IE that we already have, so we can use that
instead of creating a new IE (example usage in tests/gsup/gsup_test.c).

Related: OS#3774
Change-Id: Ic00b0601eacff6d72927cea51767801142ee75db
---
M include/osmocom/gsm/gsup.h
A include/osmocom/gsm/gsup_handover.h
M src/gsm/Makefile.am
M src/gsm/gsup.c
A src/gsm/gsup_handover.c
M src/gsm/libosmogsm.map
M tests/gsup/gsup_test.c
M tests/gsup/gsup_test.err
M tests/gsup/gsup_test.ok
9 files changed, 599 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/12860/1

diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 29ea11a..8cd737b 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -40,9 +40,12 @@

 #include <stdint.h>
 #include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsup_handover.h>
 #include <osmocom/gsm/gsup_sms.h>
 #include <osmocom/gsm/protocol/gsm_23_003.h>
+#include <osmocom/gsm/protocol/gsm_03_40.h>
 #include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+#include <osmocom/gsm/protocol/gsm_08_08.h>
 #include <osmocom/crypt/auth.h>

 #define OSMO_GSUP_PORT 4222
@@ -102,6 +105,14 @@
        OSMO_GSUP_IMEI_IE                       = 0x50,
        OSMO_GSUP_IMEI_RESULT_IE                = 0x51,

+       /* Inter-MSC handover related */
+       OSMO_GSUP_SOURCE_NAME_IE                = 0x60,
+       OSMO_GSUP_DESTINATION_NAME_IE           = 0x61,
+       OSMO_GSUP_AN_APDU_IE                    = 0x62,
+       OSMO_GSUP_CAUSE_RR_IE                   = 0x63,
+       OSMO_GSUP_CAUSE_BSSAP_IE                = 0x64,
+       OSMO_GSUP_CAUSE_SM_IE                   = 0x65,
+
        _OSMO_GSUP_IEI_END_MARKER
 };

@@ -163,6 +174,27 @@
        OSMO_GSUP_MSGT_CHECK_IMEI_REQUEST       = 0b00110000,
        OSMO_GSUP_MSGT_CHECK_IMEI_ERROR         = 0b00110001,
        OSMO_GSUP_MSGT_CHECK_IMEI_RESULT        = 0b00110010,
+
+       OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST               = 0b001100100,
+       OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR                 = 0b001100101,
+       OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT                = 0b001100110,
+
+       OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST    = 0b001101000,
+       OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR      = 0b001101001,
+       OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT     = 0b001101010,
+
+       OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_REQUEST        = 0b001101100,
+       OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_ERROR          = 0b001101101,
+       OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_RESULT         = 0b001101110,
+
+       OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST      = 0b001110000,
+       OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_ERROR        = 0b001110010,
+
+       OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST      = 0b001110100,
+       OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_ERROR        = 0b001110110,
+
+       OSMO_GSUP_MSGT_E_CLOSE                                  = 0b001110111,
+       OSMO_GSUP_MSGT_E_ABORT                                  = 0b001111011,
 };

 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
@@ -189,6 +221,12 @@
        OSMO_GSUP_IMEI_RESULT_NACK              = 2, /* on wire: 1 */
 };

+/* 3GPP 29.002 AccessNetworkProtocolId */
+enum osmo_gsup_access_network_protocol {
+       OSMO_GSUP_ACCESS_NETWORK_PROTOCOL_TS3G_48006 = 1,
+       OSMO_GSUP_ACCESS_NETWORK_PROTOCOL_TS3G_25413 = 2,
+};
+
 /*! TCAP-like session state */
 enum osmo_gsup_session_state {
        /*! Undefined session state */
@@ -229,6 +267,12 @@
        size_t                          pdp_charg_enc_len;
 };

+struct osmo_gsup_an_apdu {
+       enum osmo_gsup_access_network_protocol access_network_proto;
+       void *data;
+       size_t data_len;
+};
+
 /*! parsed/decoded GSUP protocol message */
 struct osmo_gsup_message {
        enum osmo_gsup_message_type     message_type;
@@ -286,6 +330,15 @@
        const uint8_t                   *imei_enc;
        size_t                          imei_enc_len;
        enum osmo_gsup_imei_result      imei_result;
+
+       const uint8_t                   *source_name;
+       size_t                          source_name_len;
+       const uint8_t                   *destination_name;
+       size_t                          destination_name_len;
+       struct osmo_gsup_an_apdu        an_apdu;
+       uint8_t                         cause_rr;
+       enum gsm0808_cause              cause_bssap;
+       enum gsm48_gsm_cause            cause_sm;
 };

 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
diff --git a/include/osmocom/gsm/gsup_handover.h 
b/include/osmocom/gsm/gsup_handover.h
new file mode 100644
index 0000000..acb6b65
--- /dev/null
+++ b/include/osmocom/gsm/gsup_handover.h
@@ -0,0 +1,21 @@
+#pragma once
+
+/*! \addtogroup gsup
+ *  @{
+ *
+ *  This header defines the handover extensions for Osmocom GSUP (Generic
+ *  Subscriber Update Protocol). The scope of this module is defined by
+ *  3GPP TS 29.002, section 19.2.
+ *
+ *  \file gsup_handover.h
+ *  Handover extensions for Osmocom GSUP. */
+
+#include <stdint.h>
+
+struct osmo_gsup_message;
+struct msgb;
+
+int osmo_gsup_handover_encode_an_apdu(struct msgb *msg, const struct 
osmo_gsup_message *gsup_msg);
+int osmo_gsup_handover_decode_an_apdu(struct osmo_gsup_message *gsup_msg, 
uint8_t *data, size_t data_len);
+
+/*! @} */
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 9066500..12d8fa0 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -30,7 +30,7 @@
                        auth_milenage.c milenage/aes-encblock.c gea.c \
                        milenage/aes-internal.c milenage/aes-internal-enc.c \
                        milenage/milenage.c gan.c ipa.c gsm0341.c apn.c \
-                       gsup.c gsup_sms.c gprs_gea.c gsm0503_conv.c oap.c 
gsm0808_utils.c \
+                       gsup.c gsup_handover.c gsup_sms.c gprs_gea.c 
gsm0503_conv.c oap.c gsm0808_utils.c \
                        gsm23003.c mncc.c bts_features.c oap_client.c \
                        gsm29118.c
 libgsmint_la_LDFLAGS = -no-undefined
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index a089322..1df1f1b 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -83,6 +83,27 @@
        OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_ERROR),
        OSMO_VALUE_STRING(OSMO_GSUP_MSGT_CHECK_IMEI_RESULT),

+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT),
+
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT),
+
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_ERROR),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_RESULT),
+
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_ERROR),
+
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_ERROR),
+
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_CLOSE),
+       OSMO_VALUE_STRING(OSMO_GSUP_MSGT_E_ABORT),
+
        { 0, NULL }
 };

@@ -477,6 +498,35 @@
                        gsup_msg->imei_result = osmo_decode_big_endian(value, 
value_len) + 1;
                        break;

+               case OSMO_GSUP_SOURCE_NAME_IE:
+                       gsup_msg->source_name = value;
+                       gsup_msg->source_name_len = value_len;
+                       break;
+
+               case OSMO_GSUP_DESTINATION_NAME_IE:
+                       gsup_msg->destination_name = value;
+                       gsup_msg->destination_name_len = value_len;
+                       break;
+
+               case OSMO_GSUP_AN_APDU_IE:
+                       rc = osmo_gsup_handover_decode_an_apdu(gsup_msg, value, 
value_len);
+                       if (rc)
+                               return rc;
+                       break;
+
+               case OSMO_GSUP_CAUSE_RR_IE:
+                       gsup_msg->cause_rr = osmo_decode_big_endian(value, 
value_len);
+                       break;
+
+               case OSMO_GSUP_CAUSE_BSSAP_IE:
+                       gsup_msg->cause_bssap = osmo_decode_big_endian(value, 
value_len);
+                       break;
+
+               case OSMO_GSUP_CAUSE_SM_IE:
+                       gsup_msg->cause_sm = osmo_decode_big_endian(value, 
value_len);
+                       break;
+
+
                default:
                        LOGP(DLGSUP, LOGL_NOTICE,
                             "GSUP IE type %d unknown\n", iei);
@@ -718,6 +768,31 @@
                msgb_tlv_put(msg, OSMO_GSUP_IMEI_RESULT_IE, sizeof(u8), &u8);
        }

+       if (gsup_msg->source_name)
+               msgb_tlv_put(msg, OSMO_GSUP_SOURCE_NAME_IE, 
gsup_msg->source_name_len, gsup_msg->source_name);
+
+       if (gsup_msg->destination_name)
+               msgb_tlv_put(msg, OSMO_GSUP_DESTINATION_NAME_IE, 
gsup_msg->destination_name_len,
+                            gsup_msg->destination_name);
+
+       if (gsup_msg->an_apdu.access_network_proto || 
gsup_msg->an_apdu.data_len) {
+               rc = osmo_gsup_handover_encode_an_apdu(msg, gsup_msg);
+               if (rc) {
+                       LOGP(DLGSUP, LOGL_ERROR, "Failed to encode AN-apdu IE 
\n");
+                       return -EINVAL;
+               }
+       }
+
+       if ((u8 = gsup_msg->cause_rr))
+               msgb_tlv_put(msg, OSMO_GSUP_CAUSE_RR_IE, sizeof(u8), &u8);
+
+       if ((u8 = gsup_msg->cause_bssap))
+               msgb_tlv_put(msg, OSMO_GSUP_CAUSE_BSSAP_IE, sizeof(u8), &u8);
+
+       if ((u8 = gsup_msg->cause_sm))
+               msgb_tlv_put(msg, OSMO_GSUP_CAUSE_SM_IE, sizeof(u8), &u8);
+
+
        return 0;
 }

diff --git a/src/gsm/gsup_handover.c b/src/gsm/gsup_handover.c
new file mode 100644
index 0000000..a9a478f
--- /dev/null
+++ b/src/gsm/gsup_handover.c
@@ -0,0 +1,79 @@
+/*
+ * (C) 2019 by Oliver Smith <[email protected]>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/msgb.h>
+
+#include <osmocom/gsm/gsup.h>
+#include <osmocom/gsm/tlv.h>
+
+/*! \addtogroup gsup
+ *  @{
+ *  \file gsup_handover.c
+ *  Handover extensions for Osmocom GSUP.
+ */
+
+/*! Encode AN-apdu (see 7.6.9.1).
+ * \param[out] msg      target message buffer (caller-allocated)
+ * \param[in]  gsup_msg abstract GSUP message structure
+ * \returns 0 in case of success, negative in case of error
+ */
+int osmo_gsup_handover_encode_an_apdu(struct msgb *msg, const struct 
osmo_gsup_message *gsup_msg)
+{
+       const struct osmo_gsup_an_apdu an_apdu = gsup_msg->an_apdu;
+
+       /* Tag and total length */
+       msgb_tv_put(msg, OSMO_GSUP_AN_APDU_IE, 1 + an_apdu.data_len);
+
+       /* Put access_network_proto */
+       msgb_v_put(msg, an_apdu.access_network_proto);
+
+       /* Put data */
+       uint8_t* buf = msgb_put(msg, an_apdu.data_len);
+       memcpy(buf, an_apdu.data, an_apdu.data_len);
+
+       return 0;
+}
+
+/*! Decode AN-apdu (see 7.6.9.1).
+ * \param[out] gsup_msg abstract GSUP message structure
+ * \param[in]  data     pointer to the raw IE payload
+ * \param[in]  data_len length of IE pointed by \ref data
+ * \returns 0 in case of success, negative in case of error
+ */
+int osmo_gsup_handover_decode_an_apdu(struct osmo_gsup_message *gsup_msg, 
uint8_t *data, size_t data_len)
+{
+       if (data_len < 1) {
+               LOGP(DLGSUP, LOGL_ERROR, "Corrupted an_apdu message (length 
must be >= 1)\n");
+               return -EINVAL;
+       }
+
+       gsup_msg->an_apdu.access_network_proto = data[0];
+       gsup_msg->an_apdu.data_len = data_len -1;
+       gsup_msg->an_apdu.data = data + 1;
+
+       return 0;
+}
+
+/*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index ae7c0a1..0c4ebbd 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -548,6 +548,9 @@
 osmo_gsup_session_state_names;
 osmo_gsup_get_err_msg_type;

+osmo_gsup_handover_encode_an_apdu;
+osmo_gsup_handover_decode_an_apdu;
+
 osmo_gsup_sms_encode_sm_rp_da;
 osmo_gsup_sms_decode_sm_rp_da;
 osmo_gsup_sms_encode_sm_rp_oa;
diff --git a/tests/gsup/gsup_test.c b/tests/gsup/gsup_test.c
index 4ad7431..49981c5 100644
--- a/tests/gsup/gsup_test.c
+++ b/tests/gsup/gsup_test.c
@@ -9,8 +9,14 @@

 /* Tests for osmo_gsup_messages.c */

+/* Complete IEs used multiple times (sorted alphabetically)
+ * 1st byte: IEI from osmo_gsup_iei, 2nd byte: length */
+#define TEST_AN_APDU_IE 0x62, 0x05, 0x01, 0x42, 0x42, 0x42, 0x42
+#define TEST_DESTINATION_NAME_IE 0x61, 0x05, 'M', 'S', 'C', '-', 'B'
 #define TEST_IMSI_IE 0x01, 0x08, 0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5
 #define TEST_IMSI_STR "123456789012345"
+#define TEST_MSISDN_IE 0x08, 0x07, 0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43
+#define TEST_SOURCE_NAME_IE 0x60, 0x05, 'M', 'S', 'C', '-', 'A'

 static void test_gsup_messages_dec_enc(void)
 {
@@ -64,8 +70,7 @@
        static const uint8_t update_location_res[] = {
                0x06,
                TEST_IMSI_IE,
-               0x08, 0x07, /* MSISDN of the subscriber */
-                       0x91, 0x94, 0x61, 0x46, 0x32, 0x24, 0x43,
+               TEST_MSISDN_IE,
                0x09, 0x07, /* HLR-Number of the subscriber */
                        0x91, 0x83, 0x52, 0x38, 0x48, 0x83, 0x93,
                0x04, 0x00, /* PDP info complete */
@@ -310,6 +315,229 @@
                        0x00, /* OSMO_GSUP_IMEI_RESULT_ACK */
        };

+       /* Handover related test messages. Oftentimes they only differ in the
+        * AN_APDU_IE, which is mostly a blob in GSUP. To give a better example
+        * of how the messages can be used, I've added the information an_apdu
+        * holds in brackets (see osmo-msc.git's doc/interMSC_HO_GSUP_msgs.txt).
+        * The session states are from the ASCII art in this e-mail:
+        * https://lists.osmocom.org/pipermail/openbsc/2019-January/012653.html 
*/
+       static const uint8_t send_e_prepare_handover_req [] = {
+               0x64, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (begin) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x01,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Request) */
+       };
+
+       static const uint8_t send_e_prepare_handover_err [] = {
+               0x65, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_ERROR */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
+       static const uint8_t send_e_prepare_handover_res [] = {
+               0x66, /* OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_RESULT */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Request Ack) */
+       };
+
+       static const uint8_t send_e_prepare_subsequent_handover_req [] = {
+               0x68, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (begin) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x01,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Required) */
+       };
+
+       static const uint8_t send_e_prepare_subsequent_handover_err [] = {
+               0x69, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_ERROR */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
+       static const uint8_t send_e_prepare_subsequent_handover_res [] = {
+               0x6A, /* OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Request Ack) */
+       };
+
+       static const uint8_t send_e_prepare_send_end_signal_req [] = {
+               0x6C, /* OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_REQUEST */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (end) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x03,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Complete) */
+       };
+
+       static const uint8_t send_e_prepare_send_end_signal_err [] = {
+               0x6D, /* OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_ERROR */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
+       static const uint8_t send_e_prepare_send_end_signal_res [] = {
+               0x6E, /* OSMO_GSUP_MSGT_E_PREPARE_SEND_END_SIGNAL_RESULT */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (end) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x03,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Complete) */
+       };
+
+       static const uint8_t send_e_process_access_signalling_req [] = {
+               0x70, /* OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (Handover Detect) */
+       };
+
+       static const uint8_t send_e_process_access_signalling_err [] = {
+               0x71, /* OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_ERROR */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
+       static const uint8_t send_e_forward_access_signalling_req [] = {
+               0x74, /* OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST */
+               TEST_IMSI_IE,
+               TEST_MSISDN_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+               TEST_AN_APDU_IE, /* (DTAP, e.g. CC, SMS, ...) */
+       };
+
+       static const uint8_t send_e_forward_access_signalling_err [] = {
+               0x75, /* OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_ERROR */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (continue) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x02,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
+       static const uint8_t send_e_close[] = {
+               0x77, /* OSMO_GSUP_MSGT_E_CLOSE */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (end) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x03,
+
+               TEST_SOURCE_NAME_IE,
+               TEST_DESTINATION_NAME_IE,
+       };
+
+       static const uint8_t send_e_abort[] = {
+               0x7B, /* OSMO_GSUP_MSGT_E_ABORT */
+               TEST_IMSI_IE,
+
+               /* Session ID and state (end) */
+               0x30, 0x04, 0xd3, 0xad, 0xbe, 0xef,
+               0x31, 0x01, 0x03,
+
+               /* cause_bssap */
+               0x64, 0x01,
+                       0x51, /* GSM0808_CAUSE_INVALID_MESSAGE_CONTENTS */
+       };
+
        static const struct test {
                char *name;
                const uint8_t *data;
@@ -365,6 +593,36 @@
                        send_check_imei_err, sizeof(send_check_imei_err)},
                {"Check IMEI Result",
                        send_check_imei_res, sizeof(send_check_imei_res)},
+               {"E Prepare Handover Request",
+                       send_e_prepare_handover_req, 
sizeof(send_e_prepare_handover_req)},
+               {"E Prepare Handover Error",
+                       send_e_prepare_handover_err, 
sizeof(send_e_prepare_handover_err)},
+               {"E Prepare Handover Result",
+                       send_e_prepare_handover_res, 
sizeof(send_e_prepare_handover_res)},
+               {"E Prepare Subsequent Handover Request",
+                       send_e_prepare_subsequent_handover_req, 
sizeof(send_e_prepare_subsequent_handover_req)},
+               {"E Prepare Subsequent Handover Error",
+                       send_e_prepare_subsequent_handover_err, 
sizeof(send_e_prepare_subsequent_handover_err)},
+               {"E Prepare Subsequent Handover Result",
+                       send_e_prepare_subsequent_handover_res, 
sizeof(send_e_prepare_subsequent_handover_res)},
+               {"E Prepare Send End Signal Request",
+                       send_e_prepare_send_end_signal_req, 
sizeof(send_e_prepare_send_end_signal_req)},
+               {"E Prepare Send End Signal Error",
+                       send_e_prepare_send_end_signal_err, 
sizeof(send_e_prepare_send_end_signal_err)},
+               {"E Prepare Send End Signal Result",
+                       send_e_prepare_send_end_signal_res, 
sizeof(send_e_prepare_send_end_signal_res)},
+               {"E Process Access Signalling Request",
+                       send_e_process_access_signalling_req, 
sizeof(send_e_process_access_signalling_req)},
+               {"E Process Access Signalling Error",
+                       send_e_process_access_signalling_err, 
sizeof(send_e_process_access_signalling_err)},
+               {"E Forward Access Signalling Request",
+                       send_e_forward_access_signalling_req, 
sizeof(send_e_forward_access_signalling_req)},
+               {"E Forward Access Signalling Error",
+                       send_e_forward_access_signalling_err, 
sizeof(send_e_forward_access_signalling_err)},
+               {"E Close",
+                       send_e_close, sizeof(send_e_close)},
+               {"E Abort",
+                       send_e_abort, sizeof(send_e_abort)},
        };

        printf("Test GSUP message decoding/encoding\n");
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 225735e..0adb538 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -73,6 +73,51 @@
   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
+  generated message: 64 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 01 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  64 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 01 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 65 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  original message:  65 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  IMSI:              123456789012345
+  generated message: 66 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  66 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 68 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 01 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  68 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 01 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 69 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  original message:  69 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  IMSI:              123456789012345
+  generated message: 6a 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  6a 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 6c 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  6c 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 6d 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  original message:  6d 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  IMSI:              123456789012345
+  generated message: 6e 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  6e 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 70 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  70 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 71 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  original message:  71 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  IMSI:              123456789012345
+  generated message: 74 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  original message:  74 01 08 21 43 65 87 09 21 43 f5 08 07 91 94 61 46 32 24 
43 30 04 d3 ad be ef 31 01 02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 62 05 
01 42 42 42 42
+  IMSI:              123456789012345
+  generated message: 75 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  original message:  75 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
02 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42 64 01 51
+  IMSI:              123456789012345
+  generated message: 77 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42
+  original message:  77 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
03 60 05 4d 53 43 2d 41 61 05 4d 53 43 2d 42
+  IMSI:              123456789012345
+  generated message: 7b 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
03 64 01 51
+  original message:  7b 01 08 21 43 65 87 09 21 43 f5 30 04 d3 ad be ef 31 01 
03 64 01 51
+  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
@@ -98,19 +143,34 @@
   message 22: tested 22 truncations, 21 parse failures
   message 23: tested 14 truncations, 13 parse failures
   message 24: tested 14 truncations, 13 parse failures
+  message 25: tested 50 truncations, 44 parse failures
+  message 26: tested 37 truncations, 32 parse failures
+  message 27: tested 50 truncations, 44 parse failures
+  message 28: tested 50 truncations, 44 parse failures
+  message 29: tested 37 truncations, 32 parse failures
+  message 30: tested 50 truncations, 44 parse failures
+  message 31: tested 50 truncations, 44 parse failures
+  message 32: tested 37 truncations, 32 parse failures
+  message 33: tested 50 truncations, 44 parse failures
+  message 34: tested 50 truncations, 44 parse failures
+  message 35: tested 37 truncations, 32 parse failures
+  message 36: tested 50 truncations, 44 parse failures
+  message 37: tested 37 truncations, 32 parse failures
+  message 38: tested 34 truncations, 30 parse failures
+  message 39: tested 23 truncations, 20 parse failures
 DLGSUP Stopping DLGSUP logging
   message 0: tested 2816 modifications, 510 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
   message 4: tested 3584 modifications, 770 parse failures
-  message 5: tested 20736 modifications, 4022 parse failures
+  message 5: tested 20736 modifications, 4023 parse failures
   message 6: tested 3584 modifications, 771 parse failures
   message 7: tested 3584 modifications, 770 parse failures
   message 8: tested 2816 modifications, 510 parse failures
   message 9: tested 2816 modifications, 510 parse failures
   message 10: tested 3584 modifications, 770 parse failures
-  message 11: tested 3328 modifications, 769 parse failures
+  message 11: tested 3328 modifications, 770 parse failures
   message 12: tested 54016 modifications, 4626 parse failures
   message 13: tested 11520 modifications, 1026 parse failures
   message 14: tested 5120 modifications, 1030 parse failures
@@ -124,3 +184,18 @@
   message 22: tested 5632 modifications, 771 parse failures
   message 23: tested 3584 modifications, 770 parse failures
   message 24: tested 3584 modifications, 771 parse failures
+  message 25: tested 12800 modifications, 2058 parse failures
+  message 26: tested 9472 modifications, 1804 parse failures
+  message 27: tested 12800 modifications, 2058 parse failures
+  message 28: tested 12800 modifications, 2058 parse failures
+  message 29: tested 9472 modifications, 1804 parse failures
+  message 30: tested 12800 modifications, 2058 parse failures
+  message 31: tested 12800 modifications, 2058 parse failures
+  message 32: tested 9472 modifications, 1804 parse failures
+  message 33: tested 12800 modifications, 2058 parse failures
+  message 34: tested 12800 modifications, 2058 parse failures
+  message 35: tested 9472 modifications, 1804 parse failures
+  message 36: tested 12800 modifications, 2058 parse failures
+  message 37: tested 9472 modifications, 1804 parse failures
+  message 38: tested 8704 modifications, 1547 parse failures
+  message 39: tested 5888 modifications, 1288 parse failures
diff --git a/tests/gsup/gsup_test.ok b/tests/gsup/gsup_test.ok
index 70f723c..74ca028 100644
--- a/tests/gsup/gsup_test.ok
+++ b/tests/gsup/gsup_test.ok
@@ -49,4 +49,34 @@
           Check IMEI Error OK
   Testing Check IMEI Result
           Check IMEI Result OK
+  Testing E Prepare Handover Request
+          E Prepare Handover Request OK
+  Testing E Prepare Handover Error
+          E Prepare Handover Error OK
+  Testing E Prepare Handover Result
+          E Prepare Handover Result OK
+  Testing E Prepare Subsequent Handover Request
+          E Prepare Subsequent Handover Request OK
+  Testing E Prepare Subsequent Handover Error
+          E Prepare Subsequent Handover Error OK
+  Testing E Prepare Subsequent Handover Result
+          E Prepare Subsequent Handover Result OK
+  Testing E Prepare Send End Signal Request
+          E Prepare Send End Signal Request OK
+  Testing E Prepare Send End Signal Error
+          E Prepare Send End Signal Error OK
+  Testing E Prepare Send End Signal Result
+          E Prepare Send End Signal Result OK
+  Testing E Process Access Signalling Request
+          E Process Access Signalling Request OK
+  Testing E Process Access Signalling Error
+          E Process Access Signalling Error OK
+  Testing E Forward Access Signalling Request
+          E Forward Access Signalling Request OK
+  Testing E Forward Access Signalling Error
+          E Forward Access Signalling Error OK
+  Testing E Close
+          E Close OK
+  Testing E Abort
+          E Abort OK
 Done.

--
To view, visit https://gerrit.osmocom.org/12860
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: Ic00b0601eacff6d72927cea51767801142ee75db
Gerrit-Change-Number: 12860
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to