/*  DO NOT EDIT THIS FILE.

    It has been auto-edited by fixincludes from:

	"/usr/include/rpc/svc.h"

    This had to be done to correct non-standard usages in the
    original, manufacturer supplied header file.  */

/*
 * BEGIN_DESC
 * 
 *  File: 
 *      @(#)B.11.11_LR	common/rpc/svc.h		$Revision: $
 * 
 *  Purpose:
 *      Server-side remote procedure call interface.
 * 
 *  Classification:			Release to Release Consistency Req:
 *		<<please select one of the following:>>
 * 	kernel subsystem private		none
 * 	kernel private				none
 * 	kernel 3rd party private		limited source
 * 	public					binary & source
 * 
 *  BE header:  yes
 *
 *  Shipped:  yes
 *	/usr/include/rpc/svc.h
 *
 *  <<please delete the following note if this is a "public" header>>
 *  NOTE:
 *	This header file contains information specific to the internals
 *	of the HP-UX implementation.  The contents of this header file
 *	are subject to change without notice.  Such changes may affect
 *	source code, object code, or binary compatibility between
 *	releases of HP-UX.  Code which uses the symbols contained within
 *	this header file is inherently non-portable (even between HP-UX
 *	implementations).
 * 
 * END_DESC  
*/

/*
 * Copyright (c) 1986 - 1993 by Sun Microsystems, Inc.
 */

/*
 * svc.h, Server-side remote procedure call interface.
 *
 */

#ifndef _RPC_SVC_H
#define	_RPC_SVC_H

/* #pragma ident	"@(#)svc.h	1.30	94/01/18 SMI" */

/*	svc.h 1.35 88/12/17 SMI	*/
#ifdef _KERNEL
#include  <rpc/rpc_msg.h>
#include  <sys/tihdr.h>
#else
#include <rpc/rpc_com.h>
#include <rpc/rpc_msg.h>
#include <sys/tihdr.h>
#endif

/*
 * This interface must manage two items concerning remote procedure calling:
 *
 * 1) An arbitrary number of transport connections upon which rpc requests
 * are received. They are created and registered by routines in svc_generic.c,
 * svc_vc.c and svc_dg.c; they in turn call xprt_register and
 * xprt_unregister.
 *
 * 2) An arbitrary number of locally registered services.  Services are
 * described by the following four data: program number, version number,
 * "service dispatch" function, a transport handle, and a boolean that
 * indicates whether or not the exported program should be registered with a
 * local binder service;  if true the program's number and version and the
 * address from the transport handle are registered with the binder.
 * These data are registered with rpcbind via svc_reg().
 *
 * A service's dispatch function is called whenever an rpc request comes in
 * on a transport.  The request's program and version numbers must match
 * those of the registered service.  The dispatch function is passed two
 * parameters, struct svc_req * and SVCXPRT *, defined below.
 */


#ifdef __cplusplus
extern "C" {
#endif

/*
 *	Service control requests
 */
#define	SVCGET_VERSQUIET	1
#define	SVCSET_VERSQUIET	2


enum xprt_stat {
	XPRT_DIED,
	XPRT_MOREREQS,
	XPRT_IDLE
};

/*
 * Service request
 */
struct svc_req {
	u_long		rq_prog;	/* service program number */
	u_long		rq_vers;	/* service protocol version */
	u_long		rq_proc;	/* the desired procedure */
	struct opaque_auth rq_cred;	/* raw creds from the wire */
	caddr_t		rq_clntcred;	/* read only cooked cred */
	struct __svcxprt *rq_xprt;	/* associated transport */
};


#ifdef _KERNEL
struct dupreq {
#ifdef __LP64__
        u_long          dr_xid;
#else
	uint32_t	dr_xid;
#endif /* __LP64__ */
	u_long		dr_proc;
	u_long		dr_vers;
	u_long		dr_prog;
	struct netbuf	dr_addr;
	struct netbuf	dr_resp;
	int		dr_status;
	struct dupreq	*dr_next;
	struct dupreq	*dr_chain;
};

/*
 * states of requests for duplicate request caching
 */
#define	DUP_NEW			0x00	/* new entry */
#define	DUP_INPROGRESS		0x01	/* request already going */
#define	DUP_DONE		0x02	/* request done */
#define	DUP_DROP		0x03	/* request dropped */
#define	DUP_ERROR		0x04	/* error in dup req cache */
#endif

struct xp_ops {
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
#ifdef _KERNEL
		bool_t	(*xp_recv)(struct __svcxprt *, mblk_t *,
			struct rpc_msg *); /* receive incoming requests */
#else
		bool_t	(*xp_recv)(struct __svcxprt *, struct rpc_msg *);
			/* receive incoming requests */
#endif
		enum xprt_stat (*xp_stat)(struct __svcxprt *);
			/* get transport status */
		bool_t	(*xp_getargs)(struct __svcxprt *, xdrproc_t,
					caddr_t); /* get arguments */
		bool_t	(*xp_reply)(struct __svcxprt *,
				    struct rpc_msg *); /* send reply */
		bool_t	(*xp_freeargs)(struct __svcxprt *, xdrproc_t,
					caddr_t);
			/* free mem allocated for args */
		void	(*xp_destroy)(struct __svcxprt *);
			/* destroy this struct */
#ifdef _KERNEL
		int	(*xp_dup)(struct svc_req *, caddr_t, int,
				struct dupreq **); /* check for dup */
		void	(*xp_dupdone)(struct dupreq *, caddr_t, int, int);
			/* mark dup entry as completed */
		long *	(*xp_getres)(struct __svcxprt *, int);
			/* get pointer to response buffer */
		void	(*xp_freeres)(struct __svcxprt *);
			/* destroy pre-serialized response */
		void	(*xp_clone)(struct __svcxprt *,
			struct __svcxprt *, caddr_t);
			/* clone a master xprt */
		void	(*xp_clone_destroy)(struct __svcxprt *);
			/* destroy a master xprt */
#else
		bool_t	(*xp_control)(struct __svcxprt *, const u_int,
				void *); /* catch-all control function */
#endif
#else
#ifdef __cplusplus
		bool_t	(*xp_recv)(...); /* receive incoming requests */
#else
		bool_t	(*xp_recv)(); /* receive incoming requests */
#endif
#ifdef __cplusplus
		enum xprt_stat (*xp_stat)(...); /* get transport status */
#else
		enum xprt_stat (*xp_stat)(); /* get transport status */
#endif
#ifdef __cplusplus
		bool_t	(*xp_getargs)(...); /* get arguments */
#else
		bool_t	(*xp_getargs)(); /* get arguments */
#endif
#ifdef __cplusplus
		bool_t	(*xp_reply)(...); /* send reply */
#else
		bool_t	(*xp_reply)(); /* send reply */
#endif
#ifdef __cplusplus
		bool_t	(*xp_freeargs)(...); /* free mem allocated for args */
#else
		bool_t	(*xp_freeargs)(); /* free mem allocated for args */
#endif
#ifdef __cplusplus
		void	(*xp_destroy)(...); /* destroy this struct */
#else
		void	(*xp_destroy)(); /* destroy this struct */
#endif
#ifdef _KERNEL
#ifdef __cplusplus
		int	(*xp_dup)(...); /* check for dup */
#else
		int	(*xp_dup)(); /* check for dup */
#endif
#ifdef __cplusplus
		void	(*xp_dupdone)(...); /* mark dup entry as completed */
#else
		void	(*xp_dupdone)(); /* mark dup entry as completed */
#endif
#ifdef __cplusplus
		long *	(*xp_getres)(...);	/* get pointer to response buffer */
#else
		long *	(*xp_getres)();	/* get pointer to response buffer */
#endif
#ifdef __cplusplus
		void	(*xp_freeres)(...); /* destroy pre-serialized response */
#else
		void	(*xp_freeres)(); /* destroy pre-serialized response */
#endif
#ifdef __cplusplus
		void	(*xp_clone)(...);  /* clone a master xprt */
#else
		void	(*xp_clone)();  /* clone a master xprt */
#endif
#ifdef __cplusplus
		int	(*xp_clone_destroy)(...);  /* destroy a master xprt */
#else
		int	(*xp_clone_destroy)();  /* destroy a master xprt */
#endif
#else
#ifdef __cplusplus
		bool_t	(*xp_control)(...); /* catch-all control function */
#else
		bool_t	(*xp_control)(); /* catch-all control function */
#endif
#endif
#endif
};

/*
 * Server side transport handle
 * xprt->xp_req_lock governs the following fields in xprt:
 *		xp_req_head, xp_req_tail, xp_asleep, and xp_drowsy.
 * xprt->xp_thread_lock governs the following fields in xprt:
 *		xp_max_threads, xp_min_threads, xp_detached_threads,
 *		xp_threads, and xp_dead_cv.
 * xprt->xp_lock governs the rest of the fields in xprt, except for the
 * 		clone-only fields, which are not locked.
 *
 * The xp_threads count is the number of attached threads.  These threads
 * are able to handle new requests, and it is expected that they will not
 * block for a very long time handling a given request.  The
 * xp_detached_threads count is the number of threads that have detached
 * themselves from the transport.  These threads can block indefinitely
 * while handling a request.  Once they complete the request, they exit.
 * If the number of attached threads goes to zero, the transport can be
 * closed.  If the sum of attached and detached threads goes to zero, the
 * data structure for the transport can be freed.
 *
 * A kernel service provider may register a callback function "closeproc"
 * for a transport.  When the last attached thread exits (xp_threads goes
 * to zero in svc_thread_exit) it calls the callback function, passing it
 * a reference to the transport.  This call is made with xp_thread_lock
 * held, so any cleanup bookkeeping it does should be done quickly.
 */
#ifdef _KERNEL
#ifndef _HPONC_LOCK_H_
/*
 *  The definition of kmutex_t is private and should not be deferenced by the
 *  users of the mutex routines.  It should be treated as an opaque structure.
 *  [This is a copy of the definition in "../onc+sys/lock.h"]
 */
typedef struct kmutex {
	lock_t  *spin_lockp;
	int     lockp_type;
} kmutex_t;
#endif  /* _HPONC_LOCK_H_ */
#endif  /* _KERNEL */

typedef struct __svcxprt {
#ifdef _KERNEL
	char		* xp_fp;
	struct xp_ops   * xp_ops;
	char		*xp_wq;		/* queue to write onto */
	mblk_t		* xp_req_head;
	mblk_t		* xp_req_tail;
	kmutex_t	xp_req_lock;	/* Request lock */
	kcondvar_t	xp_req_cv;
	cred_t		* xp_cred;	/* cached cred for server to use */
	struct __svcxprt *xp_next;	/* list of available service handles */
	int32_t		xp_type;	/* transport type */
	int		xp_msg_size;	/* TSDU or TIDU size from transport */
	struct netbuf	xp_rtaddr;	/* remote transport address */
	kmutex_t	xp_lock;	/* xprt structure lock */
	int		xp_max_threads;	/* Maximum total number of threads */
	int		xp_min_threads;	/* Minimum num. of attached threads */
	int		xp_threads;	/* Current num. of attached threads */
	int		xp_detached_threads; /* num. of detached threads */
	kmutex_t	xp_thread_lock;	/* Thread count lock */
	int		xp_asleep; 	/* Current number of asleep threads */
	int		xp_drowsy; 	/* Current number of drowsy threads */
#if defined(__STDC__) || defined(_lint)
	void		(*xp_closeproc)(const struct __svcxprt *);
#else
#ifdef __cplusplus
	void		(*xp_closeproc)(...);
#else
	void		(*xp_closeproc)();
#endif
#endif /* __STDC__ || _lint */
					/* optional; see comments above */
	kcondvar_t	xp_dead_cv;	/* svc threads are all gone */

	/*
	 * The following fields are null for master xprt's.  They are filled
	 * in for clone xprt's.  Because a clone is used by only one
	 * thread, it is not necessary to lock these fields.
	 */
	struct __svcxprt *xp_master;	/* back ptr to master */
	bool_t		xp_detached;	/* is the clone's thread detached */

	/* The following fields are used on a per-request basis. */
	caddr_t		xp_p1;		/* private: for use by svc ops */
	caddr_t		xp_p2;		/* private: for use by svc ops */
	caddr_t		xp_p3;		/* private: for use by svc lib */
	struct opaque_auth xp_verf;	/* raw response verifier */
#ifdef __LP64__
        u_long          xp_xid;
#else
	uint32_t	xp_xid;		/* id */
#endif /* __LP64__ */
	XDR		xp_xdrin;	/* input xdr stream */
	XDR		xp_xdrout;	/* output xdr stream */

#else	/* KERNEL */
	int		xp_fd;
#define	xp_sock		xp_fd
	u_short		xp_port;
	/*
	 * associated port number.
	 * Obsoleted, but still used to
	 * specify whether rendezvouser
	 * or normal connection
	 */
	struct	xp_ops	*xp_ops;
	int		xp_addrlen;	 /* length of remote addr. Obsoleted */
	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 */
	char		xp_raddr[16];	 /* remote address. Now obsoleted */
	struct opaque_auth xp_verf;	 /* raw response verifier */
	caddr_t		xp_p1;		 /* private: for use by svc ops */
	caddr_t		xp_p2;		 /* private: for use by svc ops */
	caddr_t		xp_p3;		 /* private: for use by svc lib */
	int32_t		xp_type;	/* transport type */
#endif
} SVCXPRT;

#ifdef _KERNEL
/*  [JAGad13445 - make NFS Q4-visible] ... begin. */
/*
 *  ---- Moved structure definition from "rpc/svc.c" to here. ----
 */

struct svc_callout {
        struct svc_callout *sc_next;
        u_long              sc_prog;
        u_long              sc_vers;
        void                (*sc_dispatch)(struct svc_req *, SVCXPRT *);
};

/*  [JAGad13445 - make NFS Q4-visible] ... end. */
#endif

#ifdef _KERNEL
/*
 * Maximum p1 and p2 buffer lengths for quick xprts.
 * These constants must
 * be changed if a new transport is added and requires more space.
 * Also note that these buffers are allocated on the stack and
 * shouldn't be very big.  A transport could dynamically allocate
 * a bigger structure on a per-call basis in its svc_x_clone routine
 * and free the memory in its svc_x_clone_destroy.
 */
#define	SVC_MAX_P1LEN   0
#define	SVC_MAX_P2LEN   32
#endif

/*
 *  Approved way of getting address of caller
 */
#define	svc_getrpccaller(x) (&(x)->xp_rtaddr)
#ifdef _KERNEL
#define	svc_getcaller(x) (&(x)->xp_rtaddr.buf)
#endif

/*
 * Operations defined on an SVCXPRT handle
 *
 * SVCXPRT		 *xprt;
 * struct rpc_msg	 *msg;
 * xdrproc_t		  xargs;
 * caddr_t		  argsp;
#ifdef _KERNEL
 * struct svc_req	 *req;
 * int			  size;
 * caddr_t		  res;
 * struct dupreq	**drpp;
 * struct dupreq	 *drp;
#endif
 */

#ifdef _KERNEL
#define	SVC_RECV(xprt, mp, msg)				\
	(*(xprt)->xp_ops->xp_recv)((xprt), (mp), (msg))
#define	svc_recv(xprt, mp, msg)				\
	(*(xprt)->xp_ops->xp_recv)((xprt), (mp), (msg))
#else
#define	SVC_RECV(xprt, msg)				\
	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
#define	svc_recv(xprt, msg)				\
	(*(xprt)->xp_ops->xp_recv)((xprt), (msg))
#endif

#define	SVC_STAT(xprt)					\
	(*(xprt)->xp_ops->xp_stat)(xprt)
#define	svc_stat(xprt)					\
	(*(xprt)->xp_ops->xp_stat)(xprt)

#define	SVC_GETARGS(xprt, xargs, argsp)			\
	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))
#define	svc_getargs(xprt, xargs, argsp)			\
	(*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp))

#define	SVC_REPLY(xprt, msg)				\
	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))
#define	svc_reply(xprt, msg)				\
	(*(xprt)->xp_ops->xp_reply) ((xprt), (msg))

#define	SVC_FREEARGS(xprt, xargs, argsp)		\
	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))
#define	svc_freeargs(xprt, xargs, argsp)		\
	(*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp))

#define	SVC_GETRES(xprt, size)		\
	(*(xprt)->xp_ops->xp_getres)((xprt), (size))
#define	svc_getres(xprt, size)		\
	(*(xprt)->xp_ops->xp_getres)((xprt), (size))

#define	SVC_FREERES(xprt)		\
	(*(xprt)->xp_ops->xp_freeres)(xprt)
#define	svc_freeres(xprt)		\
	(*(xprt)->xp_ops->xp_freeres)(xprt)

#define	SVC_DESTROY(xprt)				\
	(*(xprt)->xp_ops->xp_destroy)(xprt)
#define	svc_destroy(xprt)				\
	(*(xprt)->xp_ops->xp_destroy)(xprt)

#ifndef _KERNEL
#define	SVC_CONTROL(xprt, rq, in)				\
	(*(xprt)->xp_ops->xp_control)((xprt), (rq), (in))
#endif

#ifdef _KERNEL
#define	SVC_DUP(xprt, req, res, size, drpp)		\
	(*(xprt)->xp_ops->xp_dup)(req, res, size, drpp)
#define	svc_dup(xprt, req, res, size, drpp)		\
	(*(xprt)->xp_ops->xp_dup)(req, res, size, drpp)

#define	SVC_DUPDONE(xprt, dr, res, size, status)	\
	(*(xprt)->xp_ops->xp_dupdone)(dr, res, size, status)
#define	svc_dupdone(xprt, dr, res, size, status)	\
	(*(xprt)->xp_ops->xp_dupdone)(dr, res, size, status)

#define	SVC_CLONE(xprt, new_xprt, p2buf)	\
	(*(xprt)->xp_ops->xp_clone)(xprt, new_xprt, p2buf)
#define	svc_clone(xprt, dr, res, size, status)  \
	(*(xprt)->xp_ops->xp_clone)(dr, res, size, status)

#define	SVC_CLONE_DESTROY(xprt) \
		(*(xprt)->xp_ops->xp_clone_destroy)(xprt)
#define	svc_clone_destroy(xprt) \
		(*(xprt)->xp_ops->xp_clone_destroy)(xprt)
#endif

/*
 * Service registration
 *
 * svc_reg(xprt, prog, vers, dispatch, nconf)
 *	const SVCXPRT *xprt;
 *	const u_long prog;
 *	const u_long vers;
#ifdef __cplusplus
 *	const void (*dispatch)(...);
#else
 *	const void (*dispatch)();
#endif
 *	const struct netconfig *nconf;
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern bool_t	svc_reg(const SVCXPRT *, const u_long, const u_long,
			void (*)(struct svc_req *, SVCXPRT *),
			const struct netconfig *);
#else
extern bool_t	svc_reg();
#endif


/*
 * Service un-registration
 *
 * svc_unreg(prog, vers)
 *	const u_long prog;
 *	const u_long vers;
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern void	svc_unreg(const u_long, const u_long);
#else
extern void	svc_unreg();
#endif


/*
 * Transport registration.
 *
 * xprt_register(xprt)
 *	const SVCXPRT *xprt;
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern void	xprt_register(const SVCXPRT *);
#else
extern void	xprt_register();
#endif


/*
 * Transport un-register
 *
 * xprt_unregister(xprt)
 *	const SVCXPRT *xprt;
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern void	xprt_unregister(const SVCXPRT *);
#else
extern void	xprt_unregister();
#endif


/*
 * 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
 * and return.  If so, it should deserialize its arguments via
 * SVC_GETARGS (defined above).  If the deserialization does not work,
 * svcerr_decode should be called followed by a return.  Successful
 * decoding of the arguments should be followed the execution of the
 * procedure's code and a call to svc_sendreply.
 *
 * Also, if the service refuses to execute the procedure due to too-
 * weak authentication parameters, svcerr_weakauth should be called.
 * Note: do not confuse access-control failure with weak authentication!
 *
 * NB: In pure implementations of rpc, the caller always waits for a reply
 * msg.  This message is sent when svc_sendreply is called.
 * Therefore pure service implementations should always call
 * svc_sendreply even if the function logically returns void;  use
 * xdr.h - xdr_void for the xdr routine.  HOWEVER, connectionful rpc allows
 * for the abuse of pure rpc via batched calling or pipelining.  In the
 * case of a batched call, svc_sendreply should NOT be called since
 * this would send a return message, which is what batching tries to avoid.
 * It is the service/protocol writer's responsibility to know which calls are
 * batched and which are not.  Warning: responding to batch calls may
 * deadlock the caller and server processes!
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern bool_t	svc_sendreply(const SVCXPRT *, const xdrproc_t, const caddr_t);
extern void	svcerr_decode(const SVCXPRT *);
extern void	svcerr_weakauth(const SVCXPRT *);
extern void	svcerr_noproc(const SVCXPRT *);
extern void	svcerr_progvers(const SVCXPRT *, const u_long, const u_long);
extern void	svcerr_auth(const SVCXPRT *, const enum auth_stat);
extern void	svcerr_noprog(const SVCXPRT *);
extern void	svcerr_systemerr(const SVCXPRT *);
#else
extern bool_t	svc_sendreply();
extern void	svcerr_decode();
extern void	svcerr_weakauth();
extern void	svcerr_noproc();
extern void	svcerr_progvers();
extern void	svcerr_auth();
extern void	svcerr_noprog();
extern void	svcerr_systemerr();
#endif

/*
 * Lowest level dispatching -OR- who owns this process anyway.
 * Somebody has to wait for incoming requests and then call the correct
 * service routine.  The routine svc_run does infinite waiting; i.e.,
 * svc_run never returns.
 * Since another (co-existant) package may wish to selectively wait for
 * incoming calls or other events outside of the rpc architecture, the
 * routine svc_getreq is provided.  It must be passed readfds, the
 * "in-place" results of a select call (see select, section XXX).
 */

#ifndef _KERNEL
/*
 * Global keeper of rpc service descriptors in use
 * dynamic; must be inspected before each call to select
 */
extern fd_set svc_fdset;
#define	svc_fds ((int *)(void *)(svc_fdset.fds_bits))[0]   /* compatibility */
#endif /* _KERNEL */
/*
 * a small program implemented by the svc_rpc implementation itself;
 * also see clnt.h for protocol numbers.
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
#ifndef _KERNEL
extern void	svc_getreq(int);
extern void	svc_getreqset(fd_set *);	/* takes fdset instead of int */
extern void	svc_run(void);
#else
extern void svc_run __((struct __svcxprt *));
#endif

#else
#ifndef _KERNEL
extern void	rpctest_service();
extern void	svc_getreqset();
#endif
#endif


#ifndef _KERNEL
/*
 * These are the existing service side transport implementations
 */
/*
 * Transport independent svc_create routine.
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern  int svc_create(void (*)(struct svc_req *, SVCXPRT *),
const u_long, const u_long, const char *);
/*
#ifdef __cplusplus
 * 	void (*dispatch)(...);		-- dispatch routine
#else
 * 	void (*dispatch)();		-- dispatch routine
#endif
 *	const u_long prognum;			-- program number
 *	const u_long versnum;			-- version number
 *	const char *nettype;			-- network type
 */
#else
extern int svc_create();
#endif


/*
 * Generic server creation routine. It takes a netconfig structure
 * instead of a nettype.
 */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern  SVCXPRT	*svc_tp_create(void (*)(struct svc_req *, SVCXPRT *),
const u_long, const u_long, const struct netconfig *);
	/*
#ifdef __cplusplus
	 * void (*dispatch)(...);		-- dispatch routine
#else
	 * void (*dispatch)();		-- dispatch routine
#endif
	 * const u_long prognum;			-- program number
	 * const u_long versnum;			-- version number
	 * const struct netconfig *nconf;	-- netconfig structure
	 */
#else
extern SVCXPRT	*svc_tp_create();
#endif

/*
 * Generic TLI create routine
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern  SVCXPRT *svc_tli_create(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
 */
#else
extern SVCXPRT *svc_tli_create();
#endif


/*
 * Connectionless and connectionful create routines
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern  SVCXPRT	*svc_vc_create(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(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
	 */
#else
extern SVCXPRT	*svc_vc_create();
extern SVCXPRT	*svc_dg_create();
#endif

/*
 * the routine takes any *open* TLI file
 * descriptor as its first input and is used for open connections.
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern  SVCXPRT *svc_fd_create(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
 */
#else
extern SVCXPRT *svc_fd_create();
#endif

/*
 * Memory based rpc (for speed check and testing)
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern SVCXPRT *svc_raw_create(void);
#else
extern SVCXPRT *svc_raw_create();
#endif

/*
 * svc_dg_enable_cache() enables the cache on dg transports.
 */
#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
int svc_dg_enablecache(SVCXPRT *, const u_long);
#else
int svc_dg_enablecache();
#endif

#ifdef PORTMAP
/* For backward compatibility */
#include <rpc/svc_soc.h>
#endif

#else	/* _KERNEL */

/*
 * kernel based rpc
 */

#include <rpc/svc_soc.h>

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern int	svc_tli_kcreate(int , u_int, SVCXPRT **);
extern int	svc_clts_kcreate(  u_int, struct T_info_ack *,
			SVCXPRT **);
#else
extern int	svc_tli_kcreate();
extern int	svc_clts_kcreate();
#endif


#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
extern int	svc_cots_kcreate(void *, u_int, struct T_info_ack *,
			SVCXPRT **);
extern void	svc_queuereq(queue_t *q, mblk_t *mp);
extern void	svc_queueclose(queue_t *q);
#else
extern int	svc_cots_kcreate();
extern void	svc_queuereq();
extern void	svc_queueclose();
#endif

#endif /* !_KERNEL */

/*
 * For user level MT hot server functions
 */
#ifndef _KERNEL

/*
 * Different MT modes
 */
#define	RPC_SVC_MT_NONE		0	/* default, single-threaded */
#define	RPC_SVC_MT_AUTO		1	/* automatic MT mode */
#define	RPC_SVC_MT_USER		2	/* user MT mode */

#if defined(__STDC__) || defined(__cplusplus) || defined(_lint)
void svc_done(SVCXPRT *);
#else
void svc_done();
#endif

#endif /* !_KERNEL */

#ifdef __cplusplus
}
#endif

#ifdef _KERNEL
extern void svc_clts_kclone __((struct __svcxprt *, struct __svcxprt *, caddr_t));
extern void svc_clts_kclone_destroy __((struct __svcxprt *));
extern void svc_clts_kdestroy __((struct __svcxprt *));
extern int svc_clts_kdup __((struct svc_req *, caddr_t, int, struct dupreq **));
extern void svc_clts_kdupdone __((struct dupreq *, caddr_t, int, int));
extern int svc_clts_kfreeargs __((struct __svcxprt *, int (*)(struct XDR *, ...), caddr_t));
extern void svc_clts_kfreeres __((struct __svcxprt *));
extern int svc_clts_kgetargs __((struct __svcxprt *, int (*)(struct XDR *, ...), caddr_t));
extern long *svc_clts_kgetres __((struct __svcxprt *, int));
extern bool_t svc_clts_krecv __((struct __svcxprt *, struct msgb *, struct rpc_msg *));
extern int svc_clts_ksend __((struct __svcxprt *, struct rpc_msg *));
extern int svc_clts_kstat __((struct __svcxprt *));

/*
 * nfs module's data structures and macros.
 */
struct nfsd_xprt_table_entry
{
      SVCXPRT	*xprt;		/* Pointer to nfsd's xprt data structure */
      mblk_t	*req_head;	/* Per-spu request queue head */
      mblk_t	*req_tail;	/* Per-spu request queue tail */
      lock_t	*lock;		/* Per-spu lock.  Protects request queue. */
      long	asleep;		/* # of threads waiting for requests */
      long	req_count;	/* # of NFS requests in the queue */
      long	req_bytes;	/* total # of bytes of messages */
      queue_t	*wq;		/* nfsm modules's write-side queue */
      /*
       * Note:  I create per-spu queue and lock independent of xprt data
       * structures.  I first thoght that I can use of xprt.xp_req and
       * xprt.xp_req_lock for these, but it created a close race condition
       * (i.e. when nfsd terminates), which was hard to solve without
       * affecting performance (i.e. needed more spinlocks).  Unlike xprt
       * which needs to be destroyed when the last thread that uses it
       * terminates, nfsd_xprt_table will exist as long as the system is up.
       *
       * Also note that I made this cache-line aligned to minimize
       * false-sharing.
       */
};
typedef struct nfsd_xprt_table_entry	nfsd_xprt_table_entry_t;

struct nfsd
{
      int	myspu;
};

typedef struct nfsd	nfsd_t;

#define I_NFSD_INIT		0x20490001

extern nfsd_xprt_table_entry_t	*nfsd_xprt_table;

#endif /* _KERNEL */

#endif /* !_RPC_SVC_H */
