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
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
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;
00536 H225_AdmissionConfirm & acf;
00537 H225_AdmissionReject & arj;
00538
00539 PString alternateSecurityID;
00540
00541 protected:
00542 virtual Response OnHandlePDU();
00543 };
00544
00545
00546 class H323GatekeeperDRQ : public H323GatekeeperRequest
00547 {
00548 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00549 public:
00550 H323GatekeeperDRQ(
00551 H323GatekeeperListener & listener,
00552 const H323RasPDU & pdu
00553 );
00554
00555 #if PTRACING
00556 virtual const char * GetName() const;
00557 #endif
00558 virtual PString GetGatekeeperIdentifier() const;
00559 virtual unsigned GetGatekeeperRejectTag() const;
00560 virtual PString GetEndpointIdentifier() const;
00561 virtual unsigned GetRegisteredEndPointRejectTag() const;
00562 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00563 virtual unsigned GetSecurityRejectTag() const;
00564 virtual void SetRejectReason(
00565 unsigned reasonCode
00566 );
00567
00568 H225_DisengageRequest & drq;
00569 H225_DisengageConfirm & dcf;
00570 H225_DisengageReject & drj;
00571
00572 protected:
00573 virtual Response OnHandlePDU();
00574 };
00575
00576
00577 class H323GatekeeperBRQ : public H323GatekeeperRequest
00578 {
00579 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00580 public:
00581 H323GatekeeperBRQ(
00582 H323GatekeeperListener & listener,
00583 const H323RasPDU & pdu
00584 );
00585
00586 #if PTRACING
00587 virtual const char * GetName() const;
00588 #endif
00589 virtual PString GetGatekeeperIdentifier() const;
00590 virtual unsigned GetGatekeeperRejectTag() const;
00591 virtual PString GetEndpointIdentifier() const;
00592 virtual unsigned GetRegisteredEndPointRejectTag() const;
00593 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00594 virtual unsigned GetSecurityRejectTag() const;
00595 virtual void SetRejectReason(
00596 unsigned reasonCode
00597 );
00598
00599 H225_BandwidthRequest & brq;
00600 H225_BandwidthConfirm & bcf;
00601 H225_BandwidthReject & brj;
00602
00603 protected:
00604 virtual Response OnHandlePDU();
00605 };
00606
00607
00608 class H323GatekeeperLRQ : public H323GatekeeperRequest
00609 {
00610 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00611 public:
00612 H323GatekeeperLRQ(
00613 H323GatekeeperListener & listener,
00614 const H323RasPDU & pdu
00615 );
00616
00617 #if PTRACING
00618 virtual const char * GetName() const;
00619 #endif
00620 virtual PString GetGatekeeperIdentifier() const;
00621 virtual unsigned GetGatekeeperRejectTag() const;
00622 virtual PString GetEndpointIdentifier() const;
00623 virtual unsigned GetRegisteredEndPointRejectTag() const;
00624 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00625 virtual unsigned GetSecurityRejectTag() const;
00626 virtual void SetRejectReason(
00627 unsigned reasonCode
00628 );
00629
00630 H225_LocationRequest & lrq;
00631 H225_LocationConfirm & lcf;
00632 H225_LocationReject & lrj;
00633
00634 protected:
00635 virtual Response OnHandlePDU();
00636 };
00637
00638
00639 class H323GatekeeperIRR : public H323GatekeeperRequest
00640 {
00641 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00642 public:
00643 H323GatekeeperIRR(
00644 H323GatekeeperListener & listener,
00645 const H323RasPDU & pdu
00646 );
00647
00648 #if PTRACING
00649 virtual const char * GetName() const;
00650 #endif
00651 virtual PString GetGatekeeperIdentifier() const;
00652 virtual unsigned GetGatekeeperRejectTag() const;
00653 virtual PString GetEndpointIdentifier() const;
00654 virtual unsigned GetRegisteredEndPointRejectTag() const;
00655 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00656 virtual unsigned GetSecurityRejectTag() const;
00657 virtual void SetRejectReason(
00658 unsigned reasonCode
00659 );
00660
00661 H225_InfoRequestResponse & irr;
00662 H225_InfoRequestAck & iack;
00663 H225_InfoRequestNak & inak;
00664
00665 protected:
00666 virtual Response OnHandlePDU();
00667 };
00668
00669
00672 class H323GatekeeperCall : public PSafeObject
00673 {
00674 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00675 public:
00678 enum Direction {
00679 AnsweringCall,
00680 OriginatingCall,
00681 UnknownDirection
00682 };
00683
00686 H323GatekeeperCall(
00687 H323GatekeeperServer & server,
00688 const OpalGloballyUniqueID & callIdentifier,
00689 Direction direction
00690 );
00691
00694 ~H323GatekeeperCall();
00696
00701 Comparison Compare(
00702 const PObject & obj
00703 ) const;
00704
00707 void PrintOn(
00708 ostream & strm
00709 ) const;
00711
00719 virtual H323GatekeeperRequest::Response OnAdmission(
00720 H323GatekeeperARQ & request
00721 );
00722
00726 virtual BOOL Disengage(
00727 int reason = -1
00728 );
00729
00733 virtual H323GatekeeperRequest::Response OnDisengage(
00734 H323GatekeeperDRQ & request
00735 );
00736
00741 virtual H323GatekeeperRequest::Response OnBandwidth(
00742 H323GatekeeperBRQ & request
00743 );
00744
00748 virtual H323GatekeeperRequest::Response OnInfoResponse(
00749 H323GatekeeperIRR & request,
00750 H225_InfoRequestResponse_perCallInfo_subtype & call
00751 );
00752
00755 virtual void OnAlerting();
00756
00759 virtual void OnConnected();
00760
00771 virtual BOOL OnHeartbeat();
00772
00779 virtual PString GetCallCreditAmount() const;
00780
00787 virtual BOOL GetCallCreditMode() const;
00788
00796 virtual unsigned GetDurationLimit() const;
00797
00802 virtual BOOL SendCallCreditServiceControl();
00803
00806 BOOL AddCallCreditServiceControl(
00807 H225_ArrayOf_ServiceControlSession & serviceControl
00808 ) const;
00809
00814 virtual BOOL SendServiceControlSession(
00815 const H323ServiceControlSession & session
00816 );
00817
00823 virtual BOOL TranslateAliasAddress(
00824 const H225_AliasAddress & alias,
00825 H225_ArrayOf_AliasAddress & aliases,
00826 H323TransportAddress & address,
00827 BOOL & gkRouted
00828 );
00829
00831
00834 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00835 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00836 BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00837 unsigned GetCallReference() const { return callReference; }
00838 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00839 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00840 const PString & GetSourceNumber() const { return srcNumber; }
00841 const PStringArray & GetSourceAliases() const { return srcAliases; }
00842 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00843 PString GetSourceAddress() const;
00844 const PString & GetDestinationNumber() const { return dstNumber; }
00845 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00846 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00847 PString GetDestinationAddress() const;
00848 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00849 BOOL SetBandwidthUsed(unsigned bandwidth);
00850 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00851 const PTime & GetCallStartTime() const { return callStartTime; }
00852 const PTime & GetAlertingTime() const { return alertingTime; }
00853 const PTime & GetConnectedTime() const { return connectedTime; }
00854 const PTime & GetCallEndTime() const { return callEndTime; }
00855 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00857
00858 protected:
00859 void SetUsageInfo(const H225_RasUsageInformation & usage);
00860
00861 H323GatekeeperServer & gatekeeper;
00862 H323RegisteredEndPoint * endpoint;
00863 H323GatekeeperListener * rasChannel;
00864
00865 Direction direction;
00866 unsigned callReference;
00867 OpalGloballyUniqueID callIdentifier;
00868 OpalGloballyUniqueID conferenceIdentifier;
00869 PString srcNumber;
00870 PStringArray srcAliases;
00871 H323TransportAddress srcHost;
00872 PString dstNumber;
00873 PStringArray dstAliases;
00874 H323TransportAddress dstHost;
00875 unsigned bandwidthUsed;
00876 unsigned infoResponseRate;
00877 PTime lastInfoResponse;
00878
00879 BOOL drqReceived;
00880 PTime callStartTime;
00881 PTime alertingTime;
00882 PTime connectedTime;
00883 PTime callEndTime;
00884 H323Connection::CallEndReason callEndReason;
00885 };
00886
00887
00893 class H323RegisteredEndPoint : public PSafeObject
00894 {
00895 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00896 public:
00901 H323RegisteredEndPoint(
00902 H323GatekeeperServer & server,
00903 const PString & id
00904 );
00906
00911 Comparison Compare(
00912 const PObject & obj
00913 ) const;
00914
00917 void PrintOn(
00918 ostream & strm
00919 ) const;
00921
00928 void AddCall(
00929 H323GatekeeperCall * call
00930 );
00931
00936 BOOL RemoveCall(
00937 H323GatekeeperCall * call
00938 );
00939
00942 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00943
00946 H323GatekeeperCall & GetCall(
00947 PINDEX idx
00948 ) { return activeCalls[idx]; }
00950
00959 virtual H323GatekeeperRequest::Response OnRegistration(
00960 H323GatekeeperRRQ & request
00961 );
00962
00972 virtual H323GatekeeperRequest::Response OnFullRegistration(
00973 H323GatekeeperRRQ & request
00974 );
00975
00984 virtual H323GatekeeperRequest::Response OnSecureRegistration(
00985 H323GatekeeperRRQ & request
00986 );
00987
00991 virtual H323GatekeeperRequest::Response OnUnregistration(
00992 H323GatekeeperURQ & request
00993 );
00994
00998 virtual BOOL Unregister(
00999 int reason = -1
01000 );
01001
01006 virtual H323GatekeeperRequest::Response OnInfoResponse(
01007 H323GatekeeperIRR & request
01008 );
01009
01020 virtual BOOL OnTimeToLive();
01021
01033 virtual PString GetCallCreditAmount() const;
01034
01042 virtual BOOL GetCallCreditMode() const;
01043
01048 virtual BOOL SendServiceControlSession(
01049 const H323ServiceControlSession & session
01050 );
01051
01055 virtual BOOL AddServiceControlSession(
01056 const H323ServiceControlSession & session,
01057 H225_ArrayOf_ServiceControlSession & serviceControl
01058 );
01060
01065 virtual BOOL SetPassword(
01066 const PString & password,
01067 const PString & username = PString::Empty()
01068 );
01069
01072 const PString & GetIdentifier() const { return identifier; }
01073
01076 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01077
01080 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01081
01085 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01086
01090 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01091
01095 H323TransportAddress GetRASAddress(
01096 PINDEX idx
01097 ) const { return rasAddresses[idx]; }
01098
01102 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01103
01107 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01108
01112 H323TransportAddress GetSignalAddress(
01113 PINDEX idx
01114 ) const { return signalAddresses[idx]; }
01115
01118 const PStringArray & GetAliases() const { return aliases; }
01119
01122 BOOL ContainsAlias(
01123 const PString & alias
01124 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01125
01128 PINDEX GetAliasCount() const { return aliases.GetSize(); }
01129
01132 PString GetAlias(
01133 PINDEX idx
01134 ) const { return aliases[idx]; }
01135
01141 void RemoveAlias(
01142 const PString & alias
01143 );
01144
01147 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01148
01151 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01152
01155 PString GetPrefix(
01156 PINDEX idx
01157 ) const { return voicePrefixes[idx]; }
01158
01161 const PCaselessString & GetApplicationInfo() const { return applicationInfo; }
01162
01165 unsigned GetProtocolVersion() const { return protocolVersion; }
01166
01169 BOOL IsBehindNAT() const { return isBehindNAT; }
01170
01173 BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01174
01177 BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01178
01181 BOOL CanReceiveRIP() const;
01182
01185 BOOL GetH225Version() const { return h225Version; }
01187
01197 virtual BOOL OnSendDescriptorForEndpoint(
01198 H225_ArrayOf_AliasAddress & aliases,
01199 H225_EndpointType & terminalType,
01200 H225_ArrayOf_AliasAddress & transportAddresses
01201 );
01203
01204
01205 protected:
01206 H323GatekeeperServer & gatekeeper;
01207 H323GatekeeperListener * rasChannel;
01208
01209 PString identifier;
01210 OpalGloballyUniqueID descriptorID;
01211 H323TransportAddressArray rasAddresses;
01212 H323TransportAddressArray signalAddresses;
01213 PStringArray aliases;
01214 PStringArray voicePrefixes;
01215 PCaselessString applicationInfo;
01216 unsigned protocolVersion;
01217 BOOL isBehindNAT;
01218 BOOL canDisplayAmountString;
01219 BOOL canEnforceDurationLimit;
01220 unsigned h225Version;
01221 unsigned timeToLive;
01222 H235Authenticators authenticators;
01223
01224 PTime lastRegistration;
01225 PTime lastInfoResponse;
01226
01227 PSortedList<H323GatekeeperCall> activeCalls;
01228 POrdinalDictionary<PString> serviceControlSessions;
01229 };
01230
01231
01237 class H323GatekeeperListener : public H225_RAS
01238 {
01239 PCLASSINFO(H323GatekeeperListener, H225_RAS);
01240 public:
01245 H323GatekeeperListener(
01246 H323EndPoint & endpoint,
01247 H323GatekeeperServer & server,
01248 const PString & gatekeeperIdentifier,
01249 H323Transport * transport = NULL
01250 );
01251
01254 ~H323GatekeeperListener();
01256
01261 BOOL UnregistrationRequest(
01262 const H323RegisteredEndPoint & ep,
01263 unsigned reason
01264 );
01265
01268 BOOL DisengageRequest(
01269 const H323GatekeeperCall & call,
01270 unsigned reason
01271 );
01272
01275 virtual BOOL InfoRequest(
01276 H323RegisteredEndPoint & ep,
01277 H323GatekeeperCall * call = NULL
01278 );
01279
01282 virtual BOOL ServiceControlIndication(
01283 H323RegisteredEndPoint & ep,
01284 const H323ServiceControlSession & session,
01285 H323GatekeeperCall * call = NULL
01286 );
01288
01295 virtual H323GatekeeperRequest::Response OnDiscovery(
01296 H323GatekeeperGRQ & request
01297 );
01298
01303 virtual H323GatekeeperRequest::Response OnRegistration(
01304 H323GatekeeperRRQ & request
01305 );
01306
01311 virtual H323GatekeeperRequest::Response OnUnregistration(
01312 H323GatekeeperURQ & request
01313 );
01314
01319 virtual H323GatekeeperRequest::Response OnAdmission(
01320 H323GatekeeperARQ & request
01321 );
01322
01327 virtual H323GatekeeperRequest::Response OnDisengage(
01328 H323GatekeeperDRQ & request
01329 );
01330
01335 virtual H323GatekeeperRequest::Response OnBandwidth(
01336 H323GatekeeperBRQ & request
01337 );
01338
01343 virtual H323GatekeeperRequest::Response OnLocation(
01344 H323GatekeeperLRQ & request
01345 );
01346
01351 virtual H323GatekeeperRequest::Response OnInfoResponse(
01352 H323GatekeeperIRR & request
01353 );
01355
01358 virtual BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01359 virtual BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01360 virtual BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01361 virtual BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01362 virtual BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01363 virtual BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01364 virtual BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01365 virtual BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01366 virtual BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01367 virtual BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01368 virtual BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01369 virtual BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01370 virtual BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01371 virtual BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01372 virtual BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01374
01377 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01379
01380
01381 protected:
01382 H323GatekeeperServer & gatekeeper;
01383 };
01384
01385
01396 class H323GatekeeperServer : public H323TransactionServer
01397 {
01398 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01399 public:
01404 H323GatekeeperServer(
01405 H323EndPoint & endpoint
01406 );
01407
01410 ~H323GatekeeperServer();
01412
01413 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01414
01425 virtual H323Transactor * CreateListener(
01426 H323Transport * transport
01427 );
01428
01430
01436 virtual H323GatekeeperRequest::Response OnDiscovery(
01437 H323GatekeeperGRQ & request
01438 );
01439
01447 virtual H323GatekeeperRequest::Response OnRegistration(
01448 H323GatekeeperRRQ & request
01449 );
01450
01456 virtual H323GatekeeperRequest::Response OnUnregistration(
01457 H323GatekeeperURQ & request
01458 );
01459
01464 virtual H323GatekeeperRequest::Response OnInfoResponse(
01465 H323GatekeeperIRR & request
01466 );
01467
01478 virtual void AddEndPoint(
01479 H323RegisteredEndPoint * ep
01480 );
01481
01484 virtual BOOL RemoveEndPoint(
01485 H323RegisteredEndPoint * ep
01486 );
01487
01496 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01497 H323GatekeeperRRQ & request
01498 );
01499
01508 virtual PString CreateEndPointIdentifier();
01509
01512 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01513 const PString & identifier,
01514 PSafetyMode mode = PSafeReference
01515 );
01516
01519 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01520 const H225_ArrayOf_TransportAddress & addresses,
01521 PSafetyMode mode = PSafeReference
01522 );
01523
01526 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01527 const H323TransportAddress & address,
01528 PSafetyMode mode = PSafeReference
01529 );
01530
01533 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01534 const H225_AliasAddress & alias,
01535 PSafetyMode mode = PSafeReadWrite
01536 );
01537
01540 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01541 const PString & alias,
01542 PSafetyMode mode = PSafeReference
01543 );
01544
01547 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01548 const PString & alias,
01549 PSafetyMode mode = PSafeReference
01550 );
01551
01554 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01555 const PString & prefix,
01556 PSafetyMode mode = PSafeReference
01557 );
01558
01561 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01562 PSafetyMode mode = PSafeReference
01563 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01565
01566 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01567 const OpalGloballyUniqueID & id,
01568 H323GatekeeperCall::Direction direction
01569 );
01570
01578 virtual H323GatekeeperRequest::Response OnAdmission(
01579 H323GatekeeperARQ & request
01580 );
01581
01586 virtual H323GatekeeperRequest::Response OnDisengage(
01587 H323GatekeeperDRQ & request
01588 );
01589
01594 virtual H323GatekeeperRequest::Response OnBandwidth(
01595 H323GatekeeperBRQ & request
01596 );
01597
01606 virtual H323GatekeeperCall * CreateCall(
01607 const OpalGloballyUniqueID & callIdentifier,
01608 H323GatekeeperCall::Direction direction
01609 );
01610
01613 virtual void RemoveCall(
01614 H323GatekeeperCall * call
01615 );
01616
01619 virtual PSafePtr<H323GatekeeperCall> FindCall(
01620 const PString & description,
01621 PSafetyMode mode = PSafeReference
01622 );
01623
01626 virtual PSafePtr<H323GatekeeperCall> FindCall(
01627 const OpalGloballyUniqueID & callIdentifier,
01628 BOOL answeringCall,
01629 PSafetyMode mode = PSafeReference
01630 );
01631
01634 virtual PSafePtr<H323GatekeeperCall> FindCall(
01635 const OpalGloballyUniqueID & callIdentifier,
01636 H323GatekeeperCall::Direction direction,
01637 PSafetyMode mode = PSafeReference
01638 );
01639
01642 PSafePtr<H323GatekeeperCall> GetFirstCall(
01643 PSafetyMode mode = PSafeReference
01644 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01646
01656 virtual H323GatekeeperRequest::Response OnLocation(
01657 H323GatekeeperLRQ & request
01658 );
01659
01670 virtual BOOL TranslateAliasAddress(
01671 const H225_AliasAddress & alias,
01672 H225_ArrayOf_AliasAddress & aliases,
01673 H323TransportAddress & address,
01674 BOOL & isGKRouted
01675 );
01676
01696 virtual BOOL TranslateAliasAddressToSignalAddress(
01697 const H225_AliasAddress & alias,
01698 H323TransportAddress & address
01699 );
01701
01713 virtual BOOL CheckSignalAddressPolicy(
01714 const H323RegisteredEndPoint & ep,
01715 const H225_AdmissionRequest & arq,
01716 const H323TransportAddress & address
01717 );
01718
01731 virtual BOOL CheckAliasAddressPolicy(
01732 const H323RegisteredEndPoint & ep,
01733 const H225_AdmissionRequest & arq,
01734 const H225_AliasAddress & alias
01735 );
01736
01749 virtual BOOL CheckAliasStringPolicy(
01750 const H323RegisteredEndPoint & ep,
01751 const H225_AdmissionRequest & arq,
01752 const PString & alias
01753 );
01754
01760 virtual unsigned AllocateBandwidth(
01761 unsigned newBandwidth,
01762 unsigned oldBandwidth = 0
01763 );
01765
01777 virtual BOOL GetAdmissionRequestAuthentication(
01778 H323GatekeeperARQ & info,
01779 H235Authenticators & authenticators
01780 );
01781
01787 virtual BOOL GetUsersPassword(
01788 const PString & alias,
01789 PString & password,
01790 H323RegisteredEndPoint & registeredEndpoint
01791 ) const;
01792 virtual BOOL GetUsersPassword(
01793 const PString & alias,
01794 PString & password
01795 ) const;
01797
01802 H323PeerElement * GetPeerElement() const { return peerElement; }
01803
01807 void SetPeerElement(
01808 H323PeerElement * newPeerElement
01809 );
01810
01816 void CreatePeerElement(
01817 const H323TransportAddress & h501Interface
01818 );
01819
01825 BOOL OpenPeerElement(
01826 const H323TransportAddress & remotePeer,
01827 BOOL append = FALSE,
01828 BOOL keepTrying = TRUE
01829 );
01831
01836 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01837
01843 void SetGatekeeperIdentifier(
01844 const PString & id,
01845 BOOL adjustListeners = TRUE
01846 );
01847
01850 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01851
01854 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01855
01858 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01859
01862 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01863
01866 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01867
01870 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01871
01874 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01875
01878 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01879
01882 BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01883
01886 BOOL IsRequiredH235() const { return requireH235; }
01887
01890 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01891
01894 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01895
01898 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01899
01902 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01903
01906 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01907
01910 unsigned GetPeakCalls() const { return peakCalls; }
01911
01914 unsigned GetTotalCalls() const { return totalCalls; }
01915
01918 unsigned GetRejectedCalls() const { return rejectedCalls; }
01920
01921
01922 void RemoveAlias(
01923 H323RegisteredEndPoint & ep,
01924 const PString & alias
01925 );
01926
01927
01928 virtual BOOL OnSendDescriptorForEndpoint(
01929 H323RegisteredEndPoint & ,
01930 H225_ArrayOf_AliasAddress & ,
01931 H225_EndpointType & ,
01932 H225_ArrayOf_AliasAddress &
01933 )
01934 { return TRUE; }
01935
01936 virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01937 { return canHaveDuplicateAlias; }
01938
01939 protected:
01940
01941 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01942
01943
01944 PString gatekeeperIdentifier;
01945 unsigned totalBandwidth;
01946 unsigned usedBandwidth;
01947 unsigned defaultBandwidth;
01948 unsigned maximumBandwidth;
01949 unsigned defaultTimeToLive;
01950 unsigned defaultInfoResponseRate;
01951 BOOL overwriteOnSameSignalAddress;
01952 BOOL canHaveDuplicateAlias;
01953 BOOL canHaveDuplicatePrefix;
01954 BOOL canOnlyCallRegisteredEP;
01955 BOOL canOnlyAnswerRegisteredEP;
01956 BOOL answerCallPreGrantedARQ;
01957 BOOL makeCallPreGrantedARQ;
01958 BOOL isGatekeeperRouted;
01959 BOOL aliasCanBeHostName;
01960 BOOL requireH235;
01961 BOOL disengageOnHearbeatFail;
01962
01963 PStringToString passwords;
01964
01965
01966 PMutex mutex;
01967 time_t identifierBase;
01968 unsigned nextIdentifier;
01969 PThread * monitorThread;
01970 PSyncPoint monitorExit;
01971
01972 PLIST(ListenerList, H323GatekeeperListener);
01973 ListenerList listeners;
01974
01975 H323PeerElement * peerElement;
01976
01977 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01978
01979 class StringMap : public PString {
01980 PCLASSINFO(StringMap, PString);
01981 public:
01982 StringMap(const PString & from, const PString & id)
01983 : PString(from), identifier(id) { }
01984 PString identifier;
01985 };
01986 PSortedStringList byAddress;
01987 PSortedStringList byAlias;
01988 PSortedStringList byVoicePrefix;
01989
01990 PSafeSortedList<H323GatekeeperCall> activeCalls;
01991
01992 PINDEX peakRegistrations;
01993 PINDEX totalRegistrations;
01994 PINDEX rejectedRegistrations;
01995 PINDEX peakCalls;
01996 PINDEX totalCalls;
01997 PINDEX rejectedCalls;
01998
01999 friend class H323GatekeeperRRQ;
02000 friend class H323GatekeeperARQ;
02001 };
02002
02003
02004 #endif // __OPAL_GKSERVER_H
02005
02006
02008