OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 UDPPort* port = | 64 UDPPort* port = |
65 new UDPPort(thread, factory, network, ip, min_port, max_port, username, | 65 new UDPPort(thread, factory, network, ip, min_port, max_port, username, |
66 password, origin, emit_local_for_anyaddress); | 66 password, origin, emit_local_for_anyaddress); |
67 if (!port->Init()) { | 67 if (!port->Init()) { |
68 delete port; | 68 delete port; |
69 port = NULL; | 69 port = NULL; |
70 } | 70 } |
71 return port; | 71 return port; |
72 } | 72 } |
73 | 73 |
74 virtual ~UDPPort(); | 74 ~UDPPort() override; |
75 | 75 |
76 rtc::SocketAddress GetLocalAddress() const { | 76 rtc::SocketAddress GetLocalAddress() const { |
77 return socket_->GetLocalAddress(); | 77 return socket_->GetLocalAddress(); |
78 } | 78 } |
79 | 79 |
80 const ServerAddresses& server_addresses() const { | 80 const ServerAddresses& server_addresses() const { |
81 return server_addresses_; | 81 return server_addresses_; |
82 } | 82 } |
83 void | 83 void set_server_addresses(const ServerAddresses& addresses) { |
84 set_server_addresses(const ServerAddresses& addresses) { | |
85 server_addresses_ = addresses; | 84 server_addresses_ = addresses; |
86 } | 85 } |
87 | 86 |
88 virtual void PrepareAddress(); | 87 void PrepareAddress() override; |
89 | 88 |
90 virtual Connection* CreateConnection(const Candidate& address, | 89 Connection* CreateConnection(const Candidate& address, |
91 CandidateOrigin origin); | 90 CandidateOrigin origin, |
92 virtual int SetOption(rtc::Socket::Option opt, int value); | 91 const IceConfig& config) override; |
93 virtual int GetOption(rtc::Socket::Option opt, int* value); | 92 int SetOption(rtc::Socket::Option opt, int value) override; |
94 virtual int GetError(); | 93 int GetOption(rtc::Socket::Option opt, int* value) override; |
| 94 int GetError() override; |
95 | 95 |
96 virtual bool HandleIncomingPacket( | 96 bool HandleIncomingPacket(rtc::AsyncPacketSocket* socket, |
97 rtc::AsyncPacketSocket* socket, const char* data, size_t size, | 97 const char* data, |
98 const rtc::SocketAddress& remote_addr, | 98 size_t size, |
99 const rtc::PacketTime& packet_time) { | 99 const rtc::SocketAddress& remote_addr, |
| 100 const rtc::PacketTime& packet_time) override { |
100 // All packets given to UDP port will be consumed. | 101 // All packets given to UDP port will be consumed. |
101 OnReadPacket(socket, data, size, remote_addr, packet_time); | 102 OnReadPacket(socket, data, size, remote_addr, packet_time); |
102 return true; | 103 return true; |
103 } | 104 } |
104 virtual bool SupportsProtocol(const std::string& protocol) const { | 105 bool SupportsProtocol(const std::string& protocol) const override { |
105 return protocol == UDP_PROTOCOL_NAME; | 106 return protocol == UDP_PROTOCOL_NAME; |
106 } | 107 } |
107 | 108 |
108 void set_stun_keepalive_delay(int delay) { | 109 void set_stun_keepalive_delay(int delay) { |
109 stun_keepalive_delay_ = delay; | 110 stun_keepalive_delay_ = delay; |
110 } | 111 } |
111 int stun_keepalive_delay() const { | 112 int stun_keepalive_delay() const { |
112 return stun_keepalive_delay_; | 113 return stun_keepalive_delay_; |
113 } | 114 } |
114 | 115 |
(...skipping 23 matching lines...) Expand all Loading... |
138 rtc::PacketSocketFactory* factory, | 139 rtc::PacketSocketFactory* factory, |
139 rtc::Network* network, | 140 rtc::Network* network, |
140 rtc::AsyncPacketSocket* socket, | 141 rtc::AsyncPacketSocket* socket, |
141 const std::string& username, | 142 const std::string& username, |
142 const std::string& password, | 143 const std::string& password, |
143 const std::string& origin, | 144 const std::string& origin, |
144 bool emit_local_for_anyaddress); | 145 bool emit_local_for_anyaddress); |
145 | 146 |
146 bool Init(); | 147 bool Init(); |
147 | 148 |
148 virtual int SendTo(const void* data, size_t size, | 149 int SendTo(const void* data, |
149 const rtc::SocketAddress& addr, | 150 size_t size, |
150 const rtc::PacketOptions& options, | 151 const rtc::SocketAddress& addr, |
151 bool payload); | 152 const rtc::PacketOptions& options, |
| 153 bool payload) override; |
152 | 154 |
153 virtual void UpdateNetworkCost(); | 155 void UpdateNetworkCost() override; |
154 | 156 |
155 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, | 157 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, |
156 const rtc::SocketAddress& address); | 158 const rtc::SocketAddress& address); |
157 void OnReadPacket(rtc::AsyncPacketSocket* socket, | 159 void OnReadPacket(rtc::AsyncPacketSocket* socket, |
158 const char* data, size_t size, | 160 const char* data, size_t size, |
159 const rtc::SocketAddress& remote_addr, | 161 const rtc::SocketAddress& remote_addr, |
160 const rtc::PacketTime& packet_time); | 162 const rtc::PacketTime& packet_time); |
161 | 163 |
162 void OnSentPacket(rtc::AsyncPacketSocket* socket, | 164 void OnSentPacket(rtc::AsyncPacketSocket* socket, |
163 const rtc::SentPacket& sent_packet); | 165 const rtc::SentPacket& sent_packet) override; |
164 | 166 |
165 void OnReadyToSend(rtc::AsyncPacketSocket* socket); | 167 void OnReadyToSend(rtc::AsyncPacketSocket* socket); |
166 | 168 |
167 // This method will send STUN binding request if STUN server address is set. | 169 // This method will send STUN binding request if STUN server address is set. |
168 void MaybePrepareStunCandidate(); | 170 void MaybePrepareStunCandidate(); |
169 | 171 |
170 void SendStunBindingRequests(); | 172 void SendStunBindingRequests(); |
171 | 173 |
172 // Helper function which will set |addr|'s IP to the default local address if | 174 // Helper function which will set |addr|'s IP to the default local address if |
173 // |addr| is the "any" address and |emit_local_for_anyaddress_| is true. When | 175 // |addr| is the "any" address and |emit_local_for_anyaddress_| is true. When |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 ip, min_port, max_port, | 271 ip, min_port, max_port, |
270 username, password, servers, | 272 username, password, servers, |
271 origin); | 273 origin); |
272 if (!port->Init()) { | 274 if (!port->Init()) { |
273 delete port; | 275 delete port; |
274 port = NULL; | 276 port = NULL; |
275 } | 277 } |
276 return port; | 278 return port; |
277 } | 279 } |
278 | 280 |
279 virtual ~StunPort() {} | 281 ~StunPort() override {} |
280 | 282 |
281 virtual void PrepareAddress() { | 283 void PrepareAddress() override { SendStunBindingRequests(); } |
282 SendStunBindingRequests(); | |
283 } | |
284 | 284 |
285 protected: | 285 protected: |
286 StunPort(rtc::Thread* thread, | 286 StunPort(rtc::Thread* thread, |
287 rtc::PacketSocketFactory* factory, | 287 rtc::PacketSocketFactory* factory, |
288 rtc::Network* network, | 288 rtc::Network* network, |
289 const rtc::IPAddress& ip, | 289 const rtc::IPAddress& ip, |
290 uint16_t min_port, | 290 uint16_t min_port, |
291 uint16_t max_port, | 291 uint16_t max_port, |
292 const std::string& username, | 292 const std::string& username, |
293 const std::string& password, | 293 const std::string& password, |
(...skipping 11 matching lines...) Expand all Loading... |
305 false) { | 305 false) { |
306 // UDPPort will set these to local udp, updating these to STUN. | 306 // UDPPort will set these to local udp, updating these to STUN. |
307 set_type(STUN_PORT_TYPE); | 307 set_type(STUN_PORT_TYPE); |
308 set_server_addresses(servers); | 308 set_server_addresses(servers); |
309 } | 309 } |
310 }; | 310 }; |
311 | 311 |
312 } // namespace cricket | 312 } // namespace cricket |
313 | 313 |
314 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 314 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
OLD | NEW |