aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-12-26 18:13:38 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-01-03 02:21:23 +0100
commitab0eb2651e9c1617ef0d53f0d23c9a2b403f18fe (patch)
treed6f595099b2a994775bfd96f88c1430645a97c6c
parent5b5c3499cfd9b001215ae23ca86ba04c780abb46 (diff)
gsup: add OSMO_GSUP_RAT_TYPES_IEneels/3g_opt_in
Corresponds to the Supported RAT Types Indicator from 3GPP TS 29.002. See 8.1.2 MAP_UPDATE_LOCATION service. This is useful to communicate the RAN / RAT type of the current subscriber during Location Updating Request. The use case we have in mind for VLR <-> HLR would require only a single RAT type, but 29.002 specifies a list of supported RAT types. Hence implement this as a list. So far, have room for eight RAT types in the gsup_msg. That is an arbitrary random choice without any rationale. Change-Id: I93850710ab55a605bf61b95063a69682a2899bb1
-rw-r--r--include/osmocom/gsm/gsup.h5
-rw-r--r--src/gsm/gsup.c25
-rw-r--r--tests/gsup/gsup_test.err14
3 files changed, 37 insertions, 7 deletions
diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h
index 6adb0bf..8384e24 100644
--- a/include/osmocom/gsm/gsup.h
+++ b/include/osmocom/gsm/gsup.h
@@ -43,6 +43,7 @@
#include <osmocom/gsm/gsup_sms.h>
#include <osmocom/gsm/protocol/gsm_23_003.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+#include <osmocom/gsm/gsm_utils.h>
#include <osmocom/crypt/auth.h>
#define OSMO_GSUP_PORT 4222
@@ -83,6 +84,7 @@ enum osmo_gsup_iei {
OSMO_GSUP_AUTS_IE = 0x26,
OSMO_GSUP_RES_IE = 0x27,
OSMO_GSUP_CN_DOMAIN_IE = 0x28,
+ OSMO_GSUP_RAT_TYPES_IE = 0x29,
OSMO_GSUP_SESSION_ID_IE = 0x30,
OSMO_GSUP_SESSION_STATE_IE = 0x31,
@@ -275,6 +277,9 @@ struct osmo_gsup_message {
const uint8_t *imei_enc;
size_t imei_enc_len;
enum osmo_gsup_imei_result imei_result;
+
+ enum osmo_rat_type rat_types[8];
+ size_t rat_types_len;
};
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 3d2a8e2..29cf488 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -282,6 +282,7 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
struct osmo_gsup_message *gsup_msg)
{
int rc;
+ int i;
uint8_t tag;
/* the shift/match functions expect non-const pointers, but we'll
* either copy the data or cast pointers back to const before returning
@@ -442,6 +443,16 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
gsup_msg->cn_domain = *value;
break;
+ case OSMO_GSUP_RAT_TYPES_IE:
+ if (value_len > ARRAY_SIZE(gsup_msg->rat_types)) {
+ LOGP(DLGSUP, LOGL_ERROR, "nr of RAT types %zu > %zu\n", value_len, ARRAY_SIZE(gsup_msg->rat_types));
+ return -GMM_CAUSE_COND_IE_ERR;
+ }
+ for (i = 0; i < value_len; i++)
+ gsup_msg->rat_types[i] = value[i];
+ gsup_msg->rat_types_len = value_len;
+ break;
+
case OSMO_GSUP_CHARG_CHAR_IE:
gsup_msg->pdp_charg_enc = value;
gsup_msg->pdp_charg_enc_len = value_len;
@@ -676,6 +687,20 @@ int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
msgb_tlv_put(msg, OSMO_GSUP_CN_DOMAIN_IE, 1, &dn);
}
+ if (gsup_msg->rat_types_len) {
+ int i;
+ uint8_t *len = msgb_tl_put(msg, OSMO_GSUP_RAT_TYPES_IE);
+ *len = gsup_msg->rat_types_len;
+ for (i = 0; i < gsup_msg->rat_types_len; i++) {
+ if (!gsup_msg->rat_types[i] || gsup_msg->rat_types[i] >= OSMO_RAT_COUNT) {
+ LOGP(DLGSUP, LOGL_ERROR, "Failed to encode RAT type %s (nr %d)\n",
+ osmo_rat_type_name(gsup_msg->rat_types[i]), i);
+ return -EINVAL;
+ }
+ msgb_v_put(msg, gsup_msg->rat_types[i]);
+ }
+ }
+
if (gsup_msg->pdp_charg_enc) {
msgb_tlv_put(msg, OSMO_GSUP_CHARG_CHAR_IE,
gsup_msg->pdp_charg_enc_len, gsup_msg->pdp_charg_enc);
diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err
index 73b35fc..ea6fa15 100644
--- a/tests/gsup/gsup_test.err
+++ b/tests/gsup/gsup_test.err
@@ -101,26 +101,26 @@
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 2: tested 21248 modifications, 2577 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, 4024 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 12: tested 54016 modifications, 4626 parse failures
- message 13: tested 11520 modifications, 1026 parse failures
+ message 12: tested 54016 modifications, 4628 parse failures
+ message 13: tested 11520 modifications, 1028 parse failures
message 14: tested 5120 modifications, 1030 parse failures
- message 15: tested 10752 modifications, 1262 parse failures
+ message 15: tested 10752 modifications, 1263 parse failures
message 16: tested 7680 modifications, 1271 parse failures
message 17: tested 8448 modifications, 2053 parse failures
- message 18: tested 11264 modifications, 2307 parse failures
+ message 18: tested 11264 modifications, 2308 parse failures
message 19: tested 5120 modifications, 1031 parse failures
message 20: tested 6656 modifications, 1546 parse failures
message 21: tested 3584 modifications, 771 parse failures
- message 22: tested 5632 modifications, 771 parse failures
+ message 22: tested 5632 modifications, 772 parse failures
message 23: tested 3584 modifications, 770 parse failures
message 24: tested 3584 modifications, 771 parse failures