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 #ifndef H_H460_Featurestd23
00040 #define H_H460_Featurestd23
00041
00042
00043 #include <h460/h4601.h>
00044 #include <ptlib/plugin.h>
00045 #include <ptclib/pstun.h>
00046
00047 #if _MSC_VER
00048 #pragma once
00049 #endif
00050
00051 class H323EndPoint;
00052 class H460_FeatureStd23;
00053 class PNatMethod_H46024 : public PSTUNClient, public PThread
00054 {
00055 PCLASSINFO(PNatMethod_H46024, PNatMethod);
00056
00057 public:
00058 PNatMethod_H46024();
00059
00060 ~PNatMethod_H46024();
00061
00062 static PString GetNatMethodName();
00063 virtual PString GetName() const;
00064
00065
00066 void Start(const PString & server,H460_FeatureStd23 * _feat);
00067
00068
00069 void Main();
00070
00071
00072 virtual bool IsAvailable(
00073 const PIPSocket::Address & binding = PIPSocket::GetDefaultIpAny()
00074 );
00075
00076
00077 virtual PBoolean CreateSocketPair(
00078 PUDPSocket * & socket1,
00079 PUDPSocket * & socket2,
00080 const PIPSocket::Address & binding = PIPSocket::GetDefaultIpAny()
00081 );
00082
00083
00084 void SetAvailable();
00085
00086
00087 virtual void Activate(bool act);
00088
00089
00090 PSTUNClient::NatTypes GetNATType();
00091
00092 protected:
00093
00094 PSTUNClient::NatTypes NATTest();
00095
00096 private:
00097 bool isActive;
00098 bool isAvailable;
00099 PSTUNClient::NatTypes natType;
00100 H460_FeatureStd23 * feat;
00101 };
00102
00103
00105
00106 class H460_FeatureStd23 : public H460_FeatureStd
00107 {
00108 PCLASSINFO(H460_FeatureStd23, H460_FeatureStd);
00109
00110 public:
00111
00112 H460_FeatureStd23();
00113 virtual ~H460_FeatureStd23();
00114
00115
00116 virtual void AttachEndPoint(H323EndPoint * _ep);
00117
00118 static PStringArray GetFeatureName() { return PStringArray("Std23"); };
00119 static PStringArray GetFeatureFriendlyName() { return PStringArray("P2Pnat Detect-H.460.23"); };
00120 static int GetPurpose() { return FeatureRas; };
00121 static PStringArray GetIdentifier() { return PStringArray("23"); };
00122
00123 virtual PBoolean CommonFeature() { return isEnabled; }
00124
00125
00126
00127 virtual PBoolean OnSendGatekeeperRequest(H225_FeatureDescriptor & pdu);
00128 virtual void OnReceiveGatekeeperConfirm(const H225_FeatureDescriptor & pdu);
00129
00130 virtual PBoolean OnSendRegistrationRequest(H225_FeatureDescriptor & pdu);
00131 virtual void OnReceiveRegistrationConfirm(const H225_FeatureDescriptor & pdu);
00132
00133 H323EndPoint * GetEndPoint() const { return (H323EndPoint *)EP; }
00134
00135
00136 void OnNATTypeDetection(PSTUNClient::NatTypes type, const PIPSocket::Address & ExtIP);
00137
00138 bool IsAvailable();
00139
00140 bool AlternateNATMethod();
00141 bool UseAlternate();
00142
00143 #ifdef H323_UPnP
00144 void InitialiseUPnP();
00145 #endif
00146
00147 protected:
00148 bool DetectALG(const PIPSocket::Address & detectAddress);
00149 void StartSTUNTest(const PString & server);
00150
00151 void DelayedReRegistration();
00152
00153 private:
00154 H323EndPoint * EP;
00155 PSTUNClient::NatTypes natType;
00156 PIPSocket::Address externalIP;
00157 PBoolean natNotify;
00158 PBoolean alg;
00159 PBoolean isavailable;
00160 PBoolean isEnabled;
00161 int useAlternate;
00162
00163
00164 PThread * RegThread;
00165 PDECLARE_NOTIFIER(PThread, H460_FeatureStd23, RegMethod);
00166 };
00167
00168
00169
00170 #if !defined(_WIN32_WCE)
00171 PPLUGIN_STATIC_LOAD(Std23, H460_Feature);
00172 #endif
00173
00174
00176
00177 class H323EndPoint;
00178 class H323Connection;
00179
00180 class H460_FeatureStd24 : public H460_FeatureStd
00181 {
00182 PCLASSINFO(H460_FeatureStd24, H460_FeatureStd);
00183
00184 public:
00185 H460_FeatureStd24();
00186 virtual ~H460_FeatureStd24();
00187
00188
00189 virtual void AttachEndPoint(H323EndPoint * _ep);
00190 virtual void AttachConnection(H323Connection * _ep);
00191
00192 static PStringArray GetFeatureName() { return PStringArray("Std24"); };
00193 static PStringArray GetFeatureFriendlyName() { return PStringArray("P2Pnat Media-H.460.24"); };
00194 static int GetPurpose() { return FeatureSignal; };
00195 static PStringArray GetIdentifier() { return PStringArray("24"); };
00196
00197 virtual PBoolean CommonFeature() { return isEnabled; }
00198
00199 enum NatInstruct {
00200 e_unknown,
00201 e_noassist,
00202 e_localMaster,
00203 e_remoteMaster,
00204 e_localProxy,
00205 e_remoteProxy,
00206 e_natFullProxy,
00207 e_natAnnexA,
00208 e_natAnnexB,
00209 e_natFailure = 100
00210 };
00211
00212 static PString GetNATStrategyString(NatInstruct method);
00213
00214 enum H46024NAT {
00215 e_default,
00216 e_enable,
00217 e_AnnexA,
00218 e_AnnexB,
00219 e_disable
00220 };
00221
00222
00223 virtual PBoolean OnSendAdmissionRequest(H225_FeatureDescriptor & pdu);
00224 virtual void OnReceiveAdmissionConfirm(const H225_FeatureDescriptor & pdu);
00225 virtual void OnReceiveAdmissionReject(const H225_FeatureDescriptor & pdu);
00226
00227 virtual PBoolean OnSendSetup_UUIE(H225_FeatureDescriptor & pdu);
00228 virtual void OnReceiveSetup_UUIE(const H225_FeatureDescriptor & pdu);
00229
00230 protected:
00231 void HandleNATInstruction(NatInstruct natconfig);
00232 void SetNATMethods(H46024NAT state);
00233 void SetH46019State(bool state);
00234
00235 private:
00236 H323EndPoint * EP;
00237 H323Connection * CON;
00238 NatInstruct natconfig;
00239 PMutex h460mute;
00240 int nattype;
00241 bool isEnabled;
00242 bool useAlternate;
00243 };
00244
00245
00246 inline ostream & operator<<(ostream & strm, H460_FeatureStd24::NatInstruct method) { return strm << H460_FeatureStd24::GetNATStrategyString(method); }
00247
00248
00249 #if !defined(_WIN32_WCE)
00250 PPLUGIN_STATIC_LOAD(Std24, H460_Feature);
00251 #endif
00252
00253
00254 #endif // H_H460_Featurestd23