diff options
author | 2016-03-28 22:53:34 -0700 | |
---|---|---|
committer | 2016-03-28 22:53:34 -0700 | |
commit | c2011586fae18c7b247686428a2469198589a1f9 (patch) | |
tree | dfcd31dd1d881e6c2bda9b565f853cb0d6ccb7d3 /src/core/lib/iomgr/socket_utils_common_posix.c | |
parent | 3bd96959398d0671fee3785d4b2aee6042649b15 (diff) | |
parent | c91504ed57c93d30f654d9f3a0fee62c1236fad8 (diff) |
Merge github.com:grpc/grpc into idempotent
Diffstat (limited to 'src/core/lib/iomgr/socket_utils_common_posix.c')
-rw-r--r-- | src/core/lib/iomgr/socket_utils_common_posix.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.c b/src/core/lib/iomgr/socket_utils_common_posix.c index 9dbc2784e4..b433aee7fa 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.c +++ b/src/core/lib/iomgr/socket_utils_common_posix.c @@ -89,6 +89,28 @@ int grpc_set_socket_no_sigpipe_if_possible(int fd) { #endif } +int grpc_set_socket_ip_pktinfo_if_possible(int fd) { +#ifdef GPR_HAVE_IP_PKTINFO + int get_local_ip = 1; + return 0 == setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &get_local_ip, + sizeof(get_local_ip)); +#else + (void)fd; + return 1; +#endif +} + +int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) { +#ifdef GPR_HAVE_IPV6_RECVPKTINFO + int get_local_ip = 1; + return 0 == setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip, + sizeof(get_local_ip)); +#else + (void)fd; + return 1; +#endif +} + /* set a socket to close on exec */ int grpc_set_socket_cloexec(int fd, int close_on_exec) { int oldflags = fcntl(fd, F_GETFD, 0); |