netbase: refactor CreateSock() to accept sa_family_t

Also implement CService::GetSAFamily() to provide sa_family_t
This commit is contained in:
Matthew Zipkin
2023-05-26 12:26:43 -04:00
parent adb3a3e51d
commit bae86c8d31
9 changed files with 46 additions and 25 deletions

View File

@@ -818,6 +818,19 @@ bool CService::SetSockAddr(const struct sockaddr *paddr)
}
}
sa_family_t CService::GetSAFamily() const
{
switch (m_net) {
case NET_IPV4:
return AF_INET;
case NET_IPV6:
case NET_CJDNS:
return AF_INET6;
default:
return AF_UNSPEC;
}
}
uint16_t CService::GetPort() const
{
return port;