ncp_subr.h revision 206361
1189084Ssam/*-
2189084Ssam * Copyright (c) 1999 Boris Popov
3189084Ssam * All rights reserved.
4189084Ssam *
5189084Ssam * Redistribution and use in source and binary forms, with or without
6189084Ssam * modification, are permitted provided that the following conditions
7189084Ssam * are met:
8189084Ssam * 1. Redistributions of source code must retain the above copyright
9189084Ssam *    notice, this list of conditions and the following disclaimer.
10189084Ssam * 2. Redistributions in binary form must reproduce the above copyright
11189084Ssam *    notice, this list of conditions and the following disclaimer in the
12189084Ssam *    documentation and/or other materials provided with the distribution.
13189084Ssam *
14189084Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15189084Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16189084Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17189084Ssam * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18189084Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19189084Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20189084Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21189084Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22189084Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23189084Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24189084Ssam * SUCH DAMAGE.
25189084Ssam *
26189084Ssam * $FreeBSD: head/sys/netncp/ncp_subr.h 206361 2010-04-07 16:50:38Z joel $
27189084Ssam */
28189084Ssam#ifndef _NETNCP_NCP_SUBR_H_
29189084Ssam#define _NETNCP_NCP_SUBR_H_
30189084Ssam
31189084Ssam#define NCP_TIMER_TICK	2*hz	/* 1sec */
32189084Ssam#define	NCP_SIGMASK(set) 						\
33189084Ssam	(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||	\
34189084Ssam	 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||	\
35189084Ssam	 SIGISMEMBER(set, SIGQUIT))
36189084Ssam
37189084Ssam
38189084Ssam#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __func__ ,## args)
39189084Ssam#define nwfs_printf	NCP_PRINT
40189084Ssam/* Maybe this should panic, but I dont like that */
41189084Ssam#define NCPFATAL	NCP_PRINT
42189084Ssam#define NCPERROR	NCP_PRINT
43189084Ssam
44189084Ssam/* socket debugging */
45189084Ssam#ifdef NCP_SOCKET_DEBUG
46189084Ssam#define NCPSDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
47189084Ssam#else
48189084Ssam#define NCPSDEBUG(format, args...)
49189084Ssam#endif
50189084Ssam
51189084Ssam/* NCP calls debug */
52189084Ssam#ifdef NCP_NCP_DEBUG
53189084Ssam#define NCPNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
54189084Ssam#else
55#define NCPNDEBUG(format, args...)
56#endif
57
58/* NCP data dump */
59#ifdef NCP_DATA_DEBUG
60#define NCPDDEBUG(m) m_dumpm(m)
61#else
62#define NCPDDEBUG(m)
63#endif
64
65/* FS VOPS debug */
66#ifdef NWFS_VOPS_DEBUG
67#define NCPVODEBUG(format, args...) printf("%s: "format, __func__ ,## args)
68#else
69#define NCPVODEBUG(format, args...)
70#endif
71
72/* FS VNOPS debug */
73#ifdef NWFS_VNOPS_DEBUG
74#define NCPVNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
75#else
76#define NCPVNDEBUG(format, args...)
77#endif
78
79#define checkbad(fn) {error=(fn);if(error) goto bad;}
80
81#define	ncp_suser(cred)	priv_check_cred(cred, PRIV_NETNCP, 0)
82
83#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
84
85struct ncp_conn;
86
87struct nwmount;
88struct vnode;
89struct nwnode;
90struct vattr;
91struct uio;
92struct ncp_nlstables;
93
94struct ncp_open_info {
95	u_int32_t 		origfh;
96	ncp_fh			fh;
97	u_int8_t 		action;
98	struct nw_entry_info	fattr;
99};
100
101extern int ncp_debuglevel;
102
103struct proc;
104struct ucred;
105
106int  ncp_init(void);
107int  ncp_done(void);
108int  ncp_chkintr(struct ncp_conn *conn, struct thread *td);
109char*ncp_str_dup(char *s);
110
111/* ncp_crypt.c */
112void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
113void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
114void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
115
116#endif /* _NCP_SUBR_H_ */
117