#include <psockbun.h>
Inheritance diagram for PInterfaceMonitor:
Public Types | |
enum | { DefaultRefreshInterval = 5000 } |
typedef PIPSocket::InterfaceEntry | InterfaceEntry |
Public Member Functions | |
PInterfaceMonitor (unsigned refreshInterval=DefaultRefreshInterval, PBoolean runMonitorThread=PTrue) | |
virtual | ~PInterfaceMonitor () |
PBoolean | Start () |
Start monitoring network interfaces. | |
void | Stop () |
Stop monitoring network interfaces. | |
PStringArray | GetInterfaces (PBoolean includeLoopBack=PFalse, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny()) |
PBoolean | IsValidBindingForDestination (const PIPSocket::Address &binding, const PIPSocket::Address &destination) |
PBoolean | GetInterfaceInfo (const PString &iface, InterfaceEntry &info) |
void | SetInterfaceFilter (PInterfaceFilter *filter) |
virtual void | RefreshInterfaceList () |
void | OnRemoveSTUNClient (const PSTUNClient *stun) |
Static Public Member Functions | |
static PInterfaceMonitor & | GetInstance () |
Return the singleton interface for the network monitor. | |
static PBoolean | IsMatchingInterface (const PString &iface, const InterfaceEntry &entry) |
Protected Types | |
typedef PSmartPtr< PInterfaceMonitorClient > | ClientPtr |
typedef std::list< PInterfaceMonitorClient * > | ClientList_T |
Protected Member Functions | |
void | UpdateThreadMain () |
void | AddClient (PInterfaceMonitorClient *) |
void | RemoveClient (PInterfaceMonitorClient *) |
virtual void | OnInterfacesChanged (const PIPSocket::InterfaceTable &addedInterfaces, const PIPSocket::InterfaceTable &removedInterfaces) |
Protected Attributes | |
ClientList_T | currentClients |
PIPSocket::InterfaceTable | currentInterfaces |
PBoolean | runMonitorThread |
PTimeInterval | refreshInterval |
PMutex | mutex |
PThread * | updateThread |
PSyncPoint | threadRunning |
PInterfaceFilter * | interfaceFilter |
Friends | |
class | PInterfaceMonitorClient |
A user may override this singleton by creating a derived class and making a static instance of it before any monitor client classes are created. This would typically be done in the users main program.
typedef PSmartPtr<PInterfaceMonitorClient> PInterfaceMonitor::ClientPtr [protected] |
typedef std::list<PInterfaceMonitorClient *> PInterfaceMonitor::ClientList_T [protected] |
PInterfaceMonitor::PInterfaceMonitor | ( | unsigned | refreshInterval = DefaultRefreshInterval , |
|
PBoolean | runMonitorThread = PTrue | |||
) |
virtual PInterfaceMonitor::~PInterfaceMonitor | ( | ) | [virtual] |
static PInterfaceMonitor& PInterfaceMonitor::GetInstance | ( | ) | [static] |
Return the singleton interface for the network monitor.
PBoolean PInterfaceMonitor::Start | ( | ) |
Start monitoring network interfaces.
void PInterfaceMonitor::Stop | ( | ) |
Stop monitoring network interfaces.
PStringArray PInterfaceMonitor::GetInterfaces | ( | PBoolean | includeLoopBack = PFalse , |
|
const PIPSocket::Address & | destination = PIPSocket::GetDefaultIpAny() | |||
) |
Get an array of all current interface descriptors, possibly including the loopback (127.0.0.1) interface. Note the names are of the form ipname, eg "10.0.1.11%3Com 3C90x Ethernet Adapter" or "192.168.0.10%eth0"
destination | Flag for if loopback is to included in list |
PBoolean PInterfaceMonitor::IsValidBindingForDestination | ( | const PIPSocket::Address & | binding, | |
const PIPSocket::Address & | destination | |||
) |
Returns whether destination is reachable through binding or not. The default behaviour returns PTrue unless there is an interface filter installed an the filter does not return 'binding' among it's interfaces.
PBoolean PInterfaceMonitor::GetInterfaceInfo | ( | const PString & | iface, | |
InterfaceEntry & | info | |||
) |
Return information about an active interface given the descriptor string. Note that when searchin the descriptor may be a partial match e.g. "10.0.1.11" or "%eth0" may be used.
info | Interface desciptor name Information on the interface |
static PBoolean PInterfaceMonitor::IsMatchingInterface | ( | const PString & | iface, | |
const InterfaceEntry & | entry | |||
) | [static] |
Returns whether the descriptor string equals the interface entry. Note that when searching the descriptor may be a partial match e.g. "10.0.1.11" or "%eth0" may be used.
entry | Interface descriptor Interface entry |
void PInterfaceMonitor::SetInterfaceFilter | ( | PInterfaceFilter * | filter | ) |
Sets the monitor's interface filter. Note that the monitor instance handles deletion of the filter.
virtual void PInterfaceMonitor::RefreshInterfaceList | ( | ) | [virtual] |
void PInterfaceMonitor::OnRemoveSTUNClient | ( | const PSTUNClient * | stun | ) |
void PInterfaceMonitor::UpdateThreadMain | ( | ) | [protected] |
void PInterfaceMonitor::AddClient | ( | PInterfaceMonitorClient * | ) | [protected] |
void PInterfaceMonitor::RemoveClient | ( | PInterfaceMonitorClient * | ) | [protected] |
virtual void PInterfaceMonitor::OnInterfacesChanged | ( | const PIPSocket::InterfaceTable & | addedInterfaces, | |
const PIPSocket::InterfaceTable & | removedInterfaces | |||
) | [protected, virtual] |
friend class PInterfaceMonitorClient [friend] |
ClientList_T PInterfaceMonitor::currentClients [protected] |
PIPSocket::InterfaceTable PInterfaceMonitor::currentInterfaces [protected] |
PBoolean PInterfaceMonitor::runMonitorThread [protected] |
PTimeInterval PInterfaceMonitor::refreshInterval [protected] |
PMutex PInterfaceMonitor::mutex [protected] |
PThread* PInterfaceMonitor::updateThread [protected] |
PSyncPoint PInterfaceMonitor::threadRunning [protected] |
PInterfaceFilter* PInterfaceMonitor::interfaceFilter [protected] |