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
00231
00232
00233
00234
00235
00236
00237
00238
00239 #ifndef __OPAL_GKCLIENT_H
00240 #define __OPAL_GKCLIENT_H
00241
00242 #include "h323.h"
00243 #include "h225ras.h"
00244 #include "h235auth.h"
00245
00246 #ifdef P_USE_PRAGMA
00247 #pragma interface
00248 #endif
00249
00250 #ifdef H323_H460
00251 class H460_FeatureSet;
00252 #endif
00253
00254 class H225_ArrayOf_AliasAddress;
00255 class H225_H323_UU_PDU;
00256 class H225_AlternateGK;
00257 class H225_ArrayOf_AlternateGK;
00258 class H225_ArrayOf_ServiceControlSession;
00259
00260
00262
00265 class H323Gatekeeper : public H225_RAS
00266 {
00267 PCLASSINFO(H323Gatekeeper, H225_RAS);
00268 public:
00273 H323Gatekeeper(
00274 H323EndPoint & endpoint,
00275 H323Transport * transport
00276 );
00277
00280 ~H323Gatekeeper();
00282
00285 BOOL OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
00286 BOOL OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
00287 BOOL OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
00288 BOOL OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
00289 BOOL OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
00290 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
00291 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
00292 BOOL OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
00293 BOOL OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
00294 BOOL OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
00295 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
00296 BOOL OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
00297 BOOL OnReceiveInfoRequest(const H225_InfoRequest & irq);
00298
00299 #ifdef H323_H248
00300 BOOL OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
00301 #endif
00302
00303 void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
00304 void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
00305 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
00306 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
00308
00313 BOOL DiscoverAny();
00314
00319 BOOL DiscoverByName(
00320 const PString & identifier
00321 );
00322
00327 BOOL DiscoverByAddress(
00328 const H323TransportAddress & address
00329 );
00330
00334 BOOL DiscoverByNameAndAddress(
00335 const PString & identifier,
00336 const H323TransportAddress & address
00337 );
00338
00341 BOOL RegistrationRequest(
00342 BOOL autoReregister = TRUE
00343 );
00344
00347 BOOL UnregistrationRequest(
00348 int reason
00349 );
00350
00353 BOOL LocationRequest(
00354 const PString & alias,
00355 H323TransportAddress & address
00356 );
00357
00360 BOOL LocationRequest(
00361 const PStringList & aliases,
00362 H323TransportAddress & address
00363 );
00364
00365 struct AdmissionResponse {
00366 AdmissionResponse();
00367
00368 unsigned rejectReason;
00369
00370 BOOL gatekeeperRouted;
00371 PINDEX endpointCount;
00372 H323TransportAddress * transportAddress;
00373 PBYTEArray * accessTokenData;
00374
00375 H225_ArrayOf_AliasAddress * aliasAddresses;
00376 H225_ArrayOf_AliasAddress * destExtraCallInfo;
00377 };
00378
00381 BOOL AdmissionRequest(
00382 H323Connection & connection,
00383 AdmissionResponse & response,
00384 BOOL ignorePreGrantedARQ = FALSE
00385 );
00386
00389 BOOL DisengageRequest(
00390 const H323Connection & connection,
00391 unsigned reason
00392 );
00393
00396 BOOL BandwidthRequest(
00397 H323Connection & connection,
00398 unsigned requestedBandwidth
00399 );
00400
00403 void InfoRequestResponse();
00404
00407 void InfoRequestResponse(
00408 const H323Connection & connection
00409 );
00410
00413 void InfoRequestResponse(
00414 const H323Connection & connection,
00415 const H225_H323_UU_PDU & pdu,
00416 BOOL sent
00417 );
00418
00419 #ifdef H323_H248
00420
00422 virtual void OnServiceControlSessions(
00423 const H225_ArrayOf_ServiceControlSession & serviceControl,
00424 H323Connection * connection
00425 );
00426 #endif
00427
00428
00433 BOOL IsDiscoveryComplete() const { return discoveryComplete; }
00434
00437 BOOL IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00438
00441 void ReRegisterNow();
00442
00443 enum RegistrationFailReasons {
00444 RegistrationSuccessful,
00445 UnregisteredLocally,
00446 UnregisteredByGatekeeper,
00447 GatekeeperLostRegistration,
00448 InvalidListener,
00449 DuplicateAlias,
00450 SecurityDenied,
00451 TransportError,
00452 NumRegistrationFailReasons,
00453 RegistrationRejectReasonMask = 0x8000
00454 };
00457 RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00458
00467 PString GetName() const;
00468
00471 const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00472
00477 void SetPassword(
00478 const PString & password,
00479 const PString & username = PString()
00480 );
00481
00482
00483
00484
00485 H323TransportAddress GetGatekeeperRouteAddress() const
00486 { return gkRouteAddress; }
00488
00489
00490 protected:
00491 BOOL StartDiscovery(const H323TransportAddress & address);
00492 unsigned SetupGatekeeperRequest(H323RasPDU & request);
00493
00494 void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00495 PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00496 PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00497 void RegistrationTimeToLive();
00498
00499 void SetInfoRequestRate(
00500 const PTimeInterval & rate
00501 );
00502 void ClearInfoRequestRate();
00503 H225_InfoRequestResponse & BuildInfoRequestResponse(
00504 H323RasPDU & response,
00505 unsigned seqNum
00506 );
00507 BOOL SendUnsolicitedIRR(
00508 H225_InfoRequestResponse & irr,
00509 H323RasPDU & response
00510 );
00511
00512 void SetAlternates(
00513 const H225_ArrayOf_AlternateGK & alts,
00514 BOOL permanent
00515 );
00516
00517 void SetAssignedGatekeeper(
00518 const H225_AlternateGK & gk
00519 );
00520
00521 BOOL GetAssignedGatekeeper(
00522 H225_AlternateGK & gk
00523 );
00524
00525 virtual BOOL MakeRequest(
00526 Request & request
00527 );
00528 BOOL MakeRequestWithReregister(
00529 Request & request,
00530 unsigned unregisteredTag
00531 );
00532
00533
00534
00535 BOOL discoveryComplete;
00536 PString endpointIdentifier;
00537 PString localId;
00538 RegistrationFailReasons registrationFailReason;
00539
00540 class AlternateInfo : public PObject {
00541 PCLASSINFO(AlternateInfo, PObject);
00542 public:
00543 AlternateInfo(const H225_AlternateGK & alt);
00544 ~AlternateInfo();
00545 H225_AlternateGK GetAlternate();
00546 Comparison Compare(const PObject & obj);
00547 void PrintOn(ostream & strm) const;
00548
00549 H323TransportAddress rasAddress;
00550 PString gatekeeperIdentifier;
00551 unsigned priority;
00552 enum {
00553 NoRegistrationNeeded,
00554 NeedToRegister,
00555 Register,
00556 IsRegistered,
00557 RegistrationFailed
00558 } registrationState;
00559
00560 private:
00561
00562 AlternateInfo(const AlternateInfo &) { }
00563 AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00564 };
00565 PSortedList<AlternateInfo> alternates;
00566 BOOL alternatePermanent;
00567 PSemaphore requestMutex;
00568 H235Authenticators authenticators;
00569 AlternateInfo * assignedGK;
00570
00571 enum {
00572 RequireARQ,
00573 PregrantARQ,
00574 PreGkRoutedARQ
00575 } pregrantMakeCall, pregrantAnswerCall;
00576 H323TransportAddress gkRouteAddress;
00577
00578
00579 BOOL autoReregister;
00580 BOOL reregisterNow;
00581 PTimer timeToLive;
00582 BOOL requiresDiscovery;
00583 PTimer infoRequestRate;
00584 BOOL willRespondToIRR;
00585 PThread * monitor;
00586 BOOL monitorStop;
00587 PSyncPoint monitorTickle;
00588
00589 #ifdef H323_H248
00590 PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00591 #endif
00592
00593 #ifdef H323_H460
00594 H460_FeatureSet & features;
00595 #endif
00596
00597 };
00598
00599
00600 PLIST(H323GatekeeperList, H323Gatekeeper);
00601
00602
00603
00604 #endif // __OPAL_GKCLIENT_H
00605
00606