[ovs-dev] [PATCH 04/14] socket-util: inet_aton for Windows.

Gurucharan Shetty shettyg at nicira.com
Wed Feb 19 23:36:15 UTC 2014


Windows does not have a inet_aton(). But does have a
inet_pton().

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/socket-util.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/lib/socket-util.c b/lib/socket-util.c
index cde4d71..b3b1ae5 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -173,6 +173,20 @@ get_max_fds(void)
 #endif
 }
 
+#ifdef _WIN32
+static int inet_aton(const char *host_name, struct in_addr *addr)
+{
+    int retval = inet_pton(AF_INET, host_name, addr);
+    if (retval == -1) {
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+        VLOG_ERR_RL(&rl, "inet_pton returned error: %s",
+                    sock_strerror(sock_errno()));
+        return 0;
+    }
+    return retval;
+}
+#endif
+
 /* 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. */
-- 
1.7.9.5




More information about the dev mailing list