return 0;
}
-static bool
-rlim_is_finite(rlim_t limit)
-{
- if (limit == RLIM_INFINITY) {
- return false;
- }
-
-#ifdef RLIM_SAVED_CUR /* FreeBSD 8.0 lacks RLIM_SAVED_CUR. */
- if (limit == RLIM_SAVED_CUR) {
- return false;
- }
-#endif
-
-#ifdef RLIM_SAVED_MAX /* FreeBSD 8.0 lacks RLIM_SAVED_MAX. */
- if (limit == RLIM_SAVED_MAX) {
- return false;
- }
-#endif
-
- return true;
-}
-
-/* Returns the maximum valid FD value, plus 1. */
-int
-get_max_fds(void)
-{
- static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
- static int max_fds;
-
- if (ovsthread_once_start(&once)) {
- struct rlimit r;
- if (!getrlimit(RLIMIT_NOFILE, &r) && rlim_is_finite(r.rlim_cur)) {
- max_fds = r.rlim_cur;
- } else {
- VLOG_WARN("failed to obtain fd limit, defaulting to 1024");
- max_fds = 1024;
- }
- ovsthread_once_done(&once);
- }
-
- return max_fds;
-}
-
/* Translates 'host_name', which must be a string representation of an IP
* address, into a numeric IP address in '*addr'. Returns 0 if successful,
* otherwise a positive errno value. */
int
lookup_ip(const char *host_name, struct in_addr *addr)
{
- if (!inet_aton(host_name, addr)) {
+ if (!inet_pton(AF_INET, host_name, addr)) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name);
return ENOENT;
struct addrinfo *result;
struct addrinfo hints;
- if (inet_aton(host_name, addr)) {
+ if (inet_pton(AF_INET, host_name, addr)) {
return 0;
}
}
}
+#ifndef _WIN32
/* Attempts to shorten 'name' by opening a file descriptor for the directory
* part of the name and indirecting through /proc/self/fd/<dirfd>/<basename>.
* On systems with Linux-like /proc, this works as long as <basename> isn't too
? sun_len - offsetof(struct sockaddr_un, sun_path)
: 0);
}
+#endif /* _WIN32 */
ovs_be32
guess_netmask(ovs_be32 ip_)
ds_put_format(string, "%s:%"PRIu16,
ss_format_address(&ss, addrbuf, sizeof addrbuf),
ss_get_port(&ss));
+#ifndef _WIN32
} else if (ss.ss_family == AF_UNIX) {
struct sockaddr_un sun;
const char *null;
null = memchr(sun.sun_path, '\0', maxlen);
ds_put_buffer(string, sun.sun_path,
null ? null - sun.sun_path : maxlen);
+#endif
}
#ifdef HAVE_NETLINK
else if (ss.ss_family == AF_NETLINK) {