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