util.hpp (e5a48ab0ca0f9e6a29a78cd1110337763624a19c) | util.hpp (97b5dc68bf301a5a97e0169217de2916bd91a0de) |
---|---|
1#pragma once 2#include "types.hpp" 3 4#include <netinet/ether.h> 5#include <netinet/in.h> 6#include <unistd.h> 7 8#include <cstring> --- 77 unchanged lines hidden (view full) --- 86template <> 87struct FamilyTraits<AF_INET6> 88{ 89 using addr = in6_addr; 90}; 91 92/* @brief converts a sockaddr for the specified address family into 93 * a type_safe InAddrAny. | 1#pragma once 2#include "types.hpp" 3 4#include <netinet/ether.h> 5#include <netinet/in.h> 6#include <unistd.h> 7 8#include <cstring> --- 77 unchanged lines hidden (view full) --- 86template <> 87struct FamilyTraits<AF_INET6> 88{ 89 using addr = in6_addr; 90}; 91 92/* @brief converts a sockaddr for the specified address family into 93 * a type_safe InAddrAny. |
94 * @param[in] addressFamily - The address family of the buf | 94 * @param[in] family - The address family of the buf |
95 * @param[in] buf - The network byte order address 96 */ | 95 * @param[in] buf - The network byte order address 96 */ |
97InAddrAny addrFromBuf(int addressFamily, std::string_view buf); | 97template <int family> 98typename FamilyTraits<family>::addr addrFromBuf(std::string_view buf); 99InAddrAny addrFromBuf(int family, std::string_view buf); |
98 99/* @brief converts the ip bytes into a string representation 100 * @param[in] addr - input ip address to convert. 101 * @returns String representation of the ip. 102 */ 103std::string toString(const InAddrAny& addr); 104std::string toString(const struct in_addr& addr); 105std::string toString(const struct in6_addr& addr); --- 96 unchanged lines hidden --- | 100 101/* @brief converts the ip bytes into a string representation 102 * @param[in] addr - input ip address to convert. 103 * @returns String representation of the ip. 104 */ 105std::string toString(const InAddrAny& addr); 106std::string toString(const struct in_addr& addr); 107std::string toString(const struct in6_addr& addr); --- 96 unchanged lines hidden --- |