henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #include "rtc_base/win32socketserver.h" |
andresp@webrtc.org | ff689be | 2015-02-12 11:54:26 | [diff] [blame] | 12 | |
andresp@webrtc.org | ff689be | 2015-02-12 11:54:26 | [diff] [blame] | 13 | #include <ws2tcpip.h> // NOLINT |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 14 | #include <algorithm> |
andresp@webrtc.org | ff689be | 2015-02-12 11:54:26 | [diff] [blame] | 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 16 | #include "rtc_base/byteorder.h" |
| 17 | #include "rtc_base/checks.h" |
| 18 | #include "rtc_base/logging.h" |
| 19 | #include "rtc_base/win32window.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 20 | |
| 21 | namespace rtc { |
| 22 | |
| 23 | /////////////////////////////////////////////////////////////////////////////// |
| 24 | // Win32Socket |
| 25 | /////////////////////////////////////////////////////////////////////////////// |
| 26 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 27 | // TODO: Enable for production builds also? Use FormatMessage? |
tfarina | a41ab93 | 2015-10-30 23:08:48 | [diff] [blame] | 28 | #if !defined(NDEBUG) |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 29 | LPCSTR WSAErrorToString(int error, LPCSTR* description_result) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 30 | LPCSTR string = "Unspecified"; |
| 31 | LPCSTR description = "Unspecified description"; |
| 32 | switch (error) { |
| 33 | case ERROR_SUCCESS: |
| 34 | string = "SUCCESS"; |
| 35 | description = "Operation succeeded"; |
| 36 | break; |
| 37 | case WSAEWOULDBLOCK: |
| 38 | string = "WSAEWOULDBLOCK"; |
| 39 | description = "Using a non-blocking socket, will notify later"; |
| 40 | break; |
| 41 | case WSAEACCES: |
| 42 | string = "WSAEACCES"; |
| 43 | description = "Access denied, or sharing violation"; |
| 44 | break; |
| 45 | case WSAEADDRNOTAVAIL: |
| 46 | string = "WSAEADDRNOTAVAIL"; |
| 47 | description = "Address is not valid in this context"; |
| 48 | break; |
| 49 | case WSAENETDOWN: |
| 50 | string = "WSAENETDOWN"; |
| 51 | description = "Network is down"; |
| 52 | break; |
| 53 | case WSAENETUNREACH: |
| 54 | string = "WSAENETUNREACH"; |
| 55 | description = "Network is up, but unreachable"; |
| 56 | break; |
| 57 | case WSAENETRESET: |
| 58 | string = "WSANETRESET"; |
| 59 | description = "Connection has been reset due to keep-alive activity"; |
| 60 | break; |
| 61 | case WSAECONNABORTED: |
| 62 | string = "WSAECONNABORTED"; |
| 63 | description = "Aborted by host"; |
| 64 | break; |
| 65 | case WSAECONNRESET: |
| 66 | string = "WSAECONNRESET"; |
| 67 | description = "Connection reset by host"; |
| 68 | break; |
| 69 | case WSAETIMEDOUT: |
| 70 | string = "WSAETIMEDOUT"; |
| 71 | description = "Timed out, host failed to respond"; |
| 72 | break; |
| 73 | case WSAECONNREFUSED: |
| 74 | string = "WSAECONNREFUSED"; |
| 75 | description = "Host actively refused connection"; |
| 76 | break; |
| 77 | case WSAEHOSTDOWN: |
| 78 | string = "WSAEHOSTDOWN"; |
| 79 | description = "Host is down"; |
| 80 | break; |
| 81 | case WSAEHOSTUNREACH: |
| 82 | string = "WSAEHOSTUNREACH"; |
| 83 | description = "Host is unreachable"; |
| 84 | break; |
| 85 | case WSAHOST_NOT_FOUND: |
| 86 | string = "WSAHOST_NOT_FOUND"; |
| 87 | description = "No such host is known"; |
| 88 | break; |
| 89 | } |
| 90 | if (description_result) { |
| 91 | *description_result = description; |
| 92 | } |
| 93 | return string; |
| 94 | } |
| 95 | |
| 96 | void ReportWSAError(LPCSTR context, int error, const SocketAddress& address) { |
| 97 | LPCSTR description_string; |
| 98 | LPCSTR error_string = WSAErrorToString(error, &description_string); |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 99 | RTC_LOG(LS_INFO) << context << " = " << error << " (" << error_string << ":" |
| 100 | << description_string << ") [" << address.ToString() << "]"; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 101 | } |
| 102 | #else |
| 103 | void ReportWSAError(LPCSTR context, int error, const SocketAddress& address) {} |
| 104 | #endif |
| 105 | |
| 106 | ///////////////////////////////////////////////////////////////////////////// |
| 107 | // Win32Socket::EventSink |
| 108 | ///////////////////////////////////////////////////////////////////////////// |
| 109 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 110 | #define WM_SOCKETNOTIFY (WM_USER + 50) |
| 111 | #define WM_DNSNOTIFY (WM_USER + 51) |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 112 | |
| 113 | struct Win32Socket::DnsLookup { |
| 114 | HANDLE handle; |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 115 | uint16_t port; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 116 | char buffer[MAXGETHOSTSTRUCT]; |
| 117 | }; |
| 118 | |
| 119 | class Win32Socket::EventSink : public Win32Window { |
| 120 | public: |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 121 | explicit EventSink(Win32Socket* parent) : parent_(parent) {} |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 122 | |
| 123 | void Dispose(); |
| 124 | |
Steve Anton | 9de3aac | 2017-10-24 17:08:26 | [diff] [blame] | 125 | bool OnMessage(UINT uMsg, |
| 126 | WPARAM wParam, |
| 127 | LPARAM lParam, |
| 128 | LRESULT& result) override; |
| 129 | void OnNcDestroy() override; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 130 | |
| 131 | private: |
| 132 | bool OnSocketNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& result); |
| 133 | bool OnDnsNotify(WPARAM wParam, LPARAM lParam, LRESULT& result); |
| 134 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 135 | Win32Socket* parent_; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | void Win32Socket::EventSink::Dispose() { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 139 | parent_ = nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 140 | if (::IsWindow(handle())) { |
| 141 | ::DestroyWindow(handle()); |
| 142 | } else { |
| 143 | delete this; |
| 144 | } |
| 145 | } |
| 146 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 147 | bool Win32Socket::EventSink::OnMessage(UINT uMsg, |
| 148 | WPARAM wParam, |
| 149 | LPARAM lParam, |
| 150 | LRESULT& result) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 151 | switch (uMsg) { |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 152 | case WM_SOCKETNOTIFY: |
| 153 | case WM_TIMER: |
| 154 | return OnSocketNotify(uMsg, wParam, lParam, result); |
| 155 | case WM_DNSNOTIFY: |
| 156 | return OnDnsNotify(wParam, lParam, result); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 157 | } |
| 158 | return false; |
| 159 | } |
| 160 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 161 | bool Win32Socket::EventSink::OnSocketNotify(UINT uMsg, |
| 162 | WPARAM wParam, |
| 163 | LPARAM lParam, |
| 164 | LRESULT& result) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 165 | result = 0; |
| 166 | |
| 167 | int wsa_event = WSAGETSELECTEVENT(lParam); |
| 168 | int wsa_error = WSAGETSELECTERROR(lParam); |
| 169 | |
| 170 | // Treat connect timeouts as close notifications |
| 171 | if (uMsg == WM_TIMER) { |
| 172 | wsa_event = FD_CLOSE; |
| 173 | wsa_error = WSAETIMEDOUT; |
| 174 | } |
| 175 | |
| 176 | if (parent_) |
| 177 | parent_->OnSocketNotify(static_cast<SOCKET>(wParam), wsa_event, wsa_error); |
| 178 | return true; |
| 179 | } |
| 180 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 181 | bool Win32Socket::EventSink::OnDnsNotify(WPARAM wParam, |
| 182 | LPARAM lParam, |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 183 | LRESULT& result) { |
| 184 | result = 0; |
| 185 | |
| 186 | int error = WSAGETASYNCERROR(lParam); |
| 187 | if (parent_) |
| 188 | parent_->OnDnsNotify(reinterpret_cast<HANDLE>(wParam), error); |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | void Win32Socket::EventSink::OnNcDestroy() { |
| 193 | if (parent_) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 194 | RTC_LOG(LS_ERROR) << "EventSink hwnd is being destroyed, but the event sink" |
| 195 | " hasn't yet been disposed."; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 196 | } else { |
| 197 | delete this; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | ///////////////////////////////////////////////////////////////////////////// |
| 202 | // Win32Socket |
| 203 | ///////////////////////////////////////////////////////////////////////////// |
| 204 | |
| 205 | Win32Socket::Win32Socket() |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 206 | : socket_(INVALID_SOCKET), |
| 207 | error_(0), |
| 208 | state_(CS_CLOSED), |
| 209 | connect_time_(0), |
| 210 | closing_(false), |
| 211 | close_error_(0), |
| 212 | sink_(nullptr), |
| 213 | dns_(nullptr) {} |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 214 | |
| 215 | Win32Socket::~Win32Socket() { |
| 216 | Close(); |
| 217 | } |
| 218 | |
| 219 | bool Win32Socket::CreateT(int family, int type) { |
| 220 | Close(); |
| 221 | int proto = (SOCK_DGRAM == type) ? IPPROTO_UDP : IPPROTO_TCP; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 222 | socket_ = ::WSASocket(family, type, proto, nullptr, 0, 0); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 223 | if (socket_ == INVALID_SOCKET) { |
| 224 | UpdateLastError(); |
| 225 | return false; |
| 226 | } |
| 227 | if ((SOCK_DGRAM == type) && !SetAsync(FD_READ | FD_WRITE)) { |
| 228 | return false; |
| 229 | } |
| 230 | return true; |
| 231 | } |
| 232 | |
| 233 | int Win32Socket::Attach(SOCKET s) { |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 234 | RTC_DCHECK(socket_ == INVALID_SOCKET); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 235 | if (socket_ != INVALID_SOCKET) |
| 236 | return SOCKET_ERROR; |
| 237 | |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 238 | RTC_DCHECK(s != INVALID_SOCKET); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 239 | if (s == INVALID_SOCKET) |
| 240 | return SOCKET_ERROR; |
| 241 | |
| 242 | socket_ = s; |
| 243 | state_ = CS_CONNECTED; |
| 244 | |
| 245 | if (!SetAsync(FD_READ | FD_WRITE | FD_CLOSE)) |
| 246 | return SOCKET_ERROR; |
| 247 | |
| 248 | return 0; |
| 249 | } |
| 250 | |
| 251 | void Win32Socket::SetTimeout(int ms) { |
| 252 | if (sink_) |
| 253 | ::SetTimer(sink_->handle(), 1, ms, 0); |
| 254 | } |
| 255 | |
| 256 | SocketAddress Win32Socket::GetLocalAddress() const { |
| 257 | sockaddr_storage addr = {0}; |
| 258 | socklen_t addrlen = sizeof(addr); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 259 | int result = |
| 260 | ::getsockname(socket_, reinterpret_cast<sockaddr*>(&addr), &addrlen); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 261 | SocketAddress address; |
| 262 | if (result >= 0) { |
| 263 | SocketAddressFromSockAddrStorage(addr, &address); |
| 264 | } else { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 265 | RTC_LOG(LS_WARNING) << "GetLocalAddress: unable to get local addr, socket=" |
| 266 | << socket_; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 267 | } |
| 268 | return address; |
| 269 | } |
| 270 | |
| 271 | SocketAddress Win32Socket::GetRemoteAddress() const { |
| 272 | sockaddr_storage addr = {0}; |
| 273 | socklen_t addrlen = sizeof(addr); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 274 | int result = |
| 275 | ::getpeername(socket_, reinterpret_cast<sockaddr*>(&addr), &addrlen); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 276 | SocketAddress address; |
| 277 | if (result >= 0) { |
| 278 | SocketAddressFromSockAddrStorage(addr, &address); |
| 279 | } else { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 280 | RTC_LOG(LS_WARNING) |
| 281 | << "GetRemoteAddress: unable to get remote addr, socket=" << socket_; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 282 | } |
| 283 | return address; |
| 284 | } |
| 285 | |
| 286 | int Win32Socket::Bind(const SocketAddress& addr) { |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 287 | RTC_DCHECK(socket_ != INVALID_SOCKET); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 288 | if (socket_ == INVALID_SOCKET) |
| 289 | return SOCKET_ERROR; |
| 290 | |
| 291 | sockaddr_storage saddr; |
| 292 | size_t len = addr.ToSockAddrStorage(&saddr); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 293 | int err = ::bind(socket_, reinterpret_cast<sockaddr*>(&saddr), |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 294 | static_cast<int>(len)); |
| 295 | UpdateLastError(); |
| 296 | return err; |
| 297 | } |
| 298 | |
| 299 | int Win32Socket::Connect(const SocketAddress& addr) { |
| 300 | if (state_ != CS_CLOSED) { |
| 301 | SetError(EALREADY); |
| 302 | return SOCKET_ERROR; |
| 303 | } |
| 304 | |
| 305 | if (!addr.IsUnresolvedIP()) { |
| 306 | return DoConnect(addr); |
| 307 | } |
| 308 | |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 309 | RTC_LOG_F(LS_INFO) << "async dns lookup (" << addr.hostname() << ")"; |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 310 | DnsLookup* dns = new DnsLookup; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 311 | if (!sink_) { |
| 312 | // Explicitly create the sink ourselves here; we can't rely on SetAsync |
| 313 | // because we don't have a socket_ yet. |
| 314 | CreateSink(); |
| 315 | } |
| 316 | // TODO: Replace with IPv6 compatible lookup. |
| 317 | dns->handle = WSAAsyncGetHostByName(sink_->handle(), WM_DNSNOTIFY, |
| 318 | addr.hostname().c_str(), dns->buffer, |
| 319 | sizeof(dns->buffer)); |
| 320 | |
| 321 | if (!dns->handle) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 322 | RTC_LOG_F(LS_ERROR) << "WSAAsyncGetHostByName error: " << WSAGetLastError(); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 323 | delete dns; |
| 324 | UpdateLastError(); |
| 325 | Close(); |
| 326 | return SOCKET_ERROR; |
| 327 | } |
| 328 | |
| 329 | dns->port = addr.port(); |
| 330 | dns_ = dns; |
| 331 | state_ = CS_CONNECTING; |
| 332 | return 0; |
| 333 | } |
| 334 | |
| 335 | int Win32Socket::DoConnect(const SocketAddress& addr) { |
| 336 | if ((socket_ == INVALID_SOCKET) && !CreateT(addr.family(), SOCK_STREAM)) { |
| 337 | return SOCKET_ERROR; |
| 338 | } |
| 339 | if (!SetAsync(FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE)) { |
| 340 | return SOCKET_ERROR; |
| 341 | } |
| 342 | |
| 343 | sockaddr_storage saddr = {0}; |
| 344 | size_t len = addr.ToSockAddrStorage(&saddr); |
| 345 | connect_time_ = Time(); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 346 | int result = connect(socket_, reinterpret_cast<SOCKADDR*>(&saddr), |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 347 | static_cast<int>(len)); |
| 348 | if (result != SOCKET_ERROR) { |
| 349 | state_ = CS_CONNECTED; |
| 350 | } else { |
| 351 | int code = WSAGetLastError(); |
| 352 | if (code == WSAEWOULDBLOCK) { |
| 353 | state_ = CS_CONNECTING; |
| 354 | } else { |
| 355 | ReportWSAError("WSAAsync:connect", code, addr); |
| 356 | error_ = code; |
| 357 | Close(); |
| 358 | return SOCKET_ERROR; |
| 359 | } |
| 360 | } |
| 361 | addr_ = addr; |
| 362 | |
| 363 | return 0; |
| 364 | } |
| 365 | |
| 366 | int Win32Socket::GetError() const { |
| 367 | return error_; |
| 368 | } |
| 369 | |
| 370 | void Win32Socket::SetError(int error) { |
| 371 | error_ = error; |
| 372 | } |
| 373 | |
| 374 | Socket::ConnState Win32Socket::GetState() const { |
| 375 | return state_; |
| 376 | } |
| 377 | |
| 378 | int Win32Socket::GetOption(Option opt, int* value) { |
| 379 | int slevel; |
| 380 | int sopt; |
| 381 | if (TranslateOption(opt, &slevel, &sopt) == -1) |
| 382 | return -1; |
| 383 | |
| 384 | char* p = reinterpret_cast<char*>(value); |
| 385 | int optlen = sizeof(value); |
| 386 | return ::getsockopt(socket_, slevel, sopt, p, &optlen); |
| 387 | } |
| 388 | |
| 389 | int Win32Socket::SetOption(Option opt, int value) { |
| 390 | int slevel; |
| 391 | int sopt; |
| 392 | if (TranslateOption(opt, &slevel, &sopt) == -1) |
| 393 | return -1; |
| 394 | |
| 395 | const char* p = reinterpret_cast<const char*>(&value); |
| 396 | return ::setsockopt(socket_, slevel, sopt, p, sizeof(value)); |
| 397 | } |
| 398 | |
| 399 | int Win32Socket::Send(const void* buffer, size_t length) { |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 400 | int sent = ::send(socket_, reinterpret_cast<const char*>(buffer), |
| 401 | static_cast<int>(length), 0); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 402 | UpdateLastError(); |
| 403 | return sent; |
| 404 | } |
| 405 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 406 | int Win32Socket::SendTo(const void* buffer, |
| 407 | size_t length, |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 408 | const SocketAddress& addr) { |
| 409 | sockaddr_storage saddr; |
| 410 | size_t addr_len = addr.ToSockAddrStorage(&saddr); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 411 | int sent = ::sendto( |
| 412 | socket_, reinterpret_cast<const char*>(buffer), static_cast<int>(length), |
| 413 | 0, reinterpret_cast<sockaddr*>(&saddr), static_cast<int>(addr_len)); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 414 | UpdateLastError(); |
| 415 | return sent; |
| 416 | } |
| 417 | |
Stefan Holmer | 9131efd | 2016-05-23 16:19:26 | [diff] [blame] | 418 | int Win32Socket::Recv(void* buffer, size_t length, int64_t* timestamp) { |
| 419 | if (timestamp) { |
| 420 | *timestamp = -1; |
| 421 | } |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 422 | int received = |
| 423 | ::recv(socket_, static_cast<char*>(buffer), static_cast<int>(length), 0); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 424 | UpdateLastError(); |
| 425 | if (closing_ && received <= static_cast<int>(length)) |
| 426 | PostClosed(); |
| 427 | return received; |
| 428 | } |
| 429 | |
Stefan Holmer | 9131efd | 2016-05-23 16:19:26 | [diff] [blame] | 430 | int Win32Socket::RecvFrom(void* buffer, |
| 431 | size_t length, |
| 432 | SocketAddress* out_addr, |
| 433 | int64_t* timestamp) { |
| 434 | if (timestamp) { |
| 435 | *timestamp = -1; |
| 436 | } |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 437 | sockaddr_storage saddr; |
| 438 | socklen_t addr_len = sizeof(saddr); |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 439 | int received = |
| 440 | ::recvfrom(socket_, static_cast<char*>(buffer), static_cast<int>(length), |
| 441 | 0, reinterpret_cast<sockaddr*>(&saddr), &addr_len); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 442 | UpdateLastError(); |
| 443 | if (received != SOCKET_ERROR) |
| 444 | SocketAddressFromSockAddrStorage(saddr, out_addr); |
| 445 | if (closing_ && received <= static_cast<int>(length)) |
| 446 | PostClosed(); |
| 447 | return received; |
| 448 | } |
| 449 | |
| 450 | int Win32Socket::Listen(int backlog) { |
| 451 | int err = ::listen(socket_, backlog); |
| 452 | if (!SetAsync(FD_ACCEPT)) |
| 453 | return SOCKET_ERROR; |
| 454 | |
| 455 | UpdateLastError(); |
| 456 | if (err == 0) |
| 457 | state_ = CS_CONNECTING; |
| 458 | return err; |
| 459 | } |
| 460 | |
| 461 | Win32Socket* Win32Socket::Accept(SocketAddress* out_addr) { |
| 462 | sockaddr_storage saddr; |
| 463 | socklen_t addr_len = sizeof(saddr); |
| 464 | SOCKET s = ::accept(socket_, reinterpret_cast<sockaddr*>(&saddr), &addr_len); |
| 465 | UpdateLastError(); |
| 466 | if (s == INVALID_SOCKET) |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 467 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 468 | if (out_addr) |
| 469 | SocketAddressFromSockAddrStorage(saddr, out_addr); |
| 470 | Win32Socket* socket = new Win32Socket; |
| 471 | if (0 == socket->Attach(s)) |
| 472 | return socket; |
| 473 | delete socket; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 474 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | int Win32Socket::Close() { |
| 478 | int err = 0; |
| 479 | if (socket_ != INVALID_SOCKET) { |
| 480 | err = ::closesocket(socket_); |
| 481 | socket_ = INVALID_SOCKET; |
| 482 | closing_ = false; |
| 483 | close_error_ = 0; |
| 484 | UpdateLastError(); |
| 485 | } |
| 486 | if (dns_) { |
| 487 | WSACancelAsyncRequest(dns_->handle); |
| 488 | delete dns_; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 489 | dns_ = nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 490 | } |
| 491 | if (sink_) { |
| 492 | sink_->Dispose(); |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 493 | sink_ = nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 494 | } |
| 495 | addr_.Clear(); |
| 496 | state_ = CS_CLOSED; |
| 497 | return err; |
| 498 | } |
| 499 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 500 | void Win32Socket::CreateSink() { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 501 | RTC_DCHECK(nullptr == sink_); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 502 | |
| 503 | // Create window |
| 504 | sink_ = new EventSink(this); |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 505 | sink_->Create(nullptr, L"EventSink", 0, 0, 0, 0, 10, 10); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 506 | } |
| 507 | |
| 508 | bool Win32Socket::SetAsync(int events) { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 509 | if (nullptr == sink_) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 510 | CreateSink(); |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 511 | RTC_DCHECK(nullptr != sink_); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | // start the async select |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 515 | if (WSAAsyncSelect(socket_, sink_->handle(), WM_SOCKETNOTIFY, events) == |
| 516 | SOCKET_ERROR) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 517 | UpdateLastError(); |
| 518 | Close(); |
| 519 | return false; |
| 520 | } |
| 521 | |
| 522 | return true; |
| 523 | } |
| 524 | |
| 525 | bool Win32Socket::HandleClosed(int close_error) { |
| 526 | // WM_CLOSE will be received before all data has been read, so we need to |
| 527 | // hold on to it until the read buffer has been drained. |
| 528 | char ch; |
| 529 | closing_ = true; |
| 530 | close_error_ = close_error; |
| 531 | return (::recv(socket_, &ch, 1, MSG_PEEK) <= 0); |
| 532 | } |
| 533 | |
| 534 | void Win32Socket::PostClosed() { |
| 535 | // If we see that the buffer is indeed drained, then send the close. |
| 536 | closing_ = false; |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 537 | ::PostMessage(sink_->handle(), WM_SOCKETNOTIFY, socket_, |
| 538 | WSAMAKESELECTREPLY(FD_CLOSE, close_error_)); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | void Win32Socket::UpdateLastError() { |
| 542 | error_ = WSAGetLastError(); |
| 543 | } |
| 544 | |
| 545 | int Win32Socket::TranslateOption(Option opt, int* slevel, int* sopt) { |
| 546 | switch (opt) { |
| 547 | case OPT_DONTFRAGMENT: |
| 548 | *slevel = IPPROTO_IP; |
| 549 | *sopt = IP_DONTFRAGMENT; |
| 550 | break; |
| 551 | case OPT_RCVBUF: |
| 552 | *slevel = SOL_SOCKET; |
| 553 | *sopt = SO_RCVBUF; |
| 554 | break; |
| 555 | case OPT_SNDBUF: |
| 556 | *slevel = SOL_SOCKET; |
| 557 | *sopt = SO_SNDBUF; |
| 558 | break; |
| 559 | case OPT_NODELAY: |
| 560 | *slevel = IPPROTO_TCP; |
| 561 | *sopt = TCP_NODELAY; |
| 562 | break; |
| 563 | case OPT_DSCP: |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 564 | RTC_LOG(LS_WARNING) << "Socket::OPT_DSCP not supported."; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 565 | return -1; |
| 566 | default: |
nisse | c80e741 | 2017-01-11 13:56:46 | [diff] [blame] | 567 | RTC_NOTREACHED(); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 568 | return -1; |
| 569 | } |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | void Win32Socket::OnSocketNotify(SOCKET socket, int event, int error) { |
| 574 | // Ignore events if we're already closed. |
| 575 | if (socket != socket_) |
| 576 | return; |
| 577 | |
| 578 | error_ = error; |
| 579 | switch (event) { |
| 580 | case FD_CONNECT: |
| 581 | if (error != ERROR_SUCCESS) { |
| 582 | ReportWSAError("WSAAsync:connect notify", error, addr_); |
tfarina | a41ab93 | 2015-10-30 23:08:48 | [diff] [blame] | 583 | #if !defined(NDEBUG) |
Honghai Zhang | 82d7862 | 2016-05-06 18:29:15 | [diff] [blame] | 584 | int64_t duration = TimeSince(connect_time_); |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 585 | RTC_LOG(LS_INFO) << "WSAAsync:connect error (" << duration |
| 586 | << " ms), faking close"; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 587 | #endif |
| 588 | state_ = CS_CLOSED; |
| 589 | // If you get an error connecting, close doesn't really do anything |
| 590 | // and it certainly doesn't send back any close notification, but |
| 591 | // we really only maintain a few states, so it is easiest to get |
| 592 | // back into a known state by pretending that a close happened, even |
| 593 | // though the connect event never did occur. |
| 594 | SignalCloseEvent(this, error); |
| 595 | } else { |
tfarina | a41ab93 | 2015-10-30 23:08:48 | [diff] [blame] | 596 | #if !defined(NDEBUG) |
Honghai Zhang | 82d7862 | 2016-05-06 18:29:15 | [diff] [blame] | 597 | int64_t duration = TimeSince(connect_time_); |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 598 | RTC_LOG(LS_INFO) << "WSAAsync:connect (" << duration << " ms)"; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 599 | #endif |
| 600 | state_ = CS_CONNECTED; |
| 601 | SignalConnectEvent(this); |
| 602 | } |
| 603 | break; |
| 604 | |
| 605 | case FD_ACCEPT: |
| 606 | case FD_READ: |
| 607 | if (error != ERROR_SUCCESS) { |
| 608 | ReportWSAError("WSAAsync:read notify", error, addr_); |
| 609 | } else { |
| 610 | SignalReadEvent(this); |
| 611 | } |
| 612 | break; |
| 613 | |
| 614 | case FD_WRITE: |
| 615 | if (error != ERROR_SUCCESS) { |
| 616 | ReportWSAError("WSAAsync:write notify", error, addr_); |
| 617 | } else { |
| 618 | SignalWriteEvent(this); |
| 619 | } |
| 620 | break; |
| 621 | |
| 622 | case FD_CLOSE: |
| 623 | if (HandleClosed(error)) { |
| 624 | ReportWSAError("WSAAsync:close notify", error, addr_); |
| 625 | state_ = CS_CLOSED; |
| 626 | SignalCloseEvent(this, error); |
| 627 | } |
| 628 | break; |
| 629 | } |
| 630 | } |
| 631 | |
| 632 | void Win32Socket::OnDnsNotify(HANDLE task, int error) { |
| 633 | if (!dns_ || dns_->handle != task) |
| 634 | return; |
| 635 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 636 | uint32_t ip = 0; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 637 | if (error == 0) { |
| 638 | hostent* pHost = reinterpret_cast<hostent*>(dns_->buffer); |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 639 | uint32_t net_ip = *reinterpret_cast<uint32_t*>(pHost->h_addr_list[0]); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 640 | ip = NetworkToHost32(net_ip); |
| 641 | } |
| 642 | |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 643 | RTC_LOG_F(LS_INFO) << "(" << IPAddress(ip).ToSensitiveString() << ", " |
| 644 | << error << ")"; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 645 | |
| 646 | if (error == 0) { |
| 647 | SocketAddress address(ip, dns_->port); |
| 648 | error = DoConnect(address); |
| 649 | } else { |
| 650 | Close(); |
| 651 | } |
| 652 | |
| 653 | if (error) { |
| 654 | error_ = error; |
| 655 | SignalCloseEvent(this, error_); |
| 656 | } else { |
| 657 | delete dns_; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 658 | dns_ = nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 659 | } |
| 660 | } |
| 661 | |
| 662 | /////////////////////////////////////////////////////////////////////////////// |
| 663 | // Win32SocketServer |
| 664 | // Provides cricket base services on top of a win32 gui thread |
| 665 | /////////////////////////////////////////////////////////////////////////////// |
| 666 | |
| 667 | static UINT s_wm_wakeup_id = 0; |
| 668 | const TCHAR Win32SocketServer::kWindowName[] = L"libjingle Message Window"; |
| 669 | |
nisse | 7eaa4ea | 2017-05-08 12:25:41 | [diff] [blame] | 670 | Win32SocketServer::Win32SocketServer() |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 671 | : wnd_(this), posted_(false), hdlg_(nullptr) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 672 | if (s_wm_wakeup_id == 0) |
| 673 | s_wm_wakeup_id = RegisterWindowMessage(L"WM_WAKEUP"); |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 674 | if (!wnd_.Create(nullptr, kWindowName, 0, 0, 0, 0, 0, 0)) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 675 | RTC_LOG_GLE(LS_ERROR) << "Failed to create message window."; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 676 | } |
| 677 | } |
| 678 | |
| 679 | Win32SocketServer::~Win32SocketServer() { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 680 | if (wnd_.handle() != nullptr) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 681 | KillTimer(wnd_.handle(), 1); |
| 682 | wnd_.Destroy(); |
| 683 | } |
| 684 | } |
| 685 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 686 | Socket* Win32SocketServer::CreateSocket(int family, int type) { |
| 687 | return CreateAsyncSocket(family, type); |
| 688 | } |
| 689 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 690 | AsyncSocket* Win32SocketServer::CreateAsyncSocket(int family, int type) { |
| 691 | Win32Socket* socket = new Win32Socket; |
| 692 | if (socket->CreateT(family, type)) { |
| 693 | return socket; |
| 694 | } |
| 695 | delete socket; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 696 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | void Win32SocketServer::SetMessageQueue(MessageQueue* queue) { |
| 700 | message_queue_ = queue; |
| 701 | } |
| 702 | |
| 703 | bool Win32SocketServer::Wait(int cms, bool process_io) { |
| 704 | BOOL b; |
| 705 | if (process_io) { |
| 706 | // Spin the Win32 message pump at least once, and as long as requested. |
| 707 | // This is the Thread::ProcessMessages case. |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 708 | uint32_t start = Time(); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 709 | do { |
| 710 | MSG msg; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 711 | SetTimer(wnd_.handle(), 0, cms, nullptr); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 712 | // Get the next available message. If we have a modeless dialog, give |
| 713 | // give the message to IsDialogMessage, which will return true if it |
| 714 | // was a message for the dialog that it handled internally. |
| 715 | // Otherwise, dispatch as usual via Translate/DispatchMessage. |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 716 | b = GetMessage(&msg, nullptr, 0, 0); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 717 | if (b == -1) { |
Mirko Bonadei | 675513b | 2017-11-09 10:09:25 | [diff] [blame] | 718 | RTC_LOG_GLE(LS_ERROR) << "GetMessage failed."; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 719 | return false; |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 720 | } else if (b) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 721 | if (!hdlg_ || !IsDialogMessage(hdlg_, &msg)) { |
| 722 | TranslateMessage(&msg); |
| 723 | DispatchMessage(&msg); |
| 724 | } |
| 725 | } |
| 726 | KillTimer(wnd_.handle(), 0); |
| 727 | } while (b && TimeSince(start) < cms); |
| 728 | } else if (cms != 0) { |
| 729 | // Sit and wait forever for a WakeUp. This is the Thread::Send case. |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 730 | RTC_DCHECK(cms == -1); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 731 | MSG msg; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 732 | b = GetMessage(&msg, nullptr, s_wm_wakeup_id, s_wm_wakeup_id); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 733 | { |
| 734 | CritScope scope(&cs_); |
| 735 | posted_ = false; |
| 736 | } |
| 737 | } else { |
| 738 | // No-op (cms == 0 && !process_io). This is the Pump case. |
| 739 | b = TRUE; |
| 740 | } |
| 741 | return (b != FALSE); |
| 742 | } |
| 743 | |
| 744 | void Win32SocketServer::WakeUp() { |
| 745 | if (wnd_.handle()) { |
| 746 | // Set the "message pending" flag, if not already set. |
| 747 | { |
| 748 | CritScope scope(&cs_); |
| 749 | if (posted_) |
| 750 | return; |
| 751 | posted_ = true; |
| 752 | } |
| 753 | |
| 754 | PostMessage(wnd_.handle(), s_wm_wakeup_id, 0, 0); |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | void Win32SocketServer::Pump() { |
| 759 | // Clear the "message pending" flag. |
| 760 | { |
| 761 | CritScope scope(&cs_); |
| 762 | posted_ = false; |
| 763 | } |
| 764 | |
| 765 | // Dispatch all the messages that are currently in our queue. If new messages |
| 766 | // are posted during the dispatch, they will be handled in the next Pump. |
| 767 | // We use max(1, ...) to make sure we try to dispatch at least once, since |
| 768 | // this allow us to process "sent" messages, not included in the size() count. |
| 769 | Message msg; |
andresp@webrtc.org | ff689be | 2015-02-12 11:54:26 | [diff] [blame] | 770 | for (size_t max_messages_to_process = |
| 771 | std::max<size_t>(1, message_queue_->size()); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 772 | max_messages_to_process > 0 && message_queue_->Get(&msg, 0, false); |
| 773 | --max_messages_to_process) { |
| 774 | message_queue_->Dispatch(&msg); |
| 775 | } |
| 776 | |
| 777 | // Anything remaining? |
| 778 | int delay = message_queue_->GetDelay(); |
| 779 | if (delay == -1) { |
| 780 | KillTimer(wnd_.handle(), 1); |
| 781 | } else { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 782 | SetTimer(wnd_.handle(), 1, delay, nullptr); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 786 | bool Win32SocketServer::MessageWindow::OnMessage(UINT wm, |
| 787 | WPARAM wp, |
| 788 | LPARAM lp, |
| 789 | LRESULT& lr) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 790 | bool handled = false; |
| 791 | if (wm == s_wm_wakeup_id || (wm == WM_TIMER && wp == 1)) { |
| 792 | ss_->Pump(); |
| 793 | lr = 0; |
| 794 | handled = true; |
| 795 | } |
| 796 | return handled; |
| 797 | } |
| 798 | |
Steve Anton | 9de3aac | 2017-10-24 17:08:26 | [diff] [blame] | 799 | Win32Thread::Win32Thread(SocketServer* ss) : Thread(ss), id_(0) {} |
| 800 | |
| 801 | Win32Thread::~Win32Thread() { |
| 802 | Stop(); |
| 803 | } |
| 804 | |
| 805 | void Win32Thread::Run() { |
| 806 | id_ = GetCurrentThreadId(); |
| 807 | Thread::Run(); |
| 808 | id_ = 0; |
| 809 | } |
| 810 | |
| 811 | void Win32Thread::Quit() { |
| 812 | PostThreadMessage(id_, WM_QUIT, 0, 0); |
| 813 | } |
| 814 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 815 | } // namespace rtc |