]> err.no Git - linux-2.6/commitdiff
SUNRPC: Add support for formatted universal addresses
authorChuck Lever <chuck.lever@oracle.com>
Thu, 16 Aug 2007 20:03:26 +0000 (16:03 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 9 Oct 2007 21:16:29 +0000 (17:16 -0400)
"Universal addresses" are a string representation of an IP address and
port.  They are described fully in RFC 3530, section 2.2.  Add support
for generating them in the RPC client's socket transport module.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
include/linux/sunrpc/xprt.h
net/sunrpc/xprtsock.c

index 4596c26f97aa32fb6a037654827b1038b99acebe..902a9c0a2d9ae63e8f514f04c5459d57fd9f23b3 100644 (file)
@@ -55,6 +55,7 @@ enum rpc_display_format_t {
        RPC_DISPLAY_ALL,
        RPC_DISPLAY_HEX_ADDR,
        RPC_DISPLAY_HEX_PORT,
+       RPC_DISPLAY_UNIVERSAL_ADDR,
        RPC_DISPLAY_MAX,
 };
 
index 01121a4f0851711062b1d517a2a1b3cb394338a9..7a154e4b70f52f5e2eb4d65058b28cd57fb479ab 100644 (file)
@@ -328,6 +328,15 @@ static void xs_format_ipv4_peer_addresses(struct rpc_xprt *xprt)
                                ntohs(addr->sin_port));
        }
        xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
+
+       buf = kzalloc(30, GFP_KERNEL);
+       if (buf) {
+               snprintf(buf, 30, NIPQUAD_FMT".%u.%u",
+                               NIPQUAD(addr->sin_addr.s_addr),
+                               ntohs(addr->sin_port) >> 8,
+                               ntohs(addr->sin_port) & 0xff);
+       }
+       xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
 }
 
 static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt)
@@ -380,6 +389,15 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt)
                                ntohs(addr->sin6_port));
        }
        xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
+
+       buf = kzalloc(50, GFP_KERNEL);
+       if (buf) {
+               snprintf(buf, 50, NIP6_FMT".%u.%u",
+                               NIP6(addr->sin6_addr),
+                               ntohs(addr->sin6_port) >> 8,
+                               ntohs(addr->sin6_port) & 0xff);
+       }
+       xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
 }
 
 static void xs_free_peer_addresses(struct rpc_xprt *xprt)