aboutsummaryrefslogtreecommitdiff
path: root/fs/lockd
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-12-04 14:20:16 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-01-06 11:53:49 -0500
commitafb03699dc0a920aed3322ad0e6895533941fb1e (patch)
tree8be804b0e4985a5dba70fccc94ce0939292d3f8d /fs/lockd
parentbc995801a09d1fead0bec1356bfd836911c8eed7 (diff)
NLM: Add helper to handle IPv4 addresses
Clean up: introduce a helper function to generate IPv4 addresses using the same style as the IPv6 helper function we just added. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/host.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 012e49aaecd..780918acd6f 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -105,6 +105,13 @@ static void nlm_clear_port(struct sockaddr *sap)
}
}
+static void nlm_display_ipv4_address(const struct sockaddr *sap, char *buf,
+ const size_t len)
+{
+ const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
+ snprintf(buf, len, "%pI4", &sin->sin_addr.s_addr);
+}
+
static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
const size_t len)
{
@@ -122,11 +129,9 @@ static void nlm_display_ipv6_address(const struct sockaddr *sap, char *buf,
static void nlm_display_address(const struct sockaddr *sap,
char *buf, const size_t len)
{
- const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
-
switch (sap->sa_family) {
case AF_INET:
- snprintf(buf, len, "%pI4", &sin->sin_addr.s_addr);
+ nlm_display_ipv4_address(sap, buf, len);
break;
case AF_INET6:
nlm_display_ipv6_address(sap, buf, len);