diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2010-08-31 15:27:19 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-08-31 15:34:23 -0400 |
commit | 03fc34b23c2bff48f54c2d889d7851a31fb64a3d (patch) | |
tree | b65ddee99a52c8c12a6d23ade28bc97467cc51c0 /support | |
parent | 502edf1df5e727cf88b19b634f60392652f35ddc (diff) | |
download | nfs-utils-03fc34b23c2bff48f54c2d889d7851a31fb64a3d.tar.gz nfs-utils-03fc34b23c2bff48f54c2d889d7851a31fb64a3d.tar.xz nfs-utils-03fc34b23c2bff48f54c2d889d7851a31fb64a3d.zip |
libexport.a: Use host helper to parse address in client_init()
Take the first step towards making it possible to parse either IPv4 or
IPv6 addresses in client_init(). It won't handle IPv6 until
host_pton() has IPv6 support enabled, and it still doesn't deal with
IPv6 netmasks yet.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support')
-rw-r--r-- | support/export/client.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/support/export/client.c b/support/export/client.c index 3e797c9..a89142d 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -86,10 +86,8 @@ out_badprefix: static int init_subnetwork(nfs_client *clp) { - struct sockaddr_in sin = { - .sin_family = AF_INET, - }; static char slash32[] = "/32"; + struct addrinfo *ai; char *cp; cp = strchr(clp->m_hostname, '/'); @@ -97,9 +95,14 @@ init_subnetwork(nfs_client *clp) cp = slash32; *cp = '\0'; - sin.sin_addr.s_addr = inet_addr(clp->m_hostname); - set_addrlist_in(clp, 0, &sin); + ai = host_pton(clp->m_hostname); *cp = '/'; + if (ai == NULL) { + xlog(L_ERROR, "Invalid IP address %s", clp->m_hostname); + return false; + } + set_addrlist(clp, 0, ai->ai_addr); + freeaddrinfo(ai); return init_netmask(clp, cp); } |