InspIRCd  3.0
Classes | Functions
irc::sockets Namespace Reference


struct  cidr_mask
union  sockaddrs


bool MatchCIDR (const std::string &address, const std::string &cidr_mask, bool match_with_username)
bool aptosa (const std::string &addr, int port, irc::sockets::sockaddrs &sa)

Detailed Description

This namespace contains various protocol-independent helper classes. It also contains some types which are often used by the core and modules in place of inet_* functions and types.

Function Documentation

◆ aptosa()

bool irc::sockets::aptosa ( const std::string &  addr,
int  port,
irc::sockets::sockaddrs sa 

Convert an address-port pair into a binary sockaddr

addrThe IP address, IPv4 or IPv6
portThe port, 0 for unspecified
saThe structure to place the result in. Will be zeroed prior to conversion
true if the conversion was successful, false if not.

◆ MatchCIDR()

bool irc::sockets::MatchCIDR ( const std::string &  address,
const std::string &  cidr_mask,
bool  match_with_username 

Match CIDR, including an optional username/nickname part.

This function will compare a human-readable address (plus optional username and nickname) against a human-readable CIDR mask, for example [email protected] against *[email protected]/16. This method supports both IPV4 and IPV6 addresses.

addressThe human readable address, e.g. [email protected]
cidr_maskThe human readable mask, e.g. *@
match_with_usernameDoes the mask include a nickname segment?
True if the mask matches the address