ncp_subr.h revision 51852
1139826Simp/*
253541Sshin * Copyright (c) 1999, Boris Popov
353541Sshin * All rights reserved.
453541Sshin *
553541Sshin * Redistribution and use in source and binary forms, with or without
653541Sshin * modification, are permitted provided that the following conditions
753541Sshin * are met:
853541Sshin * 1. Redistributions of source code must retain the above copyright
953541Sshin *    notice, this list of conditions and the following disclaimer.
1053541Sshin * 2. Redistributions in binary form must reproduce the above copyright
1153541Sshin *    notice, this list of conditions and the following disclaimer in the
1253541Sshin *    documentation and/or other materials provided with the distribution.
1353541Sshin * 3. All advertising materials mentioning features or use of this software
1453541Sshin *    must display the following acknowledgement:
1553541Sshin *    This product includes software developed by Boris Popov.
1653541Sshin * 4. Neither the name of the author nor the names of any co-contributors
1753541Sshin *    may be used to endorse or promote products derived from this software
1853541Sshin *    without specific prior written permission.
1953541Sshin *
2053541Sshin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
2153541Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2253541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2353541Sshin * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2453541Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2553541Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2653541Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2753541Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28174510Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29174510Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3053541Sshin * SUCH DAMAGE.
3153541Sshin *
32139826Simp * $FreeBSD: head/sys/netncp/ncp_subr.h 51852 1999-10-02 04:06:24Z bp $
3353541Sshin */
3453541Sshin#ifndef _NCP_SUBR_H_
3553541Sshin#define _NCP_SUBR_H_
3653541Sshin
3753541Sshin#define NCP_TIMER_TICK	2*hz	/* 1sec */
3853541Sshin#define	NCP_SIGMASK(set) 						\
3953541Sshin	(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||	\
4053541Sshin	 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||	\
4153541Sshin	 SIGISMEMBER(set, SIGQUIT))
4253541Sshin
4353541Sshin
4453541Sshin#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __FUNCTION__ ,## args)
4553541Sshin#define nwfs_printf	NCP_PRINT
4653541Sshin/* Maybe this should panic, but I dont like that */
4753541Sshin#define NCPFATAL	NCP_PRINT
4853541Sshin
4953541Sshin/* socket debugging */
5053541Sshin#ifdef NCP_SOCKET_DEBUG
5153541Sshin#define NCPSDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
5253541Sshin#else
5353541Sshin#define NCPSDEBUG(format, args...)
5453541Sshin#endif
5553541Sshin
5653541Sshin/* NCP calls debug */
5753541Sshin#ifdef NCP_NCP_DEBUG
5853541Sshin#define NCPNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
5953541Sshin#else
6053541Sshin#define NCPNDEBUG(format, args...)
6153541Sshin#endif
6253541Sshin
63174510Sobrien/* NCP data dump */
64174510Sobrien#ifdef NCP_DATA_DEBUG
65174510Sobrien#define NCPDDEBUG(m) m_dumpm(m)
6662587Sitojun#else
6762587Sitojun#define NCPDDEBUG(m)
6855009Sshin#endif
6953541Sshin
7053541Sshin/* FS VOPS debug */
7195759Stanimura#ifdef NWFS_VOPS_DEBUG
7295759Stanimura#define NCPVODEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
7395759Stanimura#else
7478064Sume#define NCPVODEBUG(format, args...)
7553541Sshin#endif
7653541Sshin
7795759Stanimura/* FS VNOPS debug */
7853541Sshin#ifdef NWFS_VNOPS_DEBUG
7953541Sshin#define NCPVNDEBUG(format, args...) printf("%s: "format, __FUNCTION__ ,## args)
8095759Stanimura#else
8195759Stanimura#define NCPVNDEBUG(format, args...)
8295759Stanimura#endif
8353541Sshin
8453541Sshin#define checkbad(fn) {error=(fn);if(error) goto bad;}
8553541Sshin
8653541Sshin#define	ncp_suser(cred)	suser_xxx(cred, NULL, 0)
8753541Sshin
8895759Stanimura#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)
8953541Sshin
9053541Sshinstruct ncp_conn;
9195759Stanimura
9253541Sshinstruct nwmount;
9362587Sitojunstruct vnode;
9495759Stanimurastruct nwnode;
95122922Sandrestruct vattr;
9695759Stanimurastruct uio;
9795759Stanimurastruct ncp_nlstables;
9895759Stanimura
9953541Sshinstruct ncp_open_info {
100148385Sume	u_int32_t 		origfh;
10153541Sshin	ncp_fh			fh;
10253541Sshin	u_int8_t 		action;
10353541Sshin	struct nw_entry_info	fattr;
104171167Sgnn};
105105199Ssam
106105199Ssamextern int ncp_debuglevel;
107105199Ssam
108105199Ssamint  ncp_init(void);
10962587Sitojunvoid ncp_done(void);
11053541Sshinint  ncp_chkintr(struct ncp_conn *conn, struct proc *p);
11162587Sitojunchar*ncp_str_dup(char *s);
11253541Sshin
113141553Srwatson/* ncp_crypt.c */
11462587Sitojunvoid nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
11562587Sitojunvoid nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
11662587Sitojunvoid ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);
11778064Sume
11862587Sitojun/* ncp calls */
11953541Sshinint ncp_get_bindery_object_id(struct ncp_conn *conn,
120175162Sobrien		u_int16_t object_type, char *object_name,
121175162Sobrien		struct ncp_bindery_object *target,
122175162Sobrien		struct proc *p,struct ucred *cred);
12362587Sitojunint  ncp_login_object(struct ncp_conn *conn, unsigned char *username,
12462587Sitojun		int login_type, unsigned char *password,
125175162Sobrien		struct proc *p,struct ucred *cred);
126175162Sobrienint  ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
127175162Sobrienint  ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
12862587Sitojun
129148892Sume
13062587Sitojun#endif /* _NCP_SUBR_H_ */
13162587Sitojun