From 1bbd17282444f67e6509ecc930326ec4314da93f Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Fri, 21 Feb 2014 09:18:35 -0800 Subject: [PATCH] Replace inet_aton() with inet_pton(). 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 Acked-by: Ben Pfaff --- 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 a8c229415..5413105bb 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 c1c41ec30..b0ff7cfc1 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 e7dd597e1..aa4ab3129 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, -- 2.43.0