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

Unified Diff: webrtc/p2p/base/basicpacketsocketfactory.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: 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/basicpacketsocketfactory.cc
diff --git a/webrtc/p2p/base/basicpacketsocketfactory.cc b/webrtc/p2p/base/basicpacketsocketfactory.cc
index 697518da9d0508cfcec888306b133514307726c7..e3c558783826ce9eba8d0abd999763c96f7ac7bb 100644
--- a/webrtc/p2p/base/basicpacketsocketfactory.cc
+++ b/webrtc/p2p/base/basicpacketsocketfactory.cc
@@ -16,6 +16,7 @@
#include "webrtc/base/asyncudpsocket.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/nethelpers.h"
+#include "webrtc/base/network.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/socketadapters.h"
@@ -47,6 +48,14 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket(
const SocketAddress& address,
uint16_t min_port,
uint16_t max_port) {
+ return CreateUdpSocketOnNetwork(address, min_port, max_port, nullptr);
+}
+
+AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocketOnNetwork(
+ const SocketAddress& address,
+ uint16_t min_port,
+ uint16_t max_port,
+ const Network* network) {
// UDP sockets are simple.
rtc::AsyncSocket* socket =
socket_factory()->CreateAsyncSocket(
@@ -54,6 +63,12 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket(
if (!socket) {
return NULL;
}
+ if (network && network->IsHandleValid()) {
+ int res = socket->BindToNetwork(network->handle());
+ if (res < 0) {
+ LOG(LS_WARNING) << "Network bind failed with error " << res;
+ }
+ }
if (BindSocket(socket, address, min_port, max_port) < 0) {
LOG(LS_ERROR) << "UDP bind failed with error "
<< socket->GetError();

Powered by Google App Engine
This is Rietveld 408576698