OPAL
Version 3.10.4
|
00001 /* 00002 * gkclient.h 00003 * 00004 * Gatekeeper client protocol handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (c) 1998-2001 Equivalence Pty. Ltd. 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 00023 * 00024 * Portions of this code were written with the assisance of funding from 00025 * iFace, Inc. http://www.iface.com 00026 * 00027 * Contributor(s): ______________________________________. 00028 * 00029 * $Revision: 24178 $ 00030 * $Author: rjongbloed $ 00031 * $Date: 2010-04-05 19:10:56 -0500 (Mon, 05 Apr 2010) $ 00032 */ 00033 00034 #ifndef OPAL_H323_GKCLIENT_H 00035 #define OPAL_H323_GKCLIENT_H 00036 00037 #ifdef P_USE_PRAGMA 00038 #pragma interface 00039 #endif 00040 00041 #include <opal/buildopts.h> 00042 00043 #if OPAL_H323 00044 00045 #include <h323/h225ras.h> 00046 #include <h323/h235auth.h> 00047 00048 #if OPAL_H460 00049 class H460_FeatureSet; 00050 #endif 00051 00052 class H323Connection; 00053 class H225_ArrayOf_AliasAddress; 00054 class H225_H323_UU_PDU; 00055 class H225_AlternateGK; 00056 class H225_ArrayOf_AlternateGK; 00057 class H225_ArrayOf_ServiceControlSession; 00058 class H225_FeatureSet; 00059 00060 00062 00065 class H323Gatekeeper : public H225_RAS 00066 { 00067 PCLASSINFO(H323Gatekeeper, H225_RAS); 00068 public: 00073 H323Gatekeeper( 00074 H323EndPoint & endpoint, 00075 H323Transport * transport 00076 ); 00077 00080 ~H323Gatekeeper(); 00082 00085 virtual PBoolean WriteTo( 00086 H323TransactionPDU & pdu, 00087 const H323TransportAddressArray & addresses, 00088 PBoolean callback = true 00089 ); 00091 00094 PBoolean OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf); 00095 PBoolean OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj); 00096 PBoolean OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf); 00097 PBoolean OnReceiveRegistrationReject(const H225_RegistrationReject & rrj); 00098 PBoolean OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq); 00099 PBoolean OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf); 00100 PBoolean OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj); 00101 PBoolean OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf); 00102 PBoolean OnReceiveAdmissionReject(const H225_AdmissionReject & arj); 00103 PBoolean OnReceiveDisengageRequest(const H225_DisengageRequest & drq); 00104 PBoolean OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf); 00105 PBoolean OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq); 00106 PBoolean OnReceiveInfoRequest(const H225_InfoRequest & irq); 00107 PBoolean OnReceiveServiceControlIndication(const H225_ServiceControlIndication &); 00108 void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq); 00109 void OnSendAdmissionRequest(H225_AdmissionRequest & arq); 00110 PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const; 00111 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const; 00113 00118 PBoolean DiscoverAny(); 00119 00124 PBoolean DiscoverByName( 00125 const PString & identifier 00126 ); 00127 00132 PBoolean DiscoverByAddress( 00133 const H323TransportAddress & address 00134 ); 00135 00139 PBoolean DiscoverByNameAndAddress( 00140 const PString & identifier, 00141 const H323TransportAddress & address 00142 ); 00143 00146 PBoolean RegistrationRequest( 00147 PBoolean autoReregister = true, 00148 PBoolean didGkDiscovery = false 00149 ); 00150 00153 PBoolean UnregistrationRequest( 00154 int reason 00155 ); 00156 00159 PBoolean LocationRequest( 00160 const PString & alias, 00161 H323TransportAddress & address 00162 ); 00163 00166 PBoolean LocationRequest( 00167 const PStringList & aliases, 00168 H323TransportAddress & address 00169 ); 00170 00171 struct AdmissionResponse { 00172 AdmissionResponse(); 00173 00174 unsigned rejectReason; 00175 00176 PBoolean gatekeeperRouted; 00177 PINDEX endpointCount; 00178 H323TransportAddress * transportAddress; 00179 PBYTEArray * accessTokenData; 00180 00181 H225_ArrayOf_AliasAddress * aliasAddresses; 00182 H225_ArrayOf_AliasAddress * destExtraCallInfo; 00183 }; 00184 00187 PBoolean AdmissionRequest( 00188 H323Connection & connection, 00189 AdmissionResponse & response, 00190 PBoolean ignorePreGrantedARQ = false 00191 ); 00192 00195 PBoolean DisengageRequest( 00196 const H323Connection & connection, 00197 unsigned reason 00198 ); 00199 00202 PBoolean BandwidthRequest( 00203 H323Connection & connection, 00204 unsigned requestedBandwidth 00205 ); 00206 00209 void InfoRequestResponse(); 00210 00213 void InfoRequestResponse( 00214 const H323Connection & connection 00215 ); 00216 00219 void InfoRequestResponse( 00220 const H323Connection & connection, 00221 const H225_H323_UU_PDU & pdu, 00222 PBoolean sent 00223 ); 00224 00227 virtual void OnServiceControlSessions( 00228 const H225_ArrayOf_ServiceControlSession & serviceControl, 00229 H323Connection * connection 00230 ); 00231 00234 virtual void OnTerminalAliasChanged(); 00236 00241 PBoolean IsDiscoveryComplete() const { return discoveryComplete; } 00242 00245 PBoolean IsRegistered() const { return registrationFailReason == RegistrationSuccessful; } 00246 00247 enum RegistrationFailReasons { 00248 RegistrationSuccessful, 00249 UnregisteredLocally, 00250 UnregisteredByGatekeeper, 00251 GatekeeperLostRegistration, 00252 InvalidListener, 00253 DuplicateAlias, 00254 SecurityDenied, 00255 TransportError, 00256 NumRegistrationFailReasons, 00257 RegistrationRejectReasonMask = 0x8000 00258 }; 00261 RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; } 00262 00271 PString GetName() const; 00272 00275 const PString & GetEndpointIdentifier() const { return endpointIdentifier; } 00276 00281 void SetPassword( 00282 const PString & password, 00283 const PString & username = PString() 00284 ); 00285 00286 /* 00287 * Return the call signalling address for the gatekeeper (if present) 00288 */ 00289 H323TransportAddress GetGatekeeperRouteAddress() const 00290 { return gkRouteAddress; } 00292 00293 00294 protected: 00295 bool StartGatekeeper(const H323TransportAddress & address); 00296 virtual bool DiscoverGatekeeper(); 00297 unsigned SetupGatekeeperRequest(H323RasPDU & request); 00298 00299 void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier); 00300 PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain); 00301 PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor); 00302 void RegistrationTimeToLive(); 00303 00304 void SetInfoRequestRate( 00305 const PTimeInterval & rate 00306 ); 00307 void ClearInfoRequestRate(); 00308 H225_InfoRequestResponse & BuildInfoRequestResponse( 00309 H323RasPDU & response, 00310 unsigned seqNum 00311 ); 00312 PBoolean SendUnsolicitedIRR( 00313 H225_InfoRequestResponse & irr, 00314 H323RasPDU & response 00315 ); 00316 00317 void SetAlternates( 00318 const H225_ArrayOf_AlternateGK & alts, 00319 PBoolean permanent 00320 ); 00321 00322 virtual PBoolean MakeRequest( 00323 Request & request 00324 ); 00325 PBoolean MakeRequestWithReregister( 00326 Request & request, 00327 unsigned unregisteredTag 00328 ); 00329 00330 virtual H323Transport * CreateTransport(PIPSocket::Address bindng = PIPSocket::GetDefaultIpAny(), WORD port = 0, PBoolean reuseAddr = false); 00331 00332 // Handling interface changes 00333 void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority); 00334 void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority); 00335 void UpdateConnectionStatus(); 00336 bool SetListenerAddresses(H225_ArrayOf_TransportAddress & pdu); 00337 00338 // Gatekeeper registration state variables 00339 PBoolean discoveryComplete; 00340 PString endpointIdentifier; 00341 RegistrationFailReasons registrationFailReason; 00342 00343 enum { 00344 HighPriority = 80, 00345 LowPriority = 40, 00346 }; 00347 class InterfaceMonitor : public PInterfaceMonitorClient 00348 { 00349 PCLASSINFO(InterfaceMonitor, PInterfaceMonitorClient); 00350 00351 public: 00352 InterfaceMonitor(H323Gatekeeper & gk, PINDEX priority); 00353 00354 protected: 00355 virtual void OnAddInterface(const PIPSocket::InterfaceEntry & entry); 00356 virtual void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry); 00357 00358 H323Gatekeeper & gk; 00359 }; 00360 InterfaceMonitor highPriorityMonitor; 00361 InterfaceMonitor lowPriorityMonitor; 00362 00363 class AlternateInfo : public PObject { 00364 PCLASSINFO(AlternateInfo, PObject); 00365 public: 00366 AlternateInfo(H225_AlternateGK & alt); 00367 ~AlternateInfo(); 00368 Comparison Compare(const PObject & obj); 00369 void PrintOn(ostream & strm) const; 00370 00371 H323TransportAddress rasAddress; 00372 PString gatekeeperIdentifier; 00373 unsigned priority; 00374 enum { 00375 NoRegistrationNeeded, 00376 NeedToRegister, 00377 Register, 00378 IsRegistered, 00379 RegistrationFailed 00380 } registrationState; 00381 00382 private: 00383 // Disable copy constructor and assignment 00384 AlternateInfo(const AlternateInfo &other): PObject(other) { } 00385 AlternateInfo & operator=(const AlternateInfo &) { return *this; } 00386 }; 00387 PSortedList<AlternateInfo> alternates; 00388 PBoolean alternatePermanent; 00389 PSemaphore requestMutex; 00390 H235Authenticators authenticators; 00391 00392 enum { 00393 RequireARQ, 00394 PregrantARQ, 00395 PreGkRoutedARQ 00396 } pregrantMakeCall, pregrantAnswerCall; 00397 H323TransportAddress gkRouteAddress; 00398 00399 // Gatekeeper operation variables 00400 PBoolean autoReregister; 00401 PBoolean reregisterNow; 00402 PTimer timeToLive; 00403 PBoolean requiresDiscovery; 00404 PTimer infoRequestRate; 00405 PBoolean willRespondToIRR; 00406 PThread * monitor; 00407 PBoolean monitorStop; 00408 PSyncPoint monitorTickle; 00409 00410 PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions; 00411 00412 #if OPAL_H460 00413 H460_FeatureSet * features; 00414 #endif 00415 00416 }; 00417 00418 00419 PLIST(H323GatekeeperList, H323Gatekeeper); 00420 00421 00422 #endif // OPAL_H323 00423 00424 #endif // OPAL_H323_GKCLIENT_H 00425 00426