krpc_subr.c (83366) | krpc_subr.c (83651) |
---|---|
1/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */ | 1/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */ |
2/* $FreeBSD: head/sys/nfsclient/krpc_subr.c 83366 2001-09-12 08:38:13Z julian $ */ | |
3 4/* 5 * Copyright (c) 1995 Gordon Ross, Adam Glass 6 * Copyright (c) 1992 Regents of the University of California. 7 * All rights reserved. 8 * 9 * This software was developed by the Computer Systems Engineering group 10 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 27 unchanged lines hidden (view full) --- 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * partially based on: 42 * libnetboot/rpc.c 43 * @(#) Header: rpc.c,v 1.12 93/09/28 08:31:56 leres Exp (LBL) 44 */ 45 | 2 3/* 4 * Copyright (c) 1995 Gordon Ross, Adam Glass 5 * Copyright (c) 1992 Regents of the University of California. 6 * All rights reserved. 7 * 8 * This software was developed by the Computer Systems Engineering group 9 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and --- 27 unchanged lines hidden (view full) --- 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 * SUCH DAMAGE. 39 * 40 * partially based on: 41 * libnetboot/rpc.c 42 * @(#) Header: rpc.c,v 1.12 93/09/28 08:31:56 leres Exp (LBL) 43 */ 44 |
45#include <sys/cdefs.h> 46__FBSDID("$FreeBSD: head/sys/nfsclient/krpc_subr.c 83651 2001-09-18 23:32:09Z peter $"); 47 |
|
46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/malloc.h> 49#include <sys/mbuf.h> 50#include <sys/socket.h> 51#include <sys/socketvar.h> 52#include <sys/uio.h> 53 54#include <net/if.h> 55#include <netinet/in.h> 56 57#include <nfs/rpcv2.h> | 48#include <sys/param.h> 49#include <sys/systm.h> 50#include <sys/malloc.h> 51#include <sys/mbuf.h> 52#include <sys/socket.h> 53#include <sys/socketvar.h> 54#include <sys/uio.h> 55 56#include <net/if.h> 57#include <netinet/in.h> 58 59#include <nfs/rpcv2.h> |
58#include | 60#include <nfsclient/krpc.h> |
59#include <nfs/xdr_subs.h> 60 61/* 62 * Kernel support for Sun RPC 63 * 64 * Used currently for bootstrapping in nfs diskless configurations. 65 */ 66 --- 52 unchanged lines hidden (view full) --- 119 */ 120#define MAX_RESEND_DELAY 5 /* seconds */ 121 122/* 123 * Call portmap to lookup a port number for a particular rpc program 124 * Returns non-zero error on failure. 125 */ 126int | 61#include <nfs/xdr_subs.h> 62 63/* 64 * Kernel support for Sun RPC 65 * 66 * Used currently for bootstrapping in nfs diskless configurations. 67 */ 68 --- 52 unchanged lines hidden (view full) --- 121 */ 122#define MAX_RESEND_DELAY 5 /* seconds */ 123 124/* 125 * Call portmap to lookup a port number for a particular rpc program 126 * Returns non-zero error on failure. 127 */ 128int |
127krpc_portmap(sin, prog, vers, portp, td) 128 struct sockaddr_in *sin; /* server address */ 129 u_int prog, vers; /* host order */ 130 u_int16_t *portp; /* network order */ 131 struct thread *td; | 129krpc_portmap(struct sockaddr_in *sin, u_int prog, u_int vers, u_int16_t *portp, 130 struct thread *td) |
132{ 133 struct sdata { 134 u_int32_t prog; /* call program */ 135 u_int32_t vers; /* call version */ 136 u_int32_t proto; /* call protocol */ 137 u_int32_t port; /* call port (unused) */ 138 } *sdata; 139 struct rdata { --- 19 unchanged lines hidden (view full) --- 159 sdata->prog = txdr_unsigned(prog); 160 sdata->vers = txdr_unsigned(vers); 161 sdata->proto = txdr_unsigned(IPPROTO_UDP); 162 sdata->port = 0; 163 164 sin->sin_port = htons(PMAPPORT); 165 error = krpc_call(sin, PMAPPROG, PMAPVERS, 166 PMAPPROC_GETPORT, &m, NULL, td); | 131{ 132 struct sdata { 133 u_int32_t prog; /* call program */ 134 u_int32_t vers; /* call version */ 135 u_int32_t proto; /* call protocol */ 136 u_int32_t port; /* call port (unused) */ 137 } *sdata; 138 struct rdata { --- 19 unchanged lines hidden (view full) --- 158 sdata->prog = txdr_unsigned(prog); 159 sdata->vers = txdr_unsigned(vers); 160 sdata->proto = txdr_unsigned(IPPROTO_UDP); 161 sdata->port = 0; 162 163 sin->sin_port = htons(PMAPPORT); 164 error = krpc_call(sin, PMAPPROG, PMAPVERS, 165 PMAPPROC_GETPORT, &m, NULL, td); |
167 if (error) | 166 if (error) |
168 return error; 169 170 if (m->m_len < sizeof(*rdata)) { 171 m = m_pullup(m, sizeof(*rdata)); 172 if (m == NULL) 173 return ENOBUFS; 174 } 175 rdata = mtod(m, struct rdata *); --- 4 unchanged lines hidden (view full) --- 180} 181 182/* 183 * Do a remote procedure call (RPC) and wait for its reply. 184 * If from_p is non-null, then we are doing broadcast, and 185 * the address from whence the response came is saved there. 186 */ 187int | 167 return error; 168 169 if (m->m_len < sizeof(*rdata)) { 170 m = m_pullup(m, sizeof(*rdata)); 171 if (m == NULL) 172 return ENOBUFS; 173 } 174 rdata = mtod(m, struct rdata *); --- 4 unchanged lines hidden (view full) --- 179} 180 181/* 182 * Do a remote procedure call (RPC) and wait for its reply. 183 * If from_p is non-null, then we are doing broadcast, and 184 * the address from whence the response came is saved there. 185 */ 186int |
188krpc_call(sa, prog, vers, func, data, from_p, td) 189 struct sockaddr_in *sa; 190 u_int prog, vers, func; 191 struct mbuf **data; /* input/output */ 192 struct sockaddr **from_p; /* output */ 193 struct thread *td; | 187krpc_call(struct sockaddr_in *sa, u_int prog, u_int vers, u_int func, 188 struct mbuf **data, struct sockaddr **from_p, struct thread *td) |
194{ 195 struct socket *so; 196 struct sockaddr_in *sin, ssin; 197 struct sockaddr *from; 198 struct mbuf *m, *nam, *mhead; 199 struct rpc_call *call; 200 struct rpc_reply *reply; 201 struct sockopt sopt; --- 147 unchanged lines hidden (view full) --- 349 if (from) { 350 FREE(from, M_SONAME); 351 from = NULL; 352 } 353 if (m) { 354 m_freem(m); 355 m = NULL; 356 } | 189{ 190 struct socket *so; 191 struct sockaddr_in *sin, ssin; 192 struct sockaddr *from; 193 struct mbuf *m, *nam, *mhead; 194 struct rpc_call *call; 195 struct rpc_reply *reply; 196 struct sockopt sopt; --- 147 unchanged lines hidden (view full) --- 344 if (from) { 345 FREE(from, M_SONAME); 346 from = NULL; 347 } 348 if (m) { 349 m_freem(m); 350 m = NULL; 351 } |
357 bzero(&auio,sizeof(auio)); | 352 bzero(&auio, sizeof(auio)); |
358 auio.uio_resid = len = 1<<16; 359 rcvflg = 0; 360 error = soreceive(so, &from, &auio, &m, NULL, &rcvflg); 361 if (error == EWOULDBLOCK) { 362 secs--; 363 continue; 364 } 365 if (error) --- 85 unchanged lines hidden (view full) --- 451 */ 452struct xdr_string { 453 u_int32_t len; /* length without null or padding */ 454 char data[4]; /* data (longer, of course) */ 455 /* data is padded to a long-word boundary */ 456}; 457 458struct mbuf * | 353 auio.uio_resid = len = 1<<16; 354 rcvflg = 0; 355 error = soreceive(so, &from, &auio, &m, NULL, &rcvflg); 356 if (error == EWOULDBLOCK) { 357 secs--; 358 continue; 359 } 360 if (error) --- 85 unchanged lines hidden (view full) --- 446 */ 447struct xdr_string { 448 u_int32_t len; /* length without null or padding */ 449 char data[4]; /* data (longer, of course) */ 450 /* data is padded to a long-word boundary */ 451}; 452 453struct mbuf * |
459xdr_string_encode(str, len) 460 char *str; 461 int len; | 454xdr_string_encode(char *str, int len) |
462{ 463 struct mbuf *m; 464 struct xdr_string *xs; 465 int dlen; /* padded string length */ 466 int mlen; /* message length */ 467 468 dlen = (len + 3) & ~3; 469 mlen = dlen + 4; --- 18 unchanged lines hidden --- | 455{ 456 struct mbuf *m; 457 struct xdr_string *xs; 458 int dlen; /* padded string length */ 459 int mlen; /* message length */ 460 461 dlen = (len + 3) & ~3; 462 mlen = dlen + 4; --- 18 unchanged lines hidden --- |