| #pragma once |
| |
| #include <boost/asio/ip/address.hpp> |
| |
| #include <string> |
| |
| namespace redfish |
| { |
| namespace ip_util |
| { |
| |
| /** |
| * @brief Converts boost::asio::ip::address to string |
| * Will automatically convert IPv4-mapped IPv6 address back to IPv4. |
| * |
| * @param[in] ipAddr IP address to convert |
| * |
| * @return IP address string |
| */ |
| inline std::string toString(const boost::asio::ip::address& ipAddr) |
| { |
| if (ipAddr.is_v6() && ipAddr.to_v6().is_v4_mapped()) |
| { |
| return boost::asio::ip::make_address_v4(boost::asio::ip::v4_mapped, |
| ipAddr.to_v6()) |
| .to_string(); |
| } |
| return ipAddr.to_string(); |
| } |
| |
| } // namespace ip_util |
| } // namespace redfish |