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 #ifndef __OPAL_GKSERVER_H
00338 #define __OPAL_GKSERVER_H
00339
00340 #ifdef P_USE_PRAGMA
00341 #pragma interface
00342 #endif
00343
00344 #include "h323.h"
00345 #include "h323ep.h"
00346 #include "h225ras.h"
00347 #include "guid.h"
00348 #include "h235auth.h"
00349 #include "h323pdu.h"
00350 #include "h323trans.h"
00351
00352 #include <ptlib/safecoll.h>
00353
00354 class PASN_Sequence;
00355 class PASN_Choice;
00356
00357 class H225_AliasAddress;
00358 class H225_ArrayOf_TransportAddress;
00359 class H225_GatekeeperIdentifier;
00360 class H225_EndpointIdentifier;
00361 class H225_InfoRequestResponse_perCallInfo_subtype;
00362 class H225_RasUsageInformation;
00363
00364 class H323RegisteredEndPoint;
00365 class H323GatekeeperListener;
00366 class H323GatekeeperServer;
00367 class H323RasPDU;
00368 class H323PeerElement;
00369
00370
00371 class H323GatekeeperRequest : public H323Transaction
00372 {
00373 PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00374 public:
00379 H323GatekeeperRequest(
00380 H323GatekeeperListener & rasChannel,
00381 const H323RasPDU & pdu
00382 );
00384
00385 virtual H323TransactionPDU * CreateRIP(
00386 unsigned sequenceNumber,
00387 unsigned delay
00388 ) const;
00389
00390 virtual BOOL WritePDU(
00391 H323TransactionPDU & pdu
00392 );
00393 BOOL CheckCryptoTokens();
00394 BOOL CheckGatekeeperIdentifier();
00395 BOOL GetRegisteredEndPoint();
00396
00397 virtual PString GetGatekeeperIdentifier() const = 0;
00398 virtual unsigned GetGatekeeperRejectTag() const = 0;
00399 virtual PString GetEndpointIdentifier() const = 0;
00400 virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00401 virtual unsigned GetSecurityRejectTag() const = 0;
00402
00403 H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00404
00405 PSafePtr<H323RegisteredEndPoint> endpoint;
00406
00407 protected:
00408 H323GatekeeperListener & rasChannel;
00409 };
00410
00411
00412 class H323GatekeeperGRQ : public H323GatekeeperRequest
00413 {
00414 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00415 public:
00416 H323GatekeeperGRQ(
00417 H323GatekeeperListener & listener,
00418 const H323RasPDU & pdu
00419 );
00420
00421 #if PTRACING
00422 virtual const char * GetName() const;
00423 #endif
00424 virtual PString GetGatekeeperIdentifier() const;
00425 virtual unsigned GetGatekeeperRejectTag() const;
00426 virtual PString GetEndpointIdentifier() const;
00427 virtual unsigned GetRegisteredEndPointRejectTag() const;
00428 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00429 virtual unsigned GetSecurityRejectTag() const;
00430 virtual void SetRejectReason(
00431 unsigned reasonCode
00432 );
00433
00434 H225_GatekeeperRequest & grq;
00435 H225_GatekeeperConfirm & gcf;
00436 H225_GatekeeperReject & grj;
00437
00438 protected:
00439 virtual Response OnHandlePDU();
00440 };
00441
00442
00443 class H323GatekeeperRRQ : public H323GatekeeperRequest
00444 {
00445 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00446 public:
00447 H323GatekeeperRRQ(
00448 H323GatekeeperListener & listener,
00449 const H323RasPDU & pdu
00450 );
00451
00452 #if PTRACING
00453 virtual const char * GetName() const;
00454 #endif
00455 virtual PString GetGatekeeperIdentifier() const;
00456 virtual unsigned GetGatekeeperRejectTag() const;
00457 virtual PString GetEndpointIdentifier() const;
00458 virtual unsigned GetRegisteredEndPointRejectTag() const;
00459 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00460 virtual unsigned GetSecurityRejectTag() const;
00461 virtual void SetRejectReason(
00462 unsigned reasonCode
00463 );
00464
00465 H225_RegistrationRequest & rrq;
00466 H225_RegistrationConfirm & rcf;
00467 H225_RegistrationReject & rrj;
00468
00469 protected:
00470 virtual Response OnHandlePDU();
00471 };
00472
00473
00474 class H323GatekeeperURQ : public H323GatekeeperRequest
00475 {
00476 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00477 public:
00478 H323GatekeeperURQ(
00479 H323GatekeeperListener & listener,
00480 const H323RasPDU & pdu
00481 );
00482
00483 #if PTRACING
00484 virtual const char * GetName() const;
00485 #endif
00486 virtual PString GetGatekeeperIdentifier() const;
00487 virtual unsigned GetGatekeeperRejectTag() const;
00488 virtual PString GetEndpointIdentifier() const;
00489 virtual unsigned GetRegisteredEndPointRejectTag() const;
00490 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00491 virtual unsigned GetSecurityRejectTag() const;
00492 virtual void SetRejectReason(
00493 unsigned reasonCode
00494 );
00495
00496 H225_UnregistrationRequest & urq;
00497 H225_UnregistrationConfirm & ucf;
00498 H225_UnregistrationReject & urj;
00499
00500 protected:
00501 virtual Response OnHandlePDU();
00502 };
00503
00504
00505 class H323GatekeeperARQ : public H323GatekeeperRequest
00506 {
00507 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00508 public:
00509 H323GatekeeperARQ(
00510 H323GatekeeperListener & listener,
00511 const H323RasPDU & pdu
00512 );
00513
00514 #if PTRACING
00515 virtual const char * GetName() const;
00516 #endif
00517 virtual PString GetGatekeeperIdentifier() const;
00518 virtual unsigned GetGatekeeperRejectTag() const;
00519 virtual PString GetEndpointIdentifier() const;
00520 virtual unsigned GetRegisteredEndPointRejectTag() const;
00521 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00522 virtual unsigned GetSecurityRejectTag() const;
00523 virtual void SetRejectReason(
00524 unsigned reasonCode
00525 );
00526
00527 H225_AdmissionRequest & arq;
00528 H225_AdmissionConfirm & acf;
00529 H225_AdmissionReject & arj;
00530
00531 PString alternateSecurityID;
00532
00533 protected:
00534 virtual Response OnHandlePDU();
00535 };
00536
00537
00538 class H323GatekeeperDRQ : public H323GatekeeperRequest
00539 {
00540 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00541 public:
00542 H323GatekeeperDRQ(
00543 H323GatekeeperListener & listener,
00544 const H323RasPDU & pdu
00545 );
00546
00547 #if PTRACING
00548 virtual const char * GetName() const;
00549 #endif
00550 virtual PString GetGatekeeperIdentifier() const;
00551 virtual unsigned GetGatekeeperRejectTag() const;
00552 virtual PString GetEndpointIdentifier() const;
00553 virtual unsigned GetRegisteredEndPointRejectTag() const;
00554 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00555 virtual unsigned GetSecurityRejectTag() const;
00556 virtual void SetRejectReason(
00557 unsigned reasonCode
00558 );
00559
00560 H225_DisengageRequest & drq;
00561 H225_DisengageConfirm & dcf;
00562 H225_DisengageReject & drj;
00563
00564 protected:
00565 virtual Response OnHandlePDU();
00566 };
00567
00568
00569 class H323GatekeeperBRQ : public H323GatekeeperRequest
00570 {
00571 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00572 public:
00573 H323GatekeeperBRQ(
00574 H323GatekeeperListener & listener,
00575 const H323RasPDU & pdu
00576 );
00577
00578 #if PTRACING
00579 virtual const char * GetName() const;
00580 #endif
00581 virtual PString GetGatekeeperIdentifier() const;
00582 virtual unsigned GetGatekeeperRejectTag() const;
00583 virtual PString GetEndpointIdentifier() const;
00584 virtual unsigned GetRegisteredEndPointRejectTag() const;
00585 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00586 virtual unsigned GetSecurityRejectTag() const;
00587 virtual void SetRejectReason(
00588 unsigned reasonCode
00589 );
00590
00591 H225_BandwidthRequest & brq;
00592 H225_BandwidthConfirm & bcf;
00593 H225_BandwidthReject & brj;
00594
00595 protected:
00596 virtual Response OnHandlePDU();
00597 };
00598
00599
00600 class H323GatekeeperLRQ : public H323GatekeeperRequest
00601 {
00602 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00603 public:
00604 H323GatekeeperLRQ(
00605 H323GatekeeperListener & listener,
00606 const H323RasPDU & pdu
00607 );
00608
00609 #if PTRACING
00610 virtual const char * GetName() const;
00611 #endif
00612 virtual PString GetGatekeeperIdentifier() const;
00613 virtual unsigned GetGatekeeperRejectTag() const;
00614 virtual PString GetEndpointIdentifier() const;
00615 virtual unsigned GetRegisteredEndPointRejectTag() const;
00616 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00617 virtual unsigned GetSecurityRejectTag() const;
00618 virtual void SetRejectReason(
00619 unsigned reasonCode
00620 );
00621
00622 H225_LocationRequest & lrq;
00623 H225_LocationConfirm & lcf;
00624 H225_LocationReject & lrj;
00625
00626 protected:
00627 virtual Response OnHandlePDU();
00628 };
00629
00630
00631 class H323GatekeeperIRR : public H323GatekeeperRequest
00632 {
00633 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00634 public:
00635 H323GatekeeperIRR(
00636 H323GatekeeperListener & listener,
00637 const H323RasPDU & pdu
00638 );
00639
00640 #if PTRACING
00641 virtual const char * GetName() const;
00642 #endif
00643 virtual PString GetGatekeeperIdentifier() const;
00644 virtual unsigned GetGatekeeperRejectTag() const;
00645 virtual PString GetEndpointIdentifier() const;
00646 virtual unsigned GetRegisteredEndPointRejectTag() const;
00647 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00648 virtual unsigned GetSecurityRejectTag() const;
00649 virtual void SetRejectReason(
00650 unsigned reasonCode
00651 );
00652
00653 H225_InfoRequestResponse & irr;
00654 H225_InfoRequestAck & iack;
00655 H225_InfoRequestNak & inak;
00656
00657 protected:
00658 virtual Response OnHandlePDU();
00659 };
00660
00661
00664 class H323GatekeeperCall : public PSafeObject
00665 {
00666 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00667 public:
00670 enum Direction {
00671 AnsweringCall,
00672 OriginatingCall,
00673 UnknownDirection
00674 };
00675
00678 H323GatekeeperCall(
00679 H323GatekeeperServer & server,
00680 const OpalGloballyUniqueID & callIdentifier,
00681 Direction direction
00682 );
00683
00686 ~H323GatekeeperCall();
00688
00693 Comparison Compare(
00694 const PObject & obj
00695 ) const;
00696
00699 void PrintOn(
00700 ostream & strm
00701 ) const;
00703
00711 virtual H323GatekeeperRequest::Response OnAdmission(
00712 H323GatekeeperARQ & request
00713 );
00714
00718 virtual BOOL Disengage(
00719 int reason = -1
00720 );
00721
00725 virtual H323GatekeeperRequest::Response OnDisengage(
00726 H323GatekeeperDRQ & request
00727 );
00728
00733 virtual H323GatekeeperRequest::Response OnBandwidth(
00734 H323GatekeeperBRQ & request
00735 );
00736
00740 virtual H323GatekeeperRequest::Response OnInfoResponse(
00741 H323GatekeeperIRR & request,
00742 H225_InfoRequestResponse_perCallInfo_subtype & call
00743 );
00744
00747 virtual void OnAlerting();
00748
00751 virtual void OnConnected();
00752
00763 virtual BOOL OnHeartbeat();
00764
00765 #ifdef H323_H248
00766
00773 virtual PString GetCallCreditAmount() const;
00774
00781 virtual BOOL GetCallCreditMode() const;
00782
00790 virtual unsigned GetDurationLimit() const;
00791
00796 virtual BOOL SendCallCreditServiceControl();
00797
00800 BOOL AddCallCreditServiceControl(
00801 H225_ArrayOf_ServiceControlSession & serviceControl
00802 ) const;
00803
00808 virtual BOOL SendServiceControlSession(
00809 const H323ServiceControlSession & session
00810 );
00811
00812 #endif // H323_H248
00813
00819 virtual BOOL TranslateAliasAddress(
00820 const H225_AliasAddress & alias,
00821 H225_ArrayOf_AliasAddress & aliases,
00822 H323TransportAddress & address,
00823 BOOL & isGkRouted
00824 );
00825
00827
00830 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00831 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00832 BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00833 unsigned GetCallReference() const { return callReference; }
00834 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00835 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00836 const PString & GetSourceNumber() const { return srcNumber; }
00837 const PStringArray & GetSourceAliases() const { return srcAliases; }
00838 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00839 PString GetSourceAddress() const;
00840 const PString & GetDestinationNumber() const { return dstNumber; }
00841 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00842 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00843 PString GetDestinationAddress() const;
00844 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00845 BOOL SetBandwidthUsed(unsigned bandwidth);
00846 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00847 const PTime & GetCallStartTime() const { return callStartTime; }
00848 const PTime & GetAlertingTime() const { return alertingTime; }
00849 const PTime & GetConnectedTime() const { return connectedTime; }
00850 const PTime & GetCallEndTime() const { return callEndTime; }
00851 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00853
00854 protected:
00855 void SetUsageInfo(const H225_RasUsageInformation & usage);
00856
00857 H323GatekeeperServer & gatekeeper;
00858 H323RegisteredEndPoint * endpoint;
00859 H323GatekeeperListener * rasChannel;
00860
00861 Direction direction;
00862 unsigned callReference;
00863 OpalGloballyUniqueID callIdentifier;
00864 OpalGloballyUniqueID conferenceIdentifier;
00865 PString srcNumber;
00866 PStringArray srcAliases;
00867 H323TransportAddress srcHost;
00868 PString dstNumber;
00869 PStringArray dstAliases;
00870 H323TransportAddress dstHost;
00871 unsigned bandwidthUsed;
00872 unsigned infoResponseRate;
00873 PTime lastInfoResponse;
00874
00875 BOOL drqReceived;
00876 PTime callStartTime;
00877 PTime alertingTime;
00878 PTime connectedTime;
00879 PTime callEndTime;
00880 H323Connection::CallEndReason callEndReason;
00881 };
00882
00883
00889 class H323RegisteredEndPoint : public PSafeObject
00890 {
00891 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00892 public:
00897 H323RegisteredEndPoint(
00898 H323GatekeeperServer & server,
00899 const PString & id
00900 );
00902
00907 Comparison Compare(
00908 const PObject & obj
00909 ) const;
00910
00913 void PrintOn(
00914 ostream & strm
00915 ) const;
00917
00924 virtual void AddCall(
00925 H323GatekeeperCall * call
00926 );
00927
00932 virtual BOOL RemoveCall(
00933 H323GatekeeperCall * call
00934 );
00935
00938 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00939
00942 H323GatekeeperCall & GetCall(
00943 PINDEX idx
00944 ) { return activeCalls[idx]; }
00946
00955 virtual H323GatekeeperRequest::Response OnRegistration(
00956 H323GatekeeperRRQ & request
00957 );
00958
00968 virtual H323GatekeeperRequest::Response OnFullRegistration(
00969 H323GatekeeperRRQ & request
00970 );
00971
00980 virtual H323GatekeeperRequest::Response OnSecureRegistration(
00981 H323GatekeeperRRQ & request
00982 );
00983
00987 virtual H323GatekeeperRequest::Response OnUnregistration(
00988 H323GatekeeperURQ & request
00989 );
00990
00994 virtual BOOL Unregister(
00995 int reason = -1
00996 );
00997
01002 virtual H323GatekeeperRequest::Response OnInfoResponse(
01003 H323GatekeeperIRR & request
01004 );
01005
01016 virtual BOOL OnTimeToLive();
01017
01018 #ifdef H323_H248
01019
01031 virtual PString GetCallCreditAmount() const;
01032
01040 virtual BOOL GetCallCreditMode() const;
01041
01046 virtual BOOL SendServiceControlSession(
01047 const H323ServiceControlSession & session
01048 );
01049
01053 virtual BOOL AddServiceControlSession(
01054 const H323ServiceControlSession & session,
01055 H225_ArrayOf_ServiceControlSession & serviceControl
01056 );
01057 #endif // H323_H248
01058
01059
01064 virtual BOOL SetPassword(
01065 const PString & password,
01066 const PString & username = PString::Empty()
01067 );
01068
01071 const PString & GetIdentifier() const { return identifier; }
01072
01075 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01076
01079 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01080
01084 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01085
01089 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01090
01094 H323TransportAddress GetRASAddress(
01095 PINDEX idx
01096 ) const { return rasAddresses[idx]; }
01097
01101 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01102
01106 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01107
01111 H323TransportAddress GetSignalAddress(
01112 PINDEX idx
01113 ) const { return signalAddresses[idx]; }
01114
01117 const PStringArray & GetAliases() const { return aliases; }
01118
01121 BOOL ContainsAlias(
01122 const PString & alias
01123 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01124
01127 PINDEX GetAliasCount() const { return aliases.GetSize(); }
01128
01131 PString GetAlias(
01132 PINDEX idx
01133 ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01134
01140 void RemoveAlias(
01141 const PString & alias
01142 );
01143
01146 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01147
01150 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01151
01154 PString GetPrefix(
01155 PINDEX idx
01156 ) const { return voicePrefixes[idx]; }
01157
01160 const PCaselessString & GetApplicationInfo() const { return applicationInfo; }
01161
01164 unsigned GetProtocolVersion() const { return protocolVersion; }
01165
01168 BOOL IsBehindNAT() const { return isBehindNAT; }
01169
01172 BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01173
01176 BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01177
01180 BOOL CanReceiveRIP() const;
01181
01184 BOOL GetH225Version() const { return h225Version; }
01186
01187 #ifdef H323_H501
01188
01197 virtual BOOL OnSendDescriptorForEndpoint(
01198 H225_ArrayOf_AliasAddress & aliases,
01199 H225_EndpointType & terminalType,
01200 H225_ArrayOf_AliasAddress & transportAddresses
01201 );
01203 #endif
01204
01205
01206 protected:
01207 H323GatekeeperServer & gatekeeper;
01208 H323GatekeeperListener * rasChannel;
01209
01210 PString identifier;
01211 OpalGloballyUniqueID descriptorID;
01212 H323TransportAddressArray rasAddresses;
01213 H323TransportAddressArray signalAddresses;
01214 PStringArray aliases;
01215 PStringArray voicePrefixes;
01216 PCaselessString applicationInfo;
01217 unsigned protocolVersion;
01218 BOOL isBehindNAT;
01219 BOOL canDisplayAmountString;
01220 BOOL canEnforceDurationLimit;
01221 unsigned h225Version;
01222 unsigned timeToLive;
01223 H235Authenticators authenticators;
01224
01225 PTime lastRegistration;
01226 PTime lastInfoResponse;
01227
01228 PSortedList<H323GatekeeperCall> activeCalls;
01229 #ifdef H323_H248
01230 POrdinalDictionary<PString> serviceControlSessions;
01231 #endif
01232 };
01233
01234
01240 class H323GatekeeperListener : public H225_RAS
01241 {
01242 PCLASSINFO(H323GatekeeperListener, H225_RAS);
01243 public:
01248 H323GatekeeperListener(
01249 H323EndPoint & endpoint,
01250 H323GatekeeperServer & server,
01251 const PString & gatekeeperIdentifier,
01252 H323Transport * transport = NULL
01253 );
01254
01257 ~H323GatekeeperListener();
01259
01264 BOOL UnregistrationRequest(
01265 const H323RegisteredEndPoint & ep,
01266 unsigned reason
01267 );
01268
01271 BOOL DisengageRequest(
01272 const H323GatekeeperCall & call,
01273 unsigned reason
01274 );
01275
01278 virtual BOOL InfoRequest(
01279 H323RegisteredEndPoint & ep,
01280 H323GatekeeperCall * call = NULL
01281 );
01282
01283 #ifdef H323_H248
01284
01286 virtual BOOL ServiceControlIndication(
01287 H323RegisteredEndPoint & ep,
01288 const H323ServiceControlSession & session,
01289 H323GatekeeperCall * call = NULL
01290 );
01291 #endif
01292
01293
01300 virtual H323GatekeeperRequest::Response OnDiscovery(
01301 H323GatekeeperGRQ & request
01302 );
01303
01308 virtual H323GatekeeperRequest::Response OnRegistration(
01309 H323GatekeeperRRQ & request
01310 );
01311
01316 virtual H323GatekeeperRequest::Response OnUnregistration(
01317 H323GatekeeperURQ & request
01318 );
01319
01324 virtual H323GatekeeperRequest::Response OnAdmission(
01325 H323GatekeeperARQ & request
01326 );
01327
01332 virtual H323GatekeeperRequest::Response OnDisengage(
01333 H323GatekeeperDRQ & request
01334 );
01335
01340 virtual H323GatekeeperRequest::Response OnBandwidth(
01341 H323GatekeeperBRQ & request
01342 );
01343
01348 virtual H323GatekeeperRequest::Response OnLocation(
01349 H323GatekeeperLRQ & request
01350 );
01351
01356 virtual H323GatekeeperRequest::Response OnInfoResponse(
01357 H323GatekeeperIRR & request
01358 );
01360
01363 BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01364 BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01365 BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01366 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01367 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01368 BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01369 BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01370 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01371 BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01372 BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01373 BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01374 BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01375 BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01376 BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01377 BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01378 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01379 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01381
01384 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01386
01387
01388 protected:
01389 H323GatekeeperServer & gatekeeper;
01390 };
01391
01392
01403 class H323GatekeeperServer : public H323TransactionServer
01404 {
01405 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01406 public:
01411 H323GatekeeperServer(
01412 H323EndPoint & endpoint
01413 );
01414
01417 ~H323GatekeeperServer();
01419
01420 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01421
01432 virtual H323Transactor * CreateListener(
01433 H323Transport * transport
01434 );
01435
01437
01443 virtual H323GatekeeperRequest::Response OnDiscovery(
01444 H323GatekeeperGRQ & request
01445 );
01446
01454 virtual H323GatekeeperRequest::Response OnRegistration(
01455 H323GatekeeperRRQ & request
01456 );
01457
01463 virtual H323GatekeeperRequest::Response OnUnregistration(
01464 H323GatekeeperURQ & request
01465 );
01466
01471 virtual H323GatekeeperRequest::Response OnInfoResponse(
01472 H323GatekeeperIRR & request
01473 );
01474
01485 virtual void AddEndPoint(
01486 H323RegisteredEndPoint * ep
01487 );
01488
01491 virtual BOOL RemoveEndPoint(
01492 H323RegisteredEndPoint * ep
01493 );
01494
01503 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01504 H323GatekeeperRRQ & request
01505 );
01506
01515 virtual PString CreateEndPointIdentifier();
01516
01519 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01520 const PString & identifier,
01521 PSafetyMode mode = PSafeReference
01522 );
01523
01526 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01527 const H225_ArrayOf_TransportAddress & addresses,
01528 PSafetyMode mode = PSafeReference
01529 );
01530
01533 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01534 const H323TransportAddress & address,
01535 PSafetyMode mode = PSafeReference
01536 );
01537
01540 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01541 const H225_AliasAddress & alias,
01542 PSafetyMode mode = PSafeReadWrite
01543 );
01544
01547 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01548 const PString & alias,
01549 PSafetyMode mode = PSafeReference
01550 );
01551
01554 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01555 const PString & alias,
01556 PSafetyMode mode = PSafeReference
01557 );
01558
01561 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01562 const PString & prefix,
01563 PSafetyMode mode = PSafeReference
01564 );
01565
01568 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01569 PSafetyMode mode = PSafeReference
01570 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01572
01573 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01574 const OpalGloballyUniqueID & id,
01575 H323GatekeeperCall::Direction direction
01576 );
01577
01585 virtual H323GatekeeperRequest::Response OnAdmission(
01586 H323GatekeeperARQ & request
01587 );
01588
01593 virtual H323GatekeeperRequest::Response OnDisengage(
01594 H323GatekeeperDRQ & request
01595 );
01596
01601 virtual H323GatekeeperRequest::Response OnBandwidth(
01602 H323GatekeeperBRQ & request
01603 );
01604
01613 virtual H323GatekeeperCall * CreateCall(
01614 const OpalGloballyUniqueID & callIdentifier,
01615 H323GatekeeperCall::Direction direction
01616 );
01617
01620 virtual void AddCall(H323GatekeeperCall *)
01621 { }
01622
01625 virtual void RemoveCall(
01626 H323GatekeeperCall * call
01627 );
01628
01631 virtual PSafePtr<H323GatekeeperCall> FindCall(
01632 const PString & description,
01633 PSafetyMode mode = PSafeReference
01634 );
01635
01638 virtual PSafePtr<H323GatekeeperCall> FindCall(
01639 const OpalGloballyUniqueID & callIdentifier,
01640 BOOL answeringCall,
01641 PSafetyMode mode = PSafeReference
01642 );
01643
01646 virtual PSafePtr<H323GatekeeperCall> FindCall(
01647 const OpalGloballyUniqueID & callIdentifier,
01648 H323GatekeeperCall::Direction direction,
01649 PSafetyMode mode = PSafeReference
01650 );
01651
01654 PSafePtr<H323GatekeeperCall> GetFirstCall(
01655 PSafetyMode mode = PSafeReference
01656 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01657
01658
01660
01670 virtual H323GatekeeperRequest::Response OnLocation(
01671 H323GatekeeperLRQ & request
01672 );
01673
01685 virtual BOOL TranslateAliasAddress(
01686 const H225_AliasAddress & alias,
01687 H225_ArrayOf_AliasAddress & aliases,
01688 H323TransportAddress & address,
01689 BOOL & isGkRouted,
01690 H323GatekeeperCall * call
01691 );
01692 virtual BOOL TranslateAliasAddressToSignalAddress(
01693 const H225_AliasAddress & alias,
01694 H323TransportAddress & address
01695 );
01696
01698
01710 virtual BOOL CheckSignalAddressPolicy(
01711 const H323RegisteredEndPoint & ep,
01712 const H225_AdmissionRequest & arq,
01713 const H323TransportAddress & address
01714 );
01715
01728 virtual BOOL CheckAliasAddressPolicy(
01729 const H323RegisteredEndPoint & ep,
01730 const H225_AdmissionRequest & arq,
01731 const H225_AliasAddress & alias
01732 );
01733
01746 virtual BOOL CheckAliasStringPolicy(
01747 const H323RegisteredEndPoint & ep,
01748 const H225_AdmissionRequest & arq,
01749 const PString & alias
01750 );
01751
01757 virtual unsigned AllocateBandwidth(
01758 unsigned newBandwidth,
01759 unsigned oldBandwidth = 0
01760 );
01762
01774 virtual BOOL GetAdmissionRequestAuthentication(
01775 H323GatekeeperARQ & info,
01776 H235Authenticators & authenticators
01777 );
01778
01784 virtual BOOL GetUsersPassword(
01785 const PString & alias,
01786 PString & password,
01787 H323RegisteredEndPoint & registeredEndpoint
01788 ) const;
01789 virtual BOOL GetUsersPassword(
01790 const PString & alias,
01791 PString & password
01792 ) const;
01794
01795 #ifdef H323_H501
01796
01801 H323PeerElement * GetPeerElement() const { return peerElement; }
01802
01806 void SetPeerElement(
01807 H323PeerElement * newPeerElement
01808 );
01809
01815 void CreatePeerElement(
01816 const H323TransportAddress & h501Interface
01817 );
01818
01824 BOOL OpenPeerElement(
01825 const H323TransportAddress & remotePeer,
01826 BOOL append = FALSE,
01827 BOOL keepTrying = TRUE
01828 );
01830
01831 #endif // H323_H501
01832
01837 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01838
01844 void SetGatekeeperIdentifier(
01845 const PString & id,
01846 BOOL adjustListeners = TRUE
01847 );
01848
01851 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01852
01855 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01856
01859 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01860
01863 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01864
01867 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01868
01871 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01872
01875 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01876
01879 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01880
01883 BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01884
01887 BOOL IsRequiredH235() const { return requireH235; }
01888
01891 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01892
01895 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01896
01899 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01900
01903 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01904
01907 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01908
01911 unsigned GetPeakCalls() const { return peakCalls; }
01912
01915 unsigned GetTotalCalls() const { return totalCalls; }
01916
01919 unsigned GetRejectedCalls() const { return rejectedCalls; }
01921
01922
01923 void RemoveAlias(
01924 H323RegisteredEndPoint & ep,
01925 const PString & alias
01926 );
01927
01928 #ifdef H323_H501
01929
01930 virtual BOOL OnSendDescriptorForEndpoint(
01931 H323RegisteredEndPoint & ,
01932 H225_ArrayOf_AliasAddress & ,
01933 H225_EndpointType & ,
01934 H225_ArrayOf_AliasAddress &
01935 )
01936 { return TRUE; }
01937 #endif
01938
01939 virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01940 { return canHaveDuplicateAlias; }
01941
01942 virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01943 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01944
01945 protected:
01946
01947 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01948
01949
01950 PString gatekeeperIdentifier;
01951 unsigned totalBandwidth;
01952 unsigned usedBandwidth;
01953 unsigned defaultBandwidth;
01954 unsigned maximumBandwidth;
01955 unsigned defaultTimeToLive;
01956 unsigned defaultInfoResponseRate;
01957 BOOL overwriteOnSameSignalAddress;
01958 BOOL canHaveDuplicateAlias;
01959 BOOL canHaveDuplicatePrefix;
01960 BOOL canOnlyCallRegisteredEP;
01961 BOOL canOnlyAnswerRegisteredEP;
01962 BOOL answerCallPreGrantedARQ;
01963 BOOL makeCallPreGrantedARQ;
01964 BOOL isGatekeeperRouted;
01965 BOOL aliasCanBeHostName;
01966 BOOL requireH235;
01967 BOOL disengageOnHearbeatFail;
01968
01969 PStringToString passwords;
01970
01971
01972 PMutex mutex;
01973 time_t identifierBase;
01974 unsigned nextIdentifier;
01975 PThread * monitorThread;
01976 PSyncPoint monitorExit;
01977
01978 PLIST(ListenerList, H323GatekeeperListener);
01979 ListenerList listeners;
01980
01981 H323PeerElement * peerElement;
01982
01983 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01984
01985 class StringMap : public PString {
01986 PCLASSINFO(StringMap, PString);
01987 public:
01988 StringMap(const PString & from, const PString & id)
01989 : PString(from), identifier(id) { }
01990 PString identifier;
01991 };
01992 PSortedStringList byAddress;
01993 PSortedStringList byAlias;
01994 PSortedStringList byVoicePrefix;
01995
01996 PSafeSortedList<H323GatekeeperCall> activeCalls;
01997
01998 PINDEX peakRegistrations;
01999 PINDEX totalRegistrations;
02000 PINDEX rejectedRegistrations;
02001 PINDEX peakCalls;
02002 PINDEX totalCalls;
02003 PINDEX rejectedCalls;
02004
02005 friend class H323GatekeeperRRQ;
02006 friend class H323GatekeeperARQ;
02007 };
02008
02009
02010 #endif // __OPAL_GKSERVER_H
02011
02012
02014