Commit 171a2629 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Code cleanup/fix issue for supporting IPv4 (f-Teid)

parent acd67431
......@@ -74,10 +74,12 @@ std::string smf_qos_flow::toString() const {
s.append("\tFQI:\t\t\t\t").append(std::to_string((uint8_t) qfi.qfi)).append(
"\n");
s.append("\tUL FTEID:\t\t").append(ul_fteid.toString()).append("\n");
s.append("\tDL FTEID:\t\t").append(dl_fteid.toString()).append("\n");
s.append("\tPDR ID UL:\t\t\t").append(std::to_string(pdr_id_ul.rule_id))
.append("\n");
s.append("\tPDR ID DL:\t\t\t").append(std::to_string(pdr_id_dl.rule_id))
.append("\n");
s.append("\tPrecedence:\t\t\t").append(std::to_string(precedence.precedence))
.append("\n");
if (far_id_ul.first) {
......@@ -335,6 +337,8 @@ void smf_pdu_session::release_qos_rule_id(const uint8_t &rule_id) {
//------------------------------------------------------------------------------
std::string smf_pdu_session::toString() const {
std::string s = { };
smf_qos_flow flow = { };
s.append("PDN CONNECTION:\n");
s.append("\tPDN type:\t\t\t").append(pdn_type.toString()).append("\n");
if (ipv4)
......@@ -343,9 +347,24 @@ std::string smf_pdu_session::toString() const {
if (ipv6)
s.append("\tPAA IPv6:\t\t\t").append(conv::toString(ipv6_address)).append(
"\n");
s.append("\tDefault QFI:\t\t\t").append(std::to_string(default_qfi.qfi))
.append("\n");
if (default_qfi.qfi) {
s.append("\tDefault QFI:\t\t\t").append(std::to_string(default_qfi.qfi))
.append("\n");
} else {
s.append("\tDefault QFI:\t\t\t").append("No QFI available").append("\n");
}
s.append("\tSEID:\t\t\t\t").append(std::to_string(seid)).append("\n");
if (default_qfi.qfi) {
s.append("Default ");
for (auto it : qos_flows) {
if (it.second.qfi == default_qfi.qfi) {
s.append(it.second.toString());
}
}
}
return s;
}
......@@ -437,17 +456,17 @@ void smf_pdu_session::update_qos_rule(const QOSRulesIE &qos_rule) {
qos_rules.insert(std::pair<uint8_t, QOSRulesIE>(rule_id, qos_rule));
//marked to be synchronised with UE
qos_rules_to_be_synchronised.push_back(rule_id);
Logger::smf_app().trace("smf_pdu_session::update_qos_rule(%d) success",
Logger::smf_app().trace("Update QoS rule (%d) success",
rule_id);
} else {
Logger::smf_app().error(
"smf_pdu_session::update_qos_rule(%d) failed, rule does not existed",
"Update QoS Rule (%d) failed, rule does not existed",
rule_id);
}
} else {
Logger::smf_app().error(
"smf_pdu_session::update_qos_rule(%d) failed, invalid Rule Id",
"Update QoS rule (%d) failed, invalid Rule Id",
rule_id);
}
}
......@@ -1354,13 +1373,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
return;
}
Logger::smf_app().debug(
"NAS header information, extended_protocol_discriminator %d, security_header_type:%d",
decoded_nas_msg.header.extended_protocol_discriminator,
decoded_nas_msg.header.security_header_type);
Logger::smf_app().debug("NAS header information, Message Type %d",
decoded_nas_msg.plain.sm.header.message_type);
uint8_t message_type = decoded_nas_msg.plain.sm.header.message_type;
switch (message_type) {
......@@ -1527,7 +1539,8 @@ void smf_context::handle_pdu_session_update_sm_context_request(
}
}
Logger::smf_app().debug("Add new QoS Flow with new QRI");
Logger::smf_app().debug("Add new QoS Flow with new QRI %d",
qos_rules_ie.qosruleidentifer);
//mark this rule to be synchronised with the UE
sp.get()->update_qos_rule(qos_rules_ie);
//Add new QoS flow
......@@ -1542,7 +1555,8 @@ void smf_context::handle_pdu_session_update_sm_context_request(
sm_context_resp_pending->res.add_qos_flow_context_updated(qcu);
} else { //update existing QRI
Logger::smf_app().debug("Update existing QRI");
Logger::smf_app().debug("Update existing QRI %d",
qos_rules_ie.qosruleidentifer);
qfi.qfi = qos_rules_ie.qosflowidentifer;
if (sp.get()->get_qos_flow(qfi, qos_flow)) {
sp.get()->update_qos_rule(qos_rules_ie);
......@@ -1893,7 +1907,7 @@ void smf_context::handle_pdu_session_update_sm_context_request(
}
//store AN Tunnel Info + list of accepted QFIs
fteid_t dl_teid;
fteid_t dl_teid = { };
memcpy(
&dl_teid.teid_gre_key,
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
......@@ -1904,13 +1918,17 @@ void smf_context::handle_pdu_session_update_sm_context_request(
decoded_msg->dLQosFlowPerTNLInformation.uPTransportLayerInformation
.choice.gTPTunnel->transportLayerAddress.buf,
4);
Logger::smf_app().debug("DL GTP_F-TEID (AN F-TEID) " "0x%" PRIx32 " ",
htonl(dl_teid.teid_gre_key));
Logger::smf_app().debug("uPTransportLayerInformation (AN IP Addr) %s",
conv::toString(dl_teid.ipv4_address).c_str());
dl_teid.teid_gre_key = ntohl(dl_teid.teid_gre_key);
dl_teid.interface_type = S1_U_ENODEB_GTP_U;
dl_teid.v4 = 1; //Only V4 for now
smreq->req.set_dl_fteid(dl_teid);
Logger::smf_app().debug("DL GTP F-TEID (AN F-TEID) " "0x%" PRIx32 " ",
dl_teid.teid_gre_key);
Logger::smf_app().debug("uPTransportLayerInformation (AN IP Addr) %s",
conv::toString(dl_teid.ipv4_address).c_str());
for (int i = 0;
i
< decoded_msg->dLQosFlowPerTNLInformation.associatedQosFlowList
......@@ -1932,7 +1950,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//PDU Session Modification procedure (UE-initiated, Section 4.3.3.2@3GPP TS 23.502 or SMF-Requested)(Step 2)
case n2_sm_info_type_e::PDU_RES_MOD_RSP: {
Logger::smf_app().info("PDU_RES_MOD_RSP");
Logger::smf_app().info(
"PDU Session Modification Procedure, processing N2 SM Information");
......@@ -1971,12 +1988,11 @@ void smf_context::handle_pdu_session_update_sm_context_request(
decoded_msg->dL_NGU_UP_TNLInformation->choice.gTPTunnel
->transportLayerAddress.buf,
4);
smreq->req.set_dl_fteid(dl_teid);
Logger::smf_app().debug("gTP_TEID " "0x%" PRIx32 " ",
htonl(dl_teid.teid_gre_key));
Logger::smf_app().debug("uPTransportLayerInformation IP Addr %s",
conv::toString(dl_teid.ipv4_address).c_str());
dl_teid.teid_gre_key = ntohl(dl_teid.teid_gre_key);
dl_teid.interface_type = S1_U_ENODEB_GTP_U;
dl_teid.v4 = 1; //Only v4 for now
smreq->req.set_dl_fteid(dl_teid);
//list of Qos Flows which have been successfully setup or modified
if (decoded_msg->qosFlowAddOrModifyResponseList) {
......@@ -2006,7 +2022,6 @@ void smf_context::handle_pdu_session_update_sm_context_request(
//PDU Session Release procedure (UE-initiated, Section 4.3.4.2@3GPP TS 23.502 or SMF-Requested)(Step 2)
case n2_sm_info_type_e::PDU_RES_REL_RSP: {
Logger::smf_app().info("PDU_RES_REL_RSP");
Logger::smf_app().info(
"PDU Session Release (UE-initiated), processing N2 SM Information");
......
......@@ -415,8 +415,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//1- PDU Session Update SM Context Response (PDU Session Modification UE-Initiated procedure - step 1)
//2- N1N2MessageTransfer Request (PDU Session Modification SMF-Requested, step 1 (from SMF to AMF)) ​
Logger::smf_app().debug(
"[Create N1 SM Message] PDU Session Modification Command");
Logger::smf_app().debug("PDU Session Modification Command");
//case 1 (case2: need to be verified?)
pdu_session_update_sm_context_response &sm_context_res =
static_cast<pdu_session_update_sm_context_response&>(msg);
......@@ -542,8 +541,7 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//1 - PDU Session Update SM Context Response (PDU Session Release UE-Initiated, step 1)
//2 - N1N2MessageTransfer Request (PDU Session Release SMF-Requested, step 1)
Logger::smf_app().debug(
"[Create N1 SM Message] PDU Session Release Command");
Logger::smf_app().debug("PDU Session Release Command");
//case 1 (case2: need to be verified?)
pdu_session_update_sm_context_response &sm_context_res =
static_cast<pdu_session_update_sm_context_response&>(msg);
......@@ -567,9 +565,8 @@ void smf_n1_n2::create_n1_sm_container(pdu_session_msg &msg,
//_5GSMCongestionReattemptIndicator
// ExtendedProtocolConfigurationOptions
Logger::smf_app().debug("SM MSG, 5GSM Cause: 0x%x, %d",
sm_msg->pdu_session_release_command._5gsmcause,
static_cast<uint8_t>(sm_cause));
Logger::smf_app().debug("SM message, 5GSM Cause: 0x%x",
sm_msg->pdu_session_release_command._5gsmcause);
//Encode NAS message
bytes = nas_message_encode(data, &nas_msg,
......@@ -750,6 +747,13 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
pduSessionAggregateMaximumBitRate);
//UPTransportLayerInformation
fteid_t ul_fteid = { };
ul_fteid.interface_type = qos_flow.ul_fteid.interface_type;
ul_fteid.v4 = qos_flow.ul_fteid.v4;
ul_fteid.teid_gre_key = htonl(qos_flow.ul_fteid.teid_gre_key);
ul_fteid.ipv4_address = qos_flow.ul_fteid.ipv4_address;
Ngap_PDUSessionResourceSetupRequestTransferIEs_t *upTransportLayerInformation =
nullptr;
upTransportLayerInformation =
......@@ -774,7 +778,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
upTransportLayerInformation->value.choice.UPTransportLayerInformation
.choice.gTPTunnel->transportLayerAddress.buf,
&qos_flow.ul_fteid.ipv4_address, 4);
&ul_fteid.ipv4_address, 4);
upTransportLayerInformation->value.choice.UPTransportLayerInformation
.choice.gTPTunnel->transportLayerAddress.bits_unused = 0;
......@@ -786,7 +790,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
upTransportLayerInformation->value.choice.UPTransportLayerInformation
.choice.gTPTunnel->gTP_TEID.buf,
&qos_flow.ul_fteid.teid_gre_key, sizeof(struct in_addr));
&ul_fteid.teid_gre_key, sizeof(struct in_addr));
ASN_SEQUENCE_ADD(&ngap_IEs->protocolIEs.list,
upTransportLayerInformation);
......@@ -925,7 +929,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//2 - N1N2MessageTransfer Request (PDU Session Modification procedure, SMF-requested, step 1)
Logger::smf_app().debug(
"[Create N2 SM Information] NGAP PDU Session Resource Modify Request Transfer");
"NGAP PDU Session Resource Modify Request Transfer");
pdu_session_update_sm_context_response &sm_context_res =
static_cast<pdu_session_update_sm_context_response&>(msg);
......@@ -935,16 +939,17 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
sm_context_res.get_all_qos_flow_context_updateds(qos_flows);
for (std::map<uint8_t, qos_flow_context_updated>::iterator it = qos_flows
.begin(); it != qos_flows.end(); ++it)
Logger::smf_app().debug("qos_flow_context_updated qfi %d", it->first);
Logger::smf_app().debug("QoS flow context to be updated with QFI %d",
it->first);
//TODO: support only 1 qos flow
qos_flow_context_updated qos_flow = qos_flows.begin()->second;
Logger::smf_app().debug(
"QoS Flow, UL gTP_TEID " "0x%" PRIx32 ", UL IP Address %s ",
"QoS Flow, UL F-TEID ID " "0x%" PRIx32 ", IP Address %s ",
qos_flow.ul_fteid.teid_gre_key,
conv::toString(qos_flow.ul_fteid.ipv4_address).c_str());
Logger::smf_app().debug(
"QoS Flow, DL gTP_TEID " "0x%" PRIx32 ", DL IP Address %s",
"QoS Flow, DL F-TEID ID" "0x%" PRIx32 ", IP Address %s",
qos_flow.dl_fteid.teid_gre_key,
conv::toString(qos_flow.dl_fteid.ipv4_address).c_str());
......@@ -994,6 +999,18 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
//Ngap_UL_NGU_UP_TNLModifyList_t (included if the PDU Session modification was requested by the UE for a
//PDU Session that has no established User Plane resources)
fteid_t ul_fteid = { };
ul_fteid.interface_type = qos_flow.ul_fteid.interface_type;
ul_fteid.v4 = qos_flow.ul_fteid.v4;
ul_fteid.teid_gre_key = htonl(qos_flow.ul_fteid.teid_gre_key);
ul_fteid.ipv4_address = qos_flow.ul_fteid.ipv4_address;
fteid_t dl_fteid = { };
dl_fteid.interface_type = qos_flow.dl_fteid.interface_type;
dl_fteid.v4 = qos_flow.dl_fteid.v4;
dl_fteid.teid_gre_key = htonl(qos_flow.dl_fteid.teid_gre_key);
dl_fteid.ipv4_address = qos_flow.dl_fteid.ipv4_address;
Ngap_PDUSessionResourceModifyRequestTransferIEs_t *ul_NGU_UP_TNLModifyList =
nullptr;
ul_NGU_UP_TNLModifyList =
......@@ -1016,7 +1033,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
ngap_UL_NGU_UP_TNLModifyItem->uL_NGU_UP_TNLInformation.choice
.gTPTunnel->transportLayerAddress.buf,
&qos_flow.ul_fteid.ipv4_address, 4);
&ul_fteid.ipv4_address, 4);
ngap_UL_NGU_UP_TNLModifyItem->uL_NGU_UP_TNLInformation.choice.gTPTunnel
->transportLayerAddress.size = 4;
ngap_UL_NGU_UP_TNLModifyItem->uL_NGU_UP_TNLInformation.choice.gTPTunnel
......@@ -1030,7 +1047,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
ngap_UL_NGU_UP_TNLModifyItem->uL_NGU_UP_TNLInformation.choice
.gTPTunnel->gTP_TEID.buf,
&qos_flow.ul_fteid.teid_gre_key, sizeof(struct in_addr));
&ul_fteid.teid_gre_key, sizeof(struct in_addr));
ngap_UL_NGU_UP_TNLModifyItem->dL_NGU_UP_TNLInformation.present =
Ngap_UPTransportLayerInformation_PR_gTPTunnel;
......@@ -1041,7 +1058,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
ngap_UL_NGU_UP_TNLModifyItem->dL_NGU_UP_TNLInformation.choice
.gTPTunnel->transportLayerAddress.buf,
&qos_flow.dl_fteid.ipv4_address, 4);
&dl_fteid.ipv4_address, 4);
ngap_UL_NGU_UP_TNLModifyItem->dL_NGU_UP_TNLInformation.choice.gTPTunnel
->transportLayerAddress.size = 4;
ngap_UL_NGU_UP_TNLModifyItem->dL_NGU_UP_TNLInformation.choice.gTPTunnel
......@@ -1055,7 +1072,7 @@ void smf_n1_n2::create_n2_sm_information(pdu_session_msg &msg,
memcpy(
ngap_UL_NGU_UP_TNLModifyItem->dL_NGU_UP_TNLInformation.choice
.gTPTunnel->gTP_TEID.buf,
&qos_flow.dl_fteid.teid_gre_key, 4);
&dl_fteid.teid_gre_key, 4);
ASN_SEQUENCE_ADD(
&ul_NGU_UP_TNLModifyList->value.choice.UL_NGU_UP_TNLModifyList.list,
ngap_UL_NGU_UP_TNLModifyItem);
......
......@@ -669,6 +669,7 @@ int session_update_sm_context_procedure::run(
send_n4 = true;
flow.far_id_dl.first = true;
flow.dl_fteid = dl_fteid;
} else {
Logger::smf_app().debug("Create FAR DL");
......@@ -713,6 +714,7 @@ int session_update_sm_context_procedure::run(
flow.far_id_dl.first = true;
flow.far_id_dl.second.far_id = far_id.far_id;
flow.dl_fteid = dl_fteid;
Logger::smf_app().debug("FAR DL ID " "0x%" PRIx32 " ", far_id.far_id);
}
......@@ -777,7 +779,7 @@ int session_update_sm_context_procedure::run(
pdr_id.rule_id);
} else {
Logger::smf_app().debug(
"Update FAR, PDR DL Rule Id " "0x%" PRIx16 ", 0x%" PRIx32 " ",
"Update FAR, PDR DL Rule Id " "0x%" PRIx16 ", FAR ID 0x%" PRIx32 " ",
flow.pdr_id_dl.rule_id, flow.far_id_dl.second.far_id);
/*
// Update FAR
......@@ -831,7 +833,9 @@ int session_update_sm_context_procedure::run(
}
// after a release flows
if (not flow.ul_fteid.is_zero()) {
}
if (not flow.dl_fteid.is_zero()) {
}
// may be modified
smf_qos_flow flow2 = flow;
......@@ -1033,6 +1037,9 @@ void session_update_sm_context_procedure::handle_itti_msg(
::fteid_t dl_fteid = { };
n11_trigger->req.get_dl_fteid(dl_fteid);
Logger::smf_app().debug("AN F-TEID ID" "0x%" PRIx32 ", IP Addr %s",
dl_fteid.teid_gre_key, conv::toString(dl_fteid.ipv4_address).c_str());
std::map<uint8_t, qos_flow_context_updated> qos_flow_context_to_be_updateds =
{ };
n11_triggered_pending->res.get_all_qos_flow_context_updateds(
......
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