aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD4
-rw-r--r--CMakeLists.txt5
-rw-r--r--INSTALL.md24
-rw-r--r--Makefile5
-rw-r--r--README.md14
-rw-r--r--binding.gyp1
-rw-r--r--build.yaml2
-rw-r--r--config.m41
-rw-r--r--gRPC-Core.podspec3
-rwxr-xr-xgrpc.gemspec2
-rw-r--r--include/grpc/impl/codegen/grpc_types.h5
-rw-r--r--package.xml2
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.c110
-rw-r--r--src/core/lib/iomgr/socket_factory_posix.h90
-rw-r--r--src/core/lib/iomgr/socket_utils_common_posix.c18
-rw-r--r--src/core/lib/iomgr/socket_utils_posix.h7
-rw-r--r--src/core/lib/iomgr/udp_server.c49
-rw-r--r--src/core/lib/iomgr/udp_server.h2
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py1
-rw-r--r--test/core/iomgr/udp_server_test.c89
-rw-r--r--tools/doxygen/Doxyfile.core.internal2
-rw-r--r--tools/run_tests/generated/sources_and_headers.json3
-rw-r--r--vsprojects/vcxproj/grpc/grpc.vcxproj3
-rw-r--r--vsprojects/vcxproj/grpc/grpc.vcxproj.filters6
-rw-r--r--vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj3
-rw-r--r--vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters6
-rw-r--r--vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj3
-rw-r--r--vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters6
28 files changed, 430 insertions, 36 deletions
diff --git a/BUILD b/BUILD
index 053f581101..10d5c447ca 100644
--- a/BUILD
+++ b/BUILD
@@ -354,8 +354,8 @@ grpc_cc_library(
"src/core/lib/support/wrap_memcpy.c",
],
hdrs = [
- "src/core/lib/support/arena.h",
"src/core/lib/profiling/timers.h",
+ "src/core/lib/support/arena.h",
"src/core/lib/support/backoff.h",
"src/core/lib/support/block_annotate.h",
"src/core/lib/support/env.h",
@@ -472,6 +472,7 @@ grpc_cc_library(
"src/core/lib/iomgr/resolve_address_windows.c",
"src/core/lib/iomgr/resource_quota.c",
"src/core/lib/iomgr/sockaddr_utils.c",
+ "src/core/lib/iomgr/socket_factory_posix.c",
"src/core/lib/iomgr/socket_mutator.c",
"src/core/lib/iomgr/socket_utils_common_posix.c",
"src/core/lib/iomgr/socket_utils_linux.c",
@@ -597,6 +598,7 @@ grpc_cc_library(
"src/core/lib/iomgr/sockaddr_posix.h",
"src/core/lib/iomgr/sockaddr_utils.h",
"src/core/lib/iomgr/sockaddr_windows.h",
+ "src/core/lib/iomgr/socket_factory_posix.h",
"src/core/lib/iomgr/socket_mutator.h",
"src/core/lib/iomgr/socket_utils.h",
"src/core/lib/iomgr/socket_utils_posix.h",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5a8bff5534..f73d76dbe6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -913,6 +913,7 @@ add_library(grpc
src/core/lib/iomgr/resolve_address_windows.c
src/core/lib/iomgr/resource_quota.c
src/core/lib/iomgr/sockaddr_utils.c
+ src/core/lib/iomgr/socket_factory_posix.c
src/core/lib/iomgr/socket_mutator.c
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
@@ -1224,6 +1225,7 @@ add_library(grpc_cronet
src/core/lib/iomgr/resolve_address_windows.c
src/core/lib/iomgr/resource_quota.c
src/core/lib/iomgr/sockaddr_utils.c
+ src/core/lib/iomgr/socket_factory_posix.c
src/core/lib/iomgr/socket_mutator.c
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
@@ -1526,6 +1528,7 @@ add_library(grpc_test_util
src/core/lib/iomgr/resolve_address_windows.c
src/core/lib/iomgr/resource_quota.c
src/core/lib/iomgr/sockaddr_utils.c
+ src/core/lib/iomgr/socket_factory_posix.c
src/core/lib/iomgr/socket_mutator.c
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
@@ -1775,6 +1778,7 @@ add_library(grpc_unsecure
src/core/lib/iomgr/resolve_address_windows.c
src/core/lib/iomgr/resource_quota.c
src/core/lib/iomgr/sockaddr_utils.c
+ src/core/lib/iomgr/socket_factory_posix.c
src/core/lib/iomgr/socket_mutator.c
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
@@ -2384,6 +2388,7 @@ add_library(grpc++_cronet
src/core/lib/iomgr/resolve_address_windows.c
src/core/lib/iomgr/resource_quota.c
src/core/lib/iomgr/sockaddr_utils.c
+ src/core/lib/iomgr/socket_factory_posix.c
src/core/lib/iomgr/socket_mutator.c
src/core/lib/iomgr/socket_utils_common_posix.c
src/core/lib/iomgr/socket_utils_linux.c
diff --git a/INSTALL.md b/INSTALL.md
index 24f088ea49..89f2f11f9d 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -1,4 +1,4 @@
-#If you are in a hurry
+# If you are in a hurry
For language-specific installation instructions for gRPC runtime, please
refer to these documents
@@ -14,15 +14,15 @@ refer to these documents
* [Ruby](src/ruby): `gem install grpc`
-#Pre-requisites
+# Pre-requisites
-##Linux
+## Linux
```sh
$ [sudo] apt-get install build-essential autoconf libtool
```
-##Mac OSX
+## Mac OSX
For a Mac system, git is not available by default. You will first need to
install Xcode from the Mac AppStore and then run the following command from a
@@ -32,7 +32,7 @@ terminal:
$ [sudo] xcode-select --install
```
-##Protoc
+## Protoc
By default gRPC uses [protocol buffers](https://github.com/google/protobuf),
you will need the `protoc` compiler to generate stub server and client code.
@@ -43,7 +43,7 @@ repository recursively and it detects that you don't already have it
installed.
-#Build from Source
+# Build from Source
For developers who are interested to contribute, here is how to compile the
gRPC C Core library.
@@ -56,16 +56,16 @@ gRPC C Core library.
$ [sudo] make install
```
-##Windows
+## Windows
There are several ways to build under Windows, of varying complexity depending
on experience with the tools involved.
-###Pre-generated Visual Studio solution
+### Pre-generated Visual Studio solution
The pre-generated VS projects & solution are checked into the repository under the [vsprojects](/vsprojects) directory.
-
-###Building using CMake (with BoringSSL)
+
+### Building using CMake (with BoringSSL)
- Install [CMake](https://cmake.org/download/).
- Install [Active State Perl](http://www.activestate.com/activeperl/) (`choco install activeperl`)
- Install [Ninja](https://ninja-build.org/) (`choco install ninja`)
@@ -81,14 +81,14 @@ The pre-generated VS projects & solution are checked into the repository under t
```
NOTE: Currently you can only use Ninja to build using cmake on Windows (because of the boringssl dependency).
-###msys2 (with mingw)
+### msys2 (with mingw)
The Makefile (and source code) should support msys2's mingw32 and mingw64
compilers. Building with msys2's native compiler is also possible, but
difficult.
This approach requires having [msys2](https://msys2.github.io/) installed.
-
+
```
# Install prerequisites
MSYS2$ pacman -S autoconf automake gcc libtool mingw-w64-x86_64-toolchain perl pkg-config zlib
diff --git a/Makefile b/Makefile
index a1659cc8e5..9d3aee8a71 100644
--- a/Makefile
+++ b/Makefile
@@ -2804,6 +2804,7 @@ LIBGRPC_SRC = \
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
@@ -3118,6 +3119,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
@@ -3423,6 +3425,7 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
@@ -3652,6 +3655,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
@@ -4263,6 +4267,7 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
diff --git a/README.md b/README.md
index 934333c473..adcfdf10b8 100644
--- a/README.md
+++ b/README.md
@@ -7,11 +7,11 @@
Copyright 2015 Google Inc.
-#Documentation
+# Documentation
You can find more detailed documentation and examples in the [doc](doc) and [examples](examples) directories respectively.
-#Installation & Testing
+# Installation & Testing
See [INSTALL](INSTALL.md) for installation instructions for various platforms.
@@ -19,7 +19,7 @@ See [tools/run_tests](tools/run_tests) for more guidance on how to run various t
See [Performance dashboard](http://performance-dot-grpc-testing.appspot.com/explore?dashboard=5712453606309888) for the performance numbers for v1.0.x.
-#Repository Structure & Status
+# Repository Structure & Status
This repository contains source code for gRPC libraries for multiple languages written on top of shared C core library [src/core] (src/core).
@@ -44,7 +44,7 @@ Go source code is in the [grpc-go](http://github.com/grpc/grpc-go) repository.
See [MANIFEST.md](MANIFEST.md) for a listing of top-level items in the
repository.
-#Overview
+# Overview
Remote Procedure Calls (RPCs) provide a useful abstraction for building
@@ -54,7 +54,7 @@ These libraries enable communication between clients and servers using any
combination of the supported languages.
-##Interface
+## Interface
Developers using gRPC typically start with the description of an RPC service
@@ -66,7 +66,7 @@ Interface Definition Language (IDL) for describing both the service interface
and the structure of the payload messages. It is possible to use other
alternatives if desired.
-###Surface API
+### Surface API
Starting from an interface definition in a .proto file, gRPC provides
Protocol Compiler plugins that generate Client- and Server-side APIs.
gRPC users typically call into these APIs on the Client side and implement
@@ -94,7 +94,7 @@ the client and the server can send a stream of messages to each other. The strea
messages are delivered in the order they were sent.
-#Protocol
+# Protocol
The [gRPC protocol](doc/PROTOCOL-HTTP2.md) specifies the abstract requirements for communication between
clients and servers. A concrete embedding over HTTP/2 completes the picture by
diff --git a/binding.gyp b/binding.gyp
index 2ec57768ae..12ed7a8f3c 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -657,6 +657,7 @@
'src/core/lib/iomgr/resolve_address_windows.c',
'src/core/lib/iomgr/resource_quota.c',
'src/core/lib/iomgr/sockaddr_utils.c',
+ 'src/core/lib/iomgr/socket_factory_posix.c',
'src/core/lib/iomgr/socket_mutator.c',
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
diff --git a/build.yaml b/build.yaml
index 72b15374c6..63f22fd2fd 100644
--- a/build.yaml
+++ b/build.yaml
@@ -223,6 +223,7 @@ filegroups:
- src/core/lib/iomgr/sockaddr_posix.h
- src/core/lib/iomgr/sockaddr_utils.h
- src/core/lib/iomgr/sockaddr_windows.h
+ - src/core/lib/iomgr/socket_factory_posix.h
- src/core/lib/iomgr/socket_mutator.h
- src/core/lib/iomgr/socket_utils.h
- src/core/lib/iomgr/socket_utils_posix.h
@@ -329,6 +330,7 @@ filegroups:
- src/core/lib/iomgr/resolve_address_windows.c
- src/core/lib/iomgr/resource_quota.c
- src/core/lib/iomgr/sockaddr_utils.c
+ - src/core/lib/iomgr/socket_factory_posix.c
- src/core/lib/iomgr/socket_mutator.c
- src/core/lib/iomgr/socket_utils_common_posix.c
- src/core/lib/iomgr/socket_utils_linux.c
diff --git a/config.m4 b/config.m4
index 2bf302b835..96ac5588c0 100644
--- a/config.m4
+++ b/config.m4
@@ -130,6 +130,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/iomgr/resolve_address_windows.c \
src/core/lib/iomgr/resource_quota.c \
src/core/lib/iomgr/sockaddr_utils.c \
+ src/core/lib/iomgr/socket_factory_posix.c \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_utils_common_posix.c \
src/core/lib/iomgr/socket_utils_linux.c \
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index 6d1a59766e..1d091d0f7f 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -304,6 +304,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/sockaddr_posix.h',
'src/core/lib/iomgr/sockaddr_utils.h',
'src/core/lib/iomgr/sockaddr_windows.h',
+ 'src/core/lib/iomgr/socket_factory_posix.h',
'src/core/lib/iomgr/socket_mutator.h',
'src/core/lib/iomgr/socket_utils.h',
'src/core/lib/iomgr/socket_utils_posix.h',
@@ -500,6 +501,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/resolve_address_windows.c',
'src/core/lib/iomgr/resource_quota.c',
'src/core/lib/iomgr/sockaddr_utils.c',
+ 'src/core/lib/iomgr/socket_factory_posix.c',
'src/core/lib/iomgr/socket_mutator.c',
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
@@ -743,6 +745,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/sockaddr_posix.h',
'src/core/lib/iomgr/sockaddr_utils.h',
'src/core/lib/iomgr/sockaddr_windows.h',
+ 'src/core/lib/iomgr/socket_factory_posix.h',
'src/core/lib/iomgr/socket_mutator.h',
'src/core/lib/iomgr/socket_utils.h',
'src/core/lib/iomgr/socket_utils_posix.h',
diff --git a/grpc.gemspec b/grpc.gemspec
index 8074df266c..c7d9bfb433 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -221,6 +221,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/sockaddr_posix.h )
s.files += %w( src/core/lib/iomgr/sockaddr_utils.h )
s.files += %w( src/core/lib/iomgr/sockaddr_windows.h )
+ s.files += %w( src/core/lib/iomgr/socket_factory_posix.h )
s.files += %w( src/core/lib/iomgr/socket_mutator.h )
s.files += %w( src/core/lib/iomgr/socket_utils.h )
s.files += %w( src/core/lib/iomgr/socket_utils_posix.h )
@@ -417,6 +418,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/resolve_address_windows.c )
s.files += %w( src/core/lib/iomgr/resource_quota.c )
s.files += %w( src/core/lib/iomgr/sockaddr_utils.c )
+ s.files += %w( src/core/lib/iomgr/socket_factory_posix.c )
s.files += %w( src/core/lib/iomgr/socket_mutator.c )
s.files += %w( src/core/lib/iomgr/socket_utils_common_posix.c )
s.files += %w( src/core/lib/iomgr/socket_utils_linux.c )
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index e5c731304c..887c176f1a 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -87,6 +87,9 @@ typedef struct grpc_call grpc_call;
/** The Socket Mutator interface allows changes on socket options */
typedef struct grpc_socket_mutator grpc_socket_mutator;
+/** The Socket Factory interface creates and binds sockets */
+typedef struct grpc_socket_factory grpc_socket_factory;
+
/** Type specifier for grpc_arg */
typedef enum {
GRPC_ARG_STRING,
@@ -240,6 +243,8 @@ typedef struct {
#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name"
/** The grpc_socket_mutator instance that set the socket options. A pointer. */
#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator"
+/** The grpc_socket_factory instance to create and bind sockets. A pointer. */
+#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory"
/** If non-zero, Cronet transport will coalesce packets to fewer frames when
* possible. */
#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \
diff --git a/package.xml b/package.xml
index f096869e4e..a47f1b9761 100644
--- a/package.xml
+++ b/package.xml
@@ -230,6 +230,7 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_windows.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_factory_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_mutator.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.h" role="src" />
@@ -426,6 +427,7 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/resolve_address_windows.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/resource_quota.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/sockaddr_utils.c" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/socket_factory_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_mutator.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_common_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_linux.c" role="src" />
diff --git a/src/core/lib/iomgr/socket_factory_posix.c b/src/core/lib/iomgr/socket_factory_posix.c
new file mode 100644
index 0000000000..1050a14c46
--- /dev/null
+++ b/src/core/lib/iomgr/socket_factory_posix.c
@@ -0,0 +1,110 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "src/core/lib/iomgr/port.h"
+
+#ifdef GRPC_POSIX_SOCKET
+
+#include "src/core/lib/iomgr/socket_factory_posix.h"
+
+#include <grpc/impl/codegen/grpc_types.h>
+#include <grpc/support/sync.h>
+#include <grpc/support/useful.h>
+
+void grpc_socket_factory_init(grpc_socket_factory *factory,
+ const grpc_socket_factory_vtable *vtable) {
+ factory->vtable = vtable;
+ gpr_ref_init(&factory->refcount, 1);
+}
+
+int grpc_socket_factory_socket(grpc_socket_factory *factory, int domain,
+ int type, int protocol) {
+ return factory->vtable->socket(factory, domain, type, protocol);
+}
+
+int grpc_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
+ const grpc_resolved_address *addr) {
+ return factory->vtable->bind(factory, sockfd, addr);
+}
+
+int grpc_socket_factory_compare(grpc_socket_factory *a,
+ grpc_socket_factory *b) {
+ int c = GPR_ICMP(a, b);
+ if (c != 0) {
+ grpc_socket_factory *sma = a;
+ grpc_socket_factory *smb = b;
+ c = GPR_ICMP(sma->vtable, smb->vtable);
+ if (c == 0) {
+ c = sma->vtable->compare(sma, smb);
+ }
+ }
+ return c;
+}
+
+grpc_socket_factory *grpc_socket_factory_ref(grpc_socket_factory *factory) {
+ gpr_ref(&factory->refcount);
+ return factory;
+}
+
+void grpc_socket_factory_unref(grpc_socket_factory *factory) {
+ if (gpr_unref(&factory->refcount)) {
+ factory->vtable->destroy(factory);
+ }
+}
+
+static void *socket_factory_arg_copy(void *p) {
+ return grpc_socket_factory_ref(p);
+}
+
+static void socket_factory_arg_destroy(grpc_exec_ctx *exec_ctx, void *p) {
+ grpc_socket_factory_unref(p);
+}
+
+static int socket_factory_cmp(void *a, void *b) {
+ return grpc_socket_factory_compare((grpc_socket_factory *)a,
+ (grpc_socket_factory *)b);
+}
+
+static const grpc_arg_pointer_vtable socket_factory_arg_vtable = {
+ socket_factory_arg_copy, socket_factory_arg_destroy, socket_factory_cmp};
+
+grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory *factory) {
+ grpc_arg arg;
+ arg.type = GRPC_ARG_POINTER;
+ arg.key = GRPC_ARG_SOCKET_FACTORY;
+ arg.value.pointer.vtable = &socket_factory_arg_vtable;
+ arg.value.pointer.p = factory;
+ return arg;
+}
+
+#endif
diff --git a/src/core/lib/iomgr/socket_factory_posix.h b/src/core/lib/iomgr/socket_factory_posix.h
new file mode 100644
index 0000000000..2c63299030
--- /dev/null
+++ b/src/core/lib/iomgr/socket_factory_posix.h
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_CORE_LIB_IOMGR_SOCKET_FACTORY_POSIX_H
+#define GRPC_CORE_LIB_IOMGR_SOCKET_FACTORY_POSIX_H
+
+#include <grpc/impl/codegen/grpc_types.h>
+#include <grpc/support/sync.h>
+#include "src/core/lib/iomgr/resolve_address.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** The virtual table of grpc_socket_factory */
+typedef struct {
+ /** Replacement for socket(2) */
+ int (*socket)(grpc_socket_factory *factory, int domain, int type,
+ int protocol);
+ /** Replacement for bind(2) */
+ int (*bind)(grpc_socket_factory *factory, int sockfd,
+ const grpc_resolved_address *addr);
+ /** Compare socket factory \a a and \a b */
+ int (*compare)(grpc_socket_factory *a, grpc_socket_factory *b);
+ /** Destroys the socket factory instance */
+ void (*destroy)(grpc_socket_factory *factory);
+} grpc_socket_factory_vtable;
+
+/** The Socket Factory interface allows changes on socket options */
+struct grpc_socket_factory {
+ const grpc_socket_factory_vtable *vtable;
+ gpr_refcount refcount;
+};
+
+/** called by concrete implementations to initialize the base struct */
+void grpc_socket_factory_init(grpc_socket_factory *factory,
+ const grpc_socket_factory_vtable *vtable);
+
+/** Wrap \a factory as a grpc_arg */
+grpc_arg grpc_socket_factory_to_arg(grpc_socket_factory *factory);
+
+/** Perform the equivalent of a socket(2) operation using \a factory */
+int grpc_socket_factory_socket(grpc_socket_factory *factory, int domain,
+ int type, int protocol);
+
+/** Perform the equivalent of a bind(2) operation using \a factory */
+int grpc_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
+ const grpc_resolved_address *addr);
+
+/** Compare if \a a and \a b are the same factory or have same settings */
+int grpc_socket_factory_compare(grpc_socket_factory *a, grpc_socket_factory *b);
+
+grpc_socket_factory *grpc_socket_factory_ref(grpc_socket_factory *factory);
+void grpc_socket_factory_unref(grpc_socket_factory *factory);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_FACTORY_POSIX_H */
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c
index b69c924d4a..bbe642d0fb 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.c
+++ b/src/core/lib/iomgr/socket_utils_common_posix.c
@@ -278,11 +278,25 @@ static grpc_error *error_for_fd(int fd, const grpc_resolved_address *addr) {
grpc_error *grpc_create_dualstack_socket(
const grpc_resolved_address *resolved_addr, int type, int protocol,
grpc_dualstack_mode *dsmode, int *newfd) {
+ return grpc_create_dualstack_socket_using_factory(NULL, resolved_addr, type,
+ protocol, dsmode, newfd);
+}
+
+static int create_socket(grpc_socket_factory *factory, int domain, int type,
+ int protocol) {
+ return (factory != NULL)
+ ? grpc_socket_factory_socket(factory, domain, type, protocol)
+ : socket(domain, type, protocol);
+}
+
+grpc_error *grpc_create_dualstack_socket_using_factory(
+ grpc_socket_factory *factory, const grpc_resolved_address *resolved_addr,
+ int type, int protocol, grpc_dualstack_mode *dsmode, int *newfd) {
const struct sockaddr *addr = (const struct sockaddr *)resolved_addr->addr;
int family = addr->sa_family;
if (family == AF_INET6) {
if (grpc_ipv6_loopback_available()) {
- *newfd = socket(family, type, protocol);
+ *newfd = create_socket(factory, family, type, protocol);
} else {
*newfd = -1;
errno = EAFNOSUPPORT;
@@ -304,7 +318,7 @@ grpc_error *grpc_create_dualstack_socket(
family = AF_INET;
}
*dsmode = family == AF_INET ? GRPC_DSMODE_IPV4 : GRPC_DSMODE_NONE;
- *newfd = socket(family, type, protocol);
+ *newfd = create_socket(factory, family, type, protocol);
return error_for_fd(*newfd, resolved_addr);
}
diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h
index e84d3781a1..2c2fc95ff9 100644
--- a/src/core/lib/iomgr/socket_utils_posix.h
+++ b/src/core/lib/iomgr/socket_utils_posix.h
@@ -41,6 +41,7 @@
#include <grpc/impl/codegen/grpc_types.h>
#include "src/core/lib/iomgr/error.h"
+#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "src/core/lib/iomgr/socket_mutator.h"
/* a wrapper for accept or accept4 */
@@ -137,4 +138,10 @@ grpc_error *grpc_create_dualstack_socket(const grpc_resolved_address *addr,
grpc_dualstack_mode *dsmode,
int *newfd);
+/* Same as grpc_create_dualstack_socket(), but use the given socket factory (if
+ non-null) to create the socket, rather than calling socket() directly. */
+grpc_error *grpc_create_dualstack_socket_using_factory(
+ grpc_socket_factory *factory, const grpc_resolved_address *addr, int type,
+ int protocol, grpc_dualstack_mode *dsmode, int *newfd);
+
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c
index 28f2bd9359..86ec8f667d 100644
--- a/src/core/lib/iomgr/udp_server.c
+++ b/src/core/lib/iomgr/udp_server.c
@@ -59,11 +59,13 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
+#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
#include "src/core/lib/support/string.h"
@@ -89,6 +91,9 @@ struct grpc_udp_listener {
struct grpc_udp_server {
gpr_mu mu;
+ /* factory to use for creating and binding sockets, or NULL */
+ grpc_socket_factory *socket_factory;
+
/* active port count: how many ports are actually still listening */
size_t active_ports;
/* destroyed port count: how many ports are completely destroyed */
@@ -113,9 +118,24 @@ struct grpc_udp_server {
void *user_data;
};
-grpc_udp_server *grpc_udp_server_create(void) {
+static grpc_socket_factory *get_socket_factory(const grpc_channel_args *args) {
+ if (args) {
+ const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_SOCKET_FACTORY);
+ if (arg) {
+ GPR_ASSERT(arg->type == GRPC_ARG_POINTER);
+ return arg->value.pointer.p;
+ }
+ }
+ return NULL;
+}
+
+grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args) {
grpc_udp_server *s = gpr_malloc(sizeof(grpc_udp_server));
gpr_mu_init(&s->mu);
+ s->socket_factory = get_socket_factory(args);
+ if (s->socket_factory) {
+ grpc_socket_factory_ref(s->socket_factory);
+ }
s->active_ports = 0;
s->destroyed_ports = 0;
s->shutdown = 0;
@@ -139,6 +159,10 @@ static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
gpr_free(sp);
}
+ if (s->socket_factory) {
+ grpc_socket_factory_unref(s->socket_factory);
+ }
+
gpr_free(s);
}
@@ -215,8 +239,17 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *s,
}
}
+static int bind_socket(grpc_socket_factory *socket_factory, int sockfd,
+ const grpc_resolved_address *addr) {
+ return (socket_factory != NULL)
+ ? grpc_socket_factory_bind(socket_factory, sockfd, addr)
+ : bind(sockfd, (struct sockaddr *)addr->addr,
+ (socklen_t)addr->len);
+}
+
/* Prepare a recently-created socket for listening. */
-static int prepare_socket(int fd, const grpc_resolved_address *addr) {
+static int prepare_socket(grpc_socket_factory *socket_factory, int fd,
+ const grpc_resolved_address *addr) {
grpc_resolved_address sockname_temp;
struct sockaddr *addr_ptr = (struct sockaddr *)addr->addr;
/* Set send/receive socket buffers to 1 MB */
@@ -246,7 +279,7 @@ static int prepare_socket(int fd, const grpc_resolved_address *addr) {
}
GPR_ASSERT(addr->len < ~(socklen_t)0);
- if (bind(fd, (struct sockaddr *)addr, (socklen_t)addr->len) < 0) {
+ if (bind_socket(socket_factory, fd, addr) < 0) {
char *addr_str;
grpc_sockaddr_to_string(&addr_str, addr, 0);
gpr_log(GPR_ERROR, "bind addr=%s: %s", addr_str, strerror(errno));
@@ -339,7 +372,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
char *addr_str;
char *name;
- port = prepare_socket(fd, addr);
+ port = prepare_socket(s->socket_factory, fd, addr);
if (port >= 0) {
grpc_sockaddr_to_string(&addr_str, addr, 1);
gpr_asprintf(&name, "udp-server-listener:%s", addr_str);
@@ -417,8 +450,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
/* Try listening on IPv6 first. */
addr = &wild6;
// TODO(rjshade): Test and propagate the returned grpc_error*:
- GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP,
- &dsmode, &fd));
+ GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
+ s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
allocated_port1 =
add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb);
if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
@@ -433,8 +466,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s,
}
// TODO(rjshade): Test and propagate the returned grpc_error*:
- GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP,
- &dsmode, &fd));
+ GRPC_ERROR_UNREF(grpc_create_dualstack_socket_using_factory(
+ s->socket_factory, addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd));
if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
}
diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h
index 90842a47f0..9df3fe4d1f 100644
--- a/src/core/lib/iomgr/udp_server.h
+++ b/src/core/lib/iomgr/udp_server.h
@@ -58,7 +58,7 @@ typedef void (*grpc_udp_server_orphan_cb)(grpc_exec_ctx *exec_ctx,
grpc_fd *emfd, void *user_data);
/* Create a server, initially not bound to any ports */
-grpc_udp_server *grpc_udp_server_create(void);
+grpc_udp_server *grpc_udp_server_create(const grpc_channel_args *args);
/* Start listening to bound ports. user_data is passed to callbacks. */
void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index cb6ca34dc6..249d63ddd0 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -124,6 +124,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/iomgr/resolve_address_windows.c',
'src/core/lib/iomgr/resource_quota.c',
'src/core/lib/iomgr/sockaddr_utils.c',
+ 'src/core/lib/iomgr/socket_factory_posix.c',
'src/core/lib/iomgr/socket_mutator.c',
'src/core/lib/iomgr/socket_utils_common_posix.c',
'src/core/lib/iomgr/socket_utils_linux.c',
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 396ec959cd..12d8406323 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -48,9 +48,12 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
+#include <grpc/support/useful.h>
+#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr.h"
+#include "src/core/lib/iomgr/socket_factory_posix.h"
#include "test/core/util/test_config.h"
#define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x)
@@ -94,16 +97,59 @@ static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
g_number_of_orphan_calls++;
}
+struct test_socket_factory {
+ grpc_socket_factory base;
+ int number_of_socket_calls;
+ int number_of_bind_calls;
+};
+typedef struct test_socket_factory test_socket_factory;
+
+static int test_socket_factory_socket(grpc_socket_factory *factory, int domain,
+ int type, int protocol) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ f->number_of_socket_calls++;
+ return socket(domain, type, protocol);
+}
+
+static int test_socket_factory_bind(grpc_socket_factory *factory, int sockfd,
+ const grpc_resolved_address *addr) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ f->number_of_bind_calls++;
+ return bind(sockfd, (struct sockaddr *)addr->addr, (socklen_t)addr->len);
+}
+
+static int test_socket_factory_compare(grpc_socket_factory *a,
+ grpc_socket_factory *b) {
+ return GPR_ICMP(a, b);
+}
+
+static void test_socket_factory_destroy(grpc_socket_factory *factory) {
+ test_socket_factory *f = (test_socket_factory *)factory;
+ gpr_free(f);
+}
+
+static const grpc_socket_factory_vtable test_socket_factory_vtable = {
+ test_socket_factory_socket, test_socket_factory_bind,
+ test_socket_factory_compare, test_socket_factory_destroy};
+
+static test_socket_factory *test_socket_factory_create(void) {
+ test_socket_factory *factory = gpr_malloc(sizeof(test_socket_factory));
+ grpc_socket_factory_init(&factory->base, &test_socket_factory_vtable);
+ factory->number_of_socket_calls = 0;
+ factory->number_of_bind_calls = 0;
+ return factory;
+}
+
static void test_no_op(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
grpc_udp_server_destroy(&exec_ctx, s, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_op_with_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_start");
grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
grpc_udp_server_destroy(&exec_ctx, s, NULL);
@@ -115,7 +161,7 @@ static void test_no_op_with_port(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_port");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -131,12 +177,44 @@ static void test_no_op_with_port(void) {
GPR_ASSERT(g_number_of_orphan_calls == 1);
}
+static void test_no_op_with_port_and_socket_factory(void) {
+ g_number_of_orphan_calls = 0;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
+
+ test_socket_factory *socket_factory = test_socket_factory_create();
+ grpc_arg socket_factory_arg =
+ grpc_socket_factory_to_arg(&socket_factory->base);
+ grpc_channel_args *channel_args =
+ grpc_channel_args_copy_and_add(NULL, &socket_factory_arg, 1);
+ grpc_udp_server *s = grpc_udp_server_create(channel_args);
+ grpc_channel_args_destroy(&exec_ctx, channel_args);
+
+ LOG_TEST("test_no_op_with_port_and_socket_factory");
+
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write,
+ on_fd_orphaned));
+ GPR_ASSERT(socket_factory->number_of_socket_calls == 1);
+ GPR_ASSERT(socket_factory->number_of_bind_calls == 1);
+
+ grpc_udp_server_destroy(&exec_ctx, s, NULL);
+ grpc_exec_ctx_finish(&exec_ctx);
+ grpc_socket_factory_unref(&socket_factory->base);
+
+ /* The server had a single FD, which should have been orphaned. */
+ GPR_ASSERT(g_number_of_orphan_calls == 1);
+}
+
static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr;
struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
LOG_TEST("test_no_op_with_port_and_start");
memset(&resolved_addr, 0, sizeof(resolved_addr));
@@ -160,7 +238,7 @@ static void test_receive(int number_of_clients) {
grpc_resolved_address resolved_addr;
struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
int clifd, svrfd;
- grpc_udp_server *s = grpc_udp_server_create();
+ grpc_udp_server *s = grpc_udp_server_create(NULL);
int i;
int number_of_reads_before;
gpr_timespec deadline;
@@ -243,6 +321,7 @@ int main(int argc, char **argv) {
test_no_op();
test_no_op_with_start();
test_no_op_with_port();
+ test_no_op_with_port_and_socket_factory();
test_no_op_with_port_and_start();
test_receive(1);
test_receive(10);
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 351638389e..5eb74ea77d 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -1111,6 +1111,8 @@ src/core/lib/iomgr/sockaddr_posix.h \
src/core/lib/iomgr/sockaddr_utils.c \
src/core/lib/iomgr/sockaddr_utils.h \
src/core/lib/iomgr/sockaddr_windows.h \
+src/core/lib/iomgr/socket_factory_posix.c \
+src/core/lib/iomgr/socket_factory_posix.h \
src/core/lib/iomgr/socket_mutator.c \
src/core/lib/iomgr/socket_mutator.h \
src/core/lib/iomgr/socket_utils.h \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 14ad133863..81dbd02008 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -7512,6 +7512,7 @@
"src/core/lib/iomgr/sockaddr_posix.h",
"src/core/lib/iomgr/sockaddr_utils.h",
"src/core/lib/iomgr/sockaddr_windows.h",
+ "src/core/lib/iomgr/socket_factory_posix.h",
"src/core/lib/iomgr/socket_mutator.h",
"src/core/lib/iomgr/socket_utils.h",
"src/core/lib/iomgr/socket_utils_posix.h",
@@ -7681,6 +7682,8 @@
"src/core/lib/iomgr/sockaddr_utils.c",
"src/core/lib/iomgr/sockaddr_utils.h",
"src/core/lib/iomgr/sockaddr_windows.h",
+ "src/core/lib/iomgr/socket_factory_posix.c",
+ "src/core/lib/iomgr/socket_factory_posix.h",
"src/core/lib/iomgr/socket_mutator.c",
"src/core/lib/iomgr/socket_mutator.h",
"src/core/lib/iomgr/socket_utils.h",
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj
index afe72746e9..ccf0d4d87d 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj
@@ -349,6 +349,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h" />
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
@@ -595,6 +596,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_common_posix.c">
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
index a7d32afbe1..e9d950a962 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
@@ -145,6 +145,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
@@ -926,6 +929,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
index 62969e31ac..734ce1b025 100644
--- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
+++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
@@ -244,6 +244,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h" />
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
@@ -438,6 +439,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_common_posix.c">
diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
index 30088101f5..63eb9a0305 100644
--- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
@@ -202,6 +202,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
@@ -713,6 +716,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
index 46069134a1..a077f0ec3c 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
@@ -339,6 +339,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h" />
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
@@ -562,6 +563,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_common_posix.c">
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
index d658f4d574..e8b381cdc0 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -148,6 +148,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_utils.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.c">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.c">
<Filter>src\core\lib\iomgr</Filter>
</ClCompile>
@@ -836,6 +839,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\sockaddr_windows.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_factory_posix.h">
+ <Filter>src\core\lib\iomgr</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_mutator.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>