]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nfs/getport.c
nfs-utils: Fix source code character encoding
[nfs-utils.git] / support / nfs / getport.c
index 7e0f7982592467279e0d124f91c4adbc13a92801..d74400b0dcfe69eac02b8dbc2c531d01b16c9d79 100644 (file)
@@ -45,6 +45,7 @@
 #include <rpc/rpcb_prot.h>
 #endif
 
+#include "sockaddr.h"
 #include "nfsrpc.h"
 
 /*
@@ -215,6 +216,21 @@ nfs_get_proto(const char *netid, sa_family_t *family, unsigned long *protocol)
        struct netconfig *nconf;
        struct protoent *proto;
 
+       /*
+        * IANA does not define a protocol number for rdma netids,
+        * since "rdma" is not an IP protocol.
+        */
+       if (strcmp(netid, "rdma") == 0) {
+               *family = AF_INET;
+               *protocol = NFSPROTO_RDMA;
+               return 1;
+       }
+       if (strcmp(netid, "rdma6") == 0) {
+               *family = AF_INET6;
+               *protocol = NFSPROTO_RDMA;
+               return 1;
+       }
+
        nconf = getnetconfigent(netid);
        if (nconf == NULL)
                return 0;
@@ -241,6 +257,16 @@ nfs_get_proto(const char *netid, sa_family_t *family, unsigned long *protocol)
 {
        struct protoent *proto;
 
+       /*
+        * IANA does not define a protocol number for rdma netids,
+        * since "rdma" is not an IP protocol.
+        */
+       if (strcmp(netid, "rdma") == 0) {
+               *family = AF_INET;
+               *protocol = NFSPROTO_RDMA;
+               return 1;
+       }
+
        proto = getprotobyname(netid);
        if (proto == NULL)
                return 0;
@@ -705,8 +731,8 @@ int nfs_rpc_ping(const struct sockaddr *sap, const socklen_t salen,
                 const rpcprog_t program, const rpcvers_t version,
                 const unsigned short protocol, const struct timeval *timeout)
 {
-       struct sockaddr_storage address;
-       struct sockaddr *saddr = (struct sockaddr *)&address;
+       union nfs_sockaddr address;
+       struct sockaddr *saddr = &address.sa;
        CLIENT *client;
        struct timeval tout = { -1, 0 };
        int result = 0;
@@ -774,8 +800,8 @@ unsigned short nfs_getport(const struct sockaddr *sap,
                           const rpcvers_t version,
                           const unsigned short protocol)
 {
-       struct sockaddr_storage address;
-       struct sockaddr *saddr = (struct sockaddr *)&address;
+       union nfs_sockaddr address;
+       struct sockaddr *saddr = &address.sa;
        struct timeval timeout = { -1, 0 };
        unsigned short port = 0;
        CLIENT *client;
@@ -833,8 +859,8 @@ int nfs_getport_ping(struct sockaddr *sap, const socklen_t salen,
        }
 
        if (port != 0) {
-               struct sockaddr_storage address;
-               struct sockaddr *saddr = (struct sockaddr *)&address;
+               union nfs_sockaddr address;
+               struct sockaddr *saddr = &address.sa;
 
                memcpy(saddr, sap, (size_t)salen);
                nfs_set_port(saddr, port);
@@ -885,8 +911,8 @@ unsigned short nfs_getlocalport(const rpcprot_t program,
                                const rpcvers_t version,
                                const unsigned short protocol)
 {
-       struct sockaddr_storage address;
-       struct sockaddr *lb_addr = (struct sockaddr *)&address;
+       union nfs_sockaddr address;
+       struct sockaddr *lb_addr = &address.sa;
        socklen_t lb_len = sizeof(*lb_addr);
        unsigned short port = 0;
 
@@ -969,8 +995,8 @@ unsigned short nfs_rpcb_getaddr(const struct sockaddr *sap,
                                const unsigned short protocol,
                                const struct timeval *timeout)
 {
-       struct sockaddr_storage address;
-       struct sockaddr *saddr = (struct sockaddr *)&address;
+       union nfs_sockaddr address;
+       struct sockaddr *saddr = &address.sa;
        CLIENT *client;
        struct rpcb parms;
        struct timeval tout = { -1, 0 };