gkclient.h

Go to the documentation of this file.
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: 19279 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-01-17 04:08:34 +0000 (Thu, 17 Jan 2008) $
00032  */
00033 
00034 #ifndef __OPAL_GKCLIENT_H
00035 #define __OPAL_GKCLIENT_H
00036 
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040 
00041 
00042 #include <h323/h225ras.h>
00043 #include <h323/h235auth.h>
00044 
00045 #ifdef H323_H460
00046 class H460_FeatureSet;
00047 #endif
00048 
00049 class H323Connection;
00050 class H225_ArrayOf_AliasAddress;
00051 class H225_H323_UU_PDU;
00052 class H225_AlternateGK;
00053 class H225_ArrayOf_AlternateGK;
00054 class H225_ArrayOf_ServiceControlSession;
00055 class H225_FeatureSet;
00056 
00057 
00059 
00062 class H323Gatekeeper : public H225_RAS
00063 {
00064     PCLASSINFO(H323Gatekeeper, H225_RAS);
00065   public:
00070     H323Gatekeeper(
00071       H323EndPoint & endpoint,  
00072       H323Transport * transport       
00073     );
00074 
00077     ~H323Gatekeeper();
00079 
00082     PBoolean OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
00083     PBoolean OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
00084     PBoolean OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
00085     PBoolean OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
00086     PBoolean OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
00087     PBoolean OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
00088     PBoolean OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
00089     PBoolean OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
00090     PBoolean OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
00091     PBoolean OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
00092     PBoolean OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
00093     PBoolean OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
00094     PBoolean OnReceiveInfoRequest(const H225_InfoRequest & irq);
00095     PBoolean OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
00096     void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
00097     void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
00098     PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
00099     void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
00101 
00106     PBoolean DiscoverAny();
00107 
00112     PBoolean DiscoverByName(
00113       const PString & identifier  
00114     );
00115 
00120     PBoolean DiscoverByAddress(
00121       const H323TransportAddress & address 
00122     );
00123 
00127     PBoolean DiscoverByNameAndAddress(
00128       const PString & identifier,
00129       const H323TransportAddress & address
00130     );
00131 
00134     PBoolean RegistrationRequest(
00135       PBoolean autoReregister = PTrue  
00136     );
00137 
00140     PBoolean UnregistrationRequest(
00141       int reason      
00142     );
00143 
00146     PBoolean LocationRequest(
00147       const PString & alias,          
00148       H323TransportAddress & address  
00149     );
00150 
00153     PBoolean LocationRequest(
00154       const PStringList & aliases,    
00155       H323TransportAddress & address  
00156     );
00157 
00158     struct AdmissionResponse {
00159       AdmissionResponse();
00160 
00161       unsigned rejectReason;                      
00162 
00163       PBoolean gatekeeperRouted;                      
00164       PINDEX endpointCount;                       
00165       H323TransportAddress * transportAddress;    
00166       PBYTEArray * accessTokenData;               
00167 
00168       H225_ArrayOf_AliasAddress * aliasAddresses; 
00169       H225_ArrayOf_AliasAddress * destExtraCallInfo; 
00170     };
00171 
00174     PBoolean AdmissionRequest(
00175       H323Connection & connection,      
00176       AdmissionResponse & response,     
00177       PBoolean ignorePreGrantedARQ = PFalse  
00178     );
00179 
00182     PBoolean DisengageRequest(
00183       const H323Connection & connection,  
00184       unsigned reason                     
00185     );
00186 
00189     PBoolean BandwidthRequest(
00190       H323Connection & connection,    
00191       unsigned requestedBandwidth     
00192     );
00193 
00196     void InfoRequestResponse();
00197 
00200     void InfoRequestResponse(
00201       const H323Connection & connection  
00202     );
00203 
00206     void InfoRequestResponse(
00207       const H323Connection & connection,  
00208       const H225_H323_UU_PDU & pdu,       
00209       PBoolean sent                           
00210     );
00211 
00214     virtual void OnServiceControlSessions(
00215       const H225_ArrayOf_ServiceControlSession & serviceControl,
00216       H323Connection * connection
00217     );
00219 
00224     PBoolean IsDiscoveryComplete() const { return discoveryComplete; }
00225 
00228     PBoolean IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00229 
00230     enum RegistrationFailReasons {
00231       RegistrationSuccessful,
00232       UnregisteredLocally,
00233       UnregisteredByGatekeeper,
00234       GatekeeperLostRegistration,
00235       InvalidListener,
00236       DuplicateAlias,
00237       SecurityDenied,
00238       TransportError,
00239       NumRegistrationFailReasons,
00240       RegistrationRejectReasonMask = 0x8000
00241     };
00244     RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00245 
00254     PString GetName() const;
00255 
00258     const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00259 
00264     void SetPassword(
00265       const PString & password,            
00266       const PString & username = PString() 
00267     );
00268         
00269     /*
00270      * Return the call signalling address for the gatekeeper (if present)
00271      */
00272     H323TransportAddress GetGatekeeperRouteAddress() const
00273     { return gkRouteAddress; }
00275 
00276 
00277   protected:
00278     PBoolean StartDiscovery(const H323TransportAddress & address);
00279     unsigned SetupGatekeeperRequest(H323RasPDU & request);
00280         
00281     void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00282     PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00283     PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00284     void RegistrationTimeToLive();
00285 
00286     void SetInfoRequestRate(
00287       const PTimeInterval & rate
00288     );
00289     void ClearInfoRequestRate();
00290     H225_InfoRequestResponse & BuildInfoRequestResponse(
00291       H323RasPDU & response,
00292       unsigned seqNum
00293     );
00294     PBoolean SendUnsolicitedIRR(
00295       H225_InfoRequestResponse & irr,
00296       H323RasPDU & response
00297     );
00298 
00299     void SetAlternates(
00300       const H225_ArrayOf_AlternateGK & alts,
00301       PBoolean permanent
00302     );
00303 
00304     virtual PBoolean MakeRequest(
00305       Request & request
00306     );
00307     PBoolean MakeRequestWithReregister(
00308       Request & request,
00309       unsigned unregisteredTag
00310     );
00311     
00312     
00313     // Handling interface changes
00314     void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
00315     void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
00316     bool DiscoverGatekeeper(const H323TransportAddress & address);
00317     void UpdateConnectionStatus();
00318 
00319 
00320     // Gatekeeper registration state variables
00321     PBoolean     discoveryComplete;
00322     PString  endpointIdentifier;
00323     RegistrationFailReasons registrationFailReason;
00324     
00325     enum {
00326       HighPriority = 80,
00327       LowPriority  = 40,
00328     };
00329     class InterfaceMonitor : public PInterfaceMonitorClient
00330     {
00331       PCLASSINFO(InterfaceMonitor, PInterfaceMonitorClient);
00332       
00333       public:
00334         InterfaceMonitor(H323Gatekeeper & gk, PINDEX priority);
00335       
00336       protected:
00337         virtual void OnAddInterface(const PIPSocket::InterfaceEntry & entry);
00338         virtual void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry);
00339         
00340         H323Gatekeeper & gk;
00341     };
00342     InterfaceMonitor highPriorityMonitor;
00343     InterfaceMonitor lowPriorityMonitor;
00344     
00345     class AlternateInfo : public PObject {
00346       PCLASSINFO(AlternateInfo, PObject);
00347       public:
00348         AlternateInfo(H225_AlternateGK & alt);
00349         ~AlternateInfo();
00350         Comparison Compare(const PObject & obj);
00351         void PrintOn(ostream & strm) const;
00352 
00353         H323TransportAddress rasAddress;
00354         PString              gatekeeperIdentifier;
00355         unsigned             priority;
00356         enum {
00357           NoRegistrationNeeded,
00358           NeedToRegister,
00359           Register,
00360           IsRegistered,
00361           RegistrationFailed
00362         } registrationState;
00363 
00364       private:
00365         // Disable copy constructor and assignment
00366         AlternateInfo(const AlternateInfo &other): PObject(other) { }
00367         AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00368     };
00369     PSortedList<AlternateInfo> alternates;
00370     PBoolean               alternatePermanent;
00371     PSemaphore         requestMutex;
00372     H235Authenticators authenticators;
00373 
00374     enum {
00375       RequireARQ,
00376       PregrantARQ,
00377       PreGkRoutedARQ
00378     } pregrantMakeCall, pregrantAnswerCall;
00379     H323TransportAddress gkRouteAddress;
00380 
00381     // Gatekeeper operation variables
00382     PBoolean       autoReregister;
00383     PBoolean       reregisterNow;
00384     PTimer     timeToLive;
00385     PBoolean       requiresDiscovery;
00386     PTimer     infoRequestRate;
00387     PBoolean       willRespondToIRR;
00388     PThread  * monitor;
00389     PBoolean       monitorStop;
00390     PSyncPoint monitorTickle;
00391 
00392     PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00393         
00394 #ifdef H323_H460
00395     H460_FeatureSet & features;
00396 #endif
00397         
00398 };
00399 
00400 
00401 PLIST(H323GatekeeperList, H323Gatekeeper);
00402 
00403 
00404 #endif // __OPAL_GKCLIENT_H
00405 
00406 

Generated on Fri Mar 7 07:36:10 2008 for OPAL by  doxygen 1.5.1