21#ifndef G_NET_INTERFACES_H
22#define G_NET_INTERFACES_H
37 class InterfacesHandler ;
38 class InterfacesNotifier ;
51 unsigned int address_family{0} ;
52 bool valid_address{
false} ;
54 bool has_netmask{
false} ;
55 unsigned int netmask_bits{0U} ;
57 bool loopback{
false} ;
60 using const_iterator = std::vector<Item>::const_iterator ;
92 const_iterator
begin()
const ;
95 const_iterator
end()
const ;
98 std::vector<Address>
find(
const std::string & name ,
unsigned int port ,
99 bool allow_decoration =
true )
const ;
118 void readEvent()
override ;
119 void onFutureEvent()
override ;
124 void operator=(
const Interfaces & ) = delete ;
128 using AddressList = std::vector<Address> ;
134 mutable bool m_loaded{
false} ;
135 mutable std::vector<Item> m_list ;
136 std::unique_ptr<InterfacesNotifier> m_notifier ;
The GNet::Address class encapsulates a TCP/UDP transport address.
A base class for classes that handle asynchronous events from the event loop.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
A callback interface for GNet::FutureEvent.
An interface for receiving notification of network changes.
virtual void onInterfaceEvent(const std::string &)=0
Indicates some network event that might have invalidated the GNet::Interfaces state,...
virtual ~InterfacesHandler()=default
Destructor.
A pimple base-class used by GNet::Interfaces.
virtual std::string readEvent()=0
Called by GNet::Interfaces to handle a read event.
virtual ~InterfacesNotifier()=default
Destructor.
virtual std::string onFutureEvent()=0
Called by GNet::Interfaces to handle a future event.
A class for getting a list of network interfaces and their addresses.
void load()
Loads or reloads the list.
static bool active()
Returns true if the implementation can raise InterfacesHandler events.
Interfaces()
Default constructor resulting in an empty list.
bool loaded() const
Returns true if load()ed.
~Interfaces() override
Destructor.
static bool supported()
Returns false if a stubbed-out implementation.
const_iterator begin() const
Returns a begin iterator.
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.
const_iterator end() const
Returns a one-off-the-end iterator.
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.
G::StringArray names(bool all=false) const
Returns the interface names, optionally including interfaces that are not up.
std::vector< std::string > StringArray
A std::vector of std::strings.
Used by GNet::Interfaces to describe an interface address binding.