uvco 0.1
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
uvco::AddressHandle::NtopHelper_ Struct Reference

A helper for calling inet_ntop(3). More...

Static Public Member Functions

static std::string operator() (const struct sockaddr_in &ipv4)
 
static std::string operator() (const struct sockaddr_in6 &ipv6)
 
static std::string ntop (int family, void *addr)
 

Detailed Description

A helper for calling inet_ntop(3).

Member Function Documentation

◆ ntop()

std::string uvco::AddressHandle::NtopHelper_::ntop ( int  family,
void *  addr 
)
static
196 {
197 std::string dst{};
198 if (family == AF_INET) {
199 dst.resize(4 * 3 + 3 + 1);
200 } else if (family == AF_INET6) {
201 dst.resize(8 * 4 + 7 + 1);
202 }
203 const char *result = inet_ntop(family, addr, dst.data(), dst.size());
204 if (result == nullptr) {
205 throw UvcoException(fmt::format("inet_ntop(): {}", std::strerror(errno)));
206 }
207 dst.resize(std::strlen(result));
208 return dst;
209}
int family() const
Family is either AF_INET or AF_INET6.
Definition name_resolution.cc:76

◆ operator()() [1/2]

std::string uvco::AddressHandle::NtopHelper_::operator() ( const struct sockaddr_in &  ipv4)
static
217 {
218 return ntop(ipv4.sin_family, (void *)&ipv4.sin_addr);
219}
static std::string ntop(int family, void *addr)
Definition name_resolution.cc:196

◆ operator()() [2/2]

std::string uvco::AddressHandle::NtopHelper_::operator() ( const struct sockaddr_in6 &  ipv6)
static
212 {
213 return ntop(ipv6.sin6_family, (void *)&ipv6.sin6_addr);
214}

The documentation for this struct was generated from the following files: