Commit 27b6e5bf authored by yangjian's avatar yangjian

fix sctp-server: increase receive bytes, encode size bits -> bytes

parent f13af891
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "amf_n1.hpp" #include "amf_n1.hpp"
#include <sstream>
#include "AuthenticationFailure.hpp" #include "AuthenticationFailure.hpp"
#include "AuthenticationRequest.hpp" #include "AuthenticationRequest.hpp"
#include "AuthenticationResponse.hpp" #include "AuthenticationResponse.hpp"
...@@ -567,6 +569,40 @@ void amf_n1::identity_response_handle(uint32_t ran_ue_ngap_id, ...@@ -567,6 +569,40 @@ void amf_n1::identity_response_handle(uint32_t ran_ue_ngap_id,
if (nc.get()->to_be_register_by_new_suci) { if (nc.get()->to_be_register_by_new_suci) {
run_registration_procedure(nc); run_registration_procedure(nc);
} }
if (!nc.get()->is_stacs_available) {
string ue_context_key = "app_ue_ranid_" + to_string(ran_ue_ngap_id) +
":amfid_" + to_string(amf_ue_ngap_id);
std::shared_ptr<ue_context> uc;
// uc = amf_app_inst->amf_ue_id_2_ue_context(amf_ue_ngap_id);
Logger::amf_n1().info(
"Try to find ue_context in amf_app using ran_amf_id (%s)",
ue_context_key.c_str());
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
ue_info_t ueItem;
ueItem.connStatus = "5GMM-CONNECTED"; //"CM-CONNECTED";
ueItem.registerStatus =
"5GMM-REG-INITIATED"; // 5GMM-COMMON-PROCEDURE-INITIATED
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
ueItem.mcc = uc.get()->cgi.mcc;
ueItem.mnc = uc.get()->cgi.mnc;
ueItem.cellId = uc.get()->cgi.nrCellID;
std::shared_ptr<ue_ngap_context> unc;
unc = amf_n2_inst->ran_ue_id_2_ue_ngap_context(ran_ue_ngap_id);
if (unc.get() == nullptr) {
Logger::amf_n2().error(
"Illegal UE with ran_ue_ngap_id (0x%x)",ran_ue_ngap_id);
return;
}
ueItem.gnb_assoc_id = unc.get()->gnb_assoc_id;
stacs.update_ue_info(ueItem);
set_5gmm_state(nc, _5GMM_COMMON_PROCEDURE_INITIATED);
nc.get()->is_stacs_available = true;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -828,7 +864,8 @@ void amf_n1::registration_request_handle(bool isNasSig, ...@@ -828,7 +864,8 @@ void amf_n1::registration_request_handle(bool isNasSig,
} }
if(add_new_ue) if(add_new_ue)
stacs.ues.push_back(ueItem); stacs.ues.push_back(ueItem);
*/} */
}
// nc.get()->imsi = //need interface to transfer SUCI_imsi_t to string // nc.get()->imsi = //need interface to transfer SUCI_imsi_t to string
} }
} break; } break;
...@@ -1213,7 +1250,7 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context> &nc) { ...@@ -1213,7 +1250,7 @@ bool amf_n1::auth_vectors_generator(std::shared_ptr<nas_context> &nc) {
return true; return true;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define CURL_TIMEOUT_MS 300L #define CURL_TIMEOUT_MS 1000L
std::size_t callback_ausf(const char *in, std::size_t size, std::size_t num, std::size_t callback_ausf(const char *in, std::size_t size, std::size_t num,
std::string *out) { std::string *out) {
...@@ -2141,8 +2178,27 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, ...@@ -2141,8 +2178,27 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
std::vector<struct SNSSAI_s> nssai = {}; std::vector<struct SNSSAI_s> nssai = {};
SNSSAI_t snssai = {}; SNSSAI_t snssai = {};
snssai.sst = 1; uint32_t sst = 1;
snssai.sd = -1; int32_t sd = -1;
std::istringstream sst_istr(amf_cfg.plmn_list[0].slice_list[0].sST);
sst_istr >> sst;
Logger::amf_n1().debug("**************************** amf_cfg.plmn_list[0].slice_list[0].sST = %s",amf_cfg.plmn_list[0].slice_list[0].sST.c_str());
Logger::amf_n1().debug("**************************** sst value = %d",sst);
std::istringstream sd_istr(amf_cfg.plmn_list[0].slice_list[0].sD);
sd_istr >> sd;
Logger::amf_n1().debug("**************************** amf_cfg.plmn_list[0].slice_list[0].sD = %s",amf_cfg.plmn_list[0].slice_list[0].sD.c_str());
Logger::amf_n1().debug("**************************** sd value = %d",sd);
if(sst == 0)
sst = 1;
if(sd == 0)
sd = -1;
snssai.sst = sst;
snssai.sd = sd;
snssai.mHplmnSst = -1; snssai.mHplmnSst = -1;
snssai.mHplmnSd = -1; snssai.mHplmnSd = -1;
nssai.push_back(snssai); nssai.push_back(snssai);
...@@ -2154,7 +2210,9 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, ...@@ -2154,7 +2210,9 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str()); Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str());
// TODO: remove hardcoded values // TODO: remove hardcoded values
regAccept->set_5GS_Network_Feature_Support(0x01, 0x00); // regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
char *pathvar = NULL; char *pathvar = NULL;
pathvar = getenv("AMF_T3512_MIN"); pathvar = getenv("AMF_T3512_MIN");
uint8_t t3512_Value = 0x1e; uint8_t t3512_Value = 0x1e;
...@@ -2170,7 +2228,8 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, ...@@ -2170,7 +2228,8 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id,
{ {
Logger::amf_n1().warn("Please set environment variable \"AMF_T3512_MIN\""); Logger::amf_n1().warn("Please set environment variable \"AMF_T3512_MIN\"");
} }
regAccept->setT3512_Value(0x5, t3512_Value); // regAccept->setT3512_Value(0x5, t3512_Value);
regAccept->setT3512_Value(0x2, 0);
uint8_t buffer[BUFFER_SIZE_1024] = {0}; uint8_t buffer[BUFFER_SIZE_1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, BUFFER_SIZE_1024); int encoded_size = regAccept->encode2buffer(buffer, BUFFER_SIZE_1024);
print_buffer("amf_n1", "Registration-Accept message buffer", buffer, print_buffer("amf_n1", "Registration-Accept message buffer", buffer,
...@@ -2830,7 +2889,8 @@ void amf_n1::run_mobility_registration_update_procedure( ...@@ -2830,7 +2889,8 @@ void amf_n1::run_mobility_registration_update_procedure(
regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc, regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc,
amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID, amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID,
amf_cfg.guami.AmfPointer, 0x264a34c0); amf_cfg.guami.AmfPointer, 0x264a34c0);
regAccept->setT3512_Value(0x5, 0x1e); // regAccept->setT3512_Value(0x5, 0x1e);
regAccept->setT3512_Value(0x2, 0);
std::vector<p_tai_t> tai_list; std::vector<p_tai_t> tai_list;
p_tai_t item0; p_tai_t item0;
...@@ -2845,8 +2905,22 @@ void amf_n1::run_mobility_registration_update_procedure( ...@@ -2845,8 +2905,22 @@ void amf_n1::run_mobility_registration_update_procedure(
std::vector<struct SNSSAI_s> nssai; std::vector<struct SNSSAI_s> nssai;
SNSSAI_t snssai; SNSSAI_t snssai;
snssai.sst = 0; uint32_t sst = 1;
snssai.sd = -1; int32_t sd = -1;
std::istringstream sst_istr(amf_cfg.plmn_list[0].slice_list[0].sST);
sst_istr >> sst;
std::istringstream sd_istr(amf_cfg.plmn_list[0].slice_list[0].sD);
sd_istr >> sd;
if(sst == 0)
sst = 1;
if(sd == 0)
sd = -1;
snssai.sst = sst;
snssai.sd = sd;
snssai.mHplmnSst = -1; snssai.mHplmnSst = -1;
snssai.mHplmnSd = -1; snssai.mHplmnSd = -1;
nssai.push_back(snssai); nssai.push_back(snssai);
...@@ -2859,6 +2933,8 @@ void amf_n1::run_mobility_registration_update_procedure( ...@@ -2859,6 +2933,8 @@ void amf_n1::run_mobility_registration_update_procedure(
Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str()); Logger::amf_n1().debug("Allocated GUTI %s", guti.c_str());
regAccept->set_5GS_Network_Feature_Support(0x00, 0x00); regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
// regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
uint8_t buffer[1024] = {0}; uint8_t buffer[1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, 1024); int encoded_size = regAccept->encode2buffer(buffer, 1024);
print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer, print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer,
...@@ -2921,7 +2997,8 @@ void amf_n1::run_periodic_registration_update_procedure( ...@@ -2921,7 +2997,8 @@ void amf_n1::run_periodic_registration_update_procedure(
regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc, regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc,
amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID, amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID,
amf_cfg.guami.AmfPointer, 0x264a34c0); amf_cfg.guami.AmfPointer, 0x264a34c0);
regAccept->setT3512_Value(0x5, 0x1e); // regAccept->setT3512_Value(0x5, 0x1e);
regAccept->setT3512_Value(0x2, 0);
std::vector<p_tai_t> tai_list; std::vector<p_tai_t> tai_list;
p_tai_t item0; p_tai_t item0;
...@@ -2952,7 +3029,8 @@ void amf_n1::run_periodic_registration_update_procedure( ...@@ -2952,7 +3029,8 @@ void amf_n1::run_periodic_registration_update_procedure(
// serApt->setPDU_session_status(0x2000); // serApt->setPDU_session_status(0x2000);
} }
regAccept->set_5GS_Network_Feature_Support(0x01, 0x00); regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
// regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
uint8_t buffer[1024] = {0}; uint8_t buffer[1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, 1024); int encoded_size = regAccept->encode2buffer(buffer, 1024);
print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer, print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer,
...@@ -3008,7 +3086,8 @@ void amf_n1::run_periodic_registration_update_procedure( ...@@ -3008,7 +3086,8 @@ void amf_n1::run_periodic_registration_update_procedure(
regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc, regAccept->set5G_GUTI(amf_cfg.guami.mcc, amf_cfg.guami.mnc,
amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID, amf_cfg.guami.regionID, amf_cfg.guami.AmfSetID,
amf_cfg.guami.AmfPointer, 0x264a34c0); amf_cfg.guami.AmfPointer, 0x264a34c0);
regAccept->setT3512_Value(0x5, 0x1e); // regAccept->setT3512_Value(0x5, 0x1e);
regAccept->setT3512_Value(0x2, 0);
std::vector<p_tai_t> tai_list; std::vector<p_tai_t> tai_list;
p_tai_t item0; p_tai_t item0;
...@@ -3042,7 +3121,8 @@ void amf_n1::run_periodic_registration_update_procedure( ...@@ -3042,7 +3121,8 @@ void amf_n1::run_periodic_registration_update_procedure(
} }
delete regReq; delete regReq;
regAccept->set_5GS_Network_Feature_Support(0x01, 0x00); regAccept->set_5GS_Network_Feature_Support(0x00, 0x00);
// regAccept->set_5GS_Network_Feature_Support(0x01, 0x00);
uint8_t buffer[1024] = {0}; uint8_t buffer[1024] = {0};
int encoded_size = regAccept->encode2buffer(buffer, 1024); int encoded_size = regAccept->encode2buffer(buffer, 1024);
print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer, print_buffer("amf_n1", "Registration-Accept Message Buffer", buffer,
......
...@@ -653,13 +653,14 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -653,13 +653,14 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
msg->setGuami(guami); msg->setGuami(guami);
std::vector<S_Nssai> list; std::vector<S_Nssai> list;
S_Nssai item; S_Nssai item;
item.sst = "01"; // item.sst = "01";
item.sd = "None"; // item.sd = "None";
item.sst = amf_cfg.plmn_list[0].slice_list[0].sST;
item.sd = amf_cfg.plmn_list[0].slice_list[0].sD;
list.push_back(item); list.push_back(item);
msg->setAllowedNssai(list); msg->setAllowedNssai(list);
msg->setUESecurityCapability( // msg->setUESecurityCapability(0xe000, 0xe000, 0xe000,0xe000); // TODO: remove hardcoded value
0xe000, 0xe000, 0xe000, msg->setUESecurityCapability(0xe000, 0xe000, 0x0000,0x0000);
0xe000); // TODO: remove hardcoded value
msg->setSecurityKey((uint8_t*) bdata(itti_msg.kgnb)); msg->setSecurityKey((uint8_t*) bdata(itti_msg.kgnb));
msg->setNasPdu((uint8_t*) bdata(itti_msg.nas), blength(itti_msg.nas)); msg->setNasPdu((uint8_t*) bdata(itti_msg.nas), blength(itti_msg.nas));
...@@ -684,8 +685,10 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) { ...@@ -684,8 +685,10 @@ void amf_n2::handle_itti_message(itti_initial_context_setup_request& itti_msg) {
std::vector<PDUSessionResourceSetupRequestItem_t> list; std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item; PDUSessionResourceSetupRequestItem_t item;
item.pduSessionId = itti_msg.pdu_session_id; item.pduSessionId = itti_msg.pdu_session_id;
item.s_nssai.sst = "01"; // item.s_nssai.sst = "01";
item.s_nssai.sd = "None"; // item.s_nssai.sd = "None";
item.s_nssai.sst = amf_cfg.plmn_list[0].slice_list[0].sST;
item.s_nssai.sd = amf_cfg.plmn_list[0].slice_list[0].sD;
item.pduSessionNAS_PDU = NULL; item.pduSessionNAS_PDU = NULL;
if (itti_msg.isn2sm_avaliable) { if (itti_msg.isn2sm_avaliable) {
//bstring n2sm = itti_msg.n2sm; //bstring n2sm = itti_msg.n2sm;
...@@ -745,8 +748,10 @@ void amf_n2::handle_itti_message( ...@@ -745,8 +748,10 @@ void amf_n2::handle_itti_message(
nas_pdu[blength(itti_msg.nas)] = '\0'; nas_pdu[blength(itti_msg.nas)] = '\0';
item.pduSessionNAS_PDU = nas_pdu; item.pduSessionNAS_PDU = nas_pdu;
item.sizeofpduSessionNAS_PDU = blength(itti_msg.nas); item.sizeofpduSessionNAS_PDU = blength(itti_msg.nas);
item.s_nssai.sst = "01"; // TODO: get from N1N2msgTranferMsg // item.s_nssai.sst = "01"; // TODO: get from N1N2msgTranferMsg
item.s_nssai.sd = "none"; // TODO: get from N1N2msgTranferMsg // item.s_nssai.sd = "none"; // TODO: get from N1N2msgTranferMsg
item.s_nssai.sst = amf_cfg.plmn_list[0].slice_list[0].sST; // TODO: get from N1N2msgTranferMsg
item.s_nssai.sd = amf_cfg.plmn_list[0].slice_list[0].sD; // TODO: get from N1N2msgTranferMsg
// Get NSSAI from PDU Session Context // Get NSSAI from PDU Session Context
std::shared_ptr<nas_context> nc; std::shared_ptr<nas_context> nc;
...@@ -1075,8 +1080,10 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1075,8 +1080,10 @@ void amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
std::vector<PDUSessionResourceSetupRequestItem_t> list; std::vector<PDUSessionResourceSetupRequestItem_t> list;
PDUSessionResourceSetupRequestItem_t item; PDUSessionResourceSetupRequestItem_t item;
item.pduSessionId = psc.get()->pdu_session_id; item.pduSessionId = psc.get()->pdu_session_id;
item.s_nssai.sst = "01"; // item.s_nssai.sst = "01";
item.s_nssai.sd = ""; // item.s_nssai.sd = "";
item.s_nssai.sst = amf_cfg.plmn_list[0].slice_list[0].sST;
item.s_nssai.sd = amf_cfg.plmn_list[0].slice_list[0].sD;
item.pduSessionNAS_PDU = NULL; item.pduSessionNAS_PDU = NULL;
bstring n2sm = psc.get()->n2sm; bstring n2sm = psc.get()->n2sm;
if (blength(psc.get()->n2sm) != 0) { if (blength(psc.get()->n2sm) != 0) {
......
...@@ -113,6 +113,10 @@ int UENetworkCapability::decodefrombuffer( ...@@ -113,6 +113,10 @@ int UENetworkCapability::decodefrombuffer(
decoded_size++; decoded_size++;
_5g_EIASel = *(buf + decoded_size); _5g_EIASel = *(buf + decoded_size);
decoded_size++; decoded_size++;
if(length > (decoded_size - 2))
decoded_size = length + 2;
Logger::nas_mm().debug( Logger::nas_mm().debug(
"decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel); "decoded UENetworkCapability EA(0x%d),IA(0x%d)", _5g_EEASel, _5g_EIASel);
Logger::nas_mm().debug("decoded UENetworkCapability len(%d)", decoded_size); Logger::nas_mm().debug("decoded UENetworkCapability len(%d)", decoded_size);
......
...@@ -165,7 +165,13 @@ asn_enc_rval_t aper_encode_to_buffer( ...@@ -165,7 +165,13 @@ asn_enc_rval_t aper_encode_to_buffer(
if (td) ASN_DEBUG("Encoding \"%s\" using ALIGNED PER", td->name); if (td) ASN_DEBUG("Encoding \"%s\" using ALIGNED PER", td->name);
return aper_encode(td, constraints, sptr, encode_to_buffer_cb, &key); asn_enc_rval_t er;
er = aper_encode(td, constraints, sptr, encode_to_buffer_cb, &key);
if(er.encoded > 0)
er.encoded = (er.encoded+7) >> 3;
return er;
} }
ssize_t aper_encode_to_new_buffer( ssize_t aper_encode_to_new_buffer(
......
...@@ -39,7 +39,7 @@ extern "C" { ...@@ -39,7 +39,7 @@ extern "C" {
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#define SCTP_RECV_BUFFER_SIZE 2048 #define SCTP_RECV_BUFFER_SIZE 4096
#define SCTP_RC_ERROR -1 #define SCTP_RC_ERROR -1
#define SCTP_RC_NORMAL_READ 0 #define SCTP_RC_NORMAL_READ 0
#define SCTP_RC_DISCONNECT 1 #define SCTP_RC_DISCONNECT 1
......
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