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 #ifndef __OPAL_GKSERVER_H
00326 #define __OPAL_GKSERVER_H
00327
00328 #ifdef P_USE_PRAGMA
00329 #pragma interface
00330 #endif
00331
00332
00333 #include "h323ep.h"
00334 #include "h225ras.h"
00335 #include "guid.h"
00336 #include "h235auth.h"
00337 #include "h323pdu.h"
00338 #include "h323trans.h"
00339
00340 #include <ptlib/safecoll.h>
00341
00342
00343 class PASN_Sequence;
00344 class PASN_Choice;
00345
00346 class H225_AliasAddress;
00347 class H225_ArrayOf_TransportAddress;
00348 class H225_GatekeeperIdentifier;
00349 class H225_EndpointIdentifier;
00350 class H225_InfoRequestResponse_perCallInfo_subtype;
00351 class H225_RasUsageInformation;
00352
00353 class H323RegisteredEndPoint;
00354 class H323GatekeeperListener;
00355 class H323GatekeeperServer;
00356 class H323RasPDU;
00357 class H323PeerElement;
00358
00359
00360 class H323GatekeeperRequest : public H323Transaction
00361 {
00362 PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00363 public:
00368 H323GatekeeperRequest(
00369 H323GatekeeperListener & rasChannel,
00370 const H323RasPDU & pdu
00371 );
00373
00374 virtual H323TransactionPDU * CreateRIP(
00375 unsigned sequenceNumber,
00376 unsigned delay
00377 ) const;
00378
00379 virtual BOOL WritePDU(
00380 H323TransactionPDU & pdu
00381 );
00382 BOOL CheckCryptoTokens();
00383 BOOL CheckGatekeeperIdentifier();
00384 BOOL GetRegisteredEndPoint();
00385
00386 virtual PString GetGatekeeperIdentifier() const = 0;
00387 virtual unsigned GetGatekeeperRejectTag() const = 0;
00388 virtual PString GetEndpointIdentifier() const = 0;
00389 virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00390 virtual unsigned GetSecurityRejectTag() const = 0;
00391
00392 H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00393
00394 PSafePtr<H323RegisteredEndPoint> endpoint;
00395
00396 protected:
00397 H323GatekeeperListener & rasChannel;
00398 };
00399
00400
00401 class H323GatekeeperGRQ : public H323GatekeeperRequest
00402 {
00403 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00404 public:
00405 H323GatekeeperGRQ(
00406 H323GatekeeperListener & listener,
00407 const H323RasPDU & pdu
00408 );
00409
00410 #if PTRACING
00411 virtual const char * GetName() const;
00412 #endif
00413 virtual PString GetGatekeeperIdentifier() const;
00414 virtual unsigned GetGatekeeperRejectTag() const;
00415 virtual PString GetEndpointIdentifier() const;
00416 virtual unsigned GetRegisteredEndPointRejectTag() const;
00417 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00418 virtual unsigned GetSecurityRejectTag() const;
00419 virtual void SetRejectReason(
00420 unsigned reasonCode
00421 );
00422
00423 H225_GatekeeperRequest & grq;
00424 H225_GatekeeperConfirm & gcf;
00425 H225_GatekeeperReject & grj;
00426
00427 protected:
00428 virtual Response OnHandlePDU();
00429 };
00430
00431
00432 class H323GatekeeperRRQ : public H323GatekeeperRequest
00433 {
00434 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00435 public:
00436 H323GatekeeperRRQ(
00437 H323GatekeeperListener & listener,
00438 const H323RasPDU & pdu
00439 );
00440
00441 #if PTRACING
00442 virtual const char * GetName() const;
00443 #endif
00444 virtual PString GetGatekeeperIdentifier() const;
00445 virtual unsigned GetGatekeeperRejectTag() const;
00446 virtual PString GetEndpointIdentifier() const;
00447 virtual unsigned GetRegisteredEndPointRejectTag() const;
00448 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00449 virtual unsigned GetSecurityRejectTag() const;
00450 virtual void SetRejectReason(
00451 unsigned reasonCode
00452 );
00453
00454 H225_RegistrationRequest & rrq;
00455 H225_RegistrationConfirm & rcf;
00456 H225_RegistrationReject & rrj;
00457
00458 protected:
00459 virtual Response OnHandlePDU();
00460 };
00461
00462
00463 class H323GatekeeperURQ : public H323GatekeeperRequest
00464 {
00465 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00466 public:
00467 H323GatekeeperURQ(
00468 H323GatekeeperListener & listener,
00469 const H323RasPDU & pdu
00470 );
00471
00472 #if PTRACING
00473 virtual const char * GetName() const;
00474 #endif
00475 virtual PString GetGatekeeperIdentifier() const;
00476 virtual unsigned GetGatekeeperRejectTag() const;
00477 virtual PString GetEndpointIdentifier() const;
00478 virtual unsigned GetRegisteredEndPointRejectTag() const;
00479 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00480 virtual unsigned GetSecurityRejectTag() const;
00481 virtual void SetRejectReason(
00482 unsigned reasonCode
00483 );
00484
00485 H225_UnregistrationRequest & urq;
00486 H225_UnregistrationConfirm & ucf;
00487 H225_UnregistrationReject & urj;
00488
00489 protected:
00490 virtual Response OnHandlePDU();
00491 };
00492
00493
00494 class H323GatekeeperARQ : public H323GatekeeperRequest
00495 {
00496 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00497 public:
00498 H323GatekeeperARQ(
00499 H323GatekeeperListener & listener,
00500 const H323RasPDU & pdu
00501 );
00502
00503 #if PTRACING
00504 virtual const char * GetName() const;
00505 #endif
00506 virtual PString GetGatekeeperIdentifier() const;
00507 virtual unsigned GetGatekeeperRejectTag() const;
00508 virtual PString GetEndpointIdentifier() const;
00509 virtual unsigned GetRegisteredEndPointRejectTag() const;
00510 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00511 virtual unsigned GetSecurityRejectTag() const;
00512 virtual void SetRejectReason(
00513 unsigned reasonCode
00514 );
00515
00516 H225_AdmissionRequest & arq;
00517 H225_AdmissionConfirm & acf;
00518 H225_AdmissionReject & arj;
00519
00520 PString alternateSecurityID;
00521
00522 protected:
00523 virtual Response OnHandlePDU();
00524 };
00525
00526
00527 class H323GatekeeperDRQ : public H323GatekeeperRequest
00528 {
00529 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00530 public:
00531 H323GatekeeperDRQ(
00532 H323GatekeeperListener & listener,
00533 const H323RasPDU & pdu
00534 );
00535
00536 #if PTRACING
00537 virtual const char * GetName() const;
00538 #endif
00539 virtual PString GetGatekeeperIdentifier() const;
00540 virtual unsigned GetGatekeeperRejectTag() const;
00541 virtual PString GetEndpointIdentifier() const;
00542 virtual unsigned GetRegisteredEndPointRejectTag() const;
00543 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00544 virtual unsigned GetSecurityRejectTag() const;
00545 virtual void SetRejectReason(
00546 unsigned reasonCode
00547 );
00548
00549 H225_DisengageRequest & drq;
00550 H225_DisengageConfirm & dcf;
00551 H225_DisengageReject & drj;
00552
00553 protected:
00554 virtual Response OnHandlePDU();
00555 };
00556
00557
00558 class H323GatekeeperBRQ : public H323GatekeeperRequest
00559 {
00560 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00561 public:
00562 H323GatekeeperBRQ(
00563 H323GatekeeperListener & listener,
00564 const H323RasPDU & pdu
00565 );
00566
00567 #if PTRACING
00568 virtual const char * GetName() const;
00569 #endif
00570 virtual PString GetGatekeeperIdentifier() const;
00571 virtual unsigned GetGatekeeperRejectTag() const;
00572 virtual PString GetEndpointIdentifier() const;
00573 virtual unsigned GetRegisteredEndPointRejectTag() const;
00574 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00575 virtual unsigned GetSecurityRejectTag() const;
00576 virtual void SetRejectReason(
00577 unsigned reasonCode
00578 );
00579
00580 H225_BandwidthRequest & brq;
00581 H225_BandwidthConfirm & bcf;
00582 H225_BandwidthReject & brj;
00583
00584 protected:
00585 virtual Response OnHandlePDU();
00586 };
00587
00588
00589 class H323GatekeeperLRQ : public H323GatekeeperRequest
00590 {
00591 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00592 public:
00593 H323GatekeeperLRQ(
00594 H323GatekeeperListener & listener,
00595 const H323RasPDU & pdu
00596 );
00597
00598 #if PTRACING
00599 virtual const char * GetName() const;
00600 #endif
00601 virtual PString GetGatekeeperIdentifier() const;
00602 virtual unsigned GetGatekeeperRejectTag() const;
00603 virtual PString GetEndpointIdentifier() const;
00604 virtual unsigned GetRegisteredEndPointRejectTag() const;
00605 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00606 virtual unsigned GetSecurityRejectTag() const;
00607 virtual void SetRejectReason(
00608 unsigned reasonCode
00609 );
00610
00611 H225_LocationRequest & lrq;
00612 H225_LocationConfirm & lcf;
00613 H225_LocationReject & lrj;
00614
00615 protected:
00616 virtual Response OnHandlePDU();
00617 };
00618
00619
00620 class H323GatekeeperIRR : public H323GatekeeperRequest
00621 {
00622 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00623 public:
00624 H323GatekeeperIRR(
00625 H323GatekeeperListener & listener,
00626 const H323RasPDU & pdu
00627 );
00628
00629 #if PTRACING
00630 virtual const char * GetName() const;
00631 #endif
00632 virtual PString GetGatekeeperIdentifier() const;
00633 virtual unsigned GetGatekeeperRejectTag() const;
00634 virtual PString GetEndpointIdentifier() const;
00635 virtual unsigned GetRegisteredEndPointRejectTag() const;
00636 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00637 virtual unsigned GetSecurityRejectTag() const;
00638 virtual void SetRejectReason(
00639 unsigned reasonCode
00640 );
00641
00642 H225_InfoRequestResponse & irr;
00643 H225_InfoRequestAck & iack;
00644 H225_InfoRequestNak & inak;
00645
00646 protected:
00647 virtual Response OnHandlePDU();
00648 };
00649
00650
00653 class H323GatekeeperCall : public PSafeObject
00654 {
00655 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00656 public:
00659 enum Direction {
00660 AnsweringCall,
00661 OriginatingCall,
00662 UnknownDirection
00663 };
00664
00667 H323GatekeeperCall(
00668 H323GatekeeperServer & server,
00669 const OpalGloballyUniqueID & callIdentifier,
00670 Direction direction
00671 );
00672
00675 ~H323GatekeeperCall();
00677
00682 Comparison Compare(
00683 const PObject & obj
00684 ) const;
00685
00688 void PrintOn(
00689 ostream & strm
00690 ) const;
00692
00700 virtual H323GatekeeperRequest::Response OnAdmission(
00701 H323GatekeeperARQ & request
00702 );
00703
00707 virtual BOOL Disengage(
00708 int reason = -1
00709 );
00710
00714 virtual H323GatekeeperRequest::Response OnDisengage(
00715 H323GatekeeperDRQ & request
00716 );
00717
00722 virtual H323GatekeeperRequest::Response OnBandwidth(
00723 H323GatekeeperBRQ & request
00724 );
00725
00729 virtual H323GatekeeperRequest::Response OnInfoResponse(
00730 H323GatekeeperIRR & request,
00731 H225_InfoRequestResponse_perCallInfo_subtype & call
00732 );
00733
00736 virtual void OnAlerting();
00737
00740 virtual void OnConnected();
00741
00752 virtual BOOL OnHeartbeat();
00753
00760 virtual PString GetCallCreditAmount() const;
00761
00768 virtual BOOL GetCallCreditMode() const;
00769
00777 virtual unsigned GetDurationLimit() const;
00778
00783 virtual BOOL SendCallCreditServiceControl();
00784
00787 BOOL AddCallCreditServiceControl(
00788 H225_ArrayOf_ServiceControlSession & serviceControl
00789 ) const;
00790
00795 virtual BOOL SendServiceControlSession(
00796 const H323ServiceControlSession & session
00797 );
00798
00804 virtual BOOL TranslateAliasAddress(
00805 const H225_AliasAddress & alias,
00806 H225_ArrayOf_AliasAddress & aliases,
00807 H323TransportAddress & address,
00808 BOOL & isGkRouted
00809 );
00810
00812
00815 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00816 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00817 BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00818 unsigned GetCallReference() const { return callReference; }
00819 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00820 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00821 const PString & GetSourceNumber() const { return srcNumber; }
00822 const PStringArray & GetSourceAliases() const { return srcAliases; }
00823 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00824 PString GetSourceAddress() const;
00825 const PString & GetDestinationNumber() const { return dstNumber; }
00826 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00827 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00828 PString GetDestinationAddress() const;
00829 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00830 BOOL SetBandwidthUsed(unsigned bandwidth);
00831 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00832 const PTime & GetCallStartTime() const { return callStartTime; }
00833 const PTime & GetAlertingTime() const { return alertingTime; }
00834 const PTime & GetConnectedTime() const { return connectedTime; }
00835 const PTime & GetCallEndTime() const { return callEndTime; }
00836 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00838
00839 protected:
00840 void SetUsageInfo(const H225_RasUsageInformation & usage);
00841
00842 H323GatekeeperServer & gatekeeper;
00843 H323RegisteredEndPoint * endpoint;
00844 H323GatekeeperListener * rasChannel;
00845
00846 Direction direction;
00847 unsigned callReference;
00848 OpalGloballyUniqueID callIdentifier;
00849 OpalGloballyUniqueID conferenceIdentifier;
00850 PString srcNumber;
00851 PStringArray srcAliases;
00852 H323TransportAddress srcHost;
00853 PString dstNumber;
00854 PStringArray dstAliases;
00855 H323TransportAddress dstHost;
00856 unsigned bandwidthUsed;
00857 unsigned infoResponseRate;
00858 PTime lastInfoResponse;
00859
00860 BOOL drqReceived;
00861 PTime callStartTime;
00862 PTime alertingTime;
00863 PTime connectedTime;
00864 PTime callEndTime;
00865 H323Connection::CallEndReason callEndReason;
00866 };
00867
00868
00874 class H323RegisteredEndPoint : public PSafeObject
00875 {
00876 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00877 public:
00882 H323RegisteredEndPoint(
00883 H323GatekeeperServer & server,
00884 const PString & id
00885 );
00887
00892 Comparison Compare(
00893 const PObject & obj
00894 ) const;
00895
00898 void PrintOn(
00899 ostream & strm
00900 ) const;
00902
00909 virtual void AddCall(
00910 H323GatekeeperCall * call
00911 );
00912
00917 virtual BOOL RemoveCall(
00918 H323GatekeeperCall * call
00919 );
00920
00923 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00924
00927 H323GatekeeperCall & GetCall(
00928 PINDEX idx
00929 ) { return activeCalls[idx]; }
00931
00940 virtual H323GatekeeperRequest::Response OnRegistration(
00941 H323GatekeeperRRQ & request
00942 );
00943
00953 virtual H323GatekeeperRequest::Response OnFullRegistration(
00954 H323GatekeeperRRQ & request
00955 );
00956
00965 virtual H323GatekeeperRequest::Response OnSecureRegistration(
00966 H323GatekeeperRRQ & request
00967 );
00968
00972 virtual H323GatekeeperRequest::Response OnUnregistration(
00973 H323GatekeeperURQ & request
00974 );
00975
00979 virtual BOOL Unregister(
00980 int reason = -1
00981 );
00982
00987 virtual H323GatekeeperRequest::Response OnInfoResponse(
00988 H323GatekeeperIRR & request
00989 );
00990
01001 virtual BOOL OnTimeToLive();
01002
01014 virtual PString GetCallCreditAmount() const;
01015
01023 virtual BOOL GetCallCreditMode() const;
01024
01029 virtual BOOL SendServiceControlSession(
01030 const H323ServiceControlSession & session
01031 );
01032
01036 virtual BOOL AddServiceControlSession(
01037 const H323ServiceControlSession & session,
01038 H225_ArrayOf_ServiceControlSession & serviceControl
01039 );
01041
01046 virtual BOOL SetPassword(
01047 const PString & password,
01048 const PString & username = PString::Empty()
01049 );
01050
01053 const PString & GetIdentifier() const { return identifier; }
01054
01057 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01058
01061 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01062
01066 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01067
01071 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01072
01076 H323TransportAddress GetRASAddress(
01077 PINDEX idx
01078 ) const { return rasAddresses[idx]; }
01079
01083 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01084
01088 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01089
01093 H323TransportAddress GetSignalAddress(
01094 PINDEX idx
01095 ) const { return signalAddresses[idx]; }
01096
01099 const PStringArray & GetAliases() const { return aliases; }
01100
01103 BOOL ContainsAlias(
01104 const PString & alias
01105 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01106
01109 PINDEX GetAliasCount() const { return aliases.GetSize(); }
01110
01113 PString GetAlias(
01114 PINDEX idx
01115 ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01116
01122 void RemoveAlias(
01123 const PString & alias
01124 );
01125
01128 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01129
01132 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01133
01136 PString GetPrefix(
01137 PINDEX idx
01138 ) const { return voicePrefixes[idx]; }
01139
01142 const PCaselessString & GetApplicationInfo() const { return applicationInfo; }
01143
01146 unsigned GetProtocolVersion() const { return protocolVersion; }
01147
01150 BOOL IsBehindNAT() const { return isBehindNAT; }
01151
01154 BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01155
01158 BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01159
01162 BOOL CanReceiveRIP() const;
01163
01166 BOOL GetH225Version() const { return h225Version; }
01168
01178 virtual BOOL OnSendDescriptorForEndpoint(
01179 H225_ArrayOf_AliasAddress & aliases,
01180 H225_EndpointType & terminalType,
01181 H225_ArrayOf_AliasAddress & transportAddresses
01182 );
01184
01185
01186 protected:
01187 H323GatekeeperServer & gatekeeper;
01188 H323GatekeeperListener * rasChannel;
01189
01190 PString identifier;
01191 OpalGloballyUniqueID descriptorID;
01192 H323TransportAddressArray rasAddresses;
01193 H323TransportAddressArray signalAddresses;
01194 PStringArray aliases;
01195 PStringArray voicePrefixes;
01196 PCaselessString applicationInfo;
01197 unsigned protocolVersion;
01198 BOOL isBehindNAT;
01199 BOOL canDisplayAmountString;
01200 BOOL canEnforceDurationLimit;
01201 unsigned h225Version;
01202 unsigned timeToLive;
01203 H235Authenticators authenticators;
01204
01205 PTime lastRegistration;
01206 PTime lastInfoResponse;
01207
01208 PSortedList<H323GatekeeperCall> activeCalls;
01209 POrdinalDictionary<PString> serviceControlSessions;
01210 };
01211
01212
01218 class H323GatekeeperListener : public H225_RAS
01219 {
01220 PCLASSINFO(H323GatekeeperListener, H225_RAS);
01221 public:
01226 H323GatekeeperListener(
01227 H323EndPoint & endpoint,
01228 H323GatekeeperServer & server,
01229 const PString & gatekeeperIdentifier,
01230 H323Transport * transport = NULL
01231 );
01232
01235 ~H323GatekeeperListener();
01237
01242 BOOL UnregistrationRequest(
01243 const H323RegisteredEndPoint & ep,
01244 unsigned reason
01245 );
01246
01249 BOOL DisengageRequest(
01250 const H323GatekeeperCall & call,
01251 unsigned reason
01252 );
01253
01256 virtual BOOL InfoRequest(
01257 H323RegisteredEndPoint & ep,
01258 H323GatekeeperCall * call = NULL
01259 );
01260
01263 virtual BOOL ServiceControlIndication(
01264 H323RegisteredEndPoint & ep,
01265 const H323ServiceControlSession & session,
01266 H323GatekeeperCall * call = NULL
01267 );
01269
01276 virtual H323GatekeeperRequest::Response OnDiscovery(
01277 H323GatekeeperGRQ & request
01278 );
01279
01284 virtual H323GatekeeperRequest::Response OnRegistration(
01285 H323GatekeeperRRQ & request
01286 );
01287
01292 virtual H323GatekeeperRequest::Response OnUnregistration(
01293 H323GatekeeperURQ & request
01294 );
01295
01300 virtual H323GatekeeperRequest::Response OnAdmission(
01301 H323GatekeeperARQ & request
01302 );
01303
01308 virtual H323GatekeeperRequest::Response OnDisengage(
01309 H323GatekeeperDRQ & request
01310 );
01311
01316 virtual H323GatekeeperRequest::Response OnBandwidth(
01317 H323GatekeeperBRQ & request
01318 );
01319
01324 virtual H323GatekeeperRequest::Response OnLocation(
01325 H323GatekeeperLRQ & request
01326 );
01327
01332 virtual H323GatekeeperRequest::Response OnInfoResponse(
01333 H323GatekeeperIRR & request
01334 );
01336
01339 BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01340 BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01341 BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01342 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01343 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01344 BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01345 BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01346 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01347 BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01348 BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01349 BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01350 BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01351 BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01352 BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01353 BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01354 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01355 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01357
01360 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01362
01363
01364 protected:
01365 H323GatekeeperServer & gatekeeper;
01366 };
01367
01368
01379 class H323GatekeeperServer : public H323TransactionServer
01380 {
01381 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01382 public:
01387 H323GatekeeperServer(
01388 H323EndPoint & endpoint
01389 );
01390
01393 ~H323GatekeeperServer();
01395
01396 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01397
01408 virtual H323Transactor * CreateListener(
01409 H323Transport * transport
01410 );
01411
01413
01419 virtual H323GatekeeperRequest::Response OnDiscovery(
01420 H323GatekeeperGRQ & request
01421 );
01422
01430 virtual H323GatekeeperRequest::Response OnRegistration(
01431 H323GatekeeperRRQ & request
01432 );
01433
01439 virtual H323GatekeeperRequest::Response OnUnregistration(
01440 H323GatekeeperURQ & request
01441 );
01442
01447 virtual H323GatekeeperRequest::Response OnInfoResponse(
01448 H323GatekeeperIRR & request
01449 );
01450
01461 virtual void AddEndPoint(
01462 H323RegisteredEndPoint * ep
01463 );
01464
01467 virtual BOOL RemoveEndPoint(
01468 H323RegisteredEndPoint * ep
01469 );
01470
01479 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01480 H323GatekeeperRRQ & request
01481 );
01482
01491 virtual PString CreateEndPointIdentifier();
01492
01495 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01496 const PString & identifier,
01497 PSafetyMode mode = PSafeReference
01498 );
01499
01502 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01503 const H225_ArrayOf_TransportAddress & addresses,
01504 PSafetyMode mode = PSafeReference
01505 );
01506
01509 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01510 const H323TransportAddress & address,
01511 PSafetyMode mode = PSafeReference
01512 );
01513
01516 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01517 const H225_AliasAddress & alias,
01518 PSafetyMode mode = PSafeReadWrite
01519 );
01520
01523 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01524 const PString & alias,
01525 PSafetyMode mode = PSafeReference
01526 );
01527
01530 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01531 const PString & alias,
01532 PSafetyMode mode = PSafeReference
01533 );
01534
01537 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01538 const PString & prefix,
01539 PSafetyMode mode = PSafeReference
01540 );
01541
01544 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01545 PSafetyMode mode = PSafeReference
01546 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01548
01549 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01550 const OpalGloballyUniqueID & id,
01551 H323GatekeeperCall::Direction direction
01552 );
01553
01561 virtual H323GatekeeperRequest::Response OnAdmission(
01562 H323GatekeeperARQ & request
01563 );
01564
01569 virtual H323GatekeeperRequest::Response OnDisengage(
01570 H323GatekeeperDRQ & request
01571 );
01572
01577 virtual H323GatekeeperRequest::Response OnBandwidth(
01578 H323GatekeeperBRQ & request
01579 );
01580
01589 virtual H323GatekeeperCall * CreateCall(
01590 const OpalGloballyUniqueID & callIdentifier,
01591 H323GatekeeperCall::Direction direction
01592 );
01593
01596 virtual void AddCall(H323GatekeeperCall *)
01597 { }
01598
01601 virtual void RemoveCall(
01602 H323GatekeeperCall * call
01603 );
01604
01607 virtual PSafePtr<H323GatekeeperCall> FindCall(
01608 const PString & description,
01609 PSafetyMode mode = PSafeReference
01610 );
01611
01614 virtual PSafePtr<H323GatekeeperCall> FindCall(
01615 const OpalGloballyUniqueID & callIdentifier,
01616 BOOL answeringCall,
01617 PSafetyMode mode = PSafeReference
01618 );
01619
01622 virtual PSafePtr<H323GatekeeperCall> FindCall(
01623 const OpalGloballyUniqueID & callIdentifier,
01624 H323GatekeeperCall::Direction direction,
01625 PSafetyMode mode = PSafeReference
01626 );
01627
01630 PSafePtr<H323GatekeeperCall> GetFirstCall(
01631 PSafetyMode mode = PSafeReference
01632 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01633
01634
01636
01646 virtual H323GatekeeperRequest::Response OnLocation(
01647 H323GatekeeperLRQ & request
01648 );
01649
01661 virtual BOOL TranslateAliasAddress(
01662 const H225_AliasAddress & alias,
01663 H225_ArrayOf_AliasAddress & aliases,
01664 H323TransportAddress & address,
01665 BOOL & isGkRouted
01666 );
01667 virtual BOOL TranslateAliasAddressToSignalAddress(
01668 const H225_AliasAddress & alias,
01669 H323TransportAddress & address
01670 );
01671
01673
01685 virtual BOOL CheckSignalAddressPolicy(
01686 const H323RegisteredEndPoint & ep,
01687 const H225_AdmissionRequest & arq,
01688 const H323TransportAddress & address
01689 );
01690
01703 virtual BOOL CheckAliasAddressPolicy(
01704 const H323RegisteredEndPoint & ep,
01705 const H225_AdmissionRequest & arq,
01706 const H225_AliasAddress & alias
01707 );
01708
01721 virtual BOOL CheckAliasStringPolicy(
01722 const H323RegisteredEndPoint & ep,
01723 const H225_AdmissionRequest & arq,
01724 const PString & alias
01725 );
01726
01732 virtual unsigned AllocateBandwidth(
01733 unsigned newBandwidth,
01734 unsigned oldBandwidth = 0
01735 );
01737
01749 virtual BOOL GetAdmissionRequestAuthentication(
01750 H323GatekeeperARQ & info,
01751 H235Authenticators & authenticators
01752 );
01753
01759 virtual BOOL GetUsersPassword(
01760 const PString & alias,
01761 PString & password,
01762 H323RegisteredEndPoint & registeredEndpoint
01763 ) const;
01764 virtual BOOL GetUsersPassword(
01765 const PString & alias,
01766 PString & password
01767 ) const;
01769
01774 H323PeerElement * GetPeerElement() const { return peerElement; }
01775
01779 void SetPeerElement(
01780 H323PeerElement * newPeerElement
01781 );
01782
01788 void CreatePeerElement(
01789 const H323TransportAddress & h501Interface
01790 );
01791
01797 BOOL OpenPeerElement(
01798 const H323TransportAddress & remotePeer,
01799 BOOL append = FALSE,
01800 BOOL keepTrying = TRUE
01801 );
01803
01808 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01809
01815 void SetGatekeeperIdentifier(
01816 const PString & id,
01817 BOOL adjustListeners = TRUE
01818 );
01819
01822 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01823
01826 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01827
01830 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01831
01834 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01835
01838 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01839
01842 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01843
01846 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01847
01850 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01851
01854 BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01855
01858 BOOL IsRequiredH235() const { return requireH235; }
01859
01862 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01863
01866 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01867
01870 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01871
01874 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01875
01878 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01879
01882 unsigned GetPeakCalls() const { return peakCalls; }
01883
01886 unsigned GetTotalCalls() const { return totalCalls; }
01887
01890 unsigned GetRejectedCalls() const { return rejectedCalls; }
01892
01893
01894 void RemoveAlias(
01895 H323RegisteredEndPoint & ep,
01896 const PString & alias
01897 );
01898
01899
01900 virtual BOOL OnSendDescriptorForEndpoint(
01901 H323RegisteredEndPoint & ,
01902 H225_ArrayOf_AliasAddress & ,
01903 H225_EndpointType & ,
01904 H225_ArrayOf_AliasAddress &
01905 )
01906 { return TRUE; }
01907
01908 virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01909 { return canHaveDuplicateAlias; }
01910
01911 virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01912 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01913
01914 protected:
01915
01916 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01917
01918
01919 PString gatekeeperIdentifier;
01920 unsigned totalBandwidth;
01921 unsigned usedBandwidth;
01922 unsigned defaultBandwidth;
01923 unsigned maximumBandwidth;
01924 unsigned defaultTimeToLive;
01925 unsigned defaultInfoResponseRate;
01926 BOOL overwriteOnSameSignalAddress;
01927 BOOL canHaveDuplicateAlias;
01928 BOOL canHaveDuplicatePrefix;
01929 BOOL canOnlyCallRegisteredEP;
01930 BOOL canOnlyAnswerRegisteredEP;
01931 BOOL answerCallPreGrantedARQ;
01932 BOOL makeCallPreGrantedARQ;
01933 BOOL isGatekeeperRouted;
01934 BOOL aliasCanBeHostName;
01935 BOOL requireH235;
01936 BOOL disengageOnHearbeatFail;
01937
01938 PStringToString passwords;
01939
01940
01941 PMutex mutex;
01942 time_t identifierBase;
01943 unsigned nextIdentifier;
01944 PThread * monitorThread;
01945 PSyncPoint monitorExit;
01946
01947 PLIST(ListenerList, H323GatekeeperListener);
01948 ListenerList listeners;
01949
01950 H323PeerElement * peerElement;
01951
01952 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01953
01954 class StringMap : public PString {
01955 PCLASSINFO(StringMap, PString);
01956 public:
01957 StringMap(const PString & from, const PString & id)
01958 : PString(from), identifier(id) { }
01959 PString identifier;
01960 };
01961 PSortedStringList byAddress;
01962 PSortedStringList byAlias;
01963 PSortedStringList byVoicePrefix;
01964
01965 PSafeSortedList<H323GatekeeperCall> activeCalls;
01966
01967 PINDEX peakRegistrations;
01968 PINDEX totalRegistrations;
01969 PINDEX rejectedRegistrations;
01970 PINDEX peakCalls;
01971 PINDEX totalCalls;
01972 PINDEX rejectedCalls;
01973
01974 friend class H323GatekeeperRRQ;
01975 friend class H323GatekeeperARQ;
01976 };
01977
01978
01979 #endif // __OPAL_GKSERVER_H
01980
01981
01983