diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2008-08-20 16:10:22 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-10-07 18:17:36 -0400 |
commit | f0c929251e01a7a86b6254c775cb6b65c6457f10 (patch) | |
tree | 18016ca1cffa8ab1bbe2c064bbf76bba443d8b78 /fs/nfs/internal.h | |
parent | 460cdbc83268dd9641b57d893b03ef52fcc3f96d (diff) |
nfs: prepare to share nfs_set_port
We plan to use this function elsewhere.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/internal.h')
-rw-r--r-- | fs/nfs/internal.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 7bcf6ec2d458..8d91bd88e310 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -276,3 +276,23 @@ unsigned int nfs_page_array_len(unsigned int base, size_t len) PAGE_SIZE - 1) >> PAGE_SHIFT; } + +/* + * Set the port number in an address. Be agnostic about the address + * family. + */ +static inline void nfs_set_port(struct sockaddr *sap, unsigned short port) +{ + switch (sap->sa_family) { + case AF_INET: { + struct sockaddr_in *ap = (struct sockaddr_in *)sap; + ap->sin_port = htons(port); + break; + } + case AF_INET6: { + struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; + ap->sin6_port = htons(port); + break; + } + } +} |