ncp_subr.h revision 55991
1/*
2 * Copyright (c) 1999, Boris Popov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 *    must display the following acknowledgement:
15 *    This product includes software developed by Boris Popov.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 *    may be used to endorse or promote products derived from this software
18 *    without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/netncp/ncp_subr.h 55991 2000-01-14 19:54:42Z bde $
33 */
34#ifndef _NETNCP_NCP_SUBR_H_
35#define _NETNCP_NCP_SUBR_H_
36
37#define NCP_TIMER_TICK	2*hz	/* 1sec */
38#define	NCP_SIGMASK(set) 						\
39	(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||	\
40	 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||	\
41	 SIGISMEMBER(set, SIGQUIT))
42
43
44#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __FUNCTION__ ,## args)
45#define nwfs_printf	NCP_PRINT
46/* Maybe this should panic, but I dont like that */
47#define NCPFATAL	NCP_PRINT
48
49/* socket debugging */
50#ifdef NCP_SOCKET_DEBUG
51#define NCPSDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
52#else
53#define NCPSDEBUG(format, args...)
54#endif
55
56/* NCP calls debug */
57#ifdef NCP_NCP_DEBUG
58#define NCPNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
59#else
60#define NCPNDEBUG(format, args...)
61#endif
62
63/* NCP data dump */
64#ifdef NCP_DATA_DEBUG
65#define NCPDDEBUG(m) m_dumpm(m)
66#else
67#define NCPDDEBUG(m)
68#endif
69
70/* FS VOPS debug */
71#ifdef NWFS_VOPS_DEBUG
72#define NCPVODEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
73#else
74#define NCPVODEBUG(format, args...)
75#endif
76
77/* FS VNOPS debug */
78#ifdef NWFS_VNOPS_DEBUG
79#define NCPVNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
80#else
81#define NCPVNDEBUG(format, args...)
82#endif
83
84#define checkbad(fn) {error=(fn);if(error) goto bad;}
85
86#define	ncp_suser(cred)	suser_xxx(cred, NULL, 0)
87
88#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
89
90struct ncp_conn;
91
92struct nwmount;
93struct vnode;
94struct nwnode;
95struct vattr;
96struct uio;
97struct ncp_nlstables;
98
99struct ncp_open_info {
100	u_int32_t 		origfh;
101	ncp_fh			fh;
102	u_int8_t 		action;
103	struct nw_entry_info	fattr;
104};
105
106extern int ncp_debuglevel;
107
108struct proc;
109struct ucred;
110
111int  ncp_init(void);
112void ncp_done(void);
113int  ncp_chkintr(struct ncp_conn *conn, struct proc *p);
114char*ncp_str_dup(char *s);
115
116/* ncp_crypt.c */
117void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
118void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
119void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
120
121/* ncp calls */
122int ncp_get_bindery_object_id(struct ncp_conn *conn,
123		u_int16_t object_type, char *object_name,
124		struct ncp_bindery_object *target,
125		struct proc *p,struct ucred *cred);
126int  ncp_login_object(struct ncp_conn *conn, unsigned char *username,
127		int login_type, unsigned char *password,
128		struct proc *p,struct ucred *cred);
129int  ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
130int  ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
131
132
133#endif /* _NCP_SUBR_H_ */
134