OPAL  Version 3.14.3
transports.h
Go to the documentation of this file.
1 /*
2  * transport.h
3  *
4  * Transport declarations
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence Pty. Ltd.
10  * Portions Copyright (C) 2006 by Post Increment
11  *
12  * The contents of this file are subject to the Mozilla Public License
13  * Version 1.0 (the "License"); you may not use this file except in
14  * compliance with the License. You may obtain a copy of the License at
15  * http://www.mozilla.org/MPL/
16  *
17  * Software distributed under the License is distributed on an "AS IS"
18  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19  * the License for the specific language governing rights and limitations
20  * under the License.
21  *
22  * The Original Code is Open Phone Abstraction Library.
23  *
24  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
25  *
26  * Contributor(s): Post Increment
27  * Portions of this code were written with the assistance of funding from
28  * US Joint Forces Command Joint Concept Development & Experimentation (J9)
29  * http://www.jfcom.mil/about/abt_j9.htm
30  *
31  * $Revision: 32137 $
32  * $Author: rjongbloed $
33  * $Date: 2014-06-12 11:10:00 +1000 (Thu, 12 Jun 2014) $
34  */
35 
36 #ifndef OPAL_OPAL_TRANSPORT_H
37 #define OPAL_OPAL_TRANSPORT_H
38 
39 #ifdef P_USE_PRAGMA
40 #pragma interface
41 #endif
42 
43 #include <opal_config.h>
44 
45 #include <ptlib/sockets.h>
46 #include <ptclib/psockbun.h>
47 #include <ptclib/http.h>
48 
49 
50 class OpalManager;
51 class OpalEndPoint;
52 class OpalListener;
53 class OpalTransport;
55 
56 typedef PSafePtr<OpalTransport> OpalTransportPtr;
57 
58 
60 
155 class OpalTransportAddress : public PCaselessString
156 {
157  PCLASSINFO(OpalTransportAddress, PCaselessString);
158  public:
159  static const PCaselessString & IpPrefix();
160  static const PCaselessString & UdpPrefix();
161  static const PCaselessString & TcpPrefix();
162 #if OPAL_PTLIB_SSL
163  static const PCaselessString & TlsPrefix();
164 #if OPAL_PTLIB_HTTP
165  static const PCaselessString & WsPrefix(); // RFC6455 WebSocket (yes, still needs SSL)
166  static const PCaselessString & WssPrefix(); // RFC6455 WebSocket over TLS
167 #endif
168 #endif
169 
174  const char * address,
175  WORD port = 0,
176  const char * proto = NULL
177  );
179  const PString & address,
180  WORD port = 0,
181  const char * proto = NULL
182  );
184  const PIPSocket::Address & ip,
185  WORD port = 0,
186  const char * proto = NULL
187  );
189  const PIPSocket::AddressAndPort & ap,
190  const char * proto = NULL
191  );
192 
194  virtual PObject * Clone() const { return new OpalTransportAddress(*this); }
196 
204  PBoolean IsEquivalent(
205  const OpalTransportAddress & address,
206  bool wildcards = false
207  ) const;
208 
211  PBoolean IsCompatible(
212  const OpalTransportAddress & address
213  ) const;
214 
217  PCaselessString GetProtoPrefix() const { return Left(Find('$')+1); }
218 
219  // For backward compatibility
220  PCaselessString GetProto(bool withDollar = false) const { return Left(Find('$')+(withDollar?1:0)); }
221 
225  PBoolean GetIpAddress(PIPSocket::Address & ip) const;
226 
230  PBoolean GetIpAndPort(PIPSocket::Address & ip, WORD & port) const;
231  PBoolean GetIpAndPort(PIPSocketAddressAndPort & ipPort) const;
232 
236  virtual PString GetHostName(
237  bool includeService = false
238  ) const;
239 
240  enum BindOptions {
248  };
249 
282  OpalEndPoint & endpoint,
283  BindOptions option
284  ) const;
285 
313  virtual OpalTransport * CreateTransport(
314  OpalEndPoint & endpoint,
315  BindOptions option = HostOnly
316  ) const;
318 
319 
320  protected:
322  WORD port,
323  const char * proto
324  );
325 
327 };
328 
329 
330 class OpalTransportAddressArray : public PArray<OpalTransportAddress>
331 {
332  typedef PArray<OpalTransportAddress> ParentClass;
333  PCLASSINFO(OpalTransportAddressArray, ParentClass);
334 
335  protected:
337  : ParentClass(dummy, c) { }
338 
339  public:
340  OpalTransportAddressArray(PINDEX initialSize = 0)
341  : ParentClass(initialSize) { }
343  const OpalTransportAddress & address
344  ) { AppendAddress(address); }
346  const PStringArray & array
347  ) { AppendStringCollection(array); }
349  const PStringList & list
350  ) { AppendStringCollection(list); }
352  const PSortedStringList & list
353  ) { AppendStringCollection(list); }
354 
355  void AppendString(
356  const char * address
357  );
358  void AppendString(
359  const PString & address
360  );
361  bool AppendAddress(
362  const OpalTransportAddress & address
363  );
364  bool SetAddressPair(
365  const OpalTransportAddress & addr1,
366  const OpalTransportAddress & addr2
367  );
368 
369  virtual PObject * Clone() const
370  {
371  return new OpalTransportAddressArray(0, this);
372  }
373 
374  protected:
376  const PCollection & coll
377  );
378 };
379 
380 
381 
382 
384 
397 class OpalListener : public PObject
398 {
399  PCLASSINFO(OpalListener, PObject);
400  public:
405  OpalListener(
406  OpalEndPoint & endpoint
407  );
409 
414  void PrintOn(
415  ostream & strm
416  ) const;
418 
421  enum ThreadMode {
425  };
426 
427  typedef PNotifierTemplate<const OpalTransportPtr &> AcceptHandler;
428  #define PDECLARE_AcceptHandlerNotifier(cls, fn) PDECLARE_NOTIFIER2(OpalListener, cls, fn, const OpalTransportPtr &)
429 
430 
445  virtual bool Open(
446  const AcceptHandler & acceptHandler,
448  );
449 
452  virtual bool IsOpen() const = 0;
453 
456  virtual void Close() = 0;
457 
460  virtual OpalTransport * Accept(
461  const PTimeInterval & timeout
462  ) = 0;
463 
466  virtual OpalTransport * CreateTransport(
467  const OpalTransportAddress & localAddress,
468  const OpalTransportAddress & remoteAddress
469  ) const = 0;
470 
477  const OpalTransportAddress & remoteAddress = OpalTransportAddress()
478  ) const = 0;
479 
482  void CloseWait();
483 
489 
490 
491  protected:
500  void ListenForConnections();
501  void TransportThreadMain(OpalTransportPtr transport);
502 
504  PThread * m_thread;
507 
508  private:
509  OpalListener(const OpalListener & other) : PObject(other), m_endpoint(other.m_endpoint) { }
510  void operator=(const OpalListener &) { }
511 
512  friend class OpalHTTPConnector;
513 };
514 
515 
516 PLIST(OpalListenerList, OpalListener);
517 
518 
520 {
521  PCLASSINFO(OpalListenerIP, OpalListener);
522  public:
528  OpalEndPoint & endpoint,
529  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
530  WORD port = 0,
531  PBoolean exclusive = true
532  );
534  OpalEndPoint & endpoint,
535  const OpalTransportAddress & binding,
537  );
539 
548  const OpalTransportAddress & remoteAddress = OpalTransportAddress()
549  ) const;
551 
554  WORD GetListenerPort() const { return m_binding.GetPort(); }
555 
556  virtual const PCaselessString & GetProtoPrefix() const = 0;
558 
559 
560  protected:
561  bool CanCreateTransport(
562  const OpalTransportAddress & localAddress,
563  const OpalTransportAddress & remoteAddress
564  ) const;
565 
566  PIPSocketAddressAndPort m_binding;
568 };
569 
570 
572 {
573  PCLASSINFO(OpalListenerTCP, OpalListenerIP);
574  public:
580  OpalEndPoint & endpoint,
581  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
582  WORD port = 0,
583  PBoolean exclusive = true
584  );
586  OpalEndPoint & endpoint,
587  const OpalTransportAddress & binding,
589  );
590 
595 
618  virtual bool Open(
619  const AcceptHandler & acceptHandler,
621  );
622 
625  virtual bool IsOpen() const;
626 
629  virtual void Close();
630 
633  virtual OpalTransport * Accept(
634  const PTimeInterval & timeout
635  );
636 
639  virtual OpalTransport * CreateTransport(
640  const OpalTransportAddress & localAddress,
641  const OpalTransportAddress & remoteAddress
642  ) const;
644 
645 
646  protected:
647  virtual const PCaselessString & GetProtoPrefix() const;
648  virtual OpalTransport * OnAccept(PTCPSocket * socket);
649 
650  PTCPSocket m_listener;
651 };
652 
653 
655 {
656  PCLASSINFO(OpalListenerUDP, OpalListenerIP);
657  public:
663  OpalEndPoint & endpoint,
664  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
665  WORD port = 0,
666  PBoolean exclusive = true
667  );
669  OpalEndPoint & endpoint,
670  const OpalTransportAddress & binding,
672  );
673 
678 
701  virtual bool Open(
702  const AcceptHandler & acceptHandler,
704  );
705 
708  virtual bool IsOpen() const;
709 
712  virtual void Close();
713 
716  virtual OpalTransport * Accept(
717  const PTimeInterval & timeout
718  );
719 
722  virtual OpalTransport * CreateTransport(
723  const OpalTransportAddress & localAddress,
724  const OpalTransportAddress & remoteAddress
725  ) const;
726 
733  const OpalTransportAddress & remoteAddress = OpalTransportAddress()
734  ) const;
736 
742  PINDEX size
743  ) { m_bufferSize = size; }
745 
746 
747  protected:
748  virtual const PCaselessString & GetProtoPrefix() const;
749 
750  PMonitoredSocketsPtr m_listenerBundle;
751  PINDEX m_bufferSize;
752 };
753 
754 
756 
761 class OpalTransport : public PSafeObject
762 {
763  PCLASSINFO(OpalTransport, PSafeObject);
764  protected:
769  OpalTransport(OpalEndPoint & endpoint, PChannel * channel);
770 
771  public:
774  ~OpalTransport();
776 
781  void PrintOn(
782  ostream & strm
783  ) const;
784 
799  virtual PBoolean Write(
800  const void * buf,
801  PINDEX len
802  );
804 
809  virtual PBoolean IsReliable() const = 0;
810 
814  virtual bool IsAuthenticated(
815  const PString & /*domain*/
816  ) const { return true; }
817 
824  virtual PString GetInterface() const = 0;
825 
832  virtual bool SetInterface(
833  const PString & iface
834  );
835 
838  virtual OpalTransportAddress GetLocalAddress() const = 0;
839 
842  virtual OpalTransportAddress GetRemoteAddress() const = 0;
843 
849  virtual PBoolean SetRemoteAddress(
850  const OpalTransportAddress & address
851  ) = 0;
852 
855  virtual PBoolean Connect() = 0;
856 
859  PBoolean ConnectTo(
860  const OpalTransportAddress & address
861  ) { return SetRemoteAddress(address) && Connect(); }
862 
865  virtual PBoolean Close();
866 
869  void CloseWait();
870 
875 
878  virtual PBoolean IsCompatibleTransport(
879  const OpalTransportAddress & address
880  ) const = 0;
881 
888  };
889 
900  virtual void SetPromiscuous(
901  PromisciousModes promiscuous
902  );
903 
909 
914  virtual PString GetLastReceivedInterface() const;
915 
925  virtual PBoolean ReadPDU(
926  PBYTEArray & packet
927  ) = 0;
928 
934  virtual PBoolean WritePDU(
935  const PBYTEArray & pdu
936  ) = 0;
937 
938  typedef PNotifierTemplate<bool &> WriteConnectCallback;
939  #define PDECLARE_WriteConnectCallback(cls, fn) PDECLARE_NOTIFIER2(OpalTransport, cls, fn, bool &)
940 
953  virtual bool WriteConnect(
954  const WriteConnectCallback & function
955  );
956 
961  void SetKeepAlive(
962  const PTimeInterval & timeout,
963  const PBYTEArray & data
964  );
965 
968  virtual void AttachThread(
969  PThread * thread
970  );
971 
974  virtual PBoolean IsRunning() const;
976 
977  OpalEndPoint & GetEndPoint() const { return m_endpoint; }
978 
981  virtual const PCaselessString & GetProtoPrefix() const = 0;
982 
983  bool IsOpen() const
984  { return m_channel != NULL && m_channel->IsOpen(); }
985 
986  bool IsGood() const
987  { return IsOpen() && !m_channel->bad() && !m_channel->eof(); }
988 
989  PChannel::Errors GetErrorCode(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const
990  { return m_channel != NULL ? m_channel->GetErrorCode(group) : PChannel::NotOpen; }
991 
992  PString GetErrorText(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const
993  { return m_channel != NULL ? m_channel->GetErrorText(group) : PString::Empty(); }
994 
995  int GetErrorNumber(PChannel::ErrorGroup group = PChannel::NumErrorGroups) const
996  { return m_channel != NULL ? m_channel->GetErrorNumber(group) : -1; }
997 
998  void SetReadTimeout(const PTimeInterval & t)
999  { if (m_channel != NULL) m_channel->SetReadTimeout(t); }
1000 
1001  PChannel * GetChannel() const { return m_channel; }
1002 
1003  bool IsIdle() const { return m_referenceCount == 0 && m_idleTimer.HasExpired(); }
1004 
1007 
1008  protected:
1009  PDECLARE_NOTIFIER(PTimer, OpalTransport, KeepAlive);
1010 
1012  PChannel * m_channel;
1013  PThread * m_thread;
1015  PBYTEArray m_keepAliveData;
1016  PSimpleTimer m_idleTimer;
1017  PAtomicInteger m_referenceCount;
1018 
1019  private:
1020  OpalTransport(const OpalTransport & other) : PSafeObject(other), m_endpoint(other.m_endpoint) { }
1021  void operator=(const OpalTransport &) { }
1022 };
1023 
1024 
1026 {
1027  PCLASSINFO(OpalTransportIP, OpalTransport);
1028  protected:
1034  OpalEndPoint & endpoint,
1035  PChannel * channel,
1036  PIPSocket::Address binding,
1037  WORD port
1038  );
1040 
1041  public:
1046  virtual PString GetInterface() const;
1047 
1050  virtual OpalTransportAddress GetLocalAddress() const;
1051 
1054  virtual OpalTransportAddress GetRemoteAddress() const;
1055 
1061  virtual PBoolean SetRemoteAddress(
1062  const OpalTransportAddress & address
1063  );
1064 
1066 
1067  protected:
1070  virtual const PCaselessString & GetProtoPrefix() const = 0;
1071 
1072  PIPSocketAddressAndPort m_localAP; // Address of the local (NAT adjusted)
1073  PIPSocketAddressAndPort m_remoteAP; // Address of the remote host
1074 };
1075 
1076 
1078 {
1079  PCLASSINFO(OpalTransportTCP, OpalTransportIP);
1080  public:
1086  OpalEndPoint & endpoint,
1087  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1088  WORD port = 0,
1089  bool dummy = false
1090  );
1092  OpalEndPoint & endpoint,
1093  PChannel * socket
1094  );
1095 
1099 
1104  virtual PBoolean IsReliable() const;
1105 
1108  virtual PBoolean IsCompatibleTransport(
1109  const OpalTransportAddress & address
1110  ) const;
1111 
1114  virtual PBoolean Connect();
1115 
1125  virtual PBoolean ReadPDU(
1126  PBYTEArray & pdu
1127  );
1128 
1134  virtual PBoolean WritePDU(
1135  const PBYTEArray & pdu
1136  );
1138 
1152  void SetPDULengthFormat(int fmt,int off)
1153  {
1154  m_pduLengthFormat = fmt;
1155  m_pduLengthOffset = off;
1156  }
1157 
1158  protected:
1161  virtual const PCaselessString & GetProtoPrefix() const;
1162 
1163  bool OnConnectedSocket(PTCPSocket * socket);
1164 
1167 };
1168 
1169 
1171 {
1172  PCLASSINFO(OpalTransportUDP, OpalTransportIP);
1173  public:
1179  OpalEndPoint & endpoint,
1180  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1181  WORD port = 0,
1182  bool reuseAddr = false,
1183  bool preOpen = false
1184  );
1185 
1189  OpalEndPoint & endpoint,
1190  const PMonitoredSocketsPtr & sockets,
1191  const PString & iface
1192  );
1193 
1197 
1200  virtual PBoolean Read(
1201  void * buffer,
1202  PINDEX length
1203  );
1205 
1210  virtual PBoolean IsReliable() const;
1211 
1214  virtual PBoolean IsCompatibleTransport(
1215  const OpalTransportAddress & address
1216  ) const;
1217 
1225  virtual PBoolean Connect();
1226 
1229  virtual PString GetInterface() const;
1230 
1237  virtual bool SetInterface(
1238  const PString & iface
1239  );
1240 
1243  virtual OpalTransportAddress GetLocalAddress() const;
1244 
1250  virtual PBoolean SetRemoteAddress(
1251  const OpalTransportAddress & address
1252  );
1253 
1265  virtual void SetPromiscuous(
1266  PromisciousModes promiscuous
1267  );
1268 
1274 
1279  virtual PString GetLastReceivedInterface() const;
1280 
1290  virtual PBoolean ReadPDU(
1291  PBYTEArray & packet
1292  );
1293 
1299  virtual PBoolean WritePDU(
1300  const PBYTEArray & pdu
1301  );
1302 
1313  virtual bool WriteConnect(
1314  const WriteConnectCallback & function
1315  );
1316 
1320  PINDEX size
1321  ) { m_bufferSize = size; }
1323 
1324  protected:
1327  virtual const PCaselessString & GetProtoPrefix() const;
1328 
1331  PBYTEArray m_preReadPacket;
1333 
1334  friend class OpalListenerUDP;
1335 };
1336 
1337 
1339 
1340 class OpalInternalTransport : public PObject
1341 {
1342  PCLASSINFO(OpalInternalTransport, PObject);
1343  public:
1344  virtual bool Parse(
1345  OpalTransportAddress & address,
1346  WORD port
1347  ) const = 0;
1348 
1349  virtual PString GetHostName(
1350  const OpalTransportAddress & address,
1351  bool includeService
1352  ) const;
1353 
1354  virtual PBoolean GetIpAndPort(
1355  const OpalTransportAddress & address,
1356  PIPSocket::Address & ip,
1357  WORD & port
1358  ) const;
1359 
1360  virtual OpalListener * CreateListener(
1361  const OpalTransportAddress & address,
1362  OpalEndPoint & endpoint,
1364  ) const = 0;
1365 
1366  virtual OpalTransport * CreateTransport(
1367  const OpalTransportAddress & address,
1368  OpalEndPoint & endpoint,
1370  ) const = 0;
1371 };
1372 
1373 
1375 
1377 {
1379  public:
1380  virtual bool Parse(
1381  OpalTransportAddress & address,
1382  WORD port
1383  ) const;
1384  virtual PString GetHostName(
1385  const OpalTransportAddress & address,
1386  bool includeService
1387  ) const;
1388  virtual PBoolean GetIpAndPort(
1389  const OpalTransportAddress & address,
1390  PIPSocket::Address & ip,
1391  WORD & port
1392  ) const;
1393 
1394  static PBoolean GetAdjustedIpAndPort(const OpalTransportAddress & address,
1395  OpalEndPoint & endpoint,
1397  PIPSocketAddressAndPort & ap,
1398  PBoolean & reuseAddr);
1399 };
1400 
1401 template <class ListenerType, class TransportType, unsigned AltTypeOption, class AltTypeClass>
1403 {
1404  public:
1406  const OpalTransportAddress & address,
1407  OpalEndPoint & endpoint,
1409  ) const
1410  {
1411  return new ListenerType(endpoint, address, options);
1412  }
1413 
1415  const OpalTransportAddress & address,
1416  OpalEndPoint & endpoint,
1418  ) const
1419  {
1420  PIPSocketAddressAndPort ap;
1421  PBoolean reuseAddr;
1422  if (GetAdjustedIpAndPort(address, endpoint, options, ap, reuseAddr)) {
1423  if (options == AltTypeOption)
1424  return new AltTypeClass(endpoint, ap.GetAddress(), 0, reuseAddr);
1425  else
1426  return new TransportType(endpoint, ap.GetAddress(), 0, reuseAddr);
1427  }
1428  return NULL;
1429  }
1430 };
1431 
1434 
1435 
1437 
1438 
1439 #if OPAL_PTLIB_SSL
1440 
1441 class PSSLContext;
1442 class PSSLChannel;
1443 
1444 class OpalListenerTLS : public OpalListenerTCP
1445 {
1446  PCLASSINFO(OpalListenerTLS, OpalListenerTCP);
1447  public:
1448  OpalListenerTLS(
1449  OpalEndPoint & endpoint,
1450  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1451  WORD port = 0,
1452  PBoolean exclusive = true
1453  );
1454  OpalListenerTLS(
1455  OpalEndPoint & endpoint,
1456  const OpalTransportAddress & binding,
1458  );
1459 
1462  ~OpalListenerTLS();
1463 
1464  virtual PBoolean Open(const AcceptHandler & acceptHandler, ThreadMode mode = SpawnNewThreadMode);
1465  virtual const PCaselessString & GetProtoPrefix() const;
1466  virtual OpalTransport * CreateTransport(
1467  const OpalTransportAddress & localAddress,
1468  const OpalTransportAddress & remoteAddress
1469  ) const;
1470 
1471  protected:
1472  virtual OpalTransport * OnAccept(PTCPSocket * socket);
1473 
1474  PSSLContext * m_sslContext;
1475 };
1476 
1477 
1478 class OpalTransportTLS : public OpalTransportTCP
1479 {
1480  PCLASSINFO(OpalTransportTLS, OpalTransportTCP);
1481  public:
1482  OpalTransportTLS(
1483  OpalEndPoint & endpoint,
1484  PChannel * ssl
1485  );
1486 
1487  OpalTransportTLS(
1488  OpalEndPoint & endpoint,
1489  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1490  WORD port = 0,
1491  bool dummy = false
1492  );
1493 
1495  ~OpalTransportTLS();
1496 
1497  // Overrides
1498  virtual PBoolean IsCompatibleTransport(const OpalTransportAddress & address) const;
1499  virtual PBoolean Connect();
1500  virtual const PCaselessString & GetProtoPrefix() const;
1501  virtual bool IsAuthenticated(const PString & domain) const;
1502 };
1503 
1504 
1506 
1507 typedef OpalTransportTLS OpalTransportTCPS; // For backward compatibility
1508 typedef OpalListenerTLS OpalListenerTCPS;
1509 
1510 
1512 
1513 #if OPAL_PTLIB_HTTP
1514 
1515 class OpalListenerWS : public OpalListenerTCP
1516 {
1517  PCLASSINFO(OpalListenerWS, OpalListenerTCP);
1518 public:
1523  OpalListenerWS(
1524  OpalEndPoint & endpoint,
1525  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1526  WORD port = 0,
1527  bool exclusive = true
1528  );
1529  OpalListenerWS(
1530  OpalEndPoint & endpoint,
1531  const OpalTransportAddress & binding,
1533  );
1534 
1537  virtual OpalTransport * CreateTransport(
1538  const OpalTransportAddress & localAddress,
1539  const OpalTransportAddress & remoteAddress
1540  ) const;
1541 
1542 protected:
1543  virtual const PCaselessString & GetProtoPrefix() const;
1544  virtual OpalTransport * OnAccept(PTCPSocket * socket);
1545 };
1546 
1547 
1548 class OpalListenerWSS : public OpalListenerTLS
1549 {
1550  PCLASSINFO(OpalListenerWSS, OpalListenerTLS);
1551 public:
1552  OpalListenerWSS(
1553  OpalEndPoint & endpoint,
1554  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1555  WORD port = 0,
1556  PBoolean exclusive = true
1557  );
1558  OpalListenerWSS(
1559  OpalEndPoint & endpoint,
1560  const OpalTransportAddress & binding,
1562  );
1563 
1564  virtual const PCaselessString & GetProtoPrefix() const;
1565 
1566 protected:
1567  virtual OpalTransport * OnAccept(PTCPSocket * socket);
1568 };
1569 
1570 
1571 class OpalTransportWS : public OpalTransportTCP
1572 {
1573  PCLASSINFO(OpalTransportWS, OpalTransportTCP);
1574 public:
1575  OpalTransportWS(
1576  OpalEndPoint & endpoint,
1577  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1578  WORD port = 0,
1579  bool dummy = false
1580  );
1581  OpalTransportWS(
1582  OpalEndPoint & endpoint,
1583  PChannel * socket
1584  );
1585 
1588  virtual PBoolean Connect();
1589 
1599  virtual PBoolean ReadPDU(
1600  PBYTEArray & pdu
1601  );
1602 
1608  virtual PBoolean WritePDU(
1609  const PBYTEArray & pdu
1610  );
1611 
1612  virtual PBoolean IsCompatibleTransport(const OpalTransportAddress & address) const;
1613  virtual const PCaselessString & GetProtoPrefix() const;
1614 };
1615 
1616 
1617 class OpalTransportWSS : public OpalTransportTLS
1618 {
1619  PCLASSINFO(OpalTransportWSS, OpalTransportTLS);
1620 public:
1621  OpalTransportWSS(
1622  OpalEndPoint & endpoint,
1623  PIPSocket::Address binding = PIPSocket::GetDefaultIpAny(),
1624  WORD port = 0,
1625  bool dummy = false
1626  );
1627  OpalTransportWSS(
1628  OpalEndPoint & endpoint,
1629  PChannel * socket
1630  );
1631 
1634  virtual PBoolean Connect();
1635 
1645  virtual PBoolean ReadPDU(
1646  PBYTEArray & pdu
1647  );
1648 
1654  virtual PBoolean WritePDU(
1655  const PBYTEArray & pdu
1656  );
1657 
1658  virtual PBoolean IsCompatibleTransport(const OpalTransportAddress & address) const;
1659  virtual const PCaselessString & GetProtoPrefix() const;
1660 };
1661 
1662 
1665 
1666 
1667 class OpalHTTPConnector : public PHTTPResource
1668 {
1669  PCLASSINFO(OpalHTTPConnector, PHTTPResource)
1670  public:
1671  OpalHTTPConnector(
1672  OpalManager & manager,
1673  const PURL & url
1674  );
1675  OpalHTTPConnector(
1676  OpalManager & manager,
1677  const PURL & url,
1678  const PHTTPAuthority & auth
1679  );
1680 
1681  virtual bool OnWebSocket(PHTTPServer & server, PHTTPConnectionInfo & connectInfo);
1682 
1683  protected:
1684  OpalManager & m_manager;
1685 };
1686 
1687 
1688 #endif // OPAL_PTLIB_HTTP
1689 #endif // OPAL_PTLIB_SSL
1690 
1691 
1692 #endif // OPAL_OPAL_TRANSPORT_H
1693 
1694 
1695 // End of File ///////////////////////////////////////////////////////////////