Commit e3362e99 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Temp: Use hardcoded IPv6 Addr

parent f92c1a86
......@@ -120,6 +120,25 @@ void util::ipv4v6_to_bstring(
memcpy(str->data, bitstream_addr, sizeof(bitstream_addr));
}
void util::ipv4v6_to_bstring(
struct in_addr ipv4_address, std::string ipv6_address, bstring str) {
unsigned char bitstream_addr[12];
bitstream_addr[0] = (uint8_t)((ipv4_address.s_addr) & 0x000000ff);
bitstream_addr[1] = (uint8_t)(((ipv4_address.s_addr) & 0x0000ff00) >> 8);
bitstream_addr[2] = (uint8_t)(((ipv4_address.s_addr) & 0x00ff0000) >> 16);
bitstream_addr[3] = (uint8_t)(((ipv4_address.s_addr) & 0xff000000) >> 24);
std::string ipv6_addr = "2001:4860:4860::2";
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
if (inet_pton(AF_INET6, util::trim(ipv6_addr).c_str(), buf_in6_addr) == 1) {
// memcpy(&p, buf_in6_addr, sizeof(struct in6_addr));
for (int i = 0; i <= 7; i++)
bitstream_addr[i + 4] = (uint8_t)(buf_in6_addr[i]);
}
str->slen = 12;
memcpy(str->data, bitstream_addr, sizeof(bitstream_addr));
}
void util::string_to_bstring(const std::string& str, bstring bstr) {
// bstr = bfromcstralloc(str.length(), "\0");
bstr->slen = str.length();
......
......@@ -49,6 +49,8 @@ void ipv4_to_bstring(struct in_addr ipv4_address, bstring str);
void ipv6_to_bstring(struct in6_addr ipv6_address, bstring str);
void ipv4v6_to_bstring(
struct in_addr ipv4_address, struct in6_addr ipv6_address, bstring str);
void ipv4v6_to_bstring(
struct in_addr ipv4_address, std::string ipv6_address, bstring str);
void string_to_bstring(const std::string& str, bstring bstr);
} // namespace util
......
......@@ -33,6 +33,8 @@
#include <map>
#include "logger.hpp"
#include "string.hpp"
#include <boost/algorithm/string.hpp>
class ipv6_pool {
public:
......@@ -239,7 +241,15 @@ class paa_dynamic {
return true;
}
}
ipv4_pools[*it4].free_address(paa.ipv4_address);
// ipv4_pools[*it4].free_address(paa.ipv4_address);
// TODO: To be fixed the error for IPv6 addr allocation, so assign a
// fixed IPv6 addr here!
std::string ipv6_addr = "2001:4860:4860::2";
unsigned char buf_in6_addr[sizeof(struct in6_addr)];
if (inet_pton(
AF_INET6, util::trim(ipv6_addr).c_str(), buf_in6_addr) == 1) {
memcpy(&paa.ipv6_address, buf_in6_addr, sizeof(struct in6_addr));
}
}
Logger::smf_app().warn(
"Could not get PAA PDU_SESSION_TYPE_E_IPV4V6 for DNN %s",
......
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