00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 #ifndef __OPAL_GKSERVER_H
00341 #define __OPAL_GKSERVER_H
00342
00343 #ifdef P_USE_PRAGMA
00344 #pragma interface
00345 #endif
00346
00347 #include "h323.h"
00348 #include "h323ep.h"
00349 #include "h225ras.h"
00350 #include "guid.h"
00351 #include "h235auth.h"
00352 #include "h323pdu.h"
00353 #include "h323trans.h"
00354
00355 #include <ptlib/safecoll.h>
00356
00357 class PASN_Sequence;
00358 class PASN_Choice;
00359
00360 class H225_AliasAddress;
00361 class H225_ArrayOf_TransportAddress;
00362 class H225_GatekeeperIdentifier;
00363 class H225_EndpointIdentifier;
00364 class H225_InfoRequestResponse_perCallInfo_subtype;
00365 class H225_RasUsageInformation;
00366
00367 class H323RegisteredEndPoint;
00368 class H323GatekeeperListener;
00369 class H323GatekeeperServer;
00370 class H323RasPDU;
00371 class H323PeerElement;
00372
00373
00374 class H323GatekeeperRequest : public H323Transaction
00375 {
00376 PCLASSINFO(H323GatekeeperRequest, H323Transaction);
00377 public:
00382 H323GatekeeperRequest(
00383 H323GatekeeperListener & rasChannel,
00384 const H323RasPDU & pdu
00385 );
00387
00388 virtual H323TransactionPDU * CreateRIP(
00389 unsigned sequenceNumber,
00390 unsigned delay
00391 ) const;
00392
00393 virtual BOOL WritePDU(
00394 H323TransactionPDU & pdu
00395 );
00396 BOOL CheckCryptoTokens();
00397 BOOL CheckGatekeeperIdentifier();
00398 BOOL GetRegisteredEndPoint();
00399
00400 virtual PString GetGatekeeperIdentifier() const = 0;
00401 virtual unsigned GetGatekeeperRejectTag() const = 0;
00402 virtual PString GetEndpointIdentifier() const = 0;
00403 virtual unsigned GetRegisteredEndPointRejectTag() const = 0;
00404 virtual unsigned GetSecurityRejectTag() const = 0;
00405
00406 H323GatekeeperListener & GetRasChannel() const { return rasChannel; }
00407
00408 PSafePtr<H323RegisteredEndPoint> endpoint;
00409
00410 protected:
00411 H323GatekeeperListener & rasChannel;
00412 };
00413
00414
00415 class H323GatekeeperGRQ : public H323GatekeeperRequest
00416 {
00417 PCLASSINFO(H323GatekeeperGRQ, H323GatekeeperRequest);
00418 public:
00419 H323GatekeeperGRQ(
00420 H323GatekeeperListener & listener,
00421 const H323RasPDU & pdu
00422 );
00423
00424 #if PTRACING
00425 virtual const char * GetName() const;
00426 #endif
00427 virtual PString GetGatekeeperIdentifier() const;
00428 virtual unsigned GetGatekeeperRejectTag() const;
00429 virtual PString GetEndpointIdentifier() const;
00430 virtual unsigned GetRegisteredEndPointRejectTag() const;
00431 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00432 virtual unsigned GetSecurityRejectTag() const;
00433 virtual void SetRejectReason(
00434 unsigned reasonCode
00435 );
00436
00437 H225_GatekeeperRequest & grq;
00438 H225_GatekeeperConfirm & gcf;
00439 H225_GatekeeperReject & grj;
00440
00441 protected:
00442 virtual Response OnHandlePDU();
00443 };
00444
00445
00446 class H323GatekeeperRRQ : public H323GatekeeperRequest
00447 {
00448 PCLASSINFO(H323GatekeeperRRQ, H323GatekeeperRequest);
00449 public:
00450 H323GatekeeperRRQ(
00451 H323GatekeeperListener & listener,
00452 const H323RasPDU & pdu
00453 );
00454
00455 #if PTRACING
00456 virtual const char * GetName() const;
00457 #endif
00458 virtual PString GetGatekeeperIdentifier() const;
00459 virtual unsigned GetGatekeeperRejectTag() const;
00460 virtual PString GetEndpointIdentifier() const;
00461 virtual unsigned GetRegisteredEndPointRejectTag() const;
00462 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00463 virtual unsigned GetSecurityRejectTag() const;
00464 virtual void SetRejectReason(
00465 unsigned reasonCode
00466 );
00467
00468 H225_RegistrationRequest & rrq;
00469 H225_RegistrationConfirm & rcf;
00470 H225_RegistrationReject & rrj;
00471
00472 protected:
00473 virtual Response OnHandlePDU();
00474 };
00475
00476
00477 class H323GatekeeperURQ : public H323GatekeeperRequest
00478 {
00479 PCLASSINFO(H323GatekeeperURQ, H323GatekeeperRequest);
00480 public:
00481 H323GatekeeperURQ(
00482 H323GatekeeperListener & listener,
00483 const H323RasPDU & pdu
00484 );
00485
00486 #if PTRACING
00487 virtual const char * GetName() const;
00488 #endif
00489 virtual PString GetGatekeeperIdentifier() const;
00490 virtual unsigned GetGatekeeperRejectTag() const;
00491 virtual PString GetEndpointIdentifier() const;
00492 virtual unsigned GetRegisteredEndPointRejectTag() const;
00493 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00494 virtual unsigned GetSecurityRejectTag() const;
00495 virtual void SetRejectReason(
00496 unsigned reasonCode
00497 );
00498
00499 H225_UnregistrationRequest & urq;
00500 H225_UnregistrationConfirm & ucf;
00501 H225_UnregistrationReject & urj;
00502
00503 protected:
00504 virtual Response OnHandlePDU();
00505 };
00506
00507
00508 class H323GatekeeperARQ : public H323GatekeeperRequest
00509 {
00510 PCLASSINFO(H323GatekeeperARQ, H323GatekeeperRequest);
00511 public:
00512 H323GatekeeperARQ(
00513 H323GatekeeperListener & listener,
00514 const H323RasPDU & pdu
00515 );
00516
00517 #if PTRACING
00518 virtual const char * GetName() const;
00519 #endif
00520 virtual PString GetGatekeeperIdentifier() const;
00521 virtual unsigned GetGatekeeperRejectTag() const;
00522 virtual PString GetEndpointIdentifier() const;
00523 virtual unsigned GetRegisteredEndPointRejectTag() const;
00524 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00525 virtual unsigned GetSecurityRejectTag() const;
00526 virtual void SetRejectReason(
00527 unsigned reasonCode
00528 );
00529
00530 H225_AdmissionRequest & arq;
00531 H225_AdmissionConfirm & acf;
00532 H225_AdmissionReject & arj;
00533
00534 PString alternateSecurityID;
00535
00536 protected:
00537 virtual Response OnHandlePDU();
00538 };
00539
00540
00541 class H323GatekeeperDRQ : public H323GatekeeperRequest
00542 {
00543 PCLASSINFO(H323GatekeeperDRQ, H323GatekeeperRequest);
00544 public:
00545 H323GatekeeperDRQ(
00546 H323GatekeeperListener & listener,
00547 const H323RasPDU & pdu
00548 );
00549
00550 #if PTRACING
00551 virtual const char * GetName() const;
00552 #endif
00553 virtual PString GetGatekeeperIdentifier() const;
00554 virtual unsigned GetGatekeeperRejectTag() const;
00555 virtual PString GetEndpointIdentifier() const;
00556 virtual unsigned GetRegisteredEndPointRejectTag() const;
00557 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00558 virtual unsigned GetSecurityRejectTag() const;
00559 virtual void SetRejectReason(
00560 unsigned reasonCode
00561 );
00562
00563 H225_DisengageRequest & drq;
00564 H225_DisengageConfirm & dcf;
00565 H225_DisengageReject & drj;
00566
00567 protected:
00568 virtual Response OnHandlePDU();
00569 };
00570
00571
00572 class H323GatekeeperBRQ : public H323GatekeeperRequest
00573 {
00574 PCLASSINFO(H323GatekeeperBRQ, H323GatekeeperRequest);
00575 public:
00576 H323GatekeeperBRQ(
00577 H323GatekeeperListener & listener,
00578 const H323RasPDU & pdu
00579 );
00580
00581 #if PTRACING
00582 virtual const char * GetName() const;
00583 #endif
00584 virtual PString GetGatekeeperIdentifier() const;
00585 virtual unsigned GetGatekeeperRejectTag() const;
00586 virtual PString GetEndpointIdentifier() const;
00587 virtual unsigned GetRegisteredEndPointRejectTag() const;
00588 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00589 virtual unsigned GetSecurityRejectTag() const;
00590 virtual void SetRejectReason(
00591 unsigned reasonCode
00592 );
00593
00594 H225_BandwidthRequest & brq;
00595 H225_BandwidthConfirm & bcf;
00596 H225_BandwidthReject & brj;
00597
00598 protected:
00599 virtual Response OnHandlePDU();
00600 };
00601
00602
00603 class H323GatekeeperLRQ : public H323GatekeeperRequest
00604 {
00605 PCLASSINFO(H323GatekeeperLRQ, H323GatekeeperRequest);
00606 public:
00607 H323GatekeeperLRQ(
00608 H323GatekeeperListener & listener,
00609 const H323RasPDU & pdu
00610 );
00611
00612 #if PTRACING
00613 virtual const char * GetName() const;
00614 #endif
00615 virtual PString GetGatekeeperIdentifier() const;
00616 virtual unsigned GetGatekeeperRejectTag() const;
00617 virtual PString GetEndpointIdentifier() const;
00618 virtual unsigned GetRegisteredEndPointRejectTag() const;
00619 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00620 virtual unsigned GetSecurityRejectTag() const;
00621 virtual void SetRejectReason(
00622 unsigned reasonCode
00623 );
00624
00625 H225_LocationRequest & lrq;
00626 H225_LocationConfirm & lcf;
00627 H225_LocationReject & lrj;
00628
00629 protected:
00630 virtual Response OnHandlePDU();
00631 };
00632
00633
00634 class H323GatekeeperIRR : public H323GatekeeperRequest
00635 {
00636 PCLASSINFO(H323GatekeeperIRR, H323GatekeeperRequest);
00637 public:
00638 H323GatekeeperIRR(
00639 H323GatekeeperListener & listener,
00640 const H323RasPDU & pdu
00641 );
00642
00643 #if PTRACING
00644 virtual const char * GetName() const;
00645 #endif
00646 virtual PString GetGatekeeperIdentifier() const;
00647 virtual unsigned GetGatekeeperRejectTag() const;
00648 virtual PString GetEndpointIdentifier() const;
00649 virtual unsigned GetRegisteredEndPointRejectTag() const;
00650 virtual H235Authenticator::ValidationResult ValidatePDU() const;
00651 virtual unsigned GetSecurityRejectTag() const;
00652 virtual void SetRejectReason(
00653 unsigned reasonCode
00654 );
00655
00656 H225_InfoRequestResponse & irr;
00657 H225_InfoRequestAck & iack;
00658 H225_InfoRequestNak & inak;
00659
00660 protected:
00661 virtual Response OnHandlePDU();
00662 };
00663
00664
00667 class H323GatekeeperCall : public PSafeObject
00668 {
00669 PCLASSINFO(H323GatekeeperCall, PSafeObject);
00670 public:
00673 enum Direction {
00674 AnsweringCall,
00675 OriginatingCall,
00676 UnknownDirection
00677 };
00678
00681 H323GatekeeperCall(
00682 H323GatekeeperServer & server,
00683 const OpalGloballyUniqueID & callIdentifier,
00684 Direction direction
00685 );
00686
00689 ~H323GatekeeperCall();
00691
00696 Comparison Compare(
00697 const PObject & obj
00698 ) const;
00699
00702 void PrintOn(
00703 ostream & strm
00704 ) const;
00706
00714 virtual H323GatekeeperRequest::Response OnAdmission(
00715 H323GatekeeperARQ & request
00716 );
00717
00721 virtual BOOL Disengage(
00722 int reason = -1
00723 );
00724
00728 virtual H323GatekeeperRequest::Response OnDisengage(
00729 H323GatekeeperDRQ & request
00730 );
00731
00736 virtual H323GatekeeperRequest::Response OnBandwidth(
00737 H323GatekeeperBRQ & request
00738 );
00739
00743 virtual H323GatekeeperRequest::Response OnInfoResponse(
00744 H323GatekeeperIRR & request,
00745 H225_InfoRequestResponse_perCallInfo_subtype & call
00746 );
00747
00750 virtual void OnAlerting();
00751
00754 virtual void OnConnected();
00755
00766 virtual BOOL OnHeartbeat();
00767
00768 #ifdef H323_H248
00769
00776 virtual PString GetCallCreditAmount() const;
00777
00784 virtual BOOL GetCallCreditMode() const;
00785
00793 virtual unsigned GetDurationLimit() const;
00794
00799 virtual BOOL SendCallCreditServiceControl();
00800
00803 BOOL AddCallCreditServiceControl(
00804 H225_ArrayOf_ServiceControlSession & serviceControl
00805 ) const;
00806
00811 virtual BOOL SendServiceControlSession(
00812 const H323ServiceControlSession & session
00813 );
00814
00815 #endif // H323_H248
00816
00822 virtual BOOL TranslateAliasAddress(
00823 const H225_AliasAddress & alias,
00824 H225_ArrayOf_AliasAddress & aliases,
00825 H323TransportAddress & address,
00826 BOOL & isGkRouted
00827 );
00828
00830
00833 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
00834 H323RegisteredEndPoint & GetEndPoint() const { return *PAssertNULL(endpoint); }
00835 BOOL IsAnsweringCall() const { return direction == AnsweringCall; }
00836 unsigned GetCallReference() const { return callReference; }
00837 const OpalGloballyUniqueID & GetCallIdentifier() const { return callIdentifier; }
00838 const OpalGloballyUniqueID & GetConferenceIdentifier() const { return conferenceIdentifier; }
00839 const PString & GetSourceNumber() const { return srcNumber; }
00840 const PStringArray & GetSourceAliases() const { return srcAliases; }
00841 const H323TransportAddress & GetSourceHost() const { return srcHost; }
00842 PString GetSourceAddress() const;
00843 const PString & GetDestinationNumber() const { return dstNumber; }
00844 const PStringArray & GetDestinationAliases() const { return dstAliases; }
00845 const H323TransportAddress & GetDestinationHost() const { return dstHost; }
00846 PString GetDestinationAddress() const;
00847 unsigned GetBandwidthUsed() const { return bandwidthUsed; }
00848 BOOL SetBandwidthUsed(unsigned bandwidth);
00849 const PTime & GetLastInfoResponseTime() const { return lastInfoResponse; }
00850 const PTime & GetCallStartTime() const { return callStartTime; }
00851 const PTime & GetAlertingTime() const { return alertingTime; }
00852 const PTime & GetConnectedTime() const { return connectedTime; }
00853 const PTime & GetCallEndTime() const { return callEndTime; }
00854 H323Connection::CallEndReason GetCallEndReason() const { return callEndReason; }
00856
00857 protected:
00858 void SetUsageInfo(const H225_RasUsageInformation & usage);
00859
00860 H323GatekeeperServer & gatekeeper;
00861 H323RegisteredEndPoint * endpoint;
00862 H323GatekeeperListener * rasChannel;
00863
00864 Direction direction;
00865 unsigned callReference;
00866 OpalGloballyUniqueID callIdentifier;
00867 OpalGloballyUniqueID conferenceIdentifier;
00868 PString srcNumber;
00869 PStringArray srcAliases;
00870 H323TransportAddress srcHost;
00871 PString dstNumber;
00872 PStringArray dstAliases;
00873 H323TransportAddress dstHost;
00874 unsigned bandwidthUsed;
00875 unsigned infoResponseRate;
00876 PTime lastInfoResponse;
00877
00878 BOOL drqReceived;
00879 PTime callStartTime;
00880 PTime alertingTime;
00881 PTime connectedTime;
00882 PTime callEndTime;
00883 H323Connection::CallEndReason callEndReason;
00884 };
00885
00886
00892 class H323RegisteredEndPoint : public PSafeObject
00893 {
00894 PCLASSINFO(H323RegisteredEndPoint, PSafeObject);
00895 public:
00900 H323RegisteredEndPoint(
00901 H323GatekeeperServer & server,
00902 const PString & id
00903 );
00905
00910 Comparison Compare(
00911 const PObject & obj
00912 ) const;
00913
00916 void PrintOn(
00917 ostream & strm
00918 ) const;
00920
00927 virtual void AddCall(
00928 H323GatekeeperCall * call
00929 );
00930
00935 virtual BOOL RemoveCall(
00936 H323GatekeeperCall * call
00937 );
00938
00941 PINDEX GetCallCount() const { return activeCalls.GetSize(); }
00942
00945 H323GatekeeperCall & GetCall(
00946 PINDEX idx
00947 ) { return activeCalls[idx]; }
00949
00958 virtual H323GatekeeperRequest::Response OnRegistration(
00959 H323GatekeeperRRQ & request
00960 );
00961
00971 virtual H323GatekeeperRequest::Response OnFullRegistration(
00972 H323GatekeeperRRQ & request
00973 );
00974
00983 virtual H323GatekeeperRequest::Response OnSecureRegistration(
00984 H323GatekeeperRRQ & request
00985 );
00986
00990 virtual H323GatekeeperRequest::Response OnUnregistration(
00991 H323GatekeeperURQ & request
00992 );
00993
00997 virtual BOOL Unregister(
00998 int reason = -1
00999 );
01000
01005 virtual H323GatekeeperRequest::Response OnInfoResponse(
01006 H323GatekeeperIRR & request
01007 );
01008
01019 virtual BOOL OnTimeToLive();
01020
01021 #ifdef H323_H248
01022
01034 virtual PString GetCallCreditAmount() const;
01035
01043 virtual BOOL GetCallCreditMode() const;
01044
01049 virtual BOOL SendServiceControlSession(
01050 const H323ServiceControlSession & session
01051 );
01052
01056 virtual BOOL AddServiceControlSession(
01057 const H323ServiceControlSession & session,
01058 H225_ArrayOf_ServiceControlSession & serviceControl
01059 );
01060 #endif // H323_H248
01061
01062
01067 virtual BOOL SetPassword(
01068 const PString & password,
01069 const PString & username = PString::Empty()
01070 );
01071
01074 const PString & GetIdentifier() const { return identifier; }
01075
01078 const OpalGloballyUniqueID & GetDescriptorID() const { return descriptorID; }
01079
01082 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01083
01087 const H323TransportAddressArray & GetRASAddresses() const { return rasAddresses; }
01088
01092 PINDEX GetRASAddressCount() const { return rasAddresses.GetSize(); }
01093
01097 H323TransportAddress GetRASAddress(
01098 PINDEX idx
01099 ) const { return rasAddresses[idx]; }
01100
01104 const H323TransportAddressArray & GetSignalAddresses() const { return signalAddresses; }
01105
01109 PINDEX GetSignalAddressCount() const { return signalAddresses.GetSize(); }
01110
01114 H323TransportAddress GetSignalAddress(
01115 PINDEX idx
01116 ) const { return signalAddresses[idx]; }
01117
01120 const PStringArray & GetAliases() const { return aliases; }
01121
01124 BOOL ContainsAlias(
01125 const PString & alias
01126 ) { return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01127
01130 PINDEX GetAliasCount() const { return aliases.GetSize(); }
01131
01134 PString GetAlias(
01135 PINDEX idx
01136 ) const { if (idx < aliases.GetSize()) return aliases[idx]; return PString::Empty(); }
01137
01143 void RemoveAlias(
01144 const PString & alias
01145 );
01146
01149 virtual const H235Authenticators & GetAuthenticators() const { return authenticators; }
01150
01153 PINDEX GetPrefixCount() const { return voicePrefixes.GetSize(); }
01154
01157 PString GetPrefix(
01158 PINDEX idx
01159 ) const { return voicePrefixes[idx]; }
01160
01163 const PCaselessString & GetApplicationInfo() const { return applicationInfo; }
01164
01167 unsigned GetProtocolVersion() const { return protocolVersion; }
01168
01171 BOOL IsBehindNAT() const { return isBehindNAT; }
01172
01175 BOOL CanDisplayAmountString() const { return canDisplayAmountString; }
01176
01179 BOOL CanEnforceDurationLimit() const { return canEnforceDurationLimit; }
01180
01183 BOOL CanReceiveRIP() const;
01184
01187 BOOL GetH225Version() const { return h225Version; }
01189
01190 #ifdef H323_H501
01191
01200 virtual BOOL OnSendDescriptorForEndpoint(
01201 H225_ArrayOf_AliasAddress & aliases,
01202 H225_EndpointType & terminalType,
01203 H225_ArrayOf_AliasAddress & transportAddresses
01204 );
01206 #endif
01207
01208
01209 protected:
01210 H323GatekeeperServer & gatekeeper;
01211 H323GatekeeperListener * rasChannel;
01212
01213 PString identifier;
01214 OpalGloballyUniqueID descriptorID;
01215 H323TransportAddressArray rasAddresses;
01216 H323TransportAddressArray signalAddresses;
01217 PStringArray aliases;
01218 PStringArray voicePrefixes;
01219 PCaselessString applicationInfo;
01220 unsigned protocolVersion;
01221 BOOL isBehindNAT;
01222 BOOL canDisplayAmountString;
01223 BOOL canEnforceDurationLimit;
01224 unsigned h225Version;
01225 unsigned timeToLive;
01226 H235Authenticators authenticators;
01227
01228 PTime lastRegistration;
01229 PTime lastInfoResponse;
01230
01231 PSortedList<H323GatekeeperCall> activeCalls;
01232 #ifdef H323_H248
01233 POrdinalDictionary<PString> serviceControlSessions;
01234 #endif
01235 };
01236
01237
01243 class H323GatekeeperListener : public H225_RAS
01244 {
01245 PCLASSINFO(H323GatekeeperListener, H225_RAS);
01246 public:
01251 H323GatekeeperListener(
01252 H323EndPoint & endpoint,
01253 H323GatekeeperServer & server,
01254 const PString & gatekeeperIdentifier,
01255 H323Transport * transport = NULL
01256 );
01257
01260 ~H323GatekeeperListener();
01262
01267 BOOL UnregistrationRequest(
01268 const H323RegisteredEndPoint & ep,
01269 unsigned reason
01270 );
01271
01274 BOOL DisengageRequest(
01275 const H323GatekeeperCall & call,
01276 unsigned reason
01277 );
01278
01281 virtual BOOL InfoRequest(
01282 H323RegisteredEndPoint & ep,
01283 H323GatekeeperCall * call = NULL
01284 );
01285
01286 #ifdef H323_H248
01287
01289 virtual BOOL ServiceControlIndication(
01290 H323RegisteredEndPoint & ep,
01291 const H323ServiceControlSession & session,
01292 H323GatekeeperCall * call = NULL
01293 );
01294 #endif
01295
01296
01303 virtual H323GatekeeperRequest::Response OnDiscovery(
01304 H323GatekeeperGRQ & request
01305 );
01306
01311 virtual H323GatekeeperRequest::Response OnRegistration(
01312 H323GatekeeperRRQ & request
01313 );
01314
01319 virtual H323GatekeeperRequest::Response OnUnregistration(
01320 H323GatekeeperURQ & request
01321 );
01322
01327 virtual H323GatekeeperRequest::Response OnAdmission(
01328 H323GatekeeperARQ & request
01329 );
01330
01335 virtual H323GatekeeperRequest::Response OnDisengage(
01336 H323GatekeeperDRQ & request
01337 );
01338
01343 virtual H323GatekeeperRequest::Response OnBandwidth(
01344 H323GatekeeperBRQ & request
01345 );
01346
01351 virtual H323GatekeeperRequest::Response OnLocation(
01352 H323GatekeeperLRQ & request
01353 );
01354
01359 virtual H323GatekeeperRequest::Response OnInfoResponse(
01360 H323GatekeeperIRR & request
01361 );
01363
01366 BOOL OnReceiveGatekeeperRequest(const H323RasPDU &, const H225_GatekeeperRequest &);
01367 BOOL OnReceiveRegistrationRequest(const H323RasPDU &, const H225_RegistrationRequest &);
01368 BOOL OnReceiveUnregistrationRequest(const H323RasPDU &, const H225_UnregistrationRequest &);
01369 BOOL OnReceiveUnregistrationConfirm(const H225_UnregistrationConfirm &);
01370 BOOL OnReceiveUnregistrationReject(const H225_UnregistrationReject &);
01371 BOOL OnReceiveAdmissionRequest(const H323RasPDU &, const H225_AdmissionRequest &);
01372 BOOL OnReceiveBandwidthRequest(const H323RasPDU &, const H225_BandwidthRequest &);
01373 BOOL OnReceiveBandwidthConfirm(const H225_BandwidthConfirm &);
01374 BOOL OnReceiveBandwidthReject(const H225_BandwidthReject &);
01375 BOOL OnReceiveDisengageRequest(const H323RasPDU &, const H225_DisengageRequest &);
01376 BOOL OnReceiveDisengageConfirm(const H225_DisengageConfirm &);
01377 BOOL OnReceiveDisengageReject(const H225_DisengageReject &);
01378 BOOL OnReceiveLocationRequest(const H323RasPDU &, const H225_LocationRequest &);
01379 BOOL OnReceiveInfoRequestResponse(const H323RasPDU &, const H225_InfoRequestResponse &);
01380 BOOL OnReceiveResourcesAvailableConfirm(const H225_ResourcesAvailableConfirm &);
01381 BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01382 void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01384
01387 H323GatekeeperServer & GetGatekeeper() const { return gatekeeper; }
01389
01390
01391 protected:
01392 H323GatekeeperServer & gatekeeper;
01393 };
01394
01395
01406 class H323GatekeeperServer : public H323TransactionServer
01407 {
01408 PCLASSINFO(H323GatekeeperServer, H323TransactionServer);
01409 public:
01414 H323GatekeeperServer(
01415 H323EndPoint & endpoint
01416 );
01417
01420 ~H323GatekeeperServer();
01422
01423 WORD GetDefaultUdpPort() { return H225_RAS::DefaultRasUdpPort; }
01424
01435 virtual H323Transactor * CreateListener(
01436 H323Transport * transport
01437 );
01438
01440
01446 virtual H323GatekeeperRequest::Response OnDiscovery(
01447 H323GatekeeperGRQ & request
01448 );
01449
01457 virtual H323GatekeeperRequest::Response OnRegistration(
01458 H323GatekeeperRRQ & request
01459 );
01460
01466 virtual H323GatekeeperRequest::Response OnUnregistration(
01467 H323GatekeeperURQ & request
01468 );
01469
01474 virtual H323GatekeeperRequest::Response OnInfoResponse(
01475 H323GatekeeperIRR & request
01476 );
01477
01488 virtual void AddEndPoint(
01489 H323RegisteredEndPoint * ep
01490 );
01491
01494 virtual BOOL RemoveEndPoint(
01495 H323RegisteredEndPoint * ep
01496 );
01497
01506 virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01507 H323GatekeeperRRQ & request
01508 );
01509
01518 virtual PString CreateEndPointIdentifier();
01519
01522 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01523 const PString & identifier,
01524 PSafetyMode mode = PSafeReference
01525 );
01526
01529 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01530 const H225_ArrayOf_TransportAddress & addresses,
01531 PSafetyMode mode = PSafeReference
01532 );
01533
01536 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01537 const H323TransportAddress & address,
01538 PSafetyMode mode = PSafeReference
01539 );
01540
01543 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01544 const H225_AliasAddress & alias,
01545 PSafetyMode mode = PSafeReadWrite
01546 );
01547
01550 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01551 const PString & alias,
01552 PSafetyMode mode = PSafeReference
01553 );
01554
01557 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01558 const PString & alias,
01559 PSafetyMode mode = PSafeReference
01560 );
01561
01564 virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01565 const PString & prefix,
01566 PSafetyMode mode = PSafeReference
01567 );
01568
01571 PSafePtr<H323RegisteredEndPoint> GetFirstEndPoint(
01572 PSafetyMode mode = PSafeReference
01573 ) { return PSafePtr<H323RegisteredEndPoint>(byIdentifier, mode); }
01575
01576 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01577 const OpalGloballyUniqueID & id,
01578 H323GatekeeperCall::Direction direction
01579 );
01580
01588 virtual H323GatekeeperRequest::Response OnAdmission(
01589 H323GatekeeperARQ & request
01590 );
01591
01596 virtual H323GatekeeperRequest::Response OnDisengage(
01597 H323GatekeeperDRQ & request
01598 );
01599
01604 virtual H323GatekeeperRequest::Response OnBandwidth(
01605 H323GatekeeperBRQ & request
01606 );
01607
01616 virtual H323GatekeeperCall * CreateCall(
01617 const OpalGloballyUniqueID & callIdentifier,
01618 H323GatekeeperCall::Direction direction
01619 );
01620
01623 virtual void AddCall(H323GatekeeperCall *)
01624 { }
01625
01628 virtual void RemoveCall(
01629 H323GatekeeperCall * call
01630 );
01631
01634 virtual PSafePtr<H323GatekeeperCall> FindCall(
01635 const PString & description,
01636 PSafetyMode mode = PSafeReference
01637 );
01638
01641 virtual PSafePtr<H323GatekeeperCall> FindCall(
01642 const OpalGloballyUniqueID & callIdentifier,
01643 BOOL answeringCall,
01644 PSafetyMode mode = PSafeReference
01645 );
01646
01649 virtual PSafePtr<H323GatekeeperCall> FindCall(
01650 const OpalGloballyUniqueID & callIdentifier,
01651 H323GatekeeperCall::Direction direction,
01652 PSafetyMode mode = PSafeReference
01653 );
01654
01657 PSafePtr<H323GatekeeperCall> GetFirstCall(
01658 PSafetyMode mode = PSafeReference
01659 ) { return PSafePtr<H323GatekeeperCall>(activeCalls, mode); }
01660
01661
01663
01673 virtual H323GatekeeperRequest::Response OnLocation(
01674 H323GatekeeperLRQ & request
01675 );
01676
01688 virtual BOOL TranslateAliasAddress(
01689 const H225_AliasAddress & alias,
01690 H225_ArrayOf_AliasAddress & aliases,
01691 H323TransportAddress & address,
01692 BOOL & isGkRouted,
01693 H323GatekeeperCall * call
01694 );
01695 virtual BOOL TranslateAliasAddressToSignalAddress(
01696 const H225_AliasAddress & alias,
01697 H323TransportAddress & address
01698 );
01699
01701
01713 virtual BOOL CheckSignalAddressPolicy(
01714 const H323RegisteredEndPoint & ep,
01715 const H225_AdmissionRequest & arq,
01716 const H323TransportAddress & address
01717 );
01718
01731 virtual BOOL CheckAliasAddressPolicy(
01732 const H323RegisteredEndPoint & ep,
01733 const H225_AdmissionRequest & arq,
01734 const H225_AliasAddress & alias
01735 );
01736
01749 virtual BOOL CheckAliasStringPolicy(
01750 const H323RegisteredEndPoint & ep,
01751 const H225_AdmissionRequest & arq,
01752 const PString & alias
01753 );
01754
01760 virtual unsigned AllocateBandwidth(
01761 unsigned newBandwidth,
01762 unsigned oldBandwidth = 0
01763 );
01765
01777 virtual BOOL GetAdmissionRequestAuthentication(
01778 H323GatekeeperARQ & info,
01779 H235Authenticators & authenticators
01780 );
01781
01787 virtual BOOL GetUsersPassword(
01788 const PString & alias,
01789 PString & password,
01790 H323RegisteredEndPoint & registeredEndpoint
01791 ) const;
01792 virtual BOOL GetUsersPassword(
01793 const PString & alias,
01794 PString & password
01795 ) const;
01797
01798 #ifdef H323_H501
01799
01804 H323PeerElement * GetPeerElement() const { return peerElement; }
01805
01809 void SetPeerElement(
01810 H323PeerElement * newPeerElement
01811 );
01812
01818 void CreatePeerElement(
01819 const H323TransportAddress & h501Interface
01820 );
01821
01827 BOOL OpenPeerElement(
01828 const H323TransportAddress & remotePeer,
01829 BOOL append = FALSE,
01830 BOOL keepTrying = TRUE
01831 );
01833
01834 #endif // H323_H501
01835
01840 const PString & GetGatekeeperIdentifier() const { return gatekeeperIdentifier; }
01841
01847 void SetGatekeeperIdentifier(
01848 const PString & id,
01849 BOOL adjustListeners = TRUE
01850 );
01851
01854 unsigned GetAvailableBandwidth() const { return totalBandwidth; }
01855
01858 void SetAvailableBandwidth(unsigned bps100) { totalBandwidth = bps100; }
01859
01862 unsigned GetUsedBandwidth() const { return usedBandwidth; }
01863
01866 unsigned GetDefaultBandwidth() const { return defaultBandwidth; }
01867
01870 unsigned GetTimeToLive() const { return defaultTimeToLive; }
01871
01874 void SetTimeToLive(unsigned seconds) { defaultTimeToLive = seconds; }
01875
01878 unsigned GetInfoResponseRate() const { return defaultInfoResponseRate; }
01879
01882 void SetInfoResponseRate(unsigned seconds) { defaultInfoResponseRate = seconds; }
01883
01886 BOOL IsGatekeeperRouted() const { return isGatekeeperRouted; }
01887
01890 BOOL IsRequiredH235() const { return requireH235; }
01891
01894 unsigned GetActiveRegistrations() const { return byIdentifier.GetSize(); }
01895
01898 unsigned GetPeakRegistrations() const { return peakRegistrations; }
01899
01902 unsigned GetTotalRegistrations() const { return totalRegistrations; }
01903
01906 unsigned GetRejectedRegistrations() const { return rejectedRegistrations; }
01907
01910 unsigned GetActiveCalls() const { return activeCalls.GetSize(); }
01911
01914 unsigned GetPeakCalls() const { return peakCalls; }
01915
01918 unsigned GetTotalCalls() const { return totalCalls; }
01919
01922 unsigned GetRejectedCalls() const { return rejectedCalls; }
01924
01925
01926 void RemoveAlias(
01927 H323RegisteredEndPoint & ep,
01928 const PString & alias
01929 );
01930
01931 #ifdef H323_H501
01932
01933 virtual BOOL OnSendDescriptorForEndpoint(
01934 H323RegisteredEndPoint & ,
01935 H225_ArrayOf_AliasAddress & ,
01936 H225_EndpointType & ,
01937 H225_ArrayOf_AliasAddress &
01938 )
01939 { return TRUE; }
01940 #endif
01941
01942 virtual BOOL AllowDuplicateAlias(const H225_ArrayOf_AliasAddress & )
01943 { return canHaveDuplicateAlias; }
01944
01945 virtual BOOL OnSendFeatureSet(unsigned, H225_FeatureSet & features) const;
01946 virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet & features) const;
01947
01948 protected:
01949
01950 PDECLARE_NOTIFIER(PThread, H323GatekeeperServer, MonitorMain);
01951
01952
01953 PString gatekeeperIdentifier;
01954 unsigned totalBandwidth;
01955 unsigned usedBandwidth;
01956 unsigned defaultBandwidth;
01957 unsigned maximumBandwidth;
01958 unsigned defaultTimeToLive;
01959 unsigned defaultInfoResponseRate;
01960 BOOL overwriteOnSameSignalAddress;
01961 BOOL canHaveDuplicateAlias;
01962 BOOL canHaveDuplicatePrefix;
01963 BOOL canOnlyCallRegisteredEP;
01964 BOOL canOnlyAnswerRegisteredEP;
01965 BOOL answerCallPreGrantedARQ;
01966 BOOL makeCallPreGrantedARQ;
01967 BOOL isGatekeeperRouted;
01968 BOOL aliasCanBeHostName;
01969 BOOL requireH235;
01970 BOOL disengageOnHearbeatFail;
01971
01972 PStringToString passwords;
01973
01974
01975 PMutex mutex;
01976 time_t identifierBase;
01977 unsigned nextIdentifier;
01978 PThread * monitorThread;
01979 PSyncPoint monitorExit;
01980
01981 PLIST(ListenerList, H323GatekeeperListener);
01982 ListenerList listeners;
01983
01984 H323PeerElement * peerElement;
01985
01986 PSafeDictionary<PString, H323RegisteredEndPoint> byIdentifier;
01987
01988 class StringMap : public PString {
01989 PCLASSINFO(StringMap, PString);
01990 public:
01991 StringMap(const PString & from, const PString & id)
01992 : PString(from), identifier(id) { }
01993 PString identifier;
01994 };
01995 PSortedStringList byAddress;
01996 PSortedStringList byAlias;
01997 PSortedStringList byVoicePrefix;
01998
01999 PSafeSortedList<H323GatekeeperCall> activeCalls;
02000
02001 PINDEX peakRegistrations;
02002 PINDEX totalRegistrations;
02003 PINDEX rejectedRegistrations;
02004 PINDEX peakCalls;
02005 PINDEX totalCalls;
02006 PINDEX rejectedCalls;
02007
02008 friend class H323GatekeeperRRQ;
02009 friend class H323GatekeeperARQ;
02010 };
02011
02012
02013 #endif // __OPAL_GKSERVER_H
02014
02015
02017