Anope IRC Services  Version 2.0
Public Member Functions | Data Fields
sockaddrs Union Reference

#include <sockets.h>

Public Member Functions

 sockaddrs (const Anope::string &address="")
 
void clear ()
 
size_t size () const
 
int port () const
 
Anope::string addr () const
 
bool ipv6 () const
 
bool valid () const
 
bool operator== (const sockaddrs &other) const
 
bool operator!= (const sockaddrs &other) const
 
void pton (int type, const Anope::string &address, int pport=0)
 
void ntop (int type, const void *src)
 

Data Fields

sockaddr sa
 
sockaddr_in sa4
 
sockaddr_in6 sa6
 

Detailed Description

A sockaddr union used to combine IPv4 and IPv6 sockaddrs

Definition at line 28 of file sockets.h.

Constructor & Destructor Documentation

sockaddrs::sockaddrs ( const Anope::string address = "")

Construct the object, sets everything to 0

Definition at line 31 of file sockets.cpp.

References clear(), Anope::string::empty(), Anope::string::find(), Anope::string::find_first_not_of_ci(), Anope::string::npos, and pton().

Member Function Documentation

Anope::string sockaddrs::addr ( ) const
void sockaddrs::clear ( )

Memset the object to 0

Definition at line 38 of file sockets.cpp.

Referenced by ntop(), pton(), and sockaddrs().

bool sockaddrs::ipv6 ( ) const

Definition at line 94 of file sockets.cpp.

References sa.

Referenced by MySessionService::FindSessionIterator(), and cidr::mask().

void sockaddrs::ntop ( int  type,
const void *  src 
)

The equivalent of inet_ntop

Parameters
typeAF_INET or AF_INET6
addressThe in_addr or in_addr6 structure
Exceptions
Asocket exception if given an invalid structure

Definition at line 156 of file sockets.cpp.

References clear(), inet_ntop, sa4, and sa6.

Referenced by Packet::Pack(), IRCDMessageNick::Run(), and Packet::UnpackResourceRecord().

bool sockaddrs::operator!= ( const sockaddrs other) const
inline

Definition at line 69 of file sockets.h.

bool sockaddrs::operator== ( const sockaddrs other) const

Compares with sockaddr with another. Compares address type, port, and address

Returns
true if they are the same

Definition at line 104 of file sockets.cpp.

References sa, sa4, and sa6.

int sockaddrs::port ( ) const

Get the port represented by this addr

Returns
The port, or -1 on fail

Definition at line 58 of file sockets.cpp.

References sa, sa4, and sa6.

Referenced by ProxyConnect::Ban().

void sockaddrs::pton ( int  type,
const Anope::string address,
int  pport = 0 
)

The equivalent of inet_pton

Parameters
typeAF_INET or AF_INET6
addressThe address to place in the sockaddr structures
pportAn option port to include in the sockaddr structures
Exceptions
Asocket exception if given invalid IPs

Definition at line 121 of file sockets.cpp.

References Anope::string::c_str(), clear(), inet_pton, sa4, and sa6.

Referenced by SocketIO::Bind(), cidr::cidr(), SSLSocketIO::Connect(), SocketIO::Connect(), MyManager::Notify(), SOCKS5ProxyConnect::OnConnect(), DNSBLResolver::OnLookupComplete(), MyManager::SetIPPort(), and sockaddrs().

size_t sockaddrs::size ( ) const

Get the size of the sockaddr we represent

Returns
The size

Definition at line 43 of file sockets.cpp.

References sa, sa4, and sa6.

Referenced by SocketIO::Bind(), SSLSocketIO::Connect(), SocketIO::Connect(), pipe(), UDPSocket::ProcessWrite(), NotifySocket::ProcessWrite(), and valid().

bool sockaddrs::valid ( ) const

Field Documentation

sockaddr sockaddrs::sa
sockaddr_in sockaddrs::sa4
sockaddr_in6 sockaddrs::sa6

The documentation for this union was generated from the following files: