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: 20864 $
00030  * $Author: rjongbloed $
00031  * $Date: 2008-09-05 10:22:55 +0000 (Fri, 05 Sep 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 OPAL_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     );
00218     
00221     virtual void OnTerminalAliasChanged();
00223 
00228     PBoolean IsDiscoveryComplete() const { return discoveryComplete; }
00229 
00232     PBoolean IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00233 
00234     enum RegistrationFailReasons {
00235       RegistrationSuccessful,
00236       UnregisteredLocally,
00237       UnregisteredByGatekeeper,
00238       GatekeeperLostRegistration,
00239       InvalidListener,
00240       DuplicateAlias,
00241       SecurityDenied,
00242       TransportError,
00243       NumRegistrationFailReasons,
00244       RegistrationRejectReasonMask = 0x8000
00245     };
00248     RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00249 
00258     PString GetName() const;
00259 
00262     const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00263 
00268     void SetPassword(
00269       const PString & password,            
00270       const PString & username = PString() 
00271     );
00272         
00273     /*
00274      * Return the call signalling address for the gatekeeper (if present)
00275      */
00276     H323TransportAddress GetGatekeeperRouteAddress() const
00277     { return gkRouteAddress; }
00279 
00280 
00281   protected:
00282     bool StartGatekeeper(const H323TransportAddress & address);
00283     bool DiscoverGatekeeper();
00284     unsigned SetupGatekeeperRequest(H323RasPDU & request);
00285         
00286     void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00287     PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00288     PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00289     void RegistrationTimeToLive();
00290 
00291     void SetInfoRequestRate(
00292       const PTimeInterval & rate
00293     );
00294     void ClearInfoRequestRate();
00295     H225_InfoRequestResponse & BuildInfoRequestResponse(
00296       H323RasPDU & response,
00297       unsigned seqNum
00298     );
00299     PBoolean SendUnsolicitedIRR(
00300       H225_InfoRequestResponse & irr,
00301       H323RasPDU & response
00302     );
00303 
00304     void SetAlternates(
00305       const H225_ArrayOf_AlternateGK & alts,
00306       PBoolean permanent
00307     );
00308 
00309     virtual PBoolean MakeRequest(
00310       Request & request
00311     );
00312     PBoolean MakeRequestWithReregister(
00313       Request & request,
00314       unsigned unregisteredTag
00315     );
00316     
00317     virtual H323Transport * CreateTransport(PIPSocket::Address bindng = PIPSocket::GetDefaultIpAny(), WORD port = 0, PBoolean reuseAddr = PFalse);
00318     
00319     // Handling interface changes
00320     void OnAddInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
00321     void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry, PINDEX priority);
00322     void UpdateConnectionStatus();
00323 
00324 
00325     // Gatekeeper registration state variables
00326     PBoolean     discoveryComplete;
00327     PString  endpointIdentifier;
00328     RegistrationFailReasons registrationFailReason;
00329     
00330     enum {
00331       HighPriority = 80,
00332       LowPriority  = 40,
00333     };
00334     class InterfaceMonitor : public PInterfaceMonitorClient
00335     {
00336       PCLASSINFO(InterfaceMonitor, PInterfaceMonitorClient);
00337       
00338       public:
00339         InterfaceMonitor(H323Gatekeeper & gk, PINDEX priority);
00340       
00341       protected:
00342         virtual void OnAddInterface(const PIPSocket::InterfaceEntry & entry);
00343         virtual void OnRemoveInterface(const PIPSocket::InterfaceEntry & entry);
00344         
00345         H323Gatekeeper & gk;
00346     };
00347     InterfaceMonitor highPriorityMonitor;
00348     InterfaceMonitor lowPriorityMonitor;
00349     
00350     class AlternateInfo : public PObject {
00351       PCLASSINFO(AlternateInfo, PObject);
00352       public:
00353         AlternateInfo(H225_AlternateGK & alt);
00354         ~AlternateInfo();
00355         Comparison Compare(const PObject & obj);
00356         void PrintOn(ostream & strm) const;
00357 
00358         H323TransportAddress rasAddress;
00359         PString              gatekeeperIdentifier;
00360         unsigned             priority;
00361         enum {
00362           NoRegistrationNeeded,
00363           NeedToRegister,
00364           Register,
00365           IsRegistered,
00366           RegistrationFailed
00367         } registrationState;
00368 
00369       private:
00370         // Disable copy constructor and assignment
00371         AlternateInfo(const AlternateInfo &other): PObject(other) { }
00372         AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00373     };
00374     PSortedList<AlternateInfo> alternates;
00375     PBoolean               alternatePermanent;
00376     PSemaphore         requestMutex;
00377     H235Authenticators authenticators;
00378 
00379     enum {
00380       RequireARQ,
00381       PregrantARQ,
00382       PreGkRoutedARQ
00383     } pregrantMakeCall, pregrantAnswerCall;
00384     H323TransportAddress gkRouteAddress;
00385 
00386     // Gatekeeper operation variables
00387     PBoolean       autoReregister;
00388     PBoolean       reregisterNow;
00389     PTimer     timeToLive;
00390     PBoolean       requiresDiscovery;
00391     PTimer     infoRequestRate;
00392     PBoolean       willRespondToIRR;
00393     PThread  * monitor;
00394     PBoolean       monitorStop;
00395     PSyncPoint monitorTickle;
00396 
00397     PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00398         
00399 #ifdef OPAL_H460
00400     H460_FeatureSet * features;
00401 #endif
00402         
00403 };
00404 
00405 
00406 PLIST(H323GatekeeperList, H323Gatekeeper);
00407 
00408 
00409 #endif // __OPAL_GKCLIENT_H
00410 
00411 

Generated on Mon Sep 15 11:48:45 2008 for OPAL by  doxygen 1.5.1