2 * Copyright (c) 2008, 2009 Nicira Networks.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #define SOCKET_UTIL_H 1
20 #include <sys/types.h>
21 #include <netinet/in.h>
24 int set_nonblocking(int fd);
25 int get_max_fds(void);
26 int lookup_ip(const char *host_name, struct in_addr *address);
27 int get_socket_error(int sock);
28 int check_connection_completion(int fd);
29 int drain_rcvbuf(int fd);
30 void drain_fd(int fd, size_t n_packets);
31 int make_unix_socket(int style, bool nonblock, bool passcred,
32 const char *bind_path, const char *connect_path);
33 int get_unix_name_len(socklen_t sun_len);
34 uint32_t guess_netmask(uint32_t ip);
36 int read_fully(int fd, void *, size_t, size_t *bytes_read);
37 int write_fully(int fd, const void *, size_t, size_t *bytes_written);
39 #endif /* socket-util.h */