Lines Matching refs:fd

30 static int get_so_domain(int fd)  in get_so_domain()  argument
36 err = getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &domain, &len); in get_so_domain()
43 static int bind_to_loopback_any_port(int fd) in bind_to_loopback_any_port() argument
53 switch (get_so_domain(fd)) { in bind_to_loopback_any_port()
70 return bind(fd, &addr.sa, addr_len); in bind_to_loopback_any_port()
73 static int get_sock_port(int fd) in get_sock_port() argument
85 err = getsockname(fd, &addr.sa, &addr_len); in get_sock_port()
100 static int get_ip_local_port_range(int fd, __u32 *range) in get_ip_local_port_range() argument
107 err = getsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val, &len); in get_ip_local_port_range()
172 int fd, err; in TEST_F() local
174 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
175 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
179 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val16, sizeof(val16)); in TEST_F()
185 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val32, sizeof(val32)); in TEST_F()
191 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val64, sizeof(val64)); in TEST_F()
195 err = close(fd); in TEST_F()
221 int fd, err, port; in TEST_F() local
224 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
225 ASSERT_GE(fd, 0) TH_LOG("#%d: socket failed", i); in TEST_F()
228 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
231 err = bind_to_loopback_any_port(fd); in TEST_F()
235 port = get_sock_port(fd); in TEST_F()
239 fds[i] = fd; in TEST_F()
264 int fd, err, port; in TEST_F() local
270 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
271 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
274 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
277 err = bind_to_loopback_any_port(fd); in TEST_F()
280 port = get_sock_port(fd); in TEST_F()
283 err = close(fd); in TEST_F()
291 int i, fd, err; in TEST_F() local
297 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
298 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
301 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
304 err = bind_to_loopback_any_port(fd); in TEST_F()
307 port = get_sock_port(fd); in TEST_F()
312 fds[i] = fd; in TEST_F()
319 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
320 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
323 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
326 err = bind_to_loopback_any_port(fd); in TEST_F()
330 err = close(fd); in TEST_F()
348 int fd, err; in TEST_F() local
355 fd = socket(variant->so_domain, variant->so_type, 0); in TEST_F()
356 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
359 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
362 err = setsockopt(fd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, &one, sizeof(one)); in TEST_F()
365 err = bind_to_loopback_any_port(fd); in TEST_F()
368 port = get_sock_port(fd); in TEST_F()
391 connect(fd, &addr.sa, addr_len); in TEST_F()
393 port = get_sock_port(fd); in TEST_F()
397 err = close(fd); in TEST_F()
405 int fd, err; in TEST_F() local
407 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
408 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
411 err = get_ip_local_port_range(fd, &range); in TEST_F()
419 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
423 err = get_ip_local_port_range(fd, &range); in TEST_F()
432 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
436 err = get_ip_local_port_range(fd, &range); in TEST_F()
443 err = close(fd); in TEST_F()