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 */
......
This diff is collapsed.
......@@ -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