Lines Matching full:fd
34 static int get_so_domain(int fd) in get_so_domain() argument
40 err = getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &domain, &len); in get_so_domain()
47 static int bind_to_loopback_any_port(int fd) in bind_to_loopback_any_port() argument
57 switch (get_so_domain(fd)) { in bind_to_loopback_any_port()
74 return bind(fd, &addr.sa, addr_len); in bind_to_loopback_any_port()
77 static int get_sock_port(int fd) in get_sock_port() argument
89 err = getsockname(fd, &addr.sa, &addr_len); in get_sock_port()
104 static int get_ip_local_port_range(int fd, __u32 *range) in get_ip_local_port_range() argument
111 err = getsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val, &len); in get_ip_local_port_range()
188 int fd, err; in TEST_F() local
190 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
191 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
195 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val16, sizeof(val16)); in TEST_F()
201 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val32, sizeof(val32)); in TEST_F()
207 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &val64, sizeof(val64)); in TEST_F()
211 err = close(fd); in TEST_F()
237 int fd, err, port; in TEST_F() local
240 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
241 ASSERT_GE(fd, 0) TH_LOG("#%d: socket failed", i); in TEST_F()
244 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
247 err = bind_to_loopback_any_port(fd); in TEST_F()
251 port = get_sock_port(fd); in TEST_F()
255 fds[i] = fd; in TEST_F()
280 int fd, err, port; in TEST_F() local
286 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
287 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
290 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
293 err = bind_to_loopback_any_port(fd); in TEST_F()
296 port = get_sock_port(fd); in TEST_F()
299 err = close(fd); in TEST_F()
307 int i, fd, err; in TEST_F() local
313 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
314 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
317 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
320 err = bind_to_loopback_any_port(fd); in TEST_F()
323 port = get_sock_port(fd); in TEST_F()
328 fds[i] = fd; in TEST_F()
335 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
336 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
339 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
342 err = bind_to_loopback_any_port(fd); in TEST_F()
346 err = close(fd); in TEST_F()
364 int fd, err; in TEST_F() local
368 fd = socket(variant->so_domain, variant->so_type, 0); in TEST_F()
369 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
372 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
375 err = setsockopt(fd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, &one, sizeof(one)); in TEST_F()
378 err = bind_to_loopback_any_port(fd); in TEST_F()
381 port = get_sock_port(fd); in TEST_F()
404 connect(fd, &addr.sa, addr_len); in TEST_F()
406 port = get_sock_port(fd); in TEST_F()
410 err = close(fd); in TEST_F()
421 int fd, err; in TEST_F() local
423 fd = socket(variant->so_domain, variant->so_type, variant->so_protocol); in TEST_F()
424 ASSERT_GE(fd, 0) TH_LOG("socket failed"); in TEST_F()
427 err = get_ip_local_port_range(fd, &range); in TEST_F()
435 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
439 err = get_ip_local_port_range(fd, &range); in TEST_F()
448 err = setsockopt(fd, SOL_IP, IP_LOCAL_PORT_RANGE, &range, sizeof(range)); in TEST_F()
452 err = get_ip_local_port_range(fd, &range); in TEST_F()
459 err = close(fd); in TEST_F()