00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 #ifndef __OPAL_GKCLIENT_H
00231 #define __OPAL_GKCLIENT_H
00232
00233 #include "h323.h"
00234 #include "h225ras.h"
00235 #include "h235auth.h"
00236
00237 #ifdef P_USE_PRAGMA
00238 #pragma interface
00239 #endif
00240
00241 #ifdef H323_H460
00242 class H460_FeatureSet;
00243 #endif
00244
00245 class H225_ArrayOf_AliasAddress;
00246 class H225_H323_UU_PDU;
00247 class H225_AlternateGK;
00248 class H225_ArrayOf_AlternateGK;
00249 class H225_ArrayOf_ServiceControlSession;
00250
00251
00253
00256 class H323Gatekeeper : public H225_RAS
00257 {
00258 PCLASSINFO(H323Gatekeeper, H225_RAS);
00259 public:
00264 H323Gatekeeper(
00265 H323EndPoint & endpoint,
00266 H323Transport * transport
00267 );
00268
00271 ~H323Gatekeeper();
00273
00276 BOOL OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
00277 BOOL OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
00278 BOOL OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
00279 BOOL OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
00280 BOOL OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
00281 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
00282 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
00283 BOOL OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
00284 BOOL OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
00285 BOOL OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
00286 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
00287 BOOL OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
00288 BOOL OnReceiveInfoRequest(const H225_InfoRequest & irq);
00289
00290 #ifdef H323_H248
00291 BOOL OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
00292 #endif
00293
00294 void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
00295 void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
00296 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
00297 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
00299
00304 BOOL DiscoverAny();
00305
00310 BOOL DiscoverByName(
00311 const PString & identifier
00312 );
00313
00318 BOOL DiscoverByAddress(
00319 const H323TransportAddress & address
00320 );
00321
00325 BOOL DiscoverByNameAndAddress(
00326 const PString & identifier,
00327 const H323TransportAddress & address
00328 );
00329
00332 BOOL RegistrationRequest(
00333 BOOL autoReregister = TRUE
00334 );
00335
00338 BOOL UnregistrationRequest(
00339 int reason
00340 );
00341
00344 BOOL LocationRequest(
00345 const PString & alias,
00346 H323TransportAddress & address
00347 );
00348
00351 BOOL LocationRequest(
00352 const PStringList & aliases,
00353 H323TransportAddress & address
00354 );
00355
00356 struct AdmissionResponse {
00357 AdmissionResponse();
00358
00359 unsigned rejectReason;
00360
00361 BOOL gatekeeperRouted;
00362 PINDEX endpointCount;
00363 H323TransportAddress * transportAddress;
00364 PBYTEArray * accessTokenData;
00365
00366 H225_ArrayOf_AliasAddress * aliasAddresses;
00367 H225_ArrayOf_AliasAddress * destExtraCallInfo;
00368 };
00369
00372 BOOL AdmissionRequest(
00373 H323Connection & connection,
00374 AdmissionResponse & response,
00375 BOOL ignorePreGrantedARQ = FALSE
00376 );
00377
00380 BOOL DisengageRequest(
00381 const H323Connection & connection,
00382 unsigned reason
00383 );
00384
00387 BOOL BandwidthRequest(
00388 H323Connection & connection,
00389 unsigned requestedBandwidth
00390 );
00391
00394 void InfoRequestResponse();
00395
00398 void InfoRequestResponse(
00399 const H323Connection & connection
00400 );
00401
00404 void InfoRequestResponse(
00405 const H323Connection & connection,
00406 const H225_H323_UU_PDU & pdu,
00407 BOOL sent
00408 );
00409
00410 #ifdef H323_H248
00411
00413 virtual void OnServiceControlSessions(
00414 const H225_ArrayOf_ServiceControlSession & serviceControl,
00415 H323Connection * connection
00416 );
00417 #endif
00418
00419
00424 BOOL IsDiscoveryComplete() const { return discoveryComplete; }
00425
00428 BOOL IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00429
00430 enum RegistrationFailReasons {
00431 RegistrationSuccessful,
00432 UnregisteredLocally,
00433 UnregisteredByGatekeeper,
00434 GatekeeperLostRegistration,
00435 InvalidListener,
00436 DuplicateAlias,
00437 SecurityDenied,
00438 TransportError,
00439 NumRegistrationFailReasons,
00440 RegistrationRejectReasonMask = 0x8000
00441 };
00444 RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00445
00454 PString GetName() const;
00455
00458 const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00459
00464 void SetPassword(
00465 const PString & password,
00466 const PString & username = PString()
00467 );
00468
00469
00470
00471
00472 H323TransportAddress GetGatekeeperRouteAddress() const
00473 { return gkRouteAddress; }
00475
00476
00477 protected:
00478 BOOL StartDiscovery(const H323TransportAddress & address);
00479 unsigned SetupGatekeeperRequest(H323RasPDU & request);
00480
00481 void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00482 PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00483 PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00484 void RegistrationTimeToLive();
00485
00486 void SetInfoRequestRate(
00487 const PTimeInterval & rate
00488 );
00489 void ClearInfoRequestRate();
00490 H225_InfoRequestResponse & BuildInfoRequestResponse(
00491 H323RasPDU & response,
00492 unsigned seqNum
00493 );
00494 BOOL SendUnsolicitedIRR(
00495 H225_InfoRequestResponse & irr,
00496 H323RasPDU & response
00497 );
00498
00499 void SetAlternates(
00500 const H225_ArrayOf_AlternateGK & alts,
00501 BOOL permanent
00502 );
00503
00504 virtual BOOL MakeRequest(
00505 Request & request
00506 );
00507 BOOL MakeRequestWithReregister(
00508 Request & request,
00509 unsigned unregisteredTag
00510 );
00511
00512
00513
00514 BOOL discoveryComplete;
00515 PString endpointIdentifier;
00516 RegistrationFailReasons registrationFailReason;
00517
00518 class AlternateInfo : public PObject {
00519 PCLASSINFO(AlternateInfo, PObject);
00520 public:
00521 AlternateInfo(H225_AlternateGK & alt);
00522 ~AlternateInfo();
00523 Comparison Compare(const PObject & obj);
00524 void PrintOn(ostream & strm) const;
00525
00526 H323TransportAddress rasAddress;
00527 PString gatekeeperIdentifier;
00528 unsigned priority;
00529 enum {
00530 NoRegistrationNeeded,
00531 NeedToRegister,
00532 Register,
00533 IsRegistered,
00534 RegistrationFailed
00535 } registrationState;
00536
00537 private:
00538
00539 AlternateInfo(const AlternateInfo &) { }
00540 AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00541 };
00542 PSortedList<AlternateInfo> alternates;
00543 BOOL alternatePermanent;
00544 PSemaphore requestMutex;
00545 H235Authenticators authenticators;
00546
00547 enum {
00548 RequireARQ,
00549 PregrantARQ,
00550 PreGkRoutedARQ
00551 } pregrantMakeCall, pregrantAnswerCall;
00552 H323TransportAddress gkRouteAddress;
00553
00554
00555 BOOL autoReregister;
00556 BOOL reregisterNow;
00557 PTimer timeToLive;
00558 BOOL requiresDiscovery;
00559 PTimer infoRequestRate;
00560 BOOL willRespondToIRR;
00561 PThread * monitor;
00562 BOOL monitorStop;
00563 PSyncPoint monitorTickle;
00564
00565 #ifdef H323_H248
00566 PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00567 #endif
00568
00569 #ifdef H323_H460
00570 H460_FeatureSet & features;
00571 #endif
00572
00573 };
00574
00575
00576 PLIST(H323GatekeeperList, H323Gatekeeper);
00577
00578
00579
00580 #endif // __OPAL_GKCLIENT_H
00581
00582