1139823Simp/*- 2206361Sjoel * Copyright (c) 1999 Boris Popov 351852Sbp * All rights reserved. 451852Sbp * 551852Sbp * Redistribution and use in source and binary forms, with or without 651852Sbp * modification, are permitted provided that the following conditions 751852Sbp * are met: 851852Sbp * 1. Redistributions of source code must retain the above copyright 951852Sbp * notice, this list of conditions and the following disclaimer. 1051852Sbp * 2. Redistributions in binary form must reproduce the above copyright 1151852Sbp * notice, this list of conditions and the following disclaimer in the 1251852Sbp * documentation and/or other materials provided with the distribution. 1351852Sbp * 1451852Sbp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1551852Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1651852Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1751852Sbp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1851852Sbp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1951852Sbp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2051852Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2151852Sbp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2251852Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2351852Sbp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2451852Sbp * SUCH DAMAGE. 2551852Sbp * 2651852Sbp * $FreeBSD$ 2751852Sbp */ 2854477Sbp#ifndef _NETNCP_NCP_SUBR_H_ 2954477Sbp#define _NETNCP_NCP_SUBR_H_ 3051852Sbp 3151852Sbp#define NCP_TIMER_TICK 2*hz /* 1sec */ 3251852Sbp#define NCP_SIGMASK(set) \ 3351852Sbp (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \ 3451852Sbp SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \ 3551852Sbp SIGISMEMBER(set, SIGQUIT)) 3651852Sbp 3751852Sbp 3887599Sobrien#define NCP_PRINT(format, args...) printf("FATAL: %s: "format, __func__ ,## args) 3951852Sbp#define nwfs_printf NCP_PRINT 4051852Sbp/* Maybe this should panic, but I dont like that */ 4151852Sbp#define NCPFATAL NCP_PRINT 4274060Sbp#define NCPERROR NCP_PRINT 4351852Sbp 4451852Sbp/* socket debugging */ 4551852Sbp#ifdef NCP_SOCKET_DEBUG 4687599Sobrien#define NCPSDEBUG(format, args...) printf("%s: "format, __func__ ,## args) 4751852Sbp#else 4851852Sbp#define NCPSDEBUG(format, args...) 4951852Sbp#endif 5051852Sbp 5151852Sbp/* NCP calls debug */ 5251852Sbp#ifdef NCP_NCP_DEBUG 5387599Sobrien#define NCPNDEBUG(format, args...) printf("%s: "format, __func__ ,## args) 5451852Sbp#else 5551852Sbp#define NCPNDEBUG(format, args...) 5651852Sbp#endif 5751852Sbp 5851852Sbp/* NCP data dump */ 5951852Sbp#ifdef NCP_DATA_DEBUG 6051852Sbp#define NCPDDEBUG(m) m_dumpm(m) 6151852Sbp#else 6251852Sbp#define NCPDDEBUG(m) 6351852Sbp#endif 6451852Sbp 6551852Sbp/* FS VOPS debug */ 6651852Sbp#ifdef NWFS_VOPS_DEBUG 6787599Sobrien#define NCPVODEBUG(format, args...) printf("%s: "format, __func__ ,## args) 6851852Sbp#else 6951852Sbp#define NCPVODEBUG(format, args...) 7051852Sbp#endif 7151852Sbp 7251852Sbp/* FS VNOPS debug */ 7351852Sbp#ifdef NWFS_VNOPS_DEBUG 7487599Sobrien#define NCPVNDEBUG(format, args...) printf("%s: "format, __func__ ,## args) 7551852Sbp#else 7651852Sbp#define NCPVNDEBUG(format, args...) 7751852Sbp#endif 7851852Sbp 7951852Sbp#define checkbad(fn) {error=(fn);if(error) goto bad;} 8051852Sbp 81164033Srwatson#define ncp_suser(cred) priv_check_cred(cred, PRIV_NETNCP, 0) 8251852Sbp 8351852Sbp#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid) 8451852Sbp 8551852Sbpstruct ncp_conn; 8651852Sbp 8751852Sbpstruct nwmount; 8851852Sbpstruct vnode; 8951852Sbpstruct nwnode; 9051852Sbpstruct vattr; 9151852Sbpstruct uio; 9251852Sbpstruct ncp_nlstables; 9351852Sbp 9451852Sbpstruct ncp_open_info { 9551852Sbp u_int32_t origfh; 9651852Sbp ncp_fh fh; 9751852Sbp u_int8_t action; 9851852Sbp struct nw_entry_info fattr; 9951852Sbp}; 10051852Sbp 10151852Sbpextern int ncp_debuglevel; 10251852Sbp 10355991Sbdestruct proc; 10455991Sbdestruct ucred; 10555991Sbde 10651852Sbpint ncp_init(void); 10774060Sbpint ncp_done(void); 108111577Sfjoeint ncp_chkintr(struct ncp_conn *conn, struct thread *td); 10951852Sbpchar*ncp_str_dup(char *s); 11051852Sbp 11151852Sbp/* ncp_crypt.c */ 11251852Sbpvoid nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target); 11351852Sbpvoid nw_encrypt(const u_char *fra, const u_char *buf, u_char *target); 11451852Sbpvoid ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate); 11551852Sbp 11651852Sbp#endif /* _NCP_SUBR_H_ */ 117