Support multiple RDMA networks
This commit is contained in:
@@ -93,6 +93,13 @@ bool cidr6_match(const in6_addr &address, const in6_addr &network, uint8_t bits)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cidr_sockaddr_match(const sockaddr_storage &addr, const addr_mask_t &mask)
|
||||
{
|
||||
return mask.family == addr.ss_family && (mask.family == AF_INET
|
||||
? cidr_match(((sockaddr_in*)&addr)->sin_addr, mask.ipv4, mask.bits)
|
||||
: cidr6_match(((sockaddr_in6*)&addr)->sin6_addr, mask.ipv6, mask.bits));
|
||||
}
|
||||
|
||||
addr_mask_t cidr_parse(std::string mask)
|
||||
{
|
||||
unsigned bits = 255;
|
||||
|
||||
@@ -18,5 +18,6 @@ std::string addr_to_string(const sockaddr_storage &addr);
|
||||
addr_mask_t cidr_parse(std::string mask);
|
||||
bool cidr_match(const in_addr &address, const in_addr &network, uint8_t bits);
|
||||
bool cidr6_match(const in6_addr &address, const in6_addr &network, uint8_t bits);
|
||||
bool cidr_sockaddr_match(const sockaddr_storage &addr, const addr_mask_t &mask);
|
||||
std::vector<std::string> getifaddr_list(const std::vector<addr_mask_t> & masks = std::vector<addr_mask_t>(), bool include_v6 = false);
|
||||
int create_and_bind_socket(std::string bind_address, int bind_port, int listen_backlog, int *listening_port);
|
||||
|
||||
Reference in New Issue
Block a user