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.14 2006/01/02 15:51:44 dsandras 00031 * Merged changes from OpenH323 Atlas_devel_2. 00032 * 00033 * Revision 2.13 2005/11/30 13:35:26 csoutheren 00034 * Changed tags for Doxygen 00035 * 00036 * Revision 2.12 2004/06/04 06:54:02 csoutheren 00037 * Migrated updates from OpenH323 1.14.1 00038 * 00039 * Revision 2.11 2004/04/25 02:53:29 rjongbloed 00040 * Fixed GNU 3.4 warnings 00041 * 00042 * Revision 2.10 2004/02/19 10:46:43 rjongbloed 00043 * Merged OpenH323 version 1.13.1 changes. 00044 * 00045 * Revision 2.9 2003/01/07 04:39:52 robertj 00046 * Updated to OpenH323 v1.11.2 00047 * 00048 * Revision 2.8 2002/11/10 11:33:16 robertj 00049 * Updated to OpenH323 v1.10.3 00050 * 00051 * Revision 2.7 2002/09/16 02:52:33 robertj 00052 * Added #define so can select if #pragma interface/implementation is used on 00053 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00054 * 00055 * Revision 2.6 2002/09/04 06:01:46 robertj 00056 * Updated to OpenH323 v1.9.6 00057 * 00058 * Revision 2.5 2002/07/01 04:56:29 robertj 00059 * Updated to OpenH323 v1.9.1 00060 * 00061 * Revision 2.4 2002/03/22 06:57:48 robertj 00062 * Updated to OpenH323 version 1.8.2 00063 * 00064 * Revision 2.3 2002/02/11 09:32:11 robertj 00065 * Updated to openH323 v1.8.0 00066 * 00067 * Revision 2.2 2002/01/14 06:35:56 robertj 00068 * Updated to OpenH323 v1.7.9 00069 * 00070 * Revision 2.1 2001/08/13 05:10:39 robertj 00071 * Updates from OpenH323 v1.6.0 release. 00072 * 00073 * Revision 2.0 2001/07/27 15:48:24 robertj 00074 * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL) 00075 * 00076 * Revision 1.74 2004/02/15 03:36:30 rjongbloed 00077 * Fixed bug in removing prefixes, plus added ability to have multiple endpoints 00078 * with the same profix, thanks Rossano Ravelli 00079 * 00080 * Revision 1.73 2004/02/07 11:43:59 rjongbloed 00081 * Fixed deadlocks caused under high load by failure to check locking 00082 * success. Also added functions to find destination endpoint. 00083 * Thanks Federico Pinna and the gang at Reitek S.p.A. 00084 * 00085 * Revision 1.72 2003/12/24 07:08:47 csoutheren 00086 * Added TranslateAliasAddress on H323GatekeeperCall 00087 * 00088 * Revision 1.71 2003/12/11 05:39:04 csoutheren 00089 * Added storage of H.225 version in endpoint structure 00090 * Disabled sending RIPs to endpoints that cannot handle them 00091 * 00092 * Revision 1.70 2003/12/11 02:18:17 csoutheren 00093 * More fixes for NM deregistration problems. Seems to be fixed now :) 00094 * 00095 * Revision 1.69 2003/12/09 00:58:46 csoutheren 00096 * Fixed problem with endpoints deregistering 00097 * 00098 * Revision 1.68 2003/12/09 00:33:17 csoutheren 00099 * Added patch to prevent crash when NM unregisters from GK 00100 * Abject apologies to Rossano Ravelli for taking so long to add this 00101 * 00102 * Revision 1.67 2003/04/30 00:28:50 robertj 00103 * Redesigned the alternate credentials in ARQ system as old implementation 00104 * was fraught with concurrency issues, most importantly it can cause false 00105 * detection of replay attacks taking out an endpoint completely. 00106 * 00107 * Revision 1.66 2003/04/02 06:58:10 robertj 00108 * Added support for (optional) duplicate aliases in gatekeeper server, necessitating 00109 * the removal of AddAlias and RemoveAlias functions. 00110 * 00111 * Revision 1.65 2003/04/02 06:07:12 robertj 00112 * Added H.323 Annex G Peer Element support to gatekeeper server. 00113 * 00114 * Revision 1.64 2003/04/01 07:30:52 robertj 00115 * Added function to translate alias into alias list and transport to make 00116 * use of full information returned by peer element. 00117 * 00118 * Revision 1.63 2003/04/01 04:47:48 robertj 00119 * Abstracted H.225 RAS transaction processing (RIP and secondary thread) in 00120 * server environment for use by H.501 peer elements. 00121 * 00122 * Revision 1.62 2003/03/26 07:10:03 robertj 00123 * Added more access functions. 00124 * 00125 * Revision 1.61 2003/03/17 22:52:06 craigs 00126 * Improvided useability of AddAlias and RemoveAlias 00127 * 00128 * Revision 1.60 2003/03/04 05:34:13 robertj 00129 * Fixed GNU warnings 00130 * 00131 * Revision 1.59 2003/03/04 05:27:51 robertj 00132 * Added statistics for rejected registrations and call admissions. 00133 * 00134 * Revision 1.58 2003/03/03 06:59:26 robertj 00135 * Fixed call SetBandwidth function so adjusts global bandwidth as well. 00136 * 00137 * Revision 1.57 2003/02/21 07:21:40 robertj 00138 * Fixed incorrect ancestor in PCLASSINFO() 00139 * 00140 * Revision 1.56 2003/02/21 05:28:39 craigs 00141 * Factored out code for user with peer elements 00142 * 00143 * Revision 1.55 2003/02/06 04:43:14 robertj 00144 * Changes to help with endpoints behind NAT. 00145 * 00146 * Revision 1.54 2003/02/03 03:58:06 robertj 00147 * Fixed use of local password database with ep's that have multiple aliases. 00148 * 00149 * Revision 1.53 2003/02/01 13:31:14 robertj 00150 * Changes to support CAT authentication in RAS. 00151 * 00152 * Revision 1.52 2002/12/17 01:25:23 robertj 00153 * Added call backs on gk server when ep indicates alerting or connect. 00154 * 00155 * Revision 1.51 2002/11/28 05:45:46 robertj 00156 * Fixed bug so can set total bandwidth while calls are in progress. 00157 * 00158 * Revision 1.50 2002/11/28 04:41:44 robertj 00159 * Added support for RAS ServiceControlIndication command. 00160 * 00161 * Revision 1.49 2002/11/27 06:54:52 robertj 00162 * Added Service Control Session management as per Annex K/H.323 via RAS 00163 * only at this stage. 00164 * Added H.248 ASN and very primitive infrastructure for linking into the 00165 * Service Control Session management system. 00166 * Added basic infrastructure for Annex K/H.323 HTTP transport system. 00167 * Added Call Credit Service Control to display account balances. 00168 * 00169 * Revision 1.48 2002/11/22 00:11:29 robertj 00170 * Added call start time. 00171 * 00172 * Revision 1.47 2002/11/18 23:40:45 robertj 00173 * Changed to use the H323EndPoint::CreateAuthenticators() function, we 00174 * should use only one. 00175 * 00176 * Revision 1.46 2002/11/12 11:36:03 robertj 00177 * Added function to find endpoint by partial alias. 00178 * Optimised endpoint "indexes" to use sorted lists instead of dictionaries. 00179 * 00180 * Revision 1.45 2002/11/06 23:23:48 robertj 00181 * Fixed minor error in parameter, should be reference not value 00182 * 00183 * Revision 1.44 2002/10/29 00:12:02 robertj 00184 * Changed template classes so things like PSafeList actually creates the 00185 * base collection class as well. 00186 * Improved setting of usage info, included getting it from BRQ etc. 00187 * 00188 * Revision 1.43 2002/10/21 00:54:47 robertj 00189 * Added function to unregister an endpoint via user interface. 00190 * Added reason code to call disengage. 00191 * Added ability to find call by a description string. 00192 * 00193 * Revision 1.42 2002/10/17 05:26:33 robertj 00194 * Added function to get at registered endpoints protocol version. 00195 * 00196 * Revision 1.41 2002/10/16 07:22:50 robertj 00197 * Added support for endpoints that do not support RRQ timeToLive parameter, 00198 * will actively go see if ep is there using IRQ before expiring the ep. 00199 * 00200 * Revision 1.40 2002/10/01 08:17:34 robertj 00201 * Fixed (benign) race condition between client and server both wanting to do 00202 * a DRQ of a call at the same time. Caused an Assert, but no crash. 00203 * 00204 * Revision 1.39 2002/09/26 01:27:31 robertj 00205 * Changed appliation info name in registered endpoint to be caseless string. 00206 * 00207 * Revision 1.38 2002/09/24 08:03:51 robertj 00208 * Added H.225 RAS protocol version number to registered endpoint structure. 00209 * 00210 * Revision 1.37 2002/09/19 09:15:56 robertj 00211 * Fixed problem with making (and assuring with multi-threading) IRQ and DRQ 00212 * requests are sent to the correct endpoint address, thanks Martijn Roest. 00213 * 00214 * Revision 1.36 2002/09/16 01:14:15 robertj 00215 * Added #define so can select if #pragma interface/implementation is used on 00216 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan. 00217 * 00218 * Revision 1.35 2002/09/03 06:19:36 robertj 00219 * Normalised the multi-include header prevention ifdef/define symbol. 00220 * 00221 * Revision 1.34 2002/08/29 07:57:08 robertj 00222 * Added some statistics to gatekeeper server. 00223 * 00224 * Revision 1.33 2002/08/29 06:54:52 robertj 00225 * Removed redundent thread member variable from request info. 00226 * 00227 * Revision 1.32 2002/08/12 08:12:45 robertj 00228 * Added extra hint to help with ARQ using separate credentials from RRQ. 00229 * 00230 * Revision 1.31 2002/08/12 05:38:20 robertj 00231 * Changes to the RAS subsystem to support ability to make requests to client 00232 * from gkserver without causing bottlenecks and race conditions. 00233 * 00234 * Revision 1.30 2002/08/05 10:03:47 robertj 00235 * Cosmetic changes to normalise the usage of pragma interface/implementation. 00236 * 00237 * Revision 1.29 2002/08/05 05:17:37 robertj 00238 * Fairly major modifications to support different authentication credentials 00239 * in ARQ to the logged in ones on RRQ. For both client and server. 00240 * Various other H.235 authentication bugs and anomalies fixed on the way. 00241 * 00242 * Revision 1.28 2002/07/16 13:49:22 robertj 00243 * Added missing lock when removing call from endpoint. 00244 * 00245 * Revision 1.27 2002/07/11 09:33:56 robertj 00246 * Added access functions to various call statistics member variables. 00247 * 00248 * Revision 1.26 2002/07/11 07:01:37 robertj 00249 * Added Disengage() function to force call drop from gk server. 00250 * Added InfoRequest() function to force client to send an IRR. 00251 * Added ability to automatically clear calls if do not get IRR for it. 00252 * 00253 * Revision 1.25 2002/06/21 02:52:44 robertj 00254 * Fixed problem with double checking H.235 hashing, this causes failure as 00255 * the authenticator thinks it is a replay attack. 00256 * 00257 * Revision 1.24 2002/06/19 05:03:08 robertj 00258 * Changed gk code to allow for H.235 security on an endpoint by endpoint basis. 00259 * 00260 * Revision 1.23 2002/06/12 03:55:21 robertj 00261 * Added function to add/remove multiple listeners in one go comparing against 00262 * what is already running so does not interrupt unchanged listeners. 00263 * 00264 * Revision 1.22 2002/05/29 00:03:15 robertj 00265 * Fixed unsolicited IRR support in gk client and server, 00266 * including support for IACK and INAK. 00267 * 00268 * Revision 1.21 2002/05/21 06:30:31 robertj 00269 * Changed GRQ to the same as all the other xRQ request handlers. 00270 * 00271 * Revision 1.20 2002/05/17 03:42:08 robertj 00272 * Fixed problems with H.235 authentication on RAS for server and client. 00273 * 00274 * Revision 1.19 2002/05/07 03:18:12 robertj 00275 * Added application info (name/version etc) into registered endpoint data. 00276 * 00277 * Revision 1.18 2002/05/06 00:56:37 robertj 00278 * Sizeable rewrite of gatekeeper server code to make more bulletproof against 00279 * multithreaded operation. Especially when using slow response/RIP feature. 00280 * Also changed the call indexing to use call id and direction as key. 00281 * 00282 * Revision 1.17 2002/04/30 23:19:00 dereks 00283 * Fix documentation typos. 00284 * 00285 * Revision 1.16 2002/03/06 02:01:31 robertj 00286 * Fixed race condition when starting slow server response thread. 00287 * 00288 * Revision 1.15 2002/03/05 00:36:01 craigs 00289 * Added GetReplyAddress for H323GatekeeperRequest 00290 * 00291 * Revision 1.14 2002/03/03 21:34:50 robertj 00292 * Added gatekeeper monitor thread. 00293 * 00294 * Revision 1.13 2002/03/02 05:58:57 robertj 00295 * Fixed possible bandwidth leak (thanks Francisco Olarte Sanz) and in 00296 * the process added OnBandwidth function to H323GatekeeperCall class. 00297 * 00298 * Revision 1.12 2002/03/01 04:09:09 robertj 00299 * Fixed problems with keeping track of calls. Calls are now indexed by call-id 00300 * alone and maintain both endpoints of call in its structure. Fixes problem 00301 * with calls form an endpoint to itself, and having two objects being tracked 00302 * where there is really only one call. 00303 * 00304 * Revision 1.11 2002/02/04 05:21:13 robertj 00305 * Lots of changes to fix multithreaded slow response code (RIP). 00306 * Fixed problem with having two entries for same call in call list. 00307 * 00308 * Revision 1.10 2002/01/31 06:45:44 robertj 00309 * Added more checking for invalid list processing in calls database. 00310 * 00311 * Revision 1.9 2002/01/31 00:16:15 robertj 00312 * Removed const to allow things to compile! 00313 * 00314 * Revision 1.8 2001/12/15 08:08:52 robertj 00315 * Added alerting, connect and end of call times to be sent to RAS server. 00316 * 00317 * Revision 1.7 2001/12/14 06:40:47 robertj 00318 * Added call end reason codes in DisengageRequest for GK server use. 00319 * 00320 * Revision 1.6 2001/12/13 11:08:45 robertj 00321 * Significant changes to support slow request handling, automatically sending 00322 * RIP and spawning thread to handle time consuming operation. 00323 * 00324 * Revision 1.5 2001/11/19 06:56:44 robertj 00325 * Added prefix strings for gateways registered with this gk, thanks Mikael Stolt 00326 * 00327 * Revision 1.4 2001/08/10 11:03:49 robertj 00328 * Major changes to H.235 support in RAS to support server. 00329 * 00330 * Revision 1.3 2001/08/06 07:44:52 robertj 00331 * Fixed problems with building without SSL 00332 * 00333 * Revision 1.2 2001/08/06 03:18:35 robertj 00334 * Fission of h323.h to h323ep.h & h323con.h, h323.h now just includes files. 00335 * Improved access to H.235 secure RAS functionality. 00336 * Changes to H.323 secure RAS contexts to help use with gk server. 00337 * 00338 * Revision 1.1 2001/07/24 02:30:55 robertj 00339 * Added gatekeeper RAS protocol server classes. 00340 * 00341 */ 00342 00343 #ifndef __OPAL_GKSERVER_H 00344 #define __OPAL_GKSERVER_H 00345 00346 #ifdef P_USE_PRAGMA 00347 #pragma interface 00348 #endif 00349 00350 00351 #include <ptlib/safecoll.h> 00352 #include <opal/guid.h> 00353 #include <h323/h225ras.h> 00354 #include <h323/transaddr.h> 00355 #include <h323/h235auth.h> 00356 #include <h323/h323pdu.h> 00357 #include <h323/h323trans.h> 00358 00359 00360 class PASN_Sequence; 00361 class PASN_Choice; 00362 00363 class H225_AliasAddress; 00364 class H225_EndpointIdentifier; 00365 class H225_GatekeeperIdentifier; 00366 class H225_ArrayOf_TransportAddress; 00367 class H225_GatekeeperIdentifier; 00368 class H225_EndpointIdentifier; 00369 class H225_InfoRequestResponse_perCallInfo_subtype; 00370 class H225_RasUsageInformation; 00371 00372 class H323RegisteredEndPoint; 00373 class H323GatekeeperListener; 00374 class H323GatekeeperServer; 00375 class H323RasPDU; 00376 class H323PeerElement; 00377 00378 00379 class H323GatekeeperRequest : public H323Transaction 00380 { 00381 PCLASSINFO(H323GatekeeperRequest, H323Transaction); 00382 public: 00387 H323GatekeeperRequest( 00388 H323GatekeeperListener & rasChannel, 00389 const H323RasPDU & pdu 00390 ); 00392 00393 virtual H323TransactionPDU * CreateRIP( 00394 unsigned sequenceNumber, 00395 unsigned delay 00396 ) const; 00397 00398 virtual BOOL WritePDU( 00399 H323TransactionPDU & pdu 00400 ); 00401 BOOL CheckCryptoTokens(); 00402 BOOL CheckGatekeeperIdentifier(); 00403 BOOL GetRegisteredEndPoint(); 00404 00405 virtual PString GetGatekeeperIdentifier() const = 0; 00406 virtual unsigned GetGatekeeperRejectTag() const = 0; 00407 virtual PString GetEndpointIdentifier() const = 0; 00408 virtual unsigned GetRegisteredEndPointRejectTag() const = 0; 00409 virtual unsigned GetSecurityRejectTag() const = 0; 00410 00411 H323GatekeeperListener & GetRasChannel() const { return rasChannel; } 00412 00413 PSafePtr<H323RegisteredEndPoint> endpoint; 00414 00415 protected: 00416 H323GatekeeperListener & rasChannel; 00417 }; 00418 00419 00420 class H323GatekeeperGRQ : public H323GatekeeperRequest 00421 { 00422 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest); 00423 public: 00424 H323GatekeeperGRQ( 00425 H323GatekeeperListener & listener, 00426 const H323RasPDU & pdu 00427 ); 00428 00429 #if PTRACING 00430 virtual const char * GetName() const; 00431 #endif 00432 virtual PString GetGatekeeperIdentifier() const; 00433 virtual unsigned GetGatekeeperRejectTag() const; 00434 virtual PString GetEndpointIdentifier() const; 00435 virtual unsigned GetRegisteredEndPointRejectTag() const; 00436 virtual H235Authenticator::ValidationResult ValidatePDU() const; 00437 virtual unsigned GetSecurityRejectTag() const; 00438 virtual void SetRejectReason( 00439 unsigned reasonCode 00440 ); 00441 00442 H225_GatekeeperRequest & grq; 00443 H225_GatekeeperConfirm & gcf; 00444 H225_GatekeeperReject & grj; 00445 00446 protected: 00447 virtual Response OnHandlePDU(); 00448 }; 00449 00450 00451 class H323GatekeeperRRQ : public H323GatekeeperRequest 00452 { 00453 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest); 00454 public: 00455 H323GatekeeperRRQ( 00456 H323GatekeeperListener & listener, 00457 const H323RasPDU & pdu 00458 ); 00459 00460 #if PTRACING 00461 virtual const char * GetName() const; 00462 #endif 00463 virtual PString GetGatekeeperIdentifier() const; 00464 virtual unsigned GetGatekeeperRejectTag() const; 00465 virtual PString GetEndpointIdentifier() const; 00466 virtual unsigned GetRegisteredEndPointRejectTag() const; 00467 virtual H235Authenticator::ValidationResult ValidatePDU() const; 00468 virtual unsigned GetSecurityRejectTag() const; 00469 virtual void SetRejectReason( 00470 unsigned reasonCode 00471 ); 00472 00473 H225_RegistrationRequest & rrq; 00474 H225_RegistrationConfirm & rcf; 00475 H225_RegistrationReject & rrj; 00476 00477 protected: 00478 virtual Response OnHandlePDU(); 00479 }; 00480 00481 00482 class H323GatekeeperURQ : public H323GatekeeperRequest 00483 { 00484 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest); 00485 public: 00486 H323GatekeeperURQ( 00487 H323GatekeeperListener & listener, 00488 const H323RasPDU & pdu 00489 ); 00490 00491 #if PTRACING 00492 virtual const char * GetName() const; 00493 #endif 00494 virtual PString GetGatekeeperIdentifier() const; 00495 virtual unsigned GetGatekeeperRejectTag() const; 00496 virtual PString GetEndpointIdentifier() const; 00497 virtual unsigned GetRegisteredEndPointRejectTag() const; 00498 virtual H235Authenticator::ValidationResult ValidatePDU() const; 00499 virtual unsigned GetSecurityRejectTag() const; 00500 virtual void SetRejectReason( 00501 unsigned reasonCode 00502 ); 00503 00504 H225_UnregistrationRequest & urq; 00505 H225_UnregistrationConfirm & ucf; 00506 H225_UnregistrationReject & urj; 00507 00508 protected: 00509 virtual Response OnHandlePDU(); 00510 }; 00511 00512 00513 class H323GatekeeperARQ : public H323GatekeeperRequest 00514 { 00515 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest); 00516 public: 00517 H323GatekeeperARQ( 00518 H323GatekeeperListener & listener, 00519 const H323RasPDU & pdu 00520 ); 00521 00522 #if PTRACING 00523 virtual const char * GetName() const; 00524 #endif 00525 virtual PString GetGatekeeperIdentifier() const; 00526 virtual unsigned GetGatekeeperRejectTag() const; 00527 virtual PString GetEndpointIdentifier() const; 00528 virtual unsigned GetRegisteredEndPointRejectTag() const; 00529 virtual H235Authenticator::ValidationResult ValidatePDU() const; 00530 virtual unsigned GetSecurityRejectTag() const; 00531 virtual void SetRejectReason( 00532 unsigned reasonCode 00533 ); 00534 00535 H225_AdmissionRequest & arq;