#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
#ifdef GRPC_POSIX_SOCKET_UTILS_COMMON
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <netinet/in.h>
#include "src/core/lib/iomgr/socket_utils.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#ifdef GRPC_LINUX_TCP_H
#include <linux/tcp.h>
#else
#include <netinet/tcp.h>
#endif
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include <grpc/event_engine/endpoint_config.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/strerror.h"
#include "src/core/lib/iomgr/sockaddr.h"
grpc_error_handle grpc_set_socket_zerocopy(int fd) { … }
grpc_error_handle grpc_set_socket_nonblocking(int fd, int non_blocking) { … }
grpc_error_handle grpc_set_socket_no_sigpipe_if_possible(int fd) { … }
grpc_error_handle grpc_set_socket_ip_pktinfo_if_possible(int fd) { … }
grpc_error_handle grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) { … }
grpc_error_handle grpc_set_socket_sndbuf(int fd, int buffer_size_bytes) { … }
grpc_error_handle grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes) { … }
grpc_error_handle grpc_set_socket_cloexec(int fd, int close_on_exec) { … }
grpc_error_handle grpc_set_socket_reuse_addr(int fd, int reuse) { … }
grpc_error_handle grpc_set_socket_reuse_port(int fd, int reuse) { … }
static gpr_once g_probe_so_reuesport_once = …;
static int g_support_so_reuseport = …;
void probe_so_reuseport_once(void) { … }
bool grpc_is_socket_reuse_port_supported() { … }
grpc_error_handle grpc_set_socket_low_latency(int fd, int low_latency) { … }
#define DEFAULT_CLIENT_TCP_USER_TIMEOUT_MS …
#define DEFAULT_SERVER_TCP_USER_TIMEOUT_MS …
static int g_default_client_tcp_user_timeout_ms = …;
static int g_default_server_tcp_user_timeout_ms = …;
static bool g_default_client_tcp_user_timeout_enabled = …;
static bool g_default_server_tcp_user_timeout_enabled = …;
#if GPR_LINUX == 1
#ifndef TCP_USER_TIMEOUT
#define TCP_USER_TIMEOUT …
#endif
#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT …
#else
#ifdef TCP_USER_TIMEOUT
#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT …
#else
#define TCP_USER_TIMEOUT …
#define SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT …
#endif
#endif
static std::atomic<int> g_socket_supports_tcp_user_timeout(
SOCKET_SUPPORTS_TCP_USER_TIMEOUT_DEFAULT);
void config_default_tcp_user_timeout(bool enable, int timeout, bool is_client) { … }
grpc_error_handle grpc_set_socket_tcp_user_timeout(
int fd, const grpc_core::PosixTcpOptions& options, bool is_client) { … }
grpc_error_handle grpc_set_socket_with_mutator(int fd, grpc_fd_usage usage,
grpc_socket_mutator* mutator) { … }
grpc_error_handle grpc_apply_socket_mutator_in_args(
int fd, grpc_fd_usage usage, const grpc_core::PosixTcpOptions& options) { … }
static gpr_once g_probe_ipv6_once = …;
static int g_ipv6_loopback_available;
static void probe_ipv6_once(void) { … }
int grpc_ipv6_loopback_available(void) { … }
static grpc_error_handle error_for_fd(int fd,
const grpc_resolved_address* addr) { … }
grpc_error_handle grpc_create_dualstack_socket(
const grpc_resolved_address* resolved_addr, int type, int protocol,
grpc_dualstack_mode* dsmode, int* newfd) { … }
static int create_socket(grpc_socket_factory* factory, int domain, int type,
int protocol) { … }
grpc_error_handle 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) { … }
#endif