hammer2 - Fix flush issues with unmounted PFSs and shutdown panic
[dragonfly.git] / sys / netproto / smb / smb_subr.h
blobba22cdde8ee31cd402eb7554387f03926802a3a9
1 /*
2 * Copyright (c) 2000-2001, 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/netsmb/smb_subr.h,v 1.1.2.1 2001/05/22 08:32:34 bp Exp $
34 #ifndef _NETSMB_SMB_SUBR_H_
35 #define _NETSMB_SMB_SUBR_H_
37 #ifndef _KERNEL
38 #error "This file shouldn't be included from userland programs"
39 #endif
41 #ifdef MALLOC_DECLARE
42 MALLOC_DECLARE(M_SMBTEMP);
43 #endif
46 * For compatibility with 5.x
48 #define PDROP PUSRFLAG1 /* OR'd with pri to stop re-entry of interlock mutex */
50 #define SMBERROR(format, args...) kprintf("%s: "format, __func__ ,## args)
51 #define SMBPANIC(format, args...) kprintf("%s: "format, __func__ ,## args)
53 #ifdef SMB_SOCKET_DEBUG
54 #define SMBSDEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
55 #else
56 #define SMBSDEBUG(format, args...)
57 #endif
59 #ifdef SMB_IOD_DEBUG
60 #define SMBIODEBUG(format, args...) kprintf("%s: "format, __func__ ,## args)
61 #else
62 #define SMBIODEBUG(format, args...)
63 #endif
65 #ifdef SMB_SOCKETDATA_DEBUG
66 void m_dumpm(struct mbuf *m);
67 #else
68 #define m_dumpm(m)
69 #endif
71 #define SMB_SIGMASK(set) \
72 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
73 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
74 SIGISMEMBER(set, SIGQUIT))
76 #define smb_suser(cred) priv_check_cred(cred, PRIV_ROOT, 0)
78 #include <sys/lock.h>
79 #include <sys/spinlock.h>
80 #include <sys/spinlock2.h>
82 #define lockdestroy(lock)
83 #define smb_slock spinlock
84 #define smb_sl_init(sl, desc) spin_init(sl, desc)
85 #define smb_sl_destroy(sl)
86 #define smb_sl_lock(sl) spin_lock(sl)
87 #define smb_sl_unlock(sl) spin_unlock(sl)
89 #define SMB_STRFREE(p) do { if (p) smb_strfree(p); } while(0)
91 typedef u_int16_t smb_unichar;
92 typedef smb_unichar *smb_uniptr;
95 * Crediantials of user/process being processing in the connection procedures
97 struct smb_cred {
98 struct thread * scr_td;
99 struct ucred * scr_cred;
102 extern smb_unichar smb_unieol;
104 struct mbchain;
105 struct proc;
106 struct thread;
107 struct smb_vc;
108 struct smb_rq;
111 void smb_makescred(struct smb_cred *scred, struct thread *td, struct ucred *cred);
112 int smb_proc_intr(struct thread *td);
113 char *smb_strdup(const char *s);
114 void *smb_memdup(const void *umem, int len);
115 char *smb_strdupin(char *s, int maxlen);
116 void *smb_memdupin(void *umem, int len);
117 void smb_strtouni(u_int16_t *dst, const char *src);
118 void smb_strfree(char *s);
119 void smb_memfree(void *s);
120 void *smb_zmalloc(unsigned long size, struct malloc_type *type, int flags);
122 int smb_calcmackey(struct smb_vc *vcp);
123 int smb_encrypt(const u_char *apwd, u_char *C8, u_char *RN);
124 int smb_ntencrypt(const u_char *apwd, u_char *C8, u_char *RN);
125 int smb_maperror(int eclass, int eno);
126 int smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp,
127 const char *src, int len, int caseopt);
128 int smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp,
129 const char *src, int caseopt);
130 int smb_put_string(struct smb_rq *rqp, const char *src);
131 int smb_put_asunistring(struct smb_rq *rqp, const char *src);
132 int smb_rq_sign(struct smb_rq *rqp);
133 int smb_rq_verify(struct smb_rq *rqp);
136 * Compatibilty with 5.x functions
138 int smb_kthread_create(void (*func)(void *), void *arg,
139 struct proc **newpp, int flags, const char *fmt, ...)
140 __printflike(5, 6);
141 void smb_kthread_exit(void);
142 int smb_sleep(void *chan, struct smb_slock *sl, int slpflags, const char *wmesg, int timo);
145 #endif /* !_NETSMB_SMB_SUBR_H_ */