37 #include <ptbuildopts.h>
56 class PNatMethod :
public PObject
69 eComponent_Unknown = 255,
158 static PNatMethod * Create(
165 static PString GetNatTypeString(
171 virtual PString GetName()
const = 0;
175 virtual PString GetServer()
const = 0;
179 virtual bool GetServerAddress(
183 virtual bool GetServerAddress(
187 __inline NatTypes GetNatType(
189 ) {
return InternalGetNatType(
false, maxAge); }
191 __inline NatTypes GetNatType(
200 ) {
return GetNatTypeString(GetNatType(force)); }
205 virtual bool SetServer(
const PString & server);
209 virtual void SetCredentials(
217 virtual bool GetExternalAddress(
224 virtual bool GetInterfaceAddress(
236 virtual void Close() { }
255 ) {
return CreateSocket(eComponent_Unknown, socket, binding, localPort); }
256 virtual bool CreateSocket(
276 virtual bool CreateSocketPair(
295 virtual bool CreateSocketPair(
309 virtual bool CreateSocketPairAsync(
320 virtual bool GetSocketPairAsync(
325 void * userData = NULL
331 virtual bool IsAvailable(
338 virtual void Activate(
bool active);
343 virtual void SetAlternateAddresses(
345 void * userData = NULL
358 virtual RTPSupportTypes GetRTPSupport(
372 virtual void SetPortRanges(
375 WORD portPairBase = 0,
381 PortInfo(WORD port = 0)
403 WORD GetRandomPair();
412 virtual NatTypes InternalGetNatType(
bool forced,
const PTimeInterval & maxAge) = 0;
414 PortInfo singlePortInfo, pairedPortInfo;
419 PLIST(PNatList, PNatMethod);
423 class PNatCandidate :
public PObject
430 eType_ServerReflexive,
436 PNatCandidate(
int type, PNatMethod::Component component);
438 virtual PString AsString()
const;
443 PNatMethod::Component m_component;
456 PNatMethod::Component component = PNatMethod::eComponent_Unknown
459 virtual PNatCandidate GetCandidateInfo();
461 virtual PString GetBaseAddress();
464 PNatMethod::Component GetComponent()
const
465 {
return m_component; }
467 void SetComponent(PNatMethod::Component component)
468 { m_component = component; }
473 PNatMethod::Component m_component;
498 class PNatMethod_Fixed :
public PNatMethod
504 static PString GetNatMethodName();
505 virtual PString GetName()
const;
507 virtual PString GetServer()
const;
508 virtual bool SetServer(
const PString & str);
515 virtual NatTypes InternalGetNatType(
bool forced,
const PTimeInterval & maxAge);
529 class PNatStrategy :
public PObject
553 void AddMethod(PNatMethod * method);
566 PNatMethod * GetMethodByName(
const PString & name);
571 bool RemoveMethod(
const PString & meth);
586 WORD portPairBase = 0,
592 PNatList & GetNATList() {
return natlist; };
594 PNatMethod * LoadNatMethod(
const PString & name);
615 virtual bool ValidateDeviceName(
const PString & deviceName,
int )
const {
return SVC::GetNatMethodName() *= deviceName; }
618 #define PCREATE_NAT_PLUGIN(name) \
619 static PNatMethodServiceDescriptor<PNatMethod_##name> PNatMethod_##name##_descriptor; \
620 PCREATE_PLUGIN(name, PNatMethod, &PNatMethod_##name##_descriptor) \
623 #define P_NAT_PARAM(...) ,__VA_ARGS__
636 #define P_NAT_PARAM(...)
640 #endif // PTLIB_PNAT_H