Commit 7e455aab authored by Niuhaiwen's avatar Niuhaiwen

merge from eurecom-amf

parent 98461495
......@@ -21,7 +21,7 @@
AMF =
{
INSTANCE_ID = 1; # 0 is the default
INSTANCE_ID = 10; # 0 is the default
PID_DIRECTORY = "/var/run"; # /var/run is the default
AMF_NAME = "OAI-AMF";
......@@ -74,7 +74,7 @@ AMF =
PORT = 8282; # YOUR NETWORK CONFIG HERE
SMF_INSTANCES_POOL = (
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.199.203"; PORT = "8889"; VERSION = "v1"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 1; IPV4_ADDRESS = "192.168.199.203"; PORT = "8889"; VERSION = "v2"; SELECTED = "true"}, # YOUR SMF CONFIG HERE
{SMF_INSTANCE_ID = 2; IPV4_ADDRESS = "192.168.122.2"; PORT = "80"; VERSION = "v1"; SELECTED = "false"} # YOUR SMF CONFIG HERE
);
};
......@@ -96,7 +96,7 @@ AMF =
NAS:
{
ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "NIA2" , "NIA1" , "NIA0" ];
ORDERED_SUPPORTED_INTEGRITY_ALGORITHM_LIST = [ "NIA1" , "NIA1" , "NIA1" ];
ORDERED_SUPPORTED_CIPHERING_ALGORITHM_LIST = [ "NEA0" , "NEA1" , "NEA2" ];
};
......
......@@ -221,7 +221,7 @@ void amf_n1::handle_itti_message(itti_uplink_nas_data_ind &nas_data_ind) {
else {
Logger::amf_n1().error("No existing nas_context with GUTI %s",
nas_data_ind.guti.c_str());
return;
//return;
}
} else {
if (is_amf_ue_id_2_nas_context(amf_ue_ngap_id))
......@@ -368,7 +368,8 @@ void amf_n1::nas_signalling_establishment_request_handle(
break;
case SERVICE_REQUEST: {
Logger::amf_n1().debug("Received service request message, handling...");
nc.get()->security_ctx->ul_count.seq_num = ulCount;
if(nc.get())
nc.get()->security_ctx->ul_count.seq_num = ulCount;
service_request_handle(true, nc, ran_ue_ngap_id, amf_ue_ngap_id,
plain_msg);
}
......@@ -2256,7 +2257,8 @@ void amf_n1::ue_authentication_simulator(uint8_t *rand, uint8_t *autn) {
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
uint8_t key[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
string serving_network = "5G:mnc011.mcc460.3gppnetwork.org";
//string serving_network = "5G:mnc011.mcc460.3gppnetwork.org";
string serving_network = "5G:mnc011.mcc110.3gppnetwork.org";
print_buffer("amf_n1", "[ue] local opc", opc, 16);
print_buffer("amf_n1", "[ue] local key", key, 16);
uint8_t res[8], resStar[16];
......
......@@ -182,7 +182,8 @@ void amf_n11::handle_itti_message(
}
std::string smf_ip_addr, remote_uri;
std::shared_ptr<pdu_session_context> context;
context = supi_to_pdu_ctx(supi);
//remove http port from the URI if existed
std::size_t found_port = smf_addr.find(":");
if (found_port != std::string::npos)
......@@ -192,16 +193,16 @@ void amf_n11::handle_itti_message(
std::size_t found = psc.get()->smf_context_location.find(smf_ip_addr);
if (found != std::string::npos)
remote_uri = psc.get()->smf_context_location + "/modify";
remote_uri = context.get()->smf_context_location + "/modify";
else
remote_uri = smf_addr + psc.get()->smf_context_location + "/modify";
remote_uri = smf_addr + context.get()->smf_context_location + "/modify";
Logger::amf_n11().debug("SMF URI: %s", remote_uri.c_str());
nlohmann::json pdu_session_update_request = { };
//if (itti_msg.is_n2sm_set){
pdu_session_update_request["n2SmInfoType"] = itti_msg.n2sm_info_type;
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2msg";
pdu_session_update_request["n2SmInfo"]["contentId"] = "n2SmMsg";
std::string json_part = pdu_session_update_request.dump();
std::string n2SmMsg;
octet_stream_2_hex_stream((uint8_t*) bdata(itti_msg.n2sm),
......@@ -358,15 +359,19 @@ void amf_n11::handle_pdu_session_initial_request(
pdu_session_establishment_request["pei"] = "imei-200000000000001";
pdu_session_establishment_request["gpsi"] = "msisdn-200000000001";
pdu_session_establishment_request["dnn"] = dnn.c_str();
pdu_session_establishment_request["sNssai"]["sst"] = psc.get()->snssai.sST;
pdu_session_establishment_request["sNssai"]["sd"] = psc.get()->snssai.sD;
//pdu_session_establishment_request["sNssai"]["sst"] = psc.get()->snssai.sST;
pdu_session_establishment_request["sNssai"]["sst"] = 1;
pdu_session_establishment_request["sNssai"]["sd"] = "0";
//pdu_session_establishment_request["sNssai"]["sd"] = psc.get()->snssai.sD;
pdu_session_establishment_request["pduSessionId"] = psc.get()->pdu_session_id;
pdu_session_establishment_request["requestType"] = "INITIAL_REQUEST"; //TODO: from SM_MSG
pdu_session_establishment_request["servingNfId"] = "servingNfId";
pdu_session_establishment_request["servingNetwork"]["mcc"] = psc.get()->plmn
.mcc;
pdu_session_establishment_request["servingNetwork"]["mnc"] = psc.get()->plmn
.mnc;
//pdu_session_establishment_request["servingNetwork"]["mcc"] = psc.get()->plmn
// .mcc;
//pdu_session_establishment_request["servingNetwork"]["mnc"] = psc.get()->plmn
// .mnc;
pdu_session_establishment_request["servingNetwork"]["mcc"] = "110";
pdu_session_establishment_request["servingNetwork"]["mnc"] = "011";
pdu_session_establishment_request["anType"] = "3GPP_ACCESS"; //TODO
pdu_session_establishment_request["smContextStatusUri"] =
"smContextStatusUri";
......@@ -628,7 +633,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData,
}
//Transfer N1/N2 to gNB/UE if available
if (number_parts > 1) {
/*if (number_parts > 1) {
try {
response_data = nlohmann::json::parse(json_data_response);
} catch (nlohmann::json::exception &e) {
......@@ -648,7 +653,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData,
itti_msg->is_n1sm_set = true;
}
if (n2sm.size() > 0) {
if (n2sm.size() > 0) {
msg_str_2_msg_hex(n2sm, n2sm_hex);
print_buffer("amf_n11", "Get response n2sm:",
(uint8_t*) bdata(n2sm_hex), blength(n2sm_hex));
......@@ -667,7 +672,7 @@ void amf_n11::curl_http_client(std::string remoteUri, std::string jsonData,
"Could not send ITTI message %s to task TASK_AMF_APP",
i->get_msg_name());
}
}
}*/
}
curl_slist_free_all(headers);
......
......@@ -306,6 +306,8 @@ void amf_n2::handle_itti_message(itti_ng_setup_request &itti_msg) {
}
}
set_gnb_id_2_gnb_context(gnb_id, gc);
//store Paging DRX in gNB context
Logger::amf_n2().debug("Encoding NG_SETUP_RESPONSE ...");
//encode NG SETUP RESPONSE message with information stored in configuration file and send_msg
......
......@@ -253,7 +253,7 @@ NativeEnumerated_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
//printf("test0515 Decoding %s as NativeEnumerated\n", td->name);
printf("test0515 Decoding %s as NativeEnumerated\n", td->name);
if(ct->flags & APC_EXTENSIBLE) {
......
......@@ -332,7 +332,7 @@ NativeInteger_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
(void)opt_codec_ctx;
ASN_DEBUG("Decoding NativeInteger %s (APER)", td->name);
//printf("test0515 Decoding NativeInteger %s (APER)\n", td->name);
printf("test0515 Decoding NativeInteger %s (APER)\n", td->name);
if(!native) {
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
......
......@@ -413,12 +413,16 @@ OPEN_TYPE_aper_get(const asn_codec_ctx_t *opt_codec_ctx,
if(!elm->type_selector) {
ASN_DEBUG("Type selector is not defined for Open Type %s->%s->%s",
td->name, elm->name, elm->type->name);
printf("Type selector is not defined for Open Type %s->%s->%s\n",
td->name, elm->name, elm->type->name);
ASN__DECODE_FAILED;
}
selected = elm->type_selector(td, sptr);
printf("element selected %d \n", selected.presence_index);
if(!selected.presence_index) {
ASN__DECODE_FAILED;
printf("element ASN DECODE FAILED");
}
/* Fetch the pointer to this member */
......
......@@ -13,8 +13,8 @@ static asn_enc_rval_t asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
asn_app_consume_bytes_f *callback,
void *callback_key);
struct callback_count_bytes_key {
struct callback_count_bytes_key
{
asn_app_consume_bytes_f *callback;
void *callback_key;
size_t computed_size;
......@@ -24,31 +24,36 @@ struct callback_count_bytes_key {
* Encoder which just counts bytes that come through it.
*/
static int
callback_count_bytes_cb(const void *data, size_t size, void *keyp) {
callback_count_bytes_cb(const void *data, size_t size, void *keyp)
{
struct callback_count_bytes_key *key = keyp;
int ret;
ret = key->callback(data, size, key->callback_key);
if(ret >= 0) {
if (ret >= 0)
{
key->computed_size += size;
}
return ret;
}
struct overrun_encoder_key {
struct overrun_encoder_key
{
void *buffer;
size_t buffer_size;
size_t computed_size;
};
struct dynamic_encoder_key {
struct dynamic_encoder_key
{
void *buffer;
size_t buffer_size;
size_t computed_size;
};
struct callback_failure_catch_key {
struct callback_failure_catch_key
{
asn_app_consume_bytes_f *callback;
void *callback_key;
int callback_failed;
......@@ -59,16 +64,20 @@ struct callback_failure_catch_key {
* even if it reaches the end of the buffer.
*/
static int
overrun_encoder_cb(const void *data, size_t size, void *keyp) {
overrun_encoder_cb(const void *data, size_t size, void *keyp)
{
struct overrun_encoder_key *key = keyp;
if(key->computed_size + size > key->buffer_size) {
if (key->computed_size + size > key->buffer_size)
{
/*
* Avoid accident on the next call:
* stop adding bytes to the buffer.
*/
key->buffer_size = 0;
} else {
}
else
{
memcpy((char *)key->buffer + key->computed_size, data, size);
}
key->computed_size += size;
......@@ -81,23 +90,30 @@ overrun_encoder_cb(const void *data, size_t size, void *keyp) {
* to count even if allocation failed.
*/
static int
dynamic_encoder_cb(const void *data, size_t size, void *keyp) {
dynamic_encoder_cb(const void *data, size_t size, void *keyp)
{
struct dynamic_encoder_key *key = keyp;
if(key->buffer) {
if(key->computed_size + size >= key->buffer_size) {
if (key->buffer)
{
if (key->computed_size + size >= key->buffer_size)
{
void *p;
size_t new_size = key->buffer_size;
do {
do
{
new_size *= 2;
} while(new_size <= key->computed_size + size);
} while (new_size <= key->computed_size + size);
p = REALLOC(key->buffer, new_size);
if(p) {
if (p)
{
key->buffer = p;
key->buffer_size = new_size;
} else {
}
else
{
FREEMEM(key->buffer);
key->buffer = 0;
key->buffer_size = 0;
......@@ -117,12 +133,14 @@ dynamic_encoder_cb(const void *data, size_t size, void *keyp) {
* Encoder which help convert the application level encoder failure into EIO.
*/
static int
callback_failure_catch_cb(const void *data, size_t size, void *keyp) {
callback_failure_catch_cb(const void *data, size_t size, void *keyp)
{
struct callback_failure_catch_key *key = keyp;
int ret;
ret = key->callback(data, size, key->callback_key);
if(ret < 0) {
if (ret < 0)
{
key->callback_failed = 1;
}
......@@ -132,11 +150,13 @@ callback_failure_catch_cb(const void *data, size_t size, void *keyp) {
asn_enc_rval_t
asn_encode(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax, const asn_TYPE_descriptor_t *td,
const void *sptr, asn_app_consume_bytes_f *callback, void *callback_key) {
const void *sptr, asn_app_consume_bytes_f *callback, void *callback_key)
{
struct callback_failure_catch_key cb_key;
asn_enc_rval_t er;
if(!callback) {
if (!callback)
{
errno = EINVAL;
ASN__ENCODE_FAILED;
}
......@@ -147,7 +167,8 @@ asn_encode(const asn_codec_ctx_t *opt_codec_ctx,
er = asn_encode_internal(opt_codec_ctx, syntax, td, sptr,
callback_failure_catch_cb, &cb_key);
if(cb_key.callback_failed) {
if (cb_key.callback_failed)
{
assert(er.encoded == -1);
assert(errno == EBADF);
errno = EIO;
......@@ -160,11 +181,13 @@ asn_enc_rval_t
asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax,
const asn_TYPE_descriptor_t *td, const void *sptr,
void *buffer, size_t buffer_size) {
void *buffer, size_t buffer_size)
{
struct overrun_encoder_key buf_key;
asn_enc_rval_t er;
if(buffer_size > 0 && !buffer) {
if (buffer_size > 0 && !buffer)
{
errno = EINVAL;
ASN__ENCODE_FAILED;
}
......@@ -176,7 +199,8 @@ asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
er = asn_encode_internal(opt_codec_ctx, syntax, td, sptr,
overrun_encoder_cb, &buf_key);
if(er.encoded >= 0 && (size_t)er.encoded != buf_key.computed_size) {
if (er.encoded >= 0 && (size_t)er.encoded != buf_key.computed_size)
{
ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE
" yet produced %" ASN_PRI_SIZE " bytes",
er.encoded, buf_key.computed_size);
......@@ -189,7 +213,8 @@ asn_encode_to_buffer(const asn_codec_ctx_t *opt_codec_ctx,
asn_encode_to_new_buffer_result_t
asn_encode_to_new_buffer(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax,
const asn_TYPE_descriptor_t *td, const void *sptr) {
const asn_TYPE_descriptor_t *td, const void *sptr)
{
struct dynamic_encoder_key buf_key;
asn_encode_to_new_buffer_result_t res;
......@@ -200,19 +225,19 @@ asn_encode_to_new_buffer(const asn_codec_ctx_t *opt_codec_ctx,
res.result = asn_encode_internal(opt_codec_ctx, syntax, td, sptr,
dynamic_encoder_cb, &buf_key);
if(res.result.encoded >= 0
&& (size_t)res.result.encoded != buf_key.computed_size) {
if (res.result.encoded >= 0 && (size_t)res.result.encoded != buf_key.computed_size)
{
ASN_DEBUG("asn_encode() returned %" ASN_PRI_SSIZE
" yet produced %" ASN_PRI_SIZE " bytes",
res.result.encoded, buf_key.computed_size);
assert(res.result.encoded < 0
|| (size_t)res.result.encoded == buf_key.computed_size);
assert(res.result.encoded < 0 || (size_t)res.result.encoded == buf_key.computed_size);
}
res.buffer = buf_key.buffer;
/* 0-terminate just in case. */
if(res.buffer) {
if (res.buffer)
{
assert(buf_key.computed_size < buf_key.buffer_size);
((char *)res.buffer)[buf_key.computed_size] = '\0';
}
......@@ -224,38 +249,46 @@ static asn_enc_rval_t
asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax,
const asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *callback, void *callback_key) {
asn_app_consume_bytes_f *callback, void *callback_key)
{
asn_enc_rval_t er;
enum xer_encoder_flags_e xer_flags = XER_F_CANONICAL;
(void)opt_codec_ctx; /* Parameters are not checked on encode yet. */
if(!td || !sptr) {
if (!td || !sptr)
{
errno = EINVAL;
ASN__ENCODE_FAILED;
}
switch(syntax) {
switch (syntax)
{
case ATS_NONSTANDARD_PLAINTEXT:
if(td->op->print_struct) {
if (td->op->print_struct)
{
struct callback_count_bytes_key cb_key;
cb_key.callback = callback;
cb_key.callback_key = callback_key;
cb_key.computed_size = 0;
if(td->op->print_struct(td, sptr, 1, callback_count_bytes_cb,
&cb_key)
< 0
|| callback_count_bytes_cb("\n", 1, &cb_key) < 0) {
if (td->op->print_struct(td, sptr, 1, callback_count_bytes_cb,
&cb_key) < 0 ||
callback_count_bytes_cb("\n", 1, &cb_key) < 0)
{
errno = EBADF; /* Structure has incorrect form. */
er.encoded = -1;
er.failed_type = td;
er.structure_ptr = sptr;
} else {
}
else
{
er.encoded = cb_key.computed_size;
er.failed_type = 0;
er.structure_ptr = 0;
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
......@@ -269,16 +302,23 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
/* BER is a superset of DER. */
/* Fall through. */
case ATS_DER:
if(td->op->der_encoder) {
if (td->op->der_encoder)
{
er = der_encode(td, sptr, callback, callback_key);
if(er.encoded == -1) {
if(er.failed_type && er.failed_type->op->der_encoder) {
errno = EBADF; /* Structure has incorrect form. */
} else {
if (er.encoded == -1)
{
if (er.failed_type && er.failed_type->op->der_encoder)
{
errno = EBADF; /* Structure has incorrect form. */
}
else
{
errno = ENOENT; /* DER is not defined for this type. */
}
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
......@@ -287,34 +327,41 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
errno = ENOENT; /* Transfer syntax is not defined for any type. */
ASN__ENCODE_FAILED;
#ifdef ASN_DISABLE_OER_SUPPORT
#ifdef ASN_DISABLE_OER_SUPPORT
case ATS_BASIC_OER:
case ATS_CANONICAL_OER:
errno = ENOENT; /* PER is not defined. */
ASN__ENCODE_FAILED;
break;
#else /* ASN_DISABLE_OER_SUPPORT */
#else /* ASN_DISABLE_OER_SUPPORT */
case ATS_BASIC_OER:
/* CANONICAL-OER is a superset of BASIC-OER. */
/* Fall through. */
case ATS_CANONICAL_OER:
if(td->op->oer_encoder) {
if (td->op->oer_encoder)
{
er = oer_encode(td, sptr, callback, callback_key);
if(er.encoded == -1) {
if(er.failed_type && er.failed_type->op->oer_encoder) {
errno = EBADF; /* Structure has incorrect form. */
} else {
if (er.encoded == -1)
{
if (er.failed_type && er.failed_type->op->oer_encoder)
{
errno = EBADF; /* Structure has incorrect form. */
}
else
{
errno = ENOENT; /* OER is not defined for this type. */
}
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
break;
#endif /* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
case ATS_UNALIGNED_BASIC_PER:
case ATS_UNALIGNED_CANONICAL_PER:
case ATS_ALIGNED_BASIC_PER:
......@@ -322,24 +369,33 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
errno = ENOENT; /* PER is not defined. */
ASN__ENCODE_FAILED;
break;
#else /* ASN_DISABLE_PER_SUPPORT */
#else /* ASN_DISABLE_PER_SUPPORT */
case ATS_UNALIGNED_BASIC_PER:
/* CANONICAL-UPER is a superset of BASIC-UPER. */
/* Fall through. */
case ATS_UNALIGNED_CANONICAL_PER:
if(td->op->uper_encoder) {
if (td->op->uper_encoder)
{
er = uper_encode(td, 0, sptr, callback, callback_key);
if(er.encoded == -1) {
if(er.failed_type && er.failed_type->op->uper_encoder) {
errno = EBADF; /* Structure has incorrect form. */
} else {
if (er.encoded == -1)
{
if (er.failed_type && er.failed_type->op->uper_encoder)
{
errno = EBADF; /* Structure has incorrect form. */
}
else
{
errno = ENOENT; /* UPER is not defined for this type. */
}
} else {
}
else
{
ASN_DEBUG("Complete encoded in %ld bits", (long)er.encoded);
if(er.encoded == 0) {
if (er.encoded == 0)
{
/* Enforce "Complete Encoding" of X.691 #11.1 */
if(callback("\0", 1, callback_key) < 0) {
if (callback("\0", 1, callback_key) < 0)
{
errno = EBADF;
ASN__ENCODE_FAILED;
}
......@@ -348,7 +404,9 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
/* Convert bits into bytes */
er.encoded = (er.encoded + 7) >> 3;
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
......@@ -357,19 +415,28 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
/* CANONICAL-APER is a superset of BASIC-APER. */
/* Fall through. */
case ATS_ALIGNED_CANONICAL_PER:
if(td->op->aper_encoder) {
if (td->op->aper_encoder)
{
er = aper_encode(td, 0, sptr, callback, callback_key);
if(er.encoded == -1) {
if(er.failed_type && er.failed_type->op->aper_encoder) {
errno = EBADF; /* Structure has incorrect form. */
} else {
if (er.encoded == -1)
{
if (er.failed_type && er.failed_type->op->aper_encoder)
{
errno = EBADF; /* Structure has incorrect form. */
}
else
{
errno = ENOENT; /* APER is not defined for this type. */
}
} else {
}
else
{
ASN_DEBUG("Complete encoded in %ld bits", (long)er.encoded);
if(er.encoded == 0) {
if (er.encoded == 0)
{
/* Enforce "Complete Encoding" of X.691 #11.1 */
if(callback("\0", 1, callback_key) < 0) {
if (callback("\0", 1, callback_key) < 0)
{
errno = EBADF;
ASN__ENCODE_FAILED;
}
......@@ -378,12 +445,14 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
/* Convert bits into bytes */
er.encoded = (er.encoded + 7) >> 3;
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
break;
#endif /* ASN_DISABLE_PER_SUPPORT */
#endif /* ASN_DISABLE_PER_SUPPORT */
case ATS_BASIC_XER:
/* CANONICAL-XER is a superset of BASIC-XER. */
......@@ -391,16 +460,23 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
xer_flags |= XER_F_BASIC;
/* Fall through. */
case ATS_CANONICAL_XER:
if(td->op->xer_encoder) {
if (td->op->xer_encoder)
{
er = xer_encode(td, sptr, xer_flags, callback, callback_key);
if(er.encoded == -1) {
if(er.failed_type && er.failed_type->op->xer_encoder) {
errno = EBADF; /* Structure has incorrect form. */
} else {
if (er.encoded == -1)
{
if (er.failed_type && er.failed_type->op->xer_encoder)
{
errno = EBADF; /* Structure has incorrect form. */
}
else
{
errno = ENOENT; /* XER is not defined for this type. */
}
}
} else {
}
else
{
errno = ENOENT; /* Transfer syntax is not defined for this type. */
ASN__ENCODE_FAILED;
}
......@@ -417,12 +493,15 @@ asn_encode_internal(const asn_codec_ctx_t *opt_codec_ctx,
asn_dec_rval_t
asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
enum asn_transfer_syntax syntax, const asn_TYPE_descriptor_t *td,
void **sptr, const void *buffer, size_t size) {
if(!td || !td->op || !sptr || (size && !buffer)) {
void **sptr, const void *buffer, size_t size)
{
if (!td || !td->op || !sptr || (size && !buffer))
{
ASN__DECODE_FAILED;
}
switch(syntax) {
switch (syntax)
{
case ATS_CER:
case ATS_NONSTANDARD_PLAINTEXT:
default:
......@@ -430,13 +509,19 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
ASN__DECODE_FAILED;
case ATS_RANDOM:
if(!td->op->random_fill) {
if (!td->op->random_fill)
{
ASN__DECODE_FAILED;
} else {
if(asn_random_fill(td, sptr, 16000) == 0) {
}
else
{
if (asn_random_fill(td, sptr, 16000) == 0)
{
asn_dec_rval_t ret = {RC_OK, 0};
return ret;
} else {
}
else
{
ASN__DECODE_FAILED;
}
}
......@@ -448,7 +533,7 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
case ATS_BASIC_OER:
case ATS_CANONICAL_OER:
#ifdef ASN_DISABLE_OER_SUPPORT
#ifdef ASN_DISABLE_OER_SUPPORT
errno = ENOENT;
ASN__DECODE_FAILED;
#else
......@@ -457,7 +542,7 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
case ATS_UNALIGNED_BASIC_PER:
case ATS_UNALIGNED_CANONICAL_PER:
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
errno = ENOENT;
ASN__DECODE_FAILED;
#else
......@@ -466,7 +551,7 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
case ATS_ALIGNED_BASIC_PER:
case ATS_ALIGNED_CANONICAL_PER:
#ifdef ASN_DISABLE_PER_SUPPORT
#ifdef ASN_DISABLE_PER_SUPPORT
errno = ENOENT;
ASN__DECODE_FAILED;
#else
......@@ -478,4 +563,3 @@ asn_decode(const asn_codec_ctx_t *opt_codec_ctx,
return xer_decode(opt_codec_ctx, td, sptr, buffer, size);
}
}
......@@ -1050,7 +1050,7 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(value < 0) ASN__DECODE_STARVED;
ASN_DEBUG("CHOICE %s got index %d in range %d",
td->name, value, ct->range_bits);
//printf("test0515 CHOICE %s got index %d in range %d\n", td->name, value, ct->range_bits);
printf("test0515 CHOICE %s got index %d in range %d\n", td->name, value, ct->range_bits);
if(value > ct->upper_bound)
ASN__DECODE_FAILED;
} else {
......@@ -1069,7 +1069,7 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
/* Set presence to be able to free it later */
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
printf("test1130 decoding td->name %s set present %d\n", td->name, value+1);
elm = &td->elements[value];
if(elm->flags & ATF_POINTER) {
/* Member is a pointer to another structure */
......@@ -1079,7 +1079,7 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
memb_ptr2 = &memb_ptr;
}
ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name);
//printf("test0515 Discovered CHOICE %s encodes %s\n", td->name, elm->name);
printf("test1130 decoding element(%s) in td->name(%s), pointer(%p)\n", elm->name, td->name, memb_ptr2);
if(ct && ct->range_bits >= 0) {
rv = elm->type->op->aper_decoder(opt_codec_ctx, elm->type,
......@@ -1092,7 +1092,7 @@ CHOICE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
if(rv.code != RC_OK){
ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d",
elm->name, td->name, rv.code);
//printf("test0515 Failed to decode %s in %s (CHOICE) %d\n", elm->name, td->name, rv.code);
printf("test0515 Failed to decode %s in %s (CHOICE) %d\n", elm->name, td->name, rv.code);
}
return rv;
}
......@@ -1186,26 +1186,30 @@ CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
const asn_CHOICE_specifics_t *specs = (const asn_CHOICE_specifics_t *)td->specifics;
unsigned present;
if(!sptr) printf("test1130 sptr null\n");
else printf("test1130 OK\n");
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/*
* Figure out which CHOICE element is encoded.
*/
present = _fetch_present_idx(sptr, specs->pres_offset,specs->pres_size);
printf("test1130 present %d, td->elements %d\n", present, td->elements_count);
/*
* Print that element.
*/
if(present > 0 && present <= td->elements_count) {
asn_TYPE_member_t *elm = &td->elements[present-1];
printf("test1130 td_name %s, element_name %s\n", td->name, elm->name);
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
memb_ptr = *(const void * const *)((const char *)sptr + elm->memb_offset);
printf("test1130 memb_ptr1 (%p)\n", memb_ptr);
if(!memb_ptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
} else {
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
printf("test1130 memb_ptr2 (%p)\n", memb_ptr);
}
/* Print member's name and stuff */
......@@ -1218,6 +1222,7 @@ CHOICE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
return elm->type->op->print_struct(elm->type, memb_ptr, ilevel,
cb, app_key);
} else {
printf("test1130 casued by present = %d\n", present);
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
}
}
......
......@@ -937,7 +937,8 @@ SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
size_t edx;
int ret;
if(!sptr) printf("test1130 memory not present %s \n", td->name);
else printf("test1130 memory present %s \n", td->name);
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/* Dump preamble */
......@@ -947,6 +948,7 @@ SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
for(edx = 0; edx < td->elements_count; edx++) {
asn_TYPE_member_t *elm = &td->elements[edx];
printf("element name: %s\n", elm->name);
const void *memb_ptr;
if(elm->flags & ATF_POINTER) {
......@@ -958,6 +960,7 @@ SEQUENCE_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
}
} else {
memb_ptr = (const void *)((const char *)sptr + elm->memb_offset);
printf("test1130 element name(%s): mem_ptr(%p)\n", elm->name, memb_ptr);
}
/* Indentation */
......@@ -1507,7 +1510,7 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}
ASN_DEBUG("Decoding %s as SEQUENCE (APER)", td->name);
//printf("test0515 Decoding %s as SEQUENCE (APER)\n", td->name);
printf("test0515 Decoding %s as SEQUENCE (APER)\n", td->name);
/* Handle extensions */
if(specs->first_extension < 0) {
......@@ -1540,6 +1543,7 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
*/
for(edx = 0; edx < td->elements_count; edx++) {
asn_TYPE_member_t *elm = &td->elements[edx];
printf("test1130 decoding element (%s)\n", elm->name);
void *memb_ptr; /* Pointer to the member */
void **memb_ptr2; /* Pointer to that pointer */
#if 0
......@@ -1580,9 +1584,9 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
ASN_DEBUG("Member %s->%s is optional, p=%d (%d->%d)",
td->name, elm->name, present,
(int)opmd.nboff, (int)opmd.nbits);
//printf("test0515 Member %s->%s is optional, p=%d (%d->%d)\n",
// td->name, elm->name, present,
// (int)opmd.nboff, (int)opmd.nbits);
printf("test0515 Member %s->%s is optional, p=%d (%d->%d)\n",
td->name, elm->name, present,
(int)opmd.nboff, (int)opmd.nbits);
if(present == 0) {
/* This element is not present */
if(elm->default_value_set) {
......@@ -1601,7 +1605,7 @@ SEQUENCE_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
/* Fetch the member from the stream */
ASN_DEBUG("Decoding member \"%s\" in %s", elm->name, td->name);
//printf("test0515 Decoding member \"%s\" in %s\n", elm->name, td->name);
printf("test0515 Decoding member \"%s\" in %s\n", elm->name, td->name);
if(elm->flags & ATF_OPEN_TYPE) {
rv = OPEN_TYPE_aper_get(opt_codec_ctx, td, st, elm, pd);
......
......@@ -799,7 +799,8 @@ SET_OF_print(const asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
int ret;
int i;
if(!sptr) printf("test1130 set_of_printf sptr null\n");
else printf("test1130 set_of_printf OK\n");
if(!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
/* Dump preamble */
......
......@@ -81,6 +81,7 @@ uper_open_type_get_simple(const asn_codec_ctx_t *ctx,
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
printf("test1130 decoding open type %s\n", td->name);
do {
chunk_bytes = uper_get_length(pd, -1, 0, &repeat);
......@@ -400,7 +401,7 @@ aper_open_type_get_simple(const asn_codec_ctx_t *ctx,
const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
ssize_t chunk_bytes;
int repeat;
int repeat = 0;
uint8_t *buf = 0;
size_t bufLen = 0;
size_t bufSize = 0;
......@@ -410,9 +411,10 @@ aper_open_type_get_simple(const asn_codec_ctx_t *ctx,
ASN__STACK_OVERFLOW_CHECK(ctx);
ASN_DEBUG("Getting open type %s...", td->name);
//printf("test0515 Getting open type %s...\n", td->name);
printf("test0515 Getting open type %s...\n", td->name);
do {
printf("test1130 while repeat1(%d)\n", repeat);
chunk_bytes = aper_get_length(pd, -1, -1, &repeat);
if(chunk_bytes < 0) {
FREEMEM(buf);
......@@ -433,12 +435,13 @@ aper_open_type_get_simple(const asn_codec_ctx_t *ctx,
ASN__DECODE_STARVED;
}
bufLen += chunk_bytes;
printf("test1130 while repeat2(%d)\n", repeat);
} while(repeat);
ASN_DEBUG("Getting open type %s encoded in %ld bytes", td->name,
//ASN_DEBUG("Getting open type %s encoded in %ld bytes", td->name,
// (long)bufLen);
printf("test1130 Getting open type %s encoded in %ld bytes\n", td->name,
(long)bufLen);
//printf("test0515 Getting open type %s encoded in %ld bytes\n", td->name,
//(long)bufLen);
memset(&spd, 0, sizeof(spd));
spd.buffer = buf;
......
......@@ -65,7 +65,7 @@ void N1N2MessageCollectionDocumentApi::n1_n2_message_transfer_handler(const Pist
Logger::amf_server().debug("Request body, part 2: \n %s", parts[1].body.c_str());
bool is_ngap = false;
if (size > 2) {
if (size > 0) {
is_ngap = true;
Logger::amf_server().debug("Request body, part 3: \n %s", parts[2].body.c_str());
}
......
......@@ -62,7 +62,7 @@ void N1N2MessageCollectionDocumentApiImpl::n1_n2_message_transfer(const std::str
}
bstring n1sm;
msg_str_2_msg_hex(n1sm_str.substr(0, n1sm_str.length()), n1sm); //TODO: verify n1sm_length
msg_str_2_msg_hex(n1sm_str.substr(0, n1sm_str.length()-2), n1sm); //TODO: verify n1sm_length
bstring n2sm;
msg_str_2_msg_hex(n2sm_str, n2sm);
......
......@@ -719,7 +719,8 @@ void SmContextCreateData::toMultipart(std::shared_ptr<MultipartFormData> multipa
value += n1sm;
std::string ngsId = ", \"servingNfId\":\"servingNfId\"";
value += ngsId;
std::string sn = ", \"servingNetwork\":{\"mcc\":\"460\", \"mnc\":\"011\"}";
//std::string sn = ", \"servingNetwork\":{\"mcc\":\"460\", \"mnc\":\"011\"}";
std::string sn = ", \"servingNetwork\":{\"mcc\":\"110\", \"mnc\":\"011\"}";
value += sn;
std::string anType = ", \"anType\":\"3GPP_ACCESS\"";
value += anType;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment