ncp_subr.h revision 55991
151852Sbp/*
251852Sbp * Copyright (c) 1999, Boris Popov
351852Sbp * All rights reserved.
451852Sbp *
551852Sbp * Redistribution and use in source and binary forms, with or without
651852Sbp * modification, are permitted provided that the following conditions
751852Sbp * are met:
851852Sbp * 1. Redistributions of source code must retain the above copyright
951852Sbp *    notice, this list of conditions and the following disclaimer.
1051852Sbp * 2. Redistributions in binary form must reproduce the above copyright
1151852Sbp *    notice, this list of conditions and the following disclaimer in the
1251852Sbp *    documentation and/or other materials provided with the distribution.
1351852Sbp * 3. All advertising materials mentioning features or use of this software
1451852Sbp *    must display the following acknowledgement:
1551852Sbp *    This product includes software developed by Boris Popov.
1651852Sbp * 4. Neither the name of the author nor the names of any co-contributors
1751852Sbp *    may be used to endorse or promote products derived from this software
1851852Sbp *    without specific prior written permission.
1951852Sbp *
2051852Sbp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2151852Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2251852Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2351852Sbp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2451852Sbp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2551852Sbp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2651852Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2751852Sbp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2851852Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2951852Sbp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3051852Sbp * SUCH DAMAGE.
3151852Sbp *
3251852Sbp * $FreeBSD: head/sys/netncp/ncp_subr.h 55991 2000-01-14 19:54:42Z bde $
3351852Sbp */
3454477Sbp#ifndef _NETNCP_NCP_SUBR_H_
3554477Sbp#define _NETNCP_NCP_SUBR_H_
3651852Sbp
3751852Sbp#define NCP_TIMER_TICK	2*hz	/* 1sec */
3851852Sbp#define	NCP_SIGMASK(set) 						\
3951852Sbp	(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||	\
4051852Sbp	 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||	\
4151852Sbp	 SIGISMEMBER(set, SIGQUIT))
4251852Sbp
4351852Sbp
4451852Sbp#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __FUNCTION__ ,## args)
4551852Sbp#define nwfs_printf	NCP_PRINT
4651852Sbp/* Maybe this should panic, but I dont like that */
4751852Sbp#define NCPFATAL	NCP_PRINT
4851852Sbp
4951852Sbp/* socket debugging */
5051852Sbp#ifdef NCP_SOCKET_DEBUG
5151852Sbp#define NCPSDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
5251852Sbp#else
5351852Sbp#define NCPSDEBUG(format, args...)
5451852Sbp#endif
5551852Sbp
5651852Sbp/* NCP calls debug */
5751852Sbp#ifdef NCP_NCP_DEBUG
5851852Sbp#define NCPNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
5951852Sbp#else
6051852Sbp#define NCPNDEBUG(format, args...)
6151852Sbp#endif
6251852Sbp
6351852Sbp/* NCP data dump */
6451852Sbp#ifdef NCP_DATA_DEBUG
6551852Sbp#define NCPDDEBUG(m) m_dumpm(m)
6651852Sbp#else
6751852Sbp#define NCPDDEBUG(m)
6851852Sbp#endif
6951852Sbp
7051852Sbp/* FS VOPS debug */
7151852Sbp#ifdef NWFS_VOPS_DEBUG
7251852Sbp#define NCPVODEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
7351852Sbp#else
7451852Sbp#define NCPVODEBUG(format, args...)
7551852Sbp#endif
7651852Sbp
7751852Sbp/* FS VNOPS debug */
7851852Sbp#ifdef NWFS_VNOPS_DEBUG
7951852Sbp#define NCPVNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
8051852Sbp#else
8151852Sbp#define NCPVNDEBUG(format, args...)
8251852Sbp#endif
8351852Sbp
8451852Sbp#define checkbad(fn) {error=(fn);if(error) goto bad;}
8551852Sbp
8651852Sbp#define	ncp_suser(cred)	suser_xxx(cred, NULL, 0)
8751852Sbp
8851852Sbp#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
8951852Sbp
9051852Sbpstruct ncp_conn;
9151852Sbp
9251852Sbpstruct nwmount;
9351852Sbpstruct vnode;
9451852Sbpstruct nwnode;
9551852Sbpstruct vattr;
9651852Sbpstruct uio;
9751852Sbpstruct ncp_nlstables;
9851852Sbp
9951852Sbpstruct ncp_open_info {
10051852Sbp	u_int32_t 		origfh;
10151852Sbp	ncp_fh			fh;
10251852Sbp	u_int8_t 		action;
10351852Sbp	struct nw_entry_info	fattr;
10451852Sbp};
10551852Sbp
10651852Sbpextern int ncp_debuglevel;
10751852Sbp
10855991Sbdestruct proc;
10955991Sbdestruct ucred;
11055991Sbde
11151852Sbpint  ncp_init(void);
11251852Sbpvoid ncp_done(void);
11351852Sbpint  ncp_chkintr(struct ncp_conn *conn, struct proc *p);
11451852Sbpchar*ncp_str_dup(char *s);
11551852Sbp
11651852Sbp/* ncp_crypt.c */
11751852Sbpvoid nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
11851852Sbpvoid nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
11951852Sbpvoid ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
12051852Sbp
12151852Sbp/* ncp calls */
12251852Sbpint ncp_get_bindery_object_id(struct ncp_conn *conn,
12351852Sbp		u_int16_t object_type, char *object_name,
12451852Sbp		struct ncp_bindery_object *target,
12551852Sbp		struct proc *p,struct ucred *cred);
12651852Sbpint  ncp_login_object(struct ncp_conn *conn, unsigned char *username,
12751852Sbp		int login_type, unsigned char *password,
12851852Sbp		struct proc *p,struct ucred *cred);
12951852Sbpint  ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
13051852Sbpint  ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
13151852Sbp
13251852Sbp
13351852Sbp#endif /* _NCP_SUBR_H_ */
134