22 #ifdef GRPC_POSIX_SOCKET_UTILS_COMMON
25 #include <netinet/in.h>
26 #include <netinet/ip.h>
38 struct test_socket_mutator {
45 socklen_t intlen =
sizeof(newval);
46 struct test_socket_mutator*
m =
47 reinterpret_cast<struct test_socket_mutator*
>(mutator);
49 if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &
m->option_value,
50 sizeof(
m->option_value))) {
53 if (0 != getsockopt(fd, IPPROTO_IP, IP_TOS, &newval, &intlen)) {
56 if (newval !=
m->option_value) {
65 socklen_t intlen =
sizeof(newval);
66 struct test_socket_mutator*
m =
67 reinterpret_cast<struct test_socket_mutator*
>(mutator);
69 if (0 != setsockopt(info->
fd, IPPROTO_IP, IP_TOS, &
m->option_value,
70 sizeof(
m->option_value))) {
73 if (0 != getsockopt(info->
fd, IPPROTO_IP, IP_TOS, &newval, &intlen)) {
76 if (newval !=
m->option_value) {
83 struct test_socket_mutator*
m =
84 reinterpret_cast<struct test_socket_mutator*
>(mutator);
90 struct test_socket_mutator* ma =
91 reinterpret_cast<struct test_socket_mutator*
>(
a);
92 struct test_socket_mutator* mb =
93 reinterpret_cast<struct test_socket_mutator*
>(
b);
98 mutate_fd, compare_test_mutator, destroy_test_mutator,
nullptr};
101 nullptr, compare_test_mutator, destroy_test_mutator, mutate_fd_2};
104 int sock =
socket(PF_INET, SOCK_STREAM, 0);
107 struct test_socket_mutator mutator;
110 mutator.option_value = IPTOS_LOWDELAY;
112 "set_socket_with_mutator",
116 mutator.option_value = IPTOS_THROUGHPUT;
118 "set_socket_with_mutator",
122 mutator.option_value = IPTOS_RELIABILITY;
124 "set_socket_with_mutator",
128 mutator.option_value = -1;
136 int main(
int argc,
char** argv) {
140 sock =
socket(PF_INET, SOCK_STREAM, 0);
160 test_with_vtable(&mutator_vtable);
161 test_with_vtable(&mutator_vtable2);
170 int main(
int argc,
char** argv) {
return 1; }