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
#ifndef __OPAL_GKSERVER_H
00319
#define __OPAL_GKSERVER_H
00320
00321
#ifdef P_USE_PRAGMA
00322
#pragma interface
00323
#endif
00324
00325
00326
#include "h323ep.h"
00327
#include "h225ras.h"
00328
#include "guid.h"
00329
#include "h235auth.h"
00330
#include "h323pdu.h"
00331
#include "h323trans.h"
00332
00333
#include <ptlib/safecoll.h>
00334
00335
00336
class PASN_Sequence;
00337
class PASN_Choice;
00338
00339
class H225_AliasAddress;
00340
class H225_ArrayOf_TransportAddress;
00341
class H225_GatekeeperIdentifier;
00342
class H225_EndpointIdentifier;
00343
class H225_InfoRequestResponse_perCallInfo_subtype;
00344
class H225_RasUsageInformation;
00345
00346
class H323RegisteredEndPoint;
00347
class H323GatekeeperListener;
00348
class H323GatekeeperServer;
00349
class H323RasPDU;
00350
class H323PeerElement;
00351
00352
00353 class H323GatekeeperRequest :
public H323Transaction
00354 {
00355 PCLASSINFO(
H323GatekeeperRequest,
H323Transaction);
00356
public:
00361
H323GatekeeperRequest(
00362
H323GatekeeperListener &
rasChannel,
00363
const H323RasPDU & pdu
00364 );
00366
00367
virtual H323TransactionPDU *
CreateRIP(
00368
unsigned sequenceNumber,
00369
unsigned delay
00370 )
const;
00371
00372
virtual BOOL
WritePDU(
00373
H323TransactionPDU & pdu
00374 );
00375 BOOL
CheckCryptoTokens();
00376 BOOL
CheckGatekeeperIdentifier();
00377 BOOL
GetRegisteredEndPoint();
00378
00379
virtual PString
GetGatekeeperIdentifier()
const = 0;
00380
virtual unsigned GetGatekeeperRejectTag()
const = 0;
00381
virtual PString
GetEndpointIdentifier()
const = 0;
00382
virtual unsigned GetRegisteredEndPointRejectTag()
const = 0;
00383
virtual unsigned GetSecurityRejectTag()
const = 0;
00384
00385 H323GatekeeperListener &
GetRasChannel()
const {
return rasChannel; }
00386
00387 PSafePtr<H323RegisteredEndPoint>
endpoint;
00388
00389
protected:
00390 H323GatekeeperListener & rasChannel;
00391 };
00392
00393
00394 class H323GatekeeperGRQ :
public H323GatekeeperRequest
00395 {
00396 PCLASSINFO(
H323GatekeeperGRQ,
H323GatekeeperRequest);
00397
public:
00398
H323GatekeeperGRQ(
00399
H323GatekeeperListener & listener,
00400
const H323RasPDU & pdu
00401 );
00402
00403
#if PTRACING
00404
virtual const char * GetName()
const;
00405
#endif
00406
virtual PString
GetGatekeeperIdentifier()
const;
00407
virtual unsigned GetGatekeeperRejectTag()
const;
00408
virtual PString
GetEndpointIdentifier()
const;
00409
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00410
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00411
virtual unsigned GetSecurityRejectTag()
const;
00412
virtual void SetRejectReason(
00413
unsigned reasonCode
00414 );
00415
00416 H225_GatekeeperRequest &
grq;
00417 H225_GatekeeperConfirm &
gcf;
00418 H225_GatekeeperReject &
grj;
00419
00420
protected:
00421
virtual Response
OnHandlePDU();
00422 };
00423
00424
00425 class H323GatekeeperRRQ :
public H323GatekeeperRequest
00426 {
00427 PCLASSINFO(
H323GatekeeperRRQ,
H323GatekeeperRequest);
00428
public:
00429
H323GatekeeperRRQ(
00430
H323GatekeeperListener & listener,
00431
const H323RasPDU & pdu
00432 );
00433
00434
#if PTRACING
00435
virtual const char * GetName()
const;
00436
#endif
00437
virtual PString
GetGatekeeperIdentifier()
const;
00438
virtual unsigned GetGatekeeperRejectTag()
const;
00439
virtual PString
GetEndpointIdentifier()
const;
00440
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00441
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00442
virtual unsigned GetSecurityRejectTag()
const;
00443
virtual void SetRejectReason(
00444
unsigned reasonCode
00445 );
00446
00447 H225_RegistrationRequest &
rrq;
00448 H225_RegistrationConfirm &
rcf;
00449 H225_RegistrationReject &
rrj;
00450
00451
protected:
00452
virtual Response
OnHandlePDU();
00453 };
00454
00455
00456 class H323GatekeeperURQ :
public H323GatekeeperRequest
00457 {
00458 PCLASSINFO(
H323GatekeeperURQ,
H323GatekeeperRequest);
00459
public:
00460
H323GatekeeperURQ(
00461
H323GatekeeperListener & listener,
00462
const H323RasPDU & pdu
00463 );
00464
00465
#if PTRACING
00466
virtual const char * GetName()
const;
00467
#endif
00468
virtual PString
GetGatekeeperIdentifier()
const;
00469
virtual unsigned GetGatekeeperRejectTag()
const;
00470
virtual PString
GetEndpointIdentifier()
const;
00471
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00472
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00473
virtual unsigned GetSecurityRejectTag()
const;
00474
virtual void SetRejectReason(
00475
unsigned reasonCode
00476 );
00477
00478 H225_UnregistrationRequest &
urq;
00479 H225_UnregistrationConfirm &
ucf;
00480 H225_UnregistrationReject &
urj;
00481
00482
protected:
00483
virtual Response
OnHandlePDU();
00484 };
00485
00486
00487 class H323GatekeeperARQ :
public H323GatekeeperRequest
00488 {
00489 PCLASSINFO(
H323GatekeeperARQ,
H323GatekeeperRequest);
00490
public:
00491
H323GatekeeperARQ(
00492
H323GatekeeperListener & listener,
00493
const H323RasPDU & pdu
00494 );
00495
00496
#if PTRACING
00497
virtual const char * GetName()
const;
00498
#endif
00499
virtual PString
GetGatekeeperIdentifier()
const;
00500
virtual unsigned GetGatekeeperRejectTag()
const;
00501
virtual PString
GetEndpointIdentifier()
const;
00502
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00503
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00504
virtual unsigned GetSecurityRejectTag()
const;
00505
virtual void SetRejectReason(
00506
unsigned reasonCode
00507 );
00508
00509 H225_AdmissionRequest &
arq;
00510 H225_AdmissionConfirm &
acf;
00511 H225_AdmissionReject &
arj;
00512
00513 PString
alternateSecurityID;
00514
00515
protected:
00516
virtual Response
OnHandlePDU();
00517 };
00518
00519
00520 class H323GatekeeperDRQ :
public H323GatekeeperRequest
00521 {
00522 PCLASSINFO(
H323GatekeeperDRQ,
H323GatekeeperRequest);
00523
public:
00524
H323GatekeeperDRQ(
00525
H323GatekeeperListener & listener,
00526
const H323RasPDU & pdu
00527 );
00528
00529
#if PTRACING
00530
virtual const char * GetName()
const;
00531
#endif
00532
virtual PString
GetGatekeeperIdentifier()
const;
00533
virtual unsigned GetGatekeeperRejectTag()
const;
00534
virtual PString
GetEndpointIdentifier()
const;
00535
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00536
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00537
virtual unsigned GetSecurityRejectTag()
const;
00538
virtual void SetRejectReason(
00539
unsigned reasonCode
00540 );
00541
00542 H225_DisengageRequest &
drq;
00543 H225_DisengageConfirm &
dcf;
00544 H225_DisengageReject &
drj;
00545
00546
protected:
00547
virtual Response
OnHandlePDU();
00548 };
00549
00550
00551 class H323GatekeeperBRQ :
public H323GatekeeperRequest
00552 {
00553 PCLASSINFO(
H323GatekeeperBRQ,
H323GatekeeperRequest);
00554
public:
00555
H323GatekeeperBRQ(
00556
H323GatekeeperListener & listener,
00557
const H323RasPDU & pdu
00558 );
00559
00560
#if PTRACING
00561
virtual const char * GetName()
const;
00562
#endif
00563
virtual PString
GetGatekeeperIdentifier()
const;
00564
virtual unsigned GetGatekeeperRejectTag()
const;
00565
virtual PString
GetEndpointIdentifier()
const;
00566
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00567
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00568
virtual unsigned GetSecurityRejectTag()
const;
00569
virtual void SetRejectReason(
00570
unsigned reasonCode
00571 );
00572
00573 H225_BandwidthRequest &
brq;
00574 H225_BandwidthConfirm &
bcf;
00575 H225_BandwidthReject &
brj;
00576
00577
protected:
00578
virtual Response
OnHandlePDU();
00579 };
00580
00581
00582 class H323GatekeeperLRQ :
public H323GatekeeperRequest
00583 {
00584 PCLASSINFO(
H323GatekeeperLRQ,
H323GatekeeperRequest);
00585
public:
00586
H323GatekeeperLRQ(
00587
H323GatekeeperListener & listener,
00588
const H323RasPDU & pdu
00589 );
00590
00591
#if PTRACING
00592
virtual const char * GetName()
const;
00593
#endif
00594
virtual PString
GetGatekeeperIdentifier()
const;
00595
virtual unsigned GetGatekeeperRejectTag()
const;
00596
virtual PString
GetEndpointIdentifier()
const;
00597
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00598
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00599
virtual unsigned GetSecurityRejectTag()
const;
00600
virtual void SetRejectReason(
00601
unsigned reasonCode
00602 );
00603
00604 H225_LocationRequest &
lrq;
00605 H225_LocationConfirm &
lcf;
00606 H225_LocationReject &
lrj;
00607
00608
protected:
00609
virtual Response
OnHandlePDU();
00610 };
00611
00612
00613 class H323GatekeeperIRR :
public H323GatekeeperRequest
00614 {
00615 PCLASSINFO(
H323GatekeeperIRR,
H323GatekeeperRequest);
00616
public:
00617
H323GatekeeperIRR(
00618
H323GatekeeperListener & listener,
00619
const H323RasPDU & pdu
00620 );
00621
00622
#if PTRACING
00623
virtual const char * GetName()
const;
00624
#endif
00625
virtual PString
GetGatekeeperIdentifier()
const;
00626
virtual unsigned GetGatekeeperRejectTag()
const;
00627
virtual PString
GetEndpointIdentifier()
const;
00628
virtual unsigned GetRegisteredEndPointRejectTag()
const;
00629
virtual H235Authenticator::ValidationResult
ValidatePDU()
const;
00630
virtual unsigned GetSecurityRejectTag()
const;
00631
virtual void SetRejectReason(
00632
unsigned reasonCode
00633 );
00634
00635 H225_InfoRequestResponse &
irr;
00636 H225_InfoRequestAck &
iack;
00637 H225_InfoRequestNak &
inak;
00638
00639
protected:
00640
virtual Response
OnHandlePDU();
00641 };
00642
00643
00646 class H323GatekeeperCall :
public PSafeObject
00647 {
00648 PCLASSINFO(
H323GatekeeperCall, PSafeObject);
00649
public:
00652 enum Direction {
00653
AnsweringCall,
00654
OriginatingCall,
00655
UnknownDirection
00656 };
00657
00660
H323GatekeeperCall(
00661
H323GatekeeperServer & server,
00662
const OpalGloballyUniqueID & callIdentifier,
00663 Direction direction
00664 );
00665
00668
~H323GatekeeperCall();
00670
00675 Comparison Compare(
00676
const PObject & obj
00677 )
const;
00678
00681
void PrintOn(
00682 ostream & strm
00683 )
const;
00685
00693
virtual H323GatekeeperRequest::Response OnAdmission(
00694
H323GatekeeperARQ & request
00695 );
00696
00700
virtual BOOL Disengage(
00701
int reason = -1
00702 );
00703
00707
virtual H323GatekeeperRequest::Response OnDisengage(
00708
H323GatekeeperDRQ & request
00709 );
00710
00715
virtual H323GatekeeperRequest::Response OnBandwidth(
00716
H323GatekeeperBRQ & request
00717 );
00718
00722
virtual H323GatekeeperRequest::Response OnInfoResponse(
00723
H323GatekeeperIRR & request,
00724
H225_InfoRequestResponse_perCallInfo_subtype & call
00725 );
00726
00729
virtual void OnAlerting();
00730
00733
virtual void OnConnected();
00734
00745
virtual BOOL
OnHeartbeat();
00746
00753
virtual PString
GetCallCreditAmount() const;
00754
00761 virtual BOOL GetCallCreditMode() const;
00762
00770 virtual
unsigned GetDurationLimit() const;
00771
00776 virtual BOOL SendCallCreditServiceControl();
00777
00780 BOOL AddCallCreditServiceControl(
00781
H225_ArrayOf_ServiceControlSession & serviceControl
00782 ) const;
00783
00788 virtual BOOL SendServiceControlSession(
00789 const
H323ServiceControlSession & session
00790 );
00791
00797 virtual BOOL TranslateAliasAddress(
00798 const
H225_AliasAddress & alias,
00799
H225_ArrayOf_AliasAddress & aliases,
00800
H323TransportAddress & address
00801 );
00802
00804
00807 H323GatekeeperServer & GetGatekeeper()
const {
return gatekeeper; }
00808 H323RegisteredEndPoint &
GetEndPoint()
const {
return *PAssertNULL(
endpoint); }
00809 BOOL
IsAnsweringCall()
const {
return direction ==
AnsweringCall; }
00810 unsigned GetCallReference()
const {
return callReference; }
00811 const OpalGloballyUniqueID &
GetCallIdentifier()
const {
return callIdentifier; }
00812 const OpalGloballyUniqueID &
GetConferenceIdentifier()
const {
return conferenceIdentifier; }
00813 const PString &
GetSourceNumber()
const {
return srcNumber; }
00814 const PStringArray &
GetSourceAliases()
const {
return srcAliases; }
00815 const H323TransportAddress &
GetSourceHost()
const {
return srcHost; }
00816 PString
GetSourceAddress() const;
00817 const PString & GetDestinationNumber()
const {
return dstNumber; }
00818 const PStringArray &
GetDestinationAliases()
const {
return dstAliases; }
00819 const H323TransportAddress &
GetDestinationHost()
const {
return dstHost; }
00820 PString
GetDestinationAddress() const;
00821 unsigned GetBandwidthUsed()
const {
return bandwidthUsed; }
00822 BOOL SetBandwidthUsed(
unsigned bandwidth);
00823 const PTime &
GetLastInfoResponseTime()
const {
return lastInfoResponse; }
00824 const PTime &
GetCallStartTime()
const {
return callStartTime; }
00825 const PTime &
GetAlertingTime()
const {
return alertingTime; }
00826 const PTime &
GetConnectedTime()
const {
return connectedTime; }
00827 const PTime &
GetCallEndTime()
const {
return callEndTime; }
00828 H323Connection::CallEndReason
GetCallEndReason()
const {
return callEndReason; }
00830
00831
protected:
00832
void SetUsageInfo(
const H225_RasUsageInformation & usage);
00833
00834 H323GatekeeperServer &
gatekeeper;
00835 H323RegisteredEndPoint *
endpoint;
00836 H323GatekeeperListener *
rasChannel;
00837
00838 Direction direction;
00839 unsigned callReference;
00840 OpalGloballyUniqueID callIdentifier;
00841 OpalGloballyUniqueID conferenceIdentifier;
00842 PString
srcNumber;
00843 PStringArray
srcAliases;
00844 H323TransportAddress srcHost;
00845 PString
dstNumber;
00846 PStringArray
dstAliases;
00847 H323TransportAddress dstHost;
00848 unsigned bandwidthUsed;
00849 unsigned infoResponseRate;
00850 PTime
lastInfoResponse;
00851
00852 BOOL
drqReceived;
00853 PTime
callStartTime;
00854 PTime
alertingTime;
00855 PTime
connectedTime;
00856 PTime
callEndTime;
00857 H323Connection::CallEndReason
callEndReason;
00858 };
00859
00860
00866 class H323RegisteredEndPoint :
public PSafeObject
00867 {
00868 PCLASSINFO(
H323RegisteredEndPoint, PSafeObject);
00869
public:
00874
H323RegisteredEndPoint(
00875
H323GatekeeperServer & server,
00876
const PString &
id
00877 );
00879
00884 Comparison
Compare(
00885
const PObject & obj
00886 )
const;
00887
00890
void PrintOn(
00891 ostream & strm
00892 )
const;
00894
00901
virtual void AddCall(
00902
H323GatekeeperCall * call
00903 );
00904
00909
virtual BOOL
RemoveCall(
00910
H323GatekeeperCall * call
00911 );
00912
00915 PINDEX
GetCallCount()
const {
return activeCalls.GetSize(); }
00916
00919 H323GatekeeperCall &
GetCall(
00920 PINDEX idx
00921 ) {
return activeCalls[idx]; }
00923
00932
virtual H323GatekeeperRequest::Response OnRegistration(
00933
H323GatekeeperRRQ & request
00934 );
00935
00945
virtual H323GatekeeperRequest::Response OnFullRegistration(
00946
H323GatekeeperRRQ & request
00947 );
00948
00957
virtual H323GatekeeperRequest::Response OnSecureRegistration(
00958
H323GatekeeperRRQ & request
00959 );
00960
00964
virtual H323GatekeeperRequest::Response OnUnregistration(
00965
H323GatekeeperURQ & request
00966 );
00967
00971
virtual BOOL Unregister(
00972
int reason = -1
00973 );
00974
00979
virtual H323GatekeeperRequest::Response OnInfoResponse(
00980
H323GatekeeperIRR & request
00981 );
00982
00993
virtual BOOL
OnTimeToLive();
00994
01006
virtual PString
GetCallCreditAmount() const;
01007
01015 virtual BOOL GetCallCreditMode() const;
01016
01021 virtual BOOL SendServiceControlSession(
01022 const
H323ServiceControlSession & session
01023 );
01024
01028 virtual BOOL AddServiceControlSession(
01029 const
H323ServiceControlSession & session,
01030
H225_ArrayOf_ServiceControlSession & serviceControl
01031 );
01033
01038 virtual BOOL SetPassword(
01039 const PString & password,
01040 const PString & username = PString::Empty()
01041 );
01042
01045 const PString & GetIdentifier()
const {
return identifier; }
01046
01049 const OpalGloballyUniqueID &
GetDescriptorID()
const {
return descriptorID; }
01050
01053 H323GatekeeperServer &
GetGatekeeper()
const {
return gatekeeper; }
01054
01058 const H323TransportAddressArray &
GetRASAddresses()
const {
return rasAddresses; }
01059
01063 PINDEX
GetRASAddressCount()
const {
return rasAddresses.GetSize(); }
01064
01068 H323TransportAddress GetRASAddress(
01069 PINDEX idx
01070 )
const {
return rasAddresses[idx]; }
01071
01075 const H323TransportAddressArray &
GetSignalAddresses()
const {
return signalAddresses; }
01076
01080 PINDEX
GetSignalAddressCount()
const {
return signalAddresses.GetSize(); }
01081
01085 H323TransportAddress GetSignalAddress(
01086 PINDEX idx
01087 )
const {
return signalAddresses[idx]; }
01088
01091 const PStringArray &
GetAliases()
const {
return aliases; }
01092
01095 BOOL
ContainsAlias(
01096
const PString & alias
01097 ) {
return aliases.GetStringsIndex(alias) != P_MAX_INDEX; }
01098
01101 PINDEX
GetAliasCount()
const {
return aliases.GetSize(); }
01102
01105 PString
GetAlias(
01106 PINDEX idx
01107 )
const {
if (idx <
aliases.GetSize())
return aliases[idx];
return PString::Empty(); }
01108
01114
void RemoveAlias(
01115
const PString & alias
01116 );
01117
01120 virtual const H235Authenticators &
GetAuthenticators()
const {
return authenticators; }
01121
01124 PINDEX
GetPrefixCount()
const {
return voicePrefixes.GetSize(); }
01125
01128 PString
GetPrefix(
01129 PINDEX idx
01130 )
const {
return voicePrefixes[idx]; }
01131
01134 const PCaselessString &
GetApplicationInfo()
const {
return applicationInfo; }
01135
01138 unsigned GetProtocolVersion()
const {
return protocolVersion; }
01139
01142 BOOL
IsBehindNAT()
const {
return isBehindNAT; }
01143
01146 BOOL
CanDisplayAmountString()
const {
return canDisplayAmountString; }
01147
01150 BOOL
CanEnforceDurationLimit()
const {
return canEnforceDurationLimit; }
01151
01154 BOOL
CanReceiveRIP() const;
01155
01158 BOOL GetH225Version()
const {
return h225Version; }
01160
01170
virtual BOOL OnSendDescriptorForEndpoint(
01171
H225_ArrayOf_AliasAddress & aliases,
01172
H225_EndpointType & terminalType,
01173
H225_ArrayOf_AliasAddress & transportAddresses
01174 );
01176
01177
01178
protected:
01179 H323GatekeeperServer &
gatekeeper;
01180 H323GatekeeperListener *
rasChannel;
01181
01182 PString
identifier;
01183 OpalGloballyUniqueID descriptorID;
01184 H323TransportAddressArray
rasAddresses;
01185 H323TransportAddressArray
signalAddresses;
01186 PStringArray
aliases;
01187 PStringArray
voicePrefixes;
01188 PCaselessString
applicationInfo;
01189 unsigned protocolVersion;
01190 BOOL
isBehindNAT;
01191 BOOL
canDisplayAmountString;
01192 BOOL
canEnforceDurationLimit;
01193 unsigned h225Version;
01194 unsigned timeToLive;
01195 H235Authenticators
authenticators;
01196
01197 PTime
lastRegistration;
01198 PTime
lastInfoResponse;
01199
01200 PSortedList<H323GatekeeperCall>
activeCalls;
01201 POrdinalDictionary<PString>
serviceControlSessions;
01202 };
01203
01204
01210 class H323GatekeeperListener :
public H225_RAS
01211 {
01212 PCLASSINFO(
H323GatekeeperListener,
H225_RAS);
01213
public:
01218
H323GatekeeperListener(
01219
H323EndPoint & endpoint,
01220
H323GatekeeperServer & server,
01221
const PString & gatekeeperIdentifier,
01222
H323Transport * transport = NULL
01223 );
01224
01227
~H323GatekeeperListener();
01229
01234 BOOL
UnregistrationRequest(
01235
const H323RegisteredEndPoint & ep,
01236
unsigned reason
01237 );
01238
01241 BOOL
DisengageRequest(
01242
const H323GatekeeperCall & call,
01243
unsigned reason
01244 );
01245
01248
virtual BOOL
InfoRequest(
01249
H323RegisteredEndPoint & ep,
01250
H323GatekeeperCall * call = NULL
01251 );
01252
01255
virtual BOOL
ServiceControlIndication(
01256
H323RegisteredEndPoint & ep,
01257
const H323ServiceControlSession & session,
01258
H323GatekeeperCall * call = NULL
01259 );
01261
01268
virtual H323GatekeeperRequest::Response
OnDiscovery(
01269
H323GatekeeperGRQ & request
01270 );
01271
01276
virtual H323GatekeeperRequest::Response
OnRegistration(
01277
H323GatekeeperRRQ & request
01278 );
01279
01284
virtual H323GatekeeperRequest::Response
OnUnregistration(
01285
H323GatekeeperURQ & request
01286 );
01287
01292
virtual H323GatekeeperRequest::Response
OnAdmission(
01293
H323GatekeeperARQ & request
01294 );
01295
01300
virtual H323GatekeeperRequest::Response
OnDisengage(
01301
H323GatekeeperDRQ & request
01302 );
01303
01308
virtual H323GatekeeperRequest::Response
OnBandwidth(
01309
H323GatekeeperBRQ & request
01310 );
01311
01316
virtual H323GatekeeperRequest::Response
OnLocation(
01317
H323GatekeeperLRQ & request
01318 );
01319
01324
virtual H323GatekeeperRequest::Response
OnInfoResponse(
01325
H323GatekeeperIRR & request
01326 );
01328
01331
virtual BOOL
OnReceiveGatekeeperRequest(
const H323RasPDU &,
const H225_GatekeeperRequest &);
01332
virtual BOOL
OnReceiveRegistrationRequest(
const H323RasPDU &,
const H225_RegistrationRequest &);
01333
virtual BOOL
OnReceiveUnregistrationRequest(
const H323RasPDU &,
const H225_UnregistrationRequest &);
01334
virtual BOOL
OnReceiveUnregistrationConfirm(
const H225_UnregistrationConfirm &);
01335
virtual BOOL
OnReceiveUnregistrationReject(
const H225_UnregistrationReject &);
01336
virtual BOOL
OnReceiveAdmissionRequest(
const H323RasPDU &,
const H225_AdmissionRequest &);
01337
virtual BOOL
OnReceiveBandwidthRequest(
const H323RasPDU &,
const H225_BandwidthRequest &);
01338
virtual BOOL
OnReceiveBandwidthConfirm(
const H225_BandwidthConfirm &);
01339
virtual BOOL
OnReceiveBandwidthReject(
const H225_BandwidthReject &);
01340
virtual BOOL
OnReceiveDisengageRequest(
const H323RasPDU &,
const H225_DisengageRequest &);
01341
virtual BOOL
OnReceiveDisengageConfirm(
const H225_DisengageConfirm &);
01342
virtual BOOL
OnReceiveDisengageReject(
const H225_DisengageReject &);
01343
virtual BOOL
OnReceiveLocationRequest(
const H323RasPDU &,
const H225_LocationRequest &);
01344
virtual BOOL
OnReceiveInfoRequestResponse(
const H323RasPDU &,
const H225_InfoRequestResponse &);
01345
virtual BOOL
OnReceiveResourcesAvailableConfirm(
const H225_ResourcesAvailableConfirm &);
01347
01350 H323GatekeeperServer &
GetGatekeeper()
const {
return gatekeeper; }
01352
01353
01354
protected:
01355 H323GatekeeperServer &
gatekeeper;
01356 };
01357
01358
01369 class H323GatekeeperServer :
public H323TransactionServer
01370 {
01371 PCLASSINFO(
H323GatekeeperServer,
H323TransactionServer);
01372
public:
01377
H323GatekeeperServer(
01378
H323EndPoint & endpoint
01379 );
01380
01383
~H323GatekeeperServer();
01385
01386 WORD
GetDefaultUdpPort() {
return H225_RAS::DefaultRasUdpPort; }
01387
01398
virtual H323Transactor * CreateListener(
01399
H323Transport * transport
01400 );
01401
01403
01409
virtual H323GatekeeperRequest::Response OnDiscovery(
01410
H323GatekeeperGRQ & request
01411 );
01412
01420
virtual H323GatekeeperRequest::Response OnRegistration(
01421
H323GatekeeperRRQ & request
01422 );
01423
01429
virtual H323GatekeeperRequest::Response OnUnregistration(
01430
H323GatekeeperURQ & request
01431 );
01432
01437
virtual H323GatekeeperRequest::Response OnInfoResponse(
01438
H323GatekeeperIRR & request
01439 );
01440
01451
virtual void AddEndPoint(
01452
H323RegisteredEndPoint * ep
01453 );
01454
01457
virtual BOOL RemoveEndPoint(
01458
H323RegisteredEndPoint * ep
01459 );
01460
01469
virtual H323RegisteredEndPoint * CreateRegisteredEndPoint(
01470
H323GatekeeperRRQ & request
01471 );
01472
01481
virtual PString
CreateEndPointIdentifier();
01482
01485
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByIdentifier(
01486
const PString & identifier,
01487 PSafetyMode mode = PSafeReference
01488 );
01489
01492
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddresses(
01493
const H225_ArrayOf_TransportAddress & addresses,
01494 PSafetyMode mode = PSafeReference
01495 );
01496
01499
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointBySignalAddress(
01500
const H323TransportAddress & address,
01501 PSafetyMode mode = PSafeReference
01502 );
01503
01506
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasAddress(
01507
const H225_AliasAddress & alias,
01508 PSafetyMode mode = PSafeReadWrite
01509 );
01510
01513
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByAliasString(
01514
const PString & alias,
01515 PSafetyMode mode = PSafeReference
01516 );
01517
01520
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPartialAlias(
01521
const PString & alias,
01522 PSafetyMode mode = PSafeReference
01523 );
01524
01527
virtual PSafePtr<H323RegisteredEndPoint> FindEndPointByPrefixString(
01528
const PString & prefix,
01529 PSafetyMode mode = PSafeReference
01530 );
01531
01534 PSafePtr<H323RegisteredEndPoint>
GetFirstEndPoint(
01535 PSafetyMode mode = PSafeReference
01536 ) {
return PSafePtr<H323RegisteredEndPoint>(
byIdentifier, mode); }
01538
01539 PSafePtr<H323RegisteredEndPoint> FindDestinationEndPoint(
01540
const OpalGloballyUniqueID &
id,
01541 H323GatekeeperCall::Direction direction
01542 );
01543
01551
virtual H323GatekeeperRequest::Response OnAdmission(
01552
H323GatekeeperARQ & request
01553 );
01554
01559
virtual H323GatekeeperRequest::Response OnDisengage(
01560
H323GatekeeperDRQ & request
01561 );
01562
01567
virtual H323GatekeeperRequest::Response OnBandwidth(
01568
H323GatekeeperBRQ & request
01569 );
01570
01579
virtual H323GatekeeperCall * CreateCall(
01580
const OpalGloballyUniqueID & callIdentifier,
01581 H323GatekeeperCall::Direction direction
01582 );
01583
01586 virtual void AddCall(
H323GatekeeperCall *)
01587 { }
01588
01591
virtual void RemoveCall(
01592
H323GatekeeperCall * call
01593 );
01594
01597
virtual PSafePtr<H323GatekeeperCall> FindCall(
01598
const PString & description,
01599 PSafetyMode mode = PSafeReference
01600 );
01601
01604
virtual PSafePtr<H323GatekeeperCall> FindCall(
01605
const OpalGloballyUniqueID & callIdentifier,
01606 BOOL answeringCall,
01607 PSafetyMode mode = PSafeReference
01608 );
01609
01612
virtual PSafePtr<H323GatekeeperCall> FindCall(
01613
const OpalGloballyUniqueID & callIdentifier,
01614 H323GatekeeperCall::Direction direction,
01615 PSafetyMode mode = PSafeReference
01616 );
01617
01620 PSafePtr<H323GatekeeperCall>
GetFirstCall(
01621 PSafetyMode mode = PSafeReference
01622 ) {
return PSafePtr<H323GatekeeperCall>(
activeCalls, mode); }
01623
01624
01626
01636
virtual H323GatekeeperRequest::Response OnLocation(
01637
H323GatekeeperLRQ & request
01638 );
01639
01650
virtual BOOL TranslateAliasAddress(
01651
const H225_AliasAddress & alias,
01652
H225_ArrayOf_AliasAddress & aliases,
01653
H323TransportAddress & address
01654 );
01655
01675
virtual BOOL TranslateAliasAddressToSignalAddress(
01676
const H225_AliasAddress & alias,
01677
H323TransportAddress & address
01678 );
01680
01692
virtual BOOL CheckSignalAddressPolicy(
01693
const H323RegisteredEndPoint & ep,
01694
const H225_AdmissionRequest & arq,
01695
const H323TransportAddress & address
01696 );
01697
01710
virtual BOOL CheckAliasAddressPolicy(
01711
const H323RegisteredEndPoint & ep,
01712
const H225_AdmissionRequest & arq,
01713
const H225_AliasAddress & alias
01714 );
01715
01728
virtual BOOL CheckAliasStringPolicy(
01729
const H323RegisteredEndPoint & ep,
01730
const H225_AdmissionRequest & arq,
01731
const PString & alias
01732 );
01733
01739
virtual unsigned AllocateBandwidth(
01740
unsigned newBandwidth,
01741
unsigned oldBandwidth = 0
01742 );
01744
01756
virtual BOOL GetAdmissionRequestAuthentication(
01757
H323GatekeeperARQ & info,
01758 H235Authenticators & authenticators
01759 );
01760
01766
virtual BOOL GetUsersPassword(
01767
const PString & alias,
01768 PString & password,
01769
H323RegisteredEndPoint & registeredEndpoint
01770 )
const;
01771
virtual BOOL GetUsersPassword(
01772
const PString & alias,
01773 PString & password
01774 )
const;
01776
01781 H323PeerElement *
GetPeerElement()
const {
return peerElement; }
01782
01786
void SetPeerElement(
01787
H323PeerElement * newPeerElement
01788 );
01789
01795
void CreatePeerElement(
01796
const H323TransportAddress & h501Interface
01797 );
01798
01804 BOOL OpenPeerElement(
01805
const H323TransportAddress & remotePeer,
01806 BOOL append = FALSE,
01807 BOOL keepTrying = TRUE
01808 );
01810
01815 const PString &
GetGatekeeperIdentifier()
const {
return gatekeeperIdentifier; }
01816
01822
void SetGatekeeperIdentifier(
01823
const PString &
id,
01824 BOOL adjustListeners = TRUE
01825 );
01826
01829 unsigned GetAvailableBandwidth()
const {
return totalBandwidth; }
01830
01833 void SetAvailableBandwidth(
unsigned bps100) {
totalBandwidth = bps100; }
01834
01837 unsigned GetUsedBandwidth()
const {
return usedBandwidth; }
01838
01841 unsigned GetDefaultBandwidth()
const {
return defaultBandwidth; }
01842
01845 unsigned GetTimeToLive()
const {
return defaultTimeToLive; }
01846
01849 void SetTimeToLive(
unsigned seconds) {
defaultTimeToLive = seconds; }
01850
01853 unsigned GetInfoResponseRate()
const {
return defaultInfoResponseRate; }
01854
01857 void SetInfoResponseRate(
unsigned seconds) {
defaultInfoResponseRate = seconds; }
01858
01861 BOOL
IsGatekeeperRouted()
const {
return isGatekeeperRouted; }
01862
01865 BOOL
IsRequiredH235()
const {
return requireH235; }
01866
01869 unsigned GetActiveRegistrations()
const {
return byIdentifier.GetSize(); }
01870
01873 unsigned GetPeakRegistrations()
const {
return peakRegistrations; }
01874
01877 unsigned GetTotalRegistrations()
const {
return totalRegistrations; }
01878
01881 unsigned GetRejectedRegistrations()
const {
return rejectedRegistrations; }
01882
01885 unsigned GetActiveCalls()
const {
return activeCalls.GetSize(); }
01886
01889 unsigned GetPeakCalls()
const {
return peakCalls; }
01890
01893 unsigned GetTotalCalls()
const {
return totalCalls; }
01894
01897 unsigned GetRejectedCalls()
const {
return rejectedCalls; }
01899
01900
01901
void RemoveAlias(
01902
H323RegisteredEndPoint & ep,
01903
const PString & alias
01904 );
01905
01906
01907 virtual BOOL
OnSendDescriptorForEndpoint(
01908
H323RegisteredEndPoint & ,
01909
H225_ArrayOf_AliasAddress & ,
01910
H225_EndpointType & ,
01911
H225_ArrayOf_AliasAddress &
01912 )
01913 {
return TRUE; }
01914
01915 virtual BOOL
AllowDuplicateAlias(
const H225_ArrayOf_AliasAddress & )
01916 {
return canHaveDuplicateAlias; }
01917
01918
protected:
01919
01920 PDECLARE_NOTIFIER(PThread,
H323GatekeeperServer, MonitorMain);
01921
01922
01923 PString
gatekeeperIdentifier;
01924 unsigned totalBandwidth;
01925 unsigned usedBandwidth;
01926 unsigned defaultBandwidth;
01927 unsigned maximumBandwidth;
01928 unsigned defaultTimeToLive;
01929 unsigned defaultInfoResponseRate;
01930 BOOL
overwriteOnSameSignalAddress;
01931 BOOL
canHaveDuplicateAlias;
01932 BOOL
canHaveDuplicatePrefix;
01933 BOOL
canOnlyCallRegisteredEP;
01934 BOOL
canOnlyAnswerRegisteredEP;
01935 BOOL
answerCallPreGrantedARQ;
01936 BOOL
makeCallPreGrantedARQ;
01937 BOOL
isGatekeeperRouted;
01938 BOOL
aliasCanBeHostName;
01939 BOOL
requireH235;
01940 BOOL
disengageOnHearbeatFail;
01941
01942 PStringToString
passwords;
01943
01944
01945 PMutex
mutex;
01946 time_t
identifierBase;
01947 unsigned nextIdentifier;
01948 PThread *
monitorThread;
01949 PSyncPoint
monitorExit;
01950
01951
PLIST(ListenerList,
H323GatekeeperListener);
01952 ListenerList
listeners;
01953
01954 H323PeerElement *
peerElement;
01955
01956 PSafeDictionary<PString, H323RegisteredEndPoint>
byIdentifier;
01957
01958 class StringMap :
public PString {
01959 PCLASSINFO(
StringMap, PString);
01960
public:
01961 StringMap(
const PString & from,
const PString &
id)
01962 : PString(from),
identifier(id) { }
01963 PString
identifier;
01964 };
01965 PSortedStringList
byAddress;
01966 PSortedStringList
byAlias;
01967 PSortedStringList
byVoicePrefix;
01968
01969 PSafeSortedList<H323GatekeeperCall>
activeCalls;
01970
01971 PINDEX
peakRegistrations;
01972 PINDEX
totalRegistrations;
01973 PINDEX
rejectedRegistrations;
01974 PINDEX
peakCalls;
01975 PINDEX
totalCalls;
01976 PINDEX
rejectedCalls;
01977
01978
friend class H323GatekeeperRRQ;
01979
friend class H323GatekeeperARQ;
01980 };
01981
01982
01983
#endif // __OPAL_GKSERVER_H
01984
01985
01987