Skip to content

Commit

Permalink
WIP: HSS: Add support for Operator-Determined-Barring field
Browse files Browse the repository at this point in the history
For more information, see TS 29.272 section 5.2.2.1.3  and 7.3.30.
  • Loading branch information
pespin committed Oct 10, 2023
1 parent bb18693 commit f00cbac
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/dbi/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ int ogs_dbi_subscription_data(char *supi,
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->subscriber_status =
bson_iter_int32(&iter);
} else if (!strcmp(key, "operator_determined_barring") &&
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->operator_determined_barring =
bson_iter_int32(&iter);
} else if (!strcmp(key, "network_access_mode") &&
BSON_ITER_HOLDS_INT32(&iter)) {
subscription_data->network_access_mode =
Expand Down
2 changes: 2 additions & 0 deletions lib/diameter/s6a/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct dict_object *ogs_diam_s6a_xres = NULL;
struct dict_object *ogs_diam_s6a_autn = NULL;
struct dict_object *ogs_diam_s6a_kasme = NULL;
struct dict_object *ogs_diam_s6a_subscriber_status = NULL;
struct dict_object *ogs_diam_s6a_operator_determined_barring = NULL;
struct dict_object *ogs_diam_s6a_ambr = NULL;
struct dict_object *ogs_diam_s6a_network_access_mode = NULL;
struct dict_object *ogs_diam_s6a_access_restriction_data = NULL;
Expand Down Expand Up @@ -151,6 +152,7 @@ int ogs_diam_s6a_init(void)
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Served-Party-IP-Address", &ogs_diam_s6a_served_party_ip_address);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Data", &ogs_diam_s6a_subscription_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscriber-Status", &ogs_diam_s6a_subscriber_status);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Operator-Determined-Barring", &ogs_diam_s6a_operator_determined_barring);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Network-Access-Mode", &ogs_diam_s6a_network_access_mode);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Access-Restriction-Data", &ogs_diam_s6a_access_restriction_data);
CHECK_dict_search(DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscribed-Periodic-RAU-TAU-Timer", &ogs_diam_s6a_subscribed_rau_tau_timer);
Expand Down
1 change: 1 addition & 0 deletions lib/diameter/s6a/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ extern struct dict_object *ogs_diam_s6a_xres;
extern struct dict_object *ogs_diam_s6a_autn;
extern struct dict_object *ogs_diam_s6a_kasme;
extern struct dict_object *ogs_diam_s6a_subscriber_status;
extern struct dict_object *ogs_diam_s6a_operator_determined_barring;
extern struct dict_object *ogs_diam_s6a_ambr;
extern struct dict_object *ogs_diam_s6a_network_access_mode;
extern struct dict_object *ogs_diam_s6a_access_restriction_data;
Expand Down
10 changes: 10 additions & 0 deletions lib/proto/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@ typedef struct ogs_subscription_data_s {
#define OGS_SUBSCRIBER_STATUS_SERVICE_GRANTED 0
#define OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING 1
uint32_t subscriber_status;
#define OGS_OP_DET_BARRING_ALL_PS_BARRED (1<<0)
#define OGS_OP_DET_BARRING_ROAM_ACC_HPLMN_AP_BARRED (1<<1)
#define OGS_OP_DET_BARRING_ROAM_ACC_VPLMN_AP_BARRED (1<<2)
#define OGS_OP_DET_BARRING_ALL_OUT_CALLS (1<<3)
#define OGS_OP_DET_BARRING_ALL_OUT_INT_CALLS (1<<4)
#define OGS_OP_DET_BARRING_ALL_OUT_INT_CALLS_EXCL_HPLMN_COUNTRY (1<<5)
#define OGS_OP_DET_BARRING_ALL_OUT_INTERZONE_CALLS (1<<6)
#define OGS_OP_DET_BARRING_ALL_OUT_INTERZONE_CALLS_EXCL_HPLMN_COUNTRY (1<<7)
#define OGS_OPD_ETEBARRING_OUT_INT_CALLS_EXCL_EXCL_HPLMN_COUNTRY_AND_INTERZONE_CALLS (1<<8)
uint32_t operator_determined_barring; /* 3GPP TS 29.272 7.3.30 */
#define OGS_NETWORK_ACCESS_MODE_PACKET_AND_CIRCUIT 0
#define OGS_NETWORK_ACCESS_MODE_RESERVED 1
#define OGS_NETWORK_ACCESS_MODE_ONLY_PACKET 2
Expand Down
1 change: 1 addition & 0 deletions misc/db/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sub_data = {
"subscribed_rau_tau_timer": 12,
"network_access_mode": 0,
"subscriber_status": 0,
"operator_determined_barring": 0,
"access_restriction_data": 32,
"slice" : slice_data,
"ambr": {"uplink": {"value": 1, "unit": 3}, "downlink": {"value": 1, "unit": 3}},
Expand Down
4 changes: 3 additions & 1 deletion misc/db/python/test_SchemaUpdater.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ def setUp(self):
'opc': 'iamatransparentsecretopcstring'
},
'subscribed_rau_tau_timer': 12,
'subscriber_status': 0
'subscriber_status': 0,
"operator_determined_barring": 0,
}

def test_top_level_migration(self):
new_sub = SchemaUpdater.create_v1_from_v0(self.legacy_sub)
self.assertEqual(new_sub["imsi"], self.legacy_sub["imsi"])
self.assertEqual(new_sub["subscriber_status"], self.legacy_sub["subscriber_status"])
self.assertEqual(new_sub["operator_determined_barring"], self.legacy_sub["operator_determined_barring"])
self.assertEqual(new_sub["subscribed_rau_tau_timer"], self.legacy_sub["subscribed_rau_tau_timer"])
self.assertEqual(new_sub["network_access_mode"], self.legacy_sub["network_access_mode"])
self.assertEqual(new_sub["access_restriction_data"], self.legacy_sub["access_restriction_data"])
Expand Down
6 changes: 6 additions & 0 deletions src/hss/hss-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,12 @@ int hss_handle_change_event(const bson_t *document)
send_idr_flag = true;
subdatamask = (subdatamask |
OGS_DIAM_S6A_SUBDATA_SUB_STATUS);
} else if (!strncmp(child2_key,
"operator_determined_barring",
strlen("operator_determined_barring"))) {
send_idr_flag = true;
subdatamask = (subdatamask |
OGS_DIAM_S6A_SUBDATA_SUB_STATUS);
} else if (!strncmp(child2_key,
"network_access_mode",
strlen("network_access_mode"))) {
Expand Down
13 changes: 12 additions & 1 deletion src/hss/hss-s6a-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static int hss_s6a_avp_add_subscription_data(

struct avp *avp_msisdn, *avp_a_msisdn;
struct avp *avp_access_restriction_data;
struct avp *avp_subscriber_status, *avp_network_access_mode;
struct avp *avp_subscriber_status, *avp_operator_determined_barring, *avp_network_access_mode;
struct avp *avp_ambr, *avp_max_bandwidth_ul, *avp_max_bandwidth_dl;
struct avp *avp_rau_tau_timer;

Expand Down Expand Up @@ -373,6 +373,17 @@ static int hss_s6a_avp_add_subscription_data(
ogs_assert(ret == 0);
ret = fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_subscriber_status);
ogs_assert(ret == 0);

if (subscription_data->subscriber_status == OGS_SUBSCRIBER_STATUS_OPERATOR_DETERMINED_BARRING) {
ret = fd_msg_avp_new(
ogs_diam_s6a_operator_determined_barring, 0, &avp_operator_determined_barring);
ogs_assert(ret == 0);
val.i32 = subscription_data->operator_determined_barring;
ret = fd_msg_avp_setvalue(avp_operator_determined_barring, &val);
ogs_assert(ret == 0);
ret = fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avp_operator_determined_barring);
ogs_assert(ret == 0);
}
}

if (subdatamask & OGS_DIAM_S6A_SUBDATA_NAM) {
Expand Down
7 changes: 7 additions & 0 deletions tests/common/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ bson_t *test_db_new_simple(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -1615,6 +1616,7 @@ bson_t *test_db_new_qos_flow(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -1743,6 +1745,7 @@ bson_t *test_db_new_session(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -1893,6 +1896,7 @@ bson_t *test_db_new_ims(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -2270,6 +2274,7 @@ bson_t *test_db_new_slice_with_same_dnn(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -2647,6 +2652,7 @@ bson_t *test_db_new_slice_with_different_dnn(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down Expand Up @@ -2801,6 +2807,7 @@ bson_t *test_db_new_non3gpp(test_ue_t *test_ue)
"subscribed_rau_tau_timer", BCON_INT32(12),
"network_access_mode", BCON_INT32(0),
"subscriber_status", BCON_INT32(0),
"operator_determined_barring", BCON_INT32(0),
"access_restriction_data", BCON_INT32(32)
);
ogs_assert(doc);
Expand Down
4 changes: 4 additions & 0 deletions webui/server/models/subscriber.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ const Subscriber = new Schema({
$type: Number,
default: 0 // Service Granted
},
operator_determined_barring: {
$type: Number,
default: 0 // No barring
},
network_access_mode: {
$type: Number,
default: 0 // Packet and Circuit
Expand Down

0 comments on commit f00cbac

Please sign in to comment.