Factor out NSSAI, to be used in other messages lates

This commit is contained in:
Robert Schmidt
2025-06-27 11:40:54 +02:00
parent 9f0373e051
commit e991f26ff1
3 changed files with 29 additions and 12 deletions
+2 -11
View File
@@ -394,11 +394,7 @@ static int read_slice_info(const F1AP_ServedPLMNs_Item_t *plmn, nssai_t *nssai,
AssertFatal(ssl->list.count <= max_nssai, "cannot handle more than 16 slices\n");
for (int s = 0; s < ssl->list.count; ++s) {
const F1AP_SliceSupportItem_t *sl = ssl->list.array[s];
nssai_t *n = &nssai[s];
OCTET_STRING_TO_INT8(&sl->sNSSAI.sST, n->sst);
n->sd = 0xffffff;
if (sl->sNSSAI.sD != NULL)
OCTET_STRING_TO_INT24(sl->sNSSAI.sD, n->sd);
nssai[s] = decode_nssai(&sl->sNSSAI);
}
return ssl->list.count;
@@ -418,12 +414,7 @@ static F1AP_ProtocolExtensionContainer_10696P34_t *write_slice_info(int num_ssi,
for (int s = 0; s < num_ssi; s++) {
asn1cSequenceAdd(slice_support_list->list, F1AP_SliceSupportItem_t, slice);
const nssai_t *n = &nssai[s];
INT8_TO_OCTET_STRING(n->sst, &slice->sNSSAI.sST);
if (n->sd != 0xffffff) {
asn1cCalloc(slice->sNSSAI.sD, tmp);
INT24_TO_OCTET_STRING(n->sd, tmp);
}
slice->sNSSAI = encode_nssai(&nssai[s]);
}
return p;
+23 -1
View File
@@ -25,7 +25,7 @@
#include "OCTET_STRING.h"
#include "common/utils/utils.h"
#include "common/utils/assertions.h"
#include "common/utils/utils.h"
#include "common/utils/oai_asn1.h"
bool eq_f1ap_plmn(const plmn_id_t *a, const plmn_id_t *b)
{
@@ -115,6 +115,28 @@ uint8_t *cp_octet_string(const OCTET_STRING_t *os, int *len)
return buf;
}
F1AP_SNSSAI_t encode_nssai(const nssai_t *nssai)
{
F1AP_SNSSAI_t enc = {0};
INT8_TO_OCTET_STRING(nssai->sst, &enc.sST);
// see 23.003 sec. 28.4.2: 0xffffff means "no SD"
if (nssai->sd != 0xffffff) {
asn1cCalloc(enc.sD, tmp);
INT24_TO_OCTET_STRING(nssai->sd, tmp);
}
return enc;
}
nssai_t decode_nssai(const F1AP_SNSSAI_t *nssai)
{
// see 23.003 sec. 28.4.2: 0xffffff means "no SD"
nssai_t dec = { .sd = 0xffffff, };
OCTET_STRING_TO_INT8(&nssai->sST, dec.sst);
if (nssai->sD != NULL)
OCTET_STRING_TO_INT24(nssai->sD, dec.sd);
return dec;
}
F1AP_Cause_t encode_f1ap_cause(f1ap_Cause_t cause, long cause_value)
{
F1AP_Cause_t f1_cause = {0};
+4
View File
@@ -30,6 +30,7 @@
#include "common/utils/ds/byte_array.h"
#include "F1AP_Cause.h"
#include "F1AP_SNSSAI.h"
#include "f1ap_messages_types.h"
#ifdef ENABLE_TESTS
@@ -120,6 +121,9 @@ bool eq_f1ap_tx_bandwidth(const struct f1ap_transmission_bandwidth_t *a, const s
struct OCTET_STRING;
uint8_t *cp_octet_string(const struct OCTET_STRING *os, int *len);
F1AP_SNSSAI_t encode_nssai(const nssai_t *nssai);
nssai_t decode_nssai(const F1AP_SNSSAI_t *nssai);
F1AP_Cause_t encode_f1ap_cause(f1ap_Cause_t cause, long cause_value);
bool decode_f1ap_cause(F1AP_Cause_t f1_cause, f1ap_Cause_t *cause, long *cause_value);