gkserver.h

Go to the documentation of this file.
00001 /*
00002  * gkserver.h
00003  *
00004  * H225 Registration Admission and Security 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  * 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 2.17  2007/06/29 06:59:56  rjongbloed
00031  * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms.
00032  *
00033  * Revision 2.16  2006/08/21 04:52:40  csoutheren
00034  * Fixed spelling error in documentation
00035  *
00036  * Revision 2.15  2006/04/25 07:48:07  rjongbloed
00037  * Ported changes from OpenH323 gatekeeper server to OPAL code base.
00038  *
00039  * Revision 2.14  2006/01/02 15:51:44  dsandras
00040  * Merged changes from OpenH323 Atlas_devel_2.
00041  *
00042  * Revision 2.13  2005/11/30 13:35:26  csoutheren
00043  * Changed tags for Doxygen
00044  *
00045  * Revision 2.12  2004/06/04 06:54:02  csoutheren
00046  * Migrated updates from OpenH323 1.14.1
00047  *
00048  * Revision 2.11  2004/04/25 02:53:29  rjongbloed
00049  * Fixed GNU 3.4 warnings
00050  *
00051  * Revision 2.10  2004/02/19 10:46:43  rjongbloed
00052  * Merged OpenH323 version 1.13.1 changes.
00053  *
00054  * Revision 2.9  2003/01/07 04:39:52  robertj
00055  * Updated to OpenH323 v1.11.2
00056  *
00057  * Revision 2.8  2002/11/10 11:33:16  robertj
00058  * Updated to OpenH323 v1.10.3
00059  *
00060  * Revision 2.7  2002/09/16 02:52:33  robertj
00061  * Added #define so can select if #pragma interface/implementation is used on
00062  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00063  *
00064  * Revision 2.6  2002/09/04 06:01:46  robertj
00065  * Updated to OpenH323 v1.9.6
00066  *
00067  * Revision 2.5  2002/07/01 04:56:29  robertj
00068  * Updated to OpenH323 v1.9.1
00069  *
00070  * Revision 2.4  2002/03/22 06:57:48  robertj
00071  * Updated to OpenH323 version 1.8.2
00072  *
00073  * Revision 2.3  2002/02/11 09:32:11  robertj
00074  * Updated to openH323 v1.8.0
00075  *
00076  * Revision 2.2  2002/01/14 06:35:56  robertj
00077  * Updated to OpenH323 v1.7.9
00078  *
00079  * Revision 2.1  2001/08/13 05:10:39  robertj
00080  * Updates from OpenH323 v1.6.0 release.
00081  *
00082  * Revision 2.0  2001/07/27 15:48:24  robertj
00083  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00084  *
00085  * Revision 1.87  2005/11/30 13:05:01  csoutheren
00086  * Changed tags for Doxygen
00087  *
00088  * Revision 1.86  2005/01/03 14:03:19  csoutheren
00089  * Added new configure options and ability to disable/enable modules
00090  *
00091  * Revision 1.85  2005/01/03 06:25:52  csoutheren
00092  * Added extensive support for disabling code modules at compile time
00093  *
00094  * Revision 1.84  2004/12/14 06:22:20  csoutheren
00095  * More OSP implementation
00096  *
00097  * Revision 1.83  2004/09/03 01:06:08  csoutheren
00098  * Added initial hooks for H.460 GEF
00099  * Thanks to Simon Horne and ISVO (Asia) Pte Ltd. for this contribution
00100  *
00101  * Revision 1.82  2004/08/03 07:00:13  csoutheren
00102  * Added isGKRouted hint to TranslateAliasAddress as this is needed for the reply ACF
00103  *
00104  * Revision 1.81  2004/06/15 03:30:45  csoutheren
00105  * Adde guard to function to prevent crash if no aliases on an endpoint
00106  *
00107  * Revision 1.80  2004/06/04 07:05:07  csoutheren
00108  * Fixed obvious typos
00109  *
00110  * Revision 1.79  2004/04/25 01:52:46  rjongbloed
00111  * Fixed GCC 3.4 warnings
00112  *
00113  * Revision 1.78  2004/04/21 01:39:05  csoutheren
00114  * Added new overrides to GatekeeperServer to provide virtuals when calls and endpoints are created and destroyed
00115  *
00116  * Revision 1.77  2004/04/15 07:43:36  csoutheren
00117  * Allow gatekeeper to make a decision on multiple alias registrations for each registration
00118  *
00119  * Revision 1.76  2004/04/14 01:41:59  csoutheren
00120  * Added access to endpoint information for GetUserPassword
00121  *
00122  * Revision 1.75  2004/03/31 07:16:22  csoutheren
00123  * Added virtual to provide access to H.501 descriptor sent by GK
00124  *
00125  * Revision 1.74  2004/02/15 03:36:30  rjongbloed
00126  * Fixed bug in removing prefixes, plus added ability to have multiple endpoints
00127  *   with the same profix, thanks Rossano Ravelli
00128  *
00129  * Revision 1.73  2004/02/07 11:43:59  rjongbloed
00130  * Fixed deadlocks caused under high load by failure to check locking
00131  *   success. Also added functions to find destination endpoint.
00132  *   Thanks Federico Pinna and the gang at Reitek S.p.A.
00133  *
00134  * Revision 1.72  2003/12/24 07:08:47  csoutheren
00135  * Added TranslateAliasAddress on H323GatekeeperCall
00136  *
00137  * Revision 1.71  2003/12/11 05:39:04  csoutheren
00138  * Added storage of H.225 version in endpoint structure
00139  * Disabled sending RIPs to endpoints that cannot handle them
00140  *
00141  * Revision 1.70  2003/12/11 02:18:17  csoutheren
00142  * More fixes for NM deregistration problems. Seems to be fixed now :)
00143  *
00144  * Revision 1.69  2003/12/09 00:58:46  csoutheren
00145  * Fixed problem with endpoints deregistering
00146  *
00147  * Revision 1.68  2003/12/09 00:33:17  csoutheren
00148  * Added patch to prevent crash when NM unregisters from GK
00149  * Abject apologies to Rossano Ravelli for taking so long to add this
00150  *
00151  * Revision 1.67  2003/04/30 00:28:50  robertj
00152  * Redesigned the alternate credentials in ARQ system as old implementation
00153  *   was fraught with concurrency issues, most importantly it can cause false
00154  *   detection of replay attacks taking out an endpoint completely.
00155  *
00156  * Revision 1.66  2003/04/02 06:58:10  robertj
00157  * Added support for (optional) duplicate aliases in gatekeeper server, necessitating
00158  *   the removal of AddAlias and RemoveAlias functions.
00159  *
00160  * Revision 1.65  2003/04/02 06:07:12  robertj
00161  * Added H.323 Annex G Peer Element support to gatekeeper server.
00162  *
00163  * Revision 1.64  2003/04/01 07:30:52  robertj
00164  * Added function to translate alias into alias list and transport to make
00165  *   use of full information returned by peer element.
00166  *
00167  * Revision 1.63  2003/04/01 04:47:48  robertj
00168  * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in
00169  *   server environment for use by H.501 peer elements.
00170  *
00171  * Revision 1.62  2003/03/26 07:10:03  robertj
00172  * Added more access functions.
00173  *
00174  * Revision 1.61  2003/03/17 22:52:06  craigs
00175  * Improvided useability of AddAlias and RemoveAlias
00176  *
00177  * Revision 1.60  2003/03/04 05:34:13  robertj
00178  * Fixed GNU warnings
00179  *
00180  * Revision 1.59  2003/03/04 05:27:51  robertj
00181  * Added statistics for rejected registrations and call admissions.
00182  *
00183  * Revision 1.58  2003/03/03 06:59:26  robertj
00184  * Fixed call SetBandwidth function so adjusts global bandwidth as well.
00185  *
00186  * Revision 1.57  2003/02/21 07:21:40  robertj
00187  * Fixed incorrect ancestor in PCLASSINFO()
00188  *
00189  * Revision 1.56  2003/02/21 05:28:39  craigs
00190  * Factored out code for user with peer elements
00191  *
00192  * Revision 1.55  2003/02/06 04:43:14  robertj
00193  * Changes to help with endpoints behind NAT.
00194  *
00195  * Revision 1.54  2003/02/03 03:58:06  robertj
00196  * Fixed use of local password database with ep's that have multiple aliases.
00197  *
00198  * Revision 1.53  2003/02/01 13:31:14  robertj
00199  * Changes to support CAT authentication in RAS.
00200  *
00201  * Revision 1.52  2002/12/17 01:25:23  robertj
00202  * Added call backs on gk server when ep indicates alerting or connect.
00203  *
00204  * Revision 1.51  2002/11/28 05:45:46  robertj
00205  * Fixed bug so can set total bandwidth while calls are in progress.
00206  *
00207  * Revision 1.50  2002/11/28 04:41:44  robertj
00208  * Added support for RAS ServiceControlIndication command.
00209  *
00210  * Revision 1.49  2002/11/27 06:54:52  robertj
00211  * Added Service Control Session management as per Annex K/H.323 via RAS
00212  *   only at this stage.
00213  * Added H.248 ASN and very primitive infrastructure for linking into the
00214  *   Service Control Session management system.
00215  * Added basic infrastructure for Annex K/H.323 HTTP transport system.
00216  * Added Call Credit Service Control to display account balances.
00217  *
00218  * Revision 1.48  2002/11/22 00:11:29  robertj
00219  * Added call start time.
00220  *
00221  * Revision 1.47  2002/11/18 23:40:45  robertj
00222  * Changed to use the H323EndPoint::CreateAuthenticators() function, we
00223  *   should use only one.
00224  *
00225  * Revision 1.46  2002/11/12 11:36:03  robertj
00226  * Added function to find endpoint by partial alias.
00227  * Optimised endpoint "indexes" to use sorted lists instead of dictionaries.
00228  *
00229  * Revision 1.45  2002/11/06 23:23:48  robertj
00230  * Fixed minor error in parameter, should be reference not value
00231  *
00232  * Revision 1.44  2002/10/29 00:12:02  robertj
00233  * Changed template classes so things like PSafeList actually creates the
00234  *   base collection class as well.
00235  * Improved setting of usage info, included getting it from BRQ etc.
00236  *
00237  * Revision 1.43  2002/10/21 00:54:47  robertj
00238  * Added function to unregister an endpoint via user interface.
00239  * Added reason code to call disengage.
00240  * Added ability to find call by a description string.
00241  *
00242  * Revision 1.42  2002/10/17 05:26:33  robertj
00243  * Added function to get at registered endpoints protocol version.
00244  *
00245  * Revision 1.41  2002/10/16 07:22:50  robertj
00246  * Added support for endpoints that do not support RRQ timeToLive parameter,
00247  *   will actively go see if ep is there using IRQ before expiring the ep.
00248  *
00249  * Revision 1.40  2002/10/01 08:17:34  robertj
00250  * Fixed (benign) race condition between client and server both wanting to do
00251  *   a DRQ of a call at the same time. Caused an Assert, but no crash.
00252  *
00253  * Revision 1.39  2002/09/26 01:27:31  robertj
00254  * Changed appliation info name in registered endpoint to be caseless string.
00255  *
00256  * Revision 1.38  2002/09/24 08:03:51  robertj
00257  * Added H.225 RAS protocol version number to registered endpoint structure.
00258  *
00259  * Revision 1.37  2002/09/19 09:15:56  robertj
00260  * Fixed problem with making (and assuring with multi-threading) IRQ and DRQ
00261  *   requests are sent to the correct endpoint address, thanks Martijn Roest.
00262  *
00263  * Revision 1.36  2002/09/16 01:14:15  robertj
00264  * Added #define so can select if #pragma interface/implementation is used on
00265  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00266  *
00267  * Revision 1.35  2002/09/03 06:19:36  robertj
00268  * Normalised the multi-include header prevention ifdef/define symbol.
00269  *
00270  * Revision 1.34  2002/08/29 07:57:08  robertj
00271  * Added some statistics to gatekeeper server.
00272  *
00273  * Revision 1.33  2002/08/29 06:54:52  robertj
00274  * Removed redundent thread member variable from request info.
00275  *
00276  * Revision 1.32  2002/08/12 08:12:45  robertj
00277  * Added extra hint to help with ARQ using separate credentials from RRQ.
00278  *
00279  * Revision 1.31  2002/08/12 05:38:20  robertj
00280  * Changes to the RAS subsystem to support ability to make requests to client
00281  *   from gkserver without causing bottlenecks and race conditions.
00282  *
00283  * Revision 1.30  2002/08/05 10:03:47  robertj
00284  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00285  *
00286  * Revision 1.29  2002/08/05 05:17:37  robertj
00287  * Fairly major modifications to support different authentication credentials
00288  *   in ARQ to the logged in ones on RRQ. For both client and server.
00289  * Various other H.235 authentication bugs and anomalies fixed on the way.
00290  *
00291  * Revision 1.28  2002/07/16 13:49:22  robertj
00292  * Added missing lock when removing call from endpoint.
00293  *
00294  * Revision 1.27  2002/07/11 09:33:56  robertj
00295  * Added access functions to various call statistics member variables.
00296  *
00297  * Revision 1.26  2002/07/11 07:01:37  robertj
00298  * Added Disengage() function to force call drop from gk server.
00299  * Added InfoRequest() function to force client to send an IRR.
00300  * Added ability to automatically clear calls if do not get IRR for it.
00301  *
00302  * Revision 1.25  2002/06/21 02:52:44  robertj
00303  * Fixed problem with double checking H.235 hashing, this causes failure as
00304  *   the authenticator thinks it is a replay attack.
00305  *
00306  * Revision 1.24  2002/06/19 05:03:08  robertj
00307  * Changed gk code to allow for H.235 security on an endpoint by endpoint basis.
00308  *
00309  * Revision 1.23  2002/06/12 03:55:21  robertj
00310  * Added function to add/remove multiple listeners in one go comparing against
00311  *   what is already running so does not interrupt unchanged listeners.
00312  *
00313  * Revision 1.22  2002/05/29 00:03:15  robertj
00314  * Fixed unsolicited IRR support in gk client and server,
00315  *   including support for IACK and INAK.
00316  *
00317  * Revision 1.21  2002/05/21 06:30:31  robertj
00318  * Changed GRQ to the same as all the other xRQ request handlers.
00319  *
00320  * Revision 1.20  2002/05/17 03:42:08  robertj
00321  * Fixed problems with H.235 authentication on RAS for server and client.
00322  *
00323  * Revision 1.19  2002/05/07 03:18:12  robertj
00324  * Added application info (name/version etc) into registered endpoint data.
00325  *
00326  * Revision 1.18  2002/05/06 00:56:37  robertj
00327  * Sizeable rewrite of gatekeeper server code to make more bulletproof against
00328  *   multithreaded operation. Especially when using slow response/RIP feature.
00329  * Also changed the call indexing to use call id and direction as key.
00330  *
00331  * Revision 1.17  2002/04/30 23:19:00  dereks
00332  * Fix documentation typos.
00333  *
00334  * Revision 1.16  2002/03/06 02:01:31  robertj
00335  * Fixed race condition when starting slow server response thread.
00336  *
00337  * Revision 1.15  2002/03/05 00:36:01  craigs
00338  * Added GetReplyAddress for H323GatekeeperRequest
00339  *
00340  * Revision 1.14  2002/03/03 21:34:50  robertj
00341  * Added gatekeeper monitor thread.
00342  *
00343  * Revision 1.13  2002/03/02 05:58:57  robertj
00344  * Fixed possible bandwidth leak (thanks Francisco Olarte Sanz) and in
00345  *   the process added OnBandwidth function to H323GatekeeperCall class.
00346  *
00347  * Revision 1.12  2002/03/01 04:09:09  robertj
00348  * Fixed problems with keeping track of calls. Calls are now indexed by call-id
00349  *   alone and maintain both endpoints of call in its structure. Fixes problem
00350  *   with calls form an endpoint to itself, and having two objects being tracked
00351  *   where there is really only one call.
00352  *
00353  * Revision 1.11  2002/02/04 05:21:13  robertj
00354  * Lots of changes to fix multithreaded slow response code (RIP).
00355  * Fixed problem with having two entries for same call in call list.
00356  *
00357  * Revision 1.10  2002/01/31 06:45:44  robertj
00358  * Added more checking for invalid list processing in calls database.
00359  *
00360  * Revision 1.9  2002/01/31 00:16:15  robertj
00361  * Removed const to allow things to compile!
00362  *
00363  * Revision 1.8  2001/12/15 08:08:52  robertj
00364  * Added alerting, connect and end of call times to be sent to RAS server.
00365  *
00366  * Revision 1.7  2001/12/14 06:40:47  robertj
00367  * Added call end reason codes in DisengageRequest for GK server use.
00368  *
00369  * Revision 1.6  2001/12/13 11:08:45  robertj
00370  * Significant changes to support slow request handling, automatically sending
00371  *   RIP and spawning thread to handle time consuming operation.
00372  *
00373  * Revision 1.5  2001/11/19 06:56:44  robertj
00374  * Added prefix strings for gateways registered with this gk, thanks Mikael Stolt
00375  *
00376  * Revision 1.4  2001/08/10 11:03:49  robertj
00377  * Major changes to H.235 support in RAS to support server.
00378  *
00379  * Revision 1.3  2001/08/06 07:44:52  robertj
00380  * Fixed problems with building without SSL
00381  *
00382  * Revision 1.2  2001/08/06 03:18:35  robertj
00383  * Fission of h323.h to h323ep.h & h323con.h, h323.h now just includes files.
00384  * Improved access to H.235 secure RAS functionality.
00385  * Changes to H.323 secure RAS contexts to help use with gk server.
00386  *
00387  * Revision 1.1  2001/07/24 02:30:55  robertj
00388  * Added gatekeeper RAS protocol server classes.
00389  *
00390  */
00391 
00392 #ifndef __OPAL_GKSERVER_H
00393 #define __OPAL_GKSERVER_H
00394 
00395 #ifdef P_USE_PRAGMA
00396 #pragma interface
00397 #endif
00398 
00399 
00400 #include <ptlib/safecoll.h>
00401 #include <opal/guid.h>
00402 #include <h323/h225ras.h>
00403 #include <h323/transaddr.h>
00404 #include <h323/h235auth.h>
00405 #include <h323/h323pdu.h>
00406 #include <h323/h323trans.h>
00407 
00408 
00409 class PASN_Sequence;
00410 class PASN_Choice;
00411 
00412 class H225_AliasAddress;
00413 class H225_EndpointIdentifier;
00414 class H225_GatekeeperIdentifier;
00415 class H225_ArrayOf_TransportAddress;
00416 class H225_GatekeeperIdentifier;
00417 class H225_EndpointIdentifier;
00418 class H225_InfoRequestResponse_perCallInfo_subtype;
00419 class H225_RasUsageInformation;
00420 
00421 class H323RegisteredEndPoint;
00422 class H323GatekeeperListener;
00423 class H323GatekeeperServer;
00424 class H323RasPDU;
00425 class H323PeerElement;
00426 
00427 
00428 class H323GatekeeperRequest : public H323Transaction
00429 {
00430     PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00431   public:
00436     H323GatekeeperRequest(
00437       H323GatekeeperListener & rasChannel,
00438       const H323RasPDU & pdu
00439     );
00441 
00442     virtual H323TransactionPDU * CreateRIP(
00443       unsigned sequenceNumber,
00444       unsigned delay
00445     ) const;
00446 
00447     virtual BOOL WritePDU(
00448       H323TransactionPDU & pdu
00449     );
00450     BOOL CheckCryptoTokens();
00451     BOOL CheckGatekeeperIdentifier();
00452     BOOL GetRegisteredEndPoint();
00453 
00454     virtual PString GetGatekeeperIdentifier() const = 0;
00455     virtual unsigned GetGatekeeperRejectTag() const = 0;
00456     virtual PString GetEndpointIdentifier() const = 0;
00457     virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00458     virtual unsigned GetSecurityRejectTag() const = 0;
00459 
00460     H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00461 
00462     PSafePtr<H323RegisteredEndPoint> endpoint;
00463 
00464   protected:
00465     H323GatekeeperListener & rasChannel;
00466 };
00467 
00468 
00469 class H323GatekeeperGRQ : public H323GatekeeperRequest
00470 {
00471     PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00472   public:
00473     H323GatekeeperGRQ(
00474       H323GatekeeperListener & listener,
00475       const H323RasPDU & pdu
00476     );
00477 
00478 #if PTRACING
00479     virtual const char * GetName() const;
00480 #endif
00481     virtual PString GetGatekeeperIdentifier() const;
00482     virtual unsigned GetGatekeeperRejectTag() const;
00483     virtual PString GetEndpointIdentifier() const;
00484     virtual unsigned GetRegisteredEndPointRejectTag() const;
00485     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00486     virtual unsigned GetSecurityRejectTag() const;
00487     virtual void SetRejectReason(
00488       unsigned reasonCode
00489     );
00490 
00491     H225_GatekeeperRequest & grq;
00492     H225_GatekeeperConfirm & gcf;
00493     H225_GatekeeperReject  & grj;
00494 
00495   protected:
00496     virtual Response OnHandlePDU();
00497 };
00498 
00499 
00500 class H323GatekeeperRRQ : public H323GatekeeperRequest
00501 {
00502     PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00503   public:
00504     H323GatekeeperRRQ(
00505       H323GatekeeperListener & listener,
00506       const H323RasPDU & pdu
00507     );
00508 
00509 #if PTRACING
00510     virtual const char * GetName() const;
00511 #endif
00512     virtual PString GetGatekeeperIdentifier() const;
00513     virtual unsigned GetGatekeeperRejectTag() const;
00514     virtual PString GetEndpointIdentifier() const;
00515     virtual unsigned GetRegisteredEndPointRejectTag() const;
00516     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00517     virtual unsigned GetSecurityRejectTag() const;
00518     virtual void SetRejectReason(
00519       unsigned reasonCode
00520     );
00521 
00522     H225_RegistrationRequest & rrq;
00523     H225_RegistrationConfirm & rcf;
00524     H225_RegistrationReject  & rrj;
00525 
00526   protected:
00527     virtual Response OnHandlePDU();
00528 };
00529 
00530 
00531 class H323GatekeeperURQ : public H323GatekeeperRequest
00532 {
00533     PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00534   public:
00535     H323GatekeeperURQ(
00536       H323GatekeeperListener & listener,
00537       const H323RasPDU & pdu
00538     );
00539 
00540 #if PTRACING
00541     virtual const char * GetName() const;
00542 #endif
00543     virtual PString GetGatekeeperIdentifier() const;
00544     virtual unsigned GetGatekeeperRejectTag() const;
00545     virtual PString GetEndpointIdentifier() const;
00546     virtual unsigned GetRegisteredEndPointRejectTag() const;
00547     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00548     virtual unsigned GetSecurityRejectTag() const;
00549     virtual void SetRejectReason(
00550       unsigned reasonCode
00551     );
00552 
00553     H225_UnregistrationRequest & urq;
00554     H225_UnregistrationConfirm & ucf;
00555     H225_UnregistrationReject  & urj;
00556 
00557   protected:
00558     virtual Response OnHandlePDU();
00559 };
00560 
00561 
00562 class H323GatekeeperARQ : public H323GatekeeperRequest
00563 {
00564     PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00565   public:
00566     H323GatekeeperARQ(
00567       H323GatekeeperListener & listener,
00568       const H323RasPDU & pdu
00569     );
00570 
00571 #if PTRACING
00572     virtual const char * GetName() const;
00573 #endif
00574     virtual PString GetGatekeeperIdentifier() const;
00575     virtual unsigned GetGatekeeperRejectTag() const;
00576     virtual PString GetEndpointIdentifier() const;
00577     virtual unsigned GetRegisteredEndPointRejectTag() const;
00578     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00579     virtual unsigned GetSecurityRejectTag() const;
00580     virtual void SetRejectReason(
00581       unsigned reasonCode
00582     );
00583 
00584     H225_AdmissionRequest & arq;
00585     H225_AdmissionConfirm & acf;
00586     H225_AdmissionReject  & arj;
00587 
00588     PString alternateSecurityID;
00589 
00590   protected:
00591     virtual Response OnHandlePDU();
00592 };
00593 
00594 
00595 class H323GatekeeperDRQ : public H323GatekeeperRequest
00596 {
00597     PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00598   public:
00599     H323GatekeeperDRQ(
00600       H323GatekeeperListener & listener,
00601       const H323RasPDU & pdu
00602     );
00603 
00604 #if PTRACING
00605     virtual const char * GetName() const;
00606 #endif
00607     virtual PString GetGatekeeperIdentifier() const;
00608     virtual unsigned GetGatekeeperRejectTag() const;
00609     virtual PString GetEndpointIdentifier() const;
00610     virtual unsigned GetRegisteredEndPointRejectTag() const;
00611     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00612     virtual unsigned GetSecurityRejectTag() const;
00613     virtual void SetRejectReason(
00614       unsigned reasonCode
00615     );
00616 
00617     H225_DisengageRequest & drq;
00618     H225_DisengageConfirm & dcf;
00619     H225_DisengageReject  & drj;
00620 
00621   protected:
00622     virtual Response OnHandlePDU();
00623 };
00624 
00625 
00626 class H323GatekeeperBRQ : public H323GatekeeperRequest
00627 {
00628     PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00629   public:
00630     H323GatekeeperBRQ(
00631       H323GatekeeperListener & listener,
00632       const H323RasPDU & pdu
00633     );
00634 
00635 #if PTRACING
00636     virtual const char * GetName() const;
00637 #endif
00638     virtual PString GetGatekeeperIdentifier() const;
00639     virtual unsigned GetGatekeeperRejectTag() const;
00640     virtual PString GetEndpointIdentifier() const;
00641     virtual unsigned GetRegisteredEndPointRejectTag() const;
00642     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00643     virtual unsigned GetSecurityRejectTag() const;
00644     virtual void SetRejectReason(
00645       unsigned reasonCode
00646     );
00647 
00648     H225_BandwidthRequest & brq;
00649     H225_BandwidthConfirm & bcf;
00650     H225_BandwidthReject  & brj;
00651 
00652   protected:
00653     virtual Response OnHandlePDU();
00654 };
00655 
00656 
00657 class H323GatekeeperLRQ : public H323GatekeeperRequest
00658 {
00659     PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00660   public:
00661     H323GatekeeperLRQ(
00662       H323GatekeeperListener & listener,
00663       const H323RasPDU & pdu
00664     );
00665 
00666 #if PTRACING
00667     virtual const char * GetName() const;
00668 #endif
00669     virtual PString GetGatekeeperIdentifier() const;
00670     virtual unsigned GetGatekeeperRejectTag() const;
00671     virtual PString GetEndpointIdentifier() const;
00672     virtual unsigned GetRegisteredEndPointRejectTag() const;
00673     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00674     virtual unsigned GetSecurityRejectTag() const;
00675     virtual void SetRejectReason(
00676       unsigned reasonCode
00677     );
00678 
00679     H225_LocationRequest & lrq;
00680     H225_LocationConfirm & lcf;
00681     H225_LocationReject  & lrj;
00682 
00683   protected:
00684     virtual Response OnHandlePDU();
00685 };
00686 
00687 
00688 class H323GatekeeperIRR : public H323GatekeeperRequest
00689 {
00690     PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00691   public:
00692     H323GatekeeperIRR(
00693       H323GatekeeperListener & listener,
00694       const H323RasPDU & pdu
00695     );
00696 
00697 #if PTRACING
00698     virtual const char * GetName() const;
00699 #endif
00700     virtual PString GetGatekeeperIdentifier() const;
00701     virtual unsigned GetGatekeeperRejectTag() const;
00702     virtual PString GetEndpointIdentifier() const;
00703     virtual unsigned GetRegisteredEndPointRejectTag() const;
00704     virtual H235Authenticator::ValidationResult ValidatePDU() const;
00705     virtual unsigned GetSecurityRejectTag() const;
00706     virtual void SetRejectReason(
00707       unsigned reasonCode
00708     );
00709 
00710     H225_InfoRequestResponse & irr;
00711     H225_InfoRequestAck      & iack;
00712     H225_InfoRequestNak      & inak;
00713 
00714   protected:
00715     virtual Response OnHandlePDU();
00716 };
00717 
00718 
00721 class H323GatekeeperCall : public PSafeObject
00722 {
00723     PCLASSINFO(H323GatekeeperCall, PSafeObject);
00724   public:
00727     enum Direction {
00728       AnsweringCall,
00729       OriginatingCall,
00730       UnknownDirection
00731     };
00732 
00735     H323GatekeeperCall(
00736       H323GatekeeperServer & server,               
00737       const OpalGloballyUniqueID & callIdentifier, 
00738       Direction direction                          
00739     );
00740 
00743     ~H323GatekeeperCall();
00745 
00750     Comparison Compare(
00751       const PObject & obj  
00752     ) const;
00753 
00756     void PrintOn(
00757       ostream & strm    
00758     ) const;
00760 
00768     virtual H323GatekeeperRequest::Response OnAdmission(
00769       H323GatekeeperARQ & request
00770     );
00771 
00775     virtual BOOL Disengage(
00776       int reason = -1   
00777     );
00778 
00782     virtual H323GatekeeperRequest::Response OnDisengage(
00783       H323GatekeeperDRQ & request
00784     );
00785 
00790     virtual H323GatekeeperRequest::Response OnBandwidth(
00791       H323GatekeeperBRQ & request
00792     );
00793 
00797     virtual H323GatekeeperRequest::Response OnInfoResponse(
00798       H323GatekeeperIRR & request,
00799       H225_InfoRequestResponse_perCallInfo_subtype & call
00800     );
00801 
00804     virtual void OnAlerting();
00805 
00808     virtual void OnConnected();
00809 
00820     virtual BOOL OnHeartbeat();
00821 
00828     virtual PString GetCallCreditAmount() const;
00829 
00836     virtual BOOL GetCallCreditMode() const;
00837 
00845     virtual unsigned GetDurationLimit() const;
00846 
00851     virtual BOOL SendCallCreditServiceControl();
00852 
00855     BOOL AddCallCreditServiceControl(
00856       H225_ArrayOf_ServiceControlSession & serviceControl
00857     ) const;
00858 
00863     virtual BOOL SendServiceControlSession(
00864       const H323ServiceControlSession & session
00865     );
00866 
00872     virtual BOOL TranslateAliasAddress(
00873       const H225_AliasAddress & alias,
00874       H225_ArrayOf_AliasAddress & aliases,
00875       H323TransportAddress & address,
00876       BOOL & isGkRouted
00877     );
00878 
00880 
00883     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00884     H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00885     BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00886     unsigned GetCallReference() const { return callReference; }
00887     const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00888     const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00889     const PString & GetSourceNumber() const { return srcNumber; }
00890     const PStringArray & GetSourceAliases() const { return srcAliases; }
00891     const H323TransportAddress & GetSourceHost() const { return srcHost; }
00892     PString GetSourceAddress() const;
00893     const PString & GetDestinationNumber() const { return dstNumber; }
00894     const PStringArray & GetDestinationAliases() const { return dstAliases; }
00895     const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00896     PString GetDestinationAddress() const;
00897     unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00898     BOOL SetBandwidthUsed(unsigned bandwidth);
00899     const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00900     const PTime & GetCallStartTime() const { return callStartTime; }
00901     const PTime & GetAlertingTime() const { return alertingTime; }
00902     const PTime & GetConnectedTime() const { return connectedTime; }
00903     const PTime & GetCallEndTime() const { return callEndTime; }
00904     H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00906 
00907   protected:
00908     void SetUsageInfo(const H225_RasUsageInformation & usage);
00909 
00910     H323GatekeeperServer   & gatekeeper;
00911     H323RegisteredEndPoint * endpoint;
00912     H323GatekeeperListener * rasChannel;
00913 
00914     Direction            direction;
00915     unsigned             callReference;
00916     OpalGloballyUniqueID callIdentifier;
00917     OpalGloballyUniqueID conferenceIdentifier;
00918     PString              srcNumber;
00919     PStringArray         srcAliases;
00920     H323TransportAddress srcHost;
00921     PString              dstNumber;
00922     PStringArray         dstAliases;
00923     H323TransportAddress dstHost;
00924     unsigned             bandwidthUsed;
00925     unsigned             infoResponseRate;
00926     PTime                lastInfoResponse;
00927 
00928     BOOL                          drqReceived;
00929     PTime                         callStartTime;
00930     PTime                         alertingTime;
00931     PTime                         connectedTime;
00932     PTime                         callEndTime;
00933     H323Connection::CallEndReason callEndReason;
00934 };
00935 
00936 
00942 class H323RegisteredEndPoint : public PSafeObject
00943 {
00944     PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00945   public:
00950     H323RegisteredEndPoint(
00951       H323GatekeeperServer & server, 
00952       const PString & id             
00953     );
00955 
00960     Comparison Compare(
00961       const PObject & obj  
00962     ) const;
00963 
00966     void PrintOn(
00967       ostream & strm    
00968     ) const;
00970 
00977     virtual void AddCall(
00978       H323GatekeeperCall * call
00979     );
00980 
00985     virtual BOOL RemoveCall(
00986       H323GatekeeperCall * call
00987     );
00988 
00991     PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00992 
00995     H323GatekeeperCall & GetCall(
00996       PINDEX idx
00997     ) { return activeCalls[idx]; }
00999 
01008     virtual H323GatekeeperRequest::Response OnRegistration(
01009       H323GatekeeperRRQ & request
01010     );
01011 
01021     virtual H323GatekeeperRequest::Response OnFullRegistration(
01022       H323GatekeeperRRQ & request
01023     );
01024 
01033     virtual H323GatekeeperRequest::Response OnSecureRegistration(
01034       H323GatekeeperRRQ & request
01035     );
01036 
01040     virtual H323GatekeeperRequest::Response OnUnregistration(
01041       H323GatekeeperURQ & request
01042     );
01043 
01047     virtual BOOL Unregister(
01048       int reason = -1   
01049     );
01050 
01055     virtual H323GatekeeperRequest::Response OnInfoResponse(
01056       H323GatekeeperIRR & request
01057     );
01058 
01069     virtual BOOL OnTimeToLive();
01070 
01082     virtual PString GetCallCreditAmount() const;
01083 
01091     virtual BOOL GetCallCreditMode() const;
01092 
01097     virtual BOOL SendServiceControlSession(
01098       const H323ServiceControlSession & session
01099     );
01100 
01104     virtual BOOL AddServiceControlSession(
01105       const H323ServiceControlSession & session,
01106       H225_ArrayOf_ServiceControlSession & serviceControl
01107     );
01109 
01114     virtual BOOL SetPassword(
01115       const PString & password,
01116       const PString & username = PString::Empty()
01117     );
01118 
01121     const PString & GetIdentifier() const { return identifier; }
01122 
01125     const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01126 
01129     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01130 
01134     const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01135 
01139     PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01140 
01144     H323TransportAddress GetRASAddress(
01145       PINDEX idx
01146     ) const { return rasAddresses[idx]; }
01147 
01151     const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01152 
01156     PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01157 
01161     H323TransportAddress GetSignalAddress(
01162       PINDEX idx
01163     ) const { return signalAddresses[idx]; }
01164 
01167     const PStringArray & GetAliases() const { return aliases; }
01168 
01171     BOOL ContainsAlias(
01172       const PString & alias
01173       ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01174 
01177     PINDEX GetAliasCount() const { return aliases.GetSize(); }
01178 
01181     PString GetAlias(
01182       PINDEX idx
01183     ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01184 
01190     void RemoveAlias(
01191       const PString & alias
01192     );
01193 
01196     virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01197 
01200     PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01201 
01204     PString GetPrefix(
01205       PINDEX idx
01206     ) const { return voicePrefixes[idx]; }
01207 
01210     PCaselessString GetApplicationInfo() const { return productInfo.AsString(); }
01211 
01214     const OpalProductInfo & GetProductInfo() const { return productInfo; }
01215 
01218     unsigned GetProtocolVersion() const { return protocolVersion; }
01219 
01222     BOOL IsBehindNAT() const { return isBehindNAT; }
01223 
01226     BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01227 
01230     BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01231 
01234     BOOL CanReceiveRIP() const;
01235 
01238     BOOL GetH225Version() const { return h225Version; }
01240 
01250       virtual BOOL OnSendDescriptorForEndpoint(
01251         H225_ArrayOf_AliasAddress & aliases,          
01252         H225_EndpointType & terminalType,             
01253         H225_ArrayOf_AliasAddress & transportAddresses  
01254       );
01256 
01257 
01258   protected:
01259     H323GatekeeperServer    & gatekeeper;
01260     H323GatekeeperListener  * rasChannel;
01261 
01262     PString                   identifier;
01263     OpalGloballyUniqueID      descriptorID;
01264     H323TransportAddressArray rasAddresses;
01265     H323TransportAddressArray signalAddresses;
01266     PStringArray              aliases;
01267     PStringArray              voicePrefixes;
01268     OpalProductInfo           productInfo;
01269     unsigned                  protocolVersion;
01270     BOOL                      isBehindNAT;
01271     BOOL                      canDisplayAmountString;
01272     BOOL                      canEnforceDurationLimit;
01273     unsigned                  h225Version;
01274     unsigned                  timeToLive;
01275     H235Authenticators        authenticators;
01276 
01277     PTime lastRegistration;
01278     PTime lastInfoResponse;
01279 
01280     PSortedList<H323GatekeeperCall> activeCalls;
01281     POrdinalDictionary<PString>     serviceControlSessions;
01282 };
01283 
01284 
01290 class H323GatekeeperListener : public H225_RAS
01291 {
01292     PCLASSINFO(H323GatekeeperListener, H225_RAS);
01293   public:
01298     H323GatekeeperListener(
01299       H323EndPoint & endpoint,               
01300       H323GatekeeperServer & server,         
01301       const PString & gatekeeperIdentifier,  
01302       H323Transport * transport = NULL       
01303     );
01304 
01307     ~H323GatekeeperListener();
01309 
01314     BOOL UnregistrationRequest(
01315       const H323RegisteredEndPoint & ep,
01316       unsigned reason
01317     );
01318 
01321     BOOL DisengageRequest(
01322       const H323GatekeeperCall & call,
01323       unsigned reason
01324     );
01325 
01328     virtual BOOL InfoRequest(
01329       H323RegisteredEndPoint & ep,
01330       H323GatekeeperCall * call = NULL
01331     );
01332 
01335     virtual BOOL ServiceControlIndication(
01336       H323RegisteredEndPoint & ep,
01337       const H323ServiceControlSession & session,
01338       H323GatekeeperCall * call = NULL
01339     );
01341 
01348     virtual H323GatekeeperRequest::Response OnDiscovery(
01349       H323GatekeeperGRQ & request
01350     );
01351 
01356     virtual H323GatekeeperRequest::Response OnRegistration(
01357       H323GatekeeperRRQ & request
01358     );
01359 
01364     virtual H323GatekeeperRequest::Response OnUnregistration(
01365       H323GatekeeperURQ & request
01366     );
01367 
01372     virtual H323GatekeeperRequest::Response OnAdmission(
01373       H323GatekeeperARQ & request
01374     );
01375 
01380     virtual H323GatekeeperRequest::Response OnDisengage(
01381       H323GatekeeperDRQ & request
01382     );
01383 
01388     virtual H323GatekeeperRequest::Response OnBandwidth(
01389       H323GatekeeperBRQ & request
01390     );
01391 
01396     virtual H323GatekeeperRequest::Response OnLocation(
01397       H323GatekeeperLRQ & request
01398     );
01399 
01404     virtual H323GatekeeperRequest::Response OnInfoResponse(
01405       H323GatekeeperIRR & request
01406     );
01408 
01411     virtual BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01412     virtual BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01413     virtual BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01414     virtual BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01415     virtual BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01416     virtual BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01417     virtual BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01418     virtual BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01419     virtual BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01420     virtual BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01421     virtual BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01422     virtual BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01423     virtual BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01424     virtual BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01425     virtual BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01426     virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01427     virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01429 
01432     H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01434 
01435 
01436   protected:
01437     H323GatekeeperServer & gatekeeper;
01438 };
01439 
01440 
01451 class H323GatekeeperServer : public H323TransactionServer
01452 {
01453     PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01454   public:
01459     H323GatekeeperServer(
01460       H323EndPoint & endpoint
01461     );
01462 
01465     ~H323GatekeeperServer();
01467 
01468     WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01469 
01480     virtual H323Transactor * CreateListener(
01481       H323Transport * transport  
01482     );
01483 
01485 
01491     virtual H323GatekeeperRequest::Response OnDiscovery(
01492       H323GatekeeperGRQ & request
01493     );
01494 
01502     virtual H323GatekeeperRequest::Response OnRegistration(
01503       H323GatekeeperRRQ & request
01504     );
01505 
01511     virtual H323GatekeeperRequest::Response OnUnregistration(
01512       H323GatekeeperURQ & request
01513     );
01514 
01519     virtual H323GatekeeperRequest::Response OnInfoResponse(
01520       H323GatekeeperIRR & request
01521     );
01522 
01533     virtual void AddEndPoint(
01534       H323RegisteredEndPoint * ep
01535     );
01536 
01539     virtual BOOL RemoveEndPoint(
01540       H323RegisteredEndPoint * ep
01541     );
01542 
01551     virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01552       H323GatekeeperRRQ & request
01553     );
01554 
01563     virtual PString CreateEndPointIdentifier();
01564 
01567     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01568       const PString & identifier,
01569       PSafetyMode mode = PSafeReference
01570     );
01571 
01574     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01575       const H225_ArrayOf_TransportAddress & addresses,
01576       PSafetyMode mode = PSafeReference
01577     );
01578 
01581     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01582       const H323TransportAddress & address,
01583       PSafetyMode mode = PSafeReference
01584     );
01585 
01588     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01589       const H225_AliasAddress & alias,
01590       PSafetyMode mode = PSafeReadWrite
01591     );
01592 
01595     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01596       const PString & alias,
01597       PSafetyMode mode = PSafeReference
01598     );
01599 
01602     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01603       const PString & alias,
01604       PSafetyMode mode = PSafeReference
01605     );
01606 
01609     virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01610       const PString & prefix,
01611       PSafetyMode mode = PSafeReference
01612     );
01613 
01616     PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01617       PSafetyMode mode = PSafeReference
01618     ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01620 
01621     PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01622       const OpalGloballyUniqueID & id, 
01623       H323GatekeeperCall::Direction direction
01624     );
01625     
01633     virtual H323GatekeeperRequest::Response OnAdmission(
01634       H323GatekeeperARQ & request
01635     );
01636 
01641     virtual H323GatekeeperRequest::Response OnDisengage(
01642       H323GatekeeperDRQ & request
01643     );
01644 
01649     virtual H323GatekeeperRequest::Response OnBandwidth(
01650       H323GatekeeperBRQ & request
01651     );
01652 
01661     virtual H323GatekeeperCall * CreateCall(
01662       const OpalGloballyUniqueID & callIdentifier,
01663       H323GatekeeperCall::Direction direction
01664     );
01665 
01668     virtual void AddCall(H323GatekeeperCall *) 
01669     { }
01670 
01673     virtual void RemoveCall(
01674       H323GatekeeperCall * call
01675     );
01676 
01679     virtual PSafePtr<H323GatekeeperCall> FindCall(
01680       const PString & description,
01681       PSafetyMode mode = PSafeReference
01682     );
01683 
01686     virtual PSafePtr<H323GatekeeperCall> FindCall(
01687       const OpalGloballyUniqueID & callIdentifier,
01688       BOOL answeringCall,
01689       PSafetyMode mode = PSafeReference
01690     );
01691 
01694     virtual PSafePtr<H323GatekeeperCall> FindCall(
01695       const OpalGloballyUniqueID & callIdentifier,
01696       H323GatekeeperCall::Direction direction,
01697       PSafetyMode mode = PSafeReference
01698     );
01699 
01702     PSafePtr<H323GatekeeperCall> GetFirstCall(
01703       PSafetyMode mode = PSafeReference
01704     ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01706 
01716     virtual H323GatekeeperRequest::Response OnLocation(
01717       H323GatekeeperLRQ & request
01718     );
01719 
01731     virtual BOOL TranslateAliasAddress(
01732       const H225_AliasAddress & alias,
01733       H225_ArrayOf_AliasAddress & aliases,
01734       H323TransportAddress & address,
01735       BOOL & isGkRouted,
01736       H323GatekeeperCall * call
01737     );
01738 
01758     virtual BOOL TranslateAliasAddressToSignalAddress(
01759       const H225_AliasAddress & alias,
01760       H323TransportAddress & address
01761     );
01763 
01775     virtual BOOL CheckSignalAddressPolicy(
01776       const H323RegisteredEndPoint & ep,
01777       const H225_AdmissionRequest & arq,
01778       const H323TransportAddress & address
01779     );
01780 
01793     virtual BOOL CheckAliasAddressPolicy(
01794       const H323RegisteredEndPoint & ep,
01795       const H225_AdmissionRequest & arq,
01796       const H225_AliasAddress & alias
01797     );
01798 
01811     virtual BOOL CheckAliasStringPolicy(
01812       const H323RegisteredEndPoint & ep,
01813       const H225_AdmissionRequest & arq,
01814       const PString & alias
01815     );
01816 
01822     virtual unsigned AllocateBandwidth(
01823       unsigned newBandwidth,
01824       unsigned oldBandwidth = 0
01825     );
01827 
01839     virtual BOOL GetAdmissionRequestAuthentication(
01840       H323GatekeeperARQ & info,           
01841       H235Authenticators & authenticators 
01842     );
01843 
01849     virtual BOOL GetUsersPassword(
01850       const PString & alias,
01851       PString & password,
01852       H323RegisteredEndPoint & registeredEndpoint
01853     ) const;
01854     virtual BOOL GetUsersPassword(
01855       const PString & alias,
01856       PString & password
01857     ) const;
01859 
01864     H323PeerElement * GetPeerElement() const { return peerElement; }
01865 
01869     void SetPeerElement(
01870       H323PeerElement * newPeerElement
01871     );
01872 
01878     void CreatePeerElement(
01879       const H323TransportAddress & h501Interface
01880     );
01881 
01887     BOOL OpenPeerElement(
01888       const H323TransportAddress & remotePeer,
01889       BOOL append = FALSE,
01890       BOOL keepTrying = TRUE
01891     );
01893 
01898     const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01899 
01905     void SetGatekeeperIdentifier(
01906       const PString & id,
01907       BOOL adjustListeners = TRUE
01908     );
01909 
01912     unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01913 
01916     void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01917 
01920     unsigned GetUsedBandwidth() const { return usedBandwidth; }
01921 
01924     unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01925 
01928     unsigned GetTimeToLive() const { return defaultTimeToLive; }
01929 
01932     void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01933 
01936     unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01937 
01940     void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01941 
01944     BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01945 
01948     BOOL IsRequiredH235() const { return requireH235; }
01949 
01952     unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01953 
01956     unsigned GetPeakRegistrations() const { return peakRegistrations; }
01957 
01960     unsigned GetTotalRegistrations() const { return totalRegistrations; }
01961 
01964     unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01965 
01968     unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01969 
01972     unsigned GetPeakCalls() const { return peakCalls; }
01973 
01976     unsigned GetTotalCalls() const { return totalCalls; }
01977 
01980     unsigned GetRejectedCalls() const { return rejectedCalls; }
01982 
01983     // Remove an alias from the server database.
01984     void RemoveAlias(
01985       H323RegisteredEndPoint & ep,
01986       const PString & alias
01987     );
01988 
01989     // called when an endpoint needs to send a descriptor to the H.501 peer element
01990     virtual BOOL OnSendDescriptorForEndpoint(
01991       H323RegisteredEndPoint & /*ep*/,                    
01992       H225_ArrayOf_AliasAddress & /*aliases*/,            
01993       H225_EndpointType & /*terminalType*/,               
01994       H225_ArrayOf_AliasAddress & /*transportAddresses*/  
01995     )
01996     { return TRUE; } 
01997 
01998     virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & /*aliases*/)
01999     { return canHaveDuplicateAlias; }
02000 
02001     virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
02002     virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
02003 
02004   protected:
02005 
02006     PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
02007 
02008     // Configuration & policy variables
02009     PString  gatekeeperIdentifier;
02010     unsigned totalBandwidth;
02011     unsigned usedBandwidth;
02012     unsigned defaultBandwidth;
02013     unsigned maximumBandwidth;
02014     unsigned defaultTimeToLive;
02015     unsigned defaultInfoResponseRate;
02016     BOOL     overwriteOnSameSignalAddress;
02017     BOOL     canHaveDuplicateAlias;
02018     BOOL     canHaveDuplicatePrefix;
02019     BOOL     canOnlyCallRegisteredEP;
02020     BOOL     canOnlyAnswerRegisteredEP;
02021     BOOL     answerCallPreGrantedARQ;
02022     BOOL     makeCallPreGrantedARQ;
02023     BOOL     isGatekeeperRouted;
02024     BOOL     aliasCanBeHostName;
02025     BOOL     requireH235;
02026     BOOL     disengageOnHearbeatFail;
02027 
02028     PStringToString passwords;
02029 
02030     // Dynamic variables
02031     PMutex         mutex;
02032     time_t         identifierBase;
02033     unsigned       nextIdentifier;
02034     PThread      * monitorThread;
02035     PSyncPoint     monitorExit;
02036 
02037     PLIST(ListenerList, H323GatekeeperListener);
02038     ListenerList listeners;
02039 
02040     H323PeerElement * peerElement;
02041 
02042     PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
02043 
02044     class StringMap : public PString {
02045         PCLASSINFO(StringMap, PString);
02046       public:
02047         StringMap(const PString & from, const PString & id)
02048           : PString(from), identifier(id) { }
02049         PString identifier;
02050     };
02051     PSortedStringList byAddress;
02052     PSortedStringList byAlias;
02053     PSortedStringList byVoicePrefix;
02054 
02055     PSafeSortedList<H323GatekeeperCall> activeCalls;
02056 
02057     PINDEX peakRegistrations;
02058     PINDEX totalRegistrations;
02059     PINDEX rejectedRegistrations;
02060     PINDEX peakCalls;
02061     PINDEX totalCalls;
02062     PINDEX rejectedCalls;
02063 
02064   friend class H323GatekeeperRRQ;
02065   friend class H323GatekeeperARQ;
02066 };
02067 
02068 
02069 #endif // __OPAL_GKSERVER_H
02070 
02071 
02073 

Generated on Fri Mar 7 06:33:12 2008 for OPAL by  doxygen 1.5.1