Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/12452


Change subject: gsup: add OSMO_GSUP_RAT_TYPES_IE
......................................................................

gsup: add OSMO_GSUP_RAT_TYPES_IE

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
---
M include/osmocom/gsm/gsup.h
M src/gsm/gsup.c
M tests/gsup/gsup_test.err
3 files changed, 37 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/52/12452/1

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 @@
        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 @@
        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 @@
                     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 @@
                        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 @@
                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

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

Reply via email to