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 #ifndef __OPAL_GKCLIENT_H
00225 #define __OPAL_GKCLIENT_H
00226
00227 #include "h323.h"
00228 #include "h225ras.h"
00229 #include "h235auth.h"
00230
00231 #ifdef P_USE_PRAGMA
00232 #pragma interface
00233 #endif
00234
00235
00236 class H225_ArrayOf_AliasAddress;
00237 class H225_H323_UU_PDU;
00238 class H225_AlternateGK;
00239 class H225_ArrayOf_AlternateGK;
00240 class H225_ArrayOf_ServiceControlSession;
00241
00242
00244
00247 class H323Gatekeeper : public H225_RAS
00248 {
00249 PCLASSINFO(H323Gatekeeper, H225_RAS);
00250 public:
00255 H323Gatekeeper(
00256 H323EndPoint & endpoint,
00257 H323Transport * transport
00258 );
00259
00262 ~H323Gatekeeper();
00264
00267 BOOL OnReceiveGatekeeperConfirm(const H225_GatekeeperConfirm & gcf);
00268 BOOL OnReceiveGatekeeperReject(const H225_GatekeeperReject & grj);
00269 BOOL OnReceiveRegistrationConfirm(const H225_RegistrationConfirm & rcf);
00270 BOOL OnReceiveRegistrationReject(const H225_RegistrationReject & rrj);
00271 BOOL OnReceiveUnregistrationRequest(const H225_UnregistrationRequest & urq);
00272 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm & ucf);
00273 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject & urj);
00274 BOOL OnReceiveAdmissionConfirm(const H225_AdmissionConfirm & acf);
00275 BOOL OnReceiveAdmissionReject(const H225_AdmissionReject & arj);
00276 BOOL OnReceiveDisengageRequest(const H225_DisengageRequest & drq);
00277 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm & bcf);
00278 BOOL OnReceiveBandwidthRequest(const H225_BandwidthRequest & brq);
00279 BOOL OnReceiveInfoRequest(const H225_InfoRequest & irq);
00280
00281 #ifdef H323_H248
00282 BOOL OnReceiveServiceControlIndication(const H225_ServiceControlIndication &);
00283 #endif
00284
00285 void OnSendGatekeeperRequest(H225_GatekeeperRequest & grq);
00286 void OnSendAdmissionRequest(H225_AdmissionRequest & arq);
00287 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
00288 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
00290
00295 BOOL DiscoverAny();
00296
00301 BOOL DiscoverByName(
00302 const PString & identifier
00303 );
00304
00309 BOOL DiscoverByAddress(
00310 const H323TransportAddress & address
00311 );
00312
00316 BOOL DiscoverByNameAndAddress(
00317 const PString & identifier,
00318 const H323TransportAddress & address
00319 );
00320
00323 BOOL RegistrationRequest(
00324 BOOL autoReregister = TRUE
00325 );
00326
00329 BOOL UnregistrationRequest(
00330 int reason
00331 );
00332
00335 BOOL LocationRequest(
00336 const PString & alias,
00337 H323TransportAddress & address
00338 );
00339
00342 BOOL LocationRequest(
00343 const PStringList & aliases,
00344 H323TransportAddress & address
00345 );
00346
00347 struct AdmissionResponse {
00348 AdmissionResponse();
00349
00350 unsigned rejectReason;
00351
00352 BOOL gatekeeperRouted;
00353 PINDEX endpointCount;
00354 H323TransportAddress * transportAddress;
00355 PBYTEArray * accessTokenData;
00356
00357 H225_ArrayOf_AliasAddress * aliasAddresses;
00358 H225_ArrayOf_AliasAddress * destExtraCallInfo;
00359 };
00360
00363 BOOL AdmissionRequest(
00364 H323Connection & connection,
00365 AdmissionResponse & response,
00366 BOOL ignorePreGrantedARQ = FALSE
00367 );
00368
00371 BOOL DisengageRequest(
00372 const H323Connection & connection,
00373 unsigned reason
00374 );
00375
00378 BOOL BandwidthRequest(
00379 H323Connection & connection,
00380 unsigned requestedBandwidth
00381 );
00382
00385 void InfoRequestResponse();
00386
00389 void InfoRequestResponse(
00390 const H323Connection & connection
00391 );
00392
00395 void InfoRequestResponse(
00396 const H323Connection & connection,
00397 const H225_H323_UU_PDU & pdu,
00398 BOOL sent
00399 );
00400
00401 #ifdef H323_H248
00402
00404 virtual void OnServiceControlSessions(
00405 const H225_ArrayOf_ServiceControlSession & serviceControl,
00406 H323Connection * connection
00407 );
00408 #endif
00409
00410
00415 BOOL IsDiscoveryComplete() const { return discoveryComplete; }
00416
00419 BOOL IsRegistered() const { return registrationFailReason == RegistrationSuccessful; }
00420
00421 enum RegistrationFailReasons {
00422 RegistrationSuccessful,
00423 UnregisteredLocally,
00424 UnregisteredByGatekeeper,
00425 GatekeeperLostRegistration,
00426 InvalidListener,
00427 DuplicateAlias,
00428 SecurityDenied,
00429 TransportError,
00430 NumRegistrationFailReasons,
00431 RegistrationRejectReasonMask = 0x8000
00432 };
00435 RegistrationFailReasons GetRegistrationFailReason() const { return registrationFailReason; }
00436
00445 PString GetName() const;
00446
00449 const PString & GetEndpointIdentifier() const { return endpointIdentifier; }
00450
00455 void SetPassword(
00456 const PString & password,
00457 const PString & username = PString()
00458 );
00459
00460
00461
00462
00463 H323TransportAddress GetGatekeeperRouteAddress() const
00464 { return gkRouteAddress; }
00466
00467
00468 protected:
00469 BOOL StartDiscovery(const H323TransportAddress & address);
00470 unsigned SetupGatekeeperRequest(H323RasPDU & request);
00471
00472 void Connect(const H323TransportAddress & address, const PString & gatekeeperIdentifier);
00473 PDECLARE_NOTIFIER(PThread, H323Gatekeeper, MonitorMain);
00474 PDECLARE_NOTIFIER(PTimer, H323Gatekeeper, TickleMonitor);
00475 void RegistrationTimeToLive();
00476
00477 void SetInfoRequestRate(
00478 const PTimeInterval & rate
00479 );
00480 void ClearInfoRequestRate();
00481 H225_InfoRequestResponse & BuildInfoRequestResponse(
00482 H323RasPDU & response,
00483 unsigned seqNum
00484 );
00485 BOOL SendUnsolicitedIRR(
00486 H225_InfoRequestResponse & irr,
00487 H323RasPDU & response
00488 );
00489
00490 void SetAlternates(
00491 const H225_ArrayOf_AlternateGK & alts,
00492 BOOL permanent
00493 );
00494
00495 virtual BOOL MakeRequest(
00496 Request & request
00497 );
00498 BOOL MakeRequestWithReregister(
00499 Request & request,
00500 unsigned unregisteredTag
00501 );
00502
00503
00504
00505 BOOL discoveryComplete;
00506 PString endpointIdentifier;
00507 RegistrationFailReasons registrationFailReason;
00508
00509 class AlternateInfo : public PObject {
00510 PCLASSINFO(AlternateInfo, PObject);
00511 public:
00512 AlternateInfo(H225_AlternateGK & alt);
00513 ~AlternateInfo();
00514 Comparison Compare(const PObject & obj);
00515 void PrintOn(ostream & strm) const;
00516
00517 H323TransportAddress rasAddress;
00518 PString gatekeeperIdentifier;
00519 unsigned priority;
00520 enum {
00521 NoRegistrationNeeded,
00522 NeedToRegister,
00523 Register,
00524 IsRegistered,
00525 RegistrationFailed
00526 } registrationState;
00527
00528 private:
00529
00530 AlternateInfo(const AlternateInfo &) { }
00531 AlternateInfo & operator=(const AlternateInfo &) { return *this; }
00532 };
00533 PSortedList<AlternateInfo> alternates;
00534 BOOL alternatePermanent;
00535 PSemaphore requestMutex;
00536 H235Authenticators authenticators;
00537
00538 enum {
00539 RequireARQ,
00540 PregrantARQ,
00541 PreGkRoutedARQ
00542 } pregrantMakeCall, pregrantAnswerCall;
00543 H323TransportAddress gkRouteAddress;
00544
00545
00546 BOOL autoReregister;
00547 BOOL reregisterNow;
00548 PTimer timeToLive;
00549 BOOL requiresDiscovery;
00550 PTimer infoRequestRate;
00551 BOOL willRespondToIRR;
00552 PThread * monitor;
00553 BOOL monitorStop;
00554 PSyncPoint monitorTickle;
00555
00556 #ifdef H323_H248
00557 PDictionary<POrdinalKey, H323ServiceControlSession> serviceControlSessions;
00558 #endif
00559 };
00560
00561
00562 PLIST(H323GatekeeperList, H323Gatekeeper);
00563
00564
00565
00566 #endif // __OPAL_GKCLIENT_H
00567
00568