Commit 89b5f827 authored by KARIM's avatar KARIM

backup before adding qos rule update

parent f443d4e9
......@@ -203,6 +203,14 @@ class smf_app {
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
int process_pco_p_cscf_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
int process_pco_p_cscf_v6_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
public:
explicit smf_app(const std::string& config_file);
smf_app(smf_app const&) = delete;
......
......@@ -508,12 +508,37 @@ int smf_config::load(const string& config_file) {
util::trim(astring).c_str(), default_dnsv4,
"BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !");
smf_cfg.lookupValue(
SMF_CONFIG_STRING_DEFAULT_DNS_SEC_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), default_dns_secv4,
"BAD IPv4 ADDRESS FORMAT FOR DEFAULT DNS !");
smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_CSCF_IPV4_ADDRESS, astring);
IPV4_STR_ADDR_TO_INADDR(
util::trim(astring).c_str(), default_cscfv4,
"BAD IPv4 ADDRESS FORMAT FOR DEFAULT CSCF !");
smf_cfg.lookupValue(SMF_CONFIG_STRING_DEFAULT_CSCF_IPV6_ADDRESS, astring);
if (inet_pton(AF_INET6, util::trim(astring).c_str(), buf_in6_addr) == 1) {
memcpy(&default_cscfv6, buf_in6_addr, sizeof(struct in6_addr));
} else {
Logger::smf_app().error(
"CONFIG : BAD ADDRESS in " SMF_CONFIG_STRING_DEFAULT_CSCF_IPV6_ADDRESS
" %s",
astring.c_str());
throw(
"CONFIG : BAD ADDRESS in " SMF_CONFIG_STRING_DEFAULT_CSCF_IPV6_ADDRESS
" %s",
astring.c_str());
}
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) {
memcpy(&default_dnsv6, buf_in6_addr, sizeof(struct in6_addr));
......@@ -857,6 +882,13 @@ void smf_config::display() {
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("- " SMF_CONFIG_STRING_DNN_LIST ":");
for (int i = 0; i < num_dnn; i++) {
Logger::smf_app().info(" DNN %d:", i);
......
......@@ -66,6 +66,9 @@
#define SMF_CONFIG_STRING_IPV4_ADDRESS_RANGE_DELIMITER "-"
#define SMF_CONFIG_STRING_IPV6_ADDRESS_PREFIX_DELIMITER "/"
#define SMF_CONFIG_STRING_DEFAULT_DNS_IPV4_ADDRESS "DEFAULT_DNS_IPV4_ADDRESS"
#define SMF_CONFIG_STRING_DEFAULT_CSCF_IPV4_ADDRESS "DEFAULT_CSCF_IPV4_ADDRESS"
#define SMF_CONFIG_STRING_DEFAULT_CSCF_IPV6_ADDRESS "DEFAULT_CSCF_IPV6_ADDRESS"
#define SMF_CONFIG_STRING_DEFAULT_DNS_SEC_IPV4_ADDRESS \
"DEFAULT_DNS_SEC_IPV4_ADDRESS"
#define SMF_CONFIG_STRING_DEFAULT_DNS_IPV6_ADDRESS "DEFAULT_DNS_IPV6_ADDRESS"
......@@ -181,9 +184,10 @@ class smf_config {
struct in_addr default_dnsv4;
struct in_addr default_dns_secv4;
struct in_addr default_cscfv4;
struct in6_addr default_dnsv6;
struct in6_addr default_dns_secv6;
struct in6_addr default_cscfv6;
#define SMF_NUM_DNN_MAX 5
int num_dnn;
struct {
......
......@@ -335,6 +335,63 @@ int smf_app::process_pco_link_mtu_request(
return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp);
}
//------------------------------------------------------------------------------
int smf_app::process_pco_p_cscf_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id) {
in_addr_t cscf_ipv4_addr = smf_cfg.default_cscfv4.s_addr;
pco_protocol_or_container_id_t poc_id_resp = {0};
uint8_t cscf_array[4];
Logger::smf_app().debug(
"PCO: Protocol identifier P CSCF Request");
poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV4_ADDRESS;
poc_id_resp.length_of_protocol_id_contents = 4;
cscf_array[0] = (uint8_t)(cscf_ipv4_addr & 0x000000FF);
cscf_array[1] = (uint8_t)((cscf_ipv4_addr >> 8) & 0x000000FF);
cscf_array[2] = (uint8_t)((cscf_ipv4_addr >> 16) & 0x000000FF);
cscf_array[3] = (uint8_t)((cscf_ipv4_addr >> 24) & 0x000000FF);
std::string tmp_s((const char*) &cscf_array[0], sizeof(cscf_array));
poc_id_resp.protocol_id_contents = tmp_s;
return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp);
}
//------------------------------------------------------------------------------
int smf_app::process_pco_p_cscf_v6_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id) {
in6_addr cscf_ipv6_addr = smf_cfg.default_cscfv6;
pco_protocol_or_container_id_t poc_id_resp = {0};
uint8_t cscfv6_array[16];
Logger::smf_app().debug(
"PCO: Protocol identifier P CSCF v6 Request");
poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV6_ADDRESS;
poc_id_resp.length_of_protocol_id_contents = 16;
char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(
AF_INET6, &cscf_ipv6_addr, str_addr6,
sizeof(str_addr6))) {
std::string ipv6_addr_str((char*) str_addr6, INET6_ADDRSTRLEN);
Logger::smf_app().info(" CSCF Ipv6 address....: %s", ipv6_addr_str.c_str());
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
if (inet_pton(AF_INET6, util::trim(ipv6_addr_str).c_str(), buf_in6_addr) ==
1) {
for (int i = 0; i <= 15; i++) cscfv6_array[i] = (uint8_t)(buf_in6_addr[i]);
}
}
std::string tmp_s((const char*) &cscfv6_array[0], sizeof(cscfv6_array));
poc_id_resp.protocol_id_contents = tmp_s;
return pco_push_protocol_or_container_id(pco_resp, &poc_id_resp);
}
//------------------------------------------------------------------------------
int smf_app::process_pco_request(
const protocol_configuration_options_t& pco_req,
......@@ -384,6 +441,17 @@ int smf_app::process_pco_request(
pco_ids.ci_ipv4_link_mtu_request = true;
break;
case PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV6_ADDRESS_REQUEST:
process_pco_p_cscf_v6_request(
pco_resp, &pco_req.protocol_or_container_ids[id]);
pco_ids.ci_ipv6_p_cscf_request = true;
break;
case PCO_CONTAINER_IDENTIFIER_P_CSCF_IPV4_ADDRESS_REQUEST:
process_pco_p_cscf_request(
pco_resp, &pco_req.protocol_or_container_ids[id]);
pco_ids.ci_ipv4_p_cscf_request = true;
break;
default:
Logger::smf_app().warn(
"PCO: Protocol/container identifier 0x%04X not supported now",
......
......@@ -48,6 +48,8 @@ typedef struct protocol_configuration_options_ids_s {
uint8_t ci_ipv4_address_allocation_via_dhcpv4 : 1;
uint8_t ci_ipv4_link_mtu_request : 1;
uint8_t ci_dns_server_ipv6_address_request : 1;
uint8_t ci_ipv6_p_cscf_request : 1;
uint8_t ci_ipv4_p_cscf_request : 1;
} protocol_configuration_options_ids_t;
#endif
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