Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: webrtc/base/physicalsocketserver.cc

Issue 1556743002: Bind a socket to a network if the network handle is set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/base/physicalsocketserver.h"
10 11
11 #if defined(_MSC_VER) && _MSC_VER < 1300 12 #if defined(_MSC_VER) && _MSC_VER < 1300
12 #pragma warning(disable:4786) 13 #pragma warning(disable:4786)
13 #endif 14 #endif
14 15
15 #include <assert.h> 16 #include <assert.h>
16 17
17 #ifdef MEMORY_SANITIZER 18 #ifdef MEMORY_SANITIZER
18 #include <sanitizer/msan_interface.h> 19 #include <sanitizer/msan_interface.h>
19 #endif 20 #endif
(...skipping 17 matching lines...) Expand all
37 #endif 38 #endif
38 39
39 #include <algorithm> 40 #include <algorithm>
40 #include <map> 41 #include <map>
41 42
42 #include "webrtc/base/arraysize.h" 43 #include "webrtc/base/arraysize.h"
43 #include "webrtc/base/basictypes.h" 44 #include "webrtc/base/basictypes.h"
44 #include "webrtc/base/byteorder.h" 45 #include "webrtc/base/byteorder.h"
45 #include "webrtc/base/common.h" 46 #include "webrtc/base/common.h"
46 #include "webrtc/base/logging.h" 47 #include "webrtc/base/logging.h"
47 #include "webrtc/base/physicalsocketserver.h" 48 #include "webrtc/base/networkmonitor.h"
48 #include "webrtc/base/timeutils.h" 49 #include "webrtc/base/timeutils.h"
49 #include "webrtc/base/winping.h" 50 #include "webrtc/base/winping.h"
50 #include "webrtc/base/win32socketinit.h" 51 #include "webrtc/base/win32socketinit.h"
51 52
52 // stm: this will tell us if we are on OSX 53 // stm: this will tell us if we are on OSX
53 #ifdef HAVE_CONFIG_H 54 #ifdef HAVE_CONFIG_H
54 #include "config.h" 55 #include "config.h"
55 #endif 56 #endif
56 57
57 #if defined(WEBRTC_POSIX) 58 #if defined(WEBRTC_POSIX)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 size_t len = bind_addr.ToSockAddrStorage(&addr_storage); 168 size_t len = bind_addr.ToSockAddrStorage(&addr_storage);
168 sockaddr* addr = reinterpret_cast<sockaddr*>(&addr_storage); 169 sockaddr* addr = reinterpret_cast<sockaddr*>(&addr_storage);
169 int err = ::bind(s_, addr, static_cast<int>(len)); 170 int err = ::bind(s_, addr, static_cast<int>(len));
170 UpdateLastError(); 171 UpdateLastError();
171 #if !defined(NDEBUG) 172 #if !defined(NDEBUG)
172 if (0 == err) { 173 if (0 == err) {
173 dbg_addr_ = "Bound @ "; 174 dbg_addr_ = "Bound @ ";
174 dbg_addr_.append(GetLocalAddress().ToString()); 175 dbg_addr_.append(GetLocalAddress().ToString());
175 } 176 }
176 #endif 177 #endif
178 if (ss_->network_binder()) {
179 int result =
180 ss_->network_binder()->BindSocketToNetwork(s_, bind_addr.ipaddr());
181 if (result < 0) {
182 LOG(LS_INFO) << "Binding socket to network address "
183 << bind_addr.ipaddr().ToString() << " result " << result;
184 }
185 }
177 return err; 186 return err;
178 } 187 }
179 188
180 int PhysicalSocket::Connect(const SocketAddress& addr) { 189 int PhysicalSocket::Connect(const SocketAddress& addr) {
181 // TODO(pthatcher): Implicit creation is required to reconnect... 190 // TODO(pthatcher): Implicit creation is required to reconnect...
182 // ...but should we make it more explicit? 191 // ...but should we make it more explicit?
183 if (state_ != CS_CLOSED) { 192 if (state_ != CS_CLOSED) {
184 SetError(EALREADY); 193 SetError(EALREADY);
185 return SOCKET_ERROR; 194 return SOCKET_ERROR;
186 } 195 }
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 virtual SOCKET GetSocket() { 1111 virtual SOCKET GetSocket() {
1103 return INVALID_SOCKET; 1112 return INVALID_SOCKET;
1104 } 1113 }
1105 1114
1106 virtual bool CheckSignalClose() { return false; } 1115 virtual bool CheckSignalClose() { return false; }
1107 1116
1108 private: 1117 private:
1109 PhysicalSocketServer* ss_; 1118 PhysicalSocketServer* ss_;
1110 WSAEVENT hev_; 1119 WSAEVENT hev_;
1111 }; 1120 };
1112 #endif // WEBRTC_WIN 1121 #endif // WEBRTC_WIN
1113 1122
1114 // Sets the value of a boolean value to false when signaled. 1123 // Sets the value of a boolean value to false when signaled.
1115 class Signaler : public EventDispatcher { 1124 class Signaler : public EventDispatcher {
1116 public: 1125 public:
1117 Signaler(PhysicalSocketServer* ss, bool* pf) 1126 Signaler(PhysicalSocketServer* ss, bool* pf)
1118 : EventDispatcher(ss), pf_(pf) { 1127 : EventDispatcher(ss), pf_(pf) {
1119 } 1128 }
1120 ~Signaler() override { } 1129 ~Signaler() override { }
1121 1130
1122 void OnEvent(uint32_t ff, int err) override { 1131 void OnEvent(uint32_t ff, int err) override {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 break; 1605 break;
1597 cmsElapsed = TimeSince(msStart); 1606 cmsElapsed = TimeSince(msStart);
1598 if ((cmsWait != kForever) && (cmsElapsed >= cmsWait)) { 1607 if ((cmsWait != kForever) && (cmsElapsed >= cmsWait)) {
1599 break; 1608 break;
1600 } 1609 }
1601 } 1610 }
1602 1611
1603 // Done 1612 // Done
1604 return true; 1613 return true;
1605 } 1614 }
1606 #endif // WEBRTC_WIN 1615 #endif // WEBRTC_WIN
1607 1616
1608 } // namespace rtc 1617 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698