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 177599 2008-03-25 09:39:02Z ru $");
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_WAIT, MT_DATA);
155 sdata = mtod(m, struct sdata *);
156 m->m_len = sizeof(*sdata);
157
158 /* Do the RPC to get it. */
159 sdata->prog = txdr_unsigned(prog);
160 sdata->vers = txdr_unsigned(vers);
161 sdata->proto = txdr_unsigned(IPPROTO_UDP);
162 sdata->port = 0;
--- 104 unchanged lines hidden (view full) ---
267
268 /*
269 * Setup socket address for the server.
270 */
271
272 /*
273 * Prepend RPC message header.
274 */
275 mhead = m_gethdr(M_WAIT, MT_DATA);
276 mhead->m_next = *data;
277 call = mtod(mhead, struct krpc_call *);
278 mhead->m_len = sizeof(*call);
279 bzero((caddr_t)call, sizeof(*call));
280 /* rpc_call part */
281 xid++;
282 call->rp_xid = txdr_unsigned(xid);
283 /* call->rp_direction = 0; */
--- 17 unchanged lines hidden (view full) ---
301 /*
302 * Send it, repeatedly, until a reply is received,
303 * but delay each re-send by an increasing amount.
304 * If the delay hits the maximum, start complaining.
305 */
306 timo = 0;
307 for (;;) {
308 /* Send RPC request (or re-send). */
309 m = m_copym(mhead, 0, M_COPYALL, M_WAIT);
310 error = sosend(so, (struct sockaddr *)sa, NULL, m,
311 NULL, 0, td);
312 if (error) {
313 printf("krpc_call: sosend: %d\n", error);
314 goto out;
315 }
316 m = NULL;
317
--- 133 unchanged lines hidden (view full) ---
451 int mlen; /* message length */
452
453 dlen = (len + 3) & ~3;
454 mlen = dlen + 4;
455
456 if (mlen > MCLBYTES) /* If too big, we just can't do it. */
457 return (NULL);
458
459 m = m_get(M_WAIT, MT_DATA);
460 if (mlen > MLEN)
461 MCLGET(m, M_WAIT);
462 xs = mtod(m, struct xdr_string *);
463 m->m_len = mlen;
464 xs->len = txdr_unsigned(len);
465 bcopy(str, xs->data, len);
466 return (m);
467}
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 177599 2008-03-25 09:39:02Z ru $");
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_WAIT, MT_DATA);
155 sdata = mtod(m, struct sdata *);
156 m->m_len = sizeof(*sdata);
157
158 /* Do the RPC to get it. */
159 sdata->prog = txdr_unsigned(prog);
160 sdata->vers = txdr_unsigned(vers);
161 sdata->proto = txdr_unsigned(IPPROTO_UDP);
162 sdata->port = 0;
--- 104 unchanged lines hidden (view full) ---
267
268 /*
269 * Setup socket address for the server.
270 */
271
272 /*
273 * Prepend RPC message header.
274 */
275 mhead = m_gethdr(M_WAIT, MT_DATA);
276 mhead->m_next = *data;
277 call = mtod(mhead, struct krpc_call *);
278 mhead->m_len = sizeof(*call);
279 bzero((caddr_t)call, sizeof(*call));
280 /* rpc_call part */
281 xid++;
282 call->rp_xid = txdr_unsigned(xid);
283 /* call->rp_direction = 0; */
--- 17 unchanged lines hidden (view full) ---
301 /*
302 * Send it, repeatedly, until a reply is received,
303 * but delay each re-send by an increasing amount.
304 * If the delay hits the maximum, start complaining.
305 */
306 timo = 0;
307 for (;;) {
308 /* Send RPC request (or re-send). */
309 m = m_copym(mhead, 0, M_COPYALL, M_WAIT);
310 error = sosend(so, (struct sockaddr *)sa, NULL, m,
311 NULL, 0, td);
312 if (error) {
313 printf("krpc_call: sosend: %d\n", error);
314 goto out;
315 }
316 m = NULL;
317
--- 133 unchanged lines hidden (view full) ---
451 int mlen; /* message length */
452
453 dlen = (len + 3) & ~3;
454 mlen = dlen + 4;
455
456 if (mlen > MCLBYTES) /* If too big, we just can't do it. */
457 return (NULL);
458
459 m = m_get(M_WAIT, MT_DATA);
460 if (mlen > MLEN)
461 MCLGET(m, M_WAIT);
462 xs = mtod(m, struct xdr_string *);
463 m->m_len = mlen;
464 xs->len = txdr_unsigned(len);
465 bcopy(str, xs->data, len);
466 return (m);
467}