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 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: stable/9/sys/netncp/ncp_subr.h 206361 2010-04-07 16:50:38Z joel $ 27 */ 28 #ifndef _NETNCP_NCP_SUBR_H_ 29 #define _NETNCP_NCP_SUBR_H_ 30 31 #define NCP_TIMER_TICK 2*hz /* 1sec */ 32 #define NCP_SIGMASK(set) \ 33 (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 34 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 35 SIGISMEMBER(set, SIGQUIT)) 36 37 38 #define NCP_PRINT(format, args...) printf("FATAL: %s: "format, __func__ ,## args) 39 #define nwfs_printf NCP_PRINT 40 /* Maybe this should panic, but I dont like that */ 41 #define NCPFATAL NCP_PRINT 42 #define NCPERROR NCP_PRINT 43 44 /* socket debugging */ 45 #ifdef NCP_SOCKET_DEBUG 46 #define NCPSDEBUG(format, args...) printf("%s: "format, __func__ ,## args) 47 #else 48 #define NCPSDEBUG(format, args...) 49 #endif 50 51 /* NCP calls debug */ 52 #ifdef NCP_NCP_DEBUG 53 #define NCPNDEBUG(format, args...) printf("%s: "format, __func__ ,## args) 54 #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 85 struct ncp_conn; 86 87 struct nwmount; 88 struct vnode; 89 struct nwnode; 90 struct vattr; 91 struct uio; 92 struct ncp_nlstables; 93 94 struct 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 101 extern int ncp_debuglevel; 102 103 struct proc; 104 struct ucred; 105 106 int ncp_init(void); 107 int ncp_done(void); 108 int ncp_chkintr(struct ncp_conn *conn, struct thread *td); 109 char*ncp_str_dup(char *s); 110 111 /* ncp_crypt.c */ 112 void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target); 113 void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target); 114 void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate); 115 116 #endif /* _NCP_SUBR_H_ */ 117