Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] NWI support #35

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion etc/spgw_c.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@
"association_heartbeat_period_ms" : 2000,
"feature_overload_control" : false,
"feature_load_control" : false,
"use_nwi" : @USE_NWI@,
"up_nodes_selection" : [
{ "mcc" : "@MCC@", "mnc" : "@MNC@", "tac" : @TAC@, "apn_ni" : "@DEFAULT_APN_NI_1@", "pdn_idx" : 0, "id" : "gw@[email protected]@[email protected]@MCC@.@REALM@" }
{ "mcc" : "@MCC@", "mnc" : "@MNC@", "tac" : @TAC@, "apn_ni" : "@DEFAULT_APN_NI_1@", "pdn_idx" : 0, "id" : "gw@[email protected]@[email protected]@MCC@.@REALM@", "nwi_list" : [{"access_nwi":"@ACCESS_NWI@", "core_nwi":"@CORE_NWI@"}]}
]
},
"pcef" : {
Expand Down
3 changes: 3 additions & 0 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -uo pipefail

CONFIG_DIR="/openair-spgwc/etc"
PUSH_PROTOCOL_OPTION=${PUSH_PROTOCOL_OPTION:-no}
USE_NWI=${USE_NWI:-false}
ACCESS_NWI=${ACCESS_NWI:-access.oai.org}
CORE_NWI=${CORE_NWI:-core.oai.org}
UE_MTU_IPV4=${UE_MTU_IPV4:-1464}


Expand Down
42 changes: 34 additions & 8 deletions src/oai_spgwc/pgw_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ bool pgw_config::ParseJson() {
"Error parsing json value: spgw_app/ue_mtu_ipv4");
return false;
}
spgw_app_.default_ue_mtu_ipv4 =
spgw_app_section["ue_mtu_ipv4"].GetUint();
spgw_app_.default_ue_mtu_ipv4 = spgw_app_section["ue_mtu_ipv4"].GetUint();
}
if (doc.HasMember("pdns")) {
const RAPIDJSON_NAMESPACE::Value& pdns_section = doc["pdns"];
Expand Down Expand Up @@ -646,6 +645,13 @@ bool pgw_config::ParseJson() {
cups_.feature_load_control =
cups_section["feature_load_control"].GetBool();
}
if (cups_section.HasMember("use_nwi")) {
if (!cups_section["use_nwi"].IsBool()) {
Logger::pgwc_app().error("Error parsing json value: cups/use_nwi");
return false;
}
cups_.use_nwi = cups_section["use_nwi"].GetBool();
}
if (cups_section.HasMember("up_nodes_selection")) {
const RAPIDJSON_NAMESPACE::Value& nodes_section =
cups_section["up_nodes_selection"];
Expand All @@ -654,6 +660,7 @@ bool pgw_config::ParseJson() {
"Error parsing json value: up_nodes_selection");
return false;
}
up_node_cfg_t up_node = {};
for (RAPIDJSON_NAMESPACE::SizeType i = 0; i < nodes_section.Size(); i++) {
if (nodes_section[i].HasMember("mcc")) {
if (!nodes_section[i]["mcc"].IsString()) {
Expand Down Expand Up @@ -688,6 +695,25 @@ bool pgw_config::ParseJson() {
"Error parsing json value: cup_nodes_selection/[id]");
return false;
}
if (cups_.use_nwi & nodes_section[i].HasMember("nwi_list")) {
const RAPIDJSON_NAMESPACE::Value& nwi_section =
nodes_section[i]["nwi_list"];
for (RAPIDJSON_NAMESPACE::SizeType i = 0; i < nwi_section.Size();
i++) {
if (nwi_section[i].HasMember("access_nwi")) {
if (nwi_section[i]["access_nwi"].IsString()) {
up_node.nwi.access_nwi =
nwi_section[i]["access_nwi"].GetString();
}
}
if (nwi_section[i].HasMember("core_nwi")) {
if (nwi_section[i]["core_nwi"].IsString()) {
up_node.nwi.core_nwi =
nwi_section[i]["core_nwi"].GetString();
}
}
}
}
/*unsigned char buf_in_addr[sizeof(struct in6_addr)];
std::string up_ip_addr = nodes_section[i]["id"].GetString();
memset(buf_in_addr, 0, sizeof(buf_in_addr));
Expand All @@ -703,12 +729,12 @@ bool pgw_config::ParseJson() {
i);
return false;
}*/
up_node_cfg_t up_node = {};
up_node.mcc = nodes_section[i]["mcc"].GetString();
up_node.mnc = nodes_section[i]["mnc"].GetString();
up_node.tac = nodes_section[i]["tac"].GetInt();
up_node.pdn_index = nodes_section[i]["pdn_idx"].GetUint();
up_node.id = nodes_section[i]["id"].GetString();
// up_node_cfg_t up_node = {};
up_node.mcc = nodes_section[i]["mcc"].GetString();
up_node.mnc = nodes_section[i]["mnc"].GetString();
up_node.tac = nodes_section[i]["tac"].GetInt();
up_node.pdn_index = nodes_section[i]["pdn_idx"].GetUint();
up_node.id = nodes_section[i]["id"].GetString();
up_node.tai.from_items(up_node.mcc, up_node.mnc, up_node.tac);
cups_.nodes.push_back(up_node);
}
Expand Down
11 changes: 11 additions & 0 deletions src/oai_spgwc/pgw_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,27 @@ typedef struct pgw_app_cfg_s {
PdnCfg& GetPdnCfg(const uint pdn_index) { return pdns.at(pdn_index); }
} pgw_app_cfg_t;

typedef struct up_node_nwi_s {
std::string access_nwi;
std::string core_nwi;
} up_node_nwi_t;

typedef struct up_node_cfg_s {
std::string mcc;
std::string mnc;
uint16_t tac;
tai_field_t tai;
up_node_nwi_t nwi;
uint pdn_index;
std::string id; // FQDN, IP address
std::string toString() const {
std::string str = {};
str.append(id).append(" <-> mcc:").append(mcc).append(" mnc:").append(mnc);
str.append(" tac:").append(std::to_string(tac));
str.append(" pdn_index:").append(std::to_string(pdn_index));
if (!nwi.access_nwi.empty())
str.append(" nwi_access: ").append(nwi.access_nwi);
if (!nwi.core_nwi.empty()) str.append(" nwi_core: ").append(nwi.core_nwi);
return str;
}

Expand All @@ -164,6 +173,7 @@ typedef struct cups_cfg_s {
std::vector<up_node_cfg_t> nodes;
bool feature_overload_control;
bool feature_load_control;
bool use_nwi;
} cups_cfg_t;

class pgw_config {
Expand Down Expand Up @@ -277,6 +287,7 @@ class pgw_config {
cups_.max_associations = 8;
cups_.feature_overload_control = false;
cups_.feature_load_control = false;
cups_.use_nwi = false;
};
static bool ParseJson();

Expand Down
44 changes: 42 additions & 2 deletions src/oai_spgwc/pgwc_procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ int session_establishment_procedure::run(
pfcp::INTERFACE_VALUE_CORE; // ACCESS is for downlink, CORE for uplink
forwarding_parameters.set(destination_interface);

if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance = pgw_cfg.cups_.nodes[0].nwi.core_nwi;
forwarding_parameters.set(network_instance);
}

create_far.set(far_id);
create_far.set(apply_action);
create_far.set(forwarding_parameters);
Expand Down Expand Up @@ -197,7 +203,14 @@ int session_establishment_procedure::run(
// pfcp::framed_routing_t framed_routing = {};
// pfcp::framed_ipv6_route_t framed_ipv6_route = {};
source_interface.interface_value = pfcp::INTERFACE_VALUE_ACCESS;
local_fteid.ch = 1;

if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance = pgw_cfg.cups_.nodes[0].nwi.access_nwi;
pdi.set(network_instance);
}

local_fteid.ch = 1;
// local_fteid.chid = 1;
xgpp_conv::paa_to_pfcp_ue_ip_address(
s5_triggered_pending->gtp_ies.paa.second, ue_ip_address);
Expand Down Expand Up @@ -440,6 +453,13 @@ int modify_bearer_procedure::run(
destination_interface.interface_value =
pfcp::INTERFACE_VALUE_ACCESS; // ACCESS is for downlink, CORE for
// uplink
if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance =
pgw_cfg.cups_.nodes[0].nwi.access_nwi;
forwarding_parameters.set(network_instance);
}

forwarding_parameters.set(destination_interface);
outer_header_creation.outer_header_creation_description =
OUTER_HEADER_CREATION_GTPU_UDP_IPV4;
Expand Down Expand Up @@ -488,6 +508,13 @@ int modify_bearer_procedure::run(
// pfcp::framed_ipv6_route_t framed_ipv6_route = {};
source_interface.interface_value = pfcp::INTERFACE_VALUE_CORE;

if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance =
pgw_cfg.cups_.nodes[0].nwi.core_nwi;
pdi.set(network_instance);
}

// local_fteid.from_core_fteid(peb.sgw_fteid_s5_s8_up);
if (ppc->ipv4) {
ue_ip_address.v4 = 1;
Expand Down Expand Up @@ -570,6 +597,13 @@ int modify_bearer_procedure::run(
destination_interface.interface_value =
pfcp::INTERFACE_VALUE_CORE; // ACCESS is for downlink, CORE for
// uplink
if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance =
pgw_cfg.cups_.nodes[0].nwi.core_nwi;
forwarding_parameters.set(network_instance);
}

forwarding_parameters.set(destination_interface);

create_far.set(far_id);
Expand Down Expand Up @@ -611,7 +645,13 @@ int modify_bearer_procedure::run(
// pfcp::framed_routing_t framed_routing = {};
// pfcp::framed_ipv6_route_t framed_ipv6_route = {};
source_interface.interface_value = pfcp::INTERFACE_VALUE_ACCESS;
local_fteid.ch = 1;
if (pgw_cfg.cups_.use_nwi) {
pfcp::network_instance_t network_instance;
network_instance.network_instance =
pgw_cfg.cups_.nodes[0].nwi.access_nwi;
pdi.set(network_instance);
}
local_fteid.ch = 1;
// local_fteid.chid = 1;
xgpp_conv::pdn_ip_to_pfcp_ue_ip_address(
ppc->pdn_type, ppc->ipv4_address, ppc->ipv6_address, ue_ip_address);
Expand Down