Commit 72bc9621 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Code cleanup

parent f44b0569
...@@ -65,7 +65,7 @@ SMF = ...@@ -65,7 +65,7 @@ SMF =
DEFAULT_DNS_SEC_IPV6_ADDRESS = "2001:4860:4860::8844"; # YOUR DNS CONFIG HERE DEFAULT_DNS_SEC_IPV6_ADDRESS = "2001:4860:4860::8844"; # YOUR DNS CONFIG HERE
#Default P-CSCF server #Default P-CSCF server
DEFAULT_CSCF_IPV4_ADDRESS = "172.21.16.113"; DEFAULT_CSCF_IPV4_ADDRESS = "172.21.16.113"; #TODO: remove hardcoded value
DEFAULT_CSCF_IPV6_ADDRESS = "fe80::7915:f408:1787:db8b"; DEFAULT_CSCF_IPV6_ADDRESS = "fe80::7915:f408:1787:db8b";
#Default UE MTU #Default UE MTU
......
...@@ -193,10 +193,22 @@ class smf_app { ...@@ -193,10 +193,22 @@ class smf_app {
protocol_configuration_options_t& pco_resp, protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id); const pco_protocol_or_container_id_t* const poc_id);
/*
* process_pco_p_cscf_request
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_p_cscf_request( int process_pco_p_cscf_request(
protocol_configuration_options_t& pco_resp, protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id); const pco_protocol_or_container_id_t* const poc_id);
/*
* process_pco_p_cscf_v6_request
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_p_cscf_v6_request( int process_pco_p_cscf_v6_request(
protocol_configuration_options_t& pco_resp, protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id); const pco_protocol_or_container_id_t* const poc_id);
......
...@@ -436,16 +436,13 @@ int smf_config::load(const string& config_file) { ...@@ -436,16 +436,13 @@ int smf_config::load(const string& config_file) {
util::trim(astring).c_str(), default_dnsv4, util::trim(astring).c_str(), default_dnsv4,
"BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !"); "BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !");
smf_cfg.lookupValue( smf_cfg.lookupValue(
SMF_CONFIG_STRING_DEFAULT_DNS_SEC_IPV4_ADDRESS, astring); SMF_CONFIG_STRING_DEFAULT_DNS_SEC_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), default_dns_secv4, util::trim(astring).c_str(), default_dns_secv4,
"BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !"); "BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !");
// Default CSCF
smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_CSCF_IPV4_ADDRESS, astring); smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_CSCF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR( IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), default_cscfv4, util::trim(astring).c_str(), default_cscfv4,
...@@ -465,8 +462,6 @@ int smf_config::load(const string& config_file) { ...@@ -465,8 +462,6 @@ int smf_config::load(const string& config_file) {
astring.c_str()); astring.c_str());
} }
smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_DNS_IPV6_ADDRESS, astring); smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_DNS_IPV6_ADDRESS, astring);
if (inet_pton(AF_INET6, util::trim(astring).c_str(), buf_in6_addr) == 1) { if (inet_pton(AF_INET6, util::trim(astring).c_str(), buf_in6_addr) == 1) {
memcpy(&default_dnsv6, buf_in6_addr, sizeof(struct in6_addr)); memcpy(&default_dnsv6, buf_in6_addr, sizeof(struct in6_addr));
...@@ -901,17 +896,6 @@ void smf_config::display() { ...@@ -901,17 +896,6 @@ void smf_config::display() {
n4.thread_rd_sched_params.sched_policy); Logger::smf_app().info( " n4.thread_rd_sched_params.sched_policy); Logger::smf_app().info( "
Scheduling prio .....: %d", n4.thread_rd_sched_params.sched_priority); Scheduling prio .....: %d", n4.thread_rd_sched_params.sched_priority);
Logger::smf_app().info(
" CSCF .........: %s",
inet_ntoa(*((struct in_addr*) &default_cscfv4)));
if (inet_ntop(AF_INET6, &default_cscfv6, str_addr6, sizeof(str_addr6))) {
Logger::smf_app().info(" CSCF v6 ......: %s", str_addr6);
}
Logger::smf_app().info("- " SMF_CONFIG_STRING_DNN_LIST ":");
for (int i = 0; i < num_dnn; i++) {
Logger::smf_app().info(" DNN %d:", i);
Logger::smf_app().info( Logger::smf_app().info(
" CPU id ..............: %d", itti.itti_timer_sched_params.cpu_id); " CPU id ..............: %d", itti.itti_timer_sched_params.cpu_id);
Logger::smf_app().info( Logger::smf_app().info(
...@@ -1009,6 +993,12 @@ void smf_config::display() { ...@@ -1009,6 +993,12 @@ void smf_config::display() {
Logger::smf_app().info(" Secondary DNS v6 ....: %s", str_addr6); Logger::smf_app().info(" Secondary DNS v6 ....: %s", str_addr6);
} }
Logger::smf_app().info(
" CSCF .........: %s", inet_ntoa(*((struct in_addr*) &default_cscfv4)));
if (inet_ntop(AF_INET6, &default_cscfv6, str_addr6, sizeof(str_addr6))) {
Logger::smf_app().info(" CSCF v6 ......: %s", str_addr6);
}
Logger::smf_app().info("- Default UE MTU: %d", ue_mtu); Logger::smf_app().info("- Default UE MTU: %d", ue_mtu);
Logger::smf_app().info("- Supported Features:"); Logger::smf_app().info("- Supported Features:");
Logger::smf_app().info( Logger::smf_app().info(
......
...@@ -227,32 +227,6 @@ class smf_config { ...@@ -227,32 +227,6 @@ class smf_config {
struct in6_addr default_dns_secv6; struct in6_addr default_dns_secv6;
std::map<std::string, dnn_t> dnns; std::map<std::string, dnn_t> dnns;
struct in6_addr default_cscfv6; struct in6_addr default_cscfv6;
#define SMF_NUM_DNN_MAX 5
int num_dnn;
struct {
std::string dnn;
std::string dnn_label;
int pool_id_iv4;
int pool_id_iv6;
pdu_session_type_t pdu_session_type;
} dnn[SMF_NUM_DNN_MAX];
int num_ue_pool;
#define SMF_NUM_UE_POOL_MAX 96
struct in_addr ue_pool_range_low[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_range_high[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_network[SMF_NUM_UE_POOL_MAX];
struct in_addr ue_pool_netmask[SMF_NUM_UE_POOL_MAX];
// computed from config, UE IP adresses that matches
// ue_pool_network[]/ue_pool_netmask[] but do not match ue_pool_range_low[] -
// ue_pool_range_high[]
// The problem here is that OpenFlow do not deal with ip ranges but with
// netmasks
std::vector<struct in_addr> ue_pool_excluded[SMF_NUM_UE_POOL_MAX];
int num_paa6_pool;
struct in6_addr paa_pool6_prefix[SMF_NUM_UE_POOL_MAX];
uint8_t paa_pool6_prefix_len[SMF_NUM_UE_POOL_MAX];
bool force_push_pco; bool force_push_pco;
uint ue_mtu; uint ue_mtu;
......
...@@ -335,7 +335,6 @@ int smf_app::process_pco_link_mtu_request( ...@@ -335,7 +335,6 @@ int smf_app::process_pco_link_mtu_request(
return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp); return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int smf_app::process_pco_p_cscf_request( int smf_app::process_pco_p_cscf_request(
protocol_configuration_options_t& pco_resp, protocol_configuration_options_t& pco_resp,
...@@ -344,8 +343,7 @@ int smf_app::process_pco_p_cscf_request( ...@@ -344,8 +343,7 @@ int smf_app::process_pco_p_cscf_request(
pco_protocol_or_container_id_t poc_id_resp = {0}; pco_protocol_or_container_id_t poc_id_resp = {0};
uint8_t cscf_array[4]; uint8_t cscf_array[4];
Logger::smf_app().debug( Logger::smf_app().debug("PCO: Protocol identifier P CSCF Request");
"PCO: Protocol identifier P CSCF Request");
poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV4_ADDRESS; poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV4_ADDRESS;
poc_id_resp.length_of_protocol_id_contents = 4; poc_id_resp.length_of_protocol_id_contents = 4;
cscf_array[0] = (uint8_t)(cscf_ipv4_addr & 0x000000FF); cscf_array[0] = (uint8_t)(cscf_ipv4_addr & 0x000000FF);
...@@ -366,21 +364,19 @@ int smf_app::process_pco_p_cscf_v6_request( ...@@ -366,21 +364,19 @@ int smf_app::process_pco_p_cscf_v6_request(
pco_protocol_or_container_id_t poc_id_resp = {0}; pco_protocol_or_container_id_t poc_id_resp = {0};
uint8_t cscfv6_array[16]; uint8_t cscfv6_array[16];
Logger::smf_app().debug( Logger::smf_app().debug("PCO: Protocol identifier P CSCF v6 Request");
"PCO: Protocol identifier P CSCF v6 Request");
poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV6_ADDRESS; poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV6_ADDRESS;
poc_id_resp.length_of_protocol_id_contents = 16; poc_id_resp.length_of_protocol_id_contents = 16;
char str_addr6[INET6_ADDRSTRLEN]; char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop( if (inet_ntop(AF_INET6, &cscf_ipv6_addr, str_addr6, sizeof(str_addr6))) {
AF_INET6, &cscf_ipv6_addr, str_addr6,
sizeof(str_addr6))) {
std::string ipv6_addr_str((char*) str_addr6, INET6_ADDRSTRLEN); std::string ipv6_addr_str((char*) str_addr6, INET6_ADDRSTRLEN);
Logger::smf_app().info(" CSCF Ipv6 address....: %s", ipv6_addr_str.c_str()); Logger::smf_app().info(" CSCF Ipv6 address....: %s", ipv6_addr_str.c_str());
unsigned char buf_in6_addr[sizeof(struct in6_addr)]; unsigned char buf_in6_addr[sizeof(struct in6_addr)];
if (inet_pton(AF_INET6, util::trim(ipv6_addr_str).c_str(), buf_in6_addr) == if (inet_pton(AF_INET6, util::trim(ipv6_addr_str).c_str(), buf_in6_addr) ==
1) { 1) {
for (int i = 0; i <= 15; i++) cscfv6_array[i] = (uint8_t)(buf_in6_addr[i]); for (int i = 0; i <= 15; i++)
cscfv6_array[i] = (uint8_t)(buf_in6_addr[i]);
} }
} }
...@@ -390,8 +386,6 @@ int smf_app::process_pco_p_cscf_v6_request( ...@@ -390,8 +386,6 @@ int smf_app::process_pco_p_cscf_v6_request(
return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp); return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int smf_app::process_pco_request( int smf_app::process_pco_request(
const protocol_configuration_options_t& pco_req, const protocol_configuration_options_t& pco_req,
......
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