ReactOS 0.4.15-dev-6662-g1b3eed5
xdr_rec.c File Reference
#include <wintirpc.h>
#include <io.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/svc_auth.h>
#include <rpc/svc.h>
#include <rpc/clnt.h>
#include <stddef.h>
#include "rpc_com.h"
Include dependency graph for xdr_rec.c:

Go to the source code of this file.

Classes

struct  rec_strm
 

Macros

#define LAST_FRAG   ((u_int32_t)(1 << 31))
 

Typedefs

typedef struct rec_strm RECSTREAM
 

Functions

static bool_t xdrrec_getlong (XDR *, long *)
 
static bool_t xdrrec_putlong (XDR *, const long *)
 
static bool_t xdrrec_getbytes (XDR *, char *, u_int)
 
static bool_t xdrrec_putbytes (XDR *, const char *, u_int)
 
static u_int xdrrec_getpos (XDR *)
 
static bool_t xdrrec_setpos (XDR *, u_int)
 
static int32_txdrrec_inline (XDR *, u_int)
 
static void xdrrec_destroy (XDR *)
 
static u_int fix_buf_size (u_int)
 
static bool_t flush_out (RECSTREAM *, bool_t)
 
static bool_t fill_input_buf (RECSTREAM *)
 
static bool_t get_input_bytes (RECSTREAM *, char *, u_int)
 
static bool_t set_input_fragment (RECSTREAM *)
 
static bool_t skip_input_bytes (RECSTREAM *, u_int)
 
static bool_t realloc_stream (RECSTREAM *, u_int)
 
void xdrrec_create (XDR *xdrs, u_int sendsize, u_int recvsize, int *void *, int *readit, int *writeit)
 
int32_txdrrec_getoutbase (XDR *xdrs)
 
void xdrrec_setlastfrag (XDR *xdrs)
 
bool_t xdrrec_skiprecord (XDR *xdrs)
 
bool_t xdrrec_eof (XDR *xdrs)
 
bool_t xdrrec_endofrecord (XDR *xdrs, bool_t sendnow)
 
bool_t __xdrrec_getrec (XDR *xdrs, enum xprt_stat *statp, bool_t expectdata)
 
bool_t __xdrrec_setnonblock (XDR *xdrs, int maxrec)
 
bool_t __xdrrec_setblock (XDR *xdrs)
 

Variables

static const struct xdr_ops xdrrec_ops
 

Macro Definition Documentation

◆ LAST_FRAG

#define LAST_FRAG   ((u_int32_t)(1 << 31))

Definition at line 124 of file xdr_rec.c.

Typedef Documentation

◆ RECSTREAM

Function Documentation

◆ __xdrrec_getrec()

bool_t __xdrrec_getrec ( XDR xdrs,
enum xprt_stat statp,
bool_t  expectdata 
)

Definition at line 581 of file xdr_rec.c.

585{
586 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
587 int n;
588 u_int fraglen;
589
590 if (!rstrm->in_haveheader) {
591 n = rstrm->readit(rstrm->tcp_handle, rstrm->in_hdrp,
592 (int)sizeof (rstrm->in_header) - rstrm->in_hdrlen);
593 if (n == 0) {
594 *statp = expectdata ? XPRT_DIED : XPRT_IDLE;
595 return FALSE;
596 }
597 if (n < 0) {
598 *statp = XPRT_DIED;
599 return FALSE;
600 }
601 rstrm->in_hdrp += n;
602 rstrm->in_hdrlen += n;
603 if (rstrm->in_hdrlen < sizeof (rstrm->in_header)) {
604 *statp = XPRT_MOREREQS;
605 return FALSE;
606 }
607 rstrm->in_header = ntohl(rstrm->in_header);
608 fraglen = (int)(rstrm->in_header & ~LAST_FRAG);
609 if (fraglen == 0 || fraglen > rstrm->in_maxrec ||
610 (rstrm->in_reclen + fraglen) > rstrm->in_maxrec) {
611 *statp = XPRT_DIED;
612 return FALSE;
613 }
614 rstrm->fbtbc = rstrm->in_header & (~LAST_FRAG);
615 rstrm->in_reclen += fraglen;
616 if (rstrm->in_reclen > rstrm->recvsize)
617 realloc_stream(rstrm, rstrm->in_reclen);
618 if (rstrm->in_header & LAST_FRAG) {
619 rstrm->in_header &= ~LAST_FRAG;
620 rstrm->last_frag = TRUE;
621 }
622 }
623
624 do {
625 n = rstrm->readit(rstrm->tcp_handle,
626 rstrm->in_base + rstrm->in_received,
627 (rstrm->in_reclen - rstrm->in_received));
628
629 /* this case is needed for non-block as socket returns TIMEDOUT and -1
630 * -2 is an error case and covered by the next if() statement */
631 if (n == -1) continue;
632
633 if (n < 0) {
634 *statp = XPRT_DIED;
635 return FALSE;
636 }
637
638 if (n == 0) {
639 *statp = expectdata ? XPRT_DIED : XPRT_IDLE;
640 return FALSE;
641 }
642
643 rstrm->in_received += n;
644 if (rstrm->in_received == rstrm->in_reclen) {
645 rstrm->in_haveheader = FALSE;
646 rstrm->in_hdrp = (char *)(void *)&rstrm->in_header;
647 rstrm->in_hdrlen = 0;
648 if (rstrm->last_frag) {
649 rstrm->in_boundry = rstrm->in_base + rstrm->in_reclen;
650 rstrm->in_finger = rstrm->in_base;
651 rstrm->in_reclen = rstrm->in_received = 0;
652 *statp = XPRT_MOREREQS;
653 return TRUE;
654 }
655 }
656 } while (1);
657
658 *statp = XPRT_MOREREQS;
659 return FALSE;
660}
@ XPRT_IDLE
Definition: svc.h:84
@ XPRT_DIED
Definition: svc.h:82
@ XPRT_MOREREQS
Definition: svc.h:83
UINT32 u_int
Definition: types.h:82
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLdouble n
Definition: glext.h:7729
#define ntohl(x)
Definition: module.h:205
void * x_private
Definition: xdr.h:125
u_int recvsize
Definition: xdr_rec.c:148
u_int in_received
Definition: xdr_rec.c:156
char * in_base
Definition: xdr_rec.c:142
bool_t last_frag
Definition: xdr_rec.c:146
char * tcp_handle
Definition: xdr_rec.c:127
u_int fbtbc
Definition: xdr_rec.c:145
bool_t in_haveheader
Definition: xdr_rec.c:151
char * in_finger
Definition: xdr_rec.c:143
int(* readit)(void *, void *, int)
Definition: xdr_rec.c:140
char * in_boundry
Definition: xdr_rec.c:144
u_int32_t in_header
Definition: xdr_rec.c:152
u_int in_maxrec
Definition: xdr_rec.c:157
u_int in_reclen
Definition: xdr_rec.c:155
char * in_hdrp
Definition: xdr_rec.c:153
u_int in_hdrlen
Definition: xdr_rec.c:154
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
#define LAST_FRAG
Definition: xdr_rec.c:124
static bool_t realloc_stream(RECSTREAM *, u_int)
Definition: xdr_rec.c:826

Referenced by svc_vc_recv(), and xdrrec_skiprecord().

◆ __xdrrec_setblock()

bool_t __xdrrec_setblock ( XDR xdrs)

Definition at line 677 of file xdr_rec.c.

679{
680 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
681
682 rstrm->nonblock = FALSE;
683 return TRUE;
684}
bool_t nonblock
Definition: xdr_rec.c:150

Referenced by clnt_cb_thread().

◆ __xdrrec_setnonblock()

bool_t __xdrrec_setnonblock ( XDR xdrs,
int  maxrec 
)

Definition at line 663 of file xdr_rec.c.

666{
667 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
668
669 rstrm->nonblock = TRUE;
670 if (maxrec == 0)
671 maxrec = rstrm->recvsize;
672 rstrm->in_maxrec = maxrec;
673 return TRUE;
674}

Referenced by clnt_cb_thread(), and rendezvous_request().

◆ fill_input_buf()

static bool_t fill_input_buf ( RECSTREAM rstrm)
static

Definition at line 709 of file xdr_rec.c.

711{
712 char *where;
713 u_int32_t i;
714 int len;
715
716 if (rstrm->nonblock)
717 return FALSE;
718
719 where = rstrm->in_base;
721 where += i;
722 len = (u_int32_t)(rstrm->in_size - i);
723 if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1)
724 return (FALSE);
725 rstrm->in_finger = where;
726 where += len;
727 rstrm->in_boundry = where;
728 return (TRUE);
729}
#define PtrToUlong(u)
Definition: config.h:107
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int u_int32_t
Definition: rosdhcp.h:35
u_long in_size
Definition: xdr_rec.c:141
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93

Referenced by get_input_bytes(), and skip_input_bytes().

◆ fix_buf_size()

static u_int fix_buf_size ( u_int  s)
static

Definition at line 813 of file xdr_rec.c.

815{
816
817 if (s < 100)
818 s = 4000;
819 return (RNDUP(s));
820}
GLdouble s
Definition: gl.h:2039
#define RNDUP(x)
Definition: xdr.h:94

Referenced by xdrrec_create().

◆ flush_out()

static bool_t flush_out ( RECSTREAM rstrm,
bool_t  eor 
)
static

Definition at line 689 of file xdr_rec.c.

692{
693 u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0;
695 PtrToUlong(rstrm->frag_header) - sizeof(u_int32_t));
696
697 *(rstrm->frag_header) = htonl(len | eormask);
698 len = (u_int32_t)(PtrToUlong(rstrm->out_finger) -
699 PtrToUlong(rstrm->out_base));
700 if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len)
701 != (int)len)
702 return (FALSE);
703 rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base;
704 rstrm->out_finger = (char *)rstrm->out_base + sizeof(u_int32_t);
705 return (TRUE);
706}
#define htonl(x)
Definition: module.h:214
u_int32_t * frag_header
Definition: xdr_rec.c:135
char * out_base
Definition: xdr_rec.c:132
char * out_finger
Definition: xdr_rec.c:133
int(* writeit)(void *, void *, int)
Definition: xdr_rec.c:131

Referenced by xdrrec_endofrecord(), xdrrec_putbytes(), and xdrrec_putlong().

◆ get_input_bytes()

static bool_t get_input_bytes ( RECSTREAM rstrm,
char addr,
u_int  len 
)
static

Definition at line 732 of file xdr_rec.c.

736{
737 size_t current;
738
739 if (rstrm->nonblock) {
740 if (len > (u_int)(rstrm->in_boundry - rstrm->in_finger))
741 return FALSE;
742 memcpy(addr, rstrm->in_finger, (size_t)len);
743 rstrm->in_finger += len;
744 return TRUE;
745 }
746
747 while (len > 0) {
748 current = (size_t)(PtrToLong(rstrm->in_boundry) -
749 PtrToLong(rstrm->in_finger));
750 if (current == 0) {
751 if (! fill_input_buf(rstrm))
752 return (FALSE);
753 continue;
754 }
755 current = (len < current) ? len : current;
756 memmove(addr, rstrm->in_finger, current);
757 rstrm->in_finger += current;
758 addr += current;
759 len -= current;
760 }
761 return (TRUE);
762}
#define PtrToLong(p)
Definition: basetsd.h:84
__kernel_size_t size_t
Definition: linux.h:237
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
struct task_struct * current
Definition: linux.c:32
static bool_t fill_input_buf(RECSTREAM *)
Definition: xdr_rec.c:709

Referenced by set_input_fragment(), and xdrrec_getbytes().

◆ realloc_stream()

static bool_t realloc_stream ( RECSTREAM rstrm,
u_int  size 
)
static

Definition at line 826 of file xdr_rec.c.

829{
830 ptrdiff_t diff;
831 char *buf;
832
833 if (size > rstrm->recvsize) {
834 buf = realloc(rstrm->in_base, (size_t)size);
835 if (buf == NULL)
836 return FALSE;
837 diff = buf - rstrm->in_base;
838 rstrm->in_finger += diff;
839 rstrm->in_base = buf;
840 rstrm->in_boundry = buf + size;
841 rstrm->recvsize = size;
842 rstrm->in_size = size;
843 }
844
845 return TRUE;
846}
#define realloc
Definition: debug_ros.c:6
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by __xdrrec_getrec().

◆ set_input_fragment()

static bool_t set_input_fragment ( RECSTREAM rstrm)
static

Definition at line 765 of file xdr_rec.c.

767{
769
770 if (rstrm->nonblock)
771 return FALSE;
772 if (! get_input_bytes(rstrm, (char *)(void *)&header, sizeof(header)))
773 return (FALSE);
775 rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE;
776 /*
777 * Sanity check. Try not to accept wildly incorrect
778 * record sizes. Unfortunately, the only record size
779 * we can positively identify as being 'wildly incorrect'
780 * is zero. Ridiculously large record sizes may look wrong,
781 * but we don't have any way to be certain that they aren't
782 * what the client actually intended to send us.
783 */
784 if (header == 0)
785 return(FALSE);
786 rstrm->fbtbc = header & (~LAST_FRAG);
787 return (TRUE);
788}
static bool_t get_input_bytes(RECSTREAM *, char *, u_int)
Definition: xdr_rec.c:732

Referenced by xdrrec_eof(), xdrrec_getbytes(), and xdrrec_skiprecord().

◆ skip_input_bytes()

static bool_t skip_input_bytes ( RECSTREAM rstrm,
u_int  cnt 
)
static

Definition at line 791 of file xdr_rec.c.

794{
796
797 while (cnt > 0) {
799 PtrToUlong(rstrm->in_finger));
800 if (current == 0) {
801 if (! fill_input_buf(rstrm))
802 return (FALSE);
803 continue;
804 }
805 current = (u_int32_t)((cnt < current) ? cnt : current);
806 rstrm->in_finger += current;
807 cnt -= current;
808 }
809 return (TRUE);
810}

Referenced by xdrrec_eof(), and xdrrec_skiprecord().

◆ xdrrec_create()

void xdrrec_create ( XDR xdrs,
u_int  sendsize,
u_int  recvsize,
int void *,
int readit,
int writeit 
)

Definition at line 179 of file xdr_rec.c.

188{
189 RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM));
190
191 if (rstrm == NULL) {
192 //warnx("xdrrec_create: out of memory");
193 /*
194 * This is bad. Should rework xdrrec_create to
195 * return a handle, and in this case return NULL
196 */
197 return;
198 }
199 rstrm->sendsize = sendsize = fix_buf_size(sendsize);
200 rstrm->out_base = mem_alloc(rstrm->sendsize);
201 if (rstrm->out_base == NULL) {
202 //warnx("xdrrec_create: out of memory");
203 mem_free(rstrm, sizeof(RECSTREAM));
204 return;
205 }
206 rstrm->recvsize = recvsize = fix_buf_size(recvsize);
207 rstrm->in_base = mem_alloc(recvsize);
208 if (rstrm->in_base == NULL) {
209 //warnx("xdrrec_create: out of memory");
210 mem_free(rstrm->out_base, sendsize);
211 mem_free(rstrm, sizeof(RECSTREAM));
212 return;
213 }
214 /*
215 * now the rest ...
216 */
217 xdrs->x_ops = &xdrrec_ops;
218 xdrs->x_private = rstrm;
219 rstrm->tcp_handle = tcp_handle;
220 rstrm->readit = readit;
221 rstrm->writeit = writeit;
222 rstrm->out_finger = rstrm->out_boundry = rstrm->out_base;
223 rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base;
224 rstrm->out_finger += sizeof(u_int32_t);
225 rstrm->out_boundry += sendsize;
226 rstrm->frag_sent = FALSE;
227 rstrm->in_size = recvsize;
228 rstrm->in_boundry = rstrm->in_base;
229 rstrm->in_finger = (rstrm->in_boundry += recvsize);
230 rstrm->fbtbc = 0;
231 rstrm->last_frag = TRUE;
232 rstrm->in_haveheader = FALSE;
233 rstrm->in_hdrlen = 0;
234 rstrm->in_hdrp = (char *)(void *)&rstrm->in_header;
235 rstrm->nonblock = FALSE;
236 rstrm->in_reclen = 0;
237 rstrm->in_received = 0;
238}
#define mem_free(ptr, bsize)
Definition: types.h:124
#define mem_alloc(bsize)
Definition: types.h:123
const struct __rpc_xdr::xdr_ops * x_ops
char * out_boundry
Definition: xdr_rec.c:134
u_int sendsize
Definition: xdr_rec.c:147
bool_t frag_sent
Definition: xdr_rec.c:136
static u_int fix_buf_size(u_int)
Definition: xdr_rec.c:813
static const struct xdr_ops xdrrec_ops
Definition: xdr_rec.c:100

Referenced by clnt_vc_create(), and makefd_xprt().

◆ xdrrec_destroy()

static void xdrrec_destroy ( XDR xdrs)
static

Definition at line 469 of file xdr_rec.c.

471{
472 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
473
474 mem_free(rstrm->out_base, rstrm->sendsize);
475 mem_free(rstrm->in_base, rstrm->recvsize);
476 mem_free(rstrm, sizeof(RECSTREAM));
477}

◆ xdrrec_endofrecord()

bool_t xdrrec_endofrecord ( XDR xdrs,
bool_t  sendnow 
)

Definition at line 555 of file xdr_rec.c.

558{
559 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
560 u_long len; /* fragment length */
561
562 if (sendnow || rstrm->frag_sent ||
563 (PtrToUlong(rstrm->out_finger) + sizeof(u_int32_t) >=
564 PtrToUlong(rstrm->out_boundry))) {
565 rstrm->frag_sent = FALSE;
566 return (flush_out(rstrm, TRUE));
567 }
568 len = PtrToUlong(rstrm->out_finger) - PtrToUlong(rstrm->frag_header) -
569 sizeof(u_int32_t);
570 *(rstrm->frag_header) = htonl((u_int32_t)len | LAST_FRAG);
571 rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_finger;
572 rstrm->out_finger += sizeof(u_int32_t);
573 return (TRUE);
574}
unsigned long u_long
Definition: linux.h:269
static bool_t flush_out(RECSTREAM *, bool_t)
Definition: xdr_rec.c:689

Referenced by clnt_cb_thread(), and svc_vc_reply().

◆ xdrrec_eof()

bool_t xdrrec_eof ( XDR xdrs)

Definition at line 531 of file xdr_rec.c.

533{
534 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
535
536 while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
537 if (! skip_input_bytes(rstrm, rstrm->fbtbc))
538 return (TRUE);
539 rstrm->fbtbc = 0;
540 if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
541 return (TRUE);
542 }
543 if (rstrm->in_finger == rstrm->in_boundry)
544 return (TRUE);
545 return (FALSE);
546}
static bool_t set_input_fragment(RECSTREAM *)
Definition: xdr_rec.c:765
static bool_t skip_input_bytes(RECSTREAM *, u_int)
Definition: xdr_rec.c:791

Referenced by svc_vc_stat().

◆ xdrrec_getbytes()

static bool_t xdrrec_getbytes ( XDR xdrs,
char addr,
u_int  len 
)
static

Definition at line 295 of file xdr_rec.c.

299{
300 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
302
303 while (len > 0) {
304 current = (int)rstrm->fbtbc;
305 if (current == 0) {
306 if (rstrm->last_frag)
307 return (FALSE);
308 if (! set_input_fragment(rstrm))
309 return (FALSE);
310 continue;
311 }
312 current = (len < current) ? len : current;
313 if (! get_input_bytes(rstrm, addr, current))
314 return (FALSE);
315 addr += current;
316 rstrm->fbtbc -= current;
317 len -= current;
318 }
319 return (TRUE);
320}
if(dx< 0)
Definition: linetemp.h:194

Referenced by xdrrec_getlong().

◆ xdrrec_getlong()

static bool_t xdrrec_getlong ( XDR xdrs,
long lp 
)
static

Definition at line 247 of file xdr_rec.c.

250{
251 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
252 int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger);
253 int32_t mylong;
254
255 /* first try the inline, fast case */
256 if ((rstrm->fbtbc >= sizeof(int32_t)) &&
257 ((PtrToLong(rstrm->in_boundry) - PtrToLong(buflp)) >= sizeof(int32_t))) {
258 *lp = (long)ntohl((u_int32_t)(*buflp));
259 rstrm->fbtbc -= sizeof(int32_t);
260 rstrm->in_finger += sizeof(int32_t);
261 } else {
262 if (! xdrrec_getbytes(xdrs, (char *)(void *)&mylong,
263 sizeof(int32_t)))
264 return (FALSE);
265 *lp = (long)ntohl((u_int32_t)mylong);
266 }
267 return (TRUE);
268}
INT32 int32_t
Definition: types.h:71
#define int32_t
Definition: nsiface.idl:56
#define long
Definition: qsort.c:33
static bool_t xdrrec_getbytes(XDR *, char *, u_int)
Definition: xdr_rec.c:295

◆ xdrrec_getoutbase()

int32_t * xdrrec_getoutbase ( XDR xdrs)

Definition at line 415 of file xdr_rec.c.

417{
418 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
419 int32_t *buf = NULL;
420
421 switch (xdrs->x_op) {
422
423 case XDR_ENCODE:
424 buf = rstrm->out_base;
425 break;
426
427 case XDR_DECODE:
428 break;
429
430 case XDR_FREE:
431 break;
432 }
433 return (buf);
434}
switch(r->id)
Definition: btrfs.c:3046
enum xdr_op x_op
Definition: xdr.h:104
@ XDR_DECODE
Definition: xdr.h:86
@ XDR_FREE
Definition: xdr.h:87
@ XDR_ENCODE
Definition: xdr.h:85

Referenced by authsspi_marshal().

◆ xdrrec_getpos()

static u_int xdrrec_getpos ( XDR xdrs)
static

Definition at line 349 of file xdr_rec.c.

351{
352 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
353 off_t pos = 0;
354
355 //pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1);
356 //pos = _lseek((int)PtrToUlong(rstrm->tcp_handle), (off_t)0, 1);
357 if (pos != -1)
358 switch (xdrs->x_op) {
359
360 case XDR_ENCODE:
361 pos += PtrToLong(rstrm->out_finger) - PtrToLong(rstrm->out_base);
362 break;
363
364 case XDR_DECODE:
365 pos -= PtrToLong(rstrm->in_boundry) - PtrToLong(rstrm->in_finger);
366 break;
367
368 default:
369 pos = (off_t) -1;
370 break;
371 }
372 return ((u_int) pos);
373}
#define off_t
Definition: dosfsck.h:5
__kernel_off_t off_t
Definition: linux.h:201

Referenced by xdrrec_setpos().

◆ xdrrec_inline()

static int32_t * xdrrec_inline ( XDR xdrs,
u_int  len 
)
static

Definition at line 437 of file xdr_rec.c.

440{
441 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
442 int32_t *buf = NULL;
443
444 switch (xdrs->x_op) {
445
446 case XDR_ENCODE:
447 if ((rstrm->out_finger + len) <= rstrm->out_boundry) {
448 buf = (int32_t *)(void *)rstrm->out_finger;
449 rstrm->out_finger += len;
450 }
451 break;
452
453 case XDR_DECODE:
454 if ((len <= rstrm->fbtbc) &&
455 ((rstrm->in_finger + len) <= rstrm->in_boundry)) {
456 buf = (int32_t *)(void *)rstrm->in_finger;
457 rstrm->fbtbc -= len;
458 rstrm->in_finger += len;
459 }
460 break;
461
462 case XDR_FREE:
463 break;
464 }
465 return (buf);
466}

◆ xdrrec_putbytes()

static bool_t xdrrec_putbytes ( XDR xdrs,
const char addr,
u_int  len 
)
static

Definition at line 323 of file xdr_rec.c.

327{
328 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
329 size_t current;
330
331 while (len > 0) {
333 PtrToUlong(rstrm->out_finger));
334 current = (len < current) ? len : current;
335 memmove(rstrm->out_finger, addr, current);
336 rstrm->out_finger += current;
337 addr += current;
338 len -= current;
339 if (rstrm->out_finger == rstrm->out_boundry) {
340 rstrm->frag_sent = TRUE;
341 if (! flush_out(rstrm, FALSE))
342 return (FALSE);
343 }
344 }
345 return (TRUE);
346}

◆ xdrrec_putlong()

static bool_t xdrrec_putlong ( XDR xdrs,
const long lp 
)
static

Definition at line 271 of file xdr_rec.c.

274{
275 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
276 int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger));
277
278 if ((rstrm->out_finger += sizeof(int32_t)) > rstrm->out_boundry) {
279 /*
280 * this case should almost never happen so the code is
281 * inefficient
282 */
283 rstrm->out_finger -= sizeof(int32_t);
284 rstrm->frag_sent = TRUE;
285 if (! flush_out(rstrm, FALSE))
286 return (FALSE);
287 dest_lp = ((int32_t *)(void *)(rstrm->out_finger));
288 rstrm->out_finger += sizeof(int32_t);
289 }
290 *dest_lp = (int32_t)htonl((u_int32_t)(*lp));
291 return (TRUE);
292}

◆ xdrrec_setlastfrag()

void xdrrec_setlastfrag ( XDR xdrs)

Definition at line 488 of file xdr_rec.c.

490{
491 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
492 rstrm->last_frag = 1;
493}

Referenced by clnt_cb_thread().

◆ xdrrec_setpos()

static bool_t xdrrec_setpos ( XDR xdrs,
u_int  pos 
)
static

Definition at line 376 of file xdr_rec.c.

379{
380 RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private;
381 u_int currpos = xdrrec_getpos(xdrs);
382 int delta = currpos - pos;
383 char *newpos;
384
385 if ((int)currpos != -1)
386 switch (xdrs->x_op) {
387
388 case XDR_ENCODE:
389 newpos = rstrm->out_finger - delta;
390 if ((newpos > (char *)(void *)(rstrm->frag_header)) &&
391 (newpos < rstrm->out_boundry)) {
392 rstrm->out_finger = newpos;
393 return (TRUE);
394 }
395 break;
396
397 case XDR_DECODE:
398 newpos = rstrm->in_finger - delta;
399 if ((delta < (int)(rstrm->fbtbc)) &&
400 (newpos <= rstrm->in_boundry) &&
401 (newpos >= rstrm->in_base)) {
402 rstrm->in_finger = newpos;
403 rstrm->fbtbc -= delta;
404 return (TRUE);
405 }
406 break;
407
408 case XDR_FREE:
409 break;
410 }
411 return (FALSE);
412}
static u_int xdrrec_getpos(XDR *)
Definition: xdr_rec.c:349

◆ xdrrec_skiprecord()

bool_t xdrrec_skiprecord ( XDR xdrs)

Definition at line 496 of file xdr_rec.c.

498{
499 RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private);
500 enum xprt_stat xstat;
501
502 if (rstrm->nonblock) {
503 if (__xdrrec_getrec(xdrs, &xstat, FALSE))
504 return TRUE;
505
506 if (rstrm->in_finger == rstrm->in_boundry &&
507 xstat == XPRT_MOREREQS) {
508 rstrm->fbtbc = 0;
509 return TRUE;
510 }
511 return FALSE;
512 }
513
514 while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) {
515 if (! skip_input_bytes(rstrm, rstrm->fbtbc))
516 return (FALSE);
517 rstrm->fbtbc = 0;
518 if ((! rstrm->last_frag) && (! set_input_fragment(rstrm)))
519 return (FALSE);
520 }
521 rstrm->last_frag = FALSE;
522 return (TRUE);
523}
xprt_stat
Definition: svc.h:81
bool_t __xdrrec_getrec(XDR *xdrs, enum xprt_stat *statp, bool_t expectdata)
Definition: xdr_rec.c:581

Referenced by clnt_cb_thread(), and svc_vc_recv().

Variable Documentation

◆ xdrrec_ops

const struct xdr_ops xdrrec_ops
static
Initial value:
= {
}
static bool_t xdrrec_getlong(XDR *, long *)
Definition: xdr_rec.c:247
static void xdrrec_destroy(XDR *)
Definition: xdr_rec.c:469
static int32_t * xdrrec_inline(XDR *, u_int)
Definition: xdr_rec.c:437
static bool_t xdrrec_putlong(XDR *, const long *)
Definition: xdr_rec.c:271
static bool_t xdrrec_putbytes(XDR *, const char *, u_int)
Definition: xdr_rec.c:323
static bool_t xdrrec_setpos(XDR *, u_int)
Definition: xdr_rec.c:376

Definition at line 100 of file xdr_rec.c.

Referenced by xdrrec_create().