Commit 2be016a7 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Support DNS v6

parent f31e6e34
...@@ -104,7 +104,7 @@ void util::ipv6_to_bstring(struct in6_addr ipv6_address, bstring str) { ...@@ -104,7 +104,7 @@ void util::ipv6_to_bstring(struct in6_addr ipv6_address, bstring str) {
char str_addr6[INET6_ADDRSTRLEN]; char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(AF_INET6, &ipv6_address, str_addr6, sizeof(str_addr6))) { if (inet_ntop(AF_INET6, &ipv6_address, 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(" Ipv6 address....: %s", ipv6_addr_str.c_str()); // Logger::smf_app().info(" 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) {
...@@ -121,7 +121,7 @@ void util::ipv4v6_to_pdu_address_information( ...@@ -121,7 +121,7 @@ void util::ipv4v6_to_pdu_address_information(
if (inet_ntop(AF_INET6, &ipv6_address, str_addr6, sizeof(str_addr6))) { if (inet_ntop(AF_INET6, &ipv6_address, 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(" Ipv6 address....: %s", ipv6_addr_str.c_str()); // Logger::smf_app().info(" 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) {
......
...@@ -186,6 +186,16 @@ class smf_app { ...@@ -186,6 +186,16 @@ 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_dns_server_v6_request
* @param [protocol_configuration_options_t &] pco_resp
* @param [pco_protocol_or_container_id_t *const] proc_id
* @return
*/
int process_pco_dns_server_v6_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id);
/* /*
* process_pco_link_mtu_request * process_pco_link_mtu_request
* @param [protocol_configuration_options_t &] pco_resp * @param [protocol_configuration_options_t &] pco_resp
......
...@@ -1328,7 +1328,8 @@ void smf_context::handle_pdu_session_create_sm_context_request( ...@@ -1328,7 +1328,8 @@ void smf_context::handle_pdu_session_create_sm_context_request(
.ci_dns_server_ipv4_address_request = 0, .ci_dns_server_ipv4_address_request = 0,
.ci_ip_address_allocation_via_nas_signalling = 0, .ci_ip_address_allocation_via_nas_signalling = 0,
.ci_ipv4_address_allocation_via_dhcpv4 = 0, .ci_ipv4_address_allocation_via_dhcpv4 = 0,
.ci_ipv4_link_mtu_request = 0}; .ci_ipv4_link_mtu_request = 0,
.ci_dns_server_ipv6_address_request = 0};
smf_app_inst->process_pco_request(pco_req, pco_resp, pco_ids); smf_app_inst->process_pco_request(pco_req, pco_resp, pco_ids);
sm_context_resp_pending->res.set_epco(pco_resp); sm_context_resp_pending->res.set_epco(pco_resp);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "rfc_1877.h" #include "rfc_1877.h"
#include "smf_app.hpp" #include "smf_app.hpp"
#include "smf_config.hpp" #include "smf_config.hpp"
#include "string.hpp"
using namespace smf; using namespace smf;
...@@ -283,6 +284,38 @@ int smf_app::process_pco_dns_server_request( ...@@ -283,6 +284,38 @@ int smf_app::process_pco_dns_server_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_dns_server_v6_request(
protocol_configuration_options_t& pco_resp,
const pco_protocol_or_container_id_t* const poc_id) {
in6_addr ipcp_out_dns_prim_ipv6_addr = smf_cfg.default_dnsv6;
pco_protocol_or_container_id_t poc_id_resp = {0};
uint8_t dnsv6_array[16];
Logger::smf_app().debug(
"PCO: Protocol identifier IPCP option DNS Server v6 Request");
poc_id_resp.protocol_id = PCO_CONTAINER_IDENTIFIER_DNS_SERVER_IPV6_ADDRESS;
poc_id_resp.length_of_protocol_id_contents = 16;
char str_addr6[INET6_ADDRSTRLEN];
if (inet_ntop(
AF_INET6, &ipcp_out_dns_prim_ipv6_addr, str_addr6,
sizeof(str_addr6))) {
std::string ipv6_addr_str((char*) str_addr6, INET6_ADDRSTRLEN);
// Logger::smf_app().info(" 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++) dnsv6_array[i] = (uint8_t)(buf_in6_addr[i]);
}
}
std::string tmp_s((const char*) &dnsv6_array[0], sizeof(dnsv6_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_link_mtu_request( int smf_app::process_pco_link_mtu_request(
protocol_configuration_options_t& pco_resp, protocol_configuration_options_t& pco_resp,
...@@ -335,7 +368,11 @@ int smf_app::process_pco_request( ...@@ -335,7 +368,11 @@ int smf_app::process_pco_request(
pco_resp, &pco_req.protocol_or_container_ids[id]); pco_resp, &pco_req.protocol_or_container_ids[id]);
pco_ids.ci_dns_server_ipv4_address_request = true; pco_ids.ci_dns_server_ipv4_address_request = true;
break; break;
case PCO_CONTAINER_IDENTIFIER_DNS_SERVER_IPV6_ADDRESS:
process_pco_dns_server_v6_request(
pco_resp, &pco_req.protocol_or_container_ids[id]);
pco_ids.ci_dns_server_ipv6_address_request = true;
break;
case PCO_CONTAINER_IDENTIFIER_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING: case PCO_CONTAINER_IDENTIFIER_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING:
Logger::smf_app().debug("PCO: Allocation via NAS signaling requested"); Logger::smf_app().debug("PCO: Allocation via NAS signaling requested");
pco_ids.ci_ip_address_allocation_via_nas_signalling = true; pco_ids.ci_ip_address_allocation_via_nas_signalling = true;
......
...@@ -47,6 +47,7 @@ typedef struct protocol_configuration_options_ids_s { ...@@ -47,6 +47,7 @@ typedef struct protocol_configuration_options_ids_s {
uint8_t ci_ip_address_allocation_via_nas_signalling : 1; uint8_t ci_ip_address_allocation_via_nas_signalling : 1;
uint8_t ci_ipv4_address_allocation_via_dhcpv4 : 1; uint8_t ci_ipv4_address_allocation_via_dhcpv4 : 1;
uint8_t ci_ipv4_link_mtu_request : 1; uint8_t ci_ipv4_link_mtu_request : 1;
uint8_t ci_dns_server_ipv6_address_request : 1;
} protocol_configuration_options_ids_t; } protocol_configuration_options_ids_t;
#endif #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