henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_P2P_BASE_PORT_H_ |
| 12 | #define WEBRTC_P2P_BASE_PORT_H_ |
| 13 | |
| 14 | #include <map> |
| 15 | #include <set> |
| 16 | #include <string> |
| 17 | #include <vector> |
| 18 | |
| 19 | #include "webrtc/p2p/base/candidate.h" |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 20 | #include "webrtc/p2p/base/candidatepairinterface.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 21 | #include "webrtc/p2p/base/packetsocketfactory.h" |
| 22 | #include "webrtc/p2p/base/portinterface.h" |
| 23 | #include "webrtc/p2p/base/stun.h" |
| 24 | #include "webrtc/p2p/base/stunrequest.h" |
| 25 | #include "webrtc/p2p/base/transport.h" |
| 26 | #include "webrtc/base/asyncpacketsocket.h" |
| 27 | #include "webrtc/base/network.h" |
| 28 | #include "webrtc/base/proxyinfo.h" |
| 29 | #include "webrtc/base/ratetracker.h" |
| 30 | #include "webrtc/base/sigslot.h" |
| 31 | #include "webrtc/base/socketaddress.h" |
| 32 | #include "webrtc/base/thread.h" |
| 33 | |
| 34 | namespace cricket { |
| 35 | |
| 36 | class Connection; |
| 37 | class ConnectionRequest; |
| 38 | |
| 39 | extern const char LOCAL_PORT_TYPE[]; |
| 40 | extern const char STUN_PORT_TYPE[]; |
| 41 | extern const char PRFLX_PORT_TYPE[]; |
| 42 | extern const char RELAY_PORT_TYPE[]; |
| 43 | |
| 44 | extern const char UDP_PROTOCOL_NAME[]; |
| 45 | extern const char TCP_PROTOCOL_NAME[]; |
| 46 | extern const char SSLTCP_PROTOCOL_NAME[]; |
| 47 | |
| 48 | // RFC 6544, TCP candidate encoding rules. |
| 49 | extern const int DISCARD_PORT; |
| 50 | extern const char TCPTYPE_ACTIVE_STR[]; |
| 51 | extern const char TCPTYPE_PASSIVE_STR[]; |
| 52 | extern const char TCPTYPE_SIMOPEN_STR[]; |
| 53 | |
Honghai Zhang | 2b342bf | 2015-09-30 09:51:58 -0700 | [diff] [blame] | 54 | // The minimum time we will wait before destroying a connection after creating |
| 55 | // it. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 56 | static const int MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds. |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 57 | |
Honghai Zhang | 2cd7afe | 2015-11-12 11:14:33 -0800 | [diff] [blame] | 58 | // A connection will be declared dead if it has not received anything for this |
| 59 | // long. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 60 | static const int DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds. |
Honghai Zhang | 2cd7afe | 2015-11-12 11:14:33 -0800 | [diff] [blame] | 61 | |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 62 | // The timeout duration when a connection does not receive anything. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 63 | static const int WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 64 | |
| 65 | // The length of time we wait before timing out writability on a connection. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 66 | static const int CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 67 | |
| 68 | // The length of time we wait before we become unwritable. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 69 | static const int CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 70 | |
| 71 | // This is the length of time that we wait for a ping response to come back. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 72 | static const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds |
| 73 | |
| 74 | // The number of pings that must fail to respond before we become unwritable. |
| 75 | static const uint32_t CONNECTION_WRITE_CONNECT_FAILURES = 5; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 76 | |
| 77 | enum RelayType { |
| 78 | RELAY_GTURN, // Legacy google relay service. |
| 79 | RELAY_TURN // Standard (TURN) relay service. |
| 80 | }; |
| 81 | |
| 82 | enum IcePriorityValue { |
| 83 | // The reason we are choosing Relay preference 2 is because, we can run |
| 84 | // Relay from client to server on UDP/TCP/TLS. To distinguish the transport |
| 85 | // protocol, we prefer UDP over TCP over TLS. |
| 86 | // For UDP ICE_TYPE_PREFERENCE_RELAY will be 2. |
| 87 | // For TCP ICE_TYPE_PREFERENCE_RELAY will be 1. |
| 88 | // For TLS ICE_TYPE_PREFERENCE_RELAY will be 0. |
| 89 | // Check turnport.cc for setting these values. |
| 90 | ICE_TYPE_PREFERENCE_RELAY = 2, |
| 91 | ICE_TYPE_PREFERENCE_HOST_TCP = 90, |
| 92 | ICE_TYPE_PREFERENCE_SRFLX = 100, |
| 93 | ICE_TYPE_PREFERENCE_PRFLX = 110, |
| 94 | ICE_TYPE_PREFERENCE_HOST = 126 |
| 95 | }; |
| 96 | |
| 97 | const char* ProtoToString(ProtocolType proto); |
| 98 | bool StringToProto(const char* value, ProtocolType* proto); |
| 99 | |
| 100 | struct ProtocolAddress { |
| 101 | rtc::SocketAddress address; |
| 102 | ProtocolType proto; |
| 103 | bool secure; |
| 104 | |
| 105 | ProtocolAddress(const rtc::SocketAddress& a, ProtocolType p) |
| 106 | : address(a), proto(p), secure(false) { } |
| 107 | ProtocolAddress(const rtc::SocketAddress& a, ProtocolType p, bool sec) |
| 108 | : address(a), proto(p), secure(sec) { } |
| 109 | }; |
| 110 | |
| 111 | typedef std::set<rtc::SocketAddress> ServerAddresses; |
| 112 | |
| 113 | // Represents a local communication mechanism that can be used to create |
| 114 | // connections to similar mechanisms of the other client. Subclasses of this |
| 115 | // one add support for specific mechanisms like local UDP ports. |
| 116 | class Port : public PortInterface, public rtc::MessageHandler, |
| 117 | public sigslot::has_slots<> { |
| 118 | public: |
pkasting@chromium.org | 332331f | 2014-11-06 20:19:22 +0000 | [diff] [blame] | 119 | Port(rtc::Thread* thread, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 120 | rtc::PacketSocketFactory* factory, |
pkasting@chromium.org | 332331f | 2014-11-06 20:19:22 +0000 | [diff] [blame] | 121 | rtc::Network* network, |
| 122 | const rtc::IPAddress& ip, |
| 123 | const std::string& username_fragment, |
| 124 | const std::string& password); |
| 125 | Port(rtc::Thread* thread, |
| 126 | const std::string& type, |
| 127 | rtc::PacketSocketFactory* factory, |
| 128 | rtc::Network* network, |
| 129 | const rtc::IPAddress& ip, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 130 | uint16_t min_port, |
| 131 | uint16_t max_port, |
pkasting@chromium.org | 332331f | 2014-11-06 20:19:22 +0000 | [diff] [blame] | 132 | const std::string& username_fragment, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 133 | const std::string& password); |
| 134 | virtual ~Port(); |
| 135 | |
| 136 | virtual const std::string& Type() const { return type_; } |
| 137 | virtual rtc::Network* Network() const { return network_; } |
| 138 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 139 | // Methods to set/get ICE role and tiebreaker values. |
| 140 | IceRole GetIceRole() const { return ice_role_; } |
| 141 | void SetIceRole(IceRole role) { ice_role_ = role; } |
| 142 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 143 | void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; } |
| 144 | uint64_t IceTiebreaker() const { return tiebreaker_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 145 | |
| 146 | virtual bool SharedSocket() const { return shared_socket_; } |
| 147 | void ResetSharedSocket() { shared_socket_ = false; } |
| 148 | |
| 149 | // The thread on which this port performs its I/O. |
| 150 | rtc::Thread* thread() { return thread_; } |
| 151 | |
| 152 | // The factory used to create the sockets of this port. |
| 153 | rtc::PacketSocketFactory* socket_factory() const { return factory_; } |
| 154 | void set_socket_factory(rtc::PacketSocketFactory* factory) { |
| 155 | factory_ = factory; |
| 156 | } |
| 157 | |
| 158 | // For debugging purposes. |
| 159 | const std::string& content_name() const { return content_name_; } |
| 160 | void set_content_name(const std::string& content_name) { |
| 161 | content_name_ = content_name; |
| 162 | } |
| 163 | |
| 164 | int component() const { return component_; } |
| 165 | void set_component(int component) { component_ = component; } |
| 166 | |
| 167 | bool send_retransmit_count_attribute() const { |
| 168 | return send_retransmit_count_attribute_; |
| 169 | } |
| 170 | void set_send_retransmit_count_attribute(bool enable) { |
| 171 | send_retransmit_count_attribute_ = enable; |
| 172 | } |
| 173 | |
| 174 | // Identifies the generation that this port was created in. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 175 | uint32_t generation() { return generation_; } |
| 176 | void set_generation(uint32_t generation) { generation_ = generation; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 177 | |
| 178 | // ICE requires a single username/password per content/media line. So the |
| 179 | // |ice_username_fragment_| of the ports that belongs to the same content will |
| 180 | // be the same. However this causes a small complication with our relay |
| 181 | // server, which expects different username for RTP and RTCP. |
| 182 | // |
| 183 | // To resolve this problem, we implemented the username_fragment(), |
| 184 | // which returns a different username (calculated from |
| 185 | // |ice_username_fragment_|) for RTCP in the case of ICEPROTO_GOOGLE. And the |
| 186 | // username_fragment() simply returns |ice_username_fragment_| when running |
| 187 | // in ICEPROTO_RFC5245. |
| 188 | // |
| 189 | // As a result the ICEPROTO_GOOGLE will use different usernames for RTP and |
| 190 | // RTCP. And the ICEPROTO_RFC5245 will use same username for both RTP and |
| 191 | // RTCP. |
| 192 | const std::string username_fragment() const; |
| 193 | const std::string& password() const { return password_; } |
| 194 | |
| 195 | // Fired when candidates are discovered by the port. When all candidates |
| 196 | // are discovered that belong to port SignalAddressReady is fired. |
| 197 | sigslot::signal2<Port*, const Candidate&> SignalCandidateReady; |
| 198 | |
| 199 | // Provides all of the above information in one handy object. |
| 200 | virtual const std::vector<Candidate>& Candidates() const { |
| 201 | return candidates_; |
| 202 | } |
| 203 | |
| 204 | // SignalPortComplete is sent when port completes the task of candidates |
| 205 | // allocation. |
| 206 | sigslot::signal1<Port*> SignalPortComplete; |
| 207 | // This signal sent when port fails to allocate candidates and this port |
| 208 | // can't be used in establishing the connections. When port is in shared mode |
| 209 | // and port fails to allocate one of the candidates, port shouldn't send |
| 210 | // this signal as other candidates might be usefull in establishing the |
| 211 | // connection. |
| 212 | sigslot::signal1<Port*> SignalPortError; |
| 213 | |
| 214 | // Returns a map containing all of the connections of this port, keyed by the |
| 215 | // remote address. |
| 216 | typedef std::map<rtc::SocketAddress, Connection*> AddressMap; |
| 217 | const AddressMap& connections() { return connections_; } |
| 218 | |
| 219 | // Returns the connection to the given address or NULL if none exists. |
| 220 | virtual Connection* GetConnection( |
| 221 | const rtc::SocketAddress& remote_addr); |
| 222 | |
| 223 | // Called each time a connection is created. |
| 224 | sigslot::signal2<Port*, Connection*> SignalConnectionCreated; |
| 225 | |
| 226 | // In a shared socket mode each port which shares the socket will decide |
| 227 | // to accept the packet based on the |remote_addr|. Currently only UDP |
| 228 | // port implemented this method. |
| 229 | // TODO(mallinath) - Make it pure virtual. |
| 230 | virtual bool HandleIncomingPacket( |
| 231 | rtc::AsyncPacketSocket* socket, const char* data, size_t size, |
| 232 | const rtc::SocketAddress& remote_addr, |
| 233 | const rtc::PacketTime& packet_time) { |
| 234 | ASSERT(false); |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | // Sends a response message (normal or error) to the given request. One of |
| 239 | // these methods should be called as a response to SignalUnknownAddress. |
| 240 | // NOTE: You MUST call CreateConnection BEFORE SendBindingResponse. |
| 241 | virtual void SendBindingResponse(StunMessage* request, |
| 242 | const rtc::SocketAddress& addr); |
| 243 | virtual void SendBindingErrorResponse( |
| 244 | StunMessage* request, const rtc::SocketAddress& addr, |
| 245 | int error_code, const std::string& reason); |
| 246 | |
| 247 | void set_proxy(const std::string& user_agent, |
| 248 | const rtc::ProxyInfo& proxy) { |
| 249 | user_agent_ = user_agent; |
| 250 | proxy_ = proxy; |
| 251 | } |
| 252 | const std::string& user_agent() { return user_agent_; } |
| 253 | const rtc::ProxyInfo& proxy() { return proxy_; } |
| 254 | |
| 255 | virtual void EnablePortPackets(); |
| 256 | |
| 257 | // Called if the port has no connections and is no longer useful. |
| 258 | void Destroy(); |
| 259 | |
| 260 | virtual void OnMessage(rtc::Message *pmsg); |
| 261 | |
| 262 | // Debugging description of this port |
| 263 | virtual std::string ToString() const; |
pthatcher@webrtc.org | 0ba1533 | 2015-01-10 00:47:02 +0000 | [diff] [blame] | 264 | const rtc::IPAddress& ip() const { return ip_; } |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 265 | uint16_t min_port() { return min_port_; } |
| 266 | uint16_t max_port() { return max_port_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 267 | |
| 268 | // Timeout shortening function to speed up unit tests. |
| 269 | void set_timeout_delay(int delay) { timeout_delay_ = delay; } |
| 270 | |
| 271 | // This method will return local and remote username fragements from the |
| 272 | // stun username attribute if present. |
| 273 | bool ParseStunUsername(const StunMessage* stun_msg, |
| 274 | std::string* local_username, |
Peter Thatcher | 7cbd188 | 2015-09-17 18:54:52 -0700 | [diff] [blame] | 275 | std::string* remote_username) const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 276 | void CreateStunUsername(const std::string& remote_username, |
| 277 | std::string* stun_username_attr_str) const; |
| 278 | |
| 279 | bool MaybeIceRoleConflict(const rtc::SocketAddress& addr, |
| 280 | IceMessage* stun_msg, |
| 281 | const std::string& remote_ufrag); |
| 282 | |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 283 | // Called when a packet has been sent to the socket. |
Stefan Holmer | 55674ff | 2016-01-14 15:49:16 +0100 | [diff] [blame] | 284 | // This is made pure virtual to notify subclasses of Port that they MUST |
| 285 | // listen to AsyncPacketSocket::SignalSentPacket and then call |
| 286 | // PortInterface::OnSentPacket. |
| 287 | virtual void OnSentPacket(rtc::AsyncPacketSocket* socket, |
| 288 | const rtc::SentPacket& sent_packet) = 0; |
stefan | c1aeaf0 | 2015-10-15 07:26:07 -0700 | [diff] [blame] | 289 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 290 | // Called when the socket is currently able to send. |
| 291 | void OnReadyToSend(); |
| 292 | |
| 293 | // Called when the Connection discovers a local peer reflexive candidate. |
| 294 | // Returns the index of the new local candidate. |
| 295 | size_t AddPrflxCandidate(const Candidate& local); |
| 296 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 297 | void set_candidate_filter(uint32_t candidate_filter) { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 298 | candidate_filter_ = candidate_filter; |
| 299 | } |
honghaiz | a0c44ea | 2016-03-23 16:07:48 -0700 | [diff] [blame] | 300 | int16_t network_cost() const { return network_cost_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 301 | |
| 302 | protected: |
| 303 | enum { |
honghaiz | d0b3143 | 2015-09-30 12:42:17 -0700 | [diff] [blame] | 304 | MSG_DEAD = 0, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 305 | MSG_FIRST_AVAILABLE |
| 306 | }; |
| 307 | |
| 308 | void set_type(const std::string& type) { type_ = type; } |
| 309 | |
| 310 | void AddAddress(const rtc::SocketAddress& address, |
| 311 | const rtc::SocketAddress& base_address, |
| 312 | const rtc::SocketAddress& related_address, |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 313 | const std::string& protocol, |
| 314 | const std::string& relay_protocol, |
| 315 | const std::string& tcptype, |
| 316 | const std::string& type, |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 317 | uint32_t type_preference, |
| 318 | uint32_t relay_preference, |
Guo-wei Shieh | 3d564c1 | 2015-08-19 16:51:15 -0700 | [diff] [blame] | 319 | bool final); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 320 | |
| 321 | // Adds the given connection to the list. (Deleting removes them.) |
| 322 | void AddConnection(Connection* conn); |
| 323 | |
| 324 | // Called when a packet is received from an unknown address that is not |
| 325 | // currently a connection. If this is an authenticated STUN binding request, |
| 326 | // then we will signal the client. |
| 327 | void OnReadPacket(const char* data, size_t size, |
| 328 | const rtc::SocketAddress& addr, |
| 329 | ProtocolType proto); |
| 330 | |
| 331 | // If the given data comprises a complete and correct STUN message then the |
| 332 | // return value is true, otherwise false. If the message username corresponds |
| 333 | // with this port's username fragment, msg will contain the parsed STUN |
| 334 | // message. Otherwise, the function may send a STUN response internally. |
| 335 | // remote_username contains the remote fragment of the STUN username. |
kwiberg | 6baec03 | 2016-03-15 11:09:39 -0700 | [diff] [blame] | 336 | bool GetStunMessage(const char* data, |
| 337 | size_t size, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 338 | const rtc::SocketAddress& addr, |
kwiberg | 6baec03 | 2016-03-15 11:09:39 -0700 | [diff] [blame] | 339 | rtc::scoped_ptr<IceMessage>* out_msg, |
| 340 | std::string* out_username); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 341 | |
| 342 | // Checks if the address in addr is compatible with the port's ip. |
| 343 | bool IsCompatibleAddress(const rtc::SocketAddress& addr); |
| 344 | |
| 345 | // Returns default DSCP value. |
| 346 | rtc::DiffServCodePoint DefaultDscpValue() const { |
| 347 | // No change from what MediaChannel set. |
| 348 | return rtc::DSCP_NO_CHANGE; |
| 349 | } |
| 350 | |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 351 | uint32_t candidate_filter() { return candidate_filter_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 352 | |
| 353 | private: |
| 354 | void Construct(); |
| 355 | // Called when one of our connections deletes itself. |
| 356 | void OnConnectionDestroyed(Connection* conn); |
| 357 | |
honghaiz | d0b3143 | 2015-09-30 12:42:17 -0700 | [diff] [blame] | 358 | // Whether this port is dead, and hence, should be destroyed on the controlled |
| 359 | // side. |
| 360 | bool dead() const { |
| 361 | return ice_role_ == ICEROLE_CONTROLLED && connections_.empty(); |
| 362 | } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 363 | |
honghaiz | e3c6c82 | 2016-02-17 13:00:28 -0800 | [diff] [blame] | 364 | void OnNetworkInactive(const rtc::Network* network); |
| 365 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 366 | rtc::Thread* thread_; |
| 367 | rtc::PacketSocketFactory* factory_; |
| 368 | std::string type_; |
| 369 | bool send_retransmit_count_attribute_; |
| 370 | rtc::Network* network_; |
| 371 | rtc::IPAddress ip_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 372 | uint16_t min_port_; |
| 373 | uint16_t max_port_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 374 | std::string content_name_; |
| 375 | int component_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 376 | uint32_t generation_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 377 | // In order to establish a connection to this Port (so that real data can be |
| 378 | // sent through), the other side must send us a STUN binding request that is |
| 379 | // authenticated with this username_fragment and password. |
| 380 | // PortAllocatorSession will provide these username_fragment and password. |
| 381 | // |
| 382 | // Note: we should always use username_fragment() instead of using |
| 383 | // |ice_username_fragment_| directly. For the details see the comment on |
| 384 | // username_fragment(). |
| 385 | std::string ice_username_fragment_; |
| 386 | std::string password_; |
| 387 | std::vector<Candidate> candidates_; |
| 388 | AddressMap connections_; |
| 389 | int timeout_delay_; |
| 390 | bool enable_port_packets_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 391 | IceRole ice_role_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 392 | uint64_t tiebreaker_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 393 | bool shared_socket_; |
| 394 | // Information to use when going through a proxy. |
| 395 | std::string user_agent_; |
| 396 | rtc::ProxyInfo proxy_; |
| 397 | |
| 398 | // Candidate filter is pushed down to Port such that each Port could |
| 399 | // make its own decision on how to create candidates. For example, |
| 400 | // when IceTransportsType is set to relay, both RelayPort and |
| 401 | // TurnPort will hide raddr to avoid local address leakage. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 402 | uint32_t candidate_filter_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 403 | |
honghaiz | e1a0c94 | 2016-02-16 14:54:56 -0800 | [diff] [blame] | 404 | // A virtual cost perceived by the user, usually based on the network type |
| 405 | // (WiFi. vs. Cellular). It takes precedence over the priority when |
| 406 | // comparing two connections. |
honghaiz | a0c44ea | 2016-03-23 16:07:48 -0700 | [diff] [blame] | 407 | uint16_t network_cost_; |
honghaiz | e1a0c94 | 2016-02-16 14:54:56 -0800 | [diff] [blame] | 408 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 409 | friend class Connection; |
| 410 | }; |
| 411 | |
| 412 | // Represents a communication link between a port on the local client and a |
| 413 | // port on the remote client. |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 414 | class Connection : public CandidatePairInterface, |
| 415 | public rtc::MessageHandler, |
| 416 | public sigslot::has_slots<> { |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 417 | public: |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 418 | struct SentPing { |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 419 | SentPing(const std::string id, int64_t sent_time) |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 420 | : id(id), sent_time(sent_time) {} |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 421 | |
| 422 | std::string id; |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 423 | int64_t sent_time; |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 424 | }; |
| 425 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 426 | // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4 |
| 427 | enum State { |
| 428 | STATE_WAITING = 0, // Check has not been performed, Waiting pair on CL. |
| 429 | STATE_INPROGRESS, // Check has been sent, transaction is in progress. |
| 430 | STATE_SUCCEEDED, // Check already done, produced a successful result. |
| 431 | STATE_FAILED // Check for this connection failed. |
| 432 | }; |
| 433 | |
| 434 | virtual ~Connection(); |
| 435 | |
| 436 | // The local port where this connection sends and receives packets. |
| 437 | Port* port() { return port_; } |
| 438 | const Port* port() const { return port_; } |
| 439 | |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 440 | // Implementation of virtual methods in CandidatePairInterface. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 441 | // Returns the description of the local port |
| 442 | virtual const Candidate& local_candidate() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 443 | // Returns the description of the remote port to which we communicate. |
Honghai Zhang | cc411c0 | 2016-03-29 17:27:21 -0700 | [diff] [blame] | 444 | virtual const Candidate& remote_candidate() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 445 | |
| 446 | // Returns the pair priority. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 447 | uint64_t priority() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 448 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 449 | enum WriteState { |
| 450 | STATE_WRITABLE = 0, // we have received ping responses recently |
| 451 | STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures |
| 452 | STATE_WRITE_INIT = 2, // we have yet to receive a ping response |
| 453 | STATE_WRITE_TIMEOUT = 3, // we have had a large number of ping failures |
| 454 | }; |
| 455 | |
| 456 | WriteState write_state() const { return write_state_; } |
| 457 | bool writable() const { return write_state_ == STATE_WRITABLE; } |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 458 | bool receiving() const { return receiving_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 459 | |
| 460 | // Determines whether the connection has finished connecting. This can only |
| 461 | // be false for TCP connections. |
| 462 | bool connected() const { return connected_; } |
Honghai Zhang | 2b342bf | 2015-09-30 09:51:58 -0700 | [diff] [blame] | 463 | bool weak() const { return !(writable() && receiving() && connected()); } |
| 464 | bool active() const { |
Honghai Zhang | 2b342bf | 2015-09-30 09:51:58 -0700 | [diff] [blame] | 465 | return write_state_ != STATE_WRITE_TIMEOUT; |
| 466 | } |
| 467 | // A connection is dead if it can be safely deleted. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 468 | bool dead(int64_t now) const; |
honghaiz | 8937437 | 2015-09-24 13:14:47 -0700 | [diff] [blame] | 469 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 470 | // Estimate of the round-trip time over this connection. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 471 | int rtt() const { return rtt_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 472 | |
| 473 | size_t sent_total_bytes(); |
| 474 | size_t sent_bytes_second(); |
guoweis@webrtc.org | 930e004 | 2014-11-17 19:42:14 +0000 | [diff] [blame] | 475 | // Used to track how many packets are discarded in the application socket due |
| 476 | // to errors. |
| 477 | size_t sent_discarded_packets(); |
| 478 | size_t sent_total_packets(); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 479 | size_t recv_total_bytes(); |
| 480 | size_t recv_bytes_second(); |
| 481 | sigslot::signal1<Connection*> SignalStateChange; |
| 482 | |
| 483 | // Sent when the connection has decided that it is no longer of value. It |
| 484 | // will delete itself immediately after this call. |
| 485 | sigslot::signal1<Connection*> SignalDestroyed; |
| 486 | |
| 487 | // The connection can send and receive packets asynchronously. This matches |
| 488 | // the interface of AsyncPacketSocket, which may use UDP or TCP under the |
| 489 | // covers. |
| 490 | virtual int Send(const void* data, size_t size, |
| 491 | const rtc::PacketOptions& options) = 0; |
| 492 | |
| 493 | // Error if Send() returns < 0 |
| 494 | virtual int GetError() = 0; |
| 495 | |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 496 | sigslot::signal4<Connection*, const char*, size_t, const rtc::PacketTime&> |
| 497 | SignalReadPacket; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 498 | |
| 499 | sigslot::signal1<Connection*> SignalReadyToSend; |
| 500 | |
| 501 | // Called when a packet is received on this connection. |
| 502 | void OnReadPacket(const char* data, size_t size, |
| 503 | const rtc::PacketTime& packet_time); |
| 504 | |
| 505 | // Called when the socket is currently able to send. |
| 506 | void OnReadyToSend(); |
| 507 | |
| 508 | // Called when a connection is determined to be no longer useful to us. We |
| 509 | // still keep it around in case the other side wants to use it. But we can |
| 510 | // safely stop pinging on it and we can allow it to time out if the other |
| 511 | // side stops using it as well. |
| 512 | bool pruned() const { return pruned_; } |
| 513 | void Prune(); |
| 514 | |
| 515 | bool use_candidate_attr() const { return use_candidate_attr_; } |
| 516 | void set_use_candidate_attr(bool enable); |
| 517 | |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 518 | bool nominated() const { return nominated_; } |
| 519 | void set_nominated(bool nominated) { nominated_ = nominated; } |
| 520 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 521 | void set_remote_ice_mode(IceMode mode) { |
| 522 | remote_ice_mode_ = mode; |
| 523 | } |
| 524 | |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 525 | void set_receiving_timeout(int64_t receiving_timeout_ms) { |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 526 | receiving_timeout_ = receiving_timeout_ms; |
| 527 | } |
| 528 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 529 | // Makes the connection go away. |
| 530 | void Destroy(); |
| 531 | |
deadbeef | 376e123 | 2015-11-25 09:00:08 -0800 | [diff] [blame] | 532 | // Makes the connection go away, in a failed state. |
| 533 | void FailAndDestroy(); |
| 534 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 535 | // Checks that the state of this connection is up-to-date. The argument is |
| 536 | // the current time, which is compared against various timeouts. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 537 | void UpdateState(int64_t now); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 538 | |
| 539 | // Called when this connection should try checking writability again. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 540 | int64_t last_ping_sent() const { return last_ping_sent_; } |
| 541 | void Ping(int64_t now); |
Peter Thatcher | 1fe120a | 2015-06-10 11:33:17 -0700 | [diff] [blame] | 542 | void ReceivedPingResponse(); |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 543 | int64_t last_ping_response_received() const { |
Honghai Zhang | 381b421 | 2015-12-04 12:24:03 -0800 | [diff] [blame] | 544 | return last_ping_response_received_; |
| 545 | } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 546 | |
| 547 | // Called whenever a valid ping is received on this connection. This is |
| 548 | // public because the connection intercepts the first ping for us. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 549 | int64_t last_ping_received() const { return last_ping_received_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 550 | void ReceivedPing(); |
honghaiz | 9b5ee9c | 2015-11-11 13:19:17 -0800 | [diff] [blame] | 551 | // Handles the binding request; sends a response if this is a valid request. |
| 552 | void HandleBindingRequest(IceMessage* msg); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 553 | |
| 554 | // Debugging description of this connection |
guoweis@webrtc.org | 8c9ff20 | 2014-12-04 07:56:02 +0000 | [diff] [blame] | 555 | std::string ToDebugId() const; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 556 | std::string ToString() const; |
| 557 | std::string ToSensitiveString() const; |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 558 | // Prints pings_since_last_response_ into a string. |
| 559 | void PrintPingsSinceLastResponse(std::string* pings, size_t max); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 560 | |
| 561 | bool reported() const { return reported_; } |
| 562 | void set_reported(bool reported) { reported_ = reported;} |
| 563 | |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 564 | // This signal will be fired if this connection is nominated by the |
| 565 | // controlling side. |
| 566 | sigslot::signal1<Connection*> SignalNominated; |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 567 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 568 | // Invoked when Connection receives STUN error response with 487 code. |
| 569 | void HandleRoleConflictFromPeer(); |
| 570 | |
| 571 | State state() const { return state_; } |
| 572 | |
| 573 | IceMode remote_ice_mode() const { return remote_ice_mode_; } |
| 574 | |
honghaiz | e1a0c94 | 2016-02-16 14:54:56 -0800 | [diff] [blame] | 575 | uint32_t ComputeNetworkCost() const; |
| 576 | |
Taylor Brandstetter | 0a1bc53 | 2016-04-19 18:03:26 -0700 | [diff] [blame] | 577 | // Update the ICE password and/or generation of the remote candidate if a |
| 578 | // ufrag in |remote_ice_parameters| matches the candidate's ufrag, and the |
| 579 | // candidate's password and/or ufrag has not been set. |
| 580 | // |remote_ice_parameters| should be a list of known ICE parameters ordered |
| 581 | // by generation. |
| 582 | void MaybeSetRemoteIceCredentialsAndGeneration(const std::string& ice_ufrag, |
| 583 | const std::string& ice_pwd, |
| 584 | int generation); |
jiayl@webrtc.org | dacdd94 | 2015-01-23 17:33:34 +0000 | [diff] [blame] | 585 | |
| 586 | // If |remote_candidate_| is peer reflexive and is equivalent to |
| 587 | // |new_candidate| except the type, update |remote_candidate_| to |
| 588 | // |new_candidate|. |
| 589 | void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); |
| 590 | |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 591 | // Returns the last received time of any data, stun request, or stun |
| 592 | // response in milliseconds |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 593 | int64_t last_received() const; |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 594 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 595 | protected: |
Guo-wei Shieh | be508a1 | 2015-04-06 12:48:47 -0700 | [diff] [blame] | 596 | enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; |
| 597 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 598 | // Constructs a new connection to the given remote port. |
| 599 | Connection(Port* port, size_t index, const Candidate& candidate); |
| 600 | |
| 601 | // Called back when StunRequestManager has a stun packet to send |
| 602 | void OnSendStunPacket(const void* data, size_t size, StunRequest* req); |
| 603 | |
| 604 | // Callbacks from ConnectionRequest |
Guo-wei Shieh | be508a1 | 2015-04-06 12:48:47 -0700 | [diff] [blame] | 605 | virtual void OnConnectionRequestResponse(ConnectionRequest* req, |
| 606 | StunMessage* response); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 607 | void OnConnectionRequestErrorResponse(ConnectionRequest* req, |
| 608 | StunMessage* response); |
| 609 | void OnConnectionRequestTimeout(ConnectionRequest* req); |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 610 | void OnConnectionRequestSent(ConnectionRequest* req); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 611 | |
| 612 | // Changes the state and signals if necessary. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 613 | void set_write_state(WriteState value); |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 614 | void set_receiving(bool value); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 615 | void set_state(State state); |
| 616 | void set_connected(bool value); |
| 617 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 618 | void OnMessage(rtc::Message *pmsg); |
| 619 | |
| 620 | Port* port_; |
| 621 | size_t local_candidate_index_; |
| 622 | Candidate remote_candidate_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 623 | WriteState write_state_; |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 624 | bool receiving_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 625 | bool connected_; |
| 626 | bool pruned_; |
| 627 | // By default |use_candidate_attr_| flag will be true, |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 628 | // as we will be using aggressive nomination. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 629 | // But when peer is ice-lite, this flag "must" be initialized to false and |
| 630 | // turn on when connection becomes "best connection". |
| 631 | bool use_candidate_attr_; |
honghaiz | 5a3acd8 | 2015-08-20 15:53:17 -0700 | [diff] [blame] | 632 | // Whether this connection has been nominated by the controlling side via |
| 633 | // the use_candidate attribute. |
| 634 | bool nominated_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 635 | IceMode remote_ice_mode_; |
| 636 | StunRequestManager requests_; |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 637 | int rtt_; |
| 638 | int64_t last_ping_sent_; // last time we sent a ping to the other side |
| 639 | int64_t last_ping_received_; // last time we received a ping from the other |
| 640 | // side |
| 641 | int64_t last_data_received_; |
| 642 | int64_t last_ping_response_received_; |
Peter Thatcher | 1cf6f81 | 2015-05-15 10:40:45 -0700 | [diff] [blame] | 643 | std::vector<SentPing> pings_since_last_response_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 644 | |
| 645 | rtc::RateTracker recv_rate_tracker_; |
| 646 | rtc::RateTracker send_rate_tracker_; |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 647 | uint32_t sent_packets_discarded_; |
| 648 | uint32_t sent_packets_total_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 649 | |
| 650 | private: |
| 651 | void MaybeAddPrflxCandidate(ConnectionRequest* request, |
| 652 | StunMessage* response); |
| 653 | |
| 654 | bool reported_; |
| 655 | State state_; |
Peter Thatcher | 04ac81f | 2015-09-21 11:48:28 -0700 | [diff] [blame] | 656 | // Time duration to switch from receiving to not receiving. |
honghaiz | 34b11eb | 2016-03-16 08:55:44 -0700 | [diff] [blame] | 657 | int receiving_timeout_; |
| 658 | int64_t time_created_ms_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 659 | |
| 660 | friend class Port; |
| 661 | friend class ConnectionRequest; |
| 662 | }; |
| 663 | |
deadbeef | 376e123 | 2015-11-25 09:00:08 -0800 | [diff] [blame] | 664 | // ProxyConnection defers all the interesting work to the port. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 665 | class ProxyConnection : public Connection { |
| 666 | public: |
deadbeef | 376e123 | 2015-11-25 09:00:08 -0800 | [diff] [blame] | 667 | ProxyConnection(Port* port, size_t index, const Candidate& remote_candidate); |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 668 | |
deadbeef | 376e123 | 2015-11-25 09:00:08 -0800 | [diff] [blame] | 669 | int Send(const void* data, |
| 670 | size_t size, |
| 671 | const rtc::PacketOptions& options) override; |
| 672 | int GetError() override { return error_; } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 673 | |
| 674 | private: |
deadbeef | 376e123 | 2015-11-25 09:00:08 -0800 | [diff] [blame] | 675 | int error_ = 0; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 676 | }; |
| 677 | |
| 678 | } // namespace cricket |
| 679 | |
| 680 | #endif // WEBRTC_P2P_BASE_PORT_H_ |