Merge commit 'crater/master'
[dragonfly.git] / sys / netproto / ncp / ncp_subr.h
blob9c5f339cde4955a6e717c5af6e7d1c6826bf6c56
1 /*
2 * Copyright (c) 1999, Boris Popov
3 * All rights reserved.
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.
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.
32 * $FreeBSD: src/sys/netncp/ncp_subr.h,v 1.3 2000/01/14 19:54:39 bde Exp $
33 * $DragonFly: src/sys/netproto/ncp/ncp_subr.h,v 1.7 2006/12/22 23:57:54 swildner Exp $
35 #ifndef _NETNCP_NCP_SUBR_H_
36 #define _NETNCP_NCP_SUBR_H_
38 #define NCP_TIMER_TICK 2*hz /* 1sec */
39 #define NCP_SIGMASK(set) \
40 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
41 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
42 SIGISMEMBER(set, SIGQUIT))
45 #define NCP_PRINT(format, args...) kprintf("FATAL: %s: "format, __func__ ,## args)
46 #define nwfs_printf NCP_PRINT
47 /* Maybe this should panic, but I dont like that */
48 #define NCPFATAL NCP_PRINT
50 /* socket debugging */
51 #ifdef NCP_SOCKET_DEBUG
52 #define NCPSDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
53 #else
54 #define NCPSDEBUG(format, args...)
55 #endif
57 /* NCP calls debug */
58 #ifdef NCP_NCP_DEBUG
59 #define NCPNDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
60 #else
61 #define NCPNDEBUG(format, args...)
62 #endif
64 /* NCP data dump */
65 #ifdef NCP_DATA_DEBUG
66 #define NCPDDEBUG(m) m_dumpm(m)
67 #else
68 #define NCPDDEBUG(m)
69 #endif
71 /* FS VOPS debug */
72 #ifdef NWFS_VOPS_DEBUG
73 #define NCPVODEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
74 #else
75 #define NCPVODEBUG(format, args...)
76 #endif
78 /* FS VNOPS debug */
79 #ifdef NWFS_VNOPS_DEBUG
80 #define NCPVNDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
81 #else
82 #define NCPVNDEBUG(format, args...)
83 #endif
85 #define checkbad(fn) {error=(fn);if(error) goto bad;}
87 #define ncp_suser(cred) priv_check_cred(cred, PRIV_ROOT, 0)
89 #define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
91 struct ncp_conn;
93 struct nwmount;
94 struct vnode;
95 struct nwnode;
96 struct vattr;
97 struct uio;
98 struct ncp_nlstables;
100 struct ncp_open_info {
101 u_int32_t origfh;
102 ncp_fh fh;
103 u_int8_t action;
104 struct nw_entry_info fattr;
107 extern int ncp_debuglevel;
109 struct proc;
110 struct thread;
111 struct ucred;
113 int ncp_init(void);
114 void ncp_done(void);
115 int ncp_chkintr(struct ncp_conn *conn, struct thread *td);
116 char *ncp_str_dup(const char *s);
118 /* ncp_crypt.c */
119 void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
120 void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
121 void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
123 /* ncp calls */
124 int ncp_get_bindery_object_id(struct ncp_conn *conn,
125 u_int16_t object_type, char *object_name,
126 struct ncp_bindery_object *target,
127 struct thread *td,struct ucred *cred);
128 int ncp_login_object(struct ncp_conn *conn, unsigned char *username,
129 int login_type, unsigned char *password,
130 struct thread *td,struct ucred *cred);
131 int ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
132 int ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
135 #endif /* _NCP_SUBR_H_ */