From dab2d6ebae0b1f7d7b72ccafe42b729081409ff2 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Sat, 8 Jan 2005 06:01:35 +0000 Subject: 2005-01-07 Ralf Corsepius * librpc/include/rpc/auth_des.h, librpc/include/rpc/xdr.h, librpc/src/rpc/auth_des.c, librpc/src/rpc/auth_unix.c, librpc/src/rpc/rpc_prot.c, librpc/src/xdr/xdr.c: Misc. ansi-fications, misc. updates from FreeBSD. --- cpukit/librpc/src/rpc/auth_des.c | 47 +++---- cpukit/librpc/src/rpc/auth_unix.c | 48 +++---- cpukit/librpc/src/rpc/rpc_prot.c | 72 +++++++---- cpukit/librpc/src/xdr/xdr.c | 257 +++++++++++++++++++++++++------------- 4 files changed, 257 insertions(+), 167 deletions(-) (limited to 'cpukit/librpc/src') diff --git a/cpukit/librpc/src/rpc/auth_des.c b/cpukit/librpc/src/rpc/auth_des.c index 87d55b67e7..bb64b835b8 100644 --- a/cpukit/librpc/src/rpc/auth_des.c +++ b/cpukit/librpc/src/rpc/auth_des.c @@ -51,13 +51,7 @@ static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/auth_des.c,v 1.3 1999/08/28 00:00:32 peter Exp $"; #endif -extern bool_t __rpc_get_time_offset __P(( struct timeval *, nis_server *, - char *, char **, struct sockaddr_in * )); -extern int rtime __P(( struct sockaddr_in *, struct timeval *, struct timeval *)); -extern bool_t xdr_authdes_cred __P(( XDR *, struct authdes_cred * )); -extern bool_t xdr_authdes_verf __P(( XDR *, struct authdes_verf * )); - -#define MILLION 1000000L +#define USEC_PER_SEC 1000000L #define RTIME_TIMEOUT 5 /* seconds to wait for sync */ #define AUTH_PRIVATE(auth) (struct ad_private *) auth->ah_private @@ -65,16 +59,22 @@ extern bool_t xdr_authdes_verf __P(( XDR *, struct authdes_verf * )); #define FREE(ptr, size) mem_free((char *)(ptr), (int) size) #define ATTEMPT(xdr_op) if (!(xdr_op)) return (FALSE) +extern int rtime( struct sockaddr_in *, struct timeval *, struct timeval *); +extern bool_t xdr_authdes_cred(XDR *, struct authdes_cred *); +extern bool_t xdr_authdes_verf(XDR *, struct authdes_verf *); + +extern bool_t __rpc_get_time_offset( struct timeval *, nis_server *, char *, + char **, struct sockaddr_in * ); #define debug(msg) /*printf("%s\n", msg) */ /* * DES authenticator operations vector */ -static void authdes_nextverf(); -static bool_t authdes_marshal(); -static bool_t authdes_validate(); -static bool_t authdes_refresh(); -static void authdes_destroy(); +static void authdes_nextverf(AUTH *); +static bool_t authdes_marshal(AUTH *, XDR *); +static bool_t authdes_validate(AUTH *, struct opaque_auth *); +static bool_t authdes_refresh(AUTH *); +static void authdes_destroy(AUTH *); static struct auth_ops authdes_ops = { authdes_nextverf, authdes_marshal, @@ -313,8 +313,7 @@ failed: */ /*ARGSUSED*/ static void -authdes_nextverf(auth) - AUTH *auth; +authdes_nextverf(AUTH *auth) { /* what the heck am I supposed to do??? */ } @@ -325,9 +324,7 @@ authdes_nextverf(auth) * 2. Marshal */ static bool_t -authdes_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; +authdes_marshal(AUTH *auth, XDR *xdrs) { struct ad_private *ad = AUTH_PRIVATE(auth); struct authdes_cred *cred = &ad->ad_cred; @@ -345,8 +342,8 @@ authdes_marshal(auth, xdrs) (void) gettimeofday(&ad->ad_timestamp, (struct timezone *)NULL); ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec; ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec; - if (ad->ad_timestamp.tv_usec >= MILLION) { - ad->ad_timestamp.tv_usec -= MILLION; + if (ad->ad_timestamp.tv_usec >= USEC_PER_SEC) { + ad->ad_timestamp.tv_usec -= USEC_PER_SEC; ad->ad_timestamp.tv_sec += 1; } @@ -416,9 +413,7 @@ authdes_marshal(auth, xdrs) * 3. Validate */ static bool_t -authdes_validate(auth, rverf) - AUTH *auth; - struct opaque_auth *rverf; +authdes_validate(AUTH *auth, struct opaque_auth *rverf) { struct ad_private *ad = AUTH_PRIVATE(auth); struct authdes_verf verf; @@ -472,8 +467,7 @@ authdes_validate(auth, rverf) * 4. Refresh */ static bool_t -authdes_refresh(auth) - AUTH *auth; +authdes_refresh(AUTH *auth) { struct ad_private *ad = AUTH_PRIVATE(auth); struct authdes_cred *cred = &ad->ad_cred; @@ -512,8 +506,7 @@ authdes_refresh(auth) * 5. Destroy */ static void -authdes_destroy(auth) - AUTH *auth; +authdes_destroy(AUTH *auth) { struct ad_private *ad = AUTH_PRIVATE(auth); @@ -546,7 +539,7 @@ synchronize(syncaddr, timep) timep->tv_sec -= mytime.tv_sec; if (mytime.tv_usec > timep->tv_usec) { timep->tv_sec -= 1; - timep->tv_usec += MILLION; + timep->tv_usec += USEC_PER_SEC; } timep->tv_usec -= mytime.tv_usec; return (TRUE); diff --git a/cpukit/librpc/src/rpc/auth_unix.c b/cpukit/librpc/src/rpc/auth_unix.c index 885c92a206..279822942a 100644 --- a/cpukit/librpc/src/rpc/auth_unix.c +++ b/cpukit/librpc/src/rpc/auth_unix.c @@ -59,11 +59,11 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/auth_unix.c,v 1.12 1999/12/29 0 /* * Unix authenticator operations vector */ -static void authunix_nextverf(); -static bool_t authunix_marshal(); -static bool_t authunix_validate(); -static bool_t authunix_refresh(); -static void authunix_destroy(); +static void authunix_nextverf(AUTH*); +static bool_t authunix_marshal(AUTH*, XDR*); +static bool_t authunix_validate(AUTH*, struct opaque_auth *); +static bool_t authunix_refresh(AUTH*); +static void authunix_destroy(AUTH*); static struct auth_ops auth_unix_ops = { authunix_nextverf, @@ -109,7 +109,7 @@ authunix_create(machname, uid, gid, len, aup_gids) char *machname; int uid; int gid; - register int len; + int len; int *aup_gids; { struct authunix_parms aup; @@ -218,33 +218,28 @@ authunix_create_default() */ static void -authunix_nextverf(auth) - AUTH *auth; +authunix_nextverf(AUTH *auth) { /* no action necessary */ } static bool_t -authunix_marshal(auth, xdrs) - AUTH *auth; - XDR *xdrs; +authunix_marshal(AUTH *auth, XDR *xdrs) { - register struct audata *au = AUTH_PRIVATE(auth); + struct audata *au = AUTH_PRIVATE(auth); return (XDR_PUTBYTES(xdrs, au->au_marshed, au->au_mpos)); } static bool_t -authunix_validate(auth, verf) - register AUTH *auth; - struct opaque_auth verf; +authunix_validate( AUTH *auth, struct opaque_auth *verf ) { register struct audata *au; XDR xdrs; - if (verf.oa_flavor == AUTH_SHORT) { + if (verf->oa_flavor == AUTH_SHORT) { au = AUTH_PRIVATE(auth); - xdrmem_create(&xdrs, verf.oa_base, verf.oa_length, XDR_DECODE); + xdrmem_create(&xdrs, verf->oa_base, verf->oa_length, XDR_DECODE); if (au->au_shcred.oa_base != NULL) { mem_free(au->au_shcred.oa_base, @@ -265,14 +260,13 @@ authunix_validate(auth, verf) } static bool_t -authunix_refresh(auth) - register AUTH *auth; +authunix_refresh(AUTH *auth) { - register struct audata *au = AUTH_PRIVATE(auth); + struct audata *au = AUTH_PRIVATE(auth); struct authunix_parms aup; struct timeval now; XDR xdrs; - register int stat; + int stat; if (auth->ah_cred.oa_base == au->au_origcred.oa_base) { /* there is no hope. Punt */ @@ -308,10 +302,9 @@ done: } static void -authunix_destroy(auth) - register AUTH *auth; +authunix_destroy(AUTH *auth) { - register struct audata *au = AUTH_PRIVATE(auth); + struct audata *au = AUTH_PRIVATE(auth); mem_free(au->au_origcred.oa_base, au->au_origcred.oa_length); @@ -331,12 +324,11 @@ authunix_destroy(auth) * sets private data, au_marshed and au_mpos */ static void -marshal_new_auth(auth) - register AUTH *auth; +marshal_new_auth(AUTH *auth) { XDR xdr_stream; - register XDR *xdrs = &xdr_stream; - register struct audata *au = AUTH_PRIVATE(auth); + XDR *xdrs = &xdr_stream; + struct audata *au = AUTH_PRIVATE(auth); xdrmem_create(xdrs, au->au_marshed, MAX_AUTH_BYTES, XDR_ENCODE); if ((! xdr_opaque_auth(xdrs, &(auth->ah_cred))) || diff --git a/cpukit/librpc/src/rpc/rpc_prot.c b/cpukit/librpc/src/rpc/rpc_prot.c index 14a2524c70..11a1ad2dcd 100644 --- a/cpukit/librpc/src/rpc/rpc_prot.c +++ b/cpukit/librpc/src/rpc/rpc_prot.c @@ -50,9 +50,12 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/rpc_prot.c,v 1.8 1999/08/28 00: #include +static void accepted(enum accept_stat, struct rpc_err *); +static void rejected(enum reject_stat, struct rpc_err *); + /* * * * * * * * * * * * * * XDR Authentication * * * * * * * * * * * */ -struct opaque_auth _null_auth; +extern struct opaque_auth _null_auth; /* * XDR an opaque authentication struct @@ -60,8 +63,8 @@ struct opaque_auth _null_auth; */ bool_t xdr_opaque_auth(xdrs, ap) - register XDR *xdrs; - register struct opaque_auth *ap; + XDR *xdrs; + struct opaque_auth *ap; { if (xdr_enum(xdrs, &(ap->oa_flavor))) @@ -75,8 +78,8 @@ xdr_opaque_auth(xdrs, ap) */ bool_t xdr_des_block(xdrs, blkp) - register XDR *xdrs; - register des_block *blkp; + XDR *xdrs; + des_block *blkp; { return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block))); } @@ -88,8 +91,8 @@ xdr_des_block(xdrs, blkp) */ bool_t xdr_accepted_reply(xdrs, ar) - register XDR *xdrs; - register struct accepted_reply *ar; + XDR *xdrs; + struct accepted_reply *ar; { /* personalized union, rather than calling xdr_union */ @@ -106,7 +109,12 @@ xdr_accepted_reply(xdrs, ar) if (! xdr_u_int32_t(xdrs, &(ar->ar_vers.low))) return (FALSE); return (xdr_u_int32_t(xdrs, &(ar->ar_vers.high))); - default: + + case GARBAGE_ARGS: + case SYSTEM_ERR: + case PROC_UNAVAIL: + case PROG_UNAVAIL: +/* default: */ break; } return (TRUE); /* TRUE => open ended set of problems */ @@ -117,8 +125,8 @@ xdr_accepted_reply(xdrs, ar) */ bool_t xdr_rejected_reply(xdrs, rr) - register XDR *xdrs; - register struct rejected_reply *rr; + XDR *xdrs; + struct rejected_reply *rr; { /* personalized union, rather than calling xdr_union */ @@ -137,9 +145,9 @@ xdr_rejected_reply(xdrs, rr) return (FALSE); } -static struct xdr_discrim reply_dscrm[3] = { - { (int)MSG_ACCEPTED, xdr_accepted_reply }, - { (int)MSG_DENIED, xdr_rejected_reply }, +static const struct xdr_discrim reply_dscrm[3] = { + { (int)MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply }, + { (int)MSG_DENIED, (xdrproc_t)xdr_rejected_reply }, { __dontcare__, NULL_xdrproc_t } }; /* @@ -147,8 +155,8 @@ static struct xdr_discrim reply_dscrm[3] = { */ bool_t xdr_replymsg(xdrs, rmsg) - register XDR *xdrs; - register struct rpc_msg *rmsg; + XDR *xdrs; + struct rpc_msg *rmsg; { if ( xdr_u_int32_t(xdrs, &(rmsg->rm_xid)) && @@ -167,8 +175,8 @@ xdr_replymsg(xdrs, rmsg) */ bool_t xdr_callhdr(xdrs, cmsg) - register XDR *xdrs; - register struct rpc_msg *cmsg; + XDR *xdrs; + struct rpc_msg *cmsg; { cmsg->rm_direction = CALL; @@ -187,8 +195,8 @@ xdr_callhdr(xdrs, cmsg) static void accepted(acpt_stat, error) - register enum accept_stat acpt_stat; - register struct rpc_err *error; + enum accept_stat acpt_stat; + struct rpc_err *error; { switch (acpt_stat) { @@ -225,8 +233,8 @@ accepted(acpt_stat, error) static void rejected(rjct_stat, error) - register enum reject_stat rjct_stat; - register struct rpc_err *error; + enum reject_stat rjct_stat; + struct rpc_err *error; { switch (rjct_stat) { @@ -252,8 +260,8 @@ rejected(rjct_stat, error) */ void _seterr_reply(msg, error) - register struct rpc_msg *msg; - register struct rpc_err *error; + struct rpc_msg *msg; + struct rpc_err *error; { /* optimized for normal, SUCCESSful case */ @@ -263,7 +271,7 @@ _seterr_reply(msg, error) if (msg->acpted_rply.ar_stat == SUCCESS) { error->re_status = RPC_SUCCESS; return; - }; + } accepted(msg->acpted_rply.ar_stat, error); break; @@ -291,6 +299,22 @@ _seterr_reply(msg, error) error->re_vers.low = msg->acpted_rply.ar_vers.low; error->re_vers.high = msg->acpted_rply.ar_vers.high; break; + + case RPC_FAILED: + case RPC_SUCCESS: + case RPC_PROGNOTREGISTERED: + case RPC_PMAPFAILURE: + case RPC_UNKNOWNPROTO: + case RPC_UNKNOWNHOST: + case RPC_SYSTEMERROR: + case RPC_CANTDECODEARGS: + case RPC_PROCUNAVAIL: + case RPC_PROGUNAVAIL: + case RPC_TIMEDOUT: + case RPC_CANTRECV: + case RPC_CANTSEND: + case RPC_CANTDECODERES: + case RPC_CANTENCODEARGS: default: break; } diff --git a/cpukit/librpc/src/xdr/xdr.c b/cpukit/librpc/src/xdr/xdr.c index e608e46501..5b8b8ced7c 100644 --- a/cpukit/librpc/src/xdr/xdr.c +++ b/cpukit/librpc/src/xdr/xdr.c @@ -50,6 +50,10 @@ static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr.c,v 1.9 1999/08/28 00:02:55 #include #include +#if defined(__rtems__) +#define warnx(msg) fprintf(stderr, msg "\n"); +#endif + /* * constants specific to the xdr "protocol" */ @@ -60,7 +64,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr.c,v 1.9 1999/08/28 00:02:55 /* * for unit alignment */ -static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; +static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; /* * Free a data structure using XDR @@ -116,6 +120,7 @@ xdr_int(xdrs, ip) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -145,6 +150,7 @@ xdr_u_int(xdrs, up) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -155,7 +161,7 @@ xdr_u_int(xdrs, up) */ bool_t xdr_long(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { switch (xdrs->x_op) { @@ -166,7 +172,7 @@ xdr_long(xdrs, lp) case XDR_FREE: return (TRUE); } - + /* NOTREACHED */ return (FALSE); } @@ -176,7 +182,7 @@ xdr_long(xdrs, lp) */ bool_t xdr_u_long(xdrs, ulp) - register XDR *xdrs; + XDR *xdrs; u_long *ulp; { switch (xdrs->x_op) { @@ -187,6 +193,7 @@ xdr_u_long(xdrs, ulp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -197,7 +204,7 @@ xdr_u_long(xdrs, ulp) */ bool_t xdr_int32_t(xdrs, int32_p) - register XDR *xdrs; + XDR *xdrs; int32_t *int32_p; { long l; @@ -218,6 +225,7 @@ xdr_int32_t(xdrs, int32_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -227,7 +235,7 @@ xdr_int32_t(xdrs, int32_p) */ bool_t xdr_u_int32_t(xdrs, u_int32_p) - register XDR *xdrs; + XDR *xdrs; u_int32_t *u_int32_p; { u_long l; @@ -251,69 +259,12 @@ xdr_u_int32_t(xdrs, u_int32_p) return (FALSE); } -/* - * XDR 64-bit integers - */ -bool_t -xdr_int64_t(xdrs, int64_p) - register XDR *xdrs; - int64_t *int64_p; -{ - int64_t x; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - return (xdr_opaque(xdrs, (caddr_t)int64_p, sizeof(int64_t))); - - case XDR_DECODE: - if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) { - return (FALSE); - } - *int64_p = x; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR unsigned 64-bit integers - */ -bool_t -xdr_u_int64_t(xdrs, uint64_p) - register XDR *xdrs; - u_int64_t *uint64_p; -{ - u_int64_t x; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - return (xdr_opaque(xdrs, (caddr_t)uint64_p, sizeof(u_int64_t))); - - case XDR_DECODE: - if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) { - return (FALSE); - } - *uint64_p = x; - return (TRUE); - - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - - /* * XDR short integers */ bool_t xdr_short(xdrs, sp) - register XDR *xdrs; + XDR *xdrs; short *sp; { long l; @@ -334,6 +285,7 @@ xdr_short(xdrs, sp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -342,7 +294,7 @@ xdr_short(xdrs, sp) */ bool_t xdr_u_short(xdrs, usp) - register XDR *xdrs; + XDR *xdrs; u_short *usp; { u_long l; @@ -363,6 +315,7 @@ xdr_u_short(xdrs, usp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -372,7 +325,7 @@ xdr_u_short(xdrs, usp) */ bool_t xdr_int16_t(xdrs, int16_p) - register XDR *xdrs; + XDR *xdrs; int16_t *int16_p; { long l; @@ -393,6 +346,7 @@ xdr_int16_t(xdrs, int16_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -401,7 +355,7 @@ xdr_int16_t(xdrs, int16_p) */ bool_t xdr_u_int16_t(xdrs, u_int16_p) - register XDR *xdrs; + XDR *xdrs; u_int16_t *u_int16_p; { u_long l; @@ -422,6 +376,7 @@ xdr_u_int16_t(xdrs, u_int16_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -467,7 +422,7 @@ xdr_u_char(xdrs, cp) */ bool_t xdr_bool(xdrs, bp) - register XDR *xdrs; + XDR *xdrs; bool_t *bp; { long lb; @@ -488,6 +443,7 @@ xdr_bool(xdrs, bp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -528,11 +484,11 @@ xdr_enum(xdrs, ep) */ bool_t xdr_opaque(xdrs, cp, cnt) - register XDR *xdrs; + XDR *xdrs; caddr_t cp; - register u_int cnt; + u_int cnt; { - register u_int rndup; + u_int rndup; static int crud[BYTES_PER_XDR_UNIT]; /* @@ -580,13 +536,13 @@ xdr_opaque(xdrs, cp, cnt) */ bool_t xdr_bytes(xdrs, cpp, sizep, maxsize) - register XDR *xdrs; + XDR *xdrs; char **cpp; - register u_int *sizep; + u_int *sizep; u_int maxsize; { - register char *sp = *cpp; /* sp is the actual string pointer */ - register u_int nodesize; + char *sp = *cpp; /* sp is the actual string pointer */ + u_int nodesize; /* * first deal with the length since xdr bytes are counted @@ -609,13 +565,13 @@ xdr_bytes(xdrs, cpp, sizep, maxsize) return (TRUE); } if (sp == NULL) { - *cpp = sp = (char *)mem_alloc(nodesize); + *cpp = sp = mem_alloc(nodesize); } if (sp == NULL) { - (void) fprintf(stderr, "xdr_bytes: out of memory\n"); + warnx("xdr_bytes: out of memory"); return (FALSE); } - /* fall into ... */ + /* FALLTHROUGH */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, nodesize)); @@ -627,6 +583,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize) } return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -655,13 +612,13 @@ xdr_netobj(xdrs, np) */ bool_t xdr_union(xdrs, dscmp, unp, choices, dfault) - register XDR *xdrs; + XDR *xdrs; enum_t *dscmp; /* enum to decide which arm to work on */ char *unp; /* the union itself */ - struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ + const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ xdrproc_t dfault; /* default xdr routine */ { - register enum_t dscm; + enum_t dscm; /* * we deal with the discriminator; it's an enum @@ -704,11 +661,11 @@ xdr_union(xdrs, dscmp, unp, choices, dfault) */ bool_t xdr_string(xdrs, cpp, maxsize) - register XDR *xdrs; + XDR *xdrs; char **cpp; u_int maxsize; { - register char *sp = *cpp; /* sp is the actual string pointer */ + char *sp = *cpp; /* sp is the actual string pointer */ u_int size; u_int nodesize; @@ -720,11 +677,11 @@ xdr_string(xdrs, cpp, maxsize) if (sp == NULL) { return(TRUE); /* already free */ } - /* fall through... */ + /* FALLTHROUGH */ case XDR_ENCODE: size = strlen(sp); break; - case XDR_DECODE: /* to avoid warning */ + case XDR_DECODE: break; } if (! xdr_u_int(xdrs, &size)) { @@ -745,13 +702,13 @@ xdr_string(xdrs, cpp, maxsize) return (TRUE); } if (sp == NULL) - *cpp = sp = (char *)mem_alloc(nodesize); + *cpp = sp = mem_alloc(nodesize); if (sp == NULL) { - (void) fprintf(stderr, "xdr_string: out of memory\n"); + warnx("xdr_string: out of memory"); return (FALSE); } sp[size] = 0; - /* fall into ... */ + /* FALLTHROUGH */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, size)); @@ -761,6 +718,7 @@ xdr_string(xdrs, cpp, maxsize) *cpp = NULL; return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -775,3 +733,126 @@ xdr_wrapstring(xdrs, cpp) { return xdr_string(xdrs, cpp, LASTUNSIGNED); } + +/* + * XDR 64-bit integers + */ +bool_t +xdr_int64_t(xdrs, int64_p) + XDR *xdrs; + int64_t *int64_p; +{ + int64_t x; + + switch (xdrs->x_op) { + case XDR_ENCODE: + return (xdr_opaque(xdrs, (caddr_t)int64_p, sizeof(int64_t))); + case XDR_DECODE: + if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) { + return (FALSE); + } + *int64_p = x; + return (TRUE); + case XDR_FREE: + return (TRUE); + } + /* NOTREACHED */ + return (FALSE); +} + + +/* + * XDR unsigned 64-bit integers + */ +bool_t +xdr_u_int64_t(xdrs, uint64_p) + XDR *xdrs; + u_int64_t *uint64_p; +{ + u_int64_t x; + + switch (xdrs->x_op) { + case XDR_ENCODE: + return (xdr_opaque(xdrs, (caddr_t)uint64_p, sizeof(u_int64_t))); + case XDR_DECODE: + if (!xdr_opaque(xdrs, (caddr_t)&x, sizeof x)) { + return (FALSE); + } + *uint64_p = x; + return (TRUE); + case XDR_FREE: + return (TRUE); + } + /* NOTREACHED */ + return (FALSE); +} + +/* FIXME: RTEMS does not support u_longlong_t and longlong_t, yet */ +#if !defined(__rtems__) +/* + * XDR hypers + */ +bool_t +xdr_hyper(xdrs, llp) + XDR *xdrs; + longlong_t *llp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_int64_t(). + */ + return (xdr_int64_t(xdrs, (int64_t *)llp)); +} + + +/* + * XDR unsigned hypers + */ +bool_t +xdr_u_hyper(xdrs, ullp) + XDR *xdrs; + u_longlong_t *ullp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_u_int64_t(). + */ + return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); +} + + +/* + * XDR longlong_t's + */ +bool_t +xdr_longlong_t(xdrs, llp) + XDR *xdrs; + longlong_t *llp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_int64_t(). + */ + return (xdr_int64_t(xdrs, (int64_t *)llp)); +} + + +/* + * XDR u_longlong_t's + */ +bool_t +xdr_u_longlong_t(xdrs, ullp) + XDR *xdrs; + u_longlong_t *ullp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_u_int64_t(). + */ + return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); +} +#endif -- cgit v1.2.3