00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <ptlib.h>
00049 #include <ptlib/sockets.h>
00050
00051 #ifndef P_NATMETHOD
00052 #define P_NATMETHOD
00053
00061 class PNatMethod : public PObject
00062 {
00063 PCLASSINFO(PNatMethod,PObject);
00064
00065 public:
00066
00071 PNatMethod();
00072
00075 ~PNatMethod();
00077
00080
00084 virtual BOOL GetExternalAddress(
00085 PIPSocket::Address & externalAddress,
00086 const PTimeInterval & maxAge = 1000
00087 ) =0;
00088
00092 virtual BOOL CreateSocketPair(
00093 PUDPSocket * & socket1,
00094 PUDPSocket * & socket2
00095 ) =0;
00096
00104 virtual BOOL IsAvailable() { return FALSE; };
00105
00116 virtual void SetPortRanges(
00117 WORD portBase,
00118 WORD portMax = 0,
00119 WORD portPairBase = 0,
00120 WORD portPairMax = 0
00121 );
00123
00124 protected:
00125 struct PortInfo {
00126 PMutex mutex;
00127 WORD basePort;
00128 WORD maxPort;
00129 WORD currentPort;
00130 } singlePortInfo, pairedPortInfo;
00131
00132 };
00133
00135
00136 PLIST(PNatList, PNatMethod);
00137
00139
00145 class PNatStrategy : public PObject
00146 {
00147 PCLASSINFO(PNatStrategy,PObject);
00148
00149 public :
00150
00155 PNatStrategy();
00156
00159 ~PNatStrategy();
00161
00169 void AddMethod(PNatMethod * method);
00170
00176 PNatMethod * GetMethod();
00177
00188 void SetPortRanges(
00189 WORD portBase,
00190 WORD portMax = 0,
00191 WORD portPairBase = 0,
00192 WORD portPairMax = 0
00193 );
00195
00196 private:
00197 PNatList natlist;
00198 };
00199
00200 #endif