OPAL  Version 3.12.9
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: 30767 $
30  * $Author: rjongbloed $
31  * $Date: 2013-10-21 13:14:17 +1100 (Mon, 21 Oct 2013) $
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/buildopts.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 
55 #if OPAL_H460
56 #include <h460/h4601.h>
57 #endif
58 
59 
60 class H225_EndpointType;
61 class H225_VendorIdentifier;
62 class H225_H221NonStandard;
63 class H225_ServiceControlDescriptor;
64 class H225_FeatureSet;
65 
66 class H235SecurityInfo;
67 
68 class H323Gatekeeper;
69 class H323SignalPDU;
71 
73 
87 {
88  PCLASSINFO(H323EndPoint, OpalRTPEndPoint);
89 
90  public:
91  enum {
93  };
94 
101  );
102 
105  ~H323EndPoint();
107 
114  virtual void ShutDown();
115 
145  virtual PSafePtr<OpalConnection> MakeConnection(
146  OpalCall & call,
147  const PString & party,
148  void * userData = NULL,
149  unsigned int options = 0,
150  OpalConnection::StringOptions * stringOptions = NULL
151  );
153 
158  virtual void SetEndpointTypeInfo(
159  H225_EndpointType & info
160  ) const;
161 
164  virtual void SetVendorIdentifierInfo(
165  H225_VendorIdentifier & info
166  ) const;
167 
170  virtual void SetH221NonStandardInfo(
171  H225_H221NonStandard & info
172  ) const;
173 
176  virtual bool SetGatewaySupportedProtocol(
177  H225_ArrayOf_SupportedProtocols & protocols
178  ) const;
179 
183  virtual bool OnSetGatewayPrefixes(
184  PStringList & prefixes
185  ) const;
187 
188 
199  void AddCapability(
200  H323Capability * capability
201  );
202 
223  PINDEX SetCapability(
224  PINDEX descriptorNum,
225  PINDEX simultaneous,
226  H323Capability * cap
227  );
228 
233  PINDEX AddAllCapabilities(
234  PINDEX descriptorNum,
235  PINDEX simultaneous,
236  const PString & name
237  );
238 
242  PINDEX descriptorNum,
243  PINDEX simultaneous
244  );
245 
248  void RemoveCapabilities(
249  const PStringArray & codecNames
250  );
251 
254  void ReorderCapabilities(
255  const PStringArray & preferenceOrder
256  );
257 
261  const H245_Capability & cap
262  ) const;
263 
267  const H245_DataType & dataType
268  ) const;
269 
273  H323Capability::MainTypes mainType,
274  unsigned subType
275  ) const;
277 
300  PBoolean UseGatekeeper(
301  const PString & address = PString::Empty(),
302  const PString & identifier = PString::Empty(),
303  const PString & localAddress = PString::Empty()
304  );
305 
316  PBoolean SetGatekeeper(
317  const PString & address,
318  H323Transport * transport = NULL
319  );
320 
335  PBoolean SetGatekeeperZone(
336  const PString & address,
337  const PString & identifier,
338  H323Transport * transport = NULL
339  );
340 
350  PBoolean LocateGatekeeper(
351  const PString & identifier,
352  H323Transport * transport = NULL
353  );
354 
363  PBoolean DiscoverGatekeeper(
364  H323Transport * transport = NULL
365  );
366 
375  H323Transport * transport
376  );
377 
381 
384  PBoolean IsRegisteredWithGatekeeper() const;
385 
391  PBoolean RemoveGatekeeper(
392  int reason = -1
393  );
394 
397  virtual void SetGatekeeperPassword(
398  const PString & password,
399  const PString & username = PString::Empty()
400  );
401 
404  virtual const PString & GetGatekeeperUsername() const { return gatekeeperUsername; }
405 
408  virtual const PString & GetGatekeeperPassword() const { return gatekeeperPassword; }
409 
412  virtual H235Authenticators CreateAuthenticators();
413 
416  virtual void OnGatekeeperStatus(
418  );
420 
425  virtual void NewIncomingConnection(
426  OpalListener & listener,
427  const OpalTransportPtr & transport
428  );
429 
433  OpalCall & call,
434  const PString & token,
435  void * userData,
436  OpalTransport & transport,
437  const PString & alias,
438  const H323TransportAddress & address,
439  H323SignalPDU * setupPDU,
440  unsigned options = 0,
441  OpalConnection::StringOptions * stringOptions = NULL
442  );
443 
459  virtual PBoolean SetupTransfer(
460  const PString & token,
461  const PString & callIdentity,
462  const PString & remoteParty,
463  void * userData = NULL
464  );
465 
471  void TransferCall(
472  const PString & token,
473  const PString & remoteParty,
474  const PString & callIdentity = PString::Empty()
476  );
477 
485  const PString & primaryCallToken,
486  const PString & secondaryCallToken
487  );
488 
492  PBoolean IntrudeCall(
493  const PString & remoteParty,
494  unsigned capabilityLevel,
495  void * userData = NULL
496  );
497 
504  PBoolean ParsePartyName(
505  const PString & party,
506  PString & alias,
507  H323TransportAddress & address,
508  OpalConnection::StringOptions * stringOptions = NULL
509  );
510 
521  PSafePtr<H323Connection> FindConnectionWithLock(
522  const PString & token,
523  PSafetyMode mode = PSafeReadWrite
524  );
525 
533  virtual PBoolean OnSendSignalSetup(H323Connection & connection,
534  H323SignalPDU & setupPDU);
535 
547  virtual PBoolean OnSendCallProceeding(
548  H323Connection & connection,
549  H323SignalPDU & callProceedingPDU
550  );
551 
563  virtual PBoolean OnSendConnect(
564  H323Connection & connection,
565  H323SignalPDU & connectPDU
566  );
567 
579  virtual PBoolean OnIncomingCall(
580  H323Connection & connection,
581  const H323SignalPDU & setupPDU,
582  H323SignalPDU & alertingPDU
583  );
584 
591  virtual PBoolean OnOutgoingCall(
592  H323Connection & conn,
593  const H323SignalPDU & connectPDU
594  );
595 
600  virtual PBoolean OnCallTransferInitiate(
601  H323Connection & connection,
602  const PString & remoteParty
603  );
604 
609  virtual PBoolean OnCallTransferIdentify(
610  H323Connection & connection
611  );
612 
617  virtual void OnSendARQ(
618  H323Connection & conn,
619  H225_AdmissionRequest & arq
620  );
621 
628  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
629  H323Connection & connection,
630  const PString & callerName,
631  const H323SignalPDU & setupPDU,
632  H323SignalPDU & connectPDU,
633  H323SignalPDU & progressPDU
634  );
635  virtual OpalConnection::AnswerCallResponse OnAnswerCall(
636  OpalConnection & connection,
637  const PString & caller
638  );
639 
650  virtual PBoolean OnAlerting(
651  H323Connection & connection,
652  const H323SignalPDU & alertingPDU,
653  const PString & user
654  );
655 
660  virtual PBoolean OnSendAlerting(
661  H323Connection & connection,
662  H323SignalPDU & alerting,
663  const PString & calleeName,
664  PBoolean withMedia
665  );
666 
670  virtual PBoolean OnSentAlerting(
671  H323Connection & connection
672  );
673 
682  virtual PBoolean OnConnectionForwarded(
683  H323Connection & connection,
684  const PString & forwardParty,
685  const H323SignalPDU & pdu
686  );
687 
696  virtual PBoolean ForwardConnection(
697  H323Connection & connection,
698  const PString & forwardParty,
699  const H323SignalPDU & pdu
700  );
701 
708  virtual void OnConnectionEstablished(
709  H323Connection & connection,
710  const PString & token
711  );
712 
715  virtual PBoolean IsConnectionEstablished(
716  const PString & token
717  );
719 
720 
727  virtual PBoolean OnStartLogicalChannel(
728  H323Connection & connection,
729  H323Channel & channel
730  );
731 
736  virtual void OnClosedLogicalChannel(
737  H323Connection & connection,
738  const H323Channel & channel
739  );
740 
746  virtual void OnGatekeeperNATDetect(
747  PIPSocket::Address publicAddr,
748  PString & gkIdentifier,
749  H323TransportAddress & gkRouteAddress
750  );
752 
762  virtual void OnHTTPServiceControl(
763  unsigned operation,
764  unsigned sessionId,
765  const PString & url
766  );
767 
777  virtual void OnCallCreditServiceControl(
778  const PString & amount,
779  PBoolean mode
780  );
781 
785  virtual void OnServiceControlSession(
786  unsigned type,
787  unsigned sessionid,
788  const H323ServiceControlSession & session,
789  H323Connection * connection
790  );
791 
795  const H225_ServiceControlDescriptor & contents
796  );
798 
806  virtual PBoolean OnCallIndependentSupplementaryService(
807  const H323SignalPDU & setupPDU
808  );
809 
815  virtual PBoolean OnNegotiateConferenceCapabilities(
816  const H323SignalPDU & setupPDU
817  );
819 
824  virtual void SetDefaultLocalPartyName(
825  const PString & name
826  );
827 
836  virtual void SetLocalUserName(
837  const PString & name
838  );
839 
844  virtual const PString & GetLocalUserName() const { return localAliasNames.front(); }
845 
852  PBoolean AddAliasName(
853  const PString & name
854  );
855 
859  PBoolean RemoveAliasName(
860  const PString & name
861  );
862 
867  const PStringList & GetAliasNames() const { return localAliasNames; }
868 
871  const PStringList & GetAliasNamePatterns() const { return localAliasPatterns; }
872 
876  PBoolean AddAliasNamePattern(
877  const PString & pattern
878  );
879 
882  const PString & GetDefaultILSServer() const { return manager.GetDefaultILSServer(); }
883 
887  const PString & server
888  ) { manager.SetDefaultILSServer(server); }
889 
892  PBoolean IsFastStartDisabled() const
893  { return disableFastStart; }
894 
898  PBoolean mode
899  ) { disableFastStart = mode; }
900 
903  PBoolean IsH245TunnelingDisabled() const
904  { return disableH245Tunneling; }
905 
909  PBoolean mode
910  ) { disableH245Tunneling = mode; }
911 
914  PBoolean IsH245inSetupDisabled() const
915  { return disableH245inSetup; }
916 
920  PBoolean mode
921  ) { disableH245inSetup = mode; }
922 
925  bool IsForcedSymmetricTCS() const
926  { return m_forceSymmetricTCS; }
927 
931  bool mode
932  ) { m_forceSymmetricTCS = mode; }
933 
937  PBoolean IsH245Disabled() const
938  { return m_bH245Disabled; }
939 
943  void DisableH245(PBoolean bH245Disabled) { m_bH245Disabled = bH245Disabled; }
944 
947  PBoolean CanDisplayAmountString() const
948  { return canDisplayAmountString; }
949 
953  PBoolean mode
954  ) { canDisplayAmountString = mode; }
955 
958  PBoolean CanEnforceDurationLimit() const
959  { return canEnforceDurationLimit; }
960 
964  PBoolean mode
965  ) { canEnforceDurationLimit = mode; }
966 
967 #if OPAL_H450
968 
971 
975  unsigned level
976  ) { PAssert(level<=3, PInvalidParameter); callIntrusionProtectionLevel = level; }
977 #endif
978 
981  virtual void OnReceivedInitiateReturnError();
982 
985  PBoolean CanAutoCallForward() const { return autoCallForward; }
986 
989  const H323Capabilities & GetCapabilities() const;
990 
1005  e_MCUOnly = 160,
1009  };
1010 
1014 
1018 
1021  PBoolean IsTerminal() const;
1022 
1025  PBoolean IsGateway() const;
1026 
1029  PBoolean IsGatekeeper() const;
1030 
1033  PBoolean IsMCU() const;
1034 
1039 
1044 
1048  unsigned minDelay,
1049  unsigned maxDelay
1050  ) { manager.SetAudioJitterDelay(minDelay, maxDelay); }
1051 
1052 #if OPAL_H239
1053 
1056 
1060  bool on
1061  ) { m_defaultH239Control = on; }
1062 #endif
1063 
1066  virtual PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet &);
1067 
1070  virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet &);
1071 
1075  virtual void LoadBaseFeatureSet();
1076 
1081  virtual bool OnFeatureInstance(
1082  int instType,
1083  const PString & identifer
1084  );
1085 
1086 #if OPAL_H460
1087 
1089  bool FeatureSetDisabled() const { return disableH460; }
1090 
1093  void FeatureSetDisable() { disableH460 = true; }
1094 
1099 
1100  virtual void NATMethodCallBack(
1101  const PString & /*NatID*/,
1102  PINDEX /*msgID*/,
1103  const PString & /*message*/
1104  ) { }
1105 
1108  void H46018Enable(PBoolean enable);
1109 
1112  PBoolean H46018IsEnabled();
1113 
1116  void H46018Received() {};
1117 
1120  PBoolean H46018InOperation();
1121 
1125 #endif
1126 
1129  virtual PBoolean IsLocalAddress(
1130  const PIPSocket::Address & remoteAddress
1131  ) const { return manager.IsLocalAddress(remoteAddress); }
1132 
1135  virtual void TranslateTCPAddress(
1136  PIPSocket::Address & localAddr,
1137  const PIPSocket::Address & remoteAddr
1138  );
1139 
1142  WORD GetTCPPortBase() const { return manager.GetTCPPortBase(); }
1143 
1146  WORD GetTCPPortMax() const { return manager.GetTCPPortMax(); }
1147 
1150  void SetTCPPorts(unsigned tcpBase, unsigned tcpMax) { manager.SetTCPPorts(tcpBase, tcpMax); }
1151 
1155 
1158  WORD GetUDPPortBase() const { return manager.GetUDPPortBase(); }
1159 
1162  WORD GetUDPPortMax() const { return manager.GetUDPPortMax(); }
1163 
1166  void SetUDPPorts(unsigned udpBase, unsigned udpMax) { manager.SetUDPPorts(udpBase, udpMax); }
1167 
1171 
1174  WORD GetRtpIpPortBase() const { return manager.GetRtpIpPortBase(); }
1175 
1178  WORD GetRtpIpPortMax() const { return manager.GetRtpIpPortMax(); }
1179 
1182  void SetRtpIpPorts(unsigned udpBase, unsigned udpMax) { manager.SetRtpIpPorts(udpBase, udpMax); }
1183 
1187 
1190  const PTimeInterval & GetSignallingChannelCallTimeout() const { return signallingChannelCallTimeout; }
1191 
1194  const PTimeInterval & GetControlChannelStartTimeout() const { return controlChannelStartTimeout; }
1195 
1198  const PTimeInterval & GetEndSessionTimeout() const { return endSessionTimeout; }
1199 
1203 
1207 
1210  const PTimeInterval & GetCapabilityExchangeTimeout() const { return capabilityExchangeTimeout; }
1211 
1214  const PTimeInterval & GetLogicalChannelTimeout() const { return logicalChannelTimeout; }
1215 
1218  const PTimeInterval & GetRequestModeTimeout() const { return logicalChannelTimeout; }
1219 
1222  const PTimeInterval & GetRoundTripDelayTimeout() const { return roundTripDelayTimeout; }
1223 
1226  const PTimeInterval & GetRoundTripDelayRate() const { return roundTripDelayRate; }
1227 
1231 
1234  const PTimeInterval & GetNoMediaTimeout() const { return manager.GetNoMediaTimeout(); }
1235 
1239  const PTimeInterval & newInterval
1240  ) { manager.SetNoMediaTimeout(newInterval); }
1241 
1244  const PTimeInterval & GetGatekeeperRequestTimeout() const { return gatekeeperRequestTimeout; }
1245 
1249 
1252  const PTimeInterval & GetRasRequestTimeout() const { return rasRequestTimeout; }
1253 
1256  unsigned GetRasRequestRetries() const { return rasRequestRetries; }
1257 
1261  const PTimeInterval & GetGatekeeperTimeToLive() const { return registrationTimeToLive; }
1262 
1266  void SetGatekeeperTimeToLive(const PTimeInterval & ttl) { registrationTimeToLive = ttl; }
1267 
1270  const PString & GetGkAccessTokenOID() const { return gkAccessTokenOID; }
1271 
1274  void SetGkAccessTokenOID(const PString & token) { gkAccessTokenOID = token; }
1275 
1278  bool GetSendGRQ() const { return m_sendGRQ; }
1279 
1282  void SetSendGRQ(bool v) { m_sendGRQ = v; }
1283 
1287 
1291 
1294  const PTimeInterval & GetCallTransferT1() const { return callTransferT1; }
1295 
1298  const PTimeInterval & GetCallTransferT2() const { return callTransferT2; }
1299 
1302  const PTimeInterval & GetCallTransferT3() const { return callTransferT3; }
1303 
1306  const PTimeInterval & GetCallTransferT4() const { return callTransferT4; }
1307 
1309  const PTimeInterval & GetCallIntrusionT1() const { return callIntrusionT1; }
1310  const PTimeInterval & GetCallIntrusionT2() const { return callIntrusionT2; }
1311  const PTimeInterval & GetCallIntrusionT3() const { return callIntrusionT3; }
1312  const PTimeInterval & GetCallIntrusionT4() const { return callIntrusionT4; }
1313  const PTimeInterval & GetCallIntrusionT5() const { return callIntrusionT5; }
1314  const PTimeInterval & GetCallIntrusionT6() const { return callIntrusionT6; }
1315 
1318  H323CallIdentityDict& GetCallIdentityDictionary() { return secondaryConnectionsActive; }
1319 
1322 #if OPAL_H450
1324 #endif
1325 
1329  virtual PString GetDefaultTransport() const;
1330 
1333  virtual WORD GetDefaultSignalPort() const;
1334 
1336  PString GetCompatibility(
1338  ) const;
1339 
1345  bool SetCompatibility(
1347  const PString & regex
1348  );
1349 
1357  bool AddCompatibility(
1359  const PString & regex
1360  );
1361 
1363  bool HasCompatibilityIssue(
1365  const OpalProductInfo & productInfo
1366  ) const;
1368 
1369  protected:
1371  H323Transport * transport,
1372  const H323TransportAddress & gkAddress
1373  );
1375  OpalCall & call,
1376  const PString & existingToken,
1377  const PString & callIdentity,
1378  unsigned capabilityLevel,
1379  const PString & remoteParty,
1380  void * userData,
1381  unsigned int options = 0,
1382  OpalConnection::StringOptions * stringOptions = NULL
1383  );
1384 
1385  // Configuration variables, commonly changed
1386  PStringList localAliasNames;
1387  PStringList localAliasPatterns;
1393  PBoolean m_bH245Disabled; /* enabled or disabled h245 */
1396 #if OPAL_H450
1398 #endif
1399 
1401 
1402 #if OPAL_H239
1404 #endif
1405 
1407 
1408  // Some more configuration variables, rarely changed.
1411  PTimeInterval endSessionTimeout;
1415  PTimeInterval logicalChannelTimeout;
1416  PTimeInterval requestModeTimeout;
1417  PTimeInterval roundTripDelayTimeout;
1418  PTimeInterval roundTripDelayRate;
1421  PTimeInterval rasRequestTimeout;
1423  PTimeInterval registrationTimeToLive;
1424 
1428 
1429  /* Protect against absence of a response to the ctIdentify reqest
1430  (Transferring Endpoint - Call Transfer with a secondary Call) */
1431  PTimeInterval callTransferT1;
1432  /* Protect against failure of completion of the call transfer operation
1433  involving a secondary Call (Transferred-to Endpoint) */
1434  PTimeInterval callTransferT2;
1435  /* Protect against failure of the Transferred Endpoint not responding
1436  within sufficient time to the ctInitiate APDU (Transferring Endpoint) */
1437  PTimeInterval callTransferT3;
1438  /* May optionally operate - protects against absence of a response to the
1439  ctSetup request (Transferred Endpoint) */
1440  PTimeInterval callTransferT4;
1441 
1443  PTimeInterval callIntrusionT1;
1444  PTimeInterval callIntrusionT2;
1445  PTimeInterval callIntrusionT3;
1446  PTimeInterval callIntrusionT4;
1447  PTimeInterval callIntrusionT5;
1448  PTimeInterval callIntrusionT6;
1449 
1450  // Dynamic variables
1455  H323CallIdentityDict secondaryConnectionsActive;
1456 
1457 #if OPAL_H450
1458  mutable PAtomicInteger nextH450CallIdentity;
1460 #endif
1461 
1462 #if OPAL_H460
1466 #endif
1467 
1468  typedef map<H323Connection::CompatibilityIssues, PRegularExpression> CompatibilityEndpoints;
1470 
1471  private:
1472  P_REMOVE_VIRTUAL_VOID(OnConnectionCleared(H323Connection &, const PString &));
1473  P_REMOVE_VIRTUAL_VOID(OnRTPStatistics(const H323Connection &, const OpalRTPSession &) const);
1474  P_REMOVE_VIRTUAL(PBoolean, OnConferenceInvite(const H323SignalPDU &), false);
1475  P_REMOVE_VIRTUAL_VOID(OnGatekeeperConfirm());
1476  P_REMOVE_VIRTUAL_VOID(OnGatekeeperReject());
1477  P_REMOVE_VIRTUAL_VOID(OnRegistrationConfirm());
1478  P_REMOVE_VIRTUAL_VOID(OnRegistrationReject());
1479 
1480 #if OPAL_H460
1481  // This is because there h323plus had
1482  // a public way of adding a connection
1483  friend class H46018Transport;
1484 #endif
1485 };
1486 
1487 #endif // OPAL_H323
1488 
1489 #endif // OPAL_H323_H323EP_H
1490 
1491