GSUP: add Message Class 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 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
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 @@
 			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 @@
 		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" },
+	{}
+};
+
 /*! @} */