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

00001 /*
00002  * gkserver.h
00003  *
00004  * H225 Registration Admission and Security 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  * This code was based on original code from OpenGate of Egoboo Ltd. thanks
00025  * to Ashley Unitt for his efforts.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: gkserver.h,v $
00030  * Revision 1.1  2007/08/06 20:50:48  shorne
00031  * First commit of h323plus
00032  *
00033  * Revision 1.87  2005/11/30 13:05:01  csoutheren
00034  * Changed tags for Doxygen
00035  *
00036  * Revision 1.86  2005/01/03 14:03:19  csoutheren
00037  * Added new configure options and ability to disable/enable modules
00038  *
00039  * Revision 1.85  2005/01/03 06:25:52  csoutheren
00040  * Added extensive support for disabling code modules at compile time
00041  *
00042  * Revision 1.84  2004/12/14 06:22:20  csoutheren
00043  * More OSP implementation
00044  *
00045  * Revision 1.83  2004/09/03 01:06:08  csoutheren
00046  * Added initial hooks for H.460 GEF
00047  * Thanks to Simon Horne and ISVO (Asia) Pte Ltd. for this contribution
00048  *
00049  * Revision 1.82  2004/08/03 07:00:13  csoutheren
00050  * Added isGKRouted hint to TranslateAliasAddress as this is needed for the reply ACF
00051  *
00052  * Revision 1.81  2004/06/15 03:30:45  csoutheren
00053  * Adde guard to function to prevent crash if no aliases on an endpoint
00054  *
00055  * Revision 1.80  2004/06/04 07:05:07  csoutheren
00056  * Fixed obvious typos
00057  *
00058  * Revision 1.79  2004/04/25 01:52:46  rjongbloed
00059  * Fixed GCC 3.4 warnings
00060  *
00061  * Revision 1.78  2004/04/21 01:39:05  csoutheren
00062  * Added new overrides to GatekeeperServer to provide virtuals when calls and endpoints are created and destroyed
00063  *
00064  * Revision 1.77  2004/04/15 07:43:36  csoutheren
00065  * Allow gatekeeper to make a decision on multiple alias registrations for each registration
00066  *
00067  * Revision 1.76  2004/04/14 01:41:59  csoutheren
00068  * Added access to endpoint information for GetUserPassword
00069  *
00070  * Revision 1.75  2004/03/31 07:16:22  csoutheren
00071  * Added virtual to provide access to H.501 descriptor sent by GK
00072  *
00073  * Revision 1.74  2004/02/15 03:36:30  rjongbloed
00074  * Fixed bug in removing prefixes, plus added ability to have multiple endpoints
00075  *   with the same profix, thanks Rossano Ravelli
00076  *
00077  * Revision 1.73  2004/02/07 11:43:59  rjongbloed
00078  * Fixed deadlocks caused under high load by failure to check locking
00079  *   success. Also added functions to find destination endpoint.
00080  *   Thanks Federico Pinna and the gang at Reitek S.p.A.
00081  *
00082  * Revision 1.72  2003/12/24 07:08:47  csoutheren
00083  * Added TranslateAliasAddress on H323GatekeeperCall
00084  *
00085  * Revision 1.71  2003/12/11 05:39:04  csoutheren
00086  * Added storage of H.225 version in endpoint structure
00087  * Disabled sending RIPs to endpoints that cannot handle them
00088  *
00089  * Revision 1.70  2003/12/11 02:18:17  csoutheren
00090  * More fixes for NM deregistration problems. Seems to be fixed now :)
00091  *
00092  * Revision 1.69  2003/12/09 00:58:46  csoutheren
00093  * Fixed problem with endpoints deregistering
00094  *
00095  * Revision 1.68  2003/12/09 00:33:17  csoutheren
00096  * Added patch to prevent crash when NM unregisters from GK
00097  * Abject apologies to Rossano Ravelli for taking so long to add this
00098  *
00099  * Revision 1.67  2003/04/30 00:28:50  robertj
00100  * Redesigned the alternate credentials in ARQ system as old implementation
00101  *   was fraught with concurrency issues, most importantly it can cause false
00102  *   detection of replay attacks taking out an endpoint completely.
00103  *
00104  * Revision 1.66  2003/04/02 06:58:10  robertj
00105  * Added support for (optional) duplicate aliases in gatekeeper server, necessitating
00106  *   the removal of AddAlias and RemoveAlias functions.
00107  *
00108  * Revision 1.65  2003/04/02 06:07:12  robertj
00109  * Added H.323 Annex G Peer Element support to gatekeeper server.
00110  *
00111  * Revision 1.64  2003/04/01 07:30:52  robertj
00112  * Added function to translate alias into alias list and transport to make
00113  *   use of full information returned by peer element.
00114  *
00115  * Revision 1.63  2003/04/01 04:47:48  robertj
00116  * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in
00117  *   server environment for use by H.501 peer elements.
00118  *
00119  * Revision 1.62  2003/03/26 07:10:03  robertj
00120  * Added more access functions.
00121  *
00122  * Revision 1.61  2003/03/17 22:52:06  craigs
00123  * Improvided useability of AddAlias and RemoveAlias
00124  *
00125  * Revision 1.60  2003/03/04 05:34:13  robertj
00126  * Fixed GNU warnings
00127  *
00128  * Revision 1.59  2003/03/04 05:27:51  robertj
00129  * Added statistics for rejected registrations and call admissions.
00130  *
00131  * Revision 1.58  2003/03/03 06:59:26  robertj
00132  * Fixed call SetBandwidth function so adjusts global bandwidth as well.
00133  *
00134  * Revision 1.57  2003/02/21 07:21:40  robertj
00135  * Fixed incorrect ancestor in PCLASSINFO()
00136  *
00137  * Revision 1.56  2003/02/21 05:28:39  craigs
00138  * Factored out code for user with peer elements
00139  *
00140  * Revision 1.55  2003/02/06 04:43:14  robertj
00141  * Changes to help with endpoints behind NAT.
00142  *
00143  * Revision 1.54  2003/02/03 03:58:06  robertj
00144  * Fixed use of local password database with ep's that have multiple aliases.
00145  *
00146  * Revision 1.53  2003/02/01 13:31:14  robertj
00147  * Changes to support CAT authentication in RAS.
00148  *
00149  * Revision 1.52  2002/12/17 01:25:23  robertj
00150  * Added call backs on gk server when ep indicates alerting or connect.
00151  *
00152  * Revision 1.51  2002/11/28 05:45:46  robertj
00153  * Fixed bug so can set total bandwidth while calls are in progress.
00154  *
00155  * Revision 1.50  2002/11/28 04:41:44  robertj
00156  * Added support for RAS ServiceControlIndication command.
00157  *
00158  * Revision 1.49  2002/11/27 06:54:52  robertj
00159  * Added Service Control Session management as per Annex K/H.323 via RAS
00160  *   only at this stage.
00161  * Added H.248 ASN and very primitive infrastructure for linking into the
00162  *   Service Control Session management system.
00163  * Added basic infrastructure for Annex K/H.323 HTTP transport system.
00164  * Added Call Credit Service Control to display account balances.
00165  *
00166  * Revision 1.48  2002/11/22 00:11:29  robertj
00167  * Added call start time.
00168  *
00169  * Revision 1.47  2002/11/18 23:40:45  robertj
00170  * Changed to use the H323EndPoint::CreateAuthenticators() function, we
00171  *   should use only one.
00172  *
00173  * Revision 1.46  2002/11/12 11:36:03  robertj
00174  * Added function to find endpoint by partial alias.
00175  * Optimised endpoint "indexes" to use sorted lists instead of dictionaries.
00176  *
00177  * Revision 1.45  2002/11/06 23:23:48  robertj
00178  * Fixed minor error in parameter, should be reference not value
00179  *
00180  * Revision 1.44  2002/10/29 00:12:02  robertj
00181  * Changed template classes so things like PSafeList actually creates the
00182  *   base collection class as well.
00183  * Improved setting of usage info, included getting it from BRQ etc.
00184  *
00185  * Revision 1.43  2002/10/21 00:54:47  robertj
00186  * Added function to unregister an endpoint via user interface.
00187  * Added reason code to call disengage.
00188  * Added ability to find call by a description string.
00189  *
00190  * Revision 1.42  2002/10/17 05:26:33  robertj
00191  * Added function to get at registered endpoints protocol version.
00192  *
00193  * Revision 1.41  2002/10/16 07:22:50  robertj
00194  * Added support for endpoints that do not support RRQ timeToLive parameter,
00195  *   will actively go see if ep is there using IRQ before expiring the ep.
00196  *
00197  * Revision 1.40  2002/10/01 08:17:34  robertj
00198  * Fixed (benign) race condition between client and server both wanting to do
00199  *   a DRQ of a call at the same time. Caused an Assert, but no crash.
00200  *
00201  * Revision 1.39  2002/09/26 01:27:31  robertj
00202  * Changed appliation info name in registered endpoint to be caseless string.
00203  *
00204  * Revision 1.38  2002/09/24 08:03:51  robertj
00205  * Added H.225 RAS protocol version number to registered endpoint structure.
00206  *
00207  * Revision 1.37  2002/09/19 09:15:56  robertj
00208  * Fixed problem with making (and assuring with multi-threading) IRQ and DRQ
00209  *   requests are sent to the correct endpoint address, thanks Martijn Roest.
00210  *
00211  * Revision 1.36  2002/09/16 01:14:15  robertj
00212  * Added #define so can select if #pragma interface/implementation is used on
00213  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00214  *
00215  * Revision 1.35  2002/09/03 06:19:36  robertj
00216  * Normalised the multi-include header prevention ifdef/define symbol.
00217  *
00218  * Revision 1.34  2002/08/29 07:57:08  robertj
00219  * Added some statistics to gatekeeper server.
00220  *
00221  * Revision 1.33  2002/08/29 06:54:52  robertj
00222  * Removed redundent thread member variable from request info.
00223  *
00224  * Revision 1.32  2002/08/12 08:12:45  robertj
00225  * Added extra hint to help with ARQ using separate credentials from RRQ.
00226  *
00227  * Revision 1.31  2002/08/12 05:38:20  robertj
00228  * Changes to the RAS subsystem to support ability to make requests to client
00229  *   from gkserver without causing bottlenecks and race conditions.
00230  *
00231  * Revision 1.30  2002/08/05 10:03:47  robertj
00232  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00233  *
00234  * Revision 1.29  2002/08/05 05:17:37  robertj
00235  * Fairly major modifications to support different authentication credentials
00236  *   in ARQ to the logged in ones on RRQ. For both client and server.
00237  * Various other H.235 authentication bugs and anomalies fixed on the way.
00238  *
00239  * Revision 1.28  2002/07/16 13:49:22  robertj
00240  * Added missing lock when removing call from endpoint.
00241  *
00242  * Revision 1.27  2002/07/11 09:33:56  robertj
00243  * Added access functions to various call statistics member variables.
00244  *
00245  * Revision 1.26  2002/07/11 07:01:37  robertj
00246  * Added Disengage() function to force call drop from gk server.
00247  * Added InfoRequest() function to force client to send an IRR.
00248  * Added ability to automatically clear calls if do not get IRR for it.
00249  *
00250  * Revision 1.25  2002/06/21 02:52:44  robertj
00251  * Fixed problem with double checking H.235 hashing, this causes failure as
00252  *   the authenticator thinks it is a replay attack.
00253  *
00254  * Revision 1.24  2002/06/19 05:03:08  robertj
00255  * Changed gk code to allow for H.235 security on an endpoint by endpoint basis.
00256  *
00257  * Revision 1.23  2002/06/12 03:55:21  robertj
00258  * Added function to add/remove multiple listeners in one go comparing against
00259  *   what is already running so does not interrupt unchanged listeners.
00260  *
00261  * Revision 1.22  2002/05/29 00:03:15  robertj
00262  * Fixed unsolicited IRR support in gk client and server,
00263  *   including support for IACK and INAK.
00264  *
00265  * Revision 1.21  2002/05/21 06:30:31  robertj
00266  * Changed GRQ to the same as all the other xRQ request handlers.
00267  *
00268  * Revision 1.20  2002/05/17 03:42:08  robertj
00269  * Fixed problems with H.235 authentication on RAS for server and client.
00270  *
00271  * Revision 1.19  2002/05/07 03:18:12  robertj
00272  * Added application info (name/version etc) into registered endpoint data.
00273  *
00274  * Revision 1.18  2002/05/06 00:56:37  robertj
00275  * Sizeable rewrite of gatekeeper server code to make more bulletproof against
00276  *   multithreaded operation. Especially when using slow response/RIP feature.
00277  * Also changed the call indexing to use call id and direction as key.
00278  *
00279  * Revision 1.17  2002/04/30 23:19:00  dereks
00280  * Fix documentation typos.
00281  *
00282  * Revision 1.16  2002/03/06 02:01:31  robertj
00283  * Fixed race condition when starting slow server response thread.
00284  *
00285  * Revision 1.15  2002/03/05 00:36:01  craigs
00286  * Added GetReplyAddress for H323GatekeeperRequest
00287  *
00288  * Revision 1.14  2002/03/03 21:34:50  robertj
00289  * Added gatekeeper monitor thread.
00290  *
00291  * Revision 1.13  2002/03/02 05:58:57  robertj
00292  * Fixed possible bandwidth leak (thanks Francisco Olarte Sanz) and in
00293  *   the process added OnBandwidth function to H323GatekeeperCall class.
00294  *
00295  * Revision 1.12  2002/03/01 04:09:09  robertj
00296  * Fixed problems with keeping track of calls. Calls are now indexed by call-id
00297  *   alone and maintain both endpoints of call in its structure. Fixes problem
00298  *   with calls form an endpoint to itself, and having two objects being tracked
00299  *   where there is really only one call.
00300  *
00301  * Revision 1.11  2002/02/04 05:21:13  robertj
00302  * Lots of changes to fix multithreaded slow response code (RIP).
00303  * Fixed problem with having two entries for same call in call list.
00304  *
00305  * Revision 1.10  2002/01/31 06:45:44  robertj
00306  * Added more checking for invalid list processing in calls database.
00307  *
00308  * Revision 1.9  2002/01/31 00:16:15  robertj
00309  * Removed const to allow things to compile!
00310  *
00311  * Revision 1.8  2001/12/15 08:08:52  robertj
00312  * Added alerting, connect and end of call times to be sent to RAS server.
00313  *
00314  * Revision 1.7  2001/12/14 06:40:47  robertj
00315  * Added call end reason codes in DisengageRequest for GK server use.
00316  *
00317  * Revision 1.6  2001/12/13 11:08:45  robertj
00318  * Significant changes to support slow request handling, automatically sending
00319  *   RIP and spawning thread to handle time consuming operation.
00320  *
00321  * Revision 1.5  2001/11/19 06:56:44  robertj
00322  * Added prefix strings for gateways registered with this gk, thanks Mikael Stolt
00323  *
00324  * Revision 1.4  2001/08/10 11:03:49  robertj
00325  * Major changes to H.235 support in RAS to support server.
00326  *
00327  * Revision 1.3  2001/08/06 07:44:52  robertj
00328  * Fixed problems with building without SSL
00329  *
00330  * Revision 1.2  2001/08/06 03:18:35  robertj
00331  * Fission of h323.h to h323ep.h & h323con.h, h323.h now just includes files.
00332  * Improved access to H.235 secure RAS functionality.
00333  * Changes to H.323 secure RAS contexts to help use with gk server.
00334  *
00335  * Revision 1.1  2001/07/24 02:30:55  robertj
00336  * Added gatekeeper RAS protocol server classes.
00337  *
00338  */
00339 
00340 #ifndef __OPAL_GKSERVER_H
00341 #define __OPAL_GKSERVER_H
00342 
00343 #ifdef P_USE_PRAGMA
00344 #pragma interface
00345 #endif
00346 
00347 #include "h323.h"
00348 #include "h323ep.h"
00349 #include "h225ras.h"
00350 #include "guid.h"
00351 #include "h235auth.h"
00352 #include "h323pdu.h"
00353 #include "h323trans.h"
00354 
00355 #include <ptlib/safecoll.h>
00356 
00357 class PASN_Sequence;
00358 class PASN_Choice;
00359 
00360 class H225_AliasAddress;
00361 class H225_ArrayOf_TransportAddress;
00362 class H225_GatekeeperIdentifier;
00363 class H225_EndpointIdentifier;
00364 class H225_InfoRequestResponse_perCallInfo_subtype;
00365 class H225_RasUsageInformation;
00366 
00367 class H323RegisteredEndPoint;
00368 class H323GatekeeperListener;
00369 class H323GatekeeperServer;
00370 class H323RasPDU;
00371 class H323PeerElement;
00372 
00373 
00374 class H323GatekeeperRequest : public H323Transaction
00375 {
00376     PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00377   public:
00382     H323GatekeeperRequest(
00383       H323GatekeeperListener & rasChannel,
00384       const H323RasPDU & pdu
00385     );
00387 
00388     virtual H323TransactionPDU * CreateRIP(
00389       unsigned sequenceNumber,
00390       unsigned delay
00391     ) const;
00392 
00393     virtual BOOL WritePDU(
00394       H323TransactionPDU & pdu
00395     );
00396     BOOL CheckCryptoTokens();
00397     BOOL CheckGatekeeperIdentifier();
00398     BOOL GetRegisteredEndPoint();
00399 
00400     virtual PString GetGatekeeperIdentifier() const = 0;
00401     virtual unsigned GetGatekeeperRejectTag() const = 0;
00402     virtual PString GetEndpointIdentifier() const = 0;
00403     virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00404     virtual unsigned GetSecurityRejectTag() const = 0;
00405 
00406     H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00407 
00408     PSafePtr<H323RegisteredEndPoint> endpoint;
00409 
00410   protected:
00411     H323GatekeeperListener & rasChannel;
00412 };
00413 
00414 
00415 class H323GatekeeperGRQ : public H323GatekeeperRequest
00416 {
00417     PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00418   public:
00419     H323GatekeeperGRQ(
00420       H323GatekeeperListener & listener,
00421       const H323RasPDU & pdu
00422     );
00423 
00424 #if PTRACING
00425     virtual const char * GetName() const;
00426 #endif
00427     virtual PString GetGatekeeperIdentifier() const;
00428     virtual unsigned GetGatekeeperRejectTag() const;
00429     virtual PString GetEndpointIdentifier() const;
00430     virtual unsigned GetRegisteredEndPointRejectTag() const;
00431     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00432     virtual unsigned GetSecurityRejectTag() const;
00433     virtual void SetRejectReason(
00434       unsigned reasonCode
00435     );
00436 
00437     H225_GatekeeperRequest & grq;
00438     H225_GatekeeperConfirm & gcf;
00439     H225_GatekeeperReject  & grj;
00440 
00441   protected:
00442     virtual Response OnHandlePDU();
00443 };
00444 
00445 
00446 class H323GatekeeperRRQ : public H323GatekeeperRequest
00447 {
00448     PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00449   public:
00450     H323GatekeeperRRQ(
00451       H323GatekeeperListener & listener,
00452       const H323RasPDU & pdu
00453     );
00454 
00455 #if PTRACING
00456     virtual const char * GetName() const;
00457 #endif
00458     virtual PString GetGatekeeperIdentifier() const;
00459     virtual unsigned GetGatekeeperRejectTag() const;
00460     virtual PString GetEndpointIdentifier() const;
00461     virtual unsigned GetRegisteredEndPointRejectTag() const;
00462     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00463     virtual unsigned GetSecurityRejectTag() const;
00464     virtual void SetRejectReason(
00465       unsigned reasonCode
00466     );
00467 
00468     H225_RegistrationRequest & rrq;
00469     H225_RegistrationConfirm & rcf;
00470     H225_RegistrationReject  & rrj;
00471 
00472   protected:
00473     virtual Response OnHandlePDU();
00474 };
00475 
00476 
00477 class H323GatekeeperURQ : public H323GatekeeperRequest
00478 {
00479     PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00480   public:
00481     H323GatekeeperURQ(
00482       H323GatekeeperListener & listener,
00483       const H323RasPDU & pdu
00484     );
00485 
00486 #if PTRACING
00487     virtual const char * GetName() const;
00488 #endif
00489     virtual PString GetGatekeeperIdentifier() const;
00490     virtual unsigned GetGatekeeperRejectTag() const;
00491     virtual PString GetEndpointIdentifier() const;
00492     virtual unsigned GetRegisteredEndPointRejectTag() const;
00493     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00494     virtual unsigned GetSecurityRejectTag() const;
00495     virtual void SetRejectReason(
00496       unsigned reasonCode
00497     );
00498 
00499     H225_UnregistrationRequest & urq;
00500     H225_UnregistrationConfirm & ucf;
00501     H225_UnregistrationReject  & urj;
00502 
00503   protected:
00504     virtual Response OnHandlePDU();
00505 };
00506 
00507 
00508 class H323GatekeeperARQ : public H323GatekeeperRequest
00509 {
00510     PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00511   public:
00512     H323GatekeeperARQ(
00513       H323GatekeeperListener & listener,
00514       const H323RasPDU & pdu
00515     );
00516 
00517 #if PTRACING
00518     virtual const char * GetName() const;
00519 #endif
00520     virtual PString GetGatekeeperIdentifier() const;
00521     virtual unsigned GetGatekeeperRejectTag() const;
00522     virtual PString GetEndpointIdentifier() const;
00523     virtual unsigned GetRegisteredEndPointRejectTag() const;
00524     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00525     virtual unsigned GetSecurityRejectTag() const;
00526     virtual void SetRejectReason(
00527       unsigned reasonCode
00528     );
00529 
00530     H225_AdmissionRequest & arq;
00531     H225_AdmissionConfirm & acf;
00532     H225_AdmissionReject  & arj;
00533 
00534     PString alternateSecurityID;
00535 
00536   protected:
00537     virtual Response OnHandlePDU();
00538 };
00539 
00540 
00541 class H323GatekeeperDRQ : public H323GatekeeperRequest
00542 {
00543     PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00544   public:
00545     H323GatekeeperDRQ(
00546       H323GatekeeperListener & listener,
00547       const H323RasPDU & pdu
00548     );
00549 
00550 #if PTRACING
00551     virtual const char * GetName() const;
00552 #endif
00553     virtual PString GetGatekeeperIdentifier() const;
00554     virtual unsigned GetGatekeeperRejectTag() const;
00555     virtual PString GetEndpointIdentifier() const;
00556     virtual unsigned GetRegisteredEndPointRejectTag() const;
00557     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00558     virtual unsigned GetSecurityRejectTag() const;
00559     virtual void SetRejectReason(
00560       unsigned reasonCode
00561     );
00562 
00563     H225_DisengageRequest & drq;
00564     H225_DisengageConfirm & dcf;
00565     H225_DisengageReject  & drj;
00566 
00567   protected:
00568     virtual Response OnHandlePDU();
00569 };
00570 
00571 
00572 class H323GatekeeperBRQ : public H323GatekeeperRequest
00573 {
00574     PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00575   public:
00576     H323GatekeeperBRQ(
00577       H323GatekeeperListener & listener,
00578       const H323RasPDU & pdu
00579     );
00580 
00581 #if PTRACING
00582     virtual const char * GetName() const;
00583 #endif
00584     virtual PString GetGatekeeperIdentifier() const;
00585     virtual unsigned GetGatekeeperRejectTag() const;
00586     virtual PString GetEndpointIdentifier() const;
00587     virtual unsigned GetRegisteredEndPointRejectTag() const;
00588     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00589     virtual unsigned GetSecurityRejectTag() const;
00590     virtual void SetRejectReason(
00591       unsigned reasonCode
00592     );
00593 
00594     H225_BandwidthRequest & brq;
00595     H225_BandwidthConfirm & bcf;
00596     H225_BandwidthReject  & brj;
00597 
00598   protected:
00599     virtual Response OnHandlePDU();
00600 };
00601 
00602 
00603 class H323GatekeeperLRQ : public H323GatekeeperRequest
00604 {
00605     PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00606   public:
00607     H323GatekeeperLRQ(
00608       H323GatekeeperListener & listener,
00609       const H323RasPDU & pdu
00610     );
00611 
00612 #if PTRACING
00613     virtual const char * GetName() const;
00614 #endif
00615     virtual PString GetGatekeeperIdentifier() const;
00616     virtual unsigned GetGatekeeperRejectTag() const;
00617     virtual PString GetEndpointIdentifier() const;
00618     virtual unsigned GetRegisteredEndPointRejectTag() const;
00619     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00620     virtual unsigned GetSecurityRejectTag() const;
00621     virtual void SetRejectReason(
00622       unsigned reasonCode
00623     );
00624 
00625     H225_LocationRequest & lrq;
00626     H225_LocationConfirm & lcf;
00627     H225_LocationReject  & lrj;
00628 
00629   protected:
00630     virtual Response OnHandlePDU();
00631 };
00632 
00633 
00634 class H323GatekeeperIRR : public H323GatekeeperRequest
00635 {
00636     PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00637   public:
00638     H323GatekeeperIRR(
00639       H323GatekeeperListener & listener,
00640       const H323RasPDU & pdu
00641     );
00642 
00643 #if PTRACING
00644     virtual const char * GetName() const;
00645 #endif
00646     virtual PString GetGatekeeperIdentifier() const;
00647     virtual unsigned GetGatekeeperRejectTag() const;
00648     virtual PString GetEndpointIdentifier() const;
00649     virtual unsigned GetRegisteredEndPointRejectTag() const;
00650     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00651     virtual unsigned GetSecurityRejectTag() const;
00652     virtual void SetRejectReason(
00653       unsigned reasonCode
00654     );
00655 
00656     H225_InfoRequestResponse & irr;
00657     H225_InfoRequestAck      & iack;
00658     H225_InfoRequestNak      & inak;
00659 
00660   protected:
00661     virtual Response OnHandlePDU();
00662 };
00663 
00664 
00667 class H323GatekeeperCall : public PSafeObject
00668 {
00669     PCLASSINFO(H323GatekeeperCall, PSafeObject);
00670   public:
00673     enum Direction {
00674       AnsweringCall,
00675       OriginatingCall,
00676       UnknownDirection
00677     };
00678 
00681     H323GatekeeperCall(
00682       H323GatekeeperServer & server,               
00683       const OpalGloballyUniqueID & callIdentifier, 
00684       Direction direction                          
00685     );
00686 
00689     ~H323GatekeeperCall();
00691 
00696     Comparison Compare(
00697       const PObject & obj  
00698     ) const;
00699 
00702     void PrintOn(
00703       ostream & strm    
00704     ) const;
00706 
00714     virtual H323GatekeeperRequest::Response OnAdmission(
00715       H323GatekeeperARQ & request
00716     );
00717 
00721     virtual BOOL Disengage(
00722       int reason = -1   
00723     );
00724 
00728     virtual H323GatekeeperRequest::Response OnDisengage(
00729       H323GatekeeperDRQ & request
00730     );
00731 
00736     virtual H323GatekeeperRequest::Response OnBandwidth(
00737       H323GatekeeperBRQ & request
00738     );
00739 
00743     virtual H323GatekeeperRequest::Response OnInfoResponse(
00744       H323GatekeeperIRR & request,
00745       H225_InfoRequestResponse_perCallInfo_subtype & call
00746     );
00747 
00750     virtual void OnAlerting();
00751 
00754     virtual void OnConnected();
00755 
00766     virtual BOOL OnHeartbeat();
00767 
00768 #ifdef H323_H248
00769 
00776     virtual PString GetCallCreditAmount() const;
00777 
00784     virtual BOOL GetCallCreditMode() const;
00785 
00793     virtual unsigned GetDurationLimit() const;
00794 
00799     virtual BOOL SendCallCreditServiceControl();
00800 
00803     BOOL AddCallCreditServiceControl(
00804       H225_ArrayOf_ServiceControlSession & serviceControl
00805     ) const;
00806 
00811     virtual BOOL SendServiceControlSession(
00812       const H323ServiceControlSession & session
00813     );
00814 
00815 #endif // H323_H248
00816 
00822     virtual BOOL TranslateAliasAddress(
00823       const H225_AliasAddress & alias,
00824       H225_ArrayOf_AliasAddress & aliases,
00825       H323TransportAddress & address,
00826       BOOL & isGkRouted
00827     );
00828 
00830 
00833     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00834     H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00835     BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00836     unsigned GetCallReference() const { return callReference; }
00837     const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00838     const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00839     const PString & GetSourceNumber() const { return srcNumber; }
00840     const PStringArray & GetSourceAliases() const { return srcAliases; }
00841     const H323TransportAddress & GetSourceHost() const { return srcHost; }
00842     PString GetSourceAddress() const;
00843     const PString & GetDestinationNumber() const { return dstNumber; }
00844     const PStringArray & GetDestinationAliases() const { return dstAliases; }
00845     const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00846     PString GetDestinationAddress() const;
00847     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00848     BOOL SetBandwidthUsed(unsigned bandwidth);
00849     const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00850     const PTime & GetCallStartTime() const { return callStartTime; }
00851     const PTime & GetAlertingTime() const { return alertingTime; }
00852     const PTime & GetConnectedTime() const { return connectedTime; }
00853     const PTime & GetCallEndTime() const { return callEndTime; }
00854     H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00856 
00857   protected:
00858     void SetUsageInfo(const H225_RasUsageInformation & usage);
00859 
00860     H323GatekeeperServer   & gatekeeper;
00861     H323RegisteredEndPoint * endpoint;
00862     H323GatekeeperListener * rasChannel;
00863 
00864     Direction            direction;
00865     unsigned             callReference;
00866     OpalGloballyUniqueID callIdentifier;
00867     OpalGloballyUniqueID conferenceIdentifier;
00868     PString              srcNumber;
00869     PStringArray         srcAliases;
00870     H323TransportAddress srcHost;
00871     PString              dstNumber;
00872     PStringArray         dstAliases;
00873     H323TransportAddress dstHost;
00874     unsigned             bandwidthUsed;
00875     unsigned             infoResponseRate;
00876     PTime                lastInfoResponse;
00877 
00878     BOOL                          drqReceived;
00879     PTime                         callStartTime;
00880     PTime                         alertingTime;
00881     PTime                         connectedTime;
00882     PTime                         callEndTime;
00883     H323Connection::CallEndReason callEndReason;
00884 };
00885 
00886 
00892 class H323RegisteredEndPoint : public PSafeObject
00893 {
00894     PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00895   public:
00900     H323RegisteredEndPoint(
00901       H323GatekeeperServer & server, 
00902       const PString & id             
00903     );
00905 
00910     Comparison Compare(
00911       const PObject & obj  
00912     ) const;
00913 
00916     void PrintOn(
00917       ostream & strm    
00918     ) const;
00920 
00927     virtual void AddCall(
00928       H323GatekeeperCall * call
00929     );
00930 
00935     virtual BOOL RemoveCall(
00936       H323GatekeeperCall * call
00937     );
00938 
00941     PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00942 
00945     H323GatekeeperCall & GetCall(
00946       PINDEX idx
00947     ) { return activeCalls[idx]; }
00949 
00958     virtual H323GatekeeperRequest::Response OnRegistration(
00959       H323GatekeeperRRQ & request
00960     );
00961 
00971     virtual H323GatekeeperRequest::Response OnFullRegistration(
00972       H323GatekeeperRRQ & request
00973     );
00974 
00983     virtual H323GatekeeperRequest::Response OnSecureRegistration(
00984       H323GatekeeperRRQ & request
00985     );
00986 
00990     virtual H323GatekeeperRequest::Response OnUnregistration(
00991       H323GatekeeperURQ & request
00992     );
00993 
00997     virtual BOOL Unregister(
00998       int reason = -1   
00999     );
01000 
01005     virtual H323GatekeeperRequest::Response OnInfoResponse(
01006       H323GatekeeperIRR & request
01007     );
01008 
01019     virtual BOOL OnTimeToLive();
01020 
01021 #ifdef H323_H248
01022 
01034     virtual PString GetCallCreditAmount() const;
01035 
01043     virtual BOOL GetCallCreditMode() const;
01044 
01049     virtual BOOL SendServiceControlSession(
01050       const H323ServiceControlSession & session
01051     );
01052 
01056     virtual BOOL AddServiceControlSession(
01057       const H323ServiceControlSession & session,
01058       H225_ArrayOf_ServiceControlSession & serviceControl
01059     );
01060 #endif // H323_H248
01061 
01062 
01067     virtual BOOL SetPassword(
01068       const PString & password,
01069       const PString & username = PString::Empty()
01070     );
01071 
01074     const PString & GetIdentifier() const { return identifier; }
01075 
01078     const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01079 
01082     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01083 
01087     const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01088 
01092     PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01093 
01097     H323TransportAddress GetRASAddress(
01098       PINDEX idx
01099     ) const { return rasAddresses[idx]; }
01100 
01104     const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01105 
01109     PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01110 
01114     H323TransportAddress GetSignalAddress(
01115       PINDEX idx
01116     ) const { return signalAddresses[idx]; }
01117 
01120     const PStringArray & GetAliases() const { return aliases; }
01121 
01124     BOOL ContainsAlias(
01125       const PString & alias
01126       ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01127 
01130     PINDEX GetAliasCount() const { return aliases.GetSize(); }
01131 
01134     PString GetAlias(
01135       PINDEX idx
01136     ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01137 
01143     void RemoveAlias(
01144       const PString & alias
01145     );
01146 
01149     virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01150 
01153     PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01154 
01157     PString GetPrefix(
01158       PINDEX idx
01159     ) const { return voicePrefixes[idx]; }
01160 
01163     const PCaselessString & GetApplicationInfo() const { return applicationInfo; }
01164 
01167     unsigned GetProtocolVersion() const { return protocolVersion; }
01168 
01171     BOOL IsBehindNAT() const { return isBehindNAT; }
01172 
01175     BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01176 
01179     BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01180 
01183     BOOL CanReceiveRIP() const;
01184 
01187     BOOL GetH225Version() const { return h225Version; }
01189 
01190 #ifdef H323_H501
01191 
01200       virtual BOOL OnSendDescriptorForEndpoint(
01201         H225_ArrayOf_AliasAddress & aliases,          
01202         H225_EndpointType & terminalType,             
01203         H225_ArrayOf_AliasAddress & transportAddresses  
01204       );
01206 #endif
01207 
01208 
01209   protected:
01210     H323GatekeeperServer    & gatekeeper;
01211     H323GatekeeperListener  * rasChannel;
01212 
01213     PString                   identifier;
01214     OpalGloballyUniqueID      descriptorID;
01215     H323TransportAddressArray rasAddresses;
01216     H323TransportAddressArray signalAddresses;
01217     PStringArray              aliases;
01218     PStringArray              voicePrefixes;
01219     PCaselessString           applicationInfo;
01220     unsigned                  protocolVersion;
01221     BOOL                      isBehindNAT;
01222     BOOL                      canDisplayAmountString;
01223     BOOL                      canEnforceDurationLimit;
01224     unsigned                  h225Version;
01225     unsigned                  timeToLive;
01226     H235Authenticators        authenticators;
01227 
01228     PTime lastRegistration;
01229     PTime lastInfoResponse;
01230 
01231     PSortedList<H323GatekeeperCall> activeCalls;
01232 #ifdef H323_H248
01233     POrdinalDictionary<PString>     serviceControlSessions;
01234 #endif
01235 };
01236 
01237 
01243 class H323GatekeeperListener : public H225_RAS
01244 {
01245     PCLASSINFO(H323GatekeeperListener, H225_RAS);
01246   public:
01251     H323GatekeeperListener(
01252       H323EndPoint & endpoint,               
01253       H323GatekeeperServer & server,         
01254       const PString & gatekeeperIdentifier,  
01255       H323Transport * transport = NULL       
01256     );
01257 
01260     ~H323GatekeeperListener();
01262 
01267     BOOL UnregistrationRequest(
01268       const H323RegisteredEndPoint & ep,
01269       unsigned reason
01270     );
01271 
01274     BOOL DisengageRequest(
01275       const H323GatekeeperCall & call,
01276       unsigned reason
01277     );
01278 
01281     virtual BOOL InfoRequest(
01282       H323RegisteredEndPoint & ep,
01283       H323GatekeeperCall * call = NULL
01284     );
01285 
01286 #ifdef H323_H248
01287 
01289     virtual BOOL ServiceControlIndication(
01290       H323RegisteredEndPoint & ep,
01291       const H323ServiceControlSession & session,
01292       H323GatekeeperCall * call = NULL
01293     );
01294 #endif
01295 
01296 
01303     virtual H323GatekeeperRequest::Response OnDiscovery(
01304       H323GatekeeperGRQ & request
01305     );
01306 
01311     virtual H323GatekeeperRequest::Response OnRegistration(
01312       H323GatekeeperRRQ & request
01313     );
01314 
01319     virtual H323GatekeeperRequest::Response OnUnregistration(
01320       H323GatekeeperURQ & request
01321     );
01322 
01327     virtual H323GatekeeperRequest::Response OnAdmission(
01328       H323GatekeeperARQ & request
01329     );
01330 
01335     virtual H323GatekeeperRequest::Response OnDisengage(
01336       H323GatekeeperDRQ & request
01337     );
01338 
01343     virtual H323GatekeeperRequest::Response OnBandwidth(
01344       H323GatekeeperBRQ & request
01345     );
01346 
01351     virtual H323GatekeeperRequest::Response OnLocation(
01352       H323GatekeeperLRQ & request
01353     );
01354 
01359     virtual H323GatekeeperRequest::Response OnInfoResponse(
01360       H323GatekeeperIRR & request
01361     );
01363 
01366     BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01367     BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01368     BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01369     BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01370     BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01371     BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01372     BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01373     BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01374     BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01375     BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01376     BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01377     BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01378     BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01379     BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01380     BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01381     BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01382     void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01384 
01387     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01389 
01390 
01391   protected:
01392     H323GatekeeperServer & gatekeeper;
01393 };
01394 
01395 
01406 class H323GatekeeperServer : public H323TransactionServer
01407 {
01408     PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01409   public:
01414     H323GatekeeperServer(
01415       H323EndPoint & endpoint
01416     );
01417 
01420     ~H323GatekeeperServer();
01422 
01423     WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01424 
01435     virtual H323Transactor * CreateListener(
01436       H323Transport * transport  
01437     );
01438 
01440 
01446     virtual H323GatekeeperRequest::Response OnDiscovery(
01447       H323GatekeeperGRQ & request
01448     );
01449 
01457     virtual H323GatekeeperRequest::Response OnRegistration(
01458       H323GatekeeperRRQ & request
01459     );
01460 
01466     virtual H323GatekeeperRequest::Response OnUnregistration(
01467       H323GatekeeperURQ & request
01468     );
01469 
01474     virtual H323GatekeeperRequest::Response OnInfoResponse(
01475       H323GatekeeperIRR & request
01476     );
01477 
01488     virtual void AddEndPoint(
01489       H323RegisteredEndPoint * ep
01490     );
01491 
01494     virtual BOOL RemoveEndPoint(
01495       H323RegisteredEndPoint * ep
01496     );
01497 
01506     virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01507       H323GatekeeperRRQ & request
01508     );
01509 
01518     virtual PString CreateEndPointIdentifier();
01519 
01522     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01523       const PString & identifier,
01524       PSafetyMode mode = PSafeReference
01525     );
01526 
01529     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01530       const H225_ArrayOf_TransportAddress & addresses,
01531       PSafetyMode mode = PSafeReference
01532     );
01533 
01536     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01537       const H323TransportAddress & address,
01538       PSafetyMode mode = PSafeReference
01539     );
01540 
01543     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01544       const H225_AliasAddress & alias,
01545       PSafetyMode mode = PSafeReadWrite
01546     );
01547 
01550     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01551       const PString & alias,
01552       PSafetyMode mode = PSafeReference
01553     );
01554 
01557     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01558       const PString & alias,
01559       PSafetyMode mode = PSafeReference
01560     );
01561 
01564     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01565       const PString & prefix,
01566       PSafetyMode mode = PSafeReference
01567     );
01568 
01571     PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01572       PSafetyMode mode = PSafeReference
01573     ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01575 
01576     PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01577       const OpalGloballyUniqueID & id, 
01578       H323GatekeeperCall::Direction direction
01579     );
01580     
01588     virtual H323GatekeeperRequest::Response OnAdmission(
01589       H323GatekeeperARQ & request
01590     );
01591 
01596     virtual H323GatekeeperRequest::Response OnDisengage(
01597       H323GatekeeperDRQ & request
01598     );
01599 
01604     virtual H323GatekeeperRequest::Response OnBandwidth(
01605       H323GatekeeperBRQ & request
01606     );
01607 
01616     virtual H323GatekeeperCall * CreateCall(
01617       const OpalGloballyUniqueID & callIdentifier,
01618       H323GatekeeperCall::Direction direction
01619     );
01620 
01623     virtual void AddCall(H323GatekeeperCall *) 
01624     { }
01625 
01628     virtual void RemoveCall(
01629       H323GatekeeperCall * call
01630     );
01631 
01634     virtual PSafePtr<H323GatekeeperCall> FindCall(
01635       const PString & description,
01636       PSafetyMode mode = PSafeReference
01637     );
01638 
01641     virtual PSafePtr<H323GatekeeperCall> FindCall(
01642       const OpalGloballyUniqueID & callIdentifier,
01643       BOOL answeringCall,
01644       PSafetyMode mode = PSafeReference
01645     );
01646 
01649     virtual PSafePtr<H323GatekeeperCall> FindCall(
01650       const OpalGloballyUniqueID & callIdentifier,
01651       H323GatekeeperCall::Direction direction,
01652       PSafetyMode mode = PSafeReference
01653     );
01654 
01657     PSafePtr<H323GatekeeperCall> GetFirstCall(
01658       PSafetyMode mode = PSafeReference
01659     ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01660 
01661 
01663 
01673     virtual H323GatekeeperRequest::Response OnLocation(
01674       H323GatekeeperLRQ & request
01675     );
01676 
01688     virtual BOOL TranslateAliasAddress(
01689       const H225_AliasAddress & alias,
01690       H225_ArrayOf_AliasAddress & aliases,
01691       H323TransportAddress & address,
01692       BOOL & isGkRouted,
01693       H323GatekeeperCall * call
01694     );
01695     virtual BOOL TranslateAliasAddressToSignalAddress(
01696       const H225_AliasAddress & alias,
01697       H323TransportAddress & address
01698     );
01699 
01701 
01713     virtual BOOL CheckSignalAddressPolicy(
01714       const H323RegisteredEndPoint & ep,
01715       const H225_AdmissionRequest & arq,
01716       const H323TransportAddress & address
01717     );
01718 
01731     virtual BOOL CheckAliasAddressPolicy(
01732       const H323RegisteredEndPoint & ep,
01733       const H225_AdmissionRequest & arq,
01734       const H225_AliasAddress & alias
01735     );
01736 
01749     virtual BOOL CheckAliasStringPolicy(
01750       const H323RegisteredEndPoint & ep,
01751       const H225_AdmissionRequest & arq,
01752       const PString & alias
01753     );
01754 
01760     virtual unsigned AllocateBandwidth(
01761       unsigned newBandwidth,
01762       unsigned oldBandwidth = 0
01763     );
01765 
01777     virtual BOOL GetAdmissionRequestAuthentication(
01778       H323GatekeeperARQ & info,           
01779       H235Authenticators & authenticators 
01780     );
01781 
01787     virtual BOOL GetUsersPassword(
01788       const PString & alias,
01789       PString & password,
01790       H323RegisteredEndPoint & registeredEndpoint
01791     ) const;
01792     virtual BOOL GetUsersPassword(
01793       const PString & alias,
01794       PString & password
01795     ) const;
01797 
01798 #ifdef H323_H501
01799 
01804     H323PeerElement * GetPeerElement() const { return peerElement; }
01805 
01809     void SetPeerElement(
01810       H323PeerElement * newPeerElement
01811     );
01812 
01818     void CreatePeerElement(
01819       const H323TransportAddress & h501Interface
01820     );
01821 
01827     BOOL OpenPeerElement(
01828       const H323TransportAddress & remotePeer,
01829       BOOL append = FALSE,
01830       BOOL keepTrying = TRUE
01831     );
01833 
01834 #endif // H323_H501
01835 
01840     const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01841 
01847     void SetGatekeeperIdentifier(
01848       const PString & id,
01849       BOOL adjustListeners = TRUE
01850     );
01851 
01854     unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01855 
01858     void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01859 
01862     unsigned GetUsedBandwidth() const { return usedBandwidth; }
01863 
01866     unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01867 
01870     unsigned GetTimeToLive() const { return defaultTimeToLive; }
01871 
01874     void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01875 
01878     unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01879 
01882     void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01883 
01886     BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01887 
01890     BOOL IsRequiredH235() const { return requireH235; }
01891 
01894     unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01895 
01898     unsigned GetPeakRegistrations() const { return peakRegistrations; }
01899 
01902     unsigned GetTotalRegistrations() const { return totalRegistrations; }
01903 
01906     unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01907 
01910     unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01911 
01914     unsigned GetPeakCalls() const { return peakCalls; }
01915 
01918     unsigned GetTotalCalls() const { return totalCalls; }
01919 
01922     unsigned GetRejectedCalls() const { return rejectedCalls; }
01924 
01925     // Remove an alias from the server database.
01926     void RemoveAlias(
01927       H323RegisteredEndPoint & ep,
01928       const PString & alias
01929     );
01930 
01931 #ifdef H323_H501
01932     // called when an endpoint needs to send a descriptor to the H.501 peer element
01933     virtual BOOL OnSendDescriptorForEndpoint(
01934       H323RegisteredEndPoint & /*ep*/,                    
01935       H225_ArrayOf_AliasAddress & /*aliases*/,            
01936       H225_EndpointType & /*terminalType*/,               
01937       H225_ArrayOf_AliasAddress & /*transportAddresses*/  
01938     )
01939     { return TRUE; } 
01940 #endif
01941 
01942     virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & /*aliases*/)
01943     { return canHaveDuplicateAlias; }
01944 
01945     virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01946     virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01947 
01948   protected:
01949 
01950     PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01951 
01952     // Configuration & policy variables
01953     PString  gatekeeperIdentifier;
01954     unsigned totalBandwidth;
01955     unsigned usedBandwidth;
01956     unsigned defaultBandwidth;
01957     unsigned maximumBandwidth;
01958     unsigned defaultTimeToLive;
01959     unsigned defaultInfoResponseRate;
01960     BOOL     overwriteOnSameSignalAddress;
01961     BOOL     canHaveDuplicateAlias;
01962     BOOL     canHaveDuplicatePrefix;
01963     BOOL     canOnlyCallRegisteredEP;
01964     BOOL     canOnlyAnswerRegisteredEP;
01965     BOOL     answerCallPreGrantedARQ;
01966     BOOL     makeCallPreGrantedARQ;
01967     BOOL     isGatekeeperRouted;
01968     BOOL     aliasCanBeHostName;
01969     BOOL     requireH235;
01970     BOOL     disengageOnHearbeatFail;
01971 
01972     PStringToString passwords;
01973 
01974     // Dynamic variables
01975     PMutex         mutex;
01976     time_t         identifierBase;
01977     unsigned       nextIdentifier;
01978     PThread      * monitorThread;
01979     PSyncPoint     monitorExit;
01980 
01981     PLIST(ListenerList, H323GatekeeperListener);
01982     ListenerList listeners;
01983 
01984     H323PeerElement * peerElement;
01985 
01986     PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01987 
01988     class StringMap : public PString {
01989         PCLASSINFO(StringMap, PString);
01990       public:
01991         StringMap(const PString & from, const PString & id)
01992           : PString(from), identifier(id) { }
01993         PString identifier;
01994     };
01995     PSortedStringList byAddress;
01996     PSortedStringList byAlias;
01997     PSortedStringList byVoicePrefix;
01998 
01999     PSafeSortedList<H323GatekeeperCall> activeCalls;
02000 
02001     PINDEX peakRegistrations;
02002     PINDEX totalRegistrations;
02003     PINDEX rejectedRegistrations;
02004     PINDEX peakCalls;
02005     PINDEX totalCalls;
02006     PINDEX rejectedCalls;
02007 
02008   friend class H323GatekeeperRRQ;
02009   friend class H323GatekeeperARQ;
02010 };
02011 
02012 
02013 #endif // __OPAL_GKSERVER_H
02014 
02015 
02017 

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