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 #ifndef __OSP_H
00084 #define __OSP_H
00085
00086 #ifdef P_USE_PRAGMA
00087 #pragma interface
00088 #endif
00089
00090 #include "openh323buildopts.h"
00091 #include <guid.h>
00092 #include <ptclib/pssl.h>
00093
00094 #include "transports.h"
00095 #include "h225.h"
00096
00097 class H225_AliasAddress;
00098 class H323SignalPDU;
00099 class H225_Setup_UUIE;
00100 class H225_AdmissionRequest;
00101 class H323Connection;
00102
00103 #ifdef H323_TRANSNEXUS_OSP
00104
00109
00110 #include <osp/osp.h>
00111
00112 namespace OpalOSP {
00113
00114 #define DECLARE_GET_SET(var, suffix, type) \
00115 public: \
00116 void Set##suffix(type v) { var = v; } \
00117 type Get##suffix() const { return var; } \
00118 protected: \
00119 type var; \
00120
00122 //
00123
00124
00125
00129 void Initialise(BOOL uninitialise = FALSE);
00130
00133 PString AddressToOSPString(
00134 const PString & taddr
00135 );
00136 H323TransportAddress OSPStringToAddress(
00137 const PString & str, WORD defaultPort
00138 );
00139 PString TransportAddressToOSPString(
00140 const H323TransportAddress & taddr
00141 );
00142 inline PString TransportAddressToOSPString(
00143 const H225_TransportAddress & taddr
00144 )
00145 { return TransportAddressToOSPString(H323TransportAddress(taddr)); }
00146
00149 BOOL ConvertAliasToOSPString(
00150 const H225_AliasAddress & alias,
00151 int & format,
00152 PString & str
00153 );
00154
00155 inline PString IpAddressToOSPString(
00156 const PIPSocket::Address & addr
00157 )
00158 {
00159 return psprintf("[%d.%d.%d.%d]", addr.Byte1(), addr.Byte2(), addr.Byte3(), addr.Byte4());
00160 }
00161
00162 inline PString IpAddressPortToOSPString(
00163 const PIPSocket::Address & addr,
00164 WORD port
00165 )
00166 {
00167 return psprintf("[%d.%d.%d.%d]:%d", addr.Byte1(), addr.Byte2(), addr.Byte3(), addr.Byte4(), port);
00168 }
00169
00171
00176 class Provider : public PObject
00177 {
00178 PCLASSINFO(Provider, PObject);
00179 public:
00180 enum {
00181 IllegalHandle = -1
00182 };
00183
00186 Provider();
00187
00191 ~Provider();
00192
00199 inline int Open(
00200 const PString & servicePoint
00201 )
00202 { return Open(servicePoint, PDirectory()); }
00203 int Open(
00204 const PString & servicePoint,
00205 const PDirectory & certDir
00206 );
00209 int Open(
00210 const PString & servicePoint,
00211 const PFilePath & localPrivateKeyName,
00212 const PFilePath & localPublicCertName,
00213 const PFilePath & localAuthCertName
00214 );
00215
00218 int Open(
00219 const PString & servicePoint,
00220 PSSLPrivateKey & localPrivateKey,
00221 PSSLCertificate & localPublicCert,
00222 PSSLCertificate & localAuthCert
00223 );
00224
00227 int Close();
00228
00232 inline operator ::OSPTPROVHANDLE ()
00233 { return handle; }
00234
00237 inline BOOL IsOpen() const
00238 { return handle != IllegalHandle; }
00239
00240 inline PIPSocket::Address GetHostAddress() const
00241 { return hostAddress; }
00242
00247 DECLARE_GET_SET(deleteTimeout, DeleteTimeout, int);
00248 DECLARE_GET_SET(maxSimultConn, MaxSimultConn, int);
00249 DECLARE_GET_SET(httpPersist, HttpPersist, int);
00250 DECLARE_GET_SET(httpRetryDelay, HttpRetryDelay, int);
00251 DECLARE_GET_SET(httpRetry, HttpRetry, int);
00252 DECLARE_GET_SET(httpTimeout, HttpTimeout, int);
00253 DECLARE_GET_SET(sslLifeTime, SSLLifetime, int);
00254 DECLARE_GET_SET(deviceID, DeviceID, PString);
00255 DECLARE_GET_SET(customerID, CustomerID, PString);
00256 DECLARE_GET_SET(messageCount, MessageCount, int);
00257
00258 protected:
00259 ::OSPTPROVHANDLE handle;
00260 PIPSocket::Address hostAddress;
00261 };
00262
00264
00269 class Transaction : public PObject
00270 {
00271 PCLASSINFO(Transaction, PObject);
00272 public:
00273 enum {
00274 IllegalHandle = -1
00275 };
00276
00279 Transaction();
00280
00284 ~Transaction();
00285
00288 int Open(Provider & _provider)
00289 { return Open(_provider, ""); }
00290
00291 int Open(
00292 Provider & _provider,
00293 const PString & user
00294 );
00295
00299 struct AuthorisationInfo {
00300
00303 BOOL Extract(
00304 const H323SignalPDU & setupPDU
00305 );
00306
00309 BOOL Extract(
00310 const H225_AdmissionRequest & arqPDU
00311 );
00312
00313 PString ospvSource;
00314 PString ospvSourceDevice;
00315 H225_AliasAddress callingNumber;
00316 H225_AliasAddress calledNumber;
00317 PBYTEArray callID;
00318 };
00321 int Authorise(
00322 AuthorisationInfo & info,
00323 unsigned & numberOfDestinations
00324 );
00325 int Authorise(
00326 const PString & ospvSource,
00327 const PString & ospvSourceDevice,
00328 const H225_AliasAddress & callingNumber,
00329 const H225_AliasAddress & calledNumber,
00330 const PBYTEArray & callID,
00331 unsigned & numberOfDestinations
00332 );
00333 int Authorise(
00334 const PString & ospvSource,
00335 const PString & ospvSourceDevice,
00336 const PString & ospvCallingNumber,
00337 int ospvCallingNumberFormat,
00338 const PString & ospvCalledNumber,
00339 int ospvCalledNumberFormat,
00340 const PBYTEArray & callID,
00341 unsigned & numberOfDestinations
00342 );
00343
00346 struct DestinationInfo {
00347
00350 BOOL Insert(
00351 H323SignalPDU & setupPDU,
00352 BOOL useCiscoBug = FALSE
00353 );
00354 BOOL Insert(
00355 H225_Setup_UUIE & setupPDU,
00356 BOOL useCiscoBug = FALSE
00357 );
00358
00361 BOOL Insert(
00362 H225_AdmissionConfirm & acf,
00363 BOOL useCiscoBug = FALSE
00364 );
00365
00366 void InsertToken(H225_ArrayOf_ClearToken & clearTokens, BOOL useCiscoBug = FALSE);
00367
00368 unsigned timeLimit;
00369 PBYTEArray callID;
00370 H225_AliasAddress calledNumber;
00371 BOOL hasCallingNumber;
00372 H225_AliasAddress callingNumber;
00373 H323TransportAddress destinationAddress;
00374 PString destination;
00375 PBYTEArray token;
00376 };
00377
00380 int GetFirstDestination(
00381 DestinationInfo & info
00382 );
00383 inline int GetFirstDestination(
00384 unsigned & timeLimit,
00385 PBYTEArray & callID,
00386 PString & calledNumber,
00387 PString & destination,
00388 PString & device,
00389 PBYTEArray & token
00390 )
00391 { PString callingNumber; return GetFirstDestination(timeLimit, callID, calledNumber, callingNumber, destination, device, token); }
00392 int GetFirstDestination(
00393 unsigned & timeLimit,
00394 PBYTEArray & callID,
00395 PString & calledNumber,
00396 PString & callingNumber,
00397 PString & destination,
00398 PString & device,
00399 PBYTEArray & token
00400 );
00401
00404 int GetNextDestination(
00405 int endReason,
00406 DestinationInfo & info
00407 );
00408 inline int GetNextDestination(
00409 int endReason,
00410 unsigned & timeLimit,
00411 PBYTEArray & callID,
00412 PString & calledNumber,
00413 PString & destination,
00414 PString & device,
00415 PBYTEArray & token
00416 )
00417 { PString callingNumber; return GetNextDestination(endReason, timeLimit, callID, calledNumber, callingNumber, destination, device, token); }
00418 int GetNextDestination(
00419 int endReason,
00420 unsigned & timeLimit,
00421 PBYTEArray & callID,
00422 PString & calledNumber,
00423 PString & callingNumber,
00424 PString & destination,
00425 PString & device,
00426 PBYTEArray & token
00427 );
00428
00431 void CallStatistics(
00432 unsigned lostSentPackets,
00433 signed lostFractionSent,
00434 unsigned lostReceivedPackets,
00435 signed lostFractionReceived,
00436 const PTime & firstRTPTime
00437 );
00438
00441 void CallEnd(
00442 H323Connection & conn
00443 );
00444
00448 void ReportUsage(
00449 H323Connection & conn
00450 );
00451
00454 struct ValidationInfo {
00455
00456 ValidationInfo()
00457 { tokenAlgo = TOKEN_ALGO_SIGNED; }
00458
00461 BOOL Extract(
00462 const H323SignalPDU & setupPDU
00463 );
00464
00467 BOOL Extract(
00468 const H225_AdmissionRequest & arqPDU
00469 );
00470
00471 BOOL ExtractToken(
00472 const H225_ArrayOf_ClearToken & clearTokens
00473 );
00474
00475 PString ospvSource;
00476 PString ospvDest;
00477 PString ospvSourceDevice;
00478 PString ospvDestDevice;
00479 H225_AliasAddress callingNumber;
00480 H225_AliasAddress calledNumber;
00481 PBYTEArray callID;
00482 PBYTEArray token;
00483 unsigned tokenAlgo;
00484 };
00485 int Validate(
00486 const ValidationInfo & info,
00487 BOOL & authorised,
00488 unsigned & timeLimit
00489 );
00490
00491 int Validate(
00492 const PString & ospvSource,
00493 const PString & ospvDest,
00494 const PString & ospvSourceDevice,
00495 const PString & ospvDestDevice,
00496 const H225_AliasAddress & callingNumber,
00497 const H225_AliasAddress & calledNumber,
00498 const PBYTEArray & callID,
00499 const PBYTEArray & token,
00500 BOOL & authorised,
00501 unsigned & timeLimit
00502 )
00503 { return Validate(ospvSource, ospvDest, ospvSourceDevice, ospvDestDevice,
00504 callingNumber, calledNumber,
00505 callID, token, TOKEN_ALGO_SIGNED, authorised, timeLimit);
00506 }
00507
00508
00509 int Validate(
00510 const PString & ospvSource,
00511 const PString & ospvDest,
00512 const PString & ospvSourceDevice,
00513 const PString & ospvDestDevice,
00514 int ospvCallingNumberFormat,
00515 const PString & ospvCallingNumber,
00516 int ospvCalledNumberFormat,
00517 const PString & ospvCalledNumber,
00518 const PBYTEArray & callID,
00519 const PBYTEArray & token,
00520 BOOL & authorised,
00521 unsigned & timeLimit
00522 )
00523 { return Validate(ospvSource, ospvDest, ospvSourceDevice, ospvDestDevice,
00524 ospvCallingNumberFormat, ospvCallingNumber,
00525 ospvCalledNumberFormat, ospvCalledNumber,
00526 callID, token, TOKEN_ALGO_SIGNED, authorised, timeLimit);
00527 }
00528
00529 int Validate(
00530 const PString & ospvSource,
00531 const PString & ospvDest,
00532 const PString & ospvSourceDevice,
00533 const PString & ospvDestDevice,
00534 const H225_AliasAddress & callingNumber,
00535 const H225_AliasAddress & calledNumber,
00536 const PBYTEArray & callID,
00537 const PBYTEArray & token,
00538 unsigned int tokenAlgo,
00539 BOOL & authorised,
00540 unsigned & timeLimit
00541 );
00542 int Validate(
00543 const PString & ospvSource,
00544 const PString & ospvDest,
00545 const PString & ospvSourceDevice,
00546 const PString & ospvDestDevice,
00547 int ospvCallingNumberFormat,
00548 const PString & ospvCallingNumber,
00549 int ospvCalledNumberFormat,
00550 const PString & ospvCalledNumber,
00551 const PBYTEArray & callID,
00552 const PBYTEArray & token,
00553 unsigned int tokenAlgo,
00554 BOOL & authorised,
00555 unsigned & timeLimit
00556 );
00557
00560 int Close();
00561
00564 inline BOOL IsOpen() const
00565 { return handle != IllegalHandle; }
00566
00567 BOOL CheckOpenedAndNotEnded(const char * str);
00568
00569 inline operator ::OSPTTRANHANDLE ()
00570 { return handle; }
00571
00572 Provider * GetProvider() const
00573 { return provider; }
00574
00575 protected:
00576 Provider * provider;
00577 PString user;
00578 ::OSPTTRANHANDLE handle;
00579
00580 BOOL ended;
00581
00582 unsigned lostSentPackets;
00583 unsigned lostReceivedPackets;
00584 signed lostFractionSent;
00585 signed lostFractionReceived;
00586 PTime firstRTPTime;
00587 };
00588
00589 }
00590
00591 #endif // H323_TRANSNEXUS_OSP
00592
00593 #endif