bneradt commented on code in PR #12031: URL: https://github.com/apache/trafficserver/pull/12031#discussion_r1963893453
########## include/tscore/ink_inet.h: ########## @@ -295,6 +312,26 @@ ats_ip_are_compatible(sockaddr const *lhs, ///< Address to test. return lhs->sa_family == rhs; } +/// @return the path length including the \0 +inline int +ats_unix_path_len(sockaddr_un *s) +{ + return strnlen(s->sun_path, TS_UNIX_SIZE); +} Review Comment: I don't think `strnlen` includes the null terminator in its count. ########## include/tscore/ink_inet.h: ########## @@ -1490,6 +1584,58 @@ IpAddr::hash() const return zret; } +/// A separate Addr struct for unix paths +struct UnAddr { + using self = UnAddr; + + UnAddr() { _path[0] = 0; } + + UnAddr(self const &addr) { strncpy(_path, addr._path, TS_UNIX_SIZE); } + explicit constexpr UnAddr(const char *path) { strncpy(_path, path, TS_UNIX_SIZE - 1); } + explicit constexpr UnAddr(const std::string &path) { strncpy(_path, path.c_str(), TS_UNIX_SIZE); } + + explicit constexpr UnAddr(sockaddr const *addr) { this->assign(addr); } + explicit constexpr UnAddr(sockaddr_un const *addr) { this->assign(ats_ip_sa_cast(addr)); } + /// Construct from @c IpEndpoint. + explicit constexpr UnAddr(IpEndpoint const &addr) { this->assign(&addr.sa); } + /// Construct from @c IpEndpoint. + explicit constexpr UnAddr(IpEndpoint const *addr) { this->assign(&addr->sa); } + /// Assign sockaddr storage. + constexpr self &assign(sockaddr const *addr); + + uint16_t + family() const + { + return AF_UNIX; + } Review Comment: Can this be constexpr too while we're at it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org