1/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
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
--- 29 unchanged lines hidden (view full) ---
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 171744 2007-08-06 14:26:03Z rwatson $");
47
48#include <sys/param.h>
49#include <sys/systm.h>
50#include <sys/malloc.h>
51#include <sys/mbuf.h>
52#include <sys/proc.h>
53#include <sys/socket.h>
54#include <sys/socketvar.h>
--- 91 unchanged lines hidden (view full) ---
146 int error;
147
148 /* The portmapper port is fixed. */
149 if (prog == PMAPPROG) {
150 *portp = htons(PMAPPORT);
151 return 0;
152 }
153
154 m = m_get(M_TRYWAIT, MT_DATA);
155 if (m == NULL)
156 return ENOBUFS;
157 sdata = mtod(m, struct sdata *);
158 m->m_len = sizeof(*sdata);
159
160 /* Do the RPC to get it. */
161 sdata->prog = txdr_unsigned(prog);
162 sdata->vers = txdr_unsigned(vers);
163 sdata->proto = txdr_unsigned(IPPROTO_UDP);
164 sdata->port = 0;
--- 104 unchanged lines hidden (view full) ---
269
270 /*
271 * Setup socket address for the server.
272 */
273
274 /*
275 * Prepend RPC message header.
276 */
277 mhead = m_gethdr(M_TRYWAIT, MT_DATA);
278 mhead->m_next = *data;
279 call = mtod(mhead, struct krpc_call *);
280 mhead->m_len = sizeof(*call);
281 bzero((caddr_t)call, sizeof(*call));
282 /* rpc_call part */
283 xid++;
284 call->rp_xid = txdr_unsigned(xid);
285 /* call->rp_direction = 0; */
--- 17 unchanged lines hidden (view full) ---
303 /*
304 * Send it, repeatedly, until a reply is received,
305 * but delay each re-send by an increasing amount.
306 * If the delay hits the maximum, start complaining.
307 */
308 timo = 0;
309 for (;;) {
310 /* Send RPC request (or re-send). */
311 m = m_copym(mhead, 0, M_COPYALL, M_TRYWAIT);
312 if (m == NULL) {
313 error = ENOBUFS;
314 goto out;
315 }
316 error = sosend(so, (struct sockaddr *)sa, NULL, m,
317 NULL, 0, td);
318 if (error) {
319 printf("krpc_call: sosend: %d\n", error);
320 goto out;
321 }
322 m = NULL;
323
--- 133 unchanged lines hidden (view full) ---
457 int mlen; /* message length */
458
459 dlen = (len + 3) & ~3;
460 mlen = dlen + 4;
461
462 if (mlen > MCLBYTES) /* If too big, we just can't do it. */
463 return (NULL);
464
465 m = m_get(M_TRYWAIT, MT_DATA);
466 if (mlen > MLEN) {
467 MCLGET(m, M_TRYWAIT);
468 if ((m->m_flags & M_EXT) == 0) {
469 (void) m_free(m); /* There can be only one. */
470 return (NULL);
471 }
472 }
473 xs = mtod(m, struct xdr_string *);
474 m->m_len = mlen;
475 xs->len = txdr_unsigned(len);
476 bcopy(str, xs->data, len);
477 return (m);
478}
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
--- 29 unchanged lines hidden (view full) ---
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 171744 2007-08-06 14:26:03Z rwatson $");
47
48#include <sys/param.h>
49#include <sys/systm.h>
50#include <sys/malloc.h>
51#include <sys/mbuf.h>
52#include <sys/proc.h>
53#include <sys/socket.h>
54#include <sys/socketvar.h>
--- 91 unchanged lines hidden (view full) ---
146 int error;
147
148 /* The portmapper port is fixed. */
149 if (prog == PMAPPROG) {
150 *portp = htons(PMAPPORT);
151 return 0;
152 }
153
154 m = m_get(M_TRYWAIT, MT_DATA);
155 if (m == NULL)
156 return ENOBUFS;
157 sdata = mtod(m, struct sdata *);
158 m->m_len = sizeof(*sdata);
159
160 /* Do the RPC to get it. */
161 sdata->prog = txdr_unsigned(prog);
162 sdata->vers = txdr_unsigned(vers);
163 sdata->proto = txdr_unsigned(IPPROTO_UDP);
164 sdata->port = 0;
--- 104 unchanged lines hidden (view full) ---
269
270 /*
271 * Setup socket address for the server.
272 */
273
274 /*
275 * Prepend RPC message header.
276 */
277 mhead = m_gethdr(M_TRYWAIT, MT_DATA);
278 mhead->m_next = *data;
279 call = mtod(mhead, struct krpc_call *);
280 mhead->m_len = sizeof(*call);
281 bzero((caddr_t)call, sizeof(*call));
282 /* rpc_call part */
283 xid++;
284 call->rp_xid = txdr_unsigned(xid);
285 /* call->rp_direction = 0; */
--- 17 unchanged lines hidden (view full) ---
303 /*
304 * Send it, repeatedly, until a reply is received,
305 * but delay each re-send by an increasing amount.
306 * If the delay hits the maximum, start complaining.
307 */
308 timo = 0;
309 for (;;) {
310 /* Send RPC request (or re-send). */
311 m = m_copym(mhead, 0, M_COPYALL, M_TRYWAIT);
312 if (m == NULL) {
313 error = ENOBUFS;
314 goto out;
315 }
316 error = sosend(so, (struct sockaddr *)sa, NULL, m,
317 NULL, 0, td);
318 if (error) {
319 printf("krpc_call: sosend: %d\n", error);
320 goto out;
321 }
322 m = NULL;
323
--- 133 unchanged lines hidden (view full) ---
457 int mlen; /* message length */
458
459 dlen = (len + 3) & ~3;
460 mlen = dlen + 4;
461
462 if (mlen > MCLBYTES) /* If too big, we just can't do it. */
463 return (NULL);
464
465 m = m_get(M_TRYWAIT, MT_DATA);
466 if (mlen > MLEN) {
467 MCLGET(m, M_TRYWAIT);
468 if ((m->m_flags & M_EXT) == 0) {
469 (void) m_free(m); /* There can be only one. */
470 return (NULL);
471 }
472 }
473 xs = mtod(m, struct xdr_string *);
474 m->m_len = mlen;
475 xs->len = txdr_unsigned(len);
476 bcopy(str, xs->data, len);
477 return (m);
478}