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
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 #ifndef __OPAL_GKSERVER_H
00393 #define __OPAL_GKSERVER_H
00394
00395 #ifdef P_USE_PRAGMA
00396 #pragma interface
00397 #endif
00398
00399
00400 #include <ptlib/safecoll.h>
00401 #include <opal/guid.h>
00402 #include <h323/h225ras.h>
00403 #include <h323/transaddr.h>
00404 #include <h323/h235auth.h>
00405 #include <h323/h323pdu.h>
00406 #include <h323/h323trans.h>
00407
00408
00409 class PASN_Sequence;
00410 class PASN_Choice;
00411
00412 class H225_AliasAddress;
00413 class H225_EndpointIdentifier;
00414 class H225_GatekeeperIdentifier;
00415 class H225_ArrayOf_TransportAddress;
00416 class H225_GatekeeperIdentifier;
00417 class H225_EndpointIdentifier;
00418 class H225_InfoRequestResponse_perCallInfo_subtype;
00419 class H225_RasUsageInformation;
00420
00421 class H323RegisteredEndPoint;
00422 class H323GatekeeperListener;
00423 class H323GatekeeperServer;
00424 class H323RasPDU;
00425 class H323PeerElement;
00426
00427
00428 class H323GatekeeperRequest : public H323Transaction
00429 {
00430 PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00431 public:
00436 H323GatekeeperRequest(
00437 H323GatekeeperListener & rasChannel,
00438 const H323RasPDU & pdu
00439 );
00441
00442 virtual H323TransactionPDU * CreateRIP(
00443 unsigned sequenceNumber,
00444 unsigned delay
00445 ) const;
00446
00447 virtual BOOL WritePDU(
00448 H323TransactionPDU & pdu
00449 );
00450 BOOL CheckCryptoTokens();
00451 BOOL CheckGatekeeperIdentifier();
00452 BOOL GetRegisteredEndPoint();
00453
00454 virtual PString GetGatekeeperIdentifier() const = 0;
00455 virtual unsigned GetGatekeeperRejectTag() const = 0;
00456 virtual PString GetEndpointIdentifier() const = 0;
00457 virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00458 virtual unsigned GetSecurityRejectTag() const = 0;
00459
00460 H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00461
00462 PSafePtr<H323RegisteredEndPoint> endpoint;
00463
00464 protected:
00465 H323GatekeeperListener & rasChannel;
00466 };
00467
00468
00469 class H323GatekeeperGRQ : public H323GatekeeperRequest
00470 {
00471 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00472 public:
00473 H323GatekeeperGRQ(
00474 H323GatekeeperListener & listener,
00475 const H323RasPDU & pdu
00476 );
00477
00478 #if PTRACING
00479 virtual const char * GetName() const;
00480 #endif
00481 virtual PString GetGatekeeperIdentifier() const;
00482 virtual unsigned GetGatekeeperRejectTag() const;
00483 virtual PString GetEndpointIdentifier() const;
00484 virtual unsigned GetRegisteredEndPointRejectTag() const;
00485 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00486 virtual unsigned GetSecurityRejectTag() const;
00487 virtual void SetRejectReason(
00488 unsigned reasonCode
00489 );
00490
00491 H225_GatekeeperRequest & grq;
00492 H225_GatekeeperConfirm & gcf;
00493 H225_GatekeeperReject & grj;
00494
00495 protected:
00496 virtual Response OnHandlePDU();
00497 };
00498
00499
00500 class H323GatekeeperRRQ : public H323GatekeeperRequest
00501 {
00502 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00503 public:
00504 H323GatekeeperRRQ(
00505 H323GatekeeperListener & listener,
00506 const H323RasPDU & pdu
00507 );
00508
00509 #if PTRACING
00510 virtual const char * GetName() const;
00511 #endif
00512 virtual PString GetGatekeeperIdentifier() const;
00513 virtual unsigned GetGatekeeperRejectTag() const;
00514 virtual PString GetEndpointIdentifier() const;
00515 virtual unsigned GetRegisteredEndPointRejectTag() const;
00516 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00517 virtual unsigned GetSecurityRejectTag() const;
00518 virtual void SetRejectReason(
00519 unsigned reasonCode
00520 );
00521
00522 H225_RegistrationRequest & rrq;
00523 H225_RegistrationConfirm & rcf;
00524 H225_RegistrationReject & rrj;
00525
00526 protected:
00527 virtual Response OnHandlePDU();
00528 };
00529
00530
00531 class H323GatekeeperURQ : public H323GatekeeperRequest
00532 {
00533 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00534 public:
00535 H323GatekeeperURQ(
00536 H323GatekeeperListener & listener,
00537 const H323RasPDU & pdu
00538 );
00539
00540 #if PTRACING
00541 virtual const char * GetName() const;
00542 #endif
00543 virtual PString GetGatekeeperIdentifier() const;
00544 virtual unsigned GetGatekeeperRejectTag() const;
00545 virtual PString GetEndpointIdentifier() const;
00546 virtual unsigned GetRegisteredEndPointRejectTag() const;
00547 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00548 virtual unsigned GetSecurityRejectTag() const;
00549 virtual void SetRejectReason(
00550 unsigned reasonCode
00551 );
00552
00553 H225_UnregistrationRequest & urq;
00554 H225_UnregistrationConfirm & ucf;
00555 H225_UnregistrationReject & urj;
00556
00557 protected:
00558 virtual Response OnHandlePDU();
00559 };
00560
00561
00562 class H323GatekeeperARQ : public H323GatekeeperRequest
00563 {
00564 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00565 public:
00566 H323GatekeeperARQ(
00567 H323GatekeeperListener & listener,
00568 const H323RasPDU & pdu
00569 );
00570
00571 #if PTRACING
00572 virtual const char * GetName() const;
00573 #endif
00574 virtual PString GetGatekeeperIdentifier() const;
00575 virtual unsigned GetGatekeeperRejectTag() const;
00576 virtual PString GetEndpointIdentifier() const;
00577 virtual unsigned GetRegisteredEndPointRejectTag() const;
00578 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00579 virtual unsigned GetSecurityRejectTag() const;
00580 virtual void SetRejectReason(
00581 unsigned reasonCode
00582 );
00583
00584 H225_AdmissionRequest & arq;
00585 H225_AdmissionConfirm & acf;
00586 H225_AdmissionReject & arj;
00587
00588 PString alternateSecurityID;
00589
00590 protected:
00591 virtual Response OnHandlePDU();
00592 };
00593
00594
00595 class H323GatekeeperDRQ : public H323GatekeeperRequest
00596 {
00597 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00598 public:
00599 H323GatekeeperDRQ(
00600 H323GatekeeperListener & listener,
00601 const H323RasPDU & pdu
00602 );
00603
00604 #if PTRACING
00605 virtual const char * GetName() const;
00606 #endif
00607 virtual PString GetGatekeeperIdentifier() const;
00608 virtual unsigned GetGatekeeperRejectTag() const;
00609 virtual PString GetEndpointIdentifier() const;
00610 virtual unsigned GetRegisteredEndPointRejectTag() const;
00611 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00612 virtual unsigned GetSecurityRejectTag() const;
00613 virtual void SetRejectReason(
00614 unsigned reasonCode
00615 );
00616
00617 H225_DisengageRequest & drq;
00618 H225_DisengageConfirm & dcf;
00619 H225_DisengageReject & drj;
00620
00621 protected:
00622 virtual Response OnHandlePDU();
00623 };
00624
00625
00626 class H323GatekeeperBRQ : public H323GatekeeperRequest
00627 {
00628 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00629 public:
00630 H323GatekeeperBRQ(
00631 H323GatekeeperListener & listener,
00632 const H323RasPDU & pdu
00633 );
00634
00635 #if PTRACING
00636 virtual const char * GetName() const;
00637 #endif
00638 virtual PString GetGatekeeperIdentifier() const;
00639 virtual unsigned GetGatekeeperRejectTag() const;
00640 virtual PString GetEndpointIdentifier() const;
00641 virtual unsigned GetRegisteredEndPointRejectTag() const;
00642 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00643 virtual unsigned GetSecurityRejectTag() const;
00644 virtual void SetRejectReason(
00645 unsigned reasonCode
00646 );
00647
00648 H225_BandwidthRequest & brq;
00649 H225_BandwidthConfirm & bcf;
00650 H225_BandwidthReject & brj;
00651
00652 protected:
00653 virtual Response OnHandlePDU();
00654 };
00655
00656
00657 class H323GatekeeperLRQ : public H323GatekeeperRequest
00658 {
00659 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00660 public:
00661 H323GatekeeperLRQ(
00662 H323GatekeeperListener & listener,
00663 const H323RasPDU & pdu
00664 );
00665
00666 #if PTRACING
00667 virtual const char * GetName() const;
00668 #endif
00669 virtual PString GetGatekeeperIdentifier() const;
00670 virtual unsigned GetGatekeeperRejectTag() const;
00671 virtual PString GetEndpointIdentifier() const;
00672 virtual unsigned GetRegisteredEndPointRejectTag() const;
00673 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00674 virtual unsigned GetSecurityRejectTag() const;
00675 virtual void SetRejectReason(
00676 unsigned reasonCode
00677 );
00678
00679 H225_LocationRequest & lrq;
00680 H225_LocationConfirm & lcf;
00681 H225_LocationReject & lrj;
00682
00683 protected:
00684 virtual Response OnHandlePDU();
00685 };
00686
00687
00688 class H323GatekeeperIRR : public H323GatekeeperRequest
00689 {
00690 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00691 public:
00692 H323GatekeeperIRR(
00693 H323GatekeeperListener & listener,
00694 const H323RasPDU & pdu
00695 );
00696
00697 #if PTRACING
00698 virtual const char * GetName() const;
00699 #endif
00700 virtual PString GetGatekeeperIdentifier() const;
00701 virtual unsigned GetGatekeeperRejectTag() const;
00702 virtual PString GetEndpointIdentifier() const;
00703 virtual unsigned GetRegisteredEndPointRejectTag() const;
00704 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00705 virtual unsigned GetSecurityRejectTag() const;
00706 virtual void SetRejectReason(
00707 unsigned reasonCode
00708 );
00709
00710 H225_InfoRequestResponse & irr;
00711 H225_InfoRequestAck & iack;
00712 H225_InfoRequestNak & inak;
00713
00714 protected:
00715 virtual Response OnHandlePDU();
00716 };
00717
00718
00721 class H323GatekeeperCall : public PSafeObject
00722 {
00723 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00724 public:
00727 enum Direction {
00728 AnsweringCall,
00729 OriginatingCall,
00730 UnknownDirection
00731 };
00732
00735 H323GatekeeperCall(
00736 H323GatekeeperServer & server,
00737 const OpalGloballyUniqueID & callIdentifier,
00738 Direction direction
00739 );
00740
00743 ~H323GatekeeperCall();
00745
00750 Comparison Compare(
00751 const PObject & obj
00752 ) const;
00753
00756 void PrintOn(
00757 ostream & strm
00758 ) const;
00760
00768 virtual H323GatekeeperRequest::Response OnAdmission(
00769 H323GatekeeperARQ & request
00770 );
00771
00775 virtual BOOL Disengage(
00776 int reason = -1
00777 );
00778
00782 virtual H323GatekeeperRequest::Response OnDisengage(
00783 H323GatekeeperDRQ & request
00784 );
00785
00790 virtual H323GatekeeperRequest::Response OnBandwidth(
00791 H323GatekeeperBRQ & request
00792 );
00793
00797 virtual H323GatekeeperRequest::Response OnInfoResponse(
00798 H323GatekeeperIRR & request,
00799 H225_InfoRequestResponse_perCallInfo_subtype & call
00800 );
00801
00804 virtual void OnAlerting();
00805
00808 virtual void OnConnected();
00809
00820 virtual BOOL OnHeartbeat();
00821
00828 virtual PString GetCallCreditAmount() const;
00829
00836 virtual BOOL GetCallCreditMode() const;
00837
00845 virtual unsigned GetDurationLimit() const;
00846
00851 virtual BOOL SendCallCreditServiceControl();
00852
00855 BOOL AddCallCreditServiceControl(
00856 H225_ArrayOf_ServiceControlSession & serviceControl
00857 ) const;
00858
00863 virtual BOOL SendServiceControlSession(
00864 const H323ServiceControlSession & session
00865 );
00866
00872 virtual BOOL TranslateAliasAddress(
00873 const H225_AliasAddress & alias,
00874 H225_ArrayOf_AliasAddress & aliases,
00875 H323TransportAddress & address,
00876 BOOL & isGkRouted
00877 );
00878
00880
00883 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00884 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00885 BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00886 unsigned GetCallReference() const { return callReference; }
00887 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00888 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00889 const PString & GetSourceNumber() const { return srcNumber; }
00890 const PStringArray & GetSourceAliases() const { return srcAliases; }
00891 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00892 PString GetSourceAddress() const;
00893 const PString & GetDestinationNumber() const { return dstNumber; }
00894 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00895 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00896 PString GetDestinationAddress() const;
00897 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00898 BOOL SetBandwidthUsed(unsigned bandwidth);
00899 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00900 const PTime & GetCallStartTime() const { return callStartTime; }
00901 const PTime & GetAlertingTime() const { return alertingTime; }
00902 const PTime & GetConnectedTime() const { return connectedTime; }
00903 const PTime & GetCallEndTime() const { return callEndTime; }
00904 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00906
00907 protected:
00908 void SetUsageInfo(const H225_RasUsageInformation & usage);
00909
00910 H323GatekeeperServer & gatekeeper;
00911 H323RegisteredEndPoint * endpoint;
00912 H323GatekeeperListener * rasChannel;
00913
00914 Direction direction;
00915 unsigned callReference;
00916 OpalGloballyUniqueID callIdentifier;
00917 OpalGloballyUniqueID conferenceIdentifier;
00918 PString srcNumber;
00919 PStringArray srcAliases;
00920 H323TransportAddress srcHost;
00921 PString dstNumber;
00922 PStringArray dstAliases;
00923 H323TransportAddress dstHost;
00924 unsigned bandwidthUsed;
00925 unsigned infoResponseRate;
00926 PTime lastInfoResponse;
00927
00928 BOOL drqReceived;
00929 PTime callStartTime;
00930 PTime alertingTime;
00931 PTime connectedTime;
00932 PTime callEndTime;
00933 H323Connection::CallEndReason callEndReason;
00934 };
00935
00936
00942 class H323RegisteredEndPoint : public PSafeObject
00943 {
00944 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00945 public:
00950 H323RegisteredEndPoint(
00951 H323GatekeeperServer & server,
00952 const PString & id
00953 );
00955
00960 Comparison Compare(
00961 const PObject & obj
00962 ) const;
00963
00966 void PrintOn(
00967 ostream & strm
00968 ) const;
00970
00977 virtual void AddCall(
00978 H323GatekeeperCall * call
00979 );
00980
00985 virtual BOOL RemoveCall(
00986 H323GatekeeperCall * call
00987 );
00988
00991 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00992
00995 H323GatekeeperCall & GetCall(
00996 PINDEX idx
00997 ) { return activeCalls[idx]; }
00999
01008 virtual H323GatekeeperRequest::Response OnRegistration(
01009 H323GatekeeperRRQ & request
01010 );
01011
01021 virtual H323GatekeeperRequest::Response OnFullRegistration(
01022 H323GatekeeperRRQ & request
01023 );
01024
01033 virtual H323GatekeeperRequest::Response OnSecureRegistration(
01034 H323GatekeeperRRQ & request
01035 );
01036
01040 virtual H323GatekeeperRequest::Response OnUnregistration(
01041 H323GatekeeperURQ & request
01042 );
01043
01047 virtual BOOL Unregister(
01048 int reason = -1
01049 );
01050
01055 virtual H323GatekeeperRequest::Response OnInfoResponse(
01056 H323GatekeeperIRR & request
01057 );
01058
01069 virtual BOOL OnTimeToLive();
01070
01082 virtual PString GetCallCreditAmount() const;
01083
01091 virtual BOOL GetCallCreditMode() const;
01092
01097 virtual BOOL SendServiceControlSession(
01098 const H323ServiceControlSession & session
01099 );
01100
01104 virtual BOOL AddServiceControlSession(
01105 const H323ServiceControlSession & session,
01106 H225_ArrayOf_ServiceControlSession & serviceControl
01107 );
01109
01114 virtual BOOL SetPassword(
01115 const PString & password,
01116 const PString & username = PString::Empty()
01117 );
01118
01121 const PString & GetIdentifier() const { return identifier; }
01122
01125 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01126
01129 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01130
01134 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01135
01139 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01140
01144 H323TransportAddress GetRASAddress(
01145 PINDEX idx
01146 ) const { return rasAddresses[idx]; }
01147
01151 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01152
01156 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01157
01161 H323TransportAddress GetSignalAddress(
01162 PINDEX idx
01163 ) const { return signalAddresses[idx]; }
01164
01167 const PStringArray & GetAliases() const { return aliases; }
01168
01171 BOOL ContainsAlias(
01172 const PString & alias
01173 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01174
01177 PINDEX GetAliasCount() const { return aliases.GetSize(); }
01178
01181 PString GetAlias(
01182 PINDEX idx
01183 ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01184
01190 void RemoveAlias(
01191 const PString & alias
01192 );
01193
01196 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01197
01200 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01201
01204 PString GetPrefix(
01205 PINDEX idx
01206 ) const { return voicePrefixes[idx]; }
01207
01210 PCaselessString GetApplicationInfo() const { return productInfo.AsString(); }
01211
01214 const OpalProductInfo & GetProductInfo() const { return productInfo; }
01215
01218 unsigned GetProtocolVersion() const { return protocolVersion; }
01219
01222 BOOL IsBehindNAT() const { return isBehindNAT; }
01223
01226 BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01227
01230 BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01231
01234 BOOL CanReceiveRIP() const;
01235
01238 BOOL GetH225Version() const { return h225Version; }
01240
01250 virtual BOOL OnSendDescriptorForEndpoint(
01251 H225_ArrayOf_AliasAddress & aliases,
01252 H225_EndpointType & terminalType,
01253 H225_ArrayOf_AliasAddress & transportAddresses
01254 );
01256
01257
01258 protected:
01259 H323GatekeeperServer & gatekeeper;
01260 H323GatekeeperListener * rasChannel;
01261
01262 PString identifier;
01263 OpalGloballyUniqueID descriptorID;
01264 H323TransportAddressArray rasAddresses;
01265 H323TransportAddressArray signalAddresses;
01266 PStringArray aliases;
01267 PStringArray voicePrefixes;
01268 OpalProductInfo productInfo;
01269 unsigned protocolVersion;
01270 BOOL isBehindNAT;
01271 BOOL canDisplayAmountString;
01272 BOOL canEnforceDurationLimit;
01273 unsigned h225Version;
01274 unsigned timeToLive;
01275 H235Authenticators authenticators;
01276
01277 PTime lastRegistration;
01278 PTime lastInfoResponse;
01279
01280 PSortedList<H323GatekeeperCall> activeCalls;
01281 POrdinalDictionary<PString> serviceControlSessions;
01282 };
01283
01284
01290 class H323GatekeeperListener : public H225_RAS
01291 {
01292 PCLASSINFO(H323GatekeeperListener, H225_RAS);
01293 public:
01298 H323GatekeeperListener(
01299 H323EndPoint & endpoint,
01300 H323GatekeeperServer & server,
01301 const PString & gatekeeperIdentifier,
01302 H323Transport * transport = NULL
01303 );
01304
01307 ~H323GatekeeperListener();
01309
01314 BOOL UnregistrationRequest(
01315 const H323RegisteredEndPoint & ep,
01316 unsigned reason
01317 );
01318
01321 BOOL DisengageRequest(
01322 const H323GatekeeperCall & call,
01323 unsigned reason
01324 );
01325
01328 virtual BOOL InfoRequest(
01329 H323RegisteredEndPoint & ep,
01330 H323GatekeeperCall * call = NULL
01331 );
01332
01335 virtual BOOL ServiceControlIndication(
01336 H323RegisteredEndPoint & ep,
01337 const H323ServiceControlSession & session,
01338 H323GatekeeperCall * call = NULL
01339 );
01341
01348 virtual H323GatekeeperRequest::Response OnDiscovery(
01349 H323GatekeeperGRQ & request
01350 );
01351
01356 virtual H323GatekeeperRequest::Response OnRegistration(
01357 H323GatekeeperRRQ & request
01358 );
01359
01364 virtual H323GatekeeperRequest::Response OnUnregistration(
01365 H323GatekeeperURQ & request
01366 );
01367
01372 virtual H323GatekeeperRequest::Response OnAdmission(
01373 H323GatekeeperARQ & request
01374 );
01375
01380 virtual H323GatekeeperRequest::Response OnDisengage(
01381 H323GatekeeperDRQ & request
01382 );
01383
01388 virtual H323GatekeeperRequest::Response OnBandwidth(
01389 H323GatekeeperBRQ & request
01390 );
01391
01396 virtual H323GatekeeperRequest::Response OnLocation(
01397 H323GatekeeperLRQ & request
01398 );
01399
01404 virtual H323GatekeeperRequest::Response OnInfoResponse(
01405 H323GatekeeperIRR & request
01406 );
01408
01411 virtual BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01412 virtual BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01413 virtual BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01414 virtual BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01415 virtual BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01416 virtual BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01417 virtual BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01418 virtual BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01419 virtual BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01420 virtual BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01421 virtual BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01422 virtual BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01423 virtual BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01424 virtual BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01425 virtual BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01426 virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01427 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01429
01432 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01434
01435
01436 protected:
01437 H323GatekeeperServer & gatekeeper;
01438 };
01439
01440
01451 class H323GatekeeperServer : public H323TransactionServer
01452 {
01453 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01454 public:
01459 H323GatekeeperServer(
01460 H323EndPoint & endpoint
01461 );
01462
01465 ~H323GatekeeperServer();
01467
01468 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01469
01480 virtual H323Transactor * CreateListener(
01481 H323Transport * transport
01482 );
01483
01485
01491 virtual H323GatekeeperRequest::Response OnDiscovery(
01492 H323GatekeeperGRQ & request
01493 );
01494
01502 virtual H323GatekeeperRequest::Response OnRegistration(
01503 H323GatekeeperRRQ & request
01504 );
01505
01511 virtual H323GatekeeperRequest::Response OnUnregistration(
01512 H323GatekeeperURQ & request
01513 );
01514
01519 virtual H323GatekeeperRequest::Response OnInfoResponse(
01520 H323GatekeeperIRR & request
01521 );
01522
01533 virtual void AddEndPoint(
01534 H323RegisteredEndPoint * ep
01535 );
01536
01539 virtual BOOL RemoveEndPoint(
01540 H323RegisteredEndPoint * ep
01541 );
01542
01551 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01552 H323GatekeeperRRQ & request
01553 );
01554
01563 virtual PString CreateEndPointIdentifier();
01564
01567 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01568 const PString & identifier,
01569 PSafetyMode mode = PSafeReference
01570 );
01571
01574 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01575 const H225_ArrayOf_TransportAddress & addresses,
01576 PSafetyMode mode = PSafeReference
01577 );
01578
01581 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01582 const H323TransportAddress & address,
01583 PSafetyMode mode = PSafeReference
01584 );
01585
01588 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01589 const H225_AliasAddress & alias,
01590 PSafetyMode mode = PSafeReadWrite
01591 );
01592
01595 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01596 const PString & alias,
01597 PSafetyMode mode = PSafeReference
01598 );
01599
01602 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01603 const PString & alias,
01604 PSafetyMode mode = PSafeReference
01605 );
01606
01609 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01610 const PString & prefix,
01611 PSafetyMode mode = PSafeReference
01612 );
01613
01616 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01617 PSafetyMode mode = PSafeReference
01618 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01620
01621 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01622 const OpalGloballyUniqueID & id,
01623 H323GatekeeperCall::Direction direction
01624 );
01625
01633 virtual H323GatekeeperRequest::Response OnAdmission(
01634 H323GatekeeperARQ & request
01635 );
01636
01641 virtual H323GatekeeperRequest::Response OnDisengage(
01642 H323GatekeeperDRQ & request
01643 );
01644
01649 virtual H323GatekeeperRequest::Response OnBandwidth(
01650 H323GatekeeperBRQ & request
01651 );
01652
01661 virtual H323GatekeeperCall * CreateCall(
01662 const OpalGloballyUniqueID & callIdentifier,
01663 H323GatekeeperCall::Direction direction
01664 );
01665
01668 virtual void AddCall(H323GatekeeperCall *)
01669 { }
01670
01673 virtual void RemoveCall(
01674 H323GatekeeperCall * call
01675 );
01676
01679 virtual PSafePtr<H323GatekeeperCall> FindCall(
01680 const PString & description,
01681 PSafetyMode mode = PSafeReference
01682 );
01683
01686 virtual PSafePtr<H323GatekeeperCall> FindCall(
01687 const OpalGloballyUniqueID & callIdentifier,
01688 BOOL answeringCall,
01689 PSafetyMode mode = PSafeReference
01690 );
01691
01694 virtual PSafePtr<H323GatekeeperCall> FindCall(
01695 const OpalGloballyUniqueID & callIdentifier,
01696 H323GatekeeperCall::Direction direction,
01697 PSafetyMode mode = PSafeReference
01698 );
01699
01702 PSafePtr<H323GatekeeperCall> GetFirstCall(
01703 PSafetyMode mode = PSafeReference
01704 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01706
01716 virtual H323GatekeeperRequest::Response OnLocation(
01717 H323GatekeeperLRQ & request
01718 );
01719
01731 virtual BOOL TranslateAliasAddress(
01732 const H225_AliasAddress & alias,
01733 H225_ArrayOf_AliasAddress & aliases,
01734 H323TransportAddress & address,
01735 BOOL & isGkRouted,
01736 H323GatekeeperCall * call
01737 );
01738
01758 virtual BOOL TranslateAliasAddressToSignalAddress(
01759 const H225_AliasAddress & alias,
01760 H323TransportAddress & address
01761 );
01763
01775 virtual BOOL CheckSignalAddressPolicy(
01776 const H323RegisteredEndPoint & ep,
01777 const H225_AdmissionRequest & arq,
01778 const H323TransportAddress & address
01779 );
01780
01793 virtual BOOL CheckAliasAddressPolicy(
01794 const H323RegisteredEndPoint & ep,
01795 const H225_AdmissionRequest & arq,
01796 const H225_AliasAddress & alias
01797 );
01798
01811 virtual BOOL CheckAliasStringPolicy(
01812 const H323RegisteredEndPoint & ep,
01813 const H225_AdmissionRequest & arq,
01814 const PString & alias
01815 );
01816
01822 virtual unsigned AllocateBandwidth(
01823 unsigned newBandwidth,
01824 unsigned oldBandwidth = 0
01825 );
01827
01839 virtual BOOL GetAdmissionRequestAuthentication(
01840 H323GatekeeperARQ & info,
01841 H235Authenticators & authenticators
01842 );
01843
01849 virtual BOOL GetUsersPassword(
01850 const PString & alias,
01851 PString & password,
01852 H323RegisteredEndPoint & registeredEndpoint
01853 ) const;
01854 virtual BOOL GetUsersPassword(
01855 const PString & alias,
01856 PString & password
01857 ) const;
01859
01864 H323PeerElement * GetPeerElement() const { return peerElement; }
01865
01869 void SetPeerElement(
01870 H323PeerElement * newPeerElement
01871 );
01872
01878 void CreatePeerElement(
01879 const H323TransportAddress & h501Interface
01880 );
01881
01887 BOOL OpenPeerElement(
01888 const H323TransportAddress & remotePeer,
01889 BOOL append = FALSE,
01890 BOOL keepTrying = TRUE
01891 );
01893
01898 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01899
01905 void SetGatekeeperIdentifier(
01906 const PString & id,
01907 BOOL adjustListeners = TRUE
01908 );
01909
01912 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01913
01916 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01917
01920 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01921
01924 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01925
01928 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01929
01932 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01933
01936 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01937
01940 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01941
01944 BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01945
01948 BOOL IsRequiredH235() const { return requireH235; }
01949
01952 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01953
01956 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01957
01960 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01961
01964 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01965
01968 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01969
01972 unsigned GetPeakCalls() const { return peakCalls; }
01973
01976 unsigned GetTotalCalls() const { return totalCalls; }
01977
01980 unsigned GetRejectedCalls() const { return rejectedCalls; }
01982
01983
01984 void RemoveAlias(
01985 H323RegisteredEndPoint & ep,
01986 const PString & alias
01987 );
01988
01989
01990 virtual BOOL OnSendDescriptorForEndpoint(
01991 H323RegisteredEndPoint & ,
01992 H225_ArrayOf_AliasAddress & ,
01993 H225_EndpointType & ,
01994 H225_ArrayOf_AliasAddress &
01995 )
01996 { return TRUE; }
01997
01998 virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01999 { return canHaveDuplicateAlias; }
02000
02001 virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
02002 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
02003
02004 protected:
02005
02006 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
02007
02008
02009 PString gatekeeperIdentifier;
02010 unsigned totalBandwidth;
02011 unsigned usedBandwidth;
02012 unsigned defaultBandwidth;
02013 unsigned maximumBandwidth;
02014 unsigned defaultTimeToLive;
02015 unsigned defaultInfoResponseRate;
02016 BOOL overwriteOnSameSignalAddress;
02017 BOOL canHaveDuplicateAlias;
02018 BOOL canHaveDuplicatePrefix;
02019 BOOL canOnlyCallRegisteredEP;
02020 BOOL canOnlyAnswerRegisteredEP;
02021 BOOL answerCallPreGrantedARQ;
02022 BOOL makeCallPreGrantedARQ;
02023 BOOL isGatekeeperRouted;
02024 BOOL aliasCanBeHostName;
02025 BOOL requireH235;
02026 BOOL disengageOnHearbeatFail;
02027
02028 PStringToString passwords;
02029
02030
02031 PMutex mutex;
02032 time_t identifierBase;
02033 unsigned nextIdentifier;
02034 PThread * monitorThread;
02035 PSyncPoint monitorExit;
02036
02037 PLIST(ListenerList, H323GatekeeperListener);
02038 ListenerList listeners;
02039
02040 H323PeerElement * peerElement;
02041
02042 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
02043
02044 class StringMap : public PString {
02045 PCLASSINFO(StringMap, PString);
02046 public:
02047 StringMap(const PString & from, const PString & id)
02048 : PString(from), identifier(id) { }
02049 PString identifier;
02050 };
02051 PSortedStringList byAddress;
02052 PSortedStringList byAlias;
02053 PSortedStringList byVoicePrefix;
02054
02055 PSafeSortedList<H323GatekeeperCall> activeCalls;
02056
02057 PINDEX peakRegistrations;
02058 PINDEX totalRegistrations;
02059 PINDEX rejectedRegistrations;
02060 PINDEX peakCalls;
02061 PINDEX totalCalls;
02062 PINDEX rejectedCalls;
02063
02064 friend class H323GatekeeperRRQ;
02065 friend class H323GatekeeperARQ;
02066 };
02067
02068
02069 #endif // __OPAL_GKSERVER_H
02070
02071
02073