2014-10-28 22:20:11 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2011 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef P2P_BASE_PACKETSOCKETFACTORY_H_
|
|
|
|
|
#define P2P_BASE_PACKETSOCKETFACTORY_H_
|
2014-10-28 22:20:11 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/constructormagic.h"
|
|
|
|
|
#include "rtc_base/proxyinfo.h"
|
2014-10-28 22:20:11 +00:00
|
|
|
|
|
|
|
|
namespace rtc {
|
|
|
|
|
|
2017-08-29 12:18:32 -07:00
|
|
|
// This structure contains options required to create TCP packet sockets.
|
|
|
|
|
struct PacketSocketTcpOptions {
|
2017-10-25 14:46:18 -07:00
|
|
|
PacketSocketTcpOptions();
|
|
|
|
|
~PacketSocketTcpOptions();
|
|
|
|
|
|
2017-10-26 11:23:08 -07:00
|
|
|
int opts = 0;
|
2017-08-29 12:18:32 -07:00
|
|
|
std::vector<std::string> tls_alpn_protocols;
|
2017-09-08 12:50:41 -07:00
|
|
|
std::vector<std::string> tls_elliptic_curves;
|
2017-08-29 12:18:32 -07:00
|
|
|
};
|
|
|
|
|
|
2014-10-28 22:20:11 +00:00
|
|
|
class AsyncPacketSocket;
|
|
|
|
|
class AsyncResolverInterface;
|
|
|
|
|
|
|
|
|
|
class PacketSocketFactory {
|
|
|
|
|
public:
|
|
|
|
|
enum Options {
|
|
|
|
|
OPT_STUN = 0x04,
|
2017-01-09 08:35:45 -08:00
|
|
|
|
|
|
|
|
// The TLS options below are mutually exclusive.
|
|
|
|
|
OPT_TLS = 0x02, // Real and secure TLS.
|
|
|
|
|
OPT_TLS_FAKE = 0x01, // Fake TLS with a dummy SSL handshake.
|
|
|
|
|
OPT_TLS_INSECURE = 0x08, // Insecure TLS without certificate validation.
|
|
|
|
|
|
|
|
|
|
// Deprecated, use OPT_TLS_FAKE.
|
|
|
|
|
OPT_SSLTCP = OPT_TLS_FAKE,
|
2014-10-28 22:20:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PacketSocketFactory() { }
|
2017-10-26 11:23:08 -07:00
|
|
|
virtual ~PacketSocketFactory() = default;
|
2014-10-28 22:20:11 +00:00
|
|
|
|
2014-11-06 20:19:22 +00:00
|
|
|
virtual AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint16_t min_port,
|
|
|
|
|
uint16_t max_port) = 0;
|
2014-10-28 22:20:11 +00:00
|
|
|
virtual AsyncPacketSocket* CreateServerTcpSocket(
|
2014-11-06 20:19:22 +00:00
|
|
|
const SocketAddress& local_address,
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint16_t min_port,
|
|
|
|
|
uint16_t max_port,
|
2014-10-28 22:20:11 +00:00
|
|
|
int opts) = 0;
|
|
|
|
|
|
2017-08-29 12:18:32 -07:00
|
|
|
// TODO(deadbeef): |proxy_info| and |user_agent| should be set
|
2014-10-28 22:20:11 +00:00
|
|
|
// per-factory and not when socket is created.
|
|
|
|
|
virtual AsyncPacketSocket* CreateClientTcpSocket(
|
2014-11-06 20:19:22 +00:00
|
|
|
const SocketAddress& local_address,
|
|
|
|
|
const SocketAddress& remote_address,
|
|
|
|
|
const ProxyInfo& proxy_info,
|
|
|
|
|
const std::string& user_agent,
|
|
|
|
|
int opts) = 0;
|
2014-10-28 22:20:11 +00:00
|
|
|
|
2017-08-29 12:18:32 -07:00
|
|
|
// TODO(deadbeef): |proxy_info|, |user_agent| and |tcp_options| should
|
|
|
|
|
// be set per-factory and not when socket is created.
|
|
|
|
|
// TODO(deadbeef): Implement this method in all subclasses (namely those in
|
|
|
|
|
// Chromium), make pure virtual, and remove the old CreateClientTcpSocket.
|
|
|
|
|
virtual AsyncPacketSocket* CreateClientTcpSocket(
|
|
|
|
|
const SocketAddress& local_address,
|
|
|
|
|
const SocketAddress& remote_address,
|
|
|
|
|
const ProxyInfo& proxy_info,
|
|
|
|
|
const std::string& user_agent,
|
2017-10-25 14:46:18 -07:00
|
|
|
const PacketSocketTcpOptions& tcp_options);
|
2017-08-29 12:18:32 -07:00
|
|
|
|
2014-10-28 22:20:11 +00:00
|
|
|
virtual AsyncResolverInterface* CreateAsyncResolver() = 0;
|
|
|
|
|
|
|
|
|
|
private:
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(PacketSocketFactory);
|
2014-10-28 22:20:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace rtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // P2P_BASE_PACKETSOCKETFACTORY_H_
|