D:/Storage/CVS_Head/h323plus/include/gkclient.h

00001 /*
00002  * gkclient.h
00003  *
00004  * Gatekeeper client protocol handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1998-2000 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  * $Log: gkclient.h,v $
00030  * Revision 1.2  2007/10/16 16:54:32  shorne
00031  * Fix for H.235.1 on full reregistration
00032  *
00033  * Revision 1.1  2007/08/06 20:50:48  shorne
00034  * First commit of h323plus
00035  *
00036  * Revision 1.58.2.1  2006/12/23 19:08:02  shorne
00037  * Plugin video codecs & sundry
00038  *
00039  * Revision 1.58  2006/05/30 11:14:55  hfriederich
00040  * Switch from DISABLE_H460 to H323_H460
00041  *
00042  * Revision 1.57  2006/05/18 17:16:34  shorne
00043  * Added H460 Support
00044  *
00045  * Revision 1.56  2005/11/30 13:05:01  csoutheren
00046  * Changed tags for Doxygen
00047  *
00048  * Revision 1.55  2005/01/03 14:03:19  csoutheren
00049  * Added new configure options and ability to disable/enable modules
00050  *
00051  * Revision 1.54  2005/01/03 06:25:52  csoutheren
00052  * Added extensive support for disabling code modules at compile time
00053  *
00054  * Revision 1.53  2004/09/03 01:06:08  csoutheren
00055  * Added initial hooks for H.460 GEF
00056  * Thanks to Simon Horne and ISVO (Asia) Pte Ltd. for this contribution
00057  *
00058  * Revision 1.52  2004/03/04 04:49:34  csoutheren
00059  * Added access function for gatekeeper routed address
00060  *
00061  * Revision 1.51  2003/03/26 00:46:25  robertj
00062  * Had another go at making H323Transactor being able to be created
00063  *   without having a listener running.
00064  *
00065  * Revision 1.50  2003/02/12 23:59:22  robertj
00066  * Fixed adding missing endpoint identifer in SETUP packet when gatekeeper
00067  * routed, pointed out by Stefan Klein
00068  * Also fixed correct rutrn of gk routing in IRR packet.
00069  *
00070  * Revision 1.49  2003/02/07 06:37:42  robertj
00071  * Changed registration state to an enum so can determine why the RRQ failed.
00072  *
00073  * Revision 1.48  2003/01/06 07:09:28  robertj
00074  * Further fixes for alternate gatekeeper, thanks Kevin Bouchard
00075  *
00076  * Revision 1.47  2002/12/23 22:46:38  robertj
00077  * Changed gatekeeper discovery so an GRJ does not indicate "discovered".
00078  * Added trace output of alternate gatekeepers list.
00079  *
00080  * Revision 1.46  2002/11/28 04:41:44  robertj
00081  * Added support for RAS ServiceControlIndication command.
00082  *
00083  * Revision 1.45  2002/11/27 06:54:52  robertj
00084  * Added Service Control Session management as per Annex K/H.323 via RAS
00085  *   only at this stage.
00086  * Added H.248 ASN and very primitive infrastructure for linking into the
00087  *   Service Control Session management system.
00088  * Added basic infrastructure for Annex K/H.323 HTTP transport system.
00089  * Added Call Credit Service Control to display account balances.
00090  *
00091  * Revision 1.44  2002/11/21 07:21:46  robertj
00092  * Improvements to alternate gatekeeper client code, thanks Kevin Bouchard
00093  *
00094  * Revision 1.43  2002/09/18 06:58:29  robertj
00095  * Fixed setting of IRR frequency, an RCF could reset timer so it did not time
00096  *   out correctly and send IRR in time causing problems with gatekeeper.
00097  *
00098  * Revision 1.42  2002/09/16 01:14:15  robertj
00099  * Added #define so can select if #pragma interface/implementation is used on
00100  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00101  *
00102  * Revision 1.41  2002/09/03 06:19:36  robertj
00103  * Normalised the multi-include header prevention ifdef/define symbol.
00104  *
00105  * Revision 1.40  2002/08/15 04:13:21  robertj
00106  * Fixed correct status of isRegistered flag on various reject/errors.
00107  *
00108  * Revision 1.39  2002/08/12 05:38:20  robertj
00109  * Changes to the RAS subsystem to support ability to make requests to client
00110  *   from gkserver without causing bottlenecks and race conditions.
00111  *
00112  * Revision 1.38  2002/08/05 05:17:36  robertj
00113  * Fairly major modifications to support different authentication credentials
00114  *   in ARQ to the logged in ones on RRQ. For both client and server.
00115  * Various other H.235 authentication bugs and anomalies fixed on the way.
00116  *
00117  * Revision 1.37  2002/07/18 03:03:38  robertj
00118  * Fixed bug with continually doing lightweight RRQ if no timeToLive present
00119  *   and it should not be doing it at all, ditto for unsolicited IRR.
00120  *
00121  * Revision 1.36  2002/07/16 11:06:21  robertj
00122  * Added more alternate gatekeeper implementation, thanks Kevin Bouchard
00123  *
00124  * Revision 1.35  2002/06/26 03:47:45  robertj
00125  * Added support for alternate gatekeepers.
00126  *
00127  * Revision 1.34  2002/05/29 00:03:15  robertj
00128  * Fixed unsolicited IRR support in gk client and server,
00129  *   including support for IACK and INAK.
00130  *
00131  * Revision 1.33  2002/05/17 04:12:38  robertj
00132  * Added support for unsolicited IRR transmission in background (heartbeat).
00133  *
00134  * Revision 1.32  2002/03/19 05:17:11  robertj
00135  * Normalised ACF destExtraCallIInfo to be same as other parameters.
00136  * Added ability to get multiple endpoint addresses and tokens from ACF.
00137  *
00138  * Revision 1.31  2001/09/26 07:02:49  robertj
00139  * Added needed mutex for SeparateAuthenticationInARQ mode, thanks Nick Hoath
00140  *
00141  * Revision 1.30  2001/09/18 10:36:54  robertj
00142  * Allowed multiple overlapping requests in RAS channel.
00143  *
00144  * Revision 1.29  2001/09/13 03:21:16  robertj
00145  * Added ability to override authentication credentials for ARQ, thanks Nick Hoath
00146  *
00147  * Revision 1.28  2001/09/12 06:57:58  robertj
00148  * Added support for iNow Access Token from gk, thanks Nick Hoath
00149  *
00150  * Revision 1.27  2001/09/12 06:04:36  robertj
00151  * Added support for sending UUIE's to gk on request, thanks Nick Hoath
00152  *
00153  * Revision 1.26  2001/09/06 02:32:26  robertj
00154  * Added overloaded AdmissionRequest for backward compatibility.
00155  *
00156  * Revision 1.25  2001/08/14 04:26:46  robertj
00157  * Completed the Cisco compatible MD5 authentications, thanks Wolfgang Platzer.
00158  *
00159  * Revision 1.24  2001/08/13 01:27:00  robertj
00160  * Changed GK admission so can return multiple aliases to be used in
00161  *   setup packet, thanks Nick Hoath.
00162  *
00163  * Revision 1.23  2001/08/10 11:03:49  robertj
00164  * Major changes to H.235 support in RAS to support server.
00165  *
00166  * Revision 1.22  2001/08/06 07:44:52  robertj
00167  * Fixed problems with building without SSL
00168  *
00169  * Revision 1.21  2001/08/06 03:18:35  robertj
00170  * Fission of h323.h to h323ep.h & h323con.h, h323.h now just includes files.
00171  * Improved access to H.235 secure RAS functionality.
00172  * Changes to H.323 secure RAS contexts to help use with gk server.
00173  *
00174  * Revision 1.20  2001/08/02 04:30:09  robertj
00175  * Added ability for AdmissionRequest to alter destination alias used in
00176  *   the outgoing call.
00177  *
00178  * Revision 1.19  2001/06/18 06:23:47  robertj
00179  * Split raw H.225 RAS protocol out of gatekeeper client class.
00180  *
00181  * Revision 1.18  2001/04/05 03:39:42  robertj
00182  * Fixed deadlock if tried to do discovery in time to live timeout.
00183  *
00184  * Revision 1.17  2001/03/28 07:12:56  robertj
00185  * Changed RAS thread interlock to allow for what should not happen, the
00186  *   syncpoint being signalled before receiving any packets.
00187  *
00188  * Revision 1.16  2001/03/27 02:18:41  robertj
00189  * Changed to send gk a GRQ if it gives a discoveryRequired error on RRQ.
00190  *
00191  * Revision 1.15  2001/03/17 00:05:52  robertj
00192  * Fixed problems with Gatekeeper RIP handling.
00193  *
00194  * Revision 1.14  2001/02/28 00:20:15  robertj
00195  * Added DiscoverByNameAndAddress() function, thanks Chris Purvis.
00196  *
00197  * Revision 1.13  2001/02/09 05:16:24  robertj
00198  * Added #pragma interface for GNU C++.
00199  *
00200  * Revision 1.12  2000/09/25 06:47:54  robertj
00201  * Removed use of alias if there is no alias present, ie only have transport address.
00202  *
00203  * Revision 1.11  2000/09/01 02:12:54  robertj
00204  * Added ability to select a gatekeeper on LAN via it's identifier name.
00205  *
00206  * Revision 1.10  2000/07/11 19:20:02  robertj
00207  * Fixed problem with endpoint identifiers from some gatekeepers not being a string, just binary info.
00208  *
00209  * Revision 1.9  2000/06/20 03:17:56  robertj
00210  * Added function to get name of gatekeeper, subtle difference from getting identifier.
00211  *
00212  * Revision 1.8  2000/05/18 11:53:33  robertj
00213  * Changes to support doc++ documentation generation.
00214  *
00215  * Revision 1.7  2000/05/09 08:52:36  robertj
00216  * Added support for preGrantedARQ fields on registration.
00217  *
00218  * Revision 1.6  2000/05/02 04:32:24  robertj
00219  * Fixed copyright notice comment.
00220  *
00221  * Revision 1.5  2000/04/11 03:10:40  robertj
00222  * Added ability to reject reason on gatekeeper requests.
00223  * Added ability to get the transport being used to talk to the gatekeeper.
00224  *
00225  * Revision 1.4  2000/04/10 17:37:13  robertj
00226  * Added access function to get the gatekeeper identification string.
00227  *
00228  * Revision 1.3  1999/12/09 21:49:17  robertj
00229  * Added reregister on unregister and time to live reregistration
00230  *
00231  * Revision 1.2  1999/09/14 06:52:54  robertj
00232  * Added better support for multi-homed client hosts.
00233  *
00234  * Revision 1.1  1999/08/31 12:34:18  robertj
00235  * Added gatekeeper support.
00236  *
00237  */
00238 
00239 #ifndef __OPAL_GKCLIENT_H
00240 #define __OPAL_GKCLIENT_H
00241 
00242 #include "h323.h"
00243 #include "h225ras.h"
00244 #include "h235auth.h"
00245 
00246 #ifdef P_USE_PRAGMA
00247 #pragma interface
00248 #endif
00249 
00250 #ifdef H323_H460
00251 class H460_FeatureSet;
00252 #endif
00253 
00254 class H225_ArrayOf_AliasAddress;
00255 class H225_H323_UU_PDU;
00256 class H225_AlternateGK;
00257 class H225_ArrayOf_AlternateGK;
00258 class H225_ArrayOf_ServiceControlSession;
00259 
00260 
00262 
00265 class H323Gatekeeper : public H225_RAS
00266 {
00267     PCLASSINFO(H323Gatekeeper, H225_RAS);
00268   public:
00273     H323Gatekeeper(
00274       H323EndPoint & endpoint,  
00275       H323Transport * transport       
00276     );
00277 
00280     ~H323Gatekeeper();
00282 
00285     BOOL OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
00286     BOOL OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
00287     BOOL OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
00288     BOOL OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
00289     BOOL OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
00290     BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
00291     BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
00292     BOOL OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
00293     BOOL OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
00294     BOOL OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
00295     BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
00296     BOOL OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
00297     BOOL OnReceiveInfoRequest(const H225_InfoRequest & irq);
00298 
00299 #ifdef H323_H248
00300     BOOL OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
00301 #endif
00302 
00303     void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
00304     void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
00305     BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
00306     void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
00308 
00313     BOOL DiscoverAny();
00314 
00319     BOOL DiscoverByName(
00320       const PString & identifier  
00321     );
00322 
00327     BOOL DiscoverByAddress(
00328       const H323TransportAddress & address 
00329     );
00330 
00334     BOOL DiscoverByNameAndAddress(
00335       const PString & identifier,
00336       const H323TransportAddress & address
00337     );
00338 
00341     BOOL RegistrationRequest(
00342       BOOL autoReregister = TRUE  
00343     );
00344 
00347     BOOL UnregistrationRequest(
00348       int reason      
00349     );
00350 
00353     BOOL LocationRequest(
00354       const PString & alias,          
00355       H323TransportAddress & address  
00356     );
00357 
00360     BOOL LocationRequest(
00361       const PStringList & aliases,    
00362       H323TransportAddress & address  
00363     );
00364 
00365     struct AdmissionResponse {
00366       AdmissionResponse();
00367 
00368       unsigned rejectReason;                      
00369 
00370       BOOL gatekeeperRouted;                      
00371       PINDEX endpointCount;                       
00372       H323TransportAddress * transportAddress;    
00373       PBYTEArray * accessTokenData;               
00374 
00375       H225_ArrayOf_AliasAddress * aliasAddresses; 
00376       H225_ArrayOf_AliasAddress * destExtraCallInfo; 
00377     };
00378 
00381     BOOL AdmissionRequest(
00382       H323Connection & connection,      
00383       AdmissionResponse & response,     
00384       BOOL ignorePreGrantedARQ = FALSE  
00385     );
00386 
00389     BOOL DisengageRequest(
00390       const H323Connection & connection,  
00391       unsigned reason                     
00392     );
00393 
00396     BOOL BandwidthRequest(
00397       H323Connection & connection,    
00398       unsigned requestedBandwidth     
00399     );
00400 
00403     void InfoRequestResponse();
00404 
00407     void InfoRequestResponse(
00408       const H323Connection & connection  
00409     );
00410 
00413     void InfoRequestResponse(
00414       const H323Connection & connection,  
00415       const H225_H323_UU_PDU & pdu,       
00416       BOOL sent                           
00417     );
00418 
00419 #ifdef H323_H248
00420 
00422     virtual void OnServiceControlSessions(
00423       const H225_ArrayOf_ServiceControlSession & serviceControl,
00424       H323Connection * connection
00425     );
00426 #endif
00427 
00428 
00433     BOOL IsDiscoveryComplete() const { return discoveryComplete; }
00434 
00437     BOOL IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00438 
00441     void ReRegisterNow();
00442 
00443     enum RegistrationFailReasons {
00444       RegistrationSuccessful,
00445       UnregisteredLocally,
00446       UnregisteredByGatekeeper,
00447       GatekeeperLostRegistration,
00448       InvalidListener,
00449       DuplicateAlias,
00450       SecurityDenied,
00451       TransportError,
00452       NumRegistrationFailReasons,
00453       RegistrationRejectReasonMask = 0x8000
00454     };
00457     RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00458 
00467     PString GetName() const;
00468 
00471     const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00472 
00477     void SetPassword(
00478       const PString & password,            
00479       const PString & username = PString() 
00480     );
00481 
00482     /*
00483      * Return the call signalling address for the gatekeeper (if present)
00484      */
00485     H323TransportAddress GetGatekeeperRouteAddress() const
00486     { return gkRouteAddress; }
00488         
00489 
00490   protected:
00491     BOOL StartDiscovery(const H323TransportAddress & address);
00492     unsigned SetupGatekeeperRequest(H323RasPDU & request);
00493         
00494     void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00495     PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00496     PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00497     void RegistrationTimeToLive();
00498 
00499     void SetInfoRequestRate(
00500       const PTimeInterval & rate
00501     );
00502     void ClearInfoRequestRate();
00503     H225_InfoRequestResponse & BuildInfoRequestResponse(
00504       H323RasPDU & response,
00505       unsigned seqNum
00506     );
00507     BOOL SendUnsolicitedIRR(
00508       H225_InfoRequestResponse & irr,
00509       H323RasPDU & response
00510     );
00511 
00512     void SetAlternates(
00513       const H225_ArrayOf_AlternateGK & alts,
00514       BOOL permanent
00515     );
00516 
00517         void SetAssignedGatekeeper(
00518             const H225_AlternateGK & gk
00519         );
00520 
00521         BOOL GetAssignedGatekeeper(
00522             H225_AlternateGK & gk
00523         );
00524 
00525     virtual BOOL MakeRequest(
00526       Request & request
00527     );
00528     BOOL MakeRequestWithReregister(
00529       Request & request,
00530       unsigned unregisteredTag
00531     );
00532 
00533 
00534     // Gatekeeper registration state variables
00535     BOOL     discoveryComplete;
00536     PString  endpointIdentifier;
00537         PString  localId;
00538     RegistrationFailReasons registrationFailReason;
00539 
00540     class AlternateInfo : public PObject {
00541         PCLASSINFO(AlternateInfo, PObject);
00542       public:
00543         AlternateInfo(const H225_AlternateGK & alt);
00544             ~AlternateInfo();
00545                 H225_AlternateGK GetAlternate();
00546         Comparison Compare(const PObject & obj);
00547         void PrintOn(ostream & strm) const;
00548 
00549         H323TransportAddress rasAddress;
00550         PString              gatekeeperIdentifier;
00551         unsigned             priority;
00552         enum {
00553           NoRegistrationNeeded,
00554           NeedToRegister,
00555           Register,
00556           IsRegistered,
00557           RegistrationFailed
00558         } registrationState;
00559 
00560       private:
00561         // Disable copy constructor and assignment
00562         AlternateInfo(const AlternateInfo &) { }
00563         AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00564     };
00565     PSortedList<AlternateInfo> alternates;
00566     BOOL               alternatePermanent;
00567     PSemaphore         requestMutex;
00568     H235Authenticators authenticators;
00569         AlternateInfo *    assignedGK;
00570 
00571     enum {
00572       RequireARQ,
00573       PregrantARQ,
00574       PreGkRoutedARQ
00575     } pregrantMakeCall, pregrantAnswerCall;
00576     H323TransportAddress gkRouteAddress;
00577 
00578     // Gatekeeper operation variables
00579     BOOL       autoReregister;
00580     BOOL       reregisterNow;
00581     PTimer     timeToLive;
00582     BOOL       requiresDiscovery;
00583     PTimer     infoRequestRate;
00584     BOOL       willRespondToIRR;
00585     PThread  * monitor;
00586     BOOL       monitorStop;
00587     PSyncPoint monitorTickle;
00588 
00589 #ifdef H323_H248
00590     PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00591 #endif
00592 
00593 #ifdef H323_H460
00594     H460_FeatureSet & features;
00595 #endif
00596 
00597 };
00598 
00599 
00600 PLIST(H323GatekeeperList, H323Gatekeeper);
00601 
00602 
00603 
00604 #endif // __OPAL_GKCLIENT_H
00605 
00606 

Generated on Thu Oct 25 13:42:02 2007 for h323plus by  doxygen 1.5.2