psockbun.h
Go to the documentation of this file.
/*
* psockbun.h
*
* Socket and interface bundle code
*
* Portable Windows Library
*
* Copyright (C) 2007 Post Increment
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Post Increment
*
* Contributor(s): ______________________________________.
*
* $Revision: 28152 $
* $Author: rjongbloed $
* $Date: 2012-08-06 22:03:48 -0500 (Mon, 06 Aug 2012) $
*/
#ifndef PTLIB_PSOCKBUN_H
#define PTLIB_PSOCKBUN_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include <ptlib.h>
#include <ptlib/ipsock.h>
#include <ptlib/sockets.h>
#include <ptlib/safecoll.h>
#include <list>
class PNatMethod;
class PInterfaceMonitorClient;
class PInterfaceFilter;
#define PINTERFACE_MONITOR_FACTORY_NAME "InterfaceMonitor"
class PInterfaceMonitor : public PProcessStartup
{
PCLASSINFO(PInterfaceMonitor, PProcessStartup);
public:
enum {
DefaultRefreshInterval = 60000
};
PInterfaceMonitor(
unsigned refreshInterval = DefaultRefreshInterval,
bool runMonitorThread = true
);
virtual ~PInterfaceMonitor();
PFACTORY_GET_SINGLETON(PProcessStartupFactory, PInterfaceMonitor);
void SetRefreshInterval (unsigned refresh);
void SetRunMonitorThread (bool runMonitorThread);
void Start();
void Stop();
typedef PIPSocket::InterfaceEntry InterfaceEntry;
PStringArray GetInterfaces(
bool includeLoopBack = false,
const PIPSocket::Address & destination = PIPSocket::GetDefaultIpAny()
);
bool IsValidBindingForDestination(
const PIPSocket::Address & binding,
const PIPSocket::Address & destination
);
bool GetInterfaceInfo(
const PString & iface,
InterfaceEntry & info
) const;
static bool IsMatchingInterface(
const PString & iface,
const InterfaceEntry & entry
);
void SetInterfaceFilter(PInterfaceFilter * filter);
bool HasInterfaceFilter() const { return m_interfaceFilter != NULL; }
virtual void RefreshInterfaceList();
void OnRemoveNatMethod(const PNatMethod * natMethod);
protected:
virtual void OnShutdown();
void UpdateThreadMain();
void AddClient(PInterfaceMonitorClient *);
void RemoveClient(PInterfaceMonitorClient *);
virtual void OnInterfacesChanged(const PIPSocket::InterfaceTable & addedInterfaces, const PIPSocket::InterfaceTable & removedInterfaces);
typedef PSmartPtr<PInterfaceMonitorClient> ClientPtr;
typedef std::list<PInterfaceMonitorClient *> ClientList_T;
ClientList_T m_clients;
PMutex m_clientsMutex;
PIPSocket::InterfaceTable m_interfaces;
PMutex m_interfacesMutex;
bool m_runMonitorThread;
PTimeInterval m_refreshInterval;
PMutex m_threadMutex;
PThread * m_updateThread;
PInterfaceFilter * m_interfaceFilter;
PIPSocket::RouteTableDetector * m_changedDetector;
friend class PInterfaceMonitorClient;
};
class PInterfaceMonitorClient : public PSafeObject
{
PCLASSINFO(PInterfaceMonitorClient, PSafeObject);
public:
enum {
DefaultPriority = 50,
};
PInterfaceMonitorClient(PINDEX priority = DefaultPriority);
~PInterfaceMonitorClient();
typedef PIPSocket::InterfaceEntry InterfaceEntry;
virtual PStringArray GetInterfaces(
bool includeLoopBack = false,
const PIPSocket::Address & destination = PIPSocket::GetDefaultIpAny()
);
virtual PBoolean GetInterfaceInfo(
const PString & iface,
InterfaceEntry & info
) const;
PINDEX GetPriority() const { return priority; }
protected:
virtual void OnAddInterface(const InterfaceEntry & entry) = 0;
virtual void OnRemoveInterface(const InterfaceEntry & entry) = 0;
virtual void OnRemoveNatMethod(const PNatMethod * /*natMethod*/) { }
PINDEX priority;
friend class PInterfaceMonitor;
};
class PInterfaceFilter : public PObject {
PCLASSINFO(PInterfaceFilter, PObject);
public:
virtual PIPSocket::InterfaceTable FilterInterfaces(const PIPSocket::Address & destination,
PIPSocket::InterfaceTable & interfaces) const = 0;
};
class PMonitoredSockets : public PInterfaceMonitorClient
{
PCLASSINFO(PMonitoredSockets, PInterfaceMonitorClient);
protected:
PMonitoredSockets(
bool reuseAddr,
PNatMethod * natMethod
);
public:
virtual PBoolean Open(
WORD port
) = 0;
PBoolean IsOpen() const { return opened; }
virtual PBoolean Close() = 0;
WORD GetPort() const { return localPort; }
virtual PBoolean GetAddress(
const PString & iface,
PIPSocket::Address & address,
WORD & port,
PBoolean usingNAT
) const = 0;
virtual PChannel::Errors WriteToBundle(
const void * buffer,
PINDEX length,
const PIPSocket::Address & addr,
WORD port,
const PString & iface,
PINDEX & lastWriteCount
) = 0;
virtual PChannel::Errors ReadFromBundle(
void * buffer,
PINDEX length,
PIPSocket::Address & addr,
WORD & port,
PString & iface,
PINDEX & lastReadCount,
const PTimeInterval & timeout
) = 0;
void SetNatMethod(
PNatMethod * method
) { natMethod = method; }
// Get the current NAT method, eg STUN client pointer
PNatMethod * GetNatMethod() const { return natMethod; }
static PMonitoredSockets * Create(
const PString & iface,
bool reuseAddr = false,
PNatMethod * natMethod = NULL
);
protected:
virtual void OnRemoveNatMethod(
const PNatMethod * natMethod
);
struct SocketInfo {
SocketInfo()
: socket(NULL)
, inUse(false)
{ }
PUDPSocket * socket;
bool inUse;
};
bool CreateSocket(
SocketInfo & info,
const PIPSocket::Address & binding
);
bool DestroySocket(SocketInfo & info);
bool GetSocketAddress(
const SocketInfo & info,
PIPSocket::Address & address,
WORD & port,
bool usingNAT
) const;
PChannel::Errors WriteToSocket(
const void * buf,
PINDEX len,
const PIPSocket::Address & addr,
WORD port,
const SocketInfo & info,
PINDEX & lastWriteCount
);
PChannel::Errors ReadFromSocket(
SocketInfo & info,
void * buf,
PINDEX len,
PIPSocket::Address & addr,
WORD & port,
PINDEX & lastReadCount,
const PTimeInterval & timeout
);
PChannel::Errors ReadFromSocket(
PSocket::SelectList & readers,
PUDPSocket * & socket,
void * buf,
PINDEX len,
PIPSocket::Address & addr,
WORD & port,
PINDEX & lastReadCount,
const PTimeInterval & timeout
);
WORD localPort;
bool reuseAddress;
PNatMethod * natMethod;
bool opened;
PUDPSocket interfaceAddedSignal;
};
typedef PSafePtr<PMonitoredSockets> PMonitoredSocketsPtr;
class PMonitoredSocketChannel : public PChannel
{
PCLASSINFO(PMonitoredSocketChannel, PChannel);
public:
PMonitoredSocketChannel(
const PMonitoredSocketsPtr & sockets,
bool shared
);
virtual PBoolean IsOpen() const;
virtual PBoolean Close();
virtual PBoolean Read(
void * buffer,
PINDEX length
);
virtual PBoolean Write(
const void * buffer,
PINDEX length
);
void SetInterface(
const PString & iface
);
PString GetInterface();
bool GetLocal(
PIPSocket::Address & address,
WORD & port,
bool usingNAT
);
void SetRemote(
const PIPSocket::Address & address,
WORD port
);
void SetRemote(
const PString & hostAndPort
);
void GetRemote(
PIPSocket::Address & addr,
WORD & port
) const { addr = remoteAddress; port = remotePort; }
void SetPromiscuous(
bool flag
) { promiscuousReads = flag; }
bool GetPromiscuous() { return promiscuousReads; }
void GetLastReceived(
PIPSocket::Address & addr,
WORD & port
) const { addr = lastReceivedAddress; port = lastReceivedPort; }
PString GetLastReceivedInterface() const { return lastReceivedInterface; }
const PMonitoredSocketsPtr & GetMonitoredSockets() const { return socketBundle; }
protected:
PMonitoredSocketsPtr socketBundle;
bool sharedBundle;
PString currentInterface;
bool promiscuousReads;
PIPSocket::Address remoteAddress;
bool closing;
WORD remotePort;
PIPSocket::Address lastReceivedAddress;
WORD lastReceivedPort;
PString lastReceivedInterface;
PMutex mutex;
};
class PMonitoredSocketBundle : public PMonitoredSockets
{
PCLASSINFO(PMonitoredSocketBundle, PMonitoredSockets);
public:
PMonitoredSocketBundle(
bool reuseAddr = false,
PNatMethod * natMethod = NULL
);
~PMonitoredSocketBundle();
virtual PStringArray GetInterfaces(
bool includeLoopBack = false,
const PIPSocket::Address & destination = PIPSocket::GetDefaultIpAny()
);
virtual PBoolean Open(
WORD port
);
virtual PBoolean Close();
virtual PBoolean GetAddress(
const PString & iface,
PIPSocket::Address & address,
WORD & port,
PBoolean usingNAT
) const;
virtual PChannel::Errors WriteToBundle(
const void * buf,
PINDEX len,
const PIPSocket::Address & addr,
WORD port,
const PString & iface,
PINDEX & lastWriteCount
);
virtual PChannel::Errors ReadFromBundle(
void * buf,
PINDEX len,
PIPSocket::Address & addr,
WORD & port,
PString & iface,
PINDEX & lastReadCount,
const PTimeInterval & timeout
);
protected:
virtual void OnAddInterface(const InterfaceEntry & entry);
virtual void OnRemoveInterface(const InterfaceEntry & entry);
typedef std::map<std::string, SocketInfo> SocketInfoMap_T;
void OpenSocket(const PString & iface);
void CloseSocket(SocketInfoMap_T::iterator iterSocket);
SocketInfoMap_T socketInfoMap;
};
class PSingleMonitoredSocket : public PMonitoredSockets
{
PCLASSINFO(PSingleMonitoredSocket, PMonitoredSockets);
public:
PSingleMonitoredSocket(
const PString & theInterface,
bool reuseAddr = false,
PNatMethod * natMethod = NULL
);
~PSingleMonitoredSocket();
virtual PStringArray GetInterfaces(
bool includeLoopBack = false,
const PIPSocket::Address & destination = PIPSocket::GetDefaultIpAny()
);
virtual PBoolean Open(
WORD port
);
virtual PBoolean Close();
virtual PBoolean GetAddress(
const PString & iface,
PIPSocket::Address & address,
WORD & port,
PBoolean usingNAT
) const;
virtual PChannel::Errors WriteToBundle(
const void * buf,
PINDEX len,
const PIPSocket::Address & addr,
WORD port,
const PString & iface,
PINDEX & lastWriteCount
);
virtual PChannel::Errors ReadFromBundle(
void * buf,
PINDEX len,
PIPSocket::Address & addr,
WORD & port,
PString & iface,
PINDEX & lastReadCount,
const PTimeInterval & timeout
);
protected:
virtual void OnAddInterface(const InterfaceEntry & entry);
virtual void OnRemoveInterface(const InterfaceEntry & entry);
bool IsInterface(const PString & iface) const;
PString theInterface;
InterfaceEntry theEntry;
SocketInfo theInfo;
};
#endif // PTLIB_PSOCKBUN_H
// End Of File ///////////////////////////////////////////////////////////////
PIPSocket::RouteTableDetector
Class for detector of Route Table changes.
Definition: ipsock.h:620
PMonitoredSockets::GetPort
WORD GetPort() const
Return the local port number being used by the socket(s)
Definition: psockbun.h:285
PMonitoredSocketChannel::SetInterface
void SetInterface(const PString &iface)
Set the interface descriptor to be used for all reads/writes to this channel.
PMonitoredSockets::SocketInfo::inUse
bool inUse
Definition: psockbun.h:355
PMonitoredSocketBundle::WriteToBundle
virtual PChannel::Errors WriteToBundle(const void *buf, PINDEX len, const PIPSocket::Address &addr, WORD port, const PString &iface, PINDEX &lastWriteCount)
Write to the remote address/port using the socket(s) available.
PSingleMonitoredSocket::IsInterface
bool IsInterface(const PString &iface) const
PInterfaceMonitor::GetInterfaceInfo
bool GetInterfaceInfo(const PString &iface, InterfaceEntry &info) const
Return information about an active interface given the descriptor string.
PSingleMonitoredSocket::GetAddress
virtual PBoolean GetAddress(const PString &iface, PIPSocket::Address &address, WORD &port, PBoolean usingNAT) const
Get the local address for the given interface.
PMonitoredSocketChannel::Read
virtual PBoolean Read(void *buffer, PINDEX length)
Override of PChannel functions to allow connectionless reads.
PMonitoredSocketBundle::~PMonitoredSocketBundle
~PMonitoredSocketBundle()
PMonitoredSocketBundle::OnRemoveInterface
virtual void OnRemoveInterface(const InterfaceEntry &entry)
Call back function for when an interface has been removed from the system.
PMonitoredSocketChannel::lastReceivedAddress
PIPSocket::Address lastReceivedAddress
Definition: psockbun.h:516
PMonitoredSocketBundle::CloseSocket
void CloseSocket(SocketInfoMap_T::iterator iterSocket)
PInterfaceMonitor::UpdateThreadMain
void UpdateThreadMain()
PMonitoredSockets::ReadFromBundle
virtual PChannel::Errors ReadFromBundle(void *buffer, PINDEX length, PIPSocket::Address &addr, WORD &port, PString &iface, PINDEX &lastReadCount, const PTimeInterval &timeout)=0
Read fram a remote address/port using the socket(s) available.
PSingleMonitoredSocket::GetInterfaces
virtual PStringArray GetInterfaces(bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
Get an array of all current interface descriptors, possibly including the loopback (127...
PMonitoredSocketBundle::socketInfoMap
SocketInfoMap_T socketInfoMap
Definition: psockbun.h:613
PMonitoredSockets::reuseAddress
bool reuseAddress
Definition: psockbun.h:399
PSingleMonitoredSocket::Open
virtual PBoolean Open(WORD port)
Open the socket(s) using the specified port.
PMonitoredSockets::GetAddress
virtual PBoolean GetAddress(const PString &iface, PIPSocket::Address &address, WORD &port, PBoolean usingNAT) const =0
Get the local address for the given interface.
PInterfaceMonitorClient::priority
PINDEX priority
Definition: psockbun.h:234
PInterfaceMonitor::ClientList_T
std::list< PInterfaceMonitorClient * > ClientList_T
Definition: psockbun.h:159
PTimeInterval
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PInterfaceMonitor::PInterfaceMonitor
PInterfaceMonitor(unsigned refreshInterval=DefaultRefreshInterval, bool runMonitorThread=true)
PMonitoredSocketChannel::promiscuousReads
bool promiscuousReads
Definition: psockbun.h:512
PSingleMonitoredSocket::ReadFromBundle
virtual PChannel::Errors ReadFromBundle(void *buf, PINDEX len, PIPSocket::Address &addr, WORD &port, PString &iface, PINDEX &lastReadCount, const PTimeInterval &timeout)
Read fram a remote address/port using the socket(s) available.
PMonitoredSocketBundle::Close
virtual PBoolean Close()
Close all socket(s)
PSafePtr< PMonitoredSockets >
PInterfaceMonitor::IsMatchingInterface
static bool IsMatchingInterface(const PString &iface, const InterfaceEntry &entry)
Returns whether the descriptor string equals the interface entry.
PMonitoredSocketChannel::closing
bool closing
Definition: psockbun.h:514
PMonitoredSockets::IsOpen
PBoolean IsOpen() const
Indicate if the socket(s) are open and ready for reads/writes.
Definition: psockbun.h:279
PMonitoredSockets::OnRemoveNatMethod
virtual void OnRemoveNatMethod(const PNatMethod *natMethod)
Called when a NAT method is about to be destroyed.
PInterfaceMonitorClient::InterfaceEntry
PIPSocket::InterfaceEntry InterfaceEntry
Definition: psockbun.h:195
PMonitoredSockets::Close
virtual PBoolean Close()=0
Close all socket(s)
PMonitoredSockets
This is a base class for UDP socket(s) that are monitored for interface changes.
Definition: psockbun.h:258
PUDPSocket
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:47
PIPSocket::InterfaceEntry
Describe an interface table entry.
Definition: ipsock.h:642
PInterfaceMonitor::~PInterfaceMonitor
virtual ~PInterfaceMonitor()
PInterfaceMonitor::RefreshInterfaceList
virtual void RefreshInterfaceList()
PInterfaceMonitor::OnInterfacesChanged
virtual void OnInterfacesChanged(const PIPSocket::InterfaceTable &addedInterfaces, const PIPSocket::InterfaceTable &removedInterfaces)
PMonitoredSocketChannel::Close
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PInterfaceMonitor::m_threadMutex
PMutex m_threadMutex
Definition: psockbun.h:168
PMonitoredSocketChannel::SetRemote
void SetRemote(const PIPSocket::Address &address, WORD port)
Set the remote address/port for all Write() functions.
PInterfaceMonitorClient::OnRemoveNatMethod
virtual void OnRemoveNatMethod(const PNatMethod *)
Called when a NAT method is about to be destroyed.
Definition: psockbun.h:232
PMonitoredSockets::SocketInfo
Definition: psockbun.h:349
PSocket::SelectList
List of sockets used for Select() function.
Definition: socket.h:311
PMonitoredSocketBundle::OnAddInterface
virtual void OnAddInterface(const InterfaceEntry &entry)
Call back function for when an interface has been added to the system.
PInterfaceMonitor::IsValidBindingForDestination
bool IsValidBindingForDestination(const PIPSocket::Address &binding, const PIPSocket::Address &destination)
Returns whether destination is reachable through binding or not.
PMonitoredSocketBundle::ReadFromBundle
virtual PChannel::Errors ReadFromBundle(void *buf, PINDEX len, PIPSocket::Address &addr, WORD &port, PString &iface, PINDEX &lastReadCount, const PTimeInterval &timeout)
Read fram a remote address/port using the socket(s) available.
PMonitoredSockets::CreateSocket
bool CreateSocket(SocketInfo &info, const PIPSocket::Address &binding)
PMonitoredSocketBundle::Open
virtual PBoolean Open(WORD port)
Open the socket(s) using the specified port.
PMonitoredSocketChannel::remotePort
WORD remotePort
Definition: psockbun.h:515
PInterfaceMonitor::InterfaceEntry
PIPSocket::InterfaceEntry InterfaceEntry
Definition: psockbun.h:97
PStringArray
This is an array collection class of PString objects.
Definition: pstring.h:2024
ipsock.h
PInterfaceFilter
Definition: psockbun.h:242
PMonitoredSocketChannel::lastReceivedInterface
PString lastReceivedInterface
Definition: psockbun.h:518
PInterfaceMonitor::m_clients
ClientList_T m_clients
Definition: psockbun.h:160
PMonitoredSocketsPtr
PSafePtr< PMonitoredSockets > PMonitoredSocketsPtr
Definition: psockbun.h:406
PMonitoredSocketChannel::Write
virtual PBoolean Write(const void *buffer, PINDEX length)
Override of PChannel functions to allow connectionless writes.
PInterfaceMonitor::ClientPtr
PSmartPtr< PInterfaceMonitorClient > ClientPtr
Definition: psockbun.h:157
PMonitoredSockets::Create
static PMonitoredSockets * Create(const PString &iface, bool reuseAddr=false, PNatMethod *natMethod=NULL)
Create a new monitored socket instance based on the interface descriptor.
PChannel::Errors
Errors
Normalised error codes.
Definition: channel.h:529
PMonitoredSocketChannel::GetLocal
bool GetLocal(PIPSocket::Address &address, WORD &port, bool usingNAT)
Get the local IP address and port for the currently selected interface.
PBoolean
BOOL PBoolean
Definition: object.h:102
PMonitoredSocketChannel::GetLastReceivedInterface
PString GetLastReceivedInterface() const
Get the interface the last received UDP data was recieved on.
Definition: psockbun.h:502
PInterfaceMonitor::SetRunMonitorThread
void SetRunMonitorThread(bool runMonitorThread)
Change whether the monitor thread should run.
PMonitoredSockets::SetNatMethod
void SetNatMethod(PNatMethod *method)
Set the NAT method, eg STUN client pointer.
Definition: psockbun.h:326
PInterfaceMonitorClient::PInterfaceMonitorClient
PInterfaceMonitorClient(PINDEX priority=DefaultPriority)
PMonitoredSocketChannel
This class can be used to access the bundled/monitored UDP sockets using the PChannel API...
Definition: psockbun.h:414
PMonitoredSocketChannel::remoteAddress
PIPSocket::Address remoteAddress
Definition: psockbun.h:513
PMonitoredSocketBundle::GetAddress
virtual PBoolean GetAddress(const PString &iface, PIPSocket::Address &address, WORD &port, PBoolean usingNAT) const
Get the local address for the given interface.
PInterfaceMonitorClient::DefaultPriority
Definition: psockbun.h:190
PSingleMonitoredSocket::WriteToBundle
virtual PChannel::Errors WriteToBundle(const void *buf, PINDEX len, const PIPSocket::Address &addr, WORD port, const PString &iface, PINDEX &lastWriteCount)
Write to the remote address/port using the socket(s) available.
PMonitoredSockets::interfaceAddedSignal
PUDPSocket interfaceAddedSignal
Definition: psockbun.h:403
PNatMethod
PNatMethod Base Network Address Traversal Method class All NAT Traversal Methods are derived off this...
Definition: pnat.h:49
PInterfaceMonitor::OnShutdown
virtual void OnShutdown()
PSingleMonitoredSocket::theInterface
PString theInterface
Definition: psockbun.h:705
PInterfaceMonitorClient::~PInterfaceMonitorClient
~PInterfaceMonitorClient()
PMonitoredSocketChannel::mutex
PMutex mutex
Definition: psockbun.h:519
PMonitoredSocketBundle
This concrete class bundles a set of UDP sockets which are dynamically adjusted as interfaces are add...
Definition: psockbun.h:528
PChannel
Abstract class defining I/O channel semantics.
Definition: channel.h:107
PInterfaceMonitor::DefaultRefreshInterval
Definition: psockbun.h:69
PSafeObject
This class defines a thread-safe object in a collection.
Definition: safecoll.h:119
PInterfaceFilter::FilterInterfaces
virtual PIPSocket::InterfaceTable FilterInterfaces(const PIPSocket::Address &destination, PIPSocket::InterfaceTable &interfaces) const =0
PInterfaceMonitorClient::OnAddInterface
virtual void OnAddInterface(const InterfaceEntry &entry)=0
Call back function for when an interface has been added to the system.
PString
The character string class.
Definition: pstring.h:108
PInterfaceMonitor::OnRemoveNatMethod
void OnRemoveNatMethod(const PNatMethod *natMethod)
PSingleMonitoredSocket::OnAddInterface
virtual void OnAddInterface(const InterfaceEntry &entry)
Call back function for when an interface has been added to the system.
PInterfaceMonitorClient::GetPriority
PINDEX GetPriority() const
Returns the priority of this client.
Definition: psockbun.h:222
PInterfaceMonitorClient
This is a base class for clients of the PInterfaceMonitor singleton object.
Definition: psockbun.h:185
PMonitoredSocketChannel::IsOpen
virtual PBoolean IsOpen() const
Determine if the channel is currently open.
PInterfaceMonitor::m_interfacesMutex
PMutex m_interfacesMutex
Definition: psockbun.h:164
PSingleMonitoredSocket::PSingleMonitoredSocket
PSingleMonitoredSocket(const PString &theInterface, bool reuseAddr=false, PNatMethod *natMethod=NULL)
PSingleMonitoredSocket
This concrete class monitors a single scoket bound to a specific interface or address.
Definition: psockbun.h:623
PInterfaceMonitor
This class is a singleton that will monitor the network interfaces on a machine and update a list aof...
Definition: psockbun.h:64
PMonitoredSocketChannel::currentInterface
PString currentInterface
Definition: psockbun.h:511
PInterfaceMonitor::m_updateThread
PThread * m_updateThread
Definition: psockbun.h:169
PMonitoredSocketChannel::GetMonitoredSockets
const PMonitoredSocketsPtr & GetMonitoredSockets() const
Get the monitored socket bundle being used by this channel.
Definition: psockbun.h:505
PInterfaceMonitorClient::GetInterfaceInfo
virtual PBoolean GetInterfaceInfo(const PString &iface, InterfaceEntry &info) const
Return information about an active interface given the descriptor string.
PMonitoredSockets::ReadFromSocket
PChannel::Errors ReadFromSocket(SocketInfo &info, void *buf, PINDEX len, PIPSocket::Address &addr, WORD &port, PINDEX &lastReadCount, const PTimeInterval &timeout)
PMonitoredSocketBundle::PMonitoredSocketBundle
PMonitoredSocketBundle(bool reuseAddr=false, PNatMethod *natMethod=NULL)
PMonitoredSockets::DestroySocket
bool DestroySocket(SocketInfo &info)
PMonitoredSockets::PMonitoredSockets
PMonitoredSockets(bool reuseAddr, PNatMethod *natMethod)
PMonitoredSocketChannel::PMonitoredSocketChannel
PMonitoredSocketChannel(const PMonitoredSocketsPtr &sockets, bool shared)
Construct a monitored socket bundle channel.
PSmartPtr
This template class creates a type safe version of PSmartPointer.
Definition: smartptr.h:174
PThread
This class defines a thread of execution in the system.
Definition: thread.h:66
PMonitoredSocketBundle::GetInterfaces
virtual PStringArray GetInterfaces(bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
Get an array of all current interface descriptors, possibly including the loopback (127...
PInterfaceMonitor::m_changedDetector
PIPSocket::RouteTableDetector * m_changedDetector
Definition: psockbun.h:172
PIPSocket::GetDefaultIpAny
static PIPSocket::Address GetDefaultIpAny()
PInterfaceMonitor::m_clientsMutex
PMutex m_clientsMutex
Definition: psockbun.h:161
PMonitoredSocketChannel::GetRemote
void GetRemote(PIPSocket::Address &addr, WORD &port) const
Get the current remote address/port for all Write() functions.
Definition: psockbun.h:479
PMonitoredSockets::WriteToSocket
PChannel::Errors WriteToSocket(const void *buf, PINDEX len, const PIPSocket::Address &addr, WORD port, const SocketInfo &info, PINDEX &lastWriteCount)
PInterfaceMonitor::m_refreshInterval
PTimeInterval m_refreshInterval
Definition: psockbun.h:167
PInterfaceMonitor::SetRefreshInterval
void SetRefreshInterval(unsigned refresh)
Change the refresh interval.
PFactory
Template class for generic factories of an abstract class.
Definition: pfactory.h:144
PIPSocket::Address
A class describing an IP address.
Definition: ipsock.h:75
PMonitoredSocketChannel::sharedBundle
bool sharedBundle
Definition: psockbun.h:510
PInterfaceMonitor::GetInterfaces
PStringArray GetInterfaces(bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
Get an array of all current interface descriptors, possibly including the loopback (127...
PInterfaceMonitor::m_interfaces
PIPSocket::InterfaceTable m_interfaces
Definition: psockbun.h:163
PProcessStartup
Definition: pprocess.h:779
PSingleMonitoredSocket::theEntry
InterfaceEntry theEntry
Definition: psockbun.h:706
PInterfaceMonitor::Stop
void Stop()
Stop monitoring network interfaces.
PInterfaceMonitor::PFACTORY_GET_SINGLETON
PFACTORY_GET_SINGLETON(PProcessStartupFactory, PInterfaceMonitor)
Return the singleton interface for the network monitor.
PMonitoredSockets::GetNatMethod
PNatMethod * GetNatMethod() const
Definition: psockbun.h:332
PMonitoredSocketChannel::lastReceivedPort
WORD lastReceivedPort
Definition: psockbun.h:517
PMonitoredSocketChannel::SetPromiscuous
void SetPromiscuous(bool flag)
Set flag for receiving UDP data from any remote address.
Definition: psockbun.h:488
PMonitoredSockets::Open
virtual PBoolean Open(WORD port)=0
Open the socket(s) using the specified port.
sockets.h
PSingleMonitoredSocket::OnRemoveInterface
virtual void OnRemoveInterface(const InterfaceEntry &entry)
Call back function for when an interface has been removed from the system.
PInterfaceMonitor::Start
void Start()
Start monitoring network interfaces.
PMutex
Synonym for PTimedMutex.
PMonitoredSockets::GetSocketAddress
bool GetSocketAddress(const SocketInfo &info, PIPSocket::Address &address, WORD &port, bool usingNAT) const
PMonitoredSockets::opened
bool opened
Definition: psockbun.h:402
PInterfaceMonitor::AddClient
void AddClient(PInterfaceMonitorClient *)
PMonitoredSocketChannel::GetInterface
PString GetInterface()
Get the current interface descriptor being used/.
PMonitoredSocketChannel::GetLastReceived
void GetLastReceived(PIPSocket::Address &addr, WORD &port) const
Get the IP address and port of the last received UDP data.
Definition: psockbun.h:496
PInterfaceMonitor::RemoveClient
void RemoveClient(PInterfaceMonitorClient *)
PInterfaceMonitor::SetInterfaceFilter
void SetInterfaceFilter(PInterfaceFilter *filter)
Sets the monitor's interface filter.
PInterfaceMonitorClient::GetInterfaces
virtual PStringArray GetInterfaces(bool includeLoopBack=false, const PIPSocket::Address &destination=PIPSocket::GetDefaultIpAny())
Get an array of all current interface descriptors, possibly including the loopback (127...
PMonitoredSocketBundle::SocketInfoMap_T
std::map< std::string, SocketInfo > SocketInfoMap_T
Definition: psockbun.h:608
PSingleMonitoredSocket::~PSingleMonitoredSocket
~PSingleMonitoredSocket()
PMonitoredSockets::natMethod
PNatMethod * natMethod
Definition: psockbun.h:400
safecoll.h
PSingleMonitoredSocket::Close
virtual PBoolean Close()
Close all socket(s)
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PMonitoredSocketChannel::GetPromiscuous
bool GetPromiscuous()
Get flag for receiving UDP data from any remote address.
Definition: psockbun.h:493
PMonitoredSockets::WriteToBundle
virtual PChannel::Errors WriteToBundle(const void *buffer, PINDEX length, const PIPSocket::Address &addr, WORD port, const PString &iface, PINDEX &lastWriteCount)=0
Write to the remote address/port using the socket(s) available.
PSingleMonitoredSocket::theInfo
SocketInfo theInfo
Definition: psockbun.h:707
PMonitoredSockets::SocketInfo::SocketInfo
SocketInfo()
Definition: psockbun.h:350
PInterfaceMonitor::m_interfaceFilter
PInterfaceFilter * m_interfaceFilter
Definition: psockbun.h:171
PMonitoredSocketChannel::socketBundle
PMonitoredSocketsPtr socketBundle
Definition: psockbun.h:509
PMonitoredSocketBundle::OpenSocket
void OpenSocket(const PString &iface)
PInterfaceMonitorClient::OnRemoveInterface
virtual void OnRemoveInterface(const InterfaceEntry &entry)=0
Call back function for when an interface has been removed from the system.
PMonitoredSockets::localPort
WORD localPort
Definition: psockbun.h:398
PInterfaceMonitor::m_runMonitorThread
bool m_runMonitorThread
Definition: psockbun.h:166
PMonitoredSockets::SocketInfo::socket
PUDPSocket * socket
Definition: psockbun.h:354
PInterfaceMonitor::HasInterfaceFilter
bool HasInterfaceFilter() const
Definition: psockbun.h:141