diff options
Diffstat (limited to 'include')
31 files changed, 2492 insertions, 482 deletions
diff --git a/include/Makefile b/include/Makefile index 1b2ac62bbddc..97788a14bdab 100644 --- a/include/Makefile +++ b/include/Makefile @@ -7,13 +7,13 @@ # links. CLEANFILES= osreldate.h version vers.c -SUBDIR= rpcsvc +SUBDIR= rpcsvc rpc FILES= a.out.h ar.h assert.h bitstring.h ctype.h db.h dirent.h disktab.h \ dlfcn.h elf.h err.h fnmatch.h fstab.h \ fts.h glob.h grp.h strhash.h \ hesiod.h histedit.h ieeefp.h ifaddrs.h iso646.h langinfo.h \ libgen.h limits.h link.h locale.h malloc.h memory.h mpool.h \ - ndbm.h netdb.h nl_types.h nlist.h nsswitch.h objformat.h \ + netconfig.h ndbm.h netdb.h nl_types.h nlist.h nsswitch.h objformat.h \ paths.h pthread.h pthread_np.h pwd.h \ ranlib.h regex.h regexp.h resolv.h rune.h runetype.h \ search.h setjmp.h sgtty.h \ @@ -28,10 +28,6 @@ ARPAFILES= ftp.h inet.h nameser.h nameser_compat.h telnet.h tftp.h PROTOFILES= dumprestore.h routed.h rwhod.h talkd.h timed.h -RPCFILES= auth.h auth_unix.h clnt.h pmap_clnt.h pmap_prot.h pmap_rmt.h \ - rpc.h rpc_com.h rpc_msg.h svc.h svc_auth.h types.h xdr.h \ - auth_des.h des.h des_crypt.h - MFILES= float.h floatingpoint.h stdarg.h varargs.h # posix4/aio.h conflicts with dysons and isn't installed: @@ -86,9 +82,6 @@ beforeinstall: ${SHARED} cd ${.CURDIR}/protocols; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ ${PROTOFILES} ${DESTDIR}/usr/include/protocols - cd ${.CURDIR}/rpc; \ - ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ - ${RPCFILES} ${DESTDIR}/usr/include/rpc ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ ${.OBJDIR}/osreldate.h \ ${DESTDIR}/usr/include diff --git a/include/netconfig.h b/include/netconfig.h new file mode 100644 index 000000000000..330a5ee281c0 --- /dev/null +++ b/include/netconfig.h @@ -0,0 +1,96 @@ +/* $NetBSD: netconfig.h,v 1.1 2000/06/02 22:57:54 fvdl Exp $ */ +/* $FreeBSD$ */ + + +#ifndef _NETCONFIG_H_ +#define _NETCONFIG_H_ + +#include <sys/cdefs.h> + +#define NETCONFIG "/etc/netconfig" +#define NETPATH "NETPATH" + +struct netconfig { + char *nc_netid; /* Network ID */ + unsigned long nc_semantics; /* Semantics (see below) */ + unsigned long nc_flag; /* Flags (see below) */ + char *nc_protofmly; /* Protocol family */ + char *nc_proto; /* Protocol name */ + char *nc_device; /* Network device pathname */ + unsigned long nc_nlookups; /* Number of directory lookup libs */ + char **nc_lookups; /* Names of the libraries */ + unsigned long nc_unused[9]; /* reserved */ +}; + +typedef struct { + struct netconfig **nc_head; + struct netconfig **nc_curr; +} NCONF_HANDLE; + +/* + * nc_semantics values + */ +#define NC_TPI_CLTS 1 +#define NC_TPI_COTS 2 +#define NC_TPI_COTS_ORD 3 +#define NC_TPI_RAW 4 + +/* + * nc_flag values + */ +#define NC_NOFLAG 0x00 +#define NC_VISIBLE 0x01 +#define NC_BROADCAST 0x02 + +/* + * nc_protofmly values + */ +#define NC_NOPROTOFMLY "-" +#define NC_LOOPBACK "loopback" +#define NC_INET "inet" +#define NC_INET6 "inet6" +#define NC_IMPLINK "implink" +#define NC_PUP "pup" +#define NC_CHAOS "chaos" +#define NC_NS "ns" +#define NC_NBS "nbs" +#define NC_ECMA "ecma" +#define NC_DATAKIT "datakit" +#define NC_CCITT "ccitt" +#define NC_SNA "sna" +#define NC_DECNET "decnet" +#define NC_DLI "dli" +#define NC_LAT "lat" +#define NC_HYLINK "hylink" +#define NC_APPLETALK "appletalk" +#define NC_NIT "nit" +#define NC_IEEE802 "ieee802" +#define NC_OSI "osi" +#define NC_X25 "x25" +#define NC_OSINET "osinet" +#define NC_GOSIP "gosip" + +/* + * nc_proto values + */ +#define NC_NOPROTO "-" +#define NC_TCP "tcp" +#define NC_UDP "udp" +#define NC_ICMP "icmp" + +__BEGIN_DECLS +void *setnetconfig __P((void)); +struct netconfig *getnetconfig __P((void *)); +struct netconfig *getnetconfigent __P((char *)); +void freenetconfigent __P((struct netconfig *)); +int endnetconfig __P((void *)); + +void *setnetpath __P((void)); +struct netconfig *getnetpath __P((void *)); +int endnetpath(void *); + +void nc_perror __P((const char *)); +char *nc_sperror __P((void)); +__END_DECLS + +#endif /* _NETCONFIG_H_ */ diff --git a/include/pthread_np.h b/include/pthread_np.h index 485048bee30c..f5ac7f5aeb7c 100644 --- a/include/pthread_np.h +++ b/include/pthread_np.h @@ -29,6 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD$ */ #ifndef _PTHREAD_NP_H_ #define _PTHREAD_NP_H_ @@ -52,6 +53,7 @@ int pthread_mutexattr_setkind_np __P((pthread_mutexattr_t *, int)); void pthread_set_name_np __P((pthread_t, char *)); int pthread_switch_add_np __P((pthread_switch_routine_t)); int pthread_switch_delete_np __P((pthread_switch_routine_t)); +int pthread_main_np __P((void)); __END_DECLS #endif diff --git a/include/rpc/Makefile b/include/rpc/Makefile new file mode 100644 index 000000000000..1d159746eda4 --- /dev/null +++ b/include/rpc/Makefile @@ -0,0 +1,37 @@ +# from: @(#)Makefile 2.3 88/08/11 4.0 RPCSRC +# $FreeBSD$ + +.SUFFIXES: .x + +RPCCOM = rpcgen -C + +HDRS= rpcb_prot.h + +XFILES= rpcb_prot.x + +HFILES= auth.h auth_unix.h clnt.h clnt_soc.h clnt_stat.h \ + nettype.h pmap_clnt.h pmap_prot.h pmap_rmt.h raw.h \ + rpc.h rpc_msg.h rpcb_clnt.h rpcent.h rpc_com.h \ + svc.h svc_auth.h svc_soc.h svc_dg.h types.h xdr.h + +# Secure RPC +HFILES+= auth_des.h des.h des_crypt.h + +# Kerberos +HFILES+= auth_kerb.h + +CLEANFILES+= ${HDRS} + +all: ${HDRS} + +beforeinstall: + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \ + ${HFILES:S;^;${.CURDIR}/;} \ + ${XFILES:S;^;${.CURDIR}/;} \ + ${HDRS} \ + ${DESTDIR}/usr/include/rpc + +.x.h: + ${RPCCOM} -h -DWANT_NFS3 ${.IMPSRC} -o ${.TARGET} + +.include <bsd.prog.mk> diff --git a/include/rpc/auth.h b/include/rpc/auth.h index 4d6c38dbac17..68e8827b910c 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -1,3 +1,5 @@ +/* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -28,6 +30,7 @@ * * from: @(#)auth.h 1.17 88/02/08 SMI * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC + * from: @(#)auth.h 1.43 98/02/02 SMI * $FreeBSD$ */ @@ -43,6 +46,8 @@ #ifndef _RPC_AUTH_H #define _RPC_AUTH_H +#include <rpc/xdr.h> +#include <rpc/clnt_stat.h> #include <sys/cdefs.h> #include <sys/socket.h> @@ -50,6 +55,67 @@ #define MAXNETNAMELEN 255 /* maximum length of network user's name */ /* + * Client side authentication/security data + */ + +typedef struct sec_data { + u_int secmod; /* security mode number e.g. in nfssec.conf */ + u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int flags; /* AUTH_F_xxx flags */ + caddr_t data; /* opaque data per flavor */ +} sec_data_t; + +#ifdef _SYSCALL32_IMPL +struct sec_data32 { + uint32_t secmod; /* security mode number e.g. in nfssec.conf */ + uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ + int32_t flags; /* AUTH_F_xxx flags */ + caddr32_t data; /* opaque data per flavor */ +}; +#endif /* _SYSCALL32_IMPL */ + +/* + * AUTH_DES flavor specific data from sec_data opaque data field. + * AUTH_KERB has the same structure. + */ +typedef struct des_clnt_data { + struct netbuf syncaddr; /* time sync addr */ + struct knetconfig *knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + char *netname; /* server's netname */ + int netnamelen; /* server's netname len */ +} dh_k4_clntdata_t; + +#ifdef _SYSCALL32_IMPL +struct des_clnt_data32 { + struct netbuf32 syncaddr; /* time sync addr */ + caddr32_t knconf; /* knetconfig info that associated */ + /* with the syncaddr. */ + caddr32_t netname; /* server's netname */ + int32_t netnamelen; /* server's netname len */ +}; +#endif /* _SYSCALL32_IMPL */ + +#ifdef KERBEROS +/* + * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4) + * in sec_data->data opaque field. + */ +typedef struct krb4_svc_data { + int window; /* window option value */ +} krb4_svcdata_t; + +typedef struct krb4_svc_data des_svcdata_t; +#endif /* KERBEROS */ + +/* + * authentication/security specific flags + */ +#define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ +#define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ + + +/* * Status returned from authentication check */ enum auth_stat { @@ -67,18 +133,32 @@ enum auth_stat { */ AUTH_INVALIDRESP=6, /* bogus response verifier */ AUTH_FAILED=7 /* some unknown reason */ +#ifdef KERBEROS + /* + * kerberos errors + */ + AUTH_KERB_GENERIC = 8, /* kerberos generic error */ + AUTH_TIMEEXPIRE = 9, /* time of credential expired */ + AUTH_TKT_FILE = 10, /* something wrong with ticket file */ + AUTH_DECODE = 11, /* can't decode authenticator */ + AUTH_NET_ADDR = 12 /* wrong net address in ticket */ +#endif /* KERBEROS */ }; union des_block { struct { - u_int32_t high; - u_int32_t low; + uint32_t high; + uint32_t low; } key; char c[8]; }; typedef union des_block des_block; __BEGIN_DECLS -extern bool_t xdr_des_block __P((XDR *, des_block *)); +#ifdef __STDC__ +extern bool_t xdr_des_block(XDR *, des_block *); +#else +extern bool_t xdr_des_block(); +#endif __END_DECLS /* @@ -89,29 +169,26 @@ struct opaque_auth { caddr_t oa_base; /* address of more auth stuff */ u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ }; -__BEGIN_DECLS -bool_t xdr_opaque_auth __P((XDR *xdrs, struct opaque_auth *ap)); -__END_DECLS /* * Auth handle, interface to client side authenticators. */ -typedef struct __rpc_auth { +typedef struct __auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; struct auth_ops { - void (*ah_nextverf) __P((struct __rpc_auth *)); + void (*ah_nextverf) (struct __auth *); /* nextverf & serialize */ - int (*ah_marshal) __P((struct __rpc_auth *, XDR *)); + int (*ah_marshal) (struct __auth *, XDR *); /* validate verifier */ - int (*ah_validate) __P((struct __rpc_auth *, - struct opaque_auth *)); + int (*ah_validate) (struct __auth *, + struct opaque_auth *); /* refresh credentials */ - int (*ah_refresh) __P((struct __rpc_auth *)); + int (*ah_refresh) (struct __auth *, void *); /* destroy this structure */ - void (*ah_destroy) __P((struct __rpc_auth *)); + void (*ah_destroy) (struct __auth *); } *ah_ops; caddr_t ah_private; } AUTH; @@ -140,10 +217,10 @@ typedef struct __rpc_auth { #define auth_validate(auth, verfp) \ ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define AUTH_REFRESH(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) -#define auth_refresh(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) +#define AUTH_REFRESH(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) +#define auth_refresh(auth, msg) \ + ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define AUTH_DESTROY(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)) @@ -151,14 +228,16 @@ typedef struct __rpc_auth { ((*((auth)->ah_ops->ah_destroy))(auth)) +__BEGIN_DECLS extern struct opaque_auth _null_auth; +__END_DECLS /* * These are the various implementations of client side authenticators. */ /* - * Unix style authentication + * System style authentication * AUTH *authunix_create(machname, uid, gid, len, aup_gids) * char *machname; * int uid; @@ -167,94 +246,105 @@ extern struct opaque_auth _null_auth; * int *aup_gids; */ __BEGIN_DECLS -struct sockaddr_in; -extern AUTH *authunix_create __P((char *, int, int, int, int *)); -extern AUTH *authunix_create_default __P((void)); -extern AUTH *authnone_create __P((void)); +extern AUTH *authunix_create(char *, int, int, int, + int *); +extern AUTH *authunix_create_default(void); /* takes no parameters */ +extern AUTH *authnone_create(void); /* takes no parameters */ __END_DECLS - -/* Forward compatibility with TI-RPC */ -#define authsys_create authunix_create -#define authsys_create_default authunix_create_default - /* * DES style authentication - * AUTH *authdes_create(servername, window, timehost, ckey) + * AUTH *authsecdes_create(servername, window, timehost, ckey) * char *servername; - network name of server * u_int window; - time to live - * struct sockaddr *timehost; - optional hostname to sync with + * const char *timehost; - optional hostname to sync with * des_block *ckey; - optional conversation key to use */ __BEGIN_DECLS -extern AUTH *authdes_create __P(( char *, u_int, struct sockaddr *, des_block * )); -#ifdef NOTYET -/* - * TI-RPC supports this call, but it requires the inclusion of - * NIS+-specific headers which would require the inclusion of other - * headers which would result in a tangled mess. For now, the NIS+ - * code prototypes this routine internally. - */ -extern AUTH *authdes_pk_create __P(( char *, netobj *, u_int, - struct sockaddr *, des_block *, - nis_server * )); -#endif +extern AUTH *authdes_create (char *, u_int, struct sockaddr *, des_block *); +extern AUTH *authdes_seccreate (const char *, const u_int, const char *, + const des_block *); +__END_DECLS + +__BEGIN_DECLS +extern bool_t xdr_opaque_auth __P((XDR *, struct opaque_auth *)); __END_DECLS +#define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) +#define authsys_create_default() authunix_create_default() + /* * Netname manipulation routines. */ __BEGIN_DECLS -extern int netname2user __P(( char *, uid_t *, gid_t *, int *, gid_t *)); -extern int netname2host __P(( char *, char *, int )); -extern int getnetname __P(( char * )); -extern int user2netname __P(( char *, uid_t, char * )); -extern int host2netname __P(( char *, char *, char * )); -extern void passwd2des __P(( char *, char * )); +extern int getnetname(char *); +extern int host2netname(char *, const char *, const char *); +extern int user2netname(char *, const uid_t, const char *); +extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); +extern int netname2host(char *, char *, const int); +extern void passwd2des ( char *, char * ); __END_DECLS /* - * Keyserv interface routines. - * XXX Should not be here. + * + * These routines interface to the keyserv daemon + * */ -#ifndef HEXKEYBYTES -#define HEXKEYBYTES 48 -#endif -typedef char kbuf[HEXKEYBYTES]; -typedef char *namestr; - -struct netstarg { - kbuf st_priv_key; - kbuf st_pub_key; - namestr st_netname; -}; +__BEGIN_DECLS +extern int key_decryptsession(const char *, des_block *); +extern int key_encryptsession(const char *, des_block *); +extern int key_gendes(des_block *); +extern int key_setsecret(const char *); +extern int key_secretkey_is_set(void); +__END_DECLS +#ifdef KERBEROS +/* + * Kerberos style authentication + * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status) + * const char *service; - service name + * const char *srv_inst; - server instance + * const char *realm; - server realm + * const u_int window; - time to live + * const char *timehost; - optional hostname to sync with + * int *status; - kerberos status returned + */ __BEGIN_DECLS -extern int key_decryptsession __P(( const char *, des_block * )); -extern int key_decryptsession_pk __P(( char *, netobj *, des_block * )); -extern int key_encryptsession __P(( const char *, des_block * )); -extern int key_encryptsession_pk __P(( char *, netobj *, des_block * )); -extern int key_gendes __P(( des_block * )); -extern int key_setsecret __P(( const char * )); -extern int key_secretkey_is_set __P(( void )); -extern int key_setnet __P(( struct netstarg * )); -extern int key_get_conv __P(( char *, des_block * )); +extern AUTH *authkerb_seccreate(const char *, const char *, const char *, + const u_int, const char *, int *); __END_DECLS /* - * Publickey routines. + * Map a kerberos credential into a unix cred. + * + * authkerb_getucred(rqst, uid, gid, grouplen, groups) + * const struct svc_req *rqst; - request pointer + * uid_t *uid; + * gid_t *gid; + * short *grouplen; + * int *groups; + * */ __BEGIN_DECLS -extern int getpublickey __P(( char *, char * )); -extern int getpublicandprivatekey __P(( char *, char * )); -extern int getsecretkey __P(( char *, char *, char * )); +extern int authkerb_getucred(/* struct svc_req *, uid_t *, gid_t *, + short *, int * */); __END_DECLS +#endif /* KERBEROS */ +__BEGIN_DECLS +struct svc_req; +struct rpc_msg; +enum auth_stat _svcauth_null __P((struct svc_req *, struct rpc_msg *)); +enum auth_stat _svcauth_short __P((struct svc_req *, struct rpc_msg *)); +enum auth_stat _svcauth_unix __P((struct svc_req *, struct rpc_msg *)); +__END_DECLS #define AUTH_NONE 0 /* no authentication */ #define AUTH_NULL 0 /* backward compatibility */ -#define AUTH_UNIX 1 /* unix style (uid, gids) */ -#define AUTH_SYS 1 /* forward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS #define AUTH_SHORT 2 /* short hand unix style */ -#define AUTH_DES 3 /* des style (encrypted timestamps) */ +#define AUTH_DH 3 /* for Diffie-Hellman mechanism */ +#define AUTH_DES AUTH_DH /* for backward compatibility */ +#define AUTH_KERB 4 /* kerberos style */ #endif /* !_RPC_AUTH_H */ diff --git a/include/rpc/auth_des.h b/include/rpc/auth_des.h index a7635f87e17c..964e77480da7 100644 --- a/include/rpc/auth_des.h +++ b/include/rpc/auth_des.h @@ -1,4 +1,5 @@ /* @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC; from 1.3 88/02/08 SMI */ +/* $FreeBSD$ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -26,10 +27,13 @@ * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 + * + * from: @(#)auth_des.h 2.2 88/07/29 4.0 RPCSRC + * from: @(#)auth_des.h 1.14 94/04/25 SMI */ /* - * Copyright (c) 1988 by Sun Microsystems, Inc. + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* @@ -102,8 +106,21 @@ struct authdes_verf { #define adv_xtimeverf adv_time_u.adv_xtime #define adv_nickname adv_int_u +/* + * Map a des credential into a unix cred. + * + */ __BEGIN_DECLS extern int authdes_getucred __P(( struct authdes_cred *, uid_t *, gid_t *, int *, gid_t * )); __END_DECLS +__BEGIN_DECLS +extern bool_t xdr_authdes_cred(XDR *, struct authdes_cred *); +extern bool_t xdr_authdes_verf(XDR *, struct authdes_verf *); +extern int rtime(dev_t, struct netbuf *, int, struct timeval *, + struct timeval *); +extern void kgetnetname(char *); +extern enum auth_stat _svcauth_des(struct svc_req *, struct rpc_msg *); +__END_DECLS + #endif /* ndef _AUTH_DES_ */ diff --git a/include/rpc/auth_kerb.h b/include/rpc/auth_kerb.h new file mode 100644 index 000000000000..f0145bd4789d --- /dev/null +++ b/include/rpc/auth_kerb.h @@ -0,0 +1,143 @@ +/* $FreeBSD$ */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * auth_kerb.h, Protocol for Kerberos style authentication for RPC + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_AUTH_KERB_H +#define _RPC_AUTH_KERB_H + +#ifdef KERBEROS + +#pragma ident "@(#)auth_kerb.h 1.10 94/04/25 SMI" + +#include <kerberos/krb.h> +#include <sys/socket.h> +#include <sys/t_kuser.h> +#include <netinet/in.h> +#include <rpc/svc.h> + +/* + * There are two kinds of "names": fullnames and nicknames + */ +enum authkerb_namekind { + AKN_FULLNAME, + AKN_NICKNAME +}; +/* + * A fullname contains the ticket and the window + */ +struct authkerb_fullname { + KTEXT_ST ticket; + u_long window; /* associated window */ +}; + +/* + * cooked credential stored in rq_clntcred + */ +struct authkerb_clnt_cred { + /* start of AUTH_DAT */ + unsigned char k_flags; /* Flags from ticket */ + char pname[ANAME_SZ]; /* Principal's name */ + char pinst[INST_SZ]; /* His Instance */ + char prealm[REALM_SZ]; /* His Realm */ + unsigned long checksum; /* Data checksum (opt) */ + C_Block session; /* Session Key */ + int life; /* Life of ticket */ + unsigned long time_sec; /* Time ticket issued */ + unsigned long address; /* Address in ticket */ + /* KTEXT_ST reply; Auth reply (opt) */ + /* end of AUTH_DAT */ + unsigned long expiry; /* time the ticket is expiring */ + u_long nickname; /* Nickname into cache */ + u_long window; /* associated window */ +}; + +typedef struct authkerb_clnt_cred authkerb_clnt_cred; + +/* + * A credential + */ +struct authkerb_cred { + enum authkerb_namekind akc_namekind; + struct authkerb_fullname akc_fullname; + u_long akc_nickname; +}; + +/* + * A kerb authentication verifier + */ +struct authkerb_verf { + union { + struct timeval akv_ctime; /* clear time */ + des_block akv_xtime; /* crypt time */ + } akv_time_u; + u_long akv_int_u; +}; + +/* + * des authentication verifier: client variety + * + * akv_timestamp is the current time. + * akv_winverf is the credential window + 1. + * Both are encrypted using the conversation key. + */ +#ifndef akv_timestamp +#define akv_timestamp akv_time_u.akv_ctime +#define akv_xtimestamp akv_time_u.akv_xtime +#define akv_winverf akv_int_u +#endif +/* + * des authentication verifier: server variety + * + * akv_timeverf is the client's timestamp + client's window + * akv_nickname is the server's nickname for the client. + * akv_timeverf is encrypted using the conversation key. + */ +#ifndef akv_timeverf +#define akv_timeverf akv_time_u.akv_ctime +#define akv_xtimeverf akv_time_u.akv_xtime +#define akv_nickname akv_int_u +#endif + +/* + * Register the service name, instance and realm. + */ +extern int authkerb_create(char *, char *, char *, u_int, + struct netbuf *, int *, dev_t, int, AUTH **); +extern bool_t xdr_authkerb_cred(XDR *, struct authkerb_cred *); +extern bool_t xdr_authkerb_verf(XDR *, struct authkerb_verf *); +extern int svc_kerb_reg(SVCXPRT *, char *, char *, char *); +extern enum auth_stat _svcauth_kerb(struct svc_req *, struct rpc_msg *); + +#endif KERBEROS +#endif /* !_RPC_AUTH_KERB_H */ diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h index cf2116d611fa..2b0587b169ef 100644 --- a/include/rpc/clnt.h +++ b/include/rpc/clnt.h @@ -1,3 +1,5 @@ +/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -26,7 +28,7 @@ * 2550 Garcia Avenue * Mountain View, California 94043 * - * from: @(#)clnt.h 1.31 88/02/08 SMI + * from: @(#)clnt.h 1.31 94/04/29 SMI * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD$ */ @@ -39,52 +41,28 @@ #ifndef _RPC_CLNT_H_ #define _RPC_CLNT_H_ +#include <rpc/clnt_stat.h> #include <sys/cdefs.h> +#include <netconfig.h> #include <sys/un.h> /* - * Rpc calls return an enum clnt_stat. This should be looked at more, - * since each implementation is required to live with this (implementation - * independent) list of errors. - */ -enum clnt_stat { - RPC_SUCCESS=0, /* call succeeded */ - /* - * local errors - */ - RPC_CANTENCODEARGS=1, /* can't encode arguments */ - RPC_CANTDECODERES=2, /* can't decode results */ - RPC_CANTSEND=3, /* failure in sending call */ - RPC_CANTRECV=4, /* failure in receiving result */ - RPC_TIMEDOUT=5, /* call timed out */ - /* - * remote errors - */ - RPC_VERSMISMATCH=6, /* rpc versions not compatible */ - RPC_AUTHERROR=7, /* authentication error */ - RPC_PROGUNAVAIL=8, /* program not available */ - RPC_PROGVERSMISMATCH=9, /* program version mismatched */ - RPC_PROCUNAVAIL=10, /* procedure unavailable */ - RPC_CANTDECODEARGS=11, /* decode arguments error */ - RPC_SYSTEMERROR=12, /* generic "other problem" */ - - /* - * callrpc & clnt_create errors - */ - RPC_UNKNOWNHOST=13, /* unknown host name */ - RPC_UNKNOWNPROTO=17, /* unkown protocol */ - - /* - * _ create errors - */ - RPC_PMAPFAILURE=14, /* the pmapper failed in its call */ - RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ - /* - * unspecified error - */ - RPC_FAILED=16 -}; + * Well-known IPV6 RPC broadcast address. + */ +#define RPCB_MULTICAST_ADDR "ff02::202" +/* + * the following errors are in general unrecoverable. The caller + * should give up rather than retry. + */ +#define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ + ((s) == RPC_CANTENCODEARGS) || \ + ((s) == RPC_CANTDECODERES) || \ + ((s) == RPC_VERSMISMATCH) || \ + ((s) == RPC_PROCUNAVAIL) || \ + ((s) == RPC_PROGUNAVAIL) || \ + ((s) == RPC_PROGVERSMISMATCH) || \ + ((s) == RPC_CANTDECODEARGS)) /* * Error info. @@ -95,8 +73,8 @@ struct rpc_err { int RE_errno; /* related system error */ enum auth_stat RE_why; /* why the auth error occurred */ struct { - u_int32_t low; /* lowest verion supported */ - u_int32_t high; /* highest verion supported */ + rpcvers_t low; /* lowest version supported */ + rpcvers_t high; /* highest version supported */ } RE_vers; struct { /* maybe meaningful if RPC_FAILED */ int32_t s1; @@ -112,7 +90,7 @@ struct rpc_err { /* * Client rpc handle. - * Created by individual implementations, see e.g. rpc_udp.c. + * Created by individual implementations * Client is responsible for initializing auth, see e.g. auth_none.c. */ typedef struct __rpc_client { @@ -120,7 +98,7 @@ typedef struct __rpc_client { struct clnt_ops { /* call remote procedure */ enum clnt_stat (*cl_call) __P((struct __rpc_client *, - u_long, xdrproc_t, caddr_t, xdrproc_t, + rpcproc_t, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval)); /* abort a call */ void (*cl_abort) __P((struct __rpc_client *)); @@ -134,13 +112,37 @@ typedef struct __rpc_client { void (*cl_destroy) __P((struct __rpc_client *)); /* the ioctl() of rpc */ bool_t (*cl_control) __P((struct __rpc_client *, u_int, - void *)); + char *)); } *cl_ops; - caddr_t cl_private; /* private stuff */ + void *cl_private; /* private stuff */ + char *cl_netid; /* network token */ + char *cl_tp; /* device name */ } CLIENT; /* + * Timers used for the pseudo-transport protocol when using datagrams + */ +struct rpc_timers { + u_short rt_srtt; /* smoothed round-trip time */ + u_short rt_deviate; /* estimated deviation */ + u_long rt_rtxcur; /* current (backed-off) rto */ +}; + +/* + * Feedback values used for possible congestion and rate control + */ +#define FEEDBACK_REXMIT1 1 /* first retransmit */ +#define FEEDBACK_OK 2 /* no retransmits */ + +/* Used to set version of portmapper used in broadcast */ + +#define CLCR_SET_LOWVERS 3 +#define CLCR_GET_LOWVERS 4 + +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +/* * client side rpc interface ops * * Parameter types are: @@ -151,19 +153,19 @@ typedef struct __rpc_client { * enum clnt_stat * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) * CLIENT *rh; - * u_long proc; + * rpcproc_t proc; * xdrproc_t xargs; * caddr_t argsp; * xdrproc_t xres; * caddr_t resp; * struct timeval timeout; */ -#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \ - xres, (caddr_t)resp, secs)) -#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \ - xres, (caddr_t)resp, secs)) +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ + (caddr_t)(void *)argsp, xres, (caddr_t)(void *)resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ + (caddr_t)(void *)argsp, xres, (caddr_t)(void *)resp, secs)) /* * void @@ -203,43 +205,31 @@ typedef struct __rpc_client { #define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) /* - * control operations that apply to udp, tcp and unix transports - * - * Note: options marked XXX are no-ops in this implementation of RPC. - * The are present in TI-RPC but can't be implemented here since they - * depend on the presence of STREAMS/TLI, which we don't have. - * + * control operations that apply to both udp and tcp transports */ -#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ -#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ -#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ -#define CLGET_FD 6 /* get connections file descriptor */ -#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */ -#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ -#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ -#define CLGET_XID 10 /* Get xid */ -#define CLSET_XID 11 /* Set xid */ -#define CLGET_VERS 12 /* Get version number */ -#define CLSET_VERS 13 /* Set version number */ -#define CLGET_PROG 14 /* Get program number */ -#define CLSET_PROG 15 /* Set program number */ -#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ -#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ -#define CLSET_POP_TIMOD 18 /* pop timod XXX */ - -/* - * udp only control operations +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ +#define CLSET_POP_TIMOD 18 /* pop timod */ +/* + * Connectionless only control operations */ #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ /* - * Operations which GSSAPI needs. (Bletch.) - */ -#define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */ - - -/* * void * CLNT_DESTROY(rh); * CLIENT *rh; @@ -254,16 +244,16 @@ typedef struct __rpc_client { * and network administration. */ -#define RPCTEST_PROGRAM ((u_long)1) -#define RPCTEST_VERSION ((u_long)1) -#define RPCTEST_NULL_PROC ((u_long)2) -#define RPCTEST_NULL_BATCH_PROC ((u_long)3) +#define RPCTEST_PROGRAM ((rpcprog_t)1) +#define RPCTEST_VERSION ((rpcvers_t)1) +#define RPCTEST_NULL_PROC ((rpcproc_t)2) +#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) /* * By convention, procedure 0 takes null arguments and returns them */ -#define NULLPROC ((u_long)0) +#define NULLPROC ((rpcproc_t)0) /* * Below are the client handle creation routines for the various @@ -272,108 +262,112 @@ typedef struct __rpc_client { */ /* - * Memory based rpc (for speed check and testing) + * Generic client creation routine. Supported protocols are those that + * belong to the nettype namespace (/etc/netconfig). * CLIENT * - * clntraw_create(prog, vers) - * u_long prog; - * u_long vers; + * clnt_create(host, prog, vers, prot); + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *prot; -- protocol */ __BEGIN_DECLS -extern CLIENT *clntraw_create __P((u_long, u_long)); -__END_DECLS - +extern CLIENT *clnt_create __P((const char *, const rpcprog_t, const rpcvers_t, + const char *)); +/* + * + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const char *nettype; -- network type + */ /* - * Generic client creation routine. Supported protocols are "udp", "tcp" - * and "unix". - * CLIENT * - * clnt_create(host, prog, vers, prot); - * char *host; -- hostname - * u_long prog; -- program number - * u_long vers; -- version number - * char *prot; -- protocol + * Generic client creation routine. Supported protocols are which belong + * to the nettype name space. + */ +extern CLIENT *clnt_create_vers __P((const char *, const rpcprog_t, rpcvers_t *, + const rpcvers_t, const rpcvers_t, + const char *)); +/* + * const char *host; -- hostname + * const rpcprog_t prog; -- program number + * rpcvers_t *vers_out; -- servers highest available version + * const rpcvers_t vers_low; -- low version number + * const rpcvers_t vers_high; -- high version number + * const char *nettype; -- network type */ -__BEGIN_DECLS -extern CLIENT *clnt_create __P((char *, u_long, u_long, char *)); -__END_DECLS /* - * TCP based rpc - * CLIENT * - * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long prog; - * u_long version; - * register int *sockp; - * u_int sendsz; - * u_int recvsz; + * Generic client creation routine. It takes a netconfig structure + * instead of nettype + */ +extern CLIENT *clnt_tp_create __P((const char *, const rpcprog_t, + const rpcvers_t, const struct netconfig *)); +/* + * const char *hostname; -- hostname + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const struct netconfig *netconf; -- network config structure */ -__BEGIN_DECLS -extern CLIENT *clnttcp_create __P((struct sockaddr_in *, - u_long, - u_long, - int *, - u_int, - u_int)); -__END_DECLS +/* + * Generic TLI create routine. Only provided for compatibility. + */ +extern CLIENT *clnt_tli_create __P((const int, const struct netconfig *, + const struct netbuf *, const rpcprog_t, + const rpcvers_t, const u_int, const u_int)); /* - * UDP based rpc. - * CLIENT * - * clntudp_create(raddr, program, version, wait, sockp) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * - * Same as above, but you specify max packet sizes. - * CLIENT * - * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * u_int sendsz; - * u_int recvsz; + * const register int fd; -- fd + * const struct netconfig *nconf; -- netconfig structure + * const struct netbuf *svcaddr; -- servers address + * const u_long prog; -- program number + * const u_long vers; -- version number + * const u_int sendsz; -- send size + * const u_int recvsz; -- recv size */ -__BEGIN_DECLS -extern CLIENT *clntudp_create __P((struct sockaddr_in *, - u_long, - u_long, - struct timeval, - int *)); -extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *, - u_long, - u_long, - struct timeval, - int *, - u_int, - u_int)); -__END_DECLS +/* + * Low level clnt create routine for connectionful transports, e.g. tcp. + */ +extern CLIENT *clnt_vc_create __P((const int, const struct netbuf *, + const rpcprog_t, const rpcvers_t, + const u_int, const u_int)); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const u_int sendsz; -- buffer recv size + * const u_int recvsz; -- buffer send size + */ /* - * AF_UNIX based rpc + * Low level clnt create routine for connectionless transports, e.g. udp. + */ +extern CLIENT *clnt_dg_create __P((const int, const struct netbuf *, + const rpcprog_t, const rpcvers_t, + const u_int, const u_int)); +/* + * const int fd; -- open file descriptor + * const struct netbuf *svcaddr; -- servers address + * const rpcprog_t program; -- program number + * const rpcvers_t version; -- version number + * const u_int sendsz; -- buffer recv size + * const u_int recvsz; -- buffer send size + */ + +/* + * Memory based rpc (for speed check and testing) * CLIENT * - * clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) - * struct sockaddr_un *raddr; + * clnt_raw_create(prog, vers) * u_long prog; - * u_long version; - * register int *sockp; - * u_int sendsz; - * u_int recvsz; + * u_long vers; */ -__BEGIN_DECLS -extern CLIENT *clntunix_create __P((struct sockaddr_un *, - u_long, - u_long, - int *, - u_int, - u_int)); +extern CLIENT *clnt_raw_create __P((rpcprog_t, rpcvers_t)); + __END_DECLS @@ -381,8 +375,8 @@ __END_DECLS * Print why creation failed */ __BEGIN_DECLS -extern void clnt_pcreateerror __P((char *)); /* stderr */ -extern char *clnt_spcreateerror __P((char *)); /* string */ +extern void clnt_pcreateerror __P((const char *)); /* stderr */ +extern char *clnt_spcreateerror __P((const char *)); /* string */ __END_DECLS /* @@ -397,8 +391,8 @@ __END_DECLS * Print an English error message, given the client error code */ __BEGIN_DECLS -extern void clnt_perror __P((CLIENT *, char *)); /* stderr */ -extern char *clnt_sperror __P((CLIENT *, char *)); /* string */ +extern void clnt_perror __P((CLIENT *, const char *)); /* stderr */ +extern char *clnt_sperror __P((CLIENT *, const char *)); /* string */ __END_DECLS @@ -410,10 +404,94 @@ struct rpc_createerr { struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ }; +#ifdef _THREAD_SAFE +__BEGIN_DECLS +extern struct rpc_createerr *__rpc_createerr __P((void)); +__END_DECLS +#define rpc_createerr (*(__rpc_createerr())) +#else extern struct rpc_createerr rpc_createerr; +#endif /* _THREAD_SAFE */ + +/* + * The simplified interface: + * enum clnt_stat + * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) + * const char *host; + * const rpcprog_t prognum; + * const rpcvers_t versnum; + * const rpcproc_t procnum; + * const xdrproc_t inproc, outproc; + * const char *in; + * char *out; + * const char *nettype; + */ +__BEGIN_DECLS +extern enum clnt_stat rpc_call __P((const char *, const rpcprog_t, + const rpcvers_t, const rpcproc_t, + const xdrproc_t, const char *, + const xdrproc_t, char *, const char *)); +__END_DECLS +/* + * RPC broadcast interface + * The call is broadcasted to all locally connected nets. + * + * extern enum clnt_stat + * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const char *nettype; -- Transport type + * + * For each valid response received, the procedure eachresult is called. + * Its form is: + * done = eachresult(resp, raddr, nconf) + * bool_t done; + * caddr_t resp; + * struct netbuf *raddr; + * struct netconfig *nconf; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. nconf is the transport + * on which the response was received. + * + * extern enum clnt_stat + * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, + * eachresult, inittime, waittime, nettype) + * const rpcprog_t prog; -- program number + * const rpcvers_t vers; -- version number + * const rpcproc_t proc; -- procedure number + * const xdrproc_t xargs; -- xdr routine for args + * caddr_t argsp; -- pointer to args + * const xdrproc_t xresults; -- xdr routine for results + * caddr_t resultsp; -- pointer to results + * const resultproc_t eachresult; -- call with each result + * const int inittime; -- how long to wait initially + * const int waittime; -- maximum time to wait + * const char *nettype; -- Transport type + */ + +typedef bool_t (*resultproc_t) __P((caddr_t, ...)); + +__BEGIN_DECLS +extern enum clnt_stat rpc_broadcast __P((const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, + caddr_t, const xdrproc_t, caddr_t, + const resultproc_t, const char *)); +extern enum clnt_stat rpc_broadcast_exp __P((const rpcprog_t, const rpcvers_t, + const rpcproc_t, const xdrproc_t, + caddr_t, const xdrproc_t, caddr_t, + const resultproc_t, const int, + const int, const char *)); +__END_DECLS -#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ -#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ +/* For backward compatibility */ +#include <rpc/clnt_soc.h> -#endif /* !_RPC_CLNT_H */ +#endif /* !_RPC_CLNT_H_ */ diff --git a/include/rpc/clnt_soc.h b/include/rpc/clnt_soc.h new file mode 100644 index 000000000000..b6c1bd2300a8 --- /dev/null +++ b/include/rpc/clnt_soc.h @@ -0,0 +1,118 @@ +/* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. + */ + +/* + * clnt.h - Client side remote procedure call interface. + */ + +#ifndef _RPC_CLNT_SOC_H +#define _RPC_CLNT_SOC_H + +/* derived from clnt_soc.h 1.3 88/12/17 SMI */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC. + */ + +#include <sys/cdefs.h> + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clnttcp_create __P((struct sockaddr_in *, + u_long, + u_long, + int *, + u_int, + u_int)); +__END_DECLS + +/* + * Raw (memory) rpc. + */ +__BEGIN_DECLS +extern CLIENT *clntraw_create __P((u_long, u_long)); +__END_DECLS + + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clntudp_create __P((struct sockaddr_in *, + u_long, + u_long, + struct timeval, + int *)); +extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *, + u_long, + u_long, + struct timeval, + int *, + u_int, + u_int)); +__END_DECLS + +#endif /* _RPC_CLNT_SOC_H */ diff --git a/include/rpc/clnt_stat.h b/include/rpc/clnt_stat.h new file mode 100644 index 000000000000..26cb4ffff39c --- /dev/null +++ b/include/rpc/clnt_stat.h @@ -0,0 +1,83 @@ +/* $FreeBSD$ */ +/* + * Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * clnt_stat.h - Client side remote procedure call enum + * + */ + +#ifndef _RPC_CLNT_STAT_H +#define _RPC_CLNT_STAT_H + +#pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +enum clnt_stat { + RPC_SUCCESS = 0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS = 1, /* can't encode arguments */ + RPC_CANTDECODERES = 2, /* can't decode results */ + RPC_CANTSEND = 3, /* failure in sending call */ + RPC_CANTRECV = 4, + /* failure in receiving result */ + RPC_TIMEDOUT = 5, /* call timed out */ + RPC_INTR = 18, /* call interrupted */ + RPC_UDERROR = 23, /* recv got uderr indication */ + /* + * remote errors + */ + RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ + RPC_AUTHERROR = 7, /* authentication error */ + RPC_PROGUNAVAIL = 8, /* program not available */ + RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ + RPC_PROCUNAVAIL = 10, /* procedure unavailable */ + RPC_CANTDECODEARGS = 11, /* decode arguments error */ + RPC_SYSTEMERROR = 12, /* generic "other problem" */ + + /* + * rpc_call & clnt_create errors + */ + RPC_UNKNOWNHOST = 13, /* unknown host name */ + RPC_UNKNOWNPROTO = 17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, + /* Name to address translation failed */ + /* + * Misc error in the TLI library + */ + RPC_TLIERROR = 20, + /* + * unspecified error + */ + RPC_FAILED = 16, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25, + RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ + RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ + RPC_CANTCREATESTREAM = 28 /* can't push rpc module (cots) */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_CLNT_STAT_H */ diff --git a/include/rpc/des_crypt.h b/include/rpc/des_crypt.h index c223cd1b77f0..ce6c1bf44783 100644 --- a/include/rpc/des_crypt.h +++ b/include/rpc/des_crypt.h @@ -33,6 +33,16 @@ * 2550 Garcia Avenue * Mountain View, California 94043 */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * des_crypt.h, des library routine interface + */ + +#ifndef _DES_DES_CRYPT_H +#define _DES_DES_CRYPT_H #include <sys/cdefs.h> #include <rpc/rpc.h> @@ -75,46 +85,22 @@ * Cipher Block Chaining mode */ __BEGIN_DECLS -#ifdef __STDC__ int cbc_crypt __P(( char *, char *, unsigned int, unsigned int, char *)); -#else -cbc_crypt(/* key, buf, len, mode, ivec */); /* - char *key; - char *buf; - unsigned len; - unsigned mode; - char *ivec; -*/ -#endif +__END_DECLS /* * Electronic Code Book mode */ -#ifdef __STDC__ +__BEGIN_DECLS int ecb_crypt __P(( char *, char *, unsigned int, unsigned int )); -#else -ecb_crypt(/* key, buf, len, mode */); /* - char *key; - char *buf; - unsigned len; - unsigned mode; -*/ -#endif __END_DECLS -#ifndef _KERNEL /* * Set des parity for a key. * DES parity is odd and in the low bit of each byte */ __BEGIN_DECLS -#ifdef __STDC__ void des_setparity __P(( char *)); -#else -void -des_setparity(/* key */); /* - char *key; -*/ -#endif __END_DECLS -#endif + +#endif /* _DES_DES_CRYPT_H */ diff --git a/include/rpc/nettype.h b/include/rpc/nettype.h new file mode 100644 index 000000000000..f53c445d6ee3 --- /dev/null +++ b/include/rpc/nettype.h @@ -0,0 +1,64 @@ +/* $NetBSD: nettype.h,v 1.2 2000/07/06 03:17:19 christos Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * nettype.h, Nettype definitions. + * All for the topmost layer of rpc + * + */ + +#ifndef _RPC_NETTYPE_H +#define _RPC_NETTYPE_H + +#include <netconfig.h> + +#define _RPC_NONE 0 +#define _RPC_NETPATH 1 +#define _RPC_VISIBLE 2 +#define _RPC_CIRCUIT_V 3 +#define _RPC_DATAGRAM_V 4 +#define _RPC_CIRCUIT_N 5 +#define _RPC_DATAGRAM_N 6 +#define _RPC_TCP 7 +#define _RPC_UDP 8 + +__BEGIN_DECLS +extern void *__rpc_setconf __P((const char *)); +extern void __rpc_endconf __P((void *)); +extern struct netconfig *__rpc_getconf __P((void *)); +extern struct netconfig *__rpc_getconfip __P((const char *)); +__END_DECLS + +#endif /* !_RPC_NETTYPE_H */ diff --git a/include/rpc/pmap_clnt.h b/include/rpc/pmap_clnt.h index d4080cc2857a..a2beae5691ce 100644 --- a/include/rpc/pmap_clnt.h +++ b/include/rpc/pmap_clnt.h @@ -1,3 +1,5 @@ +/* $NetBSD: pmap_clnt.h,v 1.9 2000/06/02 22:57:55 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -26,7 +28,7 @@ * 2550 Garcia Avenue * Mountain View, California 94043 * - * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI + * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD$ */ @@ -60,8 +62,8 @@ * address if the responder to the broadcast. */ -#ifndef _RPC_PMAPCLNT_H -#define _RPC_PMAPCLNT_H +#ifndef _RPC_PMAP_CLNT_H_ +#define _RPC_PMAP_CLNT_H_ #include <sys/cdefs.h> __BEGIN_DECLS @@ -76,10 +78,9 @@ extern enum clnt_stat pmap_rmtcall __P((struct sockaddr_in *, extern enum clnt_stat clnt_broadcast __P((u_long, u_long, u_long, xdrproc_t, char *, xdrproc_t, char *, - bool_t (*) __P((caddr_t, - struct sockaddr_in *)))); + resultproc_t)); extern u_short pmap_getport __P((struct sockaddr_in *, u_long, u_long, u_int)); __END_DECLS -#endif /* !_RPC_PMAPCLNT_H */ +#endif /* !_RPC_PMAP_CLNT_H_ */ diff --git a/include/rpc/pmap_prot.h b/include/rpc/pmap_prot.h index 123ee159dfae..7dddab2e0d5b 100644 --- a/include/rpc/pmap_prot.h +++ b/include/rpc/pmap_prot.h @@ -1,3 +1,5 @@ +/* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -26,7 +28,7 @@ * 2550 Garcia Avenue * Mountain View, California 94043 * - * from: @(#)pmap_prot.h 1.14 88/02/08 SMI + * from: @(#)pmap_prot.h 1.14 88/02/08 SMI * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD$ */ @@ -68,8 +70,8 @@ * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ -#ifndef _RPC_PMAPPROT_H -#define _RPC_PMAPPROT_H +#ifndef _RPC_PMAP_PROT_H +#define _RPC_PMAP_PROT_H #include <sys/cdefs.h> #define PMAPPORT ((u_short)111) @@ -99,6 +101,7 @@ struct pmaplist { __BEGIN_DECLS extern bool_t xdr_pmap __P((XDR *, struct pmap *)); extern bool_t xdr_pmaplist __P((XDR *, struct pmaplist **)); +extern bool_t xdr_pmaplist_ptr __P((XDR *, struct pmaplist *)); __END_DECLS -#endif /* !_RPC_PMAPPROT_H */ +#endif /* !_RPC_PMAP_PROT_H */ diff --git a/include/rpc/pmap_rmt.h b/include/rpc/pmap_rmt.h index 845e815e0add..4361f0d0b4f7 100644 --- a/include/rpc/pmap_rmt.h +++ b/include/rpc/pmap_rmt.h @@ -1,3 +1,5 @@ +/* $NetBSD: pmap_rmt.h,v 1.7 1998/02/11 23:01:23 lukem Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -38,8 +40,8 @@ * Copyright (C) 1986, Sun Microsystems, Inc. */ -#ifndef _RPC_PMAPRMT_H -#define _RPC_PMAPRMT_H +#ifndef _RPC_PMAP_RMT_H +#define _RPC_PMAP_RMT_H #include <sys/cdefs.h> struct rmtcallargs { @@ -60,4 +62,4 @@ extern bool_t xdr_rmtcall_args __P((XDR *, struct rmtcallargs *)); extern bool_t xdr_rmtcallres __P((XDR *, struct rmtcallres *)); __END_DECLS -#endif /* !_RPC_PMAPRMT_H */ +#endif /* !_RPC_PMAP_RMT_H */ diff --git a/include/rpc/raw.h b/include/rpc/raw.h new file mode 100644 index 000000000000..0fea4ad087a2 --- /dev/null +++ b/include/rpc/raw.h @@ -0,0 +1,58 @@ +/* $NetBSD: raw.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +#ifndef _RPC_RAW_H +#define _RPC_RAW_H + +/* from: @(#)raw.h 1.11 94/04/25 SMI */ +/* from: @(#)raw.h 1.2 88/10/25 SMI */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * raw.h + * + * Raw interface + * The common memory area over which they will communicate + */ +extern char *__rpc_rawcombuf; + +#ifdef __cplusplus +} +#endif + +#endif /* _RPC_RAW_H */ diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h index 7fd4a7f85906..8a45c4928096 100644 --- a/include/rpc/rpc.h +++ b/include/rpc/rpc.h @@ -1,3 +1,5 @@ +/* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -41,6 +43,7 @@ #define _RPC_RPC_H #include <rpc/types.h> /* some typedefs */ +#include <sys/socket.h> #include <netinet/in.h> /* external data representation interfaces */ @@ -65,30 +68,40 @@ #include <rpc/svc.h> /* service manager and multiplexer */ #include <rpc/svc_auth.h> /* service side authenticator */ -/* - * COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON - * A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will - * already have the structures defined by <rpc/netdb.h> included in <netdb.h>. - */ -/* routines for parsing /etc/rpc */ +/* Portmapper client, server, and protocol headers */ +#include <rpc/pmap_clnt.h> +#include <rpc/pmap_prot.h> -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; +#include <rpc/rpcb_clnt.h> /* rpcbind interface functions */ -__BEGIN_DECLS -extern struct rpcent *getrpcbyname __P((char *)); -extern struct rpcent *getrpcbynumber __P((int)); -extern struct rpcent *getrpcent __P((void)); -extern int getrpcport __P((char *host, int prognum, int versnum, int proto)); -extern void setrpcent __P((int)); -extern void endrpcent __P((void)); +#include <rpc/rpcent.h> +__BEGIN_DECLS +extern int get_myaddress __P((struct sockaddr_in *)); extern int bindresvport __P((int, struct sockaddr_in *)); +extern int registerrpc __P((int, int, int, char *(*) __P((char [UDPMSGSIZE])), + xdrproc_t, xdrproc_t)); +extern int callrpc __P((char *, int, int, int, xdrproc_t, char *, + xdrproc_t , char *)); +extern int getrpcport __P((char *, int, int, int)); + +char *taddr2uaddr __P((const struct netconfig *, const struct netbuf *)); +struct netbuf *uaddr2taddr __P((const struct netconfig *, const char *)); + +struct sockaddr; extern int bindresvport_sa __P((int, struct sockaddr *)); -extern int get_myaddress __P((struct sockaddr_in *)); +__END_DECLS + +/* + * The following are not exported interfaces, they are for internal library + * and rpcbind use only. Do not use, they may change without notice. + */ +__BEGIN_DECLS +int __rpc_nconf2fd __P((const struct netconfig *)); +int __rpc_nconf2sockinfo __P((const struct netconfig *, + struct __rpc_sockinfo *)); +int __rpc_fd2sockinfo __P((int, struct __rpc_sockinfo *)); +u_int __rpc_get_t_size __P((int, int, int)); __END_DECLS #endif /* !_RPC_RPC_H */ diff --git a/include/rpc/rpc_com.h b/include/rpc/rpc_com.h index 2cf5995d2d70..8add5d4c6a03 100644 --- a/include/rpc/rpc_com.h +++ b/include/rpc/rpc_com.h @@ -1,3 +1,6 @@ +/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ +/* $FreeBSD$ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -39,40 +42,42 @@ #ifndef _RPC_RPCCOM_H #define _RPC_RPCCOM_H -/* From: #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ +#include <sys/cdefs.h> -#ifdef __cplusplus -extern "C" { -#endif +/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ /* - * File descriptor to be used on xxx_create calls to get default descriptor - */ -#define RPC_ANYSOCK -1 -#define RPC_ANYFD RPC_ANYSOCK -/* * The max size of the transport, if the size cannot be determined * by other means. */ #define RPC_MAXDATASIZE 9000 #define RPC_MAXADDRSIZE 1024 -#if defined(__STDC__) || defined(__cplusplus) -extern u_int __rpc_get_t_size (int, long); -extern u_int __rpc_get_a_size (long); -extern int __rpc_dtbsize (void); -extern int _rpc_dtablesize (void); -extern int _rpc_get_default_domain(char **); -#else -extern u_int __rpc_get_t_size (); -extern u_int __rpc_get_a_size (); -extern int __rpc_dtbsize (); -extern int _rpc_dtablesize (); -extern int _rpc_get_default_domain(); -#endif +#define __RPC_GETXID(now) ((u_int32_t)getpid() ^ (u_int32_t)(now)->tv_sec ^ \ + (u_int32_t)(now)->tv_usec) + +__BEGIN_DECLS +extern u_int __rpc_get_a_size __P((int)); +extern int __rpc_dtbsize __P((void)); +extern struct netconfig * __rpcgettp __P((int)); +extern int __rpc_get_default_domain __P((char **)); + +char *__rpc_taddr2uaddr_af __P((int, const struct netbuf *)); +struct netbuf *__rpc_uaddr2taddr_af __P((int, const char *)); +int __rpc_fixup_addr __P((struct netbuf *, const struct netbuf *)); +int __rpc_sockinfo2netid __P((struct __rpc_sockinfo *, const char **)); +int __rpc_seman2socktype __P((int)); +int __rpc_socktype2seman __P((int)); +void *rpc_nullproc __P((CLIENT *)); +int __rpc_sockisbound __P((int)); + +struct netbuf *__rpcb_findaddr __P((rpcprog_t, rpcvers_t, + const struct netconfig *, + const char *, CLIENT **)); +bool_t __rpc_control __P((int,void *)); + +char *_get_next_token __P((char *, int)); -#ifdef __cplusplus -} -#endif +__END_DECLS #endif /* _RPC_RPCCOM_H */ diff --git a/include/rpc/rpc_msg.h b/include/rpc/rpc_msg.h index 98f0f79aa881..ed634a180250 100644 --- a/include/rpc/rpc_msg.h +++ b/include/rpc/rpc_msg.h @@ -1,3 +1,5 @@ +/* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -38,10 +40,10 @@ * Copyright (C) 1984, Sun Microsystems, Inc. */ -#ifndef _RPC_RPCMSG_H -#define _RPC_RPCMSG_H +#ifndef _RPC_RPC_MSG_H +#define _RPC_RPC_MSG_H -#define RPC_MSG_VERSION ((u_long) 2) +#define RPC_MSG_VERSION ((u_int32_t) 2) #define RPC_SERVICE_PORT ((u_short) 2048) /* @@ -88,8 +90,8 @@ struct accepted_reply { enum accept_stat ar_stat; union { struct { - u_int32_t low; - u_int32_t high; + rpcvers_t low; + rpcvers_t high; } AR_versions; struct { caddr_t where; @@ -108,8 +110,8 @@ struct rejected_reply { enum reject_stat rj_stat; union { struct { - u_int32_t low; - u_int32_t high; + rpcvers_t low; + rpcvers_t high; } RJ_versions; enum auth_stat RJ_why; /* why authentication did not work */ } ru; @@ -134,10 +136,10 @@ struct reply_body { * Body of an rpc request call. */ struct call_body { - u_int32_t cb_rpcvers; /* must be equal to two */ - u_int32_t cb_prog; - u_int32_t cb_vers; - u_int32_t cb_proc; + rpcvers_t cb_rpcvers; /* must be equal to two */ + rpcprog_t cb_prog; + rpcvers_t cb_vers; + rpcproc_t cb_proc; struct opaque_auth cb_cred; struct opaque_auth cb_verf; /* protocol specific - provided by client */ }; @@ -183,14 +185,30 @@ extern bool_t xdr_callhdr __P((XDR *, struct rpc_msg *)); */ extern bool_t xdr_replymsg __P((XDR *, struct rpc_msg *)); + +/* + * XDR routine to handle a accepted rpc reply. + * xdr_accepted_reply(xdrs, rej) + * XDR *xdrs; + * struct accepted_reply *rej; + */ +extern bool_t xdr_accepted_reply __P((XDR *, struct accepted_reply *)); + +/* + * XDR routine to handle a rejected rpc reply. + * xdr_rejected_reply(xdrs, rej) + * XDR *xdrs; + * struct rejected_reply *rej; + */ +extern bool_t xdr_rejected_reply __P((XDR *, struct rejected_reply *)); + /* * Fills in the error part of a reply message. * _seterr_reply(msg, error) * struct rpc_msg *msg; * struct rpc_err *error; */ -struct rpc_err; extern void _seterr_reply __P((struct rpc_msg *, struct rpc_err *)); __END_DECLS -#endif /* !_RPC_RPCMSG_H */ +#endif /* !_RPC_RPC_MSG_H */ diff --git a/include/rpc/rpcb_clnt.h b/include/rpc/rpcb_clnt.h new file mode 100644 index 000000000000..0f081a47b0c3 --- /dev/null +++ b/include/rpc/rpcb_clnt.h @@ -0,0 +1,85 @@ +/* $NetBSD: rpcb_clnt.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpcb_clnt.h + * Supplies C routines to get to rpcbid services. + * + */ + +/* + * Usage: + * success = rpcb_set(program, version, nconf, address); + * success = rpcb_unset(program, version, nconf); + * success = rpcb_getaddr(program, version, nconf, host); + * head = rpcb_getmaps(nconf, host); + * clnt_stat = rpcb_rmtcall(nconf, host, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, addr_ptr) + * success = rpcb_gettime(host, timep) + * uaddr = rpcb_taddr2uaddr(nconf, taddr); + * taddr = rpcb_uaddr2uaddr(nconf, uaddr); + */ + +#ifndef _RPC_RPCB_CLNT_H +#define _RPC_RPCB_CLNT_H + +/* #pragma ident "@(#)rpcb_clnt.h 1.13 94/04/25 SMI" */ +/* rpcb_clnt.h 1.3 88/12/05 SMI */ + +#include <rpc/types.h> +#include <rpc/rpcb_prot.h> + +__BEGIN_DECLS +extern bool_t rpcb_set __P((const rpcprog_t, const rpcvers_t, + const struct netconfig *, const struct netbuf *)); +extern bool_t rpcb_unset __P((const rpcprog_t, const rpcvers_t, + const struct netconfig *)); +extern rpcblist *rpcb_getmaps __P((const struct netconfig *, const char *)); +extern enum clnt_stat rpcb_rmtcall __P((const struct netconfig *, + const char *, const rpcprog_t, + const rpcvers_t, const rpcproc_t, + const xdrproc_t, const caddr_t, + const xdrproc_t, const caddr_t, + const struct timeval, + const struct netbuf *)); +extern bool_t rpcb_getaddr __P((const rpcprog_t, const rpcvers_t, + const struct netconfig *, struct netbuf *, + const char *)); +extern bool_t rpcb_gettime __P((const char *, time_t *)); +extern char *rpcb_taddr2uaddr __P((struct netconfig *, struct netbuf *)); +extern struct netbuf *rpcb_uaddr2taddr __P((struct netconfig *, char *)); +__END_DECLS + +#endif /* !_RPC_RPCB_CLNT_H */ diff --git a/include/rpc/rpcb_prot.x b/include/rpc/rpcb_prot.x new file mode 100644 index 000000000000..b1ab096b40b0 --- /dev/null +++ b/include/rpc/rpcb_prot.x @@ -0,0 +1,554 @@ +%/* +% * $FreeBSD$ +% * +% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for +% * unrestricted use provided that this legend is included on all tape +% * media and as a part of the software program in whole or part. Users +% * may copy or modify Sun RPC without charge, but are not authorized +% * to license or distribute it to anyone else except as part of a product or +% * program developed by the user. +% * +% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE +% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR +% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. +% * +% * Sun RPC is provided with no support and without any obligation on the +% * part of Sun Microsystems, Inc. to assist in its use, correction, +% * modification or enhancement. +% * +% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE +% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC +% * OR ANY PART THEREOF. +% * +% * In no event will Sun Microsystems, Inc. be liable for any lost revenue +% * or profits or other special, indirect and consequential damages, even if +% * Sun has been advised of the possibility of such damages. +% * +% * Sun Microsystems, Inc. +% * 2550 Garcia Avenue +% * Mountain View, California 94043 +% */ +%/* +% * Copyright (c) 1988 by Sun Microsystems, Inc. +% */ + +%/* from rpcb_prot.x */ + +#ifdef RPC_HDR +% +%/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ +% +%#ifndef _KERNEL +% +#endif + +/* + * rpcb_prot.x + * rpcbind protocol, versions 3 and 4, in RPC Language + */ +% +%/* +% * The following procedures are supported by the protocol in version 3: +% * +% * RPCBPROC_NULL() returns () +% * takes nothing, returns nothing +% * +% * RPCBPROC_SET(rpcb) returns (bool_t) +% * TRUE is success, FALSE is failure. Registers the tuple +% * [prog, vers, address, owner, netid]. +% * Finds out owner and netid information on its own. +% * +% * RPCBPROC_UNSET(rpcb) returns (bool_t) +% * TRUE is success, FALSE is failure. Un-registers tuple +% * [prog, vers, netid]. addresses is ignored. +% * If netid is NULL, unregister all. +% * +% * RPCBPROC_GETADDR(rpcb) returns (string). +% * 0 is failure. Otherwise returns the universal address where the +% * triple [prog, vers, netid] is registered. Ignore address and owner. +% * +% * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) +% * used to dump the entire rpcbind maps +% * +% * RPCBPROC_CALLIT(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure is quiet; i.e. it does not return error information!!! +% * This routine only passes null authentication parameters. +% * It has no interface to xdr routines for RPCBPROC_CALLIT. +% * +% * RPCBPROC_GETTIME() returns (int). +% * Gets the remote machines time +% * +% * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) +% * Returns the netbuf address from universal address. +% * +% * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) +% * Returns the universal address from netbuf address. +% * +% * END OF RPCBIND VERSION 3 PROCEDURES +% */ +%/* +% * Except for RPCBPROC_CALLIT, the procedures above are carried over to +% * rpcbind version 4. Those below are added or modified for version 4. +% * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER +% * AS RPCBPROC_CALLIT. +% * +% * RPCBPROC_BCAST(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure IS quiet; i.e. it DOES NOT return error information!!! +% * This routine should be used for broadcasting and nothing else. +% * +% * RPCBPROC_GETVERSADDR(rpcb) returns (string). +% * 0 is failure. Otherwise returns the universal address where the +% * triple [prog, vers, netid] is registered. Ignore address and owner. +% * Same as RPCBPROC_GETADDR except that if the given version number +% * is not available, the address is not returned. +% * +% * RPCBPROC_INDIRECT(rpcb_rmtcallargs) +% * RETURNS (rpcb_rmtcallres); +% * Calls the procedure on the remote machine. If it is not registered, +% * this procedure is NOT quiet; i.e. it DOES return error information!!! +% * as any normal application would expect. +% * +% * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). +% * Same as RPCBPROC_GETADDR except that it returns a list of all the +% * addresses registered for the combination (prog, vers) (for all +% * transports). +% * +% * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) +% * Returns the statistics about the kind of requests received by rpcbind. +% */ +% +%/* +% * A mapping of (program, version, network ID) to address +% */ +struct rpcb { + rpcprog_t r_prog; /* program number */ + rpcvers_t r_vers; /* version number */ + string r_netid<>; /* network id */ + string r_addr<>; /* universal address */ + string r_owner<>; /* owner of this service */ +}; +#ifdef RPC_HDR +% +%typedef rpcb RPCB; +% +#endif +% +%/* +% * A list of mappings +% * +% * Below are two definitions for the rpcblist structure. This is done because +% * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a +% * struct rpcblist * that rpcgen would produce. One version of the rpcblist +% * structure (actually called rp__list) is used with rpcgen, and the other is +% * defined only in the header file for compatibility with the specified +% * interface. +% */ + +struct rp__list { + rpcb rpcb_map; + struct rp__list *rpcb_next; +}; + +typedef rp__list *rpcblist_ptr; /* results of RPCBPROC_DUMP */ + +#ifdef RPC_HDR +% +%typedef struct rp__list rpcblist; +%typedef struct rp__list RPCBLIST; +% +%#ifndef __cplusplus +%struct rpcblist { +% RPCB rpcb_map; +% struct rpcblist *rpcb_next; +%}; +%#endif +% +%#ifdef __cplusplus +%extern "C" { +%#endif +%extern bool_t xdr_rpcblist(XDR *, rpcblist**); +%#ifdef __cplusplus +%} +%#endif +% +#endif + +% +%/* +% * Arguments of remote calls +% */ +struct rpcb_rmtcallargs { + rpcprog_t prog; /* program number */ + rpcvers_t vers; /* version number */ + rpcproc_t proc; /* procedure number */ + opaque args<>; /* argument */ +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rpcb_rmtcallargs structure. +% * +% * The routine that XDRs the rpcb_rmtcallargs structure must deal with the +% * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to +% * be passed the XDR routine that knows the args' structure. This routine +% * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since +% * the application being called already knows the args structure. So we use a +% * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which +% * includes the args' XDR routine. +% */ +%struct r_rpcb_rmtcallargs { +% rpcprog_t prog; +% rpcvers_t vers; +% rpcproc_t proc; +% struct { +% u_int args_len; +% char *args_val; +% } args; +% xdrproc_t xdr_args; /* encodes args */ +%}; +% +#endif /* def RPC_HDR */ +% +%/* +% * Results of the remote call +% */ +struct rpcb_rmtcallres { + string addr<>; /* remote universal address */ + opaque results<>; /* result */ +}; +#ifdef RPC_HDR +% +%/* +% * Client-side only representation of rpcb_rmtcallres structure. +% */ +%struct r_rpcb_rmtcallres { +% char *addr; +% struct { +% u_int32_t results_len; +% char *results_val; +% } results; +% xdrproc_t xdr_res; /* decodes results */ +%}; +#endif RPC_HDR +% +%/* +% * rpcb_entry contains a merged address of a service on a particular +% * transport, plus associated netconfig information. A list of rpcb_entrys +% * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used +% * in r_nc_* fields. +% */ +struct rpcb_entry { + string r_maddr<>; /* merged address of service */ + string r_nc_netid<>; /* netid field */ + unsigned int r_nc_semantics; /* semantics of transport */ + string r_nc_protofmly<>; /* protocol family */ + string r_nc_proto<>; /* protocol name */ +}; +% +%/* +% * A list of addresses supported by a service. +% */ +struct rpcb_entry_list { + rpcb_entry rpcb_entry_map; + struct rpcb_entry_list *rpcb_entry_next; +}; + +typedef rpcb_entry_list *rpcb_entry_list_ptr; + +% +%/* +% * rpcbind statistics +% */ +% +const rpcb_highproc_2 = RPCBPROC_CALLIT; +const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR; +const rpcb_highproc_4 = RPCBPROC_GETSTAT; + +const RPCBSTAT_HIGHPROC = 13; /* # of procs in rpcbind V4 plus one */ +const RPCBVERS_STAT = 3; /* provide only for rpcbind V2, V3 and V4 */ +const RPCBVERS_4_STAT = 2; +const RPCBVERS_3_STAT = 1; +const RPCBVERS_2_STAT = 0; +% +%/* Link list of all the stats about getport and getaddr */ +struct rpcbs_addrlist { + rpcprog_t prog; + rpcvers_t vers; + int success; + int failure; + string netid<>; + struct rpcbs_addrlist *next; +}; +% +%/* Link list of all the stats about rmtcall */ +struct rpcbs_rmtcalllist { + rpcprog_t prog; + rpcvers_t vers; + rpcproc_t proc; + int success; + int failure; + int indirect; /* whether callit or indirect */ + string netid<>; + struct rpcbs_rmtcalllist *next; +}; + +typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; +typedef rpcbs_addrlist *rpcbs_addrlist_ptr; +typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; + +struct rpcb_stat { + rpcbs_proc info; + int setinfo; + int unsetinfo; + rpcbs_addrlist_ptr addrinfo; + rpcbs_rmtcalllist_ptr rmtinfo; +}; +% +%/* +% * One rpcb_stat structure is returned for each version of rpcbind +% * being monitored. +% */ + +typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; + +#ifdef RPC_HDR +% +%/* +% * We don't define netbuf in RPCL, since it would contain structure member +% * names that would conflict with the definition of struct netbuf in +% * <tiuser.h>. Instead we merely declare the XDR routine xdr_netbuf() here, +% * and implement it ourselves in rpc/rpcb_prot.c. +% */ +%#ifdef __cplusplus +%extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); +% +%#else __STDC__ +%extern bool_t xdr_netbuf(XDR *, struct netbuf *); +% +%#endif +#endif /* def RPC_HDR */ + +/* + * rpcbind procedures + */ +program RPCBPROG { + version RPCBVERS { + bool + RPCBPROC_SET(rpcb) = 1; + + bool + RPCBPROC_UNSET(rpcb) = 2; + + string + RPCBPROC_GETADDR(rpcb) = 3; + + rpcblist_ptr + RPCBPROC_DUMP(void) = 4; + + rpcb_rmtcallres + RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5; + + unsigned int + RPCBPROC_GETTIME(void) = 6; + + struct netbuf + RPCBPROC_UADDR2TADDR(string) = 7; + + string + RPCBPROC_TADDR2UADDR(struct netbuf) = 8; + } = 3; + + version RPCBVERS4 { + bool + RPCBPROC_SET(rpcb) = 1; + + bool + RPCBPROC_UNSET(rpcb) = 2; + + string + RPCBPROC_GETADDR(rpcb) = 3; + + rpcblist_ptr + RPCBPROC_DUMP(void) = 4; + + /* + * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT; + * the new name is intended to indicate that this + * procedure should be used for broadcast RPC, and + * RPCBPROC_INDIRECT should be used for indirect calls. + */ + rpcb_rmtcallres + RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT; + + unsigned int + RPCBPROC_GETTIME(void) = 6; + + struct netbuf + RPCBPROC_UADDR2TADDR(string) = 7; + + string + RPCBPROC_TADDR2UADDR(struct netbuf) = 8; + + string + RPCBPROC_GETVERSADDR(rpcb) = 9; + + rpcb_rmtcallres + RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10; + + rpcb_entry_list_ptr + RPCBPROC_GETADDRLIST(rpcb) = 11; + + rpcb_stat_byvers + RPCBPROC_GETSTAT(void) = 12; + } = 4; +} = 100000; +#ifdef RPC_HDR +% +%#define RPCBVERS_3 RPCBVERS +%#define RPCBVERS_4 RPCBVERS4 +% +%#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" +% +%#else /* ndef _KERNEL */ +%#ifdef __cplusplus +%extern "C" { +%#endif +% +%/* +% * A mapping of (program, version, network ID) to address +% */ +%struct rpcb { +% rpcprog_t r_prog; /* program number */ +% rpcvers_t r_vers; /* version number */ +% char *r_netid; /* network id */ +% char *r_addr; /* universal address */ +% char *r_owner; /* owner of the mapping */ +%}; +%typedef struct rpcb RPCB; +% +%/* +% * A list of mappings +% */ +%struct rpcblist { +% RPCB rpcb_map; +% struct rpcblist *rpcb_next; +%}; +%typedef struct rpcblist RPCBLIST; +%typedef struct rpcblist *rpcblist_ptr; +% +%/* +% * Remote calls arguments +% */ +%struct rpcb_rmtcallargs { +% rpcprog_t prog; /* program number */ +% rpcvers_t vers; /* version number */ +% rpcproc_t proc; /* procedure number */ +% u_int32_t arglen; /* arg len */ +% caddr_t args_ptr; /* argument */ +% xdrproc_t xdr_args; /* XDR routine for argument */ +%}; +%typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; +% +%/* +% * Remote calls results +% */ +%struct rpcb_rmtcallres { +% char *addr_ptr; /* remote universal address */ +% u_int32_t resultslen; /* results length */ +% caddr_t results_ptr; /* results */ +% xdrproc_t xdr_results; /* XDR routine for result */ +%}; +%typedef struct rpcb_rmtcallres rpcb_rmtcallres; +% +%struct rpcb_entry { +% char *r_maddr; +% char *r_nc_netid; +% unsigned int r_nc_semantics; +% char *r_nc_protofmly; +% char *r_nc_proto; +%}; +%typedef struct rpcb_entry rpcb_entry; +% +%/* +% * A list of addresses supported by a service. +% */ +% +%struct rpcb_entry_list { +% rpcb_entry rpcb_entry_map; +% struct rpcb_entry_list *rpcb_entry_next; +%}; +%typedef struct rpcb_entry_list rpcb_entry_list; +% +%typedef rpcb_entry_list *rpcb_entry_list_ptr; +% +%/* +% * rpcbind statistics +% */ +% +%#define rpcb_highproc_2 RPCBPROC_CALLIT +%#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR +%#define rpcb_highproc_4 RPCBPROC_GETSTAT +%#define RPCBSTAT_HIGHPROC 13 +%#define RPCBVERS_STAT 3 +%#define RPCBVERS_4_STAT 2 +%#define RPCBVERS_3_STAT 1 +%#define RPCBVERS_2_STAT 0 +% +%/* Link list of all the stats about getport and getaddr */ +% +%struct rpcbs_addrlist { +% rpcprog_t prog; +% rpcvers_t vers; +% int success; +% int failure; +% char *netid; +% struct rpcbs_addrlist *next; +%}; +%typedef struct rpcbs_addrlist rpcbs_addrlist; +% +%/* Link list of all the stats about rmtcall */ +% +%struct rpcbs_rmtcalllist { +% rpcprog_t prog; +% rpcvers_t vers; +% rpcproc_t proc; +% int success; +% int failure; +% int indirect; +% char *netid; +% struct rpcbs_rmtcalllist *next; +%}; +%typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; +% +%typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; +% +%typedef rpcbs_addrlist *rpcbs_addrlist_ptr; +% +%typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; +% +%struct rpcb_stat { +% rpcbs_proc info; +% int setinfo; +% int unsetinfo; +% rpcbs_addrlist_ptr addrinfo; +% rpcbs_rmtcalllist_ptr rmtinfo; +%}; +%typedef struct rpcb_stat rpcb_stat; +% +%/* +% * One rpcb_stat structure is returned for each version of rpcbind +% * being monitored. +% */ +% +%typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; +% +%#ifdef __cplusplus +%} +%#endif +% +%#endif /* ndef _KERNEL */ +#endif /* RPC_HDR */ diff --git a/include/rpc/rpcent.h b/include/rpc/rpcent.h new file mode 100644 index 000000000000..234002ac6a9c --- /dev/null +++ b/include/rpc/rpcent.h @@ -0,0 +1,69 @@ +/* $NetBSD: rpcent.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpcent.h, + * For converting rpc program numbers to names etc. + * + */ + +#ifndef _RPC_RPCENT_H +#define _RPC_RPCENT_H + +/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ +/* @(#)rpcent.h 1.1 88/12/06 SMI */ + + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +__BEGIN_DECLS +extern struct rpcent *getrpcbyname_r __P((const char *, struct rpcent *, + char *, int)); +extern struct rpcent *getrpcbynumber_r __P((int, struct rpcent *, char *, int)); +extern struct rpcent *getrpcent_r __P((struct rpcent *, char *, int)); + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +extern struct rpcent *getrpcbyname __P((char *)); +extern struct rpcent *getrpcbynumber __P((int)); +extern struct rpcent *getrpcent __P((void)); +extern void setrpcent __P((int)); +extern void endrpcent __P((void)); +__END_DECLS + +#endif /* !_RPC_CENT_H */ diff --git a/include/rpc/svc.h b/include/rpc/svc.h index 9ef76cfb22d9..dc03f5934f71 100644 --- a/include/rpc/svc.h +++ b/include/rpc/svc.h @@ -1,3 +1,5 @@ +/* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -26,15 +28,15 @@ * 2550 Garcia Avenue * Mountain View, California 94043 * - * from: @(#)svc.h 1.20 88/02/08 SMI - * from: @(#)svc.h 2.2 88/07/29 4.0 RPCSRC + * from: @(#)svc.h 1.35 88/12/17 SMI + * from: @(#)svc.h 1.27 94/04/25 SMI * $FreeBSD$ */ /* * svc.h, Server-side remote procedure call interface. * - * Copyright (C) 1984, Sun Microsystems, Inc. + * Copyright (C) 1986-1993 by Sun Microsystems, Inc. */ #ifndef _RPC_SVC_H @@ -63,21 +65,26 @@ * parameters, struct svc_req * and SVCXPRT *, defined below. */ +/* + * Service control requests + */ +#define SVCGET_VERSQUIET 1 +#define SVCSET_VERSQUIET 2 + + enum xprt_stat { XPRT_DIED, XPRT_MOREREQS, XPRT_IDLE }; -struct rpc_msg; - /* * Server side transport handle */ typedef struct __rpc_svcxprt { - int xp_sock; + int xp_fd; u_short xp_port; /* associated port number */ - struct xp_ops { + const struct xp_ops { /* receive incoming requests */ bool_t (*xp_recv) __P((struct __rpc_svcxprt *, struct rpc_msg *)); @@ -96,16 +103,45 @@ typedef struct __rpc_svcxprt { void (*xp_destroy) __P((struct __rpc_svcxprt *)); } *xp_ops; int xp_addrlen; /* length of remote address */ - struct sockaddr_in xp_raddr; /* remote address */ + struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ + /* XXX - fvdl stick this here for ABI backward compat reasons */ + const struct xp_ops2 { + /* catch-all function */ + bool_t (*xp_control) __P((struct __rpc_svcxprt *, const u_int, + void *)); + } *xp_ops2; + char *xp_tp; /* transport provider device name */ + char *xp_netid; /* network token */ + struct netbuf xp_ltaddr; /* local transport address */ + struct netbuf xp_rtaddr; /* remote transport address */ struct opaque_auth xp_verf; /* raw response verifier */ - caddr_t xp_p1; /* private */ - caddr_t xp_p2; /* private */ + void *xp_p1; /* private: for use by svc ops */ + void *xp_p2; /* private: for use by svc ops */ + void *xp_p3; /* private: for use by svc lib */ + int xp_type; /* transport type */ } SVCXPRT; /* + * Service request + */ +struct svc_req { + u_int32_t rq_prog; /* service program number */ + u_int32_t rq_vers; /* service protocol version */ + u_int32_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + void *rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + +/* * Approved way of getting address of caller */ -#define svc_getcaller(x) (&(x)->xp_raddr) +#define svc_getrpccaller(x) (&(x)->xp_rtaddr) + +/* + * FreeBSD-only definition to get the creds of the caller (AF_LOCAL). + */ +#define __svc_getcallercreds(x) ((struct cmsgcred *)(x)->xp_p2) /* * Operations defined on an SVCXPRT handle @@ -145,44 +181,36 @@ typedef struct __rpc_svcxprt { #define svc_destroy(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) - -/* - * Service request - */ -struct svc_req { - u_int32_t rq_prog; /* service program number */ - u_int32_t rq_vers; /* service protocol version */ - u_int32_t rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - caddr_t rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ -}; - +#define SVC_CONTROL(xprt, rq, in) \ + (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) /* * Service registration * - * svc_register(xprt, prog, vers, dispatch, protocol) - * SVCXPRT *xprt; - * u_long prog; - * u_long vers; - * void (*dispatch)(); - * int protocol; (like TCP or UDP, zero means do not register) + * svc_reg(xprt, prog, vers, dispatch, nconf) + * const SVCXPRT *xprt; + * const rpcprog_t prog; + * const rpcvers_t vers; + * const void (*dispatch)(); + * const struct netconfig *nconf; */ + __BEGIN_DECLS -extern bool_t svc_register __P((SVCXPRT *, u_long, u_long, - void (*) __P((struct svc_req *, SVCXPRT *)), int)); +extern bool_t svc_reg __P((SVCXPRT *, const rpcprog_t, const rpcvers_t, + void (*) __P((struct svc_req *, SVCXPRT *)), + const struct netconfig *)); __END_DECLS /* * Service un-registration * - * svc_unregister(prog, vers) - * u_long prog; - * u_long vers; + * svc_unreg(prog, vers) + * const rpcprog_t prog; + * const rpcvers_t vers; */ + __BEGIN_DECLS -extern void svc_unregister __P((u_long, u_long)); +extern void svc_unreg __P((const rpcprog_t, const rpcvers_t)); __END_DECLS /* @@ -206,8 +234,6 @@ extern void xprt_unregister __P((SVCXPRT *)); __END_DECLS - - /* * When the service routine is called, it must first check to see if it * knows about the procedure; if not, it should call svcerr_noproc @@ -239,10 +265,13 @@ extern bool_t svc_sendreply __P((SVCXPRT *, xdrproc_t, char *)); extern void svcerr_decode __P((SVCXPRT *)); extern void svcerr_weakauth __P((SVCXPRT *)); extern void svcerr_noproc __P((SVCXPRT *)); -extern void svcerr_progvers __P((SVCXPRT *, u_long, u_long)); +extern void svcerr_progvers __P((SVCXPRT *, rpcvers_t, rpcvers_t)); extern void svcerr_auth __P((SVCXPRT *, enum auth_stat)); extern void svcerr_noprog __P((SVCXPRT *)); extern void svcerr_systemerr __P((SVCXPRT *)); +extern int rpc_reg __P((rpcprog_t, rpcvers_t, rpcproc_t, + char *(*) __P((char *)), xdrproc_t, xdrproc_t, + char *)); __END_DECLS /* @@ -261,64 +290,130 @@ __END_DECLS * dynamic; must be inspected before each call to select */ extern int svc_maxfd; +#ifdef FD_SETSIZE extern fd_set svc_fdset; #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ +#else +extern int svc_fds; +#endif /* def FD_SETSIZE */ -#ifndef _KERNEL /* * a small program implemented by the svc_rpc implementation itself; * also see clnt.h for protocol numbers. */ -extern void rpctest_service(); -#endif +__BEGIN_DECLS +extern void rpctest_service __P((void)); +__END_DECLS __BEGIN_DECLS extern void svc_getreq __P((int)); extern void svc_getreqset __P((fd_set *)); -extern void svc_getreqset2 __P((fd_set *, int)); /* XXX: nonstd, undoc */ +extern void svc_getreq_common __P((int)); +struct pollfd; +extern void svc_getreq_poll __P((struct pollfd *, int)); + extern void svc_run __P((void)); +extern void svc_exit __P((void)); __END_DECLS /* * Socket to use on svcxxx_create call to get default socket */ #define RPC_ANYSOCK -1 +#define RPC_ANYFD RPC_ANYSOCK /* * These are the existing service side transport implementations */ +__BEGIN_DECLS /* - * Memory based rpc for testing and timing. + * Transport independent svc_create routine. + */ +extern int svc_create __P((void (*) __P((struct svc_req *, SVCXPRT *)), + const rpcprog_t, const rpcvers_t, const char *)); +/* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const char *nettype; -- network type */ -__BEGIN_DECLS -extern SVCXPRT *svcraw_create __P((void)); -__END_DECLS /* - * Udp based rpc. + * Generic server creation routine. It takes a netconfig structure + * instead of a nettype. */ -__BEGIN_DECLS -extern SVCXPRT *svcudp_create __P((int)); -extern SVCXPRT *svcudp_bufcreate __P((int, u_int, u_int)); -__END_DECLS + +extern SVCXPRT *svc_tp_create __P((void (*) __P((struct svc_req *, SVCXPRT *)), + const rpcprog_t, const rpcvers_t, + const struct netconfig *)); + /* + * void (*dispatch)(); -- dispatch routine + * const rpcprog_t prognum; -- program number + * const rpcvers_t versnum; -- version number + * const struct netconfig *nconf; -- netconfig structure + */ /* - * Tcp based rpc. + * Generic TLI create routine + */ +extern SVCXPRT *svc_tli_create __P((const int, const struct netconfig *, + const struct t_bind *, const u_int, + const u_int)); +/* + * const int fd; -- connection end point + * const struct netconfig *nconf; -- netconfig structure for network + * const struct t_bind *bindaddr; -- local bind address + * const u_int sendsz; -- max sendsize + * const u_int recvsz; -- max recvsize */ -__BEGIN_DECLS -extern SVCXPRT *svctcp_create __P((int, u_int, u_int)); -extern SVCXPRT *svcfd_create __P((int, u_int, u_int)); -__END_DECLS /* - * AF_UNIX socket based rpc. + * Connectionless and connectionful create routines */ -__BEGIN_DECLS -extern SVCXPRT *svcunix_create __P((int, u_int, u_int, char *)); -extern SVCXPRT *svcunixfd_create __P((int, u_int, u_int)); + +extern SVCXPRT *svc_vc_create __P((const int, const u_int, const u_int)); +/* + * const int fd; -- open connection end point + * const u_int sendsize; -- max send size + * const u_int recvsize; -- max recv size + */ + +extern SVCXPRT *svc_dg_create __P((const int, const u_int, const u_int)); + /* + * const int fd; -- open connection + * const u_int sendsize; -- max send size + * const u_int recvsize; -- max recv size + */ + + +/* + * the routine takes any *open* connection + * descriptor as its first input and is used for open connections. + */ +extern SVCXPRT *svc_fd_create __P((const int, const u_int, const u_int)); +/* + * const int fd; -- open connection end point + * const u_int sendsize; -- max send size + * const u_int recvsize; -- max recv size + */ + +/* + * Memory based rpc (for speed check and testing) + */ +extern SVCXPRT *svc_raw_create __P((void)); + +/* + * svc_dg_enable_cache() enables the cache on dg transports. + */ +int svc_dg_enablecache __P((SVCXPRT *, const u_int)); + __END_DECLS + +/* for backward compatibility */ +#include <rpc/svc_soc.h> + #endif /* !_RPC_SVC_H */ diff --git a/include/rpc/svc_auth.h b/include/rpc/svc_auth.h index 536d6a6481c6..8f55339968e2 100644 --- a/include/rpc/svc_auth.h +++ b/include/rpc/svc_auth.h @@ -1,3 +1,5 @@ +/* $NetBSD: svc_auth.h,v 1.8 2000/06/02 22:57:57 fvdl Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -27,7 +29,7 @@ * Mountain View, California 94043 * * from: @(#)svc_auth.h 1.6 86/07/16 SMI - * from: @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC + * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC * $FreeBSD$ */ @@ -37,20 +39,17 @@ * Copyright (C) 1984, Sun Microsystems, Inc. */ -#ifndef _RPC_SVCAUTH_H -#define _RPC_SVCAUTH_H - -struct rpc_msg; -struct svc_req; +#ifndef _RPC_SVC_AUTH_H +#define _RPC_SVC_AUTH_H /* * Server side authenticator */ __BEGIN_DECLS extern enum auth_stat _authenticate __P((struct svc_req *, struct rpc_msg *)); -extern int svc_auth_reg __P((int, enum auth_stat (*)(struct svc_req *, - struct rpc_msg *))); -extern enum auth_stat _svcauth_des __P((struct svc_req *, struct rpc_msg *)); +extern int svc_auth_reg __P((int, enum auth_stat (*) __P((struct svc_req *, + struct rpc_msg *)))); + __END_DECLS -#endif /* !_RPC_SVCAUTH_H */ +#endif /* !_RPC_SVC_AUTH_H */ diff --git a/include/rpc/svc_dg.h b/include/rpc/svc_dg.h new file mode 100644 index 000000000000..3514745d2efd --- /dev/null +++ b/include/rpc/svc_dg.h @@ -0,0 +1,51 @@ +/* $NetBSD: svc_dg.h,v 1.1 2000/06/02 23:11:16 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * XXX - this file exists only so that the rpcbind code can pull it in. + * This should go away. It should only be include by svc_dg.c and + * rpcb_svc_com.c in the rpcbind code. + */ + +/* + * kept in xprt->xp_p2 + */ +struct svc_dg_data { + /* XXX: optbuf should be the first field, used by ti_opts.c code */ + size_t su_iosz; /* size of send.recv buffer */ + u_int32_t su_xid; /* transaction id */ + XDR su_xdrs; /* XDR handle */ + char su_verfbody[MAX_AUTH_BYTES]; /* verifier body */ + void *su_cache; /* cached data, NULL if none */ +}; + +#define __rpcb_get_dg_xidp(x) (&((struct svc_dg_data *)(x)->xp_p2)->su_xid) diff --git a/include/rpc/svc_soc.h b/include/rpc/svc_soc.h new file mode 100644 index 000000000000..c3d16fec6341 --- /dev/null +++ b/include/rpc/svc_soc.h @@ -0,0 +1,116 @@ +/* $NetBSD: svc_soc.h,v 1.1 2000/06/02 22:57:57 fvdl Exp $ */ +/* $FreeBSD$ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * svc.h, Server-side remote procedure call interface. + */ + +#ifndef _RPC_SVC_SOC_H +#define _RPC_SVC_SOC_H +#include <sys/cdefs.h> + +/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ +/* svc_soc.h 1.8 89/05/01 SMI */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC + */ + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * u_long prog; + * u_long vers; + * void (*dispatch)(); + * int protocol; like TCP or UDP, zero means do not register + */ +__BEGIN_DECLS +extern bool_t svc_register __P((SVCXPRT *, u_long, u_long, + void (*) __P((struct svc_req *, SVCXPRT *)), int)); +__END_DECLS + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * u_long prog; + * u_long vers; + */ +__BEGIN_DECLS +extern void svc_unregister __P((u_long, u_long)); +__END_DECLS + + +/* + * Memory based rpc for testing and timing. + */ +__BEGIN_DECLS +extern SVCXPRT *svcraw_create __P((void)); +__END_DECLS + + +/* + * Udp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcudp_create __P((int)); +extern SVCXPRT *svcudp_bufcreate __P((int, u_int, u_int)); +extern int svcudp_enablecache __P((SVCXPRT *, u_long)); +__END_DECLS + + +/* + * Tcp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svctcp_create __P((int, u_int, u_int)); +__END_DECLS + +/* + * Fd based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcfd_create __P((int, u_int, u_int)); +__END_DECLS + +#endif /* !_RPC_SVC_SOC_H */ diff --git a/include/rpc/types.h b/include/rpc/types.h index e2ceec5b3df7..4a5c6564b270 100644 --- a/include/rpc/types.h +++ b/include/rpc/types.h @@ -1,3 +1,5 @@ +/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -37,8 +39,18 @@ #ifndef _RPC_TYPES_H #define _RPC_TYPES_H -#define bool_t int32_t -#define enum_t int32_t +#include <sys/types.h> + +typedef int32_t bool_t; +typedef int32_t enum_t; + +typedef u_int32_t rpcprog_t; +typedef u_int32_t rpcvers_t; +typedef u_int32_t rpcproc_t; +typedef u_int32_t rpcprot_t; +typedef u_int32_t rpcport_t; +typedef int32_t rpc_inline_t; + #define __dontcare__ -1 #ifndef FALSE @@ -51,12 +63,46 @@ # define NULL 0 #endif -#define mem_alloc(bsize) malloc(bsize) +#define mem_alloc(bsize) calloc(1, bsize) #define mem_free(ptr, bsize) free(ptr) -#ifndef makedev /* ie, we haven't already included it */ -#include <sys/types.h> -#endif #include <sys/time.h> +#include <netconfig.h> + +/* + * The netbuf structure is defined here, because FreeBSD / NetBSD only use + * it inside the RPC code. It's in <xti.h> on SVR4, but it would be confusing + * to have an xti.h, since FreeBSD / NetBSD does not support XTI/TLI. + */ + +/* + * The netbuf structure is used for transport-independent address storage. + */ +struct netbuf { + unsigned int maxlen; + unsigned int len; + void *buf; +}; + +/* + * The format of the addres and options arguments of the XTI t_bind call. + * Only provided for compatibility, it should not be used. + */ + +struct t_bind { + struct netbuf addr; + unsigned int qlen; +}; + +/* + * Internal library and rpcbind use. This is not an exported interface, do + * not use. + */ +struct __rpc_sockinfo { + int si_af; + int si_proto; + int si_socktype; + int si_alen; +}; #endif /* !_RPC_TYPES_H */ diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h index 2ce9205422e6..90107ffc92ac 100644 --- a/include/rpc/xdr.h +++ b/include/rpc/xdr.h @@ -1,3 +1,5 @@ +/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -97,15 +99,15 @@ enum xdr_op { */ typedef struct __rpc_xdr { enum xdr_op x_op; /* operation; fast additional param */ - struct xdr_ops { + const struct xdr_ops { /* get a long from underlying stream */ bool_t (*x_getlong) __P((struct __rpc_xdr *, long *)); - /* put a long to underlying stream */ - bool_t (*x_putlong) __P((struct __rpc_xdr *, long *)); - /* get some bytes from underlying stream */ - bool_t (*x_getbytes) __P((struct __rpc_xdr *, caddr_t, u_int)); - /* put some bytes to underlying stream */ - bool_t (*x_putbytes) __P((struct __rpc_xdr *, caddr_t, u_int)); + /* put a long to " */ + bool_t (*x_putlong) __P((struct __rpc_xdr *, const long *)); + /* get some bytes from " */ + bool_t (*x_getbytes) __P((struct __rpc_xdr *, char *, u_int)); + /* put some bytes to " */ + bool_t (*x_putbytes) __P((struct __rpc_xdr *, const char *, u_int)); /* returns bytes off from beginning */ u_int (*x_getpostn) __P((struct __rpc_xdr *)); /* lets you reposition the stream */ @@ -114,10 +116,11 @@ typedef struct __rpc_xdr { int32_t *(*x_inline) __P((struct __rpc_xdr *, u_int)); /* free privates of this xdr_stream */ void (*x_destroy) __P((struct __rpc_xdr *)); + bool_t (*x_control) __P((struct __rpc_xdr *, int, void *)); } *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ + char * x_public; /* users' data */ + void * x_private; /* pointer to private data */ + char * x_base; /* private used for position info */ int x_handy; /* extra private word */ } XDR; @@ -128,22 +131,17 @@ typedef struct __rpc_xdr { * The opaque pointer generally points to a structure of the data type * to be decoded. If this pointer is 0, then the type routines should * allocate dynamic storage of the appropriate size and return it. - */ -#ifdef _KERNEL -typedef bool_t (*xdrproc_t) __P((XDR *, void *, u_int)); -#else -/* - * XXX can't actually prototype it, because some take two args!!! + * + * XXX can't actually prototype it, because some take three args!!! */ typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */)); -#endif /* * Operations defined on a XDR handle * * XDR *xdrs; * long *longp; - * caddr_t addr; + * char * addr; * u_int len; * u_int pos; */ @@ -157,6 +155,29 @@ typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */)); #define xdr_putlong(xdrs, longp) \ (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +static __inline int +xdr_getint32(XDR *xdrs, int32_t *ip) +{ + long l; + + if (!xdr_getlong(xdrs, &l)) + return (FALSE); + *ip = (int32_t)l; + return (TRUE); +} + +static __inline int +xdr_putint32(XDR *xdrs, int32_t *ip) +{ + long l; + + l = (long)*ip; + return xdr_putlong(xdrs, &l); +} + +#define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) +#define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) + #define XDR_GETBYTES(xdrs, addr, len) \ (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) #define xdr_getbytes(xdrs, addr, len) \ @@ -189,6 +210,21 @@ typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */)); if ((xdrs)->x_ops->x_destroy) \ (*(xdrs)->x_ops->x_destroy)(xdrs) +#define XDR_CONTROL(xdrs, req, op) \ + if ((xdrs)->x_ops->x_control) \ + (*(xdrs)->x_ops->x_control)(xdrs, req, op) +#define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) + +/* + * Solaris strips the '_t' from these types -- not sure why. + * But, let's be compatible. + */ +#define xdr_rpcvers(xdrs, versp) xdr_u_int32(xdrs, versp) +#define xdr_rpcprog(xdrs, progp) xdr_u_int32(xdrs, progp) +#define xdr_rpcproc(xdrs, procp) xdr_u_int32(xdrs, procp) +#define xdr_rpcprot(xdrs, protp) xdr_u_int32(xdrs, protp) +#define xdr_rpcport(xdrs, portp) xdr_u_int32(xdrs, portp) + /* * Support struct for discriminated unions. * You create an array of xdrdiscrim structures, terminated with @@ -220,8 +256,13 @@ struct xdr_discrim { * N.B. and frozen for all time: each data type here uses 4 bytes * of external representation. */ -#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) +#define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) + +#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) @@ -229,11 +270,11 @@ struct xdr_discrim { #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) #define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) /* * These are the "generic" xdr routines. @@ -256,19 +297,23 @@ extern bool_t xdr_bool __P((XDR *, bool_t *)); extern bool_t xdr_enum __P((XDR *, enum_t *)); extern bool_t xdr_array __P((XDR *, char **, u_int *, u_int, u_int, xdrproc_t)); extern bool_t xdr_bytes __P((XDR *, char **, u_int *, u_int)); -extern bool_t xdr_opaque __P((XDR *, caddr_t, u_int)); +extern bool_t xdr_opaque __P((XDR *, char *, u_int)); extern bool_t xdr_string __P((XDR *, char **, u_int)); -extern bool_t xdr_union __P((XDR *, enum_t *, char *, struct xdr_discrim *, xdrproc_t)); -extern unsigned long xdr_sizeof __P((xdrproc_t, void *)); +extern bool_t xdr_union __P((XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t)); extern bool_t xdr_char __P((XDR *, char *)); extern bool_t xdr_u_char __P((XDR *, u_char *)); extern bool_t xdr_vector __P((XDR *, char *, u_int, u_int, xdrproc_t)); extern bool_t xdr_float __P((XDR *, float *)); extern bool_t xdr_double __P((XDR *, double *)); -extern bool_t xdr_reference __P((XDR *, caddr_t *, u_int, xdrproc_t)); -extern bool_t xdr_pointer __P((XDR *, caddr_t *, u_int, xdrproc_t)); +extern bool_t xdr_quadruple __P((XDR *, long double *)); +extern bool_t xdr_reference __P((XDR *, char **, u_int, xdrproc_t)); +extern bool_t xdr_pointer __P((XDR *, char **, u_int, xdrproc_t)); extern bool_t xdr_wrapstring __P((XDR *, char **)); extern void xdr_free __P((xdrproc_t, char *)); +extern bool_t xdr_hyper __P((XDR *, quad_t *)); +extern bool_t xdr_u_hyper __P((XDR *, u_quad_t *)); +extern bool_t xdr_longlong_t __P((XDR *, quad_t *)); +extern bool_t xdr_u_longlong_t __P((XDR *, u_quad_t *)); __END_DECLS /* @@ -291,15 +336,15 @@ __BEGIN_DECLS /* XDR using memory buffers */ extern void xdrmem_create __P((XDR *, char *, u_int, enum xdr_op)); -#ifdef _STDIO_H_ /* XDR using stdio library */ +#ifdef _STDIO_H_ extern void xdrstdio_create __P((XDR *, FILE *, enum xdr_op)); #endif /* XDR pseudo records for tcp */ extern void xdrrec_create __P((XDR *, u_int, u_int, char *, - int (*) __P((caddr_t, caddr_t, int)), - int (*) __P((caddr_t, caddr_t, int)))); + int (*) __P((char *, char *, int)), + int (*) __P((char *, char *, int)))); /* make end of xdr record */ extern bool_t xdrrec_endofrecord __P((XDR *, int)); @@ -309,6 +354,7 @@ extern bool_t xdrrec_skiprecord __P((XDR *)); /* true if no more input */ extern bool_t xdrrec_eof __P((XDR *)); +extern u_int xdrrec_readbytes __P((XDR *, caddr_t, u_int)); __END_DECLS #endif /* !_RPC_XDR_H */ diff --git a/include/rpcsvc/key_prot.x b/include/rpcsvc/key_prot.x index ab3196cfc04c..d87f39ccb910 100644 --- a/include/rpcsvc/key_prot.x +++ b/include/rpcsvc/key_prot.x @@ -44,7 +44,7 @@ */ %/* From: #pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" */ -% +%/* $FreeBSD$ */ %/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ % %/* diff --git a/include/rpcsvc/nlm_prot.x b/include/rpcsvc/nlm_prot.x index 4c3ea7d8e8ec..ba0ccf33c6cf 100644 --- a/include/rpcsvc/nlm_prot.x +++ b/include/rpcsvc/nlm_prot.x @@ -1,6 +1,3 @@ -/* @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC */ -/* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */ - /* * Network lock manager protocol definition * Copyright (C) 1986 Sun Microsystems, Inc. @@ -12,9 +9,13 @@ %#define LM_MAXSTRLEN 1024 %#define MAXNAMELEN LM_MAXSTRLEN+1 #else +%#include <sys/cdefs.h> %#ifndef lint %static const char rcsid[] = % "$FreeBSD$"; +%/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/ +%/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ +%__RCSID("$NetBSD: nlm_prot.x,v 1.6 2000/06/07 14:30:15 bouyer Exp $"); %#endif /* not lint */ #endif @@ -77,20 +78,20 @@ struct nlm_lockargs { }; struct nlm_cancargs { - netobj cookie; + netobj cookie; bool block; bool exclusive; struct nlm_lock alock; }; struct nlm_testargs { - netobj cookie; + netobj cookie; bool exclusive; struct nlm_lock alock; }; struct nlm_unlockargs { - netobj cookie; + netobj cookie; struct nlm_lock alock; }; @@ -140,11 +141,127 @@ struct nlm_notify { long state; }; +#ifdef RPC_HDR +%/* definitions for NLM version 4 */ +#endif +enum nlm4_stats { + nlm4_granted = 0, + nlm4_denied = 1, + nlm4_denied_nolock = 2, + nlm4_blocked = 3, + nlm4_denied_grace_period = 4, + nlm4_deadlck = 5, + nlm4_rofs = 6, + nlm4_stale_fh = 7, + nlm4_fbig = 8, + nlm4_failed = 9 +}; + +struct nlm4_stat { + nlm4_stats stat; +}; + +struct nlm4_holder { + bool exclusive; + u_int32_t svid; + netobj oh; + u_int64_t l_offset; + u_int64_t l_len; +}; + +struct nlm4_lock { + string caller_name<MAXNAMELEN>; + netobj fh; + netobj oh; + u_int32_t svid; + u_int64_t l_offset; + u_int64_t l_len; +}; + +struct nlm4_share { + string caller_name<MAXNAMELEN>; + netobj fh; + netobj oh; + fsh_mode mode; + fsh_access access; +}; + +union nlm4_testrply switch (nlm4_stats stat) { + case nlm_denied: + struct nlm4_holder holder; + default: + void; +}; + +struct nlm4_testres { + netobj cookie; + nlm4_testrply stat; +}; + +struct nlm4_testargs { + netobj cookie; + bool exclusive; + struct nlm4_lock alock; +}; + +struct nlm4_res { + netobj cookie; + nlm4_stat stat; +}; + +struct nlm4_lockargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm4_lock alock; + bool reclaim; /* used for recovering locks */ + int state; /* specify local status monitor state */ +}; + +struct nlm4_cancargs { + netobj cookie; + bool block; + bool exclusive; + struct nlm4_lock alock; +}; + +struct nlm4_unlockargs { + netobj cookie; + struct nlm4_lock alock; +}; + +struct nlm4_shareargs { + netobj cookie; + nlm4_share share; + bool reclaim; +}; + +struct nlm4_shareres { + netobj cookie; + nlm4_stats stat; + int sequence; +}; + +/* + * argument for the procedure called by rpc.statd when a monitored host + * status change. + * XXX assumes LM_MAXSTRLEN == SM_MAXSTRLEN + */ +struct nlm_sm_status { + string mon_name<LM_MAXSTRLEN>; /* name of host */ + int state; /* new state */ + opaque priv[16]; /* private data */ +}; + /* * Over-the-wire protocol used between the network lock managers */ program NLM_PROG { + version NLM_SM { + void NLM_SM_NOTIFY(struct nlm_sm_status) = 1; + } = 0; + version NLM_VERS { nlm_testres NLM_TEST(struct nlm_testargs) = 1; @@ -180,5 +297,25 @@ program NLM_PROG { void NLM_FREE_ALL(nlm_notify) = 23; } = 3; + version NLM_VERS4 { + nlm4_testres NLM4_TEST(nlm4_testargs) = 1; + nlm4_res NLM4_LOCK(nlm4_lockargs) = 2; + nlm4_res NLM4_CANCEL(nlm4_cancargs) = 3; + nlm4_res NLM4_UNLOCK(nlm4_unlockargs) = 4; + nlm4_res NLM4_GRANTED(nlm4_testargs) = 5; + void NLM4_TEST_MSG(nlm4_testargs) = 6; + void NLM4_LOCK_MSG(nlm4_lockargs) = 7; + void NLM4_CANCEL_MSG(nlm4_cancargs) = 8; + void NLM4_UNLOCK_MSG(nlm4_unlockargs) = 9; + void NLM4_GRANTED_MSG(nlm4_testargs) = 10; + void NLM4_TEST_RES(nlm4_testres) = 11; + void NLM4_LOCK_RES(nlm4_res) = 12; + void NLM4_CANCEL_RES(nlm4_res) = 13; + void NLM4_UNLOCK_RES(nlm4_res) = 14; + void NLM4_GRANTED_RES(nlm4_res) = 15; + nlm4_shareres NLM4_SHARE(nlm4_shareargs) = 20; + nlm4_shareres NLM4_UNSHARE(nlm4_shareargs) = 21; + nlm4_res NLM4_NM_LOCK(nlm4_lockargs) = 22; + void NLM4_FREE_ALL(nlm_notify) = 23; + } = 4; } = 100021; - diff --git a/include/rpcsvc/sm_inter.x b/include/rpcsvc/sm_inter.x index f5bf54524110..6e1862bf9fc5 100644 --- a/include/rpcsvc/sm_inter.x +++ b/include/rpcsvc/sm_inter.x @@ -62,6 +62,7 @@ program SM_PROG { struct sm_stat SM_UNMON_ALL(struct my_id) = 4; void SM_SIMU_CRASH(void) = 5; + void SM_NOTIFY(struct stat_chge) = 6; } = 1; } = 100024; @@ -90,6 +91,10 @@ struct mon{ opaque priv[16]; /* private information to store at monitor for requesting process */ }; +struct stat_chge { + string mon_name<SM_MAXSTRLEN>; /* name of the site that had the state change */ + int state; +}; /* * state # of status monitor monitonically increases each time |