OPAL  Version 3.10.4
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: 25678 $
30  * $Author: rjongbloed $
31  * $Date: 2011-05-05 17:46:37 -0500 (Thu, 05 May 2011) $
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 <opal/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 <asn/h225.h>
53 
54 #if OPAL_H460
55 #include <h460/h4601.h>
56 #endif
57 
58 
59 class H225_EndpointType;
60 class H225_VendorIdentifier;
61 class H225_H221NonStandard;
62 class H225_ServiceControlDescriptor;
63 class H225_FeatureSet;
64 
65 class H235SecurityInfo;
66 
67 class H323Gatekeeper;
68 class H323SignalPDU;
70 
72 
86 {
87  PCLASSINFO(H323EndPoint, OpalRTPEndPoint);
88 
89  public:
90  enum {
92  };
93 
100  );
101 
104  ~H323EndPoint();
106 
113  virtual void ShutDown();
114 
144  virtual PSafePtr<OpalConnection> MakeConnection(
145  OpalCall & call,
146  const PString & party,
147  void * userData = NULL,
148  unsigned int options = NULL,
149  OpalConnection::StringOptions * stringOptions = NULL
150  );
152 
157  virtual void SetEndpointTypeInfo(
158  H225_EndpointType & info
159  ) const;
160 
163  virtual void SetVendorIdentifierInfo(
164  H225_VendorIdentifier & info
165  ) const;
166 
169  virtual void SetH221NonStandardInfo(
170  H225_H221NonStandard & info
171  ) const;
172 
175  virtual bool SetGatewaySupportedProtocol(
176  H225_ArrayOf_SupportedProtocols & protocols
177  ) const;
178 
182  virtual bool OnSetGatewayPrefixes(
183  PStringList & prefixes
184  ) const;
186 
187 
198  void AddCapability(
199  H323Capability * capability
200  );
201 
222  PINDEX SetCapability(
223  PINDEX descriptorNum,
224  PINDEX simultaneous,
225  H323Capability * cap
226  );
227 
232  PINDEX AddAllCapabilities(
233  PINDEX descriptorNum,
234  PINDEX simultaneous,
235  const PString & name
236  );
237 
241  PINDEX descriptorNum,
242  PINDEX simultaneous
243  );
244 
247  void RemoveCapabilities(
248  const PStringArray & codecNames
249  );
250 
253  void ReorderCapabilities(
254  const PStringArray & preferenceOrder
255  );
256 
260  const H245_Capability & cap
261  ) const;
262 
266  const H245_DataType & dataType
267  ) const;
268 
272  H323Capability::MainTypes mainType,
273  unsigned subType
274  ) const;
276 
299  PBoolean UseGatekeeper(
300  const PString & address = PString::Empty(),
301  const PString & identifier = PString::Empty(),
302  const PString & localAddress = PString::Empty()
303  );
304 
315  PBoolean SetGatekeeper(
316  const PString & address,
317  H323Transport * transport = NULL
318  );
319 
334  PBoolean SetGatekeeperZone(
335  const PString & address,
336  const PString & identifier,
337  H323Transport * transport = NULL
338  );
339 
349  PBoolean LocateGatekeeper(
350  const PString & identifier,
351  H323Transport * transport = NULL
352  );
353 
362  PBoolean DiscoverGatekeeper(
363  H323Transport * transport = NULL
364  );
365 
374  H323Transport * transport
375  );
376 
380 
383  PBoolean IsRegisteredWithGatekeeper() const;
384 
390  PBoolean RemoveGatekeeper(
391  int reason = -1
392  );
393 
396  virtual void SetGatekeeperPassword(
397  const PString & password,
398  const PString & username = PString::Empty()
399  );
400 
403  virtual const PString & GetGatekeeperUsername() const { return gatekeeperUsername; }
404 
407  virtual const PString & GetGatekeeperPassword() const { return gatekeeperPassword; }
408 
411  virtual H235Authenticators CreateAuthenticators();
412 
415  virtual void OnGatekeeperConfirm();
416 
419  virtual void OnGatekeeperReject();
420 
423  virtual void OnRegistrationConfirm();
424 
427  virtual void OnRegistrationReject();
429 
434  virtual PBoolean NewIncomingConnection(
435  OpalTransport * transport
436  );
437 
441  OpalCall & call,
442  const PString & token,
443  void * userData,
444  OpalTransport & transport,
445  const PString & alias,
446  const H323TransportAddress & address,
447  H323SignalPDU * setupPDU,
448  unsigned options = 0,
449  OpalConnection::StringOptions * stringOptions = NULL
450  );
451 
467  virtual PBoolean SetupTransfer(
468  const PString & token,
469  const PString & callIdentity,
470  const PString & remoteParty,
471  void * userData = NULL
472  );
473 
479  void TransferCall(
480  const PString & token,
481  const PString & remoteParty,
482  const PString & callIdentity = PString::Empty()
484  );
485 
493  const PString & primaryCallToken,
494  const PString & secondaryCallToken
495  );
496 
500  void HoldCall(
501  const PString & token,
502  PBoolean localHold
503  );
504 
508  PBoolean IntrudeCall(
509  const PString & remoteParty,
510  unsigned capabilityLevel,
511  void * userData = NULL
512  );
513 
520  PBoolean ParsePartyName(
521  const PString & party,
522  PString & alias,
523  H323TransportAddress & address,
524  OpalConnection::StringOptions * stringOptions = NULL
525  );
526 
537  PSafePtr<H323Connection> FindConnectionWithLock(
538  const PString & token,
539  PSafetyMode mode = PSafeReadWrite
540  );
541 
549  virtual PBoolean OnSendSignalSetup(H323Connection & connection,
550  H323SignalPDU & setupPDU);
551 
563  virtual PBoolean OnSendCallProceeding(
564  H323Connection & connection,
565  H323SignalPDU & callProceedingPDU
566  );
567 
579  virtual PBoolean OnSendConnect(
580  H323Connection & connection,
581  H323SignalPDU & connectPDU
582  );
583 
595  virtual PBoolean OnIncomingCall(
596  H323Connection & connection,
597  const H323SignalPDU & setupPDU,
598  H323SignalPDU & alertingPDU
599  );
600 
607  virtual PBoolean OnOutgoingCall(
608  H323Connection & conn,
609  const H323SignalPDU & connectPDU
610  );
611 
616  virtual PBoolean OnCallTransferInitiate(
617  H323Connection & connection,
618  const PString & remoteParty
619  );
620 
625  virtual PBoolean OnCallTransferIdentify(
626  H323Connection & connection
627  );
628 
633  virtual void OnSendARQ(
634  H323Connection & conn,
635  H225_AdmissionRequest & arq
636  );
637 
645  H323Connection & connection,
646  const PString & callerName,
647  const H323SignalPDU & setupPDU,
648  H323SignalPDU & connectPDU,
649  H323SignalPDU & progressPDU
650  );
652  OpalConnection & connection,
653  const PString & caller
654  );
655 
666  virtual PBoolean OnAlerting(
667  H323Connection & connection,
668  const H323SignalPDU & alertingPDU,
669  const PString & user
670  );
671 
676  virtual PBoolean OnSendAlerting(
677  H323Connection & connection,
678  H323SignalPDU & alerting,
679  const PString & calleeName,
680  PBoolean withMedia
681  );
682 
686  virtual PBoolean OnSentAlerting(
687  H323Connection & connection
688  );
689 
698  virtual PBoolean OnConnectionForwarded(
699  H323Connection & connection,
700  const PString & forwardParty,
701  const H323SignalPDU & pdu
702  );
703 
712  virtual PBoolean ForwardConnection(
713  H323Connection & connection,
714  const PString & forwardParty,
715  const H323SignalPDU & pdu
716  );
717 
724  virtual void OnConnectionEstablished(
725  H323Connection & connection,
726  const PString & token
727  );
728 
731  virtual PBoolean IsConnectionEstablished(
732  const PString & token
733  );
735 
736 
743  virtual PBoolean OnStartLogicalChannel(
744  H323Connection & connection,
745  H323Channel & channel
746  );
747 
752  virtual void OnClosedLogicalChannel(
753  H323Connection & connection,
754  const H323Channel & channel
755  );
756 
764  virtual void OnRTPStatistics(
765  const H323Connection & connection,
766  const RTP_Session & session
767  ) const;
768 
774  virtual void OnGatekeeperNATDetect(
775  PIPSocket::Address publicAddr,
776  PString & gkIdentifier,
777  H323TransportAddress & gkRouteAddress
778  );
780 
790  virtual void OnHTTPServiceControl(
791  unsigned operation,
792  unsigned sessionId,
793  const PString & url
794  );
795 
805  virtual void OnCallCreditServiceControl(
806  const PString & amount,
807  PBoolean mode
808  );
809 
813  virtual void OnServiceControlSession(
814  unsigned type,
815  unsigned sessionid,
816  const H323ServiceControlSession & session,
817  H323Connection * connection
818  );
819 
823  const H225_ServiceControlDescriptor & contents
824  );
826 
834  virtual PBoolean OnConferenceInvite(
835  const H323SignalPDU & setupPDU
836  );
837 
843  virtual PBoolean OnCallIndependentSupplementaryService(
844  const H323SignalPDU & setupPDU
845  );
846 
852  virtual PBoolean OnNegotiateConferenceCapabilities(
853  const H323SignalPDU & setupPDU
854  );
856 
861  virtual void SetDefaultLocalPartyName(
862  const PString & name
863  );
864 
873  virtual void SetLocalUserName(
874  const PString & name
875  );
876 
881  virtual const PString & GetLocalUserName() const { return localAliasNames.front(); }
882 
889  PBoolean AddAliasName(
890  const PString & name
891  );
892 
896  PBoolean RemoveAliasName(
897  const PString & name
898  );
899 
904  const PStringList & GetAliasNames() const { return localAliasNames; }
905 
908  const PStringList & GetAliasNamePatterns() const { return localAliasPatterns; }
909 
913  PBoolean AddAliasNamePattern(
914  const PString & pattern
915  );
916 
919  const PString & GetDefaultILSServer() const { return manager.GetDefaultILSServer(); }
920 
924  const PString & server
925  ) { manager.SetDefaultILSServer(server); }
926 
929  PBoolean IsFastStartDisabled() const
930  { return disableFastStart; }
931 
935  PBoolean mode
936  ) { disableFastStart = mode; }
937 
940  PBoolean IsH245TunnelingDisabled() const
941  { return disableH245Tunneling; }
942 
946  PBoolean mode
947  ) { disableH245Tunneling = mode; }
948 
951  PBoolean IsH245inSetupDisabled() const
952  { return disableH245inSetup; }
953 
957  PBoolean mode
958  ) { disableH245inSetup = mode; }
959 
963  PBoolean IsH245Disabled() const
964  { return m_bH245Disabled; }
965 
969  void DisableH245(PBoolean bH245Disabled) { m_bH245Disabled = bH245Disabled; }
970 
973  PBoolean CanDisplayAmountString() const
974  { return canDisplayAmountString; }
975 
979  PBoolean mode
980  ) { canDisplayAmountString = mode; }
981 
984  PBoolean CanEnforceDurationLimit() const
985  { return canEnforceDurationLimit; }
986 
990  PBoolean mode
991  ) { canEnforceDurationLimit = mode; }
992 
993 #if OPAL_H450
994 
997 
1001  unsigned level
1002  ) { PAssert(level<=3, PInvalidParameter); callIntrusionProtectionLevel = level; }
1003 #endif
1004 
1007  virtual void OnReceivedInitiateReturnError();
1008 
1011  PBoolean CanAutoCallForward() const { return autoCallForward; }
1012 
1015  const H323Capabilities & GetCapabilities() const;
1016 
1031  e_MCUOnly = 160,
1035  };
1036 
1040 
1044 
1047  PBoolean IsTerminal() const;
1048 
1051  PBoolean IsGateway() const;
1052 
1055  PBoolean IsGatekeeper() const;
1056 
1059  PBoolean IsMCU() const;
1060 
1065 
1070 
1074  unsigned minDelay,
1075  unsigned maxDelay
1076  ) { manager.SetAudioJitterDelay(minDelay, maxDelay); }
1077 
1080  unsigned GetInitialBandwidth() const { return initialBandwidth; }
1081 
1084  void SetInitialBandwidth(unsigned bandwidth) { initialBandwidth = bandwidth; }
1085 
1086 #if OPAL_H239
1087 
1090 
1094  bool on
1095  ) { m_defaultH239Control = on; }
1096 #endif
1097 
1100  virtual PBoolean OnSendFeatureSet(unsigned, H225_FeatureSet &);
1101 
1104  virtual void OnReceiveFeatureSet(unsigned, const H225_FeatureSet &);
1105 
1109  virtual void LoadBaseFeatureSet();
1110 
1115  virtual bool OnFeatureInstance(
1116  int instType,
1117  const PString & identifer
1118  );
1119 
1120 #if OPAL_H460
1121 
1123  bool FeatureSetDisabled() const { return disableH460; }
1124 
1127  void FeatureSetDisable() { disableH460 = true; }
1128 
1133 #endif
1134 
1137  virtual PBoolean IsLocalAddress(
1138  const PIPSocket::Address & remoteAddress
1139  ) const { return manager.IsLocalAddress(remoteAddress); }
1140 
1143  virtual void TranslateTCPAddress(
1144  PIPSocket::Address & localAddr,
1145  const PIPSocket::Address & remoteAddr
1146  );
1147 
1150  WORD GetTCPPortBase() const { return manager.GetTCPPortBase(); }
1151 
1154  WORD GetTCPPortMax() const { return manager.GetTCPPortMax(); }
1155 
1158  void SetTCPPorts(unsigned tcpBase, unsigned tcpMax) { manager.SetTCPPorts(tcpBase, tcpMax); }
1159 
1163 
1166  WORD GetUDPPortBase() const { return manager.GetUDPPortBase(); }
1167 
1170  WORD GetUDPPortMax() const { return manager.GetUDPPortMax(); }
1171 
1174  void SetUDPPorts(unsigned udpBase, unsigned udpMax) { manager.SetUDPPorts(udpBase, udpMax); }
1175 
1179 
1182  WORD GetRtpIpPortBase() const { return manager.GetRtpIpPortBase(); }
1183 
1186  WORD GetRtpIpPortMax() const { return manager.GetRtpIpPortMax(); }
1187 
1190  void SetRtpIpPorts(unsigned udpBase, unsigned udpMax) { manager.SetRtpIpPorts(udpBase, udpMax); }
1191 
1195 
1198  BYTE P_DEPRECATED GetRtpIpTypeofService() const { return manager.GetMediaTypeOfService(); }
1199 
1202  void P_DEPRECATED SetRtpIpTypeofService(unsigned tos) { manager.SetMediaTypeOfService(tos); }
1203 
1206  const PTimeInterval & GetSignallingChannelCallTimeout() const { return signallingChannelCallTimeout; }
1207 
1210  const PTimeInterval & GetControlChannelStartTimeout() const { return controlChannelStartTimeout; }
1211 
1214  const PTimeInterval & GetEndSessionTimeout() const { return endSessionTimeout; }
1215 
1219 
1223 
1226  const PTimeInterval & GetCapabilityExchangeTimeout() const { return capabilityExchangeTimeout; }
1227 
1230  const PTimeInterval & GetLogicalChannelTimeout() const { return logicalChannelTimeout; }
1231 
1234  const PTimeInterval & GetRequestModeTimeout() const { return logicalChannelTimeout; }
1235 
1238  const PTimeInterval & GetRoundTripDelayTimeout() const { return roundTripDelayTimeout; }
1239 
1242  const PTimeInterval & GetRoundTripDelayRate() const { return roundTripDelayRate; }
1243 
1247 
1250  const PTimeInterval & GetNoMediaTimeout() const { return manager.GetNoMediaTimeout(); }
1251 
1255  const PTimeInterval & newInterval
1256  ) { return manager.SetNoMediaTimeout(newInterval); }
1257 
1260  const PTimeInterval & GetGatekeeperRequestTimeout() const { return gatekeeperRequestTimeout; }
1261 
1265 
1268  const PTimeInterval & GetRasRequestTimeout() const { return rasRequestTimeout; }
1269 
1272  unsigned GetRasRequestRetries() const { return rasRequestRetries; }
1273 
1277  const PTimeInterval & GetGatekeeperTimeToLive() const { return registrationTimeToLive; }
1278 
1282  void SetGatekeeperTimeToLive(const PTimeInterval & ttl) { registrationTimeToLive = ttl; }
1283 
1286  const PString & GetGkAccessTokenOID() const { return gkAccessTokenOID; }
1287 
1290  void SetGkAccessTokenOID(const PString & token) { gkAccessTokenOID = token; }
1291 
1294  PBoolean GetSendGRQ() const
1295  { return sendGRQ; }
1296 
1299  void SetSendGRQ(PBoolean v)
1300  { sendGRQ = v; }
1301 
1304  const PTimeInterval & GetCallTransferT1() const { return callTransferT1; }
1305 
1308  const PTimeInterval & GetCallTransferT2() const { return callTransferT2; }
1309 
1312  const PTimeInterval & GetCallTransferT3() const { return callTransferT3; }
1313 
1316  const PTimeInterval & GetCallTransferT4() const { return callTransferT4; }
1317 
1319  const PTimeInterval & GetCallIntrusionT1() const { return callIntrusionT1; }
1320  const PTimeInterval & GetCallIntrusionT2() const { return callIntrusionT2; }
1321  const PTimeInterval & GetCallIntrusionT3() const { return callIntrusionT3; }
1322  const PTimeInterval & GetCallIntrusionT4() const { return callIntrusionT4; }
1323  const PTimeInterval & GetCallIntrusionT5() const { return callIntrusionT5; }
1324  const PTimeInterval & GetCallIntrusionT6() const { return callIntrusionT6; }
1325 
1328  H323CallIdentityDict& GetCallIdentityDictionary() { return secondaryConnectionsActive; }
1329 
1332 #if OPAL_H450
1334 #endif
1335 
1336  PString GetDefaultTransport() const;
1338 
1339  protected:
1340  bool InternalCreateGatekeeper(H323Transport * transport);
1342  OpalCall & call,
1343  const PString & existingToken,
1344  const PString & callIdentity,
1345  unsigned capabilityLevel,
1346  const PString & remoteParty,
1347  void * userData,
1348  unsigned int options = 0,
1349  OpalConnection::StringOptions * stringOptions = NULL
1350  );
1351 
1352  // Configuration variables, commonly changed
1353  PStringList localAliasNames;
1354  PStringList localAliasPatterns;
1359  PBoolean m_bH245Disabled; /* enabled or disabled h245 */
1362 #if OPAL_H450
1364 #endif
1365 
1367 
1368 #if OPAL_H239
1370 #endif
1371 
1373 
1374  // Some more configuration variables, rarely changed.
1377  PTimeInterval endSessionTimeout;
1381  PTimeInterval logicalChannelTimeout;
1382  PTimeInterval requestModeTimeout;
1383  PTimeInterval roundTripDelayTimeout;
1384  PTimeInterval roundTripDelayRate;
1387  PTimeInterval rasRequestTimeout;
1389  PTimeInterval registrationTimeToLive;
1390 
1392  PBoolean sendGRQ;
1393 
1394  /* Protect against absence of a response to the ctIdentify reqest
1395  (Transferring Endpoint - Call Transfer with a secondary Call) */
1396  PTimeInterval callTransferT1;
1397  /* Protect against failure of completion of the call transfer operation
1398  involving a secondary Call (Transferred-to Endpoint) */
1399  PTimeInterval callTransferT2;
1400  /* Protect against failure of the Transferred Endpoint not responding
1401  within sufficient time to the ctInitiate APDU (Transferring Endpoint) */
1402  PTimeInterval callTransferT3;
1403  /* May optionally operate - protects against absence of a response to the
1404  ctSetup request (Transferred Endpoint) */
1405  PTimeInterval callTransferT4;
1406 
1408  PTimeInterval callIntrusionT1;
1409  PTimeInterval callIntrusionT2;
1410  PTimeInterval callIntrusionT3;
1411  PTimeInterval callIntrusionT4;
1412  PTimeInterval callIntrusionT5;
1413  PTimeInterval callIntrusionT6;
1414 
1415  // Dynamic variables
1420  H323CallIdentityDict secondaryConnectionsActive;
1421 
1422 #if OPAL_H450
1423  mutable PAtomicInteger nextH450CallIdentity;
1425 #endif
1426 
1427 #if OPAL_H460
1430 #endif
1431 
1432  private:
1433  P_REMOVE_VIRTUAL_VOID(OnConnectionCleared(H323Connection &, const PString &));
1434 };
1435 
1436 #endif // OPAL_H323
1437 
1438 #endif // OPAL_H323_H323EP_H
1439 
1440