OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ | 11 #ifndef WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ |
12 #define WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ | 12 #define WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ |
13 | 13 |
14 #include "webrtc/rtc_base/constructormagic.h" | 14 #include "webrtc/rtc_base/constructormagic.h" |
15 #include "webrtc/rtc_base/proxyinfo.h" | 15 #include "webrtc/rtc_base/proxyinfo.h" |
16 | 16 |
17 namespace rtc { | 17 namespace rtc { |
18 | 18 |
| 19 // This structure contains options required to create TCP packet sockets. |
| 20 struct PacketSocketTcpOptions { |
| 21 int opts; |
| 22 std::vector<std::string> tls_alpn_protocols; |
| 23 }; |
| 24 |
19 class AsyncPacketSocket; | 25 class AsyncPacketSocket; |
20 class AsyncResolverInterface; | 26 class AsyncResolverInterface; |
21 | 27 |
22 class PacketSocketFactory { | 28 class PacketSocketFactory { |
23 public: | 29 public: |
24 enum Options { | 30 enum Options { |
25 OPT_STUN = 0x04, | 31 OPT_STUN = 0x04, |
26 | 32 |
27 // The TLS options below are mutually exclusive. | 33 // The TLS options below are mutually exclusive. |
28 OPT_TLS = 0x02, // Real and secure TLS. | 34 OPT_TLS = 0x02, // Real and secure TLS. |
29 OPT_TLS_FAKE = 0x01, // Fake TLS with a dummy SSL handshake. | 35 OPT_TLS_FAKE = 0x01, // Fake TLS with a dummy SSL handshake. |
30 OPT_TLS_INSECURE = 0x08, // Insecure TLS without certificate validation. | 36 OPT_TLS_INSECURE = 0x08, // Insecure TLS without certificate validation. |
31 | 37 |
32 // Deprecated, use OPT_TLS_FAKE. | 38 // Deprecated, use OPT_TLS_FAKE. |
33 OPT_SSLTCP = OPT_TLS_FAKE, | 39 OPT_SSLTCP = OPT_TLS_FAKE, |
34 }; | 40 }; |
35 | 41 |
36 PacketSocketFactory() { } | 42 PacketSocketFactory() { } |
37 virtual ~PacketSocketFactory() { } | 43 virtual ~PacketSocketFactory() { } |
38 | 44 |
39 virtual AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, | 45 virtual AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, |
40 uint16_t min_port, | 46 uint16_t min_port, |
41 uint16_t max_port) = 0; | 47 uint16_t max_port) = 0; |
42 virtual AsyncPacketSocket* CreateServerTcpSocket( | 48 virtual AsyncPacketSocket* CreateServerTcpSocket( |
43 const SocketAddress& local_address, | 49 const SocketAddress& local_address, |
44 uint16_t min_port, | 50 uint16_t min_port, |
45 uint16_t max_port, | 51 uint16_t max_port, |
46 int opts) = 0; | 52 int opts) = 0; |
47 | 53 |
48 // TODO: |proxy_info| and |user_agent| should be set | 54 // TODO(deadbeef): |proxy_info| and |user_agent| should be set |
49 // per-factory and not when socket is created. | 55 // per-factory and not when socket is created. |
50 virtual AsyncPacketSocket* CreateClientTcpSocket( | 56 virtual AsyncPacketSocket* CreateClientTcpSocket( |
51 const SocketAddress& local_address, | 57 const SocketAddress& local_address, |
52 const SocketAddress& remote_address, | 58 const SocketAddress& remote_address, |
53 const ProxyInfo& proxy_info, | 59 const ProxyInfo& proxy_info, |
54 const std::string& user_agent, | 60 const std::string& user_agent, |
55 int opts) = 0; | 61 int opts) = 0; |
56 | 62 |
| 63 // TODO(deadbeef): |proxy_info|, |user_agent| and |tcp_options| should |
| 64 // be set per-factory and not when socket is created. |
| 65 // TODO(deadbeef): Implement this method in all subclasses (namely those in |
| 66 // Chromium), make pure virtual, and remove the old CreateClientTcpSocket. |
| 67 virtual AsyncPacketSocket* CreateClientTcpSocket( |
| 68 const SocketAddress& local_address, |
| 69 const SocketAddress& remote_address, |
| 70 const ProxyInfo& proxy_info, |
| 71 const std::string& user_agent, |
| 72 const PacketSocketTcpOptions& tcp_options) { |
| 73 return CreateClientTcpSocket(local_address, remote_address, proxy_info, |
| 74 user_agent, tcp_options.opts); |
| 75 } |
| 76 |
| 77 |
57 virtual AsyncResolverInterface* CreateAsyncResolver() = 0; | 78 virtual AsyncResolverInterface* CreateAsyncResolver() = 0; |
58 | 79 |
59 private: | 80 private: |
60 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSocketFactory); | 81 RTC_DISALLOW_COPY_AND_ASSIGN(PacketSocketFactory); |
61 }; | 82 }; |
62 | 83 |
63 } // namespace rtc | 84 } // namespace rtc |
64 | 85 |
65 #endif // WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ | 86 #endif // WEBRTC_P2P_BASE_PACKETSOCKETFACTORY_H_ |
OLD | NEW |