31 #ifndef PTLIB_PSOCKBUN_H 32 #define PTLIB_PSOCKBUN_H 51 #define PINTERFACE_MONITOR_FACTORY_NAME "InterfaceMonitor" 74 bool runMonitorThread =
true 104 bool includeLoopBack =
false,
125 InterfaceEntry & info
134 const InterfaceEntry & entry
155 virtual void OnInterfacesChanged(
const PIPSocket::InterfaceTable & addedInterfaces,
const PIPSocket::InterfaceTable & removedInterfaces);
190 DefaultPriority = 50,
204 bool includeLoopBack =
false,
215 InterfaceEntry & info
226 virtual void OnAddInterface(
const InterfaceEntry & entry) = 0;
229 virtual void OnRemoveInterface(
const InterfaceEntry & entry) = 0;
246 virtual PIPSocket::InterfaceTable FilterInterfaces(
const PIPSocket::Address & destination,
247 PIPSocket::InterfaceTable & interfaces)
const = 0;
306 PINDEX & lastWriteCount
321 PINDEX & lastReadCount,
328 ) { natMethod = method; }
340 bool reuseAddr =
false,
363 bool GetSocketAddress(
376 PINDEX & lastWriteCount
384 PINDEX & lastReadCount,
394 PINDEX & lastReadCount,
422 const PMonitoredSocketsPtr & sockets,
482 )
const { addr = remoteAddress; port = remotePort; }
490 ) { promiscuousReads = flag; }
499 )
const { addr = lastReceivedAddress; port = lastReceivedPort; }
533 bool reuseAddr =
false,
545 bool includeLoopBack =
false,
582 PINDEX & lastWriteCount
597 PINDEX & lastReadCount,
603 virtual void OnAddInterface(
const InterfaceEntry & entry);
606 virtual void OnRemoveInterface(
const InterfaceEntry & entry);
610 void OpenSocket(
const PString & iface);
611 void CloseSocket(SocketInfoMap_T::iterator iterSocket);
629 bool reuseAddr =
false,
639 bool includeLoopBack =
false,
676 PINDEX & lastWriteCount
691 PINDEX & lastReadCount,
698 virtual void OnAddInterface(
const InterfaceEntry & entry);
701 virtual void OnRemoveInterface(
const InterfaceEntry & entry);
703 bool IsInterface(
const PString & iface)
const;
711 #endif // PTLIB_PSOCKBUN_H Class for detector of Route Table changes.
Definition: ipsock.h:620
bool inUse
Definition: psockbun.h:355
friend class PInterfaceMonitorClient
Definition: psockbun.h:174
PIPSocket::Address lastReceivedAddress
Definition: psockbun.h:516
SocketInfoMap_T socketInfoMap
Definition: psockbun.h:613
bool reuseAddress
Definition: psockbun.h:399
PINDEX priority
Definition: psockbun.h:234
std::list< PInterfaceMonitorClient * > ClientList_T
Definition: psockbun.h:159
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PInterfaceMonitor(unsigned refreshInterval=DefaultRefreshInterval, bool runMonitorThread=true)
bool promiscuousReads
Definition: psockbun.h:512
static bool IsMatchingInterface(const PString &iface, const InterfaceEntry &entry)
Returns whether the descriptor string equals the interface entry.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
bool closing
Definition: psockbun.h:514
PIPSocket::InterfaceEntry InterfaceEntry
Definition: psockbun.h:195
This is a base class for UDP socket(s) that are monitored for interface changes.
Definition: psockbun.h:258
void GetLastReceived(PIPSocket::Address &addr, WORD &port) const
Get the IP address and port of the last received UDP data.
Definition: psockbun.h:496
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:47
Describe an interface table entry.
Definition: ipsock.h:642
virtual ~PInterfaceMonitor()
virtual void RefreshInterfaceList()
virtual void OnInterfacesChanged(const PIPSocket::InterfaceTable &addedInterfaces, const PIPSocket::InterfaceTable &removedInterfaces)
PMutex m_threadMutex
Definition: psockbun.h:168
void GetRemote(PIPSocket::Address &addr, WORD &port) const
Get the current remote address/port for all Write() functions.
Definition: psockbun.h:479
PINDEX GetPriority() const
Returns the priority of this client.
Definition: psockbun.h:222
virtual void OnRemoveNatMethod(const PNatMethod *)
Called when a NAT method is about to be destroyed.
Definition: psockbun.h:232
Definition: psockbun.h:349
List of sockets used for Select() function.
Definition: socket.h:311
bool IsValidBindingForDestination(const PIPSocket::Address &binding, const PIPSocket::Address &destination)
Returns whether destination is reachable through binding or not.
WORD remotePort
Definition: psockbun.h:515
PIPSocket::InterfaceEntry InterfaceEntry
Definition: psockbun.h:97
This is an array collection class of PString objects.
Definition: pstring.h:2024
Definition: psockbun.h:242
PString lastReceivedInterface
Definition: psockbun.h:518
ClientList_T m_clients
Definition: psockbun.h:160
PSafePtr< PMonitoredSockets > PMonitoredSocketsPtr
Definition: psockbun.h:406
PSmartPtr< PInterfaceMonitorClient > ClientPtr
Definition: psockbun.h:157
Errors
Normalised error codes.
Definition: channel.h:529
BOOL PBoolean
Definition: object.h:102
PNatMethod * GetNatMethod() const
Definition: psockbun.h:332
void SetRunMonitorThread(bool runMonitorThread)
Change whether the monitor thread should run.
void SetNatMethod(PNatMethod *method)
Set the NAT method, eg STUN client pointer.
Definition: psockbun.h:326
This class can be used to access the bundled/monitored UDP sockets using the PChannel API...
Definition: psockbun.h:414
PIPSocket::Address remoteAddress
Definition: psockbun.h:513
PUDPSocket interfaceAddedSignal
Definition: psockbun.h:403
PNatMethod Base Network Address Traversal Method class All NAT Traversal Methods are derived off this...
Definition: pnat.h:49
virtual void OnShutdown()
PBoolean IsOpen() const
Indicate if the socket(s) are open and ready for reads/writes.
Definition: psockbun.h:279
PString theInterface
Definition: psockbun.h:705
PMutex mutex
Definition: psockbun.h:519
This concrete class bundles a set of UDP sockets which are dynamically adjusted as interfaces are add...
Definition: psockbun.h:528
Abstract class defining I/O channel semantics.
Definition: channel.h:107
Definition: psockbun.h:69
This class defines a thread-safe object in a collection.
Definition: safecoll.h:119
bool GetInterfaceInfo(const PString &iface, InterfaceEntry &info) const
Return information about an active interface given the descriptor string.
The character string class.
Definition: pstring.h:108
void OnRemoveNatMethod(const PNatMethod *natMethod)
This is a base class for clients of the PInterfaceMonitor singleton object.
Definition: psockbun.h:185
PMutex m_interfacesMutex
Definition: psockbun.h:164
This concrete class monitors a single scoket bound to a specific interface or address.
Definition: psockbun.h:623
This class is a singleton that will monitor the network interfaces on a machine and update a list aof...
Definition: psockbun.h:64
PString currentInterface
Definition: psockbun.h:511
PThread * m_updateThread
Definition: psockbun.h:169
WORD GetPort() const
Return the local port number being used by the socket(s)
Definition: psockbun.h:285
PString GetLastReceivedInterface() const
Get the interface the last received UDP data was recieved on.
Definition: psockbun.h:502
This template class creates a type safe version of PSmartPointer.
Definition: smartptr.h:174
This class defines a thread of execution in the system.
Definition: thread.h:66
PIPSocket::RouteTableDetector * m_changedDetector
Definition: psockbun.h:172
static PIPSocket::Address GetDefaultIpAny()
PMutex m_clientsMutex
Definition: psockbun.h:161
bool HasInterfaceFilter() const
Definition: psockbun.h:141
PTimeInterval m_refreshInterval
Definition: psockbun.h:167
void SetRefreshInterval(unsigned refresh)
Change the refresh interval.
Template class for generic factories of an abstract class.
Definition: pfactory.h:144
A class describing an IP address.
Definition: ipsock.h:75
bool sharedBundle
Definition: psockbun.h:510
PStringArray GetInterfaces(bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
Get an array of all current interface descriptors, possibly including the loopback (127...
PIPSocket::InterfaceTable m_interfaces
Definition: psockbun.h:163
Definition: pprocess.h:779
InterfaceEntry theEntry
Definition: psockbun.h:706
void Stop()
Stop monitoring network interfaces.
PFACTORY_GET_SINGLETON(PProcessStartupFactory, PInterfaceMonitor)
Return the singleton interface for the network monitor.
WORD lastReceivedPort
Definition: psockbun.h:517
void SetPromiscuous(bool flag)
Set flag for receiving UDP data from any remote address.
Definition: psockbun.h:488
void Start()
Start monitoring network interfaces.
bool opened
Definition: psockbun.h:402
void AddClient(PInterfaceMonitorClient *)
void RemoveClient(PInterfaceMonitorClient *)
void SetInterfaceFilter(PInterfaceFilter *filter)
Sets the monitor's interface filter.
std::map< std::string, SocketInfo > SocketInfoMap_T
Definition: psockbun.h:608
PNatMethod * natMethod
Definition: psockbun.h:400
const PMonitoredSocketsPtr & GetMonitoredSockets() const
Get the monitored socket bundle being used by this channel.
Definition: psockbun.h:505
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
bool GetPromiscuous()
Get flag for receiving UDP data from any remote address.
Definition: psockbun.h:493
SocketInfo theInfo
Definition: psockbun.h:707
SocketInfo()
Definition: psockbun.h:350
PInterfaceFilter * m_interfaceFilter
Definition: psockbun.h:171
PMonitoredSocketsPtr socketBundle
Definition: psockbun.h:509
WORD localPort
Definition: psockbun.h:398
bool m_runMonitorThread
Definition: psockbun.h:166
PUDPSocket * socket
Definition: psockbun.h:354