OPAL  Version 3.14.3
h323ep.h
Go to the documentation of this file.
1 /*
2  * h323ep.h
3  *
4  * H.323 protocol handler
5  *
6  * Open H323 Library
7  *
8  * Copyright (c) 1998-2001 Equivalence Pty. Ltd.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open H323 Library.
21  *
22  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23  *
24  * Portions of this code were written with the assisance of funding from
25  * Vovida Networks, Inc. http://www.vovida.com.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 31774 $
30  * $Author: rjongbloed $
31  * $Date: 2014-04-16 11:58:42 +1000 (Wed, 16 Apr 2014) $
32  */
33 
34 #ifndef OPAL_H323_H323EP_H
35 #define OPAL_H323_H323EP_H
36 
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40 
41 #include <opal_config.h>
42 
43 #if OPAL_H323
44 
45 #include <rtp/rtpep.h>
46 #include <opal/manager.h>
47 #include <opal/call.h>
48 #include <opal/transports.h>
49 #include <h323/h323con.h>
50 #include <h323/h323caps.h>
51 #include <h323/h235auth.h>
52 #include <h323/gkclient.h>
53 #include <asn/h225.h>
54 #include <h460/h4601.h>
55 
56 
57 class H225_EndpointType;
58 class H225_VendorIdentifier;
59 class H225_H221NonStandard;
60 class H225_ServiceControlDescriptor;
61 class H225_FeatureSet;
62 
63 class H235SecurityInfo;
64 
65 class H323Gatekeeper;
66 class H323SignalPDU;
68 
69 class H46019Server;
70 
71 
73 
87 {
88  PCLASSINFO(H323EndPoint, OpalRTPEndPoint);
89 
90  public:
91  enum {
93  };
94 
101  );
102 
105  ~H323EndPoint();
107 
114  virtual void ShutDown();
115 
120  virtual PBoolean GarbageCollection();
121 
151  virtual PSafePtr<OpalConnection> MakeConnection(
152  OpalCall & call,
153  const PString & party,
154  void * userData = NULL,
155  unsigned int options = 0,
156  OpalConnection::StringOptions * stringOptions = NULL
157  );
158 
177  virtual void OnReleased(
178  OpalConnection & connection
179  );
180 
183  virtual PStringList GetAvailableStringOptions() const;
185 
190  virtual void SetEndpointTypeInfo(
191  H225_EndpointType & info
192  ) const;
193 
196  virtual void SetVendorIdentifierInfo(
197  H225_VendorIdentifier & info
198  ) const;
199 
202  virtual void SetH221NonStandardInfo(
203  H225_H221NonStandard & info
204  ) const;
205 
208  virtual bool SetGatewaySupportedProtocol(
209  H225_ArrayOf_SupportedProtocols & protocols
210  ) const;
211 
215  virtual bool OnSetGatewayPrefixes(
216  PStringList & prefixes
217  ) const;
219 
220 
243  bool UseGatekeeper(
244  const PString & address = PString::Empty(),
245  const PString & identifier = PString::Empty(),
246  const PString & localAddress = PString::Empty()
247  );
248 
259  bool SetGatekeeper(
260  const PString & address,
261  const PString & localAddress = PString::Empty()
262  );
263 
278  bool SetGatekeeperZone(
279  const PString & address,
280  const PString & identifier,
281  const PString & localAddress = PString::Empty()
282  );
283 
293  bool LocateGatekeeper(
294  const PString & identifier,
295  const PString & localAddress = PString::Empty()
296  );
297 
306  bool DiscoverGatekeeper(
307  const PString & localAddress = PString::Empty()
308  );
309 
318  H323Transport * transport
319  );
320 
323  H323Gatekeeper * GetGatekeeper() const { return m_gatekeepers.IsEmpty() ? NULL : &m_gatekeepers.front(); }
324 
327  const PList<H323Gatekeeper> GetGatekeepers() const { return m_gatekeepers; }
328 
331  PBoolean IsRegisteredWithGatekeeper() const;
332 
338  PBoolean RemoveGatekeeper(
339  int reason = -1
340  );
341 
344  virtual void SetGatekeeperPassword(
345  const PString & password,
346  const PString & username = PString::Empty()
347  );
348 
351  virtual const PString & GetGatekeeperUsername() const { return m_gatekeeperUsername; }
352 
355  virtual const PString & GetGatekeeperPassword() const { return m_gatekeeperPassword; }
356 
357  enum { MaxGatekeeperAliasLimit = 1000000 };
361  PINDEX limit
362  );
363 
367 
372 
376 
379  virtual H235Authenticators CreateAuthenticators();
380 
383  virtual void OnGatekeeperStatus(
385  );
387 
392  virtual void NewIncomingConnection(
393  OpalListener & listener,
394  const OpalTransportPtr & transport
395  );
396 
398  OpalTransportPtr transport,
399  bool reused = false
400  );
401 
405  OpalCall & call,
406  const PString & token,
407  void * userData,
408  OpalTransport & transport,
409  const PString & alias,
410  const H323TransportAddress & address,
411  H323SignalPDU * setupPDU,
412  unsigned options = 0,
413  OpalConnection::StringOptions * stringOptions = NULL
414  );
415 
431  virtual PBoolean SetupTransfer(
432  const PString & token,
433  const PString & callIdentity,
434  const PString & remoteParty,
435  void * userData = NULL
436  );
437 
443  void TransferCall(
444  const PString & token,
445  const PString & remoteParty,
446  const PString & callIdentity = PString::Empty()
448  );
449 
457  const PString & primaryCallToken,
458  const PString & secondaryCallToken
459  );
460 
464  PBoolean IntrudeCall(
465  const PString & remoteParty,
466  unsigned capabilityLevel,
467  void * userData = NULL
468  );
469 
476  PBoolean ParsePartyName(
477  const PString & party,
478  PString & alias,
479  H323TransportAddress & address,
480  OpalConnection::StringOptions * stringOptions = NULL
481  );
482 
493  PSafePtr<H323Connection> FindConnectionWithLock(
494  const PString & token,
495  PSafetyMode mode = PSafeReadWrite
496  );
497 
505  virtual PBoolean OnSendSignalSetup(H323Connection & connection,
506  H323SignalPDU & setupPDU);
507 
519  virtual PBoolean OnSendCallProceeding(
520  H323Connection & connection,
521  H323SignalPDU & callProceedingPDU
522  );
523 
535  virtual PBoolean OnSendConnect(
536  H323Connection & connection,
537  H323SignalPDU & connectPDU
538  );
539 
551  virtual PBoolean OnIncomingCall(
552  H323Connection & connection,
553  const H323SignalPDU & setupPDU,
554  H323SignalPDU & alertingPDU
555  );
556 
563  virtual PBoolean OnOutgoingCall(
564  H323Connection & conn,
565  const H323SignalPDU & connectPDU
566  );
567 
572  virtual PBoolean OnCallTransferInitiate(
573  H323Connection & connection,
574  const PString & remoteParty
575  );
576 
581  virtual PBoolean OnCallTransferIdentify(
582  H323Connection & connection
583  );
584 
589  virtual void OnSendARQ(
590  H323Connection & conn,
591  H225_AdmissionRequest & arq
592  );
593 
600  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
601  H323Connection & connection,
602  const PString & callerName,
603  const H323SignalPDU & setupPDU,
604  H323SignalPDU & connectPDU,
605  H323SignalPDU & progressPDU
606  );
607  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
608  OpalConnection & connection,
609  const PString & caller
610  );
611 
622  virtual PBoolean OnAlerting(
623  H323Connection & connection,
624  const H323SignalPDU & alertingPDU,
625  const PString & user
626  );
627 
632  virtual PBoolean OnSendAlerting(
633  H323Connection & connection,
634  H323SignalPDU & alerting,
635  const PString & calleeName,
636  PBoolean withMedia
637  );
638 
642  virtual PBoolean OnSentAlerting(
643  H323Connection & connection
644  );
645 
654  virtual PBoolean OnConnectionForwarded(
655  H323Connection & connection,
656  const PString & forwardParty,
657  const H323SignalPDU & pdu
658  );
659 
668  virtual PBoolean ForwardConnection(
669  H323Connection & connection,
670  const PString & forwardParty,
671  const H323SignalPDU & pdu
672  );
673 
680  virtual void OnConnectionEstablished(
681  H323Connection & connection,
682  const PString & token
683  );
684 
687  virtual PBoolean IsConnectionEstablished(
688  const PString & token
689  );
691 
692 
699  virtual PBoolean OnStartLogicalChannel(
700  H323Connection & connection,
701  H323Channel & channel
702  );
703 
708  virtual void OnClosedLogicalChannel(
709  H323Connection & connection,
710  const H323Channel & channel
711  );
712 
718  virtual void OnGatekeeperNATDetect(
719  const PIPSocket::Address & publicAddr,
720  H323TransportAddress & gkRouteAddress
721  );
723 
733  virtual void OnHTTPServiceControl(
734  unsigned operation,
735  unsigned sessionId,
736  const PString & url
737  );
738 
748  virtual void OnCallCreditServiceControl(
749  const PString & amount,
750  PBoolean mode
751  );
752 
756  virtual void OnServiceControlSession(
757  unsigned type,
758  unsigned sessionid,
759  const H323ServiceControlSession & session,
760  H323Connection * connection
761  );
762 
766  const H225_ServiceControlDescriptor & contents
767  );
769 
777  virtual PBoolean OnCallIndependentSupplementaryService(
778  const H323SignalPDU & setupPDU
779  );
780 
786  virtual PBoolean OnNegotiateConferenceCapabilities(
787  const H323SignalPDU & setupPDU
788  );
790 
795  virtual void SetDefaultLocalPartyName(
796  const PString & name
797  );
798 
807  virtual void SetLocalUserName(
808  const PString & name
809  );
810 
815  virtual const PString & GetLocalUserName() const { return localAliasNames.front(); }
816 
824  bool AddAliasNames(
825  const PStringList & names
826  );
827 
834  bool AddAliasName(
835  const PString & name
836  );
837 
841  bool RemoveAliasName(
842  const PString & name
843  );
844 
849  const PStringList & GetAliasNames() const { return localAliasNames; }
850 
854  bool AddAliasNamePattern(
855  const PString & pattern
856  );
857 
861  const PString & pattern
862  );
863 
868  const PStringList & patterns
869  ) { localAliasPatterns = patterns; }
870 
873  const PStringList & GetAliasNamePatterns() const { return localAliasPatterns; }
874 
875  static int ParseAliasPatternRange(const PString & pattern, PString & start, PString & end);
876 
879  const PString & GetDefaultILSServer() const { return manager.GetDefaultILSServer(); }
880 
884  const PString & server
885  ) { manager.SetDefaultILSServer(server); }
886 
889  PBoolean IsFastStartDisabled() const
890  { return disableFastStart; }
891 
895  PBoolean mode
896  ) { disableFastStart = mode; }
897 
900  PBoolean IsH245TunnelingDisabled() const
901  { return disableH245Tunneling; }
902 
906  PBoolean mode
907  ) { disableH245Tunneling = mode; }
908 
911  PBoolean IsH245inSetupDisabled() const
912  { return disableH245inSetup; }
913 
917  PBoolean mode
918  ) { disableH245inSetup = mode; }
919 
922  bool IsForcedSymmetricTCS() const
923  { return m_forceSymmetricTCS; }
924 
928  bool mode
929  ) { m_forceSymmetricTCS = mode; }
930 
934  PBoolean IsH245Disabled() const
935  { return m_bH245Disabled; }
936 
940  void DisableH245(PBoolean bH245Disabled) { m_bH245Disabled = bH245Disabled; }
941 
944  PBoolean CanDisplayAmountString() const
945  { return canDisplayAmountString; }
946 
950  PBoolean mode
951  ) { canDisplayAmountString = mode; }
952 
955  PBoolean CanEnforceDurationLimit() const
956  { return canEnforceDurationLimit; }
957 
961  PBoolean mode
962  ) { canEnforceDurationLimit = mode; }
963 
964 #if OPAL_H450
965 
968 
972  unsigned level
973  ) { PAssert(level<=3, PInvalidParameter); callIntrusionProtectionLevel = level; }
974 #endif
975 
978  virtual void OnReceivedInitiateReturnError();
979 
982  PBoolean CanAutoCallForward() const { return autoCallForward; }
983 
988  const H323Capabilities & GetCapabilities() const { return m_capabilities; }
989 
1004  e_MCUOnly = 160,
1008  };
1009 
1013 
1017 
1020  PBoolean IsTerminal() const;
1021 
1024  PBoolean IsGateway() const;
1025 
1028  PBoolean IsGatekeeper() const;
1029 
1032  PBoolean IsMCU() const;
1033 
1038 
1043 
1047  unsigned minDelay,
1048  unsigned maxDelay
1049  ) { manager.SetAudioJitterDelay(minDelay, maxDelay); }
1050 
1051 #if OPAL_H239
1052 
1055 
1059  bool on
1060  ) { m_defaultH239Control = on; }
1061 #endif
1062 
1063 #if OPAL_H460
1064 
1066  bool H460Disabled() const { return m_disableH460; }
1067 
1070  void DisableH460(bool disable = true) { m_disableH460 = disable; }
1071 
1073 
1078  H323Connection * connection
1079  );
1081  H323Connection * connection
1082  );
1083 
1086  virtual PBoolean OnSendFeatureSet(H460_MessageType pduType, H225_FeatureSet &);
1087 
1090  virtual void OnReceiveFeatureSet(H460_MessageType pduType, const H225_FeatureSet &);
1091 
1096  virtual bool OnLoadFeature(
1097  H460_Feature & feature
1098  );
1099 
1100 #endif // OPAL_H460
1101 
1102 #if OPAL_H460_NAT
1103  H46019Server * GetH46019Server() const { return m_H46019Server; }
1104 #endif
1105 
1108  virtual PBoolean IsLocalAddress(
1109  const PIPSocket::Address & remoteAddress
1110  ) const { return manager.IsLocalAddress(remoteAddress); }
1111 
1114  virtual void TranslateTCPAddress(
1115  PIPSocket::Address & localAddr,
1116  const PIPSocket::Address & remoteAddr
1117  );
1118 
1121  const PTimeInterval & GetSignallingChannelCallTimeout() const { return signallingChannelCallTimeout; }
1122 
1125  const PTimeInterval & GetFirstSignalPduTimeout() const { return firstSignalPduTimeout; }
1126 
1129  const PTimeInterval & GetEndSessionTimeout() const { return endSessionTimeout; }
1130 
1134 
1138 
1141  const PTimeInterval & GetCapabilityExchangeTimeout() const { return capabilityExchangeTimeout; }
1142 
1145  const PTimeInterval & GetLogicalChannelTimeout() const { return logicalChannelTimeout; }
1146 
1149  const PTimeInterval & GetRequestModeTimeout() const { return logicalChannelTimeout; }
1150 
1153  const PTimeInterval & GetRoundTripDelayTimeout() const { return roundTripDelayTimeout; }
1154 
1157  const PTimeInterval & GetRoundTripDelayRate() const { return roundTripDelayRate; }
1158 
1162 
1165  const PTimeInterval & GetNoMediaTimeout() const { return manager.GetNoMediaTimeout(); }
1166 
1170  const PTimeInterval & newInterval
1171  ) { manager.SetNoMediaTimeout(newInterval); }
1172 
1175  const PTimeInterval & GetGatekeeperRequestTimeout() const { return gatekeeperRequestTimeout; }
1176 
1180 
1183  const PTimeInterval & GetRasRequestTimeout() const { return rasRequestTimeout; }
1184 
1187  unsigned GetRasRequestRetries() const { return rasRequestRetries; }
1188 
1192  const PTimeInterval & GetGatekeeperTimeToLive() const { return registrationTimeToLive; }
1193 
1197  void SetGatekeeperTimeToLive(const PTimeInterval & ttl) { registrationTimeToLive = ttl; }
1198 
1201  const PString & GetGkAccessTokenOID() const { return gkAccessTokenOID; }
1202 
1205  void SetGkAccessTokenOID(const PString & token) { gkAccessTokenOID = token; }
1206 
1209  bool GetSendGRQ() const { return m_sendGRQ; }
1210 
1213  void SetSendGRQ(bool v) { m_sendGRQ = v; }
1214 
1218 
1222 
1225  const PTimeInterval & GetCallTransferT1() const { return callTransferT1; }
1226 
1229  const PTimeInterval & GetCallTransferT2() const { return callTransferT2; }
1230 
1233  const PTimeInterval & GetCallTransferT3() const { return callTransferT3; }
1234 
1237  const PTimeInterval & GetCallTransferT4() const { return callTransferT4; }
1238 
1240  const PTimeInterval & GetCallIntrusionT1() const { return callIntrusionT1; }
1241  const PTimeInterval & GetCallIntrusionT2() const { return callIntrusionT2; }
1242  const PTimeInterval & GetCallIntrusionT3() const { return callIntrusionT3; }
1243  const PTimeInterval & GetCallIntrusionT4() const { return callIntrusionT4; }
1244  const PTimeInterval & GetCallIntrusionT5() const { return callIntrusionT5; }
1245  const PTimeInterval & GetCallIntrusionT6() const { return callIntrusionT6; }
1246 
1247 #if OPAL_H450
1248 
1250  H323CallIdentityDict& GetCallIdentityDictionary() { return m_secondaryConnectionsActive; }
1251 
1255 #endif //OPAL_H450
1256 
1260  virtual PString GetDefaultTransport() const;
1261 
1264  virtual WORD GetDefaultSignalPort() const;
1265 
1267  PString GetCompatibility(
1268  H323Connection::CompatibilityIssues issue
1269  ) const;
1270 
1276  bool SetCompatibility(
1277  H323Connection::CompatibilityIssues issue,
1278  const PString & regex
1279  );
1280 
1288  bool AddCompatibility(
1289  H323Connection::CompatibilityIssues issue,
1290  const PString & regex
1291  );
1292 
1294  bool HasCompatibilityIssue(
1295  H323Connection::CompatibilityIssues issue,
1296  const OpalProductInfo & productInfo
1297  ) const;
1299 
1301 
1302  protected:
1304  const H323TransportAddress & remoteAddress,
1305  const PString & localAddress
1306  );
1307  void RestartGatekeeper();
1308  void GatekeeperMonitor();
1309 
1311  OpalCall & call,
1312  const PString & existingToken,
1313  const PString & callIdentity,
1314  unsigned capabilityLevel,
1315  const PString & remoteParty,
1316  void * userData,
1317  unsigned int options = 0,
1318  OpalConnection::StringOptions * stringOptions = NULL
1319  );
1320 
1321  // Configuration variables, commonly changed
1322  PStringList localAliasNames;
1323  PStringList localAliasPatterns;
1329  PBoolean m_bH245Disabled; /* enabled or disabled h245 */
1332 #if OPAL_H450
1334 #endif
1335 
1337 
1338 #if OPAL_H239
1340 #endif
1341 
1343 
1344  // Some more configuration variables, rarely changed.
1346  PTimeInterval firstSignalPduTimeout;
1347  PTimeInterval endSessionTimeout;
1351  PTimeInterval logicalChannelTimeout;
1352  PTimeInterval requestModeTimeout;
1353  PTimeInterval roundTripDelayTimeout;
1354  PTimeInterval roundTripDelayRate;
1357  PTimeInterval rasRequestTimeout;
1359  PTimeInterval registrationTimeToLive;
1360 
1364 
1365  /* Protect against absence of a response to the ctIdentify reqest
1366  (Transferring Endpoint - Call Transfer with a secondary Call) */
1367  PTimeInterval callTransferT1;
1368  /* Protect against failure of completion of the call transfer operation
1369  involving a secondary Call (Transferred-to Endpoint) */
1370  PTimeInterval callTransferT2;
1371  /* Protect against failure of the Transferred Endpoint not responding
1372  within sufficient time to the ctInitiate APDU (Transferring Endpoint) */
1373  PTimeInterval callTransferT3;
1374  /* May optionally operate - protects against absence of a response to the
1375  ctSetup request (Transferred Endpoint) */
1376  PTimeInterval callTransferT4;
1377 
1379  PTimeInterval callIntrusionT1;
1380  PTimeInterval callIntrusionT2;
1381  PTimeInterval callIntrusionT3;
1382  PTimeInterval callIntrusionT4;
1383  PTimeInterval callIntrusionT5;
1384  PTimeInterval callIntrusionT6;
1385 
1386  // Dynamic variables
1387  PSafeDictionary<PString, H323Connection> m_connectionsByCallId;
1388  std::set<OpalTransportPtr> m_reusableTransports;
1389 
1391 
1392  PList<H323Gatekeeper> m_gatekeepers;
1401 
1402 #if OPAL_H450
1403  H323CallIdentityDict m_secondaryConnectionsActive;
1404  mutable PAtomicInteger m_nextH450CallIdentity;
1406 #endif
1407 
1408 #if OPAL_H460
1411 #endif
1412 #if OPAL_H460_NAT
1413  H46019Server * m_H46019Server;
1414 #endif
1415 
1416  typedef map<H323Connection::CompatibilityIssues, PRegularExpression> CompatibilityEndpoints;
1418 
1419  private:
1420  P_REMOVE_VIRTUAL_VOID(OnConnectionCleared(H323Connection &, const PString &));
1421  P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const H323Connection &, const OpalRTPSession &) const);
1422  P_REMOVE_VIRTUAL(PBoolean, OnConferenceInvite(const H323SignalPDU &), false);
1423  P_REMOVE_VIRTUAL_VOID(OnGatekeeperConfirm());
1424  P_REMOVE_VIRTUAL_VOID(OnGatekeeperReject());
1425  P_REMOVE_VIRTUAL_VOID(OnRegistrationConfirm());
1426  P_REMOVE_VIRTUAL_VOID(OnRegistrationReject());
1427  P_REMOVE_VIRTUAL_VOID(OnGatekeeperNATDetect(PIPSocket::Address, PString &, H323TransportAddress &));
1428 };
1429 
1430 #endif // OPAL_H323
1431 
1432 #endif // OPAL_H323_H323EP_H
1433 
1434