InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
Classes | Functions
irc::sockets Namespace Reference


struct  cidr_mask
union  sockaddrs


CoreExport bool MatchCIDR (const std::string &address, const std::string &cidr_mask, bool match_with_username)
int sa_size (const irc::sockets::sockaddrs &sa)
CoreExport bool aptosa (const std::string &addr, int port, irc::sockets::sockaddrs &sa)
CoreExport bool satoap (const irc::sockets::sockaddrs &sa, std::string &addr, int &port)
std::string satouser (const 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

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.
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 joe!bloggs@ against *!bloggs@ This method supports both IPV4 and IPV6 addresses.

addressThe human readable address, e.g. fred@
cidr_maskThe human readable mask, e.g. *@
match_with_usernameDoes the mask include a nickname segment?
True if the mask matches the address
int irc::sockets::sa_size ( const irc::sockets::sockaddrs sa)

Return the size of the structure for syscall passing

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

Convert a binary sockaddr to an address-port pair

saThe structure to convert
addrthe IP address
portthe port
true if the conversion was successful, false if unknown address family
std::string irc::sockets::satouser ( const irc::sockets::sockaddrs sa)

Convert a binary sockaddr to a user-readable string. This means IPv6 addresses are written as [::1]:6667, and *:6668 is used for

saThe structure to convert
The string; "<unknown>" if not a valid address