21#ifndef G_NET_INTERFACES_H
22#define G_NET_INTERFACES_H
38 class InterfacesHandler ;
39 class InterfacesNotifier ;
55 unsigned int address_family {0} ;
56 bool valid_address {
false} ;
58 bool has_netmask {
false} ;
59 unsigned int netmask_bits {0U} ;
61 bool loopback {
false} ;
64 using const_iterator = std::vector<Item>::const_iterator ;
96 const_iterator
begin()
const ;
99 const_iterator
end()
const ;
102 std::vector<Address>
addresses(
const std::string & name ,
unsigned int port ,
int af = AF_UNSPEC )
const ;
106 std::size_t
addresses( std::vector<Address> & out ,
const std::string & name ,
unsigned int port ,
int af = AF_UNSPEC )
const ;
111 void readEvent()
override ;
112 void onFutureEvent()
override ;
121 using AddressList = std::vector<Address> ;
122 void loadImp(
EventState , std::vector<Item> & list ) ;
123 static int index(
const std::string & ) ;
128 mutable bool m_loaded{
false} ;
129 mutable std::vector<Item> m_list ;
130 std::unique_ptr<InterfacesNotifier> m_notifier ;
The GNet::Address class encapsulates a TCP/UDP transport address.
A base class for classes that have a file descriptor and handle asynchronous events from the event lo...
A lightweight object containing an ExceptionHandler pointer, optional ExceptionSource pointer and opt...
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.
Interfaces(EventState)
Constructor resulting in an empty list.
std::vector< Address > addresses(const std::string &name, unsigned int port, int af=AF_UNSPEC) const
Returns addresses bound to the given interface.
void load()
Loads or reloads the list.
static bool active()
Returns true if the implementation can raise InterfacesHandler events.
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.
const_iterator end() const
Returns a one-off-the-end iterator.
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.