From 8b4f8addb3f352d59a7659518ce10b10e53af8ae Mon Sep 17 00:00:00 2001 From: gckopper <41166074+gckopper@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:53:53 -0300 Subject: [PATCH] adding a patch for the plmn id, sst and sd encoding in the example xApps that come with flexric --- .../flexric/fix_plmn_sst_sd_encoding.patch | 165 ++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 RICs/near-realtime/flexric/fix_plmn_sst_sd_encoding.patch diff --git a/RICs/near-realtime/flexric/fix_plmn_sst_sd_encoding.patch b/RICs/near-realtime/flexric/fix_plmn_sst_sd_encoding.patch new file mode 100644 index 0000000..67b57fb --- /dev/null +++ b/RICs/near-realtime/flexric/fix_plmn_sst_sd_encoding.patch @@ -0,0 +1,165 @@ +diff --git a/examples/xApp/c/control/xapp_oran_ctrl.c b/examples/xApp/c/control/xapp_oran_ctrl.c +index 8c30d02..c5ea3e2 100644 +--- a/examples/xApp/c/control/xapp_oran_ctrl.c ++++ b/examples/xApp/c/control/xapp_oran_ctrl.c +@@ -25,6 +25,9 @@ + #include "../../../../src/util/time_now_us.h" + #include "../../../../src/util/alg_ds/ds/lock_guard/lock_guard.h" + #include "../../../../src/sm/rc_sm/rc_sm_id.h" ++#include "lib/3gpp/ie/plmn_identity.h" ++#include "util/byte_array.h" ++#include + #include + #include + #include +@@ -53,6 +56,37 @@ e2sm_rc_ctrl_hdr_frmt_1_t gen_rc_ctrl_hdr_frmt_1(ue_id_e2sm_t ue_id, uint32_t ri + return dst; + } + ++static ++byte_array_t plmn_id_to_ba(e2sm_plmn_t id) { ++ assert(id.mcc < 1000 && "Tried to convert an MCC with more than 3 digits"); ++ assert((id.mnc < 1000 || (id.mnc_digit_len == 2 && id.mnc < 100)) && "Tried to convert an invalid MNC"); ++ uint8_t* buf = calloc(3, sizeof(uint8_t)); ++ byte_array_t dst = {.len=3, .buf=buf}; ++ buf[0] = ((id.mcc / 10) % 10) << 4 | (id.mcc / 100); ++ buf[1] = (3 - id.mnc_digit_len) * 0xf0 | id.mnc/100 << 4 | (id.mcc % 10); ++ buf[2] = (id.mnc % 10) << 4 | ((id.mnc/10)%10); ++ return dst; ++} ++ ++static ++byte_array_t sst_to_ba(uint8_t sst) { ++ uint8_t* buf = calloc(1, sizeof(uint8_t)); ++ byte_array_t dst = {.len=1, .buf=buf}; ++ buf[0] = sst; ++ return dst; ++} ++ ++static ++byte_array_t sd_to_ba(uint32_t sd) { ++ assert(sd <= 0xffffff && "SD provided is too big"); ++ uint8_t* buf = calloc(3, sizeof(uint8_t)); ++ byte_array_t dst = {.len=3, .buf=buf}; ++ buf[0] = sd & 0xff; ++ buf[1] = (sd >> 8) & 0xff; ++ buf[2] = (sd >> 16) & 0xff; ++ return dst; ++} ++ + static + e2sm_rc_ctrl_hdr_t gen_rc_ctrl_hdr(e2sm_rc_ctrl_hdr_e hdr_frmt, ue_id_e2sm_t ue_id, uint32_t ric_style_type, uint16_t ctrl_act_id) + { +@@ -85,15 +119,17 @@ typedef enum { + + static + void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, +- const char* sst_str, +- const char* sd_str, +- int dedicated_prb) ++ const byte_array_t plmn, ++ const byte_array_t sst, ++ const byte_array_t sd, ++ int min_prb, ++ int max_prb) + { + // RRM Policy Ratio Group, STRUCTURE (RRM Policy Ratio List -> RRM Policy Ratio Group) + // lst_ran_param_t* RRM_Policy_Ratio_Group = &RRM_Policy_Ratio_List->ran_param_val.lst->lst_ran_param[0]; + RRM_Policy_Ratio_Group->ran_param_id = RRM_Policy_Ratio_Group_8_4_3_6; +- RRM_Policy_Ratio_Group->ran_param_struct.sz_ran_param_struct = 4; +- RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct = calloc(4, sizeof(seq_ran_param_t)); ++ RRM_Policy_Ratio_Group->ran_param_struct.sz_ran_param_struct = 3; ++ RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct = calloc(3, sizeof(seq_ran_param_t)); + assert(RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct != NULL && "Memory exhausted"); + // RRM Policy, STRUCTURE (RRM Policy Ratio Group -> RRM Policy) + seq_ran_param_t* RRM_Policy = &RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct[0]; +@@ -126,10 +162,8 @@ void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, + PLMN_Identity->ran_param_val.flag_false = calloc(1, sizeof(ran_parameter_value_t)); + assert(PLMN_Identity->ran_param_val.flag_false != NULL && "Memory exhausted"); + PLMN_Identity->ran_param_val.flag_false->type = OCTET_STRING_RAN_PARAMETER_VALUE; +- char plmnid_str[] = "50501"; +- byte_array_t plmn_id = cp_str_to_ba(plmnid_str); // TODO +- PLMN_Identity->ran_param_val.flag_false->octet_str_ran.len = plmn_id.len; +- PLMN_Identity->ran_param_val.flag_false->octet_str_ran.buf = plmn_id.buf; ++ PLMN_Identity->ran_param_val.flag_false->octet_str_ran.len = plmn.len; ++ PLMN_Identity->ran_param_val.flag_false->octet_str_ran.buf = plmn.buf; + // S-NSSAI, STRUCTURE (RRM Policy Member -> S-NSSAI) + seq_ran_param_t* S_NSSAI = &RRM_Policy_Member->ran_param_struct.ran_param_struct[1]; + S_NSSAI->ran_param_id = S_NSSAI_8_4_3_6; +@@ -146,7 +180,6 @@ void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, + assert(SST->ran_param_val.flag_false != NULL && "Memory exhausted"); + SST->ran_param_val.flag_false->type = OCTET_STRING_RAN_PARAMETER_VALUE; + // char sst_str[] = "1"; +- byte_array_t sst = cp_str_to_ba(sst_str); //TODO + SST->ran_param_val.flag_false->octet_str_ran.len = sst.len; + SST->ran_param_val.flag_false->octet_str_ran.buf = sst.buf; + // SD, ELEMENT (S-NSSAI -> SD) +@@ -157,7 +190,6 @@ void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, + assert(SD->ran_param_val.flag_false != NULL && "Memory exhausted"); + SD->ran_param_val.flag_false->type = OCTET_STRING_RAN_PARAMETER_VALUE; + // char sd_str[] = "0"; +- byte_array_t sd = cp_str_to_ba(sd_str); //TODO + SD->ran_param_val.flag_false->octet_str_ran.len = sd.len; + SD->ran_param_val.flag_false->octet_str_ran.buf = sd.buf; + // Min PRB Policy Ratio, ELEMENT (RRM Policy Ratio Group -> Min PRB Policy Ratio) +@@ -167,7 +199,6 @@ void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, + Min_PRB_Policy_Ratio->ran_param_val.flag_false = calloc(1, sizeof(ran_parameter_value_t)); + assert(Min_PRB_Policy_Ratio->ran_param_val.flag_false != NULL && "Memory exhausted"); + Min_PRB_Policy_Ratio->ran_param_val.flag_false->type = INTEGER_RAN_PARAMETER_VALUE; +- int min_prb = 5; //TODO + Min_PRB_Policy_Ratio->ran_param_val.flag_false->int_ran = min_prb; + // Max PRB Policy Ratio, ELEMENT (RRM Policy Ratio Group -> Max PRB Policy Ratio) + seq_ran_param_t* Max_PRB_Policy_Ratio = &RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct[2]; +@@ -176,25 +207,15 @@ void gen_rrm_policy_ratio_group(lst_ran_param_t* RRM_Policy_Ratio_Group, + Max_PRB_Policy_Ratio->ran_param_val.flag_false = calloc(1, sizeof(ran_parameter_value_t)); + assert(Max_PRB_Policy_Ratio->ran_param_val.flag_false != NULL && "Memory exhausted"); + Max_PRB_Policy_Ratio->ran_param_val.flag_false->type = INTEGER_RAN_PARAMETER_VALUE; +- int max_prb = 51; //TODO + Max_PRB_Policy_Ratio->ran_param_val.flag_false->int_ran = max_prb; + // Dedicated PRB Policy Ratio, ELEMENT (RRM Policy Ratio Group -> Dedicated PRB Policy Ratio) +- seq_ran_param_t* Dedicated_PRB_Policy_Ratio = &RRM_Policy_Ratio_Group->ran_param_struct.ran_param_struct[3]; +- Dedicated_PRB_Policy_Ratio->ran_param_id = Dedicated_PRB_Policy_Ratio_8_4_3_6; +- Dedicated_PRB_Policy_Ratio->ran_param_val.type = ELEMENT_KEY_FLAG_FALSE_RAN_PARAMETER_VAL_TYPE; +- Dedicated_PRB_Policy_Ratio->ran_param_val.flag_false = calloc(1, sizeof(ran_parameter_value_t)); +- assert(Dedicated_PRB_Policy_Ratio->ran_param_val.flag_false != NULL && "Memory exhausted"); +- Dedicated_PRB_Policy_Ratio->ran_param_val.flag_false->type = INTEGER_RAN_PARAMETER_VALUE; +- // int dedicated_prb = 70; //TODO +- Dedicated_PRB_Policy_Ratio->ran_param_val.flag_false->int_ran = dedicated_prb; +- + return; + } + + static + void gen_rrm_policy_ratio_list(seq_ran_param_t* RRM_Policy_Ratio_List) + { +- int num_slice = 2; ++ int num_slice = 1; + // seq_ran_param_t* RRM_Policy_Ratio_List = &dst.ran_param[0]; + RRM_Policy_Ratio_List->ran_param_id = RRM_Policy_Ratio_List_8_4_3_6; + RRM_Policy_Ratio_List->ran_param_val.type = LIST_RAN_PARAMETER_VAL_TYPE; +@@ -204,14 +225,19 @@ void gen_rrm_policy_ratio_list(seq_ran_param_t* RRM_Policy_Ratio_List) + RRM_Policy_Ratio_List->ran_param_val.lst->lst_ran_param = calloc(num_slice, sizeof(lst_ran_param_t)); + assert(RRM_Policy_Ratio_List->ran_param_val.lst->lst_ran_param != NULL && "Memory exhausted"); + +- const char* sst_str[] = {"1", "1"}; +- const char* sd_str[] = {"0", "5"}; +- int dedicated_prb[] = {70, 30}; ++ const byte_array_t sd = sd_to_ba(0x111111); ++ const byte_array_t sst = sst_to_ba(0x1); ++ e2sm_plmn_t id = {.mcc=1,.mnc=1,.mnc_digit_len=2}; ++ const byte_array_t plmn = plmn_id_to_ba(id); ++ int min_prb[] = {0}; ++ int max_prb[] = {5}; + for (int i = 0; i < num_slice; i++) { + gen_rrm_policy_ratio_group(&RRM_Policy_Ratio_List->ran_param_val.lst->lst_ran_param[i], +- sst_str[i], +- sd_str[i], +- dedicated_prb[i]); ++ plmn, ++ sst, ++ sd, ++ min_prb[i], ++ max_prb[i]); + } + + return;