[ovs-dev] [PATCH v2 2/4] Replace inet_aton() with inet_pton().

Gurucharan Shetty shettyg at nicira.com
Fri Feb 21 21:14:34 UTC 2014


Windows does not have inet_aton(), but does have a inet_pton().
inet_aton() is not defined in POSIX. But inet_pton() is.

Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
---
 lib/bfd.c         |    2 +-
 lib/socket-util.c |    4 ++--
 vswitchd/bridge.c |    7 ++++---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/bfd.c b/lib/bfd.c
index a8c2294..5413105 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -878,7 +878,7 @@ bfd_forwarding__(struct bfd *bfd) OVS_REQUIRES(mutex)
 static bool
 bfd_lookup_ip(const char *host_name, struct in_addr *addr)
 {
-    if (!inet_aton(host_name, addr)) {
+    if (!inet_pton(AF_INET, host_name, addr)) {
         VLOG_ERR_RL(&rl, "\"%s\" is not a valid IP address", host_name);
         return false;
     }
diff --git a/lib/socket-util.c b/lib/socket-util.c
index 7f385b8..3654951 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -128,7 +128,7 @@ set_dscp(int fd, uint8_t dscp)
 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;
@@ -165,7 +165,7 @@ lookup_hostname(const char *host_name, struct in_addr *addr)
     struct addrinfo *result;
     struct addrinfo hints;
 
-    if (inet_aton(host_name, addr)) {
+    if (inet_pton(AF_INET, host_name, addr)) {
         return 0;
     }
 
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index e7dd597..aa4ab31 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2823,7 +2823,8 @@ bridge_configure_local_iface_netdev(struct bridge *br,
 
     /* If there's no local interface or no IP address, give up. */
     local_iface = iface_from_ofp_port(br, OFPP_LOCAL);
-    if (!local_iface || !c->local_ip || !inet_aton(c->local_ip, &ip)) {
+    if (!local_iface || !c->local_ip
+        || !inet_pton(AF_INET, c->local_ip, &ip)) {
         return;
     }
 
@@ -2833,7 +2834,7 @@ bridge_configure_local_iface_netdev(struct bridge *br,
 
     /* Configure the IP address and netmask. */
     if (!c->local_netmask
-        || !inet_aton(c->local_netmask, &mask)
+        || !inet_pton(AF_INET, c->local_netmask, &mask)
         || !mask.s_addr) {
         mask.s_addr = guess_netmask(ip.s_addr);
     }
@@ -2844,7 +2845,7 @@ bridge_configure_local_iface_netdev(struct bridge *br,
 
     /* Configure the default gateway. */
     if (c->local_gateway
-        && inet_aton(c->local_gateway, &gateway)
+        && inet_pton(AF_INET, c->local_gateway, &gateway)
         && gateway.s_addr) {
         if (!netdev_add_router(netdev, gateway)) {
             VLOG_INFO("bridge %s: configured gateway "IP_FMT,
-- 
1.7.9.5




More information about the dev mailing list