ncp_subr.h revision 139823
1139823Simp/*-
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 139823 2005-01-07 01:45:51Z imp $
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
4487599Sobrien#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __func__ ,## args)
4551852Sbp#define nwfs_printf	NCP_PRINT
4651852Sbp/* Maybe this should panic, but I dont like that */
4751852Sbp#define NCPFATAL	NCP_PRINT
4874060Sbp#define NCPERROR	NCP_PRINT
4951852Sbp
5051852Sbp/* socket debugging */
5151852Sbp#ifdef NCP_SOCKET_DEBUG
5287599Sobrien#define NCPSDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
5351852Sbp#else
5451852Sbp#define NCPSDEBUG(format, args...)
5551852Sbp#endif
5651852Sbp
5751852Sbp/* NCP calls debug */
5851852Sbp#ifdef NCP_NCP_DEBUG
5987599Sobrien#define NCPNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
6051852Sbp#else
6151852Sbp#define NCPNDEBUG(format, args...)
6251852Sbp#endif
6351852Sbp
6451852Sbp/* NCP data dump */
6551852Sbp#ifdef NCP_DATA_DEBUG
6651852Sbp#define NCPDDEBUG(m) m_dumpm(m)
6751852Sbp#else
6851852Sbp#define NCPDDEBUG(m)
6951852Sbp#endif
7051852Sbp
7151852Sbp/* FS VOPS debug */
7251852Sbp#ifdef NWFS_VOPS_DEBUG
7387599Sobrien#define NCPVODEBUG(format, args...) printf("%s: "format, __func__ ,## args)
7451852Sbp#else
7551852Sbp#define NCPVODEBUG(format, args...)
7651852Sbp#endif
7751852Sbp
7851852Sbp/* FS VNOPS debug */
7951852Sbp#ifdef NWFS_VNOPS_DEBUG
8087599Sobrien#define NCPVNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
8151852Sbp#else
8251852Sbp#define NCPVNDEBUG(format, args...)
8351852Sbp#endif
8451852Sbp
8551852Sbp#define checkbad(fn) {error=(fn);if(error) goto bad;}
8651852Sbp
8793593Sjhb#define	ncp_suser(cred)	suser_cred(cred, 0)
8851852Sbp
8951852Sbp#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
9051852Sbp
9151852Sbpstruct ncp_conn;
9251852Sbp
9351852Sbpstruct nwmount;
9451852Sbpstruct vnode;
9551852Sbpstruct nwnode;
9651852Sbpstruct vattr;
9751852Sbpstruct uio;
9851852Sbpstruct ncp_nlstables;
9951852Sbp
10051852Sbpstruct ncp_open_info {
10151852Sbp	u_int32_t 		origfh;
10251852Sbp	ncp_fh			fh;
10351852Sbp	u_int8_t 		action;
10451852Sbp	struct nw_entry_info	fattr;
10551852Sbp};
10651852Sbp
10751852Sbpextern int ncp_debuglevel;
10851852Sbp
10955991Sbdestruct proc;
11055991Sbdestruct ucred;
11155991Sbde
11251852Sbpint  ncp_init(void);
11374060Sbpint  ncp_done(void);
114111577Sfjoeint  ncp_chkintr(struct ncp_conn *conn, struct thread *td);
11551852Sbpchar*ncp_str_dup(char *s);
11651852Sbp
11751852Sbp/* ncp_crypt.c */
11851852Sbpvoid nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
11951852Sbpvoid nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
12051852Sbpvoid ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
12151852Sbp
12251852Sbp#endif /* _NCP_SUBR_H_ */
123