E-MailRelay
|
A class for getting a list of network interfaces and their addresses. More...
#include <ginterfaces.h>
Classes | |
struct | Item |
Used by GNet::Interfaces to describe an interface address binding. More... | |
Public Types | |
using | const_iterator = std::vector< Item >::const_iterator |
![]() | |
enum class | Reason { closed , down , reset , abort , other } |
Public Member Functions | |
Interfaces () | |
Default constructor resulting in an empty list. More... | |
Interfaces (ExceptionSink, InterfacesHandler &) | |
Constructor resulting in an empty list with an attached event handler. More... | |
~Interfaces () override | |
Destructor. | |
void | load () |
Loads or reloads the list. More... | |
bool | loaded () const |
Returns true if load()ed. More... | |
G::StringArray | names (bool all=false) const |
Returns the interface names, optionally including interfaces that are not up. More... | |
const_iterator | begin () const |
Returns a begin iterator. More... | |
const_iterator | end () const |
Returns a one-off-the-end iterator. More... | |
std::vector< Address > | find (const std::string &name, unsigned int port, bool allow_decoration=true) const |
Finds the named interface and returns its addresses if it is up. More... | |
std::vector< Address > | addresses (const G::StringArray &names, unsigned int port, G::StringArray &used_names, G::StringArray &empty_names, G::StringArray &bad_names) const |
Treats each name given as an address or interface name and returns the total set of addresses. More... | |
Interfaces (const Interfaces &)=delete | |
Interfaces (Interfaces &&)=delete | |
void | operator= (const Interfaces &)=delete |
void | operator= (Interfaces &&)=delete |
![]() | |
virtual | ~EventHandler ()=default |
Destructor. | |
virtual void | readEvent () |
Called for a read event. More... | |
virtual void | writeEvent () |
Called for a write event. More... | |
virtual void | otherEvent (Reason) |
Called for a socket-exception event, or a socket-close event on windows. More... | |
![]() | |
virtual | ~FutureEventHandler ()=default |
Destructor. | |
virtual void | onFutureEvent ()=0 |
Callback function that delivers the future event. | |
Static Public Member Functions | |
static bool | supported () |
Returns false if a stubbed-out implementation. More... | |
static bool | active () |
Returns true if the implementation can raise InterfacesHandler events. More... | |
![]() | |
static std::string | str (Reason) |
Returns a printable description of the other-event reason. More... | |
A class for getting a list of network interfaces and their addresses.
Definition at line 44 of file ginterfaces.h.
using GNet::Interfaces::const_iterator = std::vector<Item>::const_iterator |
Definition at line 60 of file ginterfaces.h.
|
default |
Default constructor resulting in an empty list.
Use load() to initialise.
GNet::Interfaces::Interfaces | ( | ExceptionSink | es, |
InterfacesHandler & | handler | ||
) |
Constructor resulting in an empty list with an attached event handler.
Use load() or find() to initialise the list and activate the event listener.
Definition at line 30 of file ginterfaces_common.cpp.
|
static |
Returns true if the implementation can raise InterfacesHandler events.
Definition at line 72 of file ginterfaces_unix.cpp.
std::vector< GNet::Address > GNet::Interfaces::addresses | ( | const G::StringArray & | names, |
unsigned int | port, | ||
G::StringArray & | used_names, | ||
G::StringArray & | empty_names, | ||
G::StringArray & | bad_names | ||
) | const |
Treats each name given as an address or interface name and returns the total set of addresses.
Returns by reference (1) names that are, or have, addresses, (2) names that might be interfaces with no bound addresses, and (3) the remainder, ie. names that are not addresses and cannot be a valid interface name.
Definition at line 100 of file ginterfaces_common.cpp.
GNet::Interfaces::const_iterator GNet::Interfaces::begin | ( | ) | const |
Returns a begin iterator.
Definition at line 147 of file ginterfaces_common.cpp.
GNet::Interfaces::const_iterator GNet::Interfaces::end | ( | ) | const |
Returns a one-off-the-end iterator.
Definition at line 152 of file ginterfaces_common.cpp.
std::vector< GNet::Address > GNet::Interfaces::find | ( | const std::string & | name, |
unsigned int | port, | ||
bool | allow_decoration = true |
||
) | const |
Finds the named interface and returns its addresses if it is up.
If the decoration flag is used and the name is decorated with "-ipv4" or "-ipv6" then only those addresses are returned. The returned addresses all have the given port number. Returns the empty list if not found or if found but not up. Does lazy load()ing.
Definition at line 58 of file ginterfaces_common.cpp.
void GNet::Interfaces::load | ( | ) |
Loads or reloads the list.
Definition at line 39 of file ginterfaces_common.cpp.
bool GNet::Interfaces::loaded | ( | ) | const |
Returns true if load()ed.
Definition at line 53 of file ginterfaces_common.cpp.
G::StringArray GNet::Interfaces::names | ( | bool | all = false | ) | const |
Returns the interface names, optionally including interfaces that are not up.
Definition at line 134 of file ginterfaces_common.cpp.
|
static |
Returns false if a stubbed-out implementation.
Definition at line 48 of file ginterfaces_common.cpp.