aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-04-01 22:24:33 +0200
committerHarald Welte <laforge@gnumonks.org>2019-04-13 21:38:58 +0000
commit9838c9070fb8147418e65348e71147a52f64320b (patch)
treef1d9c54235f01cb5a47f73a3eb3ca082a729f3b9
parent0ee798a0172a009cec4fb27c427b8f1d66fca749 (diff)
GSUP: add Message Class IEHEADmaster
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 Message Class 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
-rw-r--r--include/osmocom/gsm/gsup.h21
-rw-r--r--src/gsm/gsup.c18
-rw-r--r--src/gsm/libosmogsm.map1
-rw-r--r--tests/gsup/gsup_test.c4
-rw-r--r--tests/gsup/gsup_test.err8
5 files changed, 47 insertions, 5 deletions
diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 9a583aa..7f304a3 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -68,6 +68,7 @@ enum osmo_gsup_iei {
OSMO_GSUP_FREEZE_PTMSI_IE = 0x07,
OSMO_GSUP_MSISDN_IE = 0x08,
OSMO_GSUP_HLR_NUMBER_IE = 0x09,
+ OSMO_GSUP_MESSAGE_CLASS_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 @@ struct osmo_gsup_pdp_info {
size_t pdp_charg_enc_len;
};
+enum osmo_gsup_message_class {
+ OSMO_GSUP_MESSAGE_CLASS_UNSET = 0,
+ OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT = 1,
+ OSMO_GSUP_MESSAGE_CLASS_SMS = 2,
+ OSMO_GSUP_MESSAGE_CLASS_USSD = 3,
+ OSMO_GSUP_MESSAGE_CLASS_INTER_MSC = 4,
+ /* Keep this as last entry with a value of max(enum osmo_gsup_message_class) + 1.
+ * This value shall serve as the size for an array to aid de-muxing all known GSUP classes. */
+ OSMO_GSUP_MESSAGE_CLASS_ARRAYSIZE
+};
+
+extern const struct value_string osmo_gsup_message_class_names[];
+static inline const char *osmo_gsup_message_class_name(enum osmo_gsup_message_class val)
+{ return get_value_string(osmo_gsup_message_class_names, val); }
+
/*! parsed/decoded GSUP protocol message */
struct osmo_gsup_message {
enum osmo_gsup_message_type message_type;
@@ -286,6 +302,11 @@ struct osmo_gsup_message {
const uint8_t *imei_enc;
size_t imei_enc_len;
enum osmo_gsup_imei_result imei_result;
+
+ /*! Indicate the message class to trivially dispatch incoming GSUP messages to the right code paths.
+ * Inter-MSC messages are *required* to set a class = OSMO_GSUP_MESSAGE_CLASS_INTER_MSC. For older message classes, this may
+ * be omitted (for backwards compatibility only -- if in doubt, include it). */
+ enum osmo_gsup_message_class message_class;
};
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..71dbbe1 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -477,6 +477,10 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
gsup_msg->imei_result = osmo_decode_big_endian(value, value_len) + 1;
break;
+ case OSMO_GSUP_MESSAGE_CLASS_IE:
+ gsup_msg->message_class = value[0];
+ break;
+
default:
LOGP(DLGSUP, LOGL_NOTICE,
"GSUP IE type %d unknown\n", iei);
@@ -718,7 +722,21 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
msgb_tlv_put(msg, OSMO_GSUP_IMEI_RESULT_IE, sizeof(u8), &u8);
}
+ if (gsup_msg->message_class != OSMO_GSUP_MESSAGE_CLASS_UNSET) {
+ u8 = gsup_msg->message_class;
+ msgb_tlv_put(msg, OSMO_GSUP_MESSAGE_CLASS_IE, sizeof(u8), &u8);
+ }
+
return 0;
}
+const struct value_string osmo_gsup_message_class_names[] = {
+ { OSMO_GSUP_MESSAGE_CLASS_UNSET, "unset" },
+ { OSMO_GSUP_MESSAGE_CLASS_SUBSCRIBER_MANAGEMENT, "Subscriber-Management" },
+ { OSMO_GSUP_MESSAGE_CLASS_SMS, "SMS" },
+ { OSMO_GSUP_MESSAGE_CLASS_USSD, "USSD" },
+ { OSMO_GSUP_MESSAGE_CLASS_INTER_MSC, "Inter-MSC" },
+ {}
+};
+
/*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 56481fd..47f3b45 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -586,6 +586,7 @@ osmo_gsup_encode;
osmo_gsup_decode;
osmo_gsup_message_type_names;
osmo_gsup_session_state_names;
+osmo_gsup_message_class_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..0631a51 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_CLASS_SUBSCR_IE 0xa, 0x1, 0x1
static void test_gsup_messages_dec_enc(void)
{
@@ -20,7 +21,8 @@ static void test_gsup_messages_dec_enc(void)
static const uint8_t send_auth_info_req[] = {
0x08,
- TEST_IMSI_IE
+ TEST_IMSI_IE,
+ TEST_CLASS_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