X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fgetport.c;h=3331ad4beda75af72a256a578456c3b3212ef326;hp=7e0f7982592467279e0d124f91c4adbc13a92801;hb=3302783c6ccd992b8e8dc479620c54533ef7bf9d;hpb=626010056efb7baa76b08b5e6572720e02e425b4 diff --git a/support/nfs/getport.c b/support/nfs/getport.c index 7e0f798..3331ad4 100644 --- a/support/nfs/getport.c +++ b/support/nfs/getport.c @@ -17,8 +17,8 @@ * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 0211-1301 USA * */ @@ -45,6 +45,7 @@ #include #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 };