diff options
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) | |||
276 | PAGE_SIZE - 1) >> PAGE_SHIFT; | 276 | PAGE_SIZE - 1) >> PAGE_SHIFT; |
277 | } | 277 | } |
278 | 278 | ||
279 | |||
280 | /* | ||
281 | * Set the port number in an address. Be agnostic about the address | ||
282 | * family. | ||
283 | */ | ||
284 | static inline void nfs_set_port(struct sockaddr *sap, unsigned short port) | ||
285 | { | ||
286 | switch (sap->sa_family) { | ||
287 | case AF_INET: { | ||
288 | struct sockaddr_in *ap = (struct sockaddr_in *)sap; | ||
289 | ap->sin_port = htons(port); | ||
290 | break; | ||
291 | } | ||
292 | case AF_INET6: { | ||
293 | struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; | ||
294 | ap->sin6_port = htons(port); | ||
295 | break; | ||
296 | } | ||
297 | } | ||
298 | } | ||