52 class PNatMethod :
public PObject
60 eComponent_Unknown = 255,
134 PNatMethod(
unsigned priority);
158 static PNatMethod * Create(
160 PPluginManager * pluginMgr = NULL
165 static PString GetNatTypeString(
175 virtual PString GetFriendlyName()
const;
180 virtual void Activate(
bool active);
185 virtual bool IsAvailable(
192 virtual PString GetServer()
const = 0;
196 bool GetServerAddress(
200 bool GetServerAddress(
208 __inline NatTypes GetNatType(
212 __inline NatTypes GetNatType()
const {
return m_natType; }
219 ) {
return GetNatTypeString(GetNatType(force)); }
221 PString GetNatTypeName()
const {
return GetNatTypeString(GetNatType()); }
226 virtual bool SetServer(
const PString & server);
230 virtual void SetCredentials(
240 bool GetExternalAddress(
244 bool GetExternalAddress(
250 virtual bool GetInterfaceAddress(
266 virtual void Close() { }
286 Component component = eComponent_Unknown
302 virtual bool CreateSocketPair(
319 virtual RTPSupportTypes GetRTPSupport(
333 virtual void SetPortRanges(
336 WORD portPairBase = 0,
341 bool IsActive()
const {
return m_active; }
342 unsigned GetPriority()
const {
return m_priority; }
345 virtual PNATUDPSocket * InternalCreateSocket(Component component,
PObject * context) = 0;
346 virtual void InternalUpdate(
bool externalAddressOnly) = 0;
354 PNatMethod::NatTypes m_natType;
364 friend class PNatMethods;
370 class PNatCandidate :
public PObject
383 Types type = EndTypes,
384 PNatMethod::Component component = PNatMethod::eComponent_Unknown,
385 const char * foundation = NULL,
386 unsigned priority = 1,
387 const char * protocol =
"udp"
391 virtual void PrintOn(ostream & strm)
const;
394 PNatMethod::Component m_component;
398 unsigned m_networkCost;
399 unsigned m_networkId;
418 PNatMethod::Component component
422 virtual const char * GetNatName()
const {
return "NAT"; }
424 virtual void GetCandidateInfo(PNatCandidate & candidate);
427 PString GetBaseAddress()
const;
430 PNatMethod::Component GetComponent()
const
431 {
return m_component; }
436 PNatMethod::Component m_component;
461 class PNatMethod_Fixed :
public PNatMethod
465 enum { DefaultPriority = 50 };
466 PNatMethod_Fixed(
unsigned priority = DefaultPriority);
468 static const char * MethodName();
471 virtual PString GetServer()
const;
472 virtual bool SetServer(
const PString & str);
475 virtual void Close();
478 class Socket :
public PNATUDPSocket
483 PNatMethod::Component component,
492 virtual PNATUDPSocket * InternalCreateSocket(Component component,
PObject * context);
493 virtual void InternalUpdate(
bool);
506 class PNatMethod_AWS :
public PNatMethod_Fixed
510 PNatMethod_AWS(
unsigned priority = DefaultPriority);
512 static const char * MethodName();
515 virtual PString GetServer()
const;
516 virtual bool SetServer(
const PString & str);
520 void InternalUpdate(
bool);
538 bool loadFromFactory =
false,
539 PPluginManager * pluginMgr = NULL
547 void LoadAll(PPluginManager * pluginMgr = NULL);
552 virtual PNatMethod * GetMethod(
560 virtual PNatMethod * GetMethodByName(
566 virtual bool RemoveMethod(
572 virtual bool SetMethodPriority(
579 virtual bool IsLocalAddress(
596 WORD portPairBase = 0,
602 PNatMethods & GetNATList() {
return *
this; }
606 typedef PNatMethods PNatList;
607 typedef PNatMethods PNatStrategy;
618 #define PCREATE_NAT_PLUGIN(name, friendlyName) \
619 PCREATE_PLUGIN(name, PNatMethod, PNatMethod_##name, PPlugin_PNatMethod, \
620 virtual const char * GetFriendlyName() const { return friendlyName; } \
624 #define P_NAT_PARAM(...) ,__VA_ARGS__
637 #define P_NAT_PARAM(...)
641 #endif // PTLIB_PNAT_H
#define PMaxTimeInterval
Definition: timeint.h:31
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
This class defines an absolute time and date.
Definition: ptime.h:49
A socket channel that uses the UDP transport on the Internet Protocol.
Definition: udpsock.h:42
#define PPLUGIN_STATIC_LOAD(serviceName, serviceType)
Definition: plugin.h:123
This class is a variation of a string that ignores case.
Definition: pstring.h:2012
virtual PString GetName() const
Get the platform and I/O channel type name of the channel.
A class describing an IP address and port number combination.
Definition: ipsock.h:278
PCREATE_PLUGIN_SERVICE(PLDAPSchema)
This template class maps the PAbstractList to a specific object type.
Definition: lists.h:322
#define PDECLARE_MUTEX(...)
Definition: mutex.h:200
#define P_REMOVE_VIRTUAL(type, fn, ret)
Definition: object.h:146
#define P_DECLARE_ENUM(name, first,...)
This declares a standard enumeration (enum) of symbols with ++ and – operators.
Definition: object.h:248
bool PBoolean
Definition: object.h:174
#define P_DECLARE_STREAMABLE_ENUM(name, first,...)
This declares a standard enumeration using P_DECLARE_ENUM() and adds the text names so can be streame...
Definition: object.h:326
The character string class.
Definition: pstring.h:108
virtual Comparison Compare(const PObject &obj) const
Compare the two objects and return their relative rank.
A class describing an IP address.
Definition: ipsock.h:59
Class for handling a range of ports for local binding.
Definition: ipsock.h:412
This template class maps the PAbstractSortedList to a specific object type.
Definition: lists.h:964
static const PIPSocket::Address & GetDefaultIpAny()
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
virtual void PrintOn(ostream &strm) const
Output the contents of the object to the stream.