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 #ifndef __OPAL_GKSERVER_H
00035 #define __OPAL_GKSERVER_H
00036
00037 #ifdef P_USE_PRAGMA
00038 #pragma interface
00039 #endif
00040
00041 #include <opal/buildopts.h>
00042
00043 #include <ptlib/safecoll.h>
00044 #include <opal/guid.h>
00045 #include <h323/h225ras.h>
00046 #include <h323/transaddr.h>
00047 #include <h323/h235auth.h>
00048 #include <h323/h323pdu.h>
00049 #include <h323/h323trans.h>
00050
00051
00052 class PASN_Sequence;
00053 class PASN_Choice;
00054
00055 class H225_AliasAddress;
00056 class H225_EndpointIdentifier;
00057 class H225_GatekeeperIdentifier;
00058 class H225_ArrayOf_TransportAddress;
00059 class H225_GatekeeperIdentifier;
00060 class H225_EndpointIdentifier;
00061 class H225_InfoRequestResponse_perCallInfo_subtype;
00062 class H225_RasUsageInformation;
00063
00064 class H323RegisteredEndPoint;
00065 class H323GatekeeperListener;
00066 class H323GatekeeperServer;
00067 class H323RasPDU;
00068 class H323PeerElement;
00069
00070
00071 class H323GatekeeperRequest : public H323Transaction
00072 {
00073 PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00074 public:
00079 H323GatekeeperRequest(
00080 H323GatekeeperListener & rasChannel,
00081 const H323RasPDU & pdu
00082 );
00084
00085 virtual H323TransactionPDU * CreateRIP(
00086 unsigned sequenceNumber,
00087 unsigned delay
00088 ) const;
00089
00090 virtual PBoolean WritePDU(
00091 H323TransactionPDU & pdu
00092 );
00093 PBoolean CheckCryptoTokens();
00094 PBoolean CheckGatekeeperIdentifier();
00095 PBoolean GetRegisteredEndPoint();
00096
00097 virtual PString GetGatekeeperIdentifier() const = 0;
00098 virtual unsigned GetGatekeeperRejectTag() const = 0;
00099 virtual PString GetEndpointIdentifier() const = 0;
00100 virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00101 virtual unsigned GetSecurityRejectTag() const = 0;
00102
00103 H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00104
00105 PSafePtr<H323RegisteredEndPoint> endpoint;
00106
00107 protected:
00108 H323GatekeeperListener & rasChannel;
00109 };
00110
00111
00112 class H323GatekeeperGRQ : public H323GatekeeperRequest
00113 {
00114 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00115 public:
00116 H323GatekeeperGRQ(
00117 H323GatekeeperListener & listener,
00118 const H323RasPDU & pdu
00119 );
00120
00121 #if PTRACING
00122 virtual const char * GetName() const;
00123 #endif
00124 virtual PString GetGatekeeperIdentifier() const;
00125 virtual unsigned GetGatekeeperRejectTag() const;
00126 virtual PString GetEndpointIdentifier() const;
00127 virtual unsigned GetRegisteredEndPointRejectTag() const;
00128 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00129 virtual unsigned GetSecurityRejectTag() const;
00130 virtual void SetRejectReason(
00131 unsigned reasonCode
00132 );
00133
00134 H225_GatekeeperRequest & grq;
00135 H225_GatekeeperConfirm & gcf;
00136 H225_GatekeeperReject & grj;
00137
00138 protected:
00139 virtual Response OnHandlePDU();
00140 };
00141
00142
00143 class H323GatekeeperRRQ : public H323GatekeeperRequest
00144 {
00145 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00146 public:
00147 H323GatekeeperRRQ(
00148 H323GatekeeperListener & listener,
00149 const H323RasPDU & pdu
00150 );
00151
00152 #if PTRACING
00153 virtual const char * GetName() const;
00154 #endif
00155 virtual PString GetGatekeeperIdentifier() const;
00156 virtual unsigned GetGatekeeperRejectTag() const;
00157 virtual PString GetEndpointIdentifier() const;
00158 virtual unsigned GetRegisteredEndPointRejectTag() const;
00159 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00160 virtual unsigned GetSecurityRejectTag() const;
00161 virtual void SetRejectReason(
00162 unsigned reasonCode
00163 );
00164
00165 H225_RegistrationRequest & rrq;
00166 H225_RegistrationConfirm & rcf;
00167 H225_RegistrationReject & rrj;
00168
00169 protected:
00170 virtual Response OnHandlePDU();
00171 };
00172
00173
00174 class H323GatekeeperURQ : public H323GatekeeperRequest
00175 {
00176 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00177 public:
00178 H323GatekeeperURQ(
00179 H323GatekeeperListener & listener,
00180 const H323RasPDU & pdu
00181 );
00182
00183 #if PTRACING
00184 virtual const char * GetName() const;
00185 #endif
00186 virtual PString GetGatekeeperIdentifier() const;
00187 virtual unsigned GetGatekeeperRejectTag() const;
00188 virtual PString GetEndpointIdentifier() const;
00189 virtual unsigned GetRegisteredEndPointRejectTag() const;
00190 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00191 virtual unsigned GetSecurityRejectTag() const;
00192 virtual void SetRejectReason(
00193 unsigned reasonCode
00194 );
00195
00196 H225_UnregistrationRequest & urq;
00197 H225_UnregistrationConfirm & ucf;
00198 H225_UnregistrationReject & urj;
00199
00200 protected:
00201 virtual Response OnHandlePDU();
00202 };
00203
00204
00205 class H323GatekeeperARQ : public H323GatekeeperRequest
00206 {
00207 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00208 public:
00209 H323GatekeeperARQ(
00210 H323GatekeeperListener & listener,
00211 const H323RasPDU & pdu
00212 );
00213
00214 #if PTRACING
00215 virtual const char * GetName() const;
00216 #endif
00217 virtual PString GetGatekeeperIdentifier() const;
00218 virtual unsigned GetGatekeeperRejectTag() const;
00219 virtual PString GetEndpointIdentifier() const;
00220 virtual unsigned GetRegisteredEndPointRejectTag() const;
00221 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00222 virtual unsigned GetSecurityRejectTag() const;
00223 virtual void SetRejectReason(
00224 unsigned reasonCode
00225 );
00226
00227 H225_AdmissionRequest & arq;
00228 H225_AdmissionConfirm & acf;
00229 H225_AdmissionReject & arj;
00230
00231 PString alternateSecurityID;
00232
00233 protected:
00234 virtual Response OnHandlePDU();
00235 };
00236
00237
00238 class H323GatekeeperDRQ : public H323GatekeeperRequest
00239 {
00240 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00241 public:
00242 H323GatekeeperDRQ(
00243 H323GatekeeperListener & listener,
00244 const H323RasPDU & pdu
00245 );
00246
00247 #if PTRACING
00248 virtual const char * GetName() const;
00249 #endif
00250 virtual PString GetGatekeeperIdentifier() const;
00251 virtual unsigned GetGatekeeperRejectTag() const;
00252 virtual PString GetEndpointIdentifier() const;
00253 virtual unsigned GetRegisteredEndPointRejectTag() const;
00254 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00255 virtual unsigned GetSecurityRejectTag() const;
00256 virtual void SetRejectReason(
00257 unsigned reasonCode
00258 );
00259
00260 H225_DisengageRequest & drq;
00261 H225_DisengageConfirm & dcf;
00262 H225_DisengageReject & drj;
00263
00264 protected:
00265 virtual Response OnHandlePDU();
00266 };
00267
00268
00269 class H323GatekeeperBRQ : public H323GatekeeperRequest
00270 {
00271 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00272 public:
00273 H323GatekeeperBRQ(
00274 H323GatekeeperListener & listener,
00275 const H323RasPDU & pdu
00276 );
00277
00278 #if PTRACING
00279 virtual const char * GetName() const;
00280 #endif
00281 virtual PString GetGatekeeperIdentifier() const;
00282 virtual unsigned GetGatekeeperRejectTag() const;
00283 virtual PString GetEndpointIdentifier() const;
00284 virtual unsigned GetRegisteredEndPointRejectTag() const;
00285 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00286 virtual unsigned GetSecurityRejectTag() const;
00287 virtual void SetRejectReason(
00288 unsigned reasonCode
00289 );
00290
00291 H225_BandwidthRequest & brq;
00292 H225_BandwidthConfirm & bcf;
00293 H225_BandwidthReject & brj;
00294
00295 protected:
00296 virtual Response OnHandlePDU();
00297 };
00298
00299
00300 class H323GatekeeperLRQ : public H323GatekeeperRequest
00301 {
00302 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00303 public:
00304 H323GatekeeperLRQ(
00305 H323GatekeeperListener & listener,
00306 const H323RasPDU & pdu
00307 );
00308
00309 #if PTRACING
00310 virtual const char * GetName() const;
00311 #endif
00312 virtual PString GetGatekeeperIdentifier() const;
00313 virtual unsigned GetGatekeeperRejectTag() const;
00314 virtual PString GetEndpointIdentifier() const;
00315 virtual unsigned GetRegisteredEndPointRejectTag() const;
00316 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00317 virtual unsigned GetSecurityRejectTag() const;
00318 virtual void SetRejectReason(
00319 unsigned reasonCode
00320 );
00321
00322 H225_LocationRequest & lrq;
00323 H225_LocationConfirm & lcf;
00324 H225_LocationReject & lrj;
00325
00326 protected:
00327 virtual Response OnHandlePDU();
00328 };
00329
00330
00331 class H323GatekeeperIRR : public H323GatekeeperRequest
00332 {
00333 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00334 public:
00335 H323GatekeeperIRR(
00336 H323GatekeeperListener & listener,
00337 const H323RasPDU & pdu
00338 );
00339
00340 #if PTRACING
00341 virtual const char * GetName() const;
00342 #endif
00343 virtual PString GetGatekeeperIdentifier() const;
00344 virtual unsigned GetGatekeeperRejectTag() const;
00345 virtual PString GetEndpointIdentifier() const;
00346 virtual unsigned GetRegisteredEndPointRejectTag() const;
00347 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00348 virtual unsigned GetSecurityRejectTag() const;
00349 virtual void SetRejectReason(
00350 unsigned reasonCode
00351 );
00352
00353 H225_InfoRequestResponse & irr;
00354 H225_InfoRequestAck & iack;
00355 H225_InfoRequestNak & inak;
00356
00357 protected:
00358 virtual Response OnHandlePDU();
00359 };
00360
00361
00364 class H323GatekeeperCall : public PSafeObject
00365 {
00366 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00367 public:
00370 enum Direction {
00371 AnsweringCall,
00372 OriginatingCall,
00373 UnknownDirection
00374 };
00375
00378 H323GatekeeperCall(
00379 H323GatekeeperServer & server,
00380 const OpalGloballyUniqueID & callIdentifier,
00381 Direction direction
00382 );
00383
00386 ~H323GatekeeperCall();
00388
00393 Comparison Compare(
00394 const PObject & obj
00395 ) const;
00396
00399 void PrintOn(
00400 ostream & strm
00401 ) const;
00403
00411 virtual H323GatekeeperRequest::Response OnAdmission(
00412 H323GatekeeperARQ & request
00413 );
00414
00418 virtual PBoolean Disengage(
00419 int reason = -1
00420 );
00421
00425 virtual H323GatekeeperRequest::Response OnDisengage(
00426 H323GatekeeperDRQ & request
00427 );
00428
00433 virtual H323GatekeeperRequest::Response OnBandwidth(
00434 H323GatekeeperBRQ & request
00435 );
00436
00440 virtual H323GatekeeperRequest::Response OnInfoResponse(
00441 H323GatekeeperIRR & request,
00442 H225_InfoRequestResponse_perCallInfo_subtype & call
00443 );
00444
00447 virtual void OnAlerting();
00448
00451 virtual void OnConnected();
00452
00463 virtual PBoolean OnHeartbeat();
00464
00471 virtual PString GetCallCreditAmount() const;
00472
00479 virtual PBoolean GetCallCreditMode() const;
00480
00488 virtual unsigned GetDurationLimit() const;
00489
00494 virtual PBoolean SendCallCreditServiceControl();
00495
00498 PBoolean AddCallCreditServiceControl(
00499 H225_ArrayOf_ServiceControlSession & serviceControl
00500 ) const;
00501
00506 virtual PBoolean SendServiceControlSession(
00507 const H323ServiceControlSession & session
00508 );
00509
00515 virtual PBoolean TranslateAliasAddress(
00516 const H225_AliasAddress & alias,
00517 H225_ArrayOf_AliasAddress & aliases,
00518 H323TransportAddress & address,
00519 PBoolean & isGkRouted
00520 );
00521
00523
00526 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00527 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00528 PBoolean IsAnsweringCall() const { return direction == AnsweringCall; }
00529 unsigned GetCallReference() const { return callReference; }
00530 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00531 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00532 const PString & GetSourceNumber() const { return srcNumber; }
00533 const PStringArray & GetSourceAliases() const { return srcAliases; }
00534 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00535 PString GetSourceAddress() const;
00536 const PString & GetDestinationNumber() const { return dstNumber; }
00537 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00538 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00539 PString GetDestinationAddress() const;
00540 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00541 PBoolean SetBandwidthUsed(unsigned bandwidth);
00542 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00543 const PTime & GetCallStartTime() const { return callStartTime; }
00544 const PTime & GetAlertingTime() const { return alertingTime; }
00545 const PTime & GetConnectedTime() const { return connectedTime; }
00546 const PTime & GetCallEndTime() const { return callEndTime; }
00547 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00549
00550 protected:
00551 void SetUsageInfo(const H225_RasUsageInformation & usage);
00552
00553 H323GatekeeperServer & gatekeeper;
00554 H323RegisteredEndPoint * endpoint;
00555 H323GatekeeperListener * rasChannel;
00556
00557 Direction direction;
00558 unsigned callReference;
00559 OpalGloballyUniqueID callIdentifier;
00560 OpalGloballyUniqueID conferenceIdentifier;
00561 PString srcNumber;
00562 PStringArray srcAliases;
00563 H323TransportAddress srcHost;
00564 PString dstNumber;
00565 PStringArray dstAliases;
00566 H323TransportAddress dstHost;
00567 unsigned bandwidthUsed;
00568 unsigned infoResponseRate;
00569 PTime lastInfoResponse;
00570
00571 PBoolean drqReceived;
00572 PTime callStartTime;
00573 PTime alertingTime;
00574 PTime connectedTime;
00575 PTime callEndTime;
00576 H323Connection::CallEndReason callEndReason;
00577 };
00578
00579
00585 class H323RegisteredEndPoint : public PSafeObject
00586 {
00587 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00588 public:
00593 H323RegisteredEndPoint(
00594 H323GatekeeperServer & server,
00595 const PString & id
00596 );
00598
00603 Comparison Compare(
00604 const PObject & obj
00605 ) const;
00606
00609 void PrintOn(
00610 ostream & strm
00611 ) const;
00613
00620 virtual void AddCall(
00621 H323GatekeeperCall * call
00622 );
00623
00628 virtual PBoolean RemoveCall(
00629 H323GatekeeperCall * call
00630 );
00631
00634 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00635
00638 H323GatekeeperCall & GetCall(
00639 PINDEX idx
00640 ) { return activeCalls[idx]; }
00642
00651 virtual H323GatekeeperRequest::Response OnRegistration(
00652 H323GatekeeperRRQ & request
00653 );
00654
00664 virtual H323GatekeeperRequest::Response OnFullRegistration(
00665 H323GatekeeperRRQ & request
00666 );
00667
00676 virtual H323GatekeeperRequest::Response OnSecureRegistration(
00677 H323GatekeeperRRQ & request
00678 );
00679
00683 virtual H323GatekeeperRequest::Response OnUnregistration(
00684 H323GatekeeperURQ & request
00685 );
00686
00690 virtual PBoolean Unregister(
00691 int reason = -1
00692 );
00693
00698 virtual H323GatekeeperRequest::Response OnInfoResponse(
00699 H323GatekeeperIRR & request
00700 );
00701
00712 virtual PBoolean OnTimeToLive();
00713
00725 virtual PString GetCallCreditAmount() const;
00726
00734 virtual PBoolean GetCallCreditMode() const;
00735
00740 virtual PBoolean SendServiceControlSession(
00741 const H323ServiceControlSession & session
00742 );
00743
00747 virtual PBoolean AddServiceControlSession(
00748 const H323ServiceControlSession & session,
00749 H225_ArrayOf_ServiceControlSession & serviceControl
00750 );
00752
00757 virtual PBoolean SetPassword(
00758 const PString & password,
00759 const PString & username = PString::Empty()
00760 );
00761
00764 const PString & GetIdentifier() const { return identifier; }
00765
00768 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
00769
00772 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00773
00777 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
00778
00782 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
00783
00787 H323TransportAddress GetRASAddress(
00788 PINDEX idx
00789 ) const { return rasAddresses[idx]; }
00790
00794 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
00795
00799 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
00800
00804 H323TransportAddress GetSignalAddress(
00805 PINDEX idx
00806 ) const { return signalAddresses[idx]; }
00807
00810 const PStringArray & GetAliases() const { return aliases; }
00811
00814 PBoolean ContainsAlias(
00815 const PString & alias
00816 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
00817
00820 PINDEX GetAliasCount() const { return aliases.GetSize(); }
00821
00824 PString GetAlias(
00825 PINDEX idx
00826 ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
00827
00833 void RemoveAlias(
00834 const PString & alias
00835 );
00836
00839 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
00840
00843 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
00844
00847 PString GetPrefix(
00848 PINDEX idx
00849 ) const { return voicePrefixes[idx]; }
00850
00853 PCaselessString GetApplicationInfo() const { return productInfo.AsString(); }
00854
00857 const OpalProductInfo & GetProductInfo() const { return productInfo; }
00858
00861 unsigned GetProtocolVersion() const { return protocolVersion; }
00862
00865 PBoolean IsBehindNAT() const { return isBehindNAT; }
00866
00869 PBoolean CanDisplayAmountString() const { return canDisplayAmountString; }
00870
00873 PBoolean CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
00874
00877 PBoolean CanReceiveRIP() const;
00878
00881 PBoolean GetH225Version() const { return h225Version; }
00883
00893 virtual PBoolean OnSendDescriptorForEndpoint(
00894 H225_ArrayOf_AliasAddress & aliases,
00895 H225_EndpointType & terminalType,
00896 H225_ArrayOf_AliasAddress & transportAddresses
00897 );
00899
00900
00901 protected:
00902 H323GatekeeperServer & gatekeeper;
00903 H323GatekeeperListener * rasChannel;
00904
00905 PString identifier;
00906 OpalGloballyUniqueID descriptorID;
00907 H323TransportAddressArray rasAddresses;
00908 H323TransportAddressArray signalAddresses;
00909 PStringArray aliases;
00910 PStringArray voicePrefixes;
00911 OpalProductInfo productInfo;
00912 unsigned protocolVersion;
00913 PBoolean isBehindNAT;
00914 PBoolean canDisplayAmountString;
00915 PBoolean canEnforceDurationLimit;
00916 unsigned h225Version;
00917 unsigned timeToLive;
00918 H235Authenticators authenticators;
00919
00920 PTime lastRegistration;
00921 PTime lastInfoResponse;
00922
00923 PSortedList<H323GatekeeperCall> activeCalls;
00924 POrdinalDictionary<PString> serviceControlSessions;
00925 };
00926
00927
00933 class H323GatekeeperListener : public H225_RAS
00934 {
00935 PCLASSINFO(H323GatekeeperListener, H225_RAS);
00936 public:
00941 H323GatekeeperListener(
00942 H323EndPoint & endpoint,
00943 H323GatekeeperServer & server,
00944 const PString & gatekeeperIdentifier,
00945 H323Transport * transport = NULL
00946 );
00947
00950 ~H323GatekeeperListener();
00952
00957 PBoolean UnregistrationRequest(
00958 const H323RegisteredEndPoint & ep,
00959 unsigned reason
00960 );
00961
00964 PBoolean DisengageRequest(
00965 const H323GatekeeperCall & call,
00966 unsigned reason
00967 );
00968
00971 virtual PBoolean InfoRequest(
00972 H323RegisteredEndPoint & ep,
00973 H323GatekeeperCall * call = NULL
00974 );
00975
00978 virtual PBoolean ServiceControlIndication(
00979 H323RegisteredEndPoint & ep,
00980 const H323ServiceControlSession & session,
00981 H323GatekeeperCall * call = NULL
00982 );
00984
00991 virtual H323GatekeeperRequest::Response OnDiscovery(
00992 H323GatekeeperGRQ & request
00993 );
00994
00999 virtual H323GatekeeperRequest::Response OnRegistration(
01000 H323GatekeeperRRQ & request
01001 );
01002
01007 virtual H323GatekeeperRequest::Response OnUnregistration(
01008 H323GatekeeperURQ & request
01009 );
01010
01015 virtual H323GatekeeperRequest::Response OnAdmission(
01016 H323GatekeeperARQ & request
01017 );
01018
01023 virtual H323GatekeeperRequest::Response OnDisengage(
01024 H323GatekeeperDRQ & request
01025 );
01026
01031 virtual H323GatekeeperRequest::Response OnBandwidth(
01032 H323GatekeeperBRQ & request
01033 );
01034
01039 virtual H323GatekeeperRequest::Response OnLocation(
01040 H323GatekeeperLRQ & request
01041 );
01042
01047 virtual H323GatekeeperRequest::Response OnInfoResponse(
01048 H323GatekeeperIRR & request
01049 );
01051
01054 virtual PBoolean OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01055 virtual PBoolean OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01056 virtual PBoolean OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01057 virtual PBoolean OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01058 virtual PBoolean OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01059 virtual PBoolean OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01060 virtual PBoolean OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01061 virtual PBoolean OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01062 virtual PBoolean OnReceiveBandwidthReject(const H225_BandwidthReject &);
01063 virtual PBoolean OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01064 virtual PBoolean OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01065 virtual PBoolean OnReceiveDisengageReject(const H225_DisengageReject &);
01066 virtual PBoolean OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01067 virtual PBoolean OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01068 virtual PBoolean OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01069 virtual PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01070 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01072
01075 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01077
01078
01079 protected:
01080 H323GatekeeperServer & gatekeeper;
01081 };
01082
01083
01094 class H323GatekeeperServer : public H323TransactionServer
01095 {
01096 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01097 public:
01102 H323GatekeeperServer(
01103 H323EndPoint & endpoint
01104 );
01105
01108 ~H323GatekeeperServer();
01110
01111 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01112
01123 virtual H323Transactor * CreateListener(
01124 H323Transport * transport
01125 );
01126
01128
01134 virtual H323GatekeeperRequest::Response OnDiscovery(
01135 H323GatekeeperGRQ & request
01136 );
01137
01145 virtual H323GatekeeperRequest::Response OnRegistration(
01146 H323GatekeeperRRQ & request
01147 );
01148
01154 virtual H323GatekeeperRequest::Response OnUnregistration(
01155 H323GatekeeperURQ & request
01156 );
01157
01162 virtual H323GatekeeperRequest::Response OnInfoResponse(
01163 H323GatekeeperIRR & request
01164 );
01165
01176 virtual void AddEndPoint(
01177 H323RegisteredEndPoint * ep
01178 );
01179
01182 virtual PBoolean RemoveEndPoint(
01183 H323RegisteredEndPoint * ep
01184 );
01185
01194 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01195 H323GatekeeperRRQ & request
01196 );
01197
01206 virtual PString CreateEndPointIdentifier();
01207
01210 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01211 const PString & identifier,
01212 PSafetyMode mode = PSafeReference
01213 );
01214
01217 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01218 const H225_ArrayOf_TransportAddress & addresses,
01219 PSafetyMode mode = PSafeReference
01220 );
01221
01224 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01225 const H323TransportAddress & address,
01226 PSafetyMode mode = PSafeReference
01227 );
01228
01231 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01232 const H225_AliasAddress & alias,
01233 PSafetyMode mode = PSafeReadWrite
01234 );
01235
01238 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01239 const PString & alias,
01240 PSafetyMode mode = PSafeReference
01241 );
01242
01245 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01246 const PString & alias,
01247 PSafetyMode mode = PSafeReference
01248 );
01249
01252 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01253 const PString & prefix,
01254 PSafetyMode mode = PSafeReference
01255 );
01256
01259 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01260 PSafetyMode mode = PSafeReference
01261 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01263
01264 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01265 const OpalGloballyUniqueID & id,
01266 H323GatekeeperCall::Direction direction
01267 );
01268
01276 virtual H323GatekeeperRequest::Response OnAdmission(
01277 H323GatekeeperARQ & request
01278 );
01279
01284 virtual H323GatekeeperRequest::Response OnDisengage(
01285 H323GatekeeperDRQ & request
01286 );
01287
01292 virtual H323GatekeeperRequest::Response OnBandwidth(
01293 H323GatekeeperBRQ & request
01294 );
01295
01304 virtual H323GatekeeperCall * CreateCall(
01305 const OpalGloballyUniqueID & callIdentifier,
01306 H323GatekeeperCall::Direction direction
01307 );
01308
01311 virtual void AddCall(H323GatekeeperCall *)
01312 { }
01313
01316 virtual void RemoveCall(
01317 H323GatekeeperCall * call
01318 );
01319
01322 virtual PSafePtr<H323GatekeeperCall> FindCall(
01323 const PString & description,
01324 PSafetyMode mode = PSafeReference
01325 );
01326
01329 virtual PSafePtr<H323GatekeeperCall> FindCall(
01330 const OpalGloballyUniqueID & callIdentifier,
01331 PBoolean answeringCall,
01332 PSafetyMode mode = PSafeReference
01333 );
01334
01337 virtual PSafePtr<H323GatekeeperCall> FindCall(
01338 const OpalGloballyUniqueID & callIdentifier,
01339 H323GatekeeperCall::Direction direction,
01340 PSafetyMode mode = PSafeReference
01341 );
01342
01345 PSafePtr<H323GatekeeperCall> GetFirstCall(
01346 PSafetyMode mode = PSafeReference
01347 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01349
01359 virtual H323GatekeeperRequest::Response OnLocation(
01360 H323GatekeeperLRQ & request
01361 );
01362
01374 virtual PBoolean TranslateAliasAddress(
01375 const H225_AliasAddress & alias,
01376 H225_ArrayOf_AliasAddress & aliases,
01377 H323TransportAddress & address,
01378 PBoolean & isGkRouted,
01379 H323GatekeeperCall * call
01380 );
01381
01401 virtual PBoolean TranslateAliasAddressToSignalAddress(
01402 const H225_AliasAddress & alias,
01403 H323TransportAddress & address
01404 );
01406
01418 virtual PBoolean CheckSignalAddressPolicy(
01419 const H323RegisteredEndPoint & ep,
01420 const H225_AdmissionRequest & arq,
01421 const H323TransportAddress & address
01422 );
01423
01436 virtual PBoolean CheckAliasAddressPolicy(
01437 const H323RegisteredEndPoint & ep,
01438 const H225_AdmissionRequest & arq,
01439 const H225_AliasAddress & alias
01440 );
01441
01454 virtual PBoolean CheckAliasStringPolicy(
01455 const H323RegisteredEndPoint & ep,
01456 const H225_AdmissionRequest & arq,
01457 const PString & alias
01458 );
01459
01465 virtual unsigned AllocateBandwidth(
01466 unsigned newBandwidth,
01467 unsigned oldBandwidth = 0
01468 );
01470
01482 virtual PBoolean GetAdmissionRequestAuthentication(
01483 H323GatekeeperARQ & info,
01484 H235Authenticators & authenticators
01485 );
01486
01492 virtual PBoolean GetUsersPassword(
01493 const PString & alias,
01494 PString & password,
01495 H323RegisteredEndPoint & registeredEndpoint
01496 ) const;
01497 virtual PBoolean GetUsersPassword(
01498 const PString & alias,
01499 PString & password
01500 ) const;
01502
01507 H323PeerElement * GetPeerElement() const { return peerElement; }
01508
01512 void SetPeerElement(
01513 H323PeerElement * newPeerElement
01514 );
01515
01521 void CreatePeerElement(
01522 const H323TransportAddress & h501Interface
01523 );
01524
01530 PBoolean OpenPeerElement(
01531 const H323TransportAddress & remotePeer,
01532 PBoolean append = PFalse,
01533 PBoolean keepTrying = PTrue
01534 );
01536
01541 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01542
01548 void SetGatekeeperIdentifier(
01549 const PString & id,
01550 PBoolean adjustListeners = PTrue
01551 );
01552
01555 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01556
01559 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01560
01563 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01564
01567 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01568
01571 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01572
01575 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01576
01579 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01580
01583 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01584
01587 PBoolean IsGatekeeperRouted() const { return isGatekeeperRouted; }
01588
01591 PBoolean IsRequiredH235() const { return requireH235; }
01592
01595 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01596
01599 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01600
01603 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01604
01607 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01608
01611 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01612
01615 unsigned GetPeakCalls() const { return peakCalls; }
01616
01619 unsigned GetTotalCalls() const { return totalCalls; }
01620
01623 unsigned GetRejectedCalls() const { return rejectedCalls; }
01625
01626
01627 void RemoveAlias(
01628 H323RegisteredEndPoint & ep,
01629 const PString & alias
01630 );
01631
01632
01633 virtual PBoolean OnSendDescriptorForEndpoint(
01634 H323RegisteredEndPoint & ,
01635 H225_ArrayOf_AliasAddress & ,
01636 H225_EndpointType & ,
01637 H225_ArrayOf_AliasAddress &
01638 )
01639 { return PTrue; }
01640
01641 virtual PBoolean AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01642 { return canHaveDuplicateAlias; }
01643
01644 virtual PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01645 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01646
01647 protected:
01648
01649 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01650
01651
01652 PString gatekeeperIdentifier;
01653 unsigned totalBandwidth;
01654 unsigned usedBandwidth;
01655 unsigned defaultBandwidth;
01656 unsigned maximumBandwidth;
01657 unsigned defaultTimeToLive;
01658 unsigned defaultInfoResponseRate;
01659 PBoolean overwriteOnSameSignalAddress;
01660 PBoolean canHaveDuplicateAlias;
01661 PBoolean canHaveDuplicatePrefix;
01662 PBoolean canOnlyCallRegisteredEP;
01663 PBoolean canOnlyAnswerRegisteredEP;
01664 PBoolean answerCallPreGrantedARQ;
01665 PBoolean makeCallPreGrantedARQ;
01666 PBoolean isGatekeeperRouted;
01667 PBoolean aliasCanBeHostName;
01668 PBoolean requireH235;
01669 PBoolean disengageOnHearbeatFail;
01670
01671 PStringToString passwords;
01672
01673
01674 PMutex mutex;
01675 time_t identifierBase;
01676 unsigned nextIdentifier;
01677 PThread * monitorThread;
01678 PSyncPoint monitorExit;
01679
01680 PLIST(ListenerList, H323GatekeeperListener);
01681 ListenerList listeners;
01682
01683 H323PeerElement * peerElement;
01684
01685 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01686
01687 class StringMap : public PString {
01688 PCLASSINFO(StringMap, PString);
01689 public:
01690 StringMap(const PString & from, const PString & id)
01691 : PString(from), identifier(id) { }
01692 PString identifier;
01693 };
01694 PSortedStringList byAddress;
01695 PSortedStringList byAlias;
01696 PSortedStringList byVoicePrefix;
01697
01698 PSafeSortedList<H323GatekeeperCall> activeCalls;
01699
01700 PINDEX peakRegistrations;
01701 PINDEX totalRegistrations;
01702 PINDEX rejectedRegistrations;
01703 PINDEX peakCalls;
01704 PINDEX totalCalls;
01705 PINDEX rejectedCalls;
01706
01707 friend class H323GatekeeperRRQ;
01708 friend class H323GatekeeperARQ;
01709 };
01710
01711
01712 #endif // __OPAL_GKSERVER_H
01713
01714
01716