code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_file.h 206361 2010-04-07 16:50:38Z joel $
 */

#ifndef _NETNCP_NCP_FILE_H_
#define _NETNCP_NCP_FILE_H_

typedef struct {
   nuint32  sequence;
   nuint32  parent;
   nuint32  attributes;
   nuint8   uniqueID;
   nuint8   flags;
   nuint8   nameSpace;
   nuint8   nameLength;
   nuint8   name [256];
   nuint32  creationDateAndTime;
   nuint32  ownerID;
   nuint32  lastArchiveDateAndTime;
   nuint32  lastArchiverID;
   nuint32  updateDateAndTime;
   nuint32  updatorID;
   nuint32  fileSize;
   nuint8   reserved[44];
   nuint16  inheritedRightsMask;
   nuint16  lastAccessDate;
   nuint32  deletedTime;
   nuint32  deletedDateAndTime;
   nuint32  deletorID;
   nuint8   reserved3 [16];
} __packed NWDELETED_INFO;

__BEGIN_DECLS

int	ncp_AllocTempDirHandle(char *, NWDIR_HANDLE *);
int	ncp_DeallocateDirHandle(NWDIR_HANDLE);
int	ncp_GetNSEntryInfo(NWDIR_HANDLE, struct nw_entry_info *, int *);

NWCCODE	ncp_ScanNSEntryInfo(NWCONN_HANDLE, nuint8, nuint16,
	SEARCH_SEQUENCE *, pnstr8, nuint32, NW_ENTRY_INFO *);

NWCCODE ncp_PurgeDeletedFile(NWCONN_HANDLE, nuint32, nuint32, nuint32, nuint8);

NWCCODE NWRecoverDeletedFile(NWCONN_HANDLE, NWDIR_HANDLE,
	nuint32, nuint32, nuint32, pnstr8, pnstr8);

NWCCODE ncp_ScanForDeletedFiles(NWCONN_HANDLE, pnuint32, pnuint32, pnuint32,
	nuint8,	NWDELETED_INFO *);

__END_DECLS

#endif /* _NCP_NCP_FILE_ */


code:
/*-
 * Copyright (c) 1999, 2000, 2001 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_lib.h 206361 2010-04-07 16:50:38Z joel $
 */

#ifndef _NETNCP_NCP_LIB_H_
#define _NETNCP_NCP_LIB_H_

#define IPX
#define INET

#include <netncp/ncp.h>
#include <netncp/ncp_conn.h>
#include <netncp/ncp_user.h>
#include <netncp/ncp_rq.h>

#define ncp_printf printf

#define sipx_cnetwork	sipx_addr.x_net.c_net
#define sipx_node	sipx_addr.x_host.c_host
#define ipx_netlong(iaddr) (((union ipx_net_u *)(&((iaddr).x_net)))->long_e)

#define	STDPARAM_ARGS	'A':case 'B':case 'C':case 'I':case 'M': \
		   case 'N':case 'U':case 'R':case 'S':case 'T': \
		   case 'W':case 'O':case 'P'

#define STDPARAM_OPT	"A:BCI:M:NO:P:U:R:S:T:W:"

#ifndef min
#define	min(a,b)	(((a)<(b)) ? (a) : (b))
#endif

/*
 * An attempt to do a unified options parser
 */
enum ncp_argtype {NCA_STR,NCA_INT,NCA_BOOL};

struct ncp_args;

typedef int ncp_setopt_t (struct ncp_args*);

#define	NAFL_NONE	0x0000
#define	NAFL_HAVEMIN	0x0001
#define	NAFL_HAVEMAX	0x0002
#define	NAFL_MINMAX	NAFL_HAVEMIN | NAFL_HAVEMAX

struct ncp_args {
	enum ncp_argtype at;
	int	opt;	/* command line option */
	char	*name;	/* rc file equiv */
	int	flag;	/* NAFL_* */
	int	ival;	/* int/bool values, or max len for str value */
	char	*str;	/* string value */
	int	min;	/* min for ival */
	int	max;	/* max for ival */
	ncp_setopt_t *fn;/* call back to validate */
};

typedef struct {
  nuint8    day;
  nuint8    month;
  nuint16   year;
} NW_DATE;

/* hours is a nuint16  so that this structure will be the same length as a dword */
typedef struct {
  nuint8    seconds;
  nuint8    minutes;
  nuint16   hours;
} NW_TIME;

struct ncp_bitname {
	u_int	bn_bit;
	const char	*bn_name;
};

__BEGIN_DECLS

int ncp_args_parserc(struct ncp_args *, char *, ncp_setopt_t *);
int ncp_args_parseopt(struct ncp_args *, int, char *, ncp_setopt_t *);

struct sockaddr_ipx;
struct ipx_addr;
struct sockaddr;
struct ncp_buf;
struct rcfile;

int  ncp_initlib(void);
int  ncp_connect(struct ncp_conn_args *, int *);
int  ncp_connect_addr(struct sockaddr *, NWCONN_HANDLE *);
int  ncp_disconnect(int);
int  ncp_request(int, int, struct ncp_buf *);
int  ncp_conn_request(int, struct ncp_buf *);
int  ncp_login(int, const char *, int, const char *);
int  ncp_conn_scan(struct ncp_conn_loginfo *, int *);
int  ncp_conn_cnt(void);
void *ncp_conn_list(void);
int  ncp_conn_getinfo(int, struct ncp_conn_stat *);
int  ncp_conn_getuser(int, char **);
int  ncp_conn2ref(int, int *);
int  ncp_conn_dup(NWCONN_HANDLE, NWCONN_HANDLE *);
int  ncp_path2conn(char *, int *);
int  ncp_li_init(struct ncp_conn_loginfo *, int, char *[]);
void ncp_li_done(struct ncp_conn_loginfo *);
int  ncp_li_login(struct ncp_conn_loginfo *, int *);
int  ncp_li_readrc(struct ncp_conn_loginfo *);
int  ncp_li_check(struct ncp_conn_loginfo *);
int  ncp_li_arg(struct ncp_conn_loginfo *, int, char *);
int  ncp_li_setserver(struct ncp_conn_loginfo *, const char *);
int  ncp_li_setuser(struct ncp_conn_loginfo *, char *);
int  ncp_li_setpassword(struct ncp_conn_loginfo *, const char *);
int  ncp_conn_setflags(int, u_int16_t, u_int16_t);
int  ncp_conn_find(char *, char *);
NWCCODE NWRequest(NWCONN_HANDLE, nuint16, nuint16, NW_FRAGMENT *,
    nuint16, NW_FRAGMENT *);

#define ncp_setpermanent(connHandle,on)	ncp_conn_setflags(connHandle, NCPFL_PERMANENT, (on) ? NCPFL_PERMANENT : 0)
#define ncp_setprimary(connHandle,on)	ncp_conn_setflags(connHandle, NCPFL_PRIMARY, (on) ? NCPFL_PRIMARY : 0)

int  ncp_find_fileserver(struct ncp_conn_loginfo *, int, char *);
int  ncp_find_server(struct ncp_conn_loginfo *, int, int, char *);

/* misc rotines */
char* ncp_str_upper(char *);
int  ncp_open_rcfile(void);
int  ncp_getopt(int, char * const *, const char *);
void NWUnpackDateTime(nuint32, NW_DATE *, NW_TIME *);
void NWUnpackDate(nuint16, NW_DATE *);
void NWUnpackTime(nuint16, NW_TIME *);
time_t ncp_UnpackDateTime(nuint32);
int  ncp_GetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
int  ncp_SetFileServerDateAndTime(NWCONN_HANDLE, time_t *);
NWCCODE NWDownFileServer(NWCONN_HANDLE, int);
NWCCODE NWCloseBindery(NWCONN_HANDLE);
NWCCODE NWOpenBindery(NWCONN_HANDLE);
NWCCODE NWDisableTTS(NWCONN_HANDLE);
NWCCODE NWEnableTTS(NWCONN_HANDLE);
NWCCODE NWDisableFileServerLogin(NWCONN_HANDLE);
NWCCODE NWEnableFileServerLogin(NWCONN_HANDLE);
void ncp_error(const char *, int, ...) __printf0like(1, 3);
char *ncp_printb(char *, int, const struct ncp_bitname *);
void nw_keyhash(const u_char *, const u_char *, int, u_char *);
void nw_encrypt(const u_char *, const u_char *, u_char *);
void ipx_print_addr(struct ipx_addr *);

/* bindery calls */
int  ncp_get_bindery_object_id(NWCONN_HANDLE, u_int16_t, const char *,
		struct ncp_bindery_object *);
int  ncp_get_bindery_object_name(NWCONN_HANDLE, u_int32_t,
		struct ncp_bindery_object *);
int  ncp_scan_bindery_object(NWCONN_HANDLE, u_int32_t, u_int16_t,
		char *, struct ncp_bindery_object *);
int  ncp_read_property_value(NWCONN_HANDLE, int object_type, const char *,
		int, const char *, struct nw_property *);
int  ncp_get_encryption_key(NWCONN_HANDLE, char *);
int  ncp_change_obj_passwd(NWCONN_HANDLE,
	const struct ncp_bindery_object *, const u_char *,
	const u_char *, const u_char *);
int  ncp_keyed_verify_password(NWCONN_HANDLE, char *, char *,
		struct ncp_bindery_object *);

/* queue calls */
int  ncp_create_queue_job_and_file(NWCONN_HANDLE, u_int32_t, struct queue_job *);
int  ncp_close_file_and_start_job(NWCONN_HANDLE, u_int32_t, struct queue_job *);
int  ncp_attach_to_queue(NWCONN_HANDLE, u_int32_t);
int  ncp_detach_from_queue(NWCONN_HANDLE, u_int32_t);
int  ncp_service_queue_job(NWCONN_HANDLE, u_int32_t, u_int16_t,
		struct queue_job *);
int  ncp_finish_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t, u_int32_t);
int  ncp_abort_servicing_job(NWCONN_HANDLE, u_int32_t, u_int32_t);
int  ncp_get_queue_length(NWCONN_HANDLE, u_int32_t, u_int32_t *);
int  ncp_get_queue_job_ids(NWCONN_HANDLE, u_int32_t, u_int32_t,
		u_int32_t *, u_int32_t *, u_int32_t []);
int  ncp_get_queue_job_info(NWCONN_HANDLE, u_int32_t, u_int32_t,
		struct nw_queue_job_entry *);
/*
 * filesystem and volume calls
 */
int  ncp_read(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
int  ncp_write(NWCONN_HANDLE, ncp_fh *, off_t, size_t, char *);
int  ncp_geteinfo(char *, struct nw_entry_info *);
int  ncp_NSEntryInfo(NWCONN_HANDLE, nuint8, nuint8, nuint32, NW_ENTRY_INFO *);

NWCCODE NWGetVolumeName(NWCONN_HANDLE, u_char, char *);

/* misc ncp calls */
int  ncp_get_file_server_information(NWCONN_HANDLE, struct ncp_file_server_info *);
int  ncp_get_stations_logged_info(NWCONN_HANDLE, u_int32_t,
		struct ncp_bindery_object *, time_t *);
int  ncp_get_internet_address(NWCONN_HANDLE, u_int32_t, struct ipx_addr *,
		u_int8_t *);
NWCCODE NWGetObjectConnectionNumbers(NWCONN_HANDLE, pnstr8, nuint16,
		pnuint16, pnuint16, nuint16);
/*
 * Message broadcast
 */
NWCCODE NWDisableBroadcasts(NWCONN_HANDLE);
NWCCODE	NWEnableBroadcasts(NWCONN_HANDLE);
NWCCODE	NWBroadcastToConsole(NWCONN_HANDLE, pnstr8);
NWCCODE NWSendBroadcastMessage(NWCONN_HANDLE, pnstr8, nuint16, pnuint16, pnuint8);
NWCCODE NWGetBroadcastMessage(NWCONN_HANDLE, pnstr8);

/*
 * RPC calls
 */
NWCCODE	NWSMExecuteNCFFile(NWCONN_HANDLE, pnstr8);
NWCCODE	NWSMLoadNLM(NWCONN_HANDLE, pnstr8);
NWCCODE NWSMUnloadNLM(NWCONN_HANDLE, pnstr8);
NWCCODE NWSMMountVolume(NWCONN_HANDLE, pnstr8, nuint32 *);
NWCCODE NWSMDismountVolumeByName(NWCONN_HANDLE, pnstr8);
NWCCODE NWSMSetDynamicCmdIntValue(NWCONN_HANDLE, pnstr8, nuint32);
NWCCODE NWSMSetDynamicCmdStrValue(NWCONN_HANDLE, pnstr8, pnstr8);

__END_DECLS

extern int ncp_opterr, ncp_optind, ncp_optopt, ncp_optreset;
extern char *ncp_optarg;

extern struct rcfile *ncp_rc;
extern int sysentoffset;
#endif /* _NETNCP_NCP_LIB_H_ */

repo_name: veiledmerc/mira

license: mit


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_ncp.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_NCP_H_
#define _NETNCP_NCP_NCP_H_

#define NCP_ALLOC_SLOT		0x1111
#define NCP_REQUEST		0x2222
#define NCP_REPLY		0x3333
#define NCP_FREE_SLOT		0x5555
#define	NCP_PACKET_BURST	0x7777
#define NCP_POSITIVE_ACK	0x9999

/*
 * Bits for connection state field in ncp_rphdr
 */
#define	NCP_CS_BAD_CONN		0x01	/* no such connection */
#define	NCP_CS_NO_SLOTS		0x04	/* no connection slots available */
#define	NCP_CS_SERVER_DOWN	0x10	/* server in down state */
#define	NCP_CS_HAVE_BROADCAST	0x40	/* server holds broadcast for us */

#define NCP_RETRY_COUNT		5
#define	NCP_RETRY_TIMEOUT	10
#define	NCP_RESTORE_COUNT	2	/* how many times try to restore per
					 * single request, should be an _even_ */

struct ncp_rqhdr {
	u_int16_t type;
	u_int8_t  seq;
	u_int8_t  conn_low;
	u_int8_t  task;
	u_int8_t  conn_high;
	u_int8_t  fn;
	u_int8_t  data[0];
} __packed;

struct ncp_rphdr {
	u_int16_t	type;
	u_int8_t	seq;
	u_int8_t	conn_low;
	u_int8_t	task;
	u_int8_t	conn_high;
	u_int8_t	completion_code;
	u_int8_t	connection_state;
	u_int8_t	data[0];
}__packed;

#define	BFL_ABT		0x04
#define	BFL_EOB		0x10
#define	BFL_SYS		0x80

#define	BOP_READ	1L
#define	BOP_WRITE	2L

#define	BERR_NONE	0
#define	BERR_INIT	1
#define	BERR_IO		2
#define	BERR_NODATA	3
#define	BERR_WRITE	4

struct ncp_bursthdr {
	u_short	bh_type;
	u_char	bh_flags;
	u_char	bh_streamtype;
	u_long	bh_srcid;
	u_long	bh_dstid;
	u_long	bh_seq;			/* HL */
	u_long	bh_send_delay;		/* HL */
	u_short	bh_bseq;		/* HL */
	u_short	bh_aseq;		/* HL */
	u_long	bh_blen;		/* HL */
	u_long	bh_dofs;		/* HL */
	u_short	bh_dlen;		/* HL */
	u_short	bh_misfrags;		/* HL */
} __packed;

struct ncp_conn;
struct ncp_conn_args;
struct ncp_rq;
struct ucred;

int  ncp_ncp_connect(struct ncp_conn *conn);
int  ncp_ncp_disconnect(struct ncp_conn *conn);
int  ncp_negotiate_buffersize(struct ncp_conn *conn, int size, int *target);
int  ncp_renegotiate_connparam(struct ncp_conn *conn, int buffsize,
	u_int8_t in_options);
int  ncp_get_bindery_object_id(struct ncp_conn *conn,
		u_int16_t object_type, char *object_name,
		struct ncp_bindery_object *target,
		struct thread *td,struct ucred *cred);
int  ncp_get_encryption_key(struct ncp_conn *conn, char *target);
int  ncp_login_encrypted(struct ncp_conn *conn,
	struct ncp_bindery_object *object,
	const u_char *key, const u_char *passwd,
	struct thread *td, struct ucred *cred);
int ncp_login_unencrypted(struct ncp_conn *conn, u_int16_t object_type,
	const char *object_name, const u_char *passwd,
	struct thread *td, struct ucred *cred);
int  ncp_read(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);
int  ncp_write(struct ncp_conn *conn, ncp_fh *file, struct uio *uiop, struct ucred *cred);

#endif /* _NCP_NCP_H_ */


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_nls.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_NLS_H_
#define _NETNCP_NCP_NLS_H_

/* options for handle path & caseopt in mount struct */
#define NWHP_HDB	0x01	/* have dir base */
#define	NWHP_UPPER	0x02	/* local names has upper case */
#define	NWHP_LOWER	0x04	/* --"-- lower case */
#define	NWHP_DOS	0x08	/* using dos name space */
#define	NWHP_NLS	0x10	/* do name translation via tables, any nmspc */
#define	NWHP_NOSTRICT	0x20	/* pretend to be a case insensitive */

struct ncp_nlstables {
	u_char	*to_lower;	/* local charset to lower case */
	u_char	*to_upper;	/* local charset to upper case */
	u_char	*n2u;		/* NetWare to Unix */
	u_char	*u2n;
	int	opt;		/* may depend on context */
};

#ifndef _KERNEL
/*
 * NLS, supported character conversion schemes.
 * NCP_NLS_UNIXCHARSET_NETWARECHARSET
 */
#define	NCP_NLS_AS_IS		1
#define	NCP_NLS_AS_IS_NAME	"asis"
#define	NCP_NLS_KOI_866		2
#define	NCP_NLS_SE		3
#define	NCP_NLS_KOI_866_NAME	"koi2cp866"
#define	NCP_NLS_SE_NAME		"se"

extern struct ncp_nlstables ncp_nls;	/* active nls */

__BEGIN_DECLS

int   ncp_nls_setrecode(int scheme);
int   ncp_nls_setrecodebyname(char *name);
int   ncp_nls_setlocale(char *name);
char* ncp_nls_str_n2u(char *dst, const char *src);
char* ncp_nls_str_u2n(char *dst, const char *src);
char* ncp_nls_mem_n2u(char *dst, const char *src, int size);
char* ncp_nls_mem_u2n(char *dst, const char *src, int size);

__END_DECLS

#else /* !_KERNEL */

extern struct ncp_nlstables ncp_defnls;

void ncp_str_upper(char *name);
void ncp_str_lower(char *name);
void ncp_pathcopy(const char *src, char *dst, int len, struct ncp_nlstables *nt);
int  ncp_pathcheck(char *s, int len, struct ncp_nlstables *nt, int strict);
void ncp_path2unix(char *src, char *dst, int len, struct ncp_nlstables *nt);

#endif /* !_KERNEL */

#endif /* _NCP_NCP_NLS_H_ */


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_rcfile.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_RCFILE_H_
#define _NETNCP_NCP_RCFILE_H_
#include <sys/queue.h>

struct rckey {
	SLIST_ENTRY(rckey)	rk_next;
	char 			*rk_name;
	char			*rk_value;
};

struct rcsection {
	SLIST_ENTRY(rcsection)	rs_next;
	SLIST_HEAD(rckey_head,rckey) rs_keys;
	char			*rs_name;
};

struct rcfile {
	SLIST_ENTRY(rcfile)	rf_next;
	SLIST_HEAD(rcsec_head, rcsection) rf_sect;
	char			*rf_name;
	FILE			*rf_f;
};

__BEGIN_DECLS

int  rc_open(char *, char *,struct rcfile **);
int  rc_close(struct rcfile *);
int  rc_getstringptr(struct rcfile *, char *, char *, char **);
int  rc_getstring(struct rcfile *, char *, char *, int, char *);
int  rc_getint(struct rcfile *, char *, char *, int *);
int  rc_getbool(struct rcfile *, char *, char *, int *);

__END_DECLS

#endif	/* _NETNCP_NCP_RCFILE_H_ */


code:
/*-
 * Copyright (c) 1999, 2000, 2001 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_rq.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_RQ_H_
#define _NETNCP_NCP_RQ_H_

#include <sys/endian.h>

#define getb(buf,ofs) 		(((const u_int8_t *)(buf))[ofs])
#define setb(buf,ofs,val)	(((u_int8_t*)(buf))[ofs])=val
#define getbw(buf,ofs)		((u_int16_t)(getb(buf,ofs)))

#define	getwle(buf,ofs) (le16toh(*((u_int16_t*)(&((u_int8_t*)(buf))[ofs]))))
#define	getdle(buf,ofs) (le32toh(*((u_int32_t*)(&((u_int8_t*)(buf))[ofs]))))
#define	getwbe(buf,ofs) (be16toh(*((u_int16_t*)(&((u_int8_t*)(buf))[ofs]))))
#define	getdbe(buf,ofs) (be32toh(*((u_int32_t*)(&((u_int8_t*)(buf))[ofs]))))

#define	setwle(buf,ofs,val) \
	(*((u_int16_t*)(&((u_int8_t*)(buf))[ofs])))=htole16(val)
#define	setdle(buf,ofs,val) \
	(*((u_int32_t*)(&((u_int8_t*)(buf))[ofs])))=htole32(val)
#define	setwbe(buf,ofs,val) \
	(*((u_int16_t*)(&((u_int8_t*)(buf))[ofs])))=htobe16(val)
#define	setdbe(buf,ofs,val) \
	(*((u_int32_t*)(&((u_int8_t*)(buf))[ofs])))=htobe32(val)

#ifdef _KERNEL

#include <sys/mchain.h>

#define	NCPR_ALLOCED		0x0001	/* request structure was allocated */
#define	NCPR_DONTFREEONERR	0x0002	/* do not free structure on error */

/*
 * Structure to prepare ncp request and receive reply
 */
struct ncp_rq {
	int		nr_flags;
	struct mbchain	rq;
	struct mdchain	rp;
	int		nr_minrplen;	/* minimal rp size (-1 if not known) */
	int		nr_rpsize;	/* reply size minus ncp header */
	int		nr_cc;		/* completion code */
	int		nr_cs;		/* connection state */
	struct thread *	nr_td;		/* thread that did rq */
	struct ucred *	nr_cred;	/* user that did rq */
	int		rexmit;
	struct ncp_conn*nr_conn;	/* back link */
};

int  ncp_rq_alloc(u_int8_t fn, struct ncp_conn *ncp, struct thread *td,
	struct ucred *cred, struct ncp_rq **rqpp);
int  ncp_rq_alloc_any(u_int32_t ptype, u_int8_t fn, struct ncp_conn *ncp,
	struct thread *td,	struct ucred *cred, struct ncp_rq **rqpp);
int  ncp_rq_alloc_subfn(u_int8_t fn, u_int8_t subfn, struct ncp_conn *ncp,
	struct thread *td,	struct ucred *cred, struct ncp_rq **rqpp);
int  ncp_rq_init_any(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,
	struct ncp_conn *ncp,
	struct thread *td, struct ucred *cred);
void ncp_rq_done(struct ncp_rq *rqp);
int  ncp_request(struct ncp_rq *rqp);
int  ncp_request_int(struct ncp_rq *rqp);

struct ncp_nlstables;

int  ncp_rq_pathstring(struct ncp_rq *rqp, int size, const char *name, struct ncp_nlstables*);
int  ncp_rq_dbase_path(struct ncp_rq *, u_int8_t vol_num,
		    u_int32_t dir_base, int namelen, u_char *name, struct ncp_nlstables *nt);
int  ncp_rq_pstring(struct ncp_rq *rqp, const char *s);

void ncp_sign_init(const char *logindata, char *sign_root);

#else /* ifdef _KERNEL */

#define	DECLARE_RQ	struct ncp_buf conn1, *conn=&conn1

#define	ncp_add_byte(conn,x) (conn)->packet[(conn)->rqsize++]=x

struct ncp_buf;

__BEGIN_DECLS

void ncp_init_request(struct ncp_buf *);
void ncp_init_request_s(struct ncp_buf *, int);
void ncp_add_word_lh(struct ncp_buf *, u_int16_t);
void ncp_add_dword_lh(struct ncp_buf *, u_int32_t);
void ncp_add_word_hl(struct ncp_buf *, u_int16_t);
void ncp_add_dword_hl(struct ncp_buf *, u_int32_t);
void ncp_add_mem(struct ncp_buf *, const void *, int);
void ncp_add_mem_nls(struct ncp_buf *, const void *, int);
void ncp_add_pstring(struct ncp_buf *, const char *);
void ncp_add_handle_path(struct ncp_buf *, nuint32, nuint32, int, const char *);

#define ncp_reply_data(conn,offset) ((conn)->packet+offset)
#define ncp_reply_byte(conn,offset) (*(u_int8_t*)(ncp_reply_data(conn, offset)))

u_int16_t ncp_reply_word_hl(struct ncp_buf *, int);
u_int16_t ncp_reply_word_lh(struct ncp_buf *, int);
u_int32_t ncp_reply_dword_hl(struct ncp_buf *, int);
u_int32_t ncp_reply_dword_lh(struct ncp_buf *, int);

static __inline void
ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh) {
	fh->val1 = (fh->val.val32 = sfd);
	return;
}

__END_DECLS

#endif /* ifdef _KERNEL */

#endif	/* !_NETNCP_NCP_RQ_H_ */


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_sock.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_SOCK_H_
#define _NETNCP_NCP_SOCK_H_

struct ncp_conn;
struct mbuf;
struct ncp_rq;
struct proc;
struct socket;
struct timeval;

int  ncp_sock_connect(struct ncp_conn *ncp);
int  ncp_sock_recv(struct socket *so, struct mbuf **mp, int *rlen);
int  ncp_sock_send(struct socket *so, struct mbuf *data, struct ncp_rq *rqp);
int  ncp_sock_disconnect(struct ncp_conn *conn);
int  ncp_sock_checksum(struct ncp_conn *conn, int enable);

void ncp_check_rq(struct ncp_conn *conn);
void ncp_check_conn(struct ncp_conn *conn);

void ncp_check_wd(struct ncp_conn *conn);

#endif /* _NCP_SOCK_H_ */


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_subr.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_SUBR_H_
#define _NETNCP_NCP_SUBR_H_

#define NCP_TIMER_TICK	2*hz	/* 1sec */
#define	NCP_SIGMASK(set) 						\
	(SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) ||	\
	 SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) ||	\
	 SIGISMEMBER(set, SIGQUIT))

#define	NCP_PRINT(format, args...) printf("FATAL: %s: "format, __func__ ,## args)
#define nwfs_printf	NCP_PRINT
/* Maybe this should panic, but I dont like that */
#define NCPFATAL	NCP_PRINT
#define NCPERROR	NCP_PRINT

/* socket debugging */
#ifdef NCP_SOCKET_DEBUG
#define NCPSDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
#else
#define NCPSDEBUG(format, args...)
#endif

/* NCP calls debug */
#ifdef NCP_NCP_DEBUG
#define NCPNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
#else
#define NCPNDEBUG(format, args...)
#endif

/* NCP data dump */
#ifdef NCP_DATA_DEBUG
#define NCPDDEBUG(m) m_dumpm(m)
#else
#define NCPDDEBUG(m)
#endif

/* FS VOPS debug */
#ifdef NWFS_VOPS_DEBUG
#define NCPVODEBUG(format, args...) printf("%s: "format, __func__ ,## args)
#else
#define NCPVODEBUG(format, args...)
#endif

/* FS VNOPS debug */
#ifdef NWFS_VNOPS_DEBUG
#define NCPVNDEBUG(format, args...) printf("%s: "format, __func__ ,## args)
#else
#define NCPVNDEBUG(format, args...)
#endif

#define checkbad(fn) {error=(fn);if(error) goto bad;}

#define	ncp_suser(cred)	priv_check_cred(cred, PRIV_NETNCP, 0)

#define ncp_isowner(conn,cred) ((cred)->cr_uid == (conn)->nc_owner->cr_uid)

struct ncp_conn;

struct nwmount;
struct vnode;
struct nwnode;
struct vattr;
struct uio;
struct ncp_nlstables;

struct ncp_open_info {
	u_int32_t 		origfh;
	ncp_fh			fh;
	u_int8_t 		action;
	struct nw_entry_info	fattr;
};

extern int ncp_debuglevel;

struct proc;
struct ucred;

int  ncp_init(void);
int  ncp_done(void);
int  ncp_chkintr(struct ncp_conn *conn, struct thread *td);
char*ncp_str_dup(char *s);

/* ncp_crypt.c */
void nw_keyhash(const u_char *key, const u_char *buf, int buflen, u_char *target);
void nw_encrypt(const u_char *fra, const u_char *buf, u_char *target);
void ncp_sign(const u_int32_t *state, const char *x, u_int32_t *ostate);

#endif /* _NCP_SUBR_H_ */


code:
/*-
 * Copyright (c) 1999 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncp_user.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETNCP_NCP_USER_H_
#define _NETNCP_NCP_USER_H_

/*
 * "ncp" interface to kernel, this can be done via syscalls but may eat
 * a lot of them, so we select internal code, define req's and replays
 * as necessary. Structure for call is simple:
 * byte=NCP_CONN
 * byte=NCP_CONN_SUBFN
 * ....=data
 */
#define	NCP_CONN		0xF5	/* change if that will occupied */
#define	NCP_CONN_READ		0x01	/* read from file handle */
#define	NCP_CONN_WRITE		0x02	/* write to file handle */
#define	NCP_CONN_SETFLAGS	0x03	/* word mask, word flags */
#define	NCP_CONN_LOGIN		0x04	/* bind login on handle */
#define	NCP_CONN_GETINFO	0x05	/* get information about connection */
#define	NCP_CONN_GETUSER	0x06	/* get user name for connection */
#define	NCP_CONN_CONN2REF	0x07	/* convert handle to reference */
#define	NCP_CONN_CONNCLOSE	0x08	/* release connection handle */
#define	NCP_CONN_FRAG		0x09	/* ncp fragmented request */
#define	NCP_CONN_DUP		0x0A	/* get an additional handle */
#define	NCP_CONN_GETDATA	0x0B	/* retrieve NCP_CD_* vals */
#define	NCP_CONN_SETDATA	0x0C	/* store NCP_CD_* vals */

/*
 * Internal connection data can be set by owner or superuser and retrieved
 * only by superuser
 */
#define	NCP_CD_NDSLOGINKEY	0x01
#define	NCP_CD_NDSPRIVATEKEY	0x02
#define NCP_CD_NDSUFLAGS	0x03

/* user side structures to issue fragmented ncp calls */
typedef struct {
	char	*fragAddress;
	u_int32_t fragSize;
} NW_FRAGMENT;

struct ncp_rw {
	ncp_fh	nrw_fh;
	char 	*nrw_base;
	off_t	nrw_offset;
	int	nrw_cnt;
};

struct ncp_conn_login {
	char	*username;
	int	objtype;
	char	*password;
};

struct ncp_conn_frag {
	int		cc;		/* completion code */
	int		cs;		/* connection state */
	int		fn;
	int		rqfcnt;
	NW_FRAGMENT	*rqf;
	int		rpfcnt;
	NW_FRAGMENT	*rpf;
};

#endif


code:
/*-
 * Copyright (c) 2003 Tim J. Robbins.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netncp/ncpio.h 111657 2003-02-28 04:31:29Z tjr $
 */

#ifndef _NETNCP_NCPIO_H_
#define _NETNCP_NCPIO_H_

#ifndef _KERNEL
#include <sys/types.h>
#endif
#include <sys/ioccom.h>

#define	NCP_NAME	"ncp"

struct ncp_conn_args;
struct ncp_buf;

struct ncpioc_connect {
	struct ncp_conn_args	*ioc_li;
	int			*ioc_connhandle;
};

struct ncpioc_request {
	int			ioc_connhandle;
	int			ioc_fn;
	struct ncp_buf		*ioc_ncpbuf;
};

struct ncpioc_connscan {
	struct ncp_conn_args	*ioc_li;
	int			*ioc_connhandle;
};

#define	NCPIOC_CONNECT		_IOW('N',  100, struct ncpioc_connect)
#define	NCPIOC_REQUEST		_IOW('N',  101, struct ncpioc_request)
#define	NCPIOC_CONNSCAN		_IOW('N',  102, struct ncpioc_connscan)

#endif /* _NETNCP_NCPIO_H_ */


code:
/*
 * NetWare requestor error codes, they taken from NDK
 *
 * $FreeBSD: release/9.0.0/sys/netncp/nwerror.h 54477 1999-12-12 05:50:07Z bp $
 */
#ifndef _NETNCP_NWERROR_H_
#define _NETNCP_NWERROR_H_

#ifndef SUCCESS
#define SUCCESS                        0
#endif

#define SHELL_ERROR                    0x8800
#define VLM_ERROR                      0x8800
#define ALREADY_ATTACHED               0x8800  /* 0  - Attach attempted to server with valid, existing connection */
#define INVALID_CONNECTION             0x8801  /* 1  - Request attempted with invalid or non-attached connection handle */
#define DRIVE_IN_USE                   0x8802  /* 2  - OS/2 only (NOT USED) */
#define CANT_ADD_CDS                   0x8803  /* 3  - Map drive attempted but unable to add new current directory structure */
#define DRIVE_CANNOT_MAP               0x8803
#define BAD_DRIVE_BASE                 0x8804  /* 4  - Map drive attempted with invalid path specification */
#define NET_READ_ERROR                 0x8805  /* 5  - Attempt to receive from the selected transport failed */
#define NET_RECV_ERROR                 0x8805  /* 5  */
#define UNKNOWN_NET_ERROR              0x8806  /* 6  - Network send attempted with an un-specific network error */
#define SERVER_INVALID_SLOT            0x8807  /* 7  - Server request attempted with invalid server connection slot */
#define BAD_SERVER_SLOT                0x8807  /* 7  */
#define NO_SERVER_SLOTS                0x8808  /* 8  - Attach attempted to server with no connection slots available */
#define NET_WRITE_ERROR                0x8809  /* 9  - Attempt to send on the selected transport failed */
#define CONNECTION_IN_ERROR_STATE      0x8809  /* Client-32 */
#define NET_SEND_ERROR                 0x8809  /* 9  */
#define SERVER_NO_ROUTE                0x880A  /* 10 - Attempted to find route to server where no route exists */
#define BAD_LOCAL_TARGET               0x880B  /* 11 - OS/2 only */
#define TOO_MANY_REQ_FRAGS             0x880C  /* 12 - Attempted request with too many request fragments specified */
#define CONNECT_LIST_OVERFLOW          0x880D  /* 13 */
#define BUFFER_OVERFLOW                0x880E  /* 14 - Attempt to receive more data than the reply buffer had room for */
#define MORE_DATA_ERROR                0x880E  /* Client-32 */
#define NO_CONN_TO_SERVER              0x880F  /* 15 */
#define NO_CONNECTION_TO_SERVER        0x880F  /* 15 - Attempt to get connection for a server not connected */
#define NO_ROUTER_FOUND                0x8810  /* 16 - OS/2 only */
#define BAD_FUNC_ERROR                 0x8811  /* 17 */
#define INVALID_SHELL_CALL             0x8811  /* 17 - Attempted function call to non- existent or illegal function */
#define SCAN_COMPLETE                  0x8812
#define LIP_RESIZE_ERROR               0x8812  /* Client-32 */
#define UNSUPPORTED_NAME_FORMAT_TYPE   0x8813
#define INVALID_DIR_HANDLE             0x8813  /* Client-32 */
#define HANDLE_ALREADY_LICENSED        0x8814
#define OUT_OF_CLIENT_MEMORY           0x8814  /* Client-32 */
#define HANDLE_ALREADY_UNLICENSED      0x8815
#define PATH_NOT_OURS                  0x8815  /* Client-32 */
#define INVALID_NCP_PACKET_LENGTH      0x8816
#define PATH_IS_PRINT_DEVICE           0x8816  /* Client-32 */
#define SETTING_UP_TIMEOUT             0x8817
#define PATH_IS_EXCLUDED_DEVICE        0x8817  /* Client-32 */
#define SETTING_SIGNALS                0x8818
#define PATH_IS_INVALID                0x8818  /* Client-32 */
#define SERVER_CONNECTION_LOST         0x8819
#define NOT_SAME_DEVICE                0x8819  /* Client-32 */
#define OUT_OF_HEAP_SPACE              0x881A
#define INVALID_SERVICE_REQUEST        0x881B
#define INVALID_SEARCH_HANDLE          0x881B  /* Client-32 */
#define INVALID_TASK_NUMBER            0x881C
#define INVALID_DEVICE_HANDLE          0x881C  /* Client-32 */
#define INVALID_MESSAGE_LENGTH         0x881D
#define INVALID_SEM_HANDLE             0x881D  /* Client-32 */
#define EA_SCAN_DONE                   0x881E
#define INVALID_CFG_HANDLE             0x881E  /* Client-32 */
#define BAD_CONNECTION_NUMBER          0x881F
#define INVALID_MOD_HANDLE             0x881F  /* Client-32 */
#define ASYN_FIRST_PASS                0x8820
#define INVALID_DEVICE_INDEX           0x8821
#define INVALID_CONN_HANDLE            0x8822
#define INVALID_QUEUE_ID               0x8823
#define INVALID_PDEVICE_HANDLE         0x8824
#define INVALID_JOB_HANDLE             0x8825
#define INVALID_ELEMENT_ID             0x8826
#define ALIAS_NOT_FOUND                0x8827
#define RESOURCE_SUSPENDED             0x8828
#define INVALID_QUEUE_SPECIFIED        0x8829
#define DEVICE_ALREADY_OPEN            0x882A
#define JOB_ALREADY_OPEN               0x882B
#define QUEUE_NAME_ID_MISMATCH         0x882C
#define JOB_ALREADY_STARTED            0x882D
#define SPECT_DAA_TYPE_NOT_SUPPORTED   0x882E
#define INVALID_ENVIR_HANDLE           0x882F
#define NOT_SAME_CONNECTION            0x8830  /* 48 - Internal server request attempted accross different server connections */
#define PRIMARY_CONNECTION_NOT_SET     0x8831  /* 49 - Attempt to retrieve default connection with no primary connection set */
#define NO_PRIMARY_SET                 0x8831  /* 49 */
#define KEYWORD_NOT_FOUND              0x8832  /* Client-32 */
#define PRINT_CAPTURE_NOT_IN_PROGRESS  0x8832  /* Client-32 */
#define NO_CAPTURE_SET                 0x8832  /* 50 */
#define NO_CAPTURE_IN_PROGRESS         0x8832  /* 50 - Capture information requested on port with no capture in progress */
#define BAD_BUFFER_LENGTH              0x8833  /* 51 */
#define INVALID_BUFFER_LENGTH          0x8833  /* 51 - Used to indicate length which caller requested on a GetDNC or SetDNC was too large */
#define NO_USER_NAME                   0x8834  /* 52 */
#define NO_NETWARE_PRINT_SPOOLER       0x8835  /* 53 - Capture requested without having the local print spooler installed */
#define INVALID_PARAMETER              0x8836  /* 54 - Attempted function with an invalid function parameter specified */
#define CONFIG_FILE_OPEN_FAILED        0x8837  /* 55 - OS/2 only */
#define NO_CONFIG_FILE                 0x8838  /* 56 - OS/2 only */
#define CONFIG_FILE_READ_FAILED        0x8839  /* 57 - OS/2 only */
#define CONFIG_LINE_TOO_LONG           0x883A  /* 58 - OS/2 only */
#define CONFIG_LINES_IGNORED           0x883B  /* 59 - OS/2 only */
#define NOT_MY_RESOURCE                0x883C  /* 60 - Attempted request made with a parameter using foriegn resource */
#define DAEMON_INSTALLED               0x883D  /* 61 - OS/2 only */
#define SPOOLER_INSTALLED              0x883E  /* 62 - Attempted load of print spooler with print spooler already installed */
#define CONN_TABLE_FULL                0x883F  /* 63 */
#define CONNECTION_TABLE_FULL          0x883F  /* 63 - Attempted to allocate a connection handle with no more local connection table entries */
#define CONFIG_SECTION_NOT_FOUND       0x8840  /* 64 - OS/2 only */
#define BAD_TRAN_TYPE                  0x8841  /* 65 */
#define INVALID_TRANSPORT_TYPE         0x8841  /* 65 - Attempted function on a connection with an invalid transport selected */
#define TDS_TAG_IN_USE                 0x8842  /* 66 - OS/2 only */
#define TDS_OUT_OF_MEMORY              0x8843  /* 67 - OS/2 only */
#define TDS_INVALID_TAG                0x8844  /* 68 - Attempted TDS function with invalid tag */
#define TDS_WRITE_TRUNCATED            0x8845  /* 69 - Attempted TDS write with buffer that exceeded buffer */
#define NO_CONNECTION_TO_DS            0x8846  /* Client-32 */
#define NO_DIRECTORY_SERVICE_CONNECTION 0x8846  /* 70 */
#define SERVICE_BUSY                   0x8846  /* 70 - Attempted request made to partially asynchronous function in busy state */
#define NO_SERVER_ERROR                0x8847  /* 71 - Attempted connect failed to find any servers responding */
#define BAD_VLM_ERROR                  0x8848  /* 72 - Attempted function call to non-existant or not-loaded overlay */
#define NETWORK_DRIVE_IN_USE           0x8849  /* 73 - Attempted map to network drive that was already mapped */
#define LOCAL_DRIVE_IN_USE             0x884A  /* 74 - Attempted map to local drive that was in use */
#define NO_DRIVES_AVAILABLE            0x884B  /* 75 - Attempted map to next available drive when none were available */
#define DEVICE_NOT_REDIRECTED          0x884C  /* 76 - The device is not redirected */
#define NO_MORE_SFT_ENTRIES            0x884D  /* 77 - Maximum number of files was reached */
#define UNLOAD_ERROR                   0x884E  /* 78 - Attempted unload failed */
#define IN_USE_ERROR                   0x884F  /* 79 - Attempted re-use of already in use connection entry */
#define TOO_MANY_REP_FRAGS             0x8850  /* 80 - Attempted request with too many reply fragments specified */
#define TABLE_FULL                     0x8851  /* 81 - Attempted to add a name into the name table after it was full */
#ifndef SOCKET_NOT_OPEN
#define SOCKET_NOT_OPEN                0x8852  /* 82 - Listen was posted on unopened socket */
#endif
#define MEM_MGR_ERROR                  0x8853  /* 83 - Attempted enhanced memory operation failed */
#define SFT3_ERROR                     0x8854  /* 84 - An SFT3 switch occured mid-transfer */
#define PREFERRED_NOT_FOUND            0x8855  /* 85 - the preferred directory server was not established but another directory server was returned */
#define DEVICE_NOT_RECOGNIZED          0x8856  /* 86 - used to determine if the device is not used by VISE so pass it on to the next redirector, if any. */
#define BAD_NET_TYPE                   0x8857  /* 87 - the network type (Bind/NDS) does not match the server version */
#define ERROR_OPENING_FILE             0x8858  /* 88 - generic open failure error, invalid path, access denied, etc.. */
#define NO_PREFERRED_SPECIFIED         0x8859  /* 89 - no preferred name specified */
#define ERROR_OPENING_SOCKET           0x885A  /* 90 - error opening a socket */
#define REQUESTER_FAILURE              0x885A  /* Client-32 */
#define RESOURCE_ACCESS_DENIED         0x885B  /* Client-32 */
#define SIGNATURE_LEVEL_CONFLICT       0x8861
#define NO_LOCK_FOUND                  0x8862  /* OS/2 - process lock on conn handle failed, process ID not recognized */
#define LOCK_TABLE_FULL                0x8863  /* OS/2 - process lock on conn handle failed, process lock table full */
#define INVALID_MATCH_DATA             0x8864
#define MATCH_FAILED                   0x8865
#define NO_MORE_ENTRIES                0x8866
#define INSUFFICIENT_RESOURCES         0x8867
#define STRING_TRANSLATION             0x8868
#define STRING_TRANSLATION_NEEDED      0x8868  /* Client-32 */
#define ACCESS_VIOLATION               0x8869
#define NOT_AUTHENTICATED              0x886A
#define INVALID_LEVEL                  0x886B
#define RESOURCE_LOCK_ERROR            0x886C
#define INVALID_NAME_FORMAT            0x886D
#define OBJECT_EXISTS                  0x886E
#define OBJECT_NOT_FOUND               0x886F
#define UNSUPPORTED_TRAN_TYPE          0x8870
#define INVALID_STRING_TYPE            0x8871
#define INVALID_OWNER                  0x8872
#define UNSUPPORTED_AUTHENTICATOR      0x8873
#define IO_PENDING                     0x8874
#define INVALID_DRIVE_NUM              0x8875
#define SHELL_FAILURE                  0x88FF
#define VLM_FAILURE                    0x88FF

#define  SVC_ALREADY_REGISTERED        0x8880 /* Client-32 */
#define  SVC_REGISTRY_FULL             0x8881 /* Client-32 */
#define  SVC_NOT_REGISTERED            0x8882 /* Client-32 */
#define  OUT_OF_RESOURCES              0x8883 /* Client-32 */
#define  RESOLVE_SVC_FAILED            0x8884 /* Client-32 */
#define  CONNECT_FAILED                0x8885 /* Client-32 */
#define  PROTOCOL_NOT_BOUND            0x8886 /* Client-32 */
#define  AUTHENTICATION_FAILED         0x8887 /* Client-32 */
#define  INVALID_AUTHEN_HANDLE         0x8888 /* Client-32 */
#define  AUTHEN_HANDLE_ALREADY_EXISTS  0x8889 /* Client-32 */

#define  DIFF_OBJECT_ALREADY_AUTHEN    0x8890 /* Client-32 */
#define  REQUEST_NOT_SERVICEABLE       0x8891 /* Client-32 */
#define  AUTO_RECONNECT_SO_REBUILD     0x8892 /* Client-32 */
#define  AUTO_RECONNECT_RETRY_REQUEST  0x8893 /* Client-32 */
#define  ASYNC_REQUEST_IN_USE          0x8894 /* Client-32 */
#define  ASYNC_REQUEST_CANCELED        0x8895 /* Client-32 */
#define  SESS_SVC_ALREADY_REGISTERED   0x8896 /* Client-32 */
#define  SESS_SVC_NOT_REGISTERED       0x8897 /* Client-32 */
#define  PREVIOUSLY_AUTHENTICATED      0x8899 /* Client-32 */
#define  RESOLVE_SVC_PARTIAL           0x889A /* Client-32 */
#define  NO_DEFAULT_SPECIFIED          0x889B /* Client-32 */
#define  HOOK_REQUEST_NOT_HANDLED      0x889C /* Client-32 */
#define  HOOK_REQUEST_BUSY             0x889D /* Client-32 */
#define  HOOK_REQUEST_QUEUED           0x889D /* Client-32 */
#define  AUTO_RECONNECT_SO_IGNORE      0x889E /* Client-32 */
#define  ASYNC_REQUEST_NOT_IN_USE      0x889F /* Client-32 */
#define  AUTO_RECONNECT_FAILURE        0x88A0 /* Client-32 */
#define  NET_ERROR_ABORT_APPLICATION   0x88A1 /* Client-32 */
#define  NET_ERROR_SUSPEND_APPLICATION 0x88A2 /* Client-32 */
#define  NET_ERROR_ABORTED_PROCESS_GROUP  0x88A3 /* Client-32 */
#define  NET_ERROR_PASSWORD_HAS_EXPIRED   0x88A5 /* Client-32 */
#define  NET_ERROR_NETWORK_INACTIVE       0x88A6 /* Client-32 */
#define  REPLY_TRUNCATED            0x88e6    /* 230 NLM */

/* Server Errors */

#define ERR_INSUFFICIENT_SPACE          0x8901  /* 001 */
#define ERR_NO_MORE_ENTRY           0x8914   /* 020 */
#define NLM_INVALID_CONNECTION         0x890a   /* 010 */
#define ERR_BUFFER_TOO_SMALL            0x8977  /* 119 */
#define ERR_VOLUME_FLAG_NOT_SET         0x8978  /* 120 the service requested, not avail. on the selected vol. */
#define ERR_NO_ITEMS_FOUND              0x8979  /* 121 */
#define ERR_CONN_ALREADY_TEMP           0x897a  /* 122 */
#define ERR_CONN_ALREADY_LOGGED_IN      0x897b  /* 123 */
#define ERR_CONN_NOT_AUTHENTICATED      0x897c  /* 124 */
#define ERR_CONN_NOT_LOGGED_IN          0x897d  /* 125 */
#define NCP_BOUNDARY_CHECK_FAILED       0x897e  /* 126 */
#define ERR_LOCK_WAITING                0x897f  /* 127 */
#define ERR_LOCK_FAIL                   0x8980  /* 128 */
#define FILE_IN_USE_ERROR               0x8980  /* 128 */
#define NO_MORE_FILE_HANDLES            0x8981  /* 129 */
#define NO_OPEN_PRIVILEGES              0x8982  /* 130 */
#define IO_ERROR_NETWORK_DISK           0x8983  /* 131 */
#define ERR_AUDITING_HARD_IO_ERROR      0x8983  /* 131 */
#define NO_CREATE_PRIVILEGES            0x8984  /* 132 */
#define ERR_AUDITING_NOT_SUPV           0x8984  /* 132 */
#define NO_CREATE_DELETE_PRIVILEGES     0x8985  /* 133 */
#define CREATE_FILE_EXISTS_READ_ONLY    0x8986  /* 134 */
#define WILD_CARDS_IN_CREATE_FILE_NAME  0x8987  /* 135 */
#define CREATE_FILENAME_ERROR           0x8987  /* 135 */
#define INVALID_FILE_HANDLE             0x8988  /* 136 */
#define NO_SEARCH_PRIVILEGES            0x8989  /* 137 */
#define NO_DELETE_PRIVILEGES            0x898A  /* 138 */
#define NO_RENAME_PRIVILEGES            0x898B  /* 139 */
#define NO_MODIFY_PRIVILEGES            0x898C  /* 140 */
#define SOME_FILES_AFFECTED_IN_USE      0x898D  /* 141 */
#define NO_FILES_AFFECTED_IN_USE        0x898E  /* 142 */
#define SOME_FILES_AFFECTED_READ_ONLY   0x898F  /* 143 */
#define NO_FILES_AFFECTED_READ_ONLY     0x8990  /* 144 */
#define SOME_FILES_RENAMED_NAME_EXISTS  0x8991  /* 145 */
#define NO_FILES_RENAMED_NAME_EXISTS    0x8992  /* 146 */
#define NO_READ_PRIVILEGES              0x8993  /* 147 */
#define NO_WRITE_PRIVILEGES_OR_READONLY 0x8994  /* 148 */
#define FILE_DETACHED                   0x8995  /* 149 */
#define SERVER_OUT_OF_MEMORY            0x8996  /* 150 */
#define ERR_TARGET_NOT_A_SUBDIRECTORY   0x8996  /* 150 can be changed later (note written by server people). */
#define NO_DISK_SPACE_FOR_SPOOL_FILE    0x8997  /* 151 */
#define ERR_AUDITING_NOT_ENABLED        0x8997  /* 151 */
#define VOLUME_DOES_NOT_EXIST           0x8998  /* 152 */
#define DIRECTORY_FULL                  0x8999  /* 153 */
#define RENAMING_ACROSS_VOLUMES         0x899A  /* 154 */
#define BAD_DIRECTORY_HANDLE            0x899B  /* 155 */
#define INVALID_PATH                    0x899C  /* 156 */
#define NO_MORE_TRUSTEES                0x899C  /* 156 */
#define NO_MORE_DIRECTORY_HANDLES       0x899D  /* 157 */
#define INVALID_FILENAME                0x899E  /* 158 */
#define DIRECTORY_ACTIVE                0x899F  /* 159 */
#define DIRECTORY_NOT_EMPTY             0x89A0  /* 160 */
#define DIRECTORY_IO_ERROR              0x89A1  /* 161 */
#define READ_FILE_WITH_RECORD_LOCKED    0x89A2  /* 162 */
#define ERR_TRANSACTION_RESTARTED       0x89A3  /* 163 */
#define ERR_RENAME_DIR_INVALID          0x89A4  /* 164 */
#define ERR_INVALID_OPENCREATE_MODE     0x89A5  /* 165 */
#define ERR_ALREADY_IN_USE              0x89A6  /* 166 */
#define ERR_AUDITING_ACTIVE             0x89A6  /* 166 */
#define ERR_INVALID_RESOURCE_TAG        0x89A7  /* 167 */
#define ERR_ACCESS_DENIED               0x89A8  /* 168 */
#define ERR_AUDITING_NO_RIGHTS          0x89A8  /* 168 */
#define INVALID_DATA_STREAM             0x89BE  /* 190 */
#define INVALID_NAME_SPACE              0x89BF  /* 191 */
#define NO_ACCOUNTING_PRIVILEGES        0x89C0  /* 192 */
#define LOGIN_DENIED_NO_ACCOUNT_BALANCE 0x89C1  /* 193 */
#define LOGIN_DENIED_NO_CREDIT          0x89C2  /* 194 */
#define ERR_AUDITING_RECORD_SIZE        0x89C2  /* 194 */
#define ERR_TOO_MANY_HOLDS              0x89C3  /* 195 */
#define ACCOUNTING_DISABLED             0x89C4  /* 196 */
#define INTRUDER_DETECTION_LOCK         0x89C5  /* 197 */
#define NO_CONSOLE_OPERATOR             0x89C6  /* 198 */
#define NO_CONSOLE_PRIVILEGES           0x89C6  /* 198 */
#define ERR_Q_IO_FAILURE                0x89D0  /* 208 */
#define ERR_NO_QUEUE                    0x89D1  /* 209 */
#define ERR_NO_Q_SERVER                 0x89D2  /* 210 */
#define ERR_NO_Q_RIGHTS                 0x89D3  /* 211 */
#define ERR_Q_FULL                      0x89D4  /* 212 */
#define ERR_NO_Q_JOB                    0x89D5  /* 213 */
#define ERR_NO_Q_JOB_RIGHTS             0x89D6  /* 214 */
#define ERR_Q_IN_SERVICE                0x89D7  /* 215 */
#define PASSWORD_NOT_UNIQUE             0x89D7  /* 215 */
#define ERR_Q_NOT_ACTIVE                0x89D8  /* 216 */
#define PASSWORD_TOO_SHORT              0x89D8  /* 216 */
#define ERR_Q_STN_NOT_SERVER            0x89D9  /* 217 */
#define LOGIN_DENIED_NO_CONNECTION      0x89D9  /* 217 */
#define ERR_MAXIMUM_LOGINS_EXCEEDED     0x89D9  /* 217 */
#define ERR_Q_HALTED                    0x89DA  /* 218 */
#define UNAUTHORIZED_LOGIN_TIME         0x89DA  /* 218 */
#define UNAUTHORIZED_LOGIN_STATION      0x89DB  /* 219 */
#define ERR_Q_MAX_SERVERS               0x89DB  /* 219 */
#define ACCOUNT_DISABLED                0x89DC  /* 220 */
#define PASSWORD_HAS_EXPIRED_NO_GRACE   0x89DE  /* 222 */
#define PASSWORD_HAS_EXPIRED            0x89DF  /* 223 */
#define E_NO_MORE_USERS                 0x89E7  /* 231 */
#define NOT_ITEM_PROPERTY               0x89E8  /* 232 */
#define WRITE_PROPERTY_TO_GROUP         0x89E8  /* 232 */
#define MEMBER_ALREADY_EXISTS           0x89E9  /* 233 */
#define NO_SUCH_MEMBER                  0x89EA  /* 234 */
#define NOT_GROUP_PROPERTY              0x89EB  /* 235 */
#define NO_SUCH_SEGMENT                 0x89EC  /* 236 */
#define PROPERTY_ALREADY_EXISTS         0x89ED  /* 237 */
#define OBJECT_ALREADY_EXISTS           0x89EE  /* 238 */
#define INVALID_NAME                    0x89EF  /* 239 */
#define WILD_CARD_NOT_ALLOWED           0x89F0  /* 240 */
#define INVALID_BINDERY_SECURITY        0x89F1  /* 241 */
#define NO_OBJECT_READ_PRIVILEGE        0x89F2  /* 242 */
#define NO_OBJECT_RENAME_PRIVILEGE      0x89F3  /* 243 */
#define NO_OBJECT_DELETE_PRIVILEGE      0x89F4  /* 244 */
#define NO_OBJECT_CREATE_PRIVILEGE      0x89F5  /* 245 */
#define NO_PROPERTY_DELETE_PRIVILEGE    0x89F6  /* 246 */
#define NO_PROPERTY_CREATE_PRIVILEGE    0x89F7  /* 247 */
#define NO_PROPERTY_WRITE_PRIVILEGE     0x89F8  /* 248 */
#define NO_FREE_CONNECTION_SLOTS        0x89F9  /* 249 */
#define NO_PROPERTY_READ_PRIVILEGE      0x89F9  /* 249 */
#define NO_MORE_SERVER_SLOTS            0x89FA  /* 250 */
#define TEMP_REMAP_ERROR                0x89FA  /* 250 */
#define INVALID_PARAMETERS              0x89FB  /* 251 */
#define NO_SUCH_PROPERTY                0x89FB  /* 251 */
#define ERR_NCP_NOT_SUPPORTED           0x89FB  /* 251 */
#define INTERNET_PACKET_REQT_CANCELED   0x89FC  /* 252 */
#define UNKNOWN_FILE_SERVER             0x89FC  /* 252 */
#define MESSAGE_QUEUE_FULL              0x89FC  /* 252 */
#define NO_SUCH_OBJECT                  0x89FC  /* 252 */
#define LOCK_COLLISION                  0x89FD  /* 253 */
#define BAD_STATION_NUMBER              0x89FD  /* 253 */
#define INVALID_PACKET_LENGTH           0x89FD  /* 253 */
#define UNKNOWN_REQUEST                 0x89FD  /* 253 */
#define BINDERY_LOCKED                  0x89FE  /* 254 */
#define TRUSTEE_NOT_FOUND               0x89FE  /* 254 */
#define DIRECTORY_LOCKED                0x89FE  /* 254 */
#define INVALID_SEMAPHORE_NAME_LENGTH   0x89FE  /* 254 */
#define PACKET_NOT_DELIVERABLE          0x89FE  /* 254 */
#define SERVER_BINDERY_LOCKED           0x89FE  /* 254 */
#define SOCKET_TABLE_FULL               0x89FE  /* 254 */
#define SPOOL_DIRECTORY_ERROR           0x89FE  /* 254 */
#define SUPERVISOR_HAS_DISABLED_LOGIN   0x89FE  /* 254 */
#define TIMEOUT_FAILURE                 0x89FE  /* 254 */
#define BAD_PRINTER_ERROR               0x89FF  /* 255 */
#define BAD_RECORD_OFFSET               0x89FF  /* 255 */
#define CLOSE_FCB_ERROR                 0x89FF  /* 255 */
#define FILE_EXTENSION_ERROR            0x89FF  /* 255 */
#define FILE_NAME_ERROR                 0x89FF  /* 255 */
#define HARDWARE_FAILURE                0x89FF  /* 255 */
#define INVALID_DRIVE_NUMBER            0x89FF  /* 255 */
#define DOS_INVALID_DRIVE               0x000F  /* 255 */
#define INVALID_INITIAL_SEMAPHORE_VALUE 0x89FF  /* 255 */
#define INVALID_SEMAPHORE_HANDLE        0x89FF  /* 255 */
#define IO_BOUND_ERROR                  0x89FF  /* 255 */
#define NO_FILES_FOUND_ERROR            0x89FF  /* 255 */
#define NO_RESPONSE_FROM_SERVER         0x89FF  /* 255 */
#define NO_SUCH_OBJECT_OR_BAD_PASSWORD  0x89FF  /* 255 */
#define PATH_NOT_LOCATABLE              0x89FF  /* 255 */
#define QUEUE_FULL_ERROR                0x89FF  /* 255 */
#define REQUEST_NOT_OUTSTANDING         0x89FF  /* 255 */
#ifndef SOCKET_ALREADY_OPEN
#define SOCKET_ALREADY_OPEN             0x89FF  /* 255 */
#endif
#define LOCK_ERROR                      0x89FF  /* 255 */
#ifndef FAILURE
#define FAILURE                         0x89FF  /* 255 Generic Failure */
#endif

/* #define NOT_SAME_LOCAL_DRIVE         0x89F6 */
/* #define TARGET_DRIVE_NOT_LOCAL       0x89F7 */
/* #define ALREADY_ATTACHED_TO_SERVER   0x89F8 */ /* 248 */
/* #define NOT_ATTACHED_TO_SERVER       0x89F8 */

/**** Network errors ****/
/* Decimal values at end of line are 32768 lower than actual */

#define NWE_ALREADY_ATTACHED            0x8800  /* 0  - Attach attempted to server with valid, existing connection */
#define NWE_CONN_INVALID                0x8801  /* 1  - Request attempted with invalid or non-attached connection handle */
#define NWE_DRIVE_IN_USE                0x8802  /* 2  - OS/2 only (NOT USED) */
#define NWE_DRIVE_CANNOT_MAP            0x8803  /* 3  - Map drive attempted but unable to add new current directory structure */
#define NWE_DRIVE_BAD_PATH              0x8804  /* 4  - Map drive attempted with invalid path specification */
#define NWE_NET_RECEIVE                 0x8805  /* 5  - Attempt to receive from the selected transport failed */
#define NWE_NET_UNKNOWN                 0x8806  /* 6  - Network send attempted with an un-specific network error */
#define NWE_SERVER_BAD_SLOT             0x8807  /* 7  - Server request attempted with invalid server connection slot */
#define NWE_SERVER_NO_SLOTS             0x8808  /* 8  - Attach attempted to server with no connection slots available */
#define NWE_NET_SEND                    0x8809  /* 9  - Attempt to send on the selected transport failed */
#define NWE_SERVER_NO_ROUTE             0x880A  /* 10 - Attempted to find route to server where no route exists */
#define NWE_BAD_LOCAL_TARGET            0x880B  /* 11 - OS/2 only */
#define NWE_REQ_TOO_MANY_REQ_FRAGS      0x880C  /* 12 - Attempted request with too many request fragments specified */
#define NWE_CONN_LIST_OVERFLOW          0x880D  /* 13 */
#define NWE_BUFFER_OVERFLOW             0x880E  /* 14 - Attempt to receive more data than the reply buffer had room for */
#define NWE_SERVER_NO_CONN              0x880F  /* 15 - Attempt to get connection for a server not connected */
#define NWE_NO_ROUTER_FOUND             0x8810  /* 16 - OS/2 only */
#define NWE_FUNCTION_INVALID            0x8811  /* 17 - Attempted function call to non- existent or illegal function */
#define NWE_SCAN_COMPLETE               0x8812
#define NWE_UNSUPPORTED_NAME_FORMAT_TYP 0x8813
#define NWE_HANDLE_ALREADY_LICENSED     0x8814
#define NWE_HANDLE_ALREADY_UNLICENSED   0x8815
#define NWE_INVALID_NCP_PACKET_LENGTH   0x8816
#define NWE_SETTING_UP_TIMEOUT          0x8817
#define NWE_SETTING_SIGNALS             0x8818
#define NWE_SERVER_CONNECTION_LOST      0x8819
#define NWE_OUT_OF_HEAP_SPACE           0x881A
#define NWE_INVALID_SERVICE_REQUEST     0x881B
#define NWE_INVALID_TASK_NUMBER         0x881C
#define NWE_INVALID_MESSAGE_LENGTH      0x881D
#define NWE_EA_SCAN_DONE                0x881E
#define NWE_BAD_CONNECTION_NUMBER       0x881F
#define NWE_MULT_TREES_NOT_SUPPORTED    0x8820  /* 32 - Attempt to open a connection to a DS tree other than the default tree */
#define NWE_CONN_NOT_SAME               0x8830  /* 48 - Internal server request attempted across different server connections */
#define NWE_CONN_PRIMARY_NOT_SET        0x8831  /* 49 - Attempt to retrieve default connection with no primary connection set */
#define NWE_PRN_CAPTURE_NOT_IN_PROGRESS 0x8832  /* 50 - Capture information requested on port with no capture in progress */
#define NWE_BUFFER_INVALID_LEN          0x8833  /* 51 - Used to indicate length which caller requested on a GetDNC or SetDNC was too large */
#define NWE_USER_NO_NAME                0x8834  /* 52 */
#define NWE_PRN_NO_LOCAL_SPOOLER        0x8835  /* 53 - Capture requested without having the local print spooler installed */
#define NWE_PARAM_INVALID               0x8836  /* 54 - Attempted function with an invalid function parameter specified */
#define NWE_CFG_OPEN_FAILED             0x8837  /* 55 - OS/2 only */
#define NWE_CFG_NO_FILE                 0x8838  /* 56 - OS/2 only */
#define NWE_CFG_READ_FAILED             0x8839  /* 57 - OS/2 only */
#define NWE_CFG_LINE_TOO_LONG           0x883A  /* 58 - OS/2 only */
#define NWE_CFG_LINES_IGNORED           0x883B  /* 59 - OS/2 only */
#define NWE_RESOURCE_NOT_OWNED          0x883C  /* 60 - Attempted request made with a parameter using foriegn resource */
#define NWE_DAEMON_INSTALLED            0x883D  /* 61 - OS/2 only */
#define NWE_PRN_SPOOLER_INSTALLED       0x883E  /* 62 - Attempted load of print spooler with print spooler already installed */
#define NWE_CONN_TABLE_FULL             0x883F  /* 63 - Attempted to allocate a connection handle with no more local connection table entries */
#define NWE_CFG_SECTION_NOT_FOUND       0x8840  /* 64 - OS/2 only */
#define NWE_TRAN_INVALID_TYPE           0x8841  /* 65 - Attempted function on a connection with an invalid transport selected */
#define NWE_TDS_TAG_IN_USE              0x8842  /* 66 - OS/2 only */
#define NWE_TDS_OUT_OF_MEMORY           0x8843  /* 67 - OS/2 only */
#define NWE_TDS_INVALID_TAG             0x8844  /* 68 - Attempted TDS function with invalid tag */
#define NWE_TDS_WRITE_TRUNCATED         0x8845  /* 69 - Attempted TDS write with buffer that exceeded buffer */
#define NWE_DS_NO_CONN                  0x8846  /* 70 */
#define NWE_SERVICE_BUSY                0x8846  /* 70 - Attempted request made to partially asynchronous function in busy state */
#define NWE_SERVER_NOT_FOUND            0x8847  /* 71 - Attempted connect failed to find any servers responding */
#define NWE_VLM_INVALID                 0x8848  /* 72 - Attempted function call to non-existant or not-loaded overlay */
#define NWE_DRIVE_ALREADY_MAPPED        0x8849  /* 73 - Attempted map to network drive that was already mapped */
#define NWE_DRIVE_LOCAL_IN_USE          0x884A  /* 74 - Attempted map to local drive that was in use */
#define NWE_DRIVE_NONE_AVAILABLE        0x884B  /* 75 - Attempted map to next available drive when none were available */
#define NWE_DEVICE_NOT_REDIRECTED       0x884C  /* 76 - The device is not redirected */
#define NWE_FILE_MAX_REACHED            0x884D  /* 77 - Maximum number of files was reached */
#define NWE_UNLOAD_FAILED               0x884E  /* 78 - Attempted unload failed */
#define NWE_CONN_IN_USE                 0x884F  /* 79 - Attempted re-use of already in use connection entry */
#define NWE_REQ_TOO_MANY_REP_FRAGS      0x8850  /* 80 - Attempted request with too many reply fragments specified */
#define NWE_NAME_TABLE_FULL             0x8851  /* 81 - Attempted to add a name into the name table after it was full */
#define NWE_SOCKET_NOT_OPEN             0x8852  /* 82 - Listen was posted on unopened socket */
#define NWE_MEMORY_MGR_ERROR            0x8853  /* 83 - Attempted enhanced memory operation failed */
#define NWE_SFT3_ERROR                  0x8854  /* 84 - An SFT3 switch occured mid-transfer */
#define NWE_DS_PREFERRED_NOT_FOUND      0x8855  /* 85 - the preferred directory server was not established but another directory server was returned */
#define NWE_DEVICE_NOT_RECOGNIZED       0x8856  /* 86 - used to determine if the device is not used by VISE so pass it on to the next redirector, if any. */
#define NWE_NET_INVALID_TYPE            0x8857  /* 87 - the network type (Bind/NDS) does not match the server version */
#define NWE_FILE_OPEN_FAILED            0x8858  /* 88 - generic open failure error, invalid path, access denied, etc.. */
#define NWE_DS_PREFERRED_NOT_SPECIFIED  0x8859  /* 89 - no preferred name specified */
#define NWE_SOCKET_OPEN_FAILED          0x885A  /* 90 - error opening a socket */
#define NWE_SIGNATURE_LEVEL_CONFLICT    0x8861
#define NWE_NO_LOCK_FOUND               0x8862  /* OS/2 - process lock on conn handle failed, process ID not recognized */
#define NWE_LOCK_TABLE_FULL             0x8863  /* OS/2 - process lock on conn handle failed, process lock table full */
#define NWE_INVALID_MATCH_DATA          0x8864
#define NWE_MATCH_FAILED                0x8865
#define NWE_NO_MORE_ENTRIES             0x8866
#define NWE_INSUFFICIENT_RESOURCES      0x8867
#define NWE_STRING_TRANSLATION          0x8868
#define NWE_ACCESS_VIOLATION            0x8869
#define NWE_NOT_AUTHENTICATED           0x886A
#define NWE_INVALID_LEVEL               0x886B
#define NWE_RESOURCE_LOCK               0x886C
#define NWE_INVALID_NAME_FORMAT         0x886D
#define NWE_OBJECT_EXISTS               0x886E
#define NWE_OBJECT_NOT_FOUND            0x886F
#define NWE_UNSUPPORTED_TRAN_TYPE       0x8870
#define NWE_INVALID_STRING_TYPE         0x8871
#define NWE_INVALID_OWNER               0x8872
#define NWE_UNSUPPORTED_AUTHENTICATOR   0x8873
#define NWE_IO_PENDING                  0x8874
#define NWE_INVALID_DRIVE_NUMBER        0x8875
#define NWE_REPLY_TRUNCATED            0x88e6    /* 230 NLM */
#define NWE_REQUESTER_FAILURE           0x88FF

/* Server Errors */

#define NWE_INSUFFICIENT_SPACE          0x8901  /* 001 */
#define NWE_BUFFER_TOO_SMALL            0x8977  /* 119 */
#define NWE_VOL_FLAG_NOT_SET            0x8978  /* 120 the service requested, not avail. on the selected vol. */
#define NWE_NO_ITEMS_FOUND              0x8979  /* 121 */
#define NWE_CONN_ALREADY_TEMP           0x897a  /* 122 */
#define NWE_CONN_ALREADY_LOGGED_IN      0x897b  /* 123 */
#define NWE_CONN_NOT_AUTHENTICATED      0x897c  /* 124 */
#define NWE_CONN_NOT_LOGGED_IN          0x897d  /* 125 */
#define NWE_NCP_BOUNDARY_CHECK_FAILED   0x897e  /* 126 */
#define NWE_LOCK_WAITING                0x897f  /* 127 */
#define NWE_LOCK_FAIL                   0x8980  /* 128 */
#define NWE_FILE_IN_USE                 0x8980  /* 128 */
#define NWE_FILE_NO_HANDLES             0x8981  /* 129 */
#define NWE_FILE_NO_OPEN_PRIV           0x8982  /* 130 */
#define NWE_DISK_IO_ERROR               0x8983  /* 131 */
#define NWE_AUDITING_HARD_IO_ERROR      0x8983  /* 131 */
#define NWE_FILE_NO_CREATE_PRIV         0x8984  /* 132 */
#define NWE_AUDITING_NOT_SUPV           0x8984  /* 132 */
#define NWE_FILE_NO_CREATE_DEL_PRIV     0x8985  /* 133 */
#define NWE_FILE_EXISTS_READ_ONLY       0x8986  /* 134 */
#define NWE_FILE_WILD_CARDS_IN_NAME     0x8987  /* 135 */
#define NWE_FILE_INVALID_HANDLE         0x8988  /* 136 */
#define NWE_FILE_NO_SRCH_PRIV           0x8989  /* 137 */
#define NWE_FILE_NO_DEL_PRIV            0x898A  /* 138 */
#define NWE_FILE_NO_RENAME_PRIV         0x898B  /* 139 */
#define NWE_FILE_NO_MOD_PRIV            0x898C  /* 140 */
#define NWE_FILE_SOME_IN_USE            0x898D  /* 141 */
#define NWE_FILE_NONE_IN_USE            0x898E  /* 142 */
#define NWE_FILE_SOME_READ_ONLY         0x898F  /* 143 */
#define NWE_FILE_NONE_READ_ONLY         0x8990  /* 144 */
#define NWE_FILE_SOME_RENAMED_EXIST     0x8991  /* 145 */
#define NWE_FILE_NONE_RENAMED_EXIST     0x8992  /* 146 */
#define NWE_FILE_NO_READ_PRIV           0x8993  /* 147 */
#define NWE_FILE_NO_WRITE_PRIV          0x8994  /* 148 */
#define NWE_FILE_READ_ONLY              0x8994  /* 148 */
#define NWE_FILE_DETACHED               0x8995  /* 149 */
#define NWE_SERVER_OUT_OF_MEMORY        0x8996  /* 150 */
#define NWE_DIR_TARGET_INVALID          0x8996  /* 150 */
#define NWE_DISK_NO_SPOOL_SPACE         0x8997  /* 151 */
#define NWE_AUDITING_NOT_ENABLED        0x8997  /* 151 */
#define NWE_VOL_INVALID                 0x8998  /* 152 */
#define NWE_DIR_FULL                    0x8999  /* 153 */
#define NWE_VOL_RENAMING_ACROSS         0x899A  /* 154 */
#define NWE_DIRHANDLE_INVALID           0x899B  /* 155 */
#define NWE_PATH_INVALID                0x899C  /* 156 */
#define NWE_TRUSTEES_NO_MORE            0x899C  /* 156 */
#define NWE_DIRHANDLE_NO_MORE           0x899D  /* 157 */
#define NWE_FILE_NAME_INVALID           0x899E  /* 158 */
#define NWE_DIR_ACTIVE                  0x899F  /* 159 */
#define NWE_DIR_NOT_EMPTY               0x89A0  /* 160 */
#define NWE_DIR_IO_ERROR                0x89A1  /* 161 */
#define NWE_FILE_IO_LOCKED              0x89A2  /* 162 */
#define NWE_TTS_RANSACTION_RESTARTED    0x89A3  /* 163 */
#define NWE_TTS_TRANSACTION_RESTARTED   0x89A3  /* 163 */
#define NWE_DIR_RENAME_INVALID          0x89A4  /* 164 */
#define NWE_FILE_OPENCREAT_MODE_INVALID 0x89A5  /* 165 */
#define NWE_ALREADY_IN_USE              0x89A6  /* 166 */
#define NWE_AUDITING_ACTIVE             0x89A6  /* 166 */
#define NWE_RESOURCE_TAG_INVALID        0x89A7  /* 167 */
#define NWE_ACCESS_DENIED               0x89A8  /* 168 */
#define NWE_AUDITING_NO_RIGHTS          0x89A8  /* 168 */
#define NWE_DATA_STREAM_INVALID         0x89BE  /* 190 */
#define NWE_NAME_SPACE_INVALID          0x89BF  /* 191 */
#define NWE_ACCTING_NO_PRIV             0x89C0  /* 192 */
#define NWE_ACCTING_NO_BALANCE          0x89C1  /* 193 */
#define NWE_ACCTING_NO_CREDIT           0x89C2  /* 194 */
#define NWE_AUDITING_RECORD_SIZE        0x89C2  /* 194 */
#define NWE_ACCTING_TOO_MANY_HOLDS      0x89C3  /* 195 */
#define NWE_ACCTING_DISABLED            0x89C4  /* 196 */
#define NWE_LOGIN_LOCKOUT               0x89C5  /* 197 */
#define NWE_CONSOLE_NO_PRIV             0x89C6  /* 198 */
#define NWE_Q_IO_FAILURE                0x89D0  /* 208 */
#define NWE_Q_NONE                      0x89D1  /* 209 */
#define NWE_Q_NO_SERVER                 0x89D2  /* 210 */
#define NWE_Q_NO_RIGHTS                 0x89D3  /* 211 */
#define NWE_Q_FULL                      0x89D4  /* 212 */
#define NWE_Q_NO_JOB                    0x89D5  /* 213 */
#define NWE_Q_NO_JOB_RIGHTS             0x89D6  /* 214 */
#define NWE_PASSWORD_UNENCRYPTED        0x89D6  /* 214 */
#define NWE_Q_IN_SERVICE                0x89D7  /* 215 */
#define NWE_PASSWORD_NOT_UNIQUE         0x89D7  /* 215 */
#define NWE_Q_NOT_ACTIVE                0x89D8  /* 216 */
#define NWE_PASSWORD_TOO_SHORT          0x89D8  /* 216 */
#define NWE_Q_STN_NOT_SERVER            0x89D9  /* 217 */
#define NWE_LOGIN_NO_CONN               0x89D9  /* 217 */
#define NWE_LOGIN_MAX_EXCEEDED          0x89D9  /* 217 */
#define NWE_Q_HALTED                    0x89DA  /* 218 */
#define NWE_LOGIN_UNAUTHORIZED_TIME     0x89DA  /* 218 */
#define NWE_LOGIN_UNAUTHORIZED_STATION  0x89DB  /* 219 */
#define NWE_Q_MAX_SERVERS               0x89DB  /* 219 */
#define NWE_ACCT_DISABLED               0x89DC  /* 220 */
#define NWE_PASSWORD_INVALID            0x89DE  /* 222 */
#define NWE_PASSWORD_EXPIRED            0x89DF  /* 223 */
#define NWE_LOGIN_NO_CONN_AVAIL         0x89E0  /* 224 */
#define NWE_E_NO_MORE_USERS             0x89E7  /* 231 */
#define NWE_BIND_NOT_ITEM_PROP          0x89E8  /* 232 */
#define NWE_BIND_WRITE_TO_GROUP_PROP    0x89E8  /* 232 */
#define NWE_BIND_MEMBER_ALREADY_EXISTS  0x89E9  /* 233 */
#define NWE_BIND_NO_SUCH_MEMBER         0x89EA  /* 234 */
#define NWE_BIND_NOT_GROUP_PROP         0x89EB  /* 235 */
#define NWE_BIND_NO_SUCH_SEGMENT        0x89EC  /* 236 */
#define NWE_BIND_PROP_ALREADY_EXISTS    0x89ED  /* 237 */
#define NWE_BIND_OBJ_ALREADY_EXISTS     0x89EE  /* 238 */
#define NWE_BIND_NAME_INVALID           0x89EF  /* 239 */
#define NWE_BIND_WILDCARD_INVALID       0x89F0  /* 240 */
#define NWE_BIND_SECURITY_INVALID       0x89F1  /* 241 */
#define NWE_BIND_OBJ_NO_READ_PRIV       0x89F2  /* 242 */
#define NWE_BIND_OBJ_NO_RENAME_PRIV     0x89F3  /* 243 */
#define NWE_BIND_OBJ_NO_DELETE_PRIV     0x89F4  /* 244 */
#define NWE_BIND_OBJ_NO_CREATE_PRIV     0x89F5  /* 245 */
#define NWE_BIND_PROP_NO_DELETE_PRIV    0x89F6  /* 246 */
#define NWE_BIND_PROP_NO_CREATE_PRIV    0x89F7  /* 247 */
#define NWE_BIND_PROP_NO_WRITE_PRIV     0x89F8  /* 248 */
#define NWE_BIND_PROP_NO_READ_PRIV      0x89F9  /* 249 */
#define NWE_NO_FREE_CONN_SLOTS          0x89F9  /* 249 */
#define NWE_NO_MORE_SERVER_SLOTS        0x89FA  /* 250 */
#define NWE_TEMP_REMAP_ERROR            0x89FA  /* 250 */
#define NWE_PARAMETERS_INVALID          0x89FB  /* 251 */
#define NWE_BIND_NO_SUCH_PROP           0x89FB  /* 251 */
#define NWE_NCP_NOT_SUPPORTED           0x89FB  /* 251 */
#define NWE_INET_PACKET_REQ_CANCELED    0x89FC  /* 252 */
#define NWE_SERVER_UNKNOWN              0x89FC  /* 252 */
#define NWE_MSG_Q_FULL                  0x89FC  /* 252 */
#define NWE_BIND_NO_SUCH_OBJ            0x89FC  /* 252 */
#define NWE_LOCK_COLLISION              0x89FD  /* 253 */
#define NWE_CONN_NUM_INVALID            0x89FD  /* 253 */
#define NWE_PACKET_LEN_INVALID          0x89FD  /* 253 */
#define NWE_UNKNOWN_REQ                 0x89FD  /* 253 */
#define NWE_BIND_LOCKED                 0x89FE  /* 254 */
#define NWE_TRUSTEE_NOT_FOUND           0x89FE  /* 254 */
#define NWE_DIR_LOCKED                  0x89FE  /* 254 */
#define NWE_SEM_INVALID_NAME_LEN        0x89FE  /* 254 */
#define NWE_PACKET_NOT_DELIVERABLE      0x89FE  /* 254 */
#define NWE_SOCKET_TABLE_FULL           0x89FE  /* 254 */
#define NWE_SPOOL_DIR_ERROR             0x89FE  /* 254 */
#define NWE_LOGIN_DISABLED_BY_SUPER     0x89FE  /* 254 */
#define NWE_TIMEOUT_FAILURE             0x89FE  /* 254 */
#define NWE_FILE_EXT                    0x89FF  /* 255 */
#define NWE_FILE_NAME                   0x89FF  /* 255 */
#define NWE_HARD_FAILURE                0x89FF  /* 255 */
#define NWE_FCB_CLOSE                   0x89FF  /* 255 */
#define NWE_IO_BOUND                    0x89FF  /* 255 */
#define NWE_BAD_SPOOL_PRINTER           0x89FF  /* 255 */
#define NWE_BAD_RECORD_OFFSET           0x89FF  /* 255 */
#define NWE_DRIVE_INVALID_NUM           0x89FF  /* 255 */
#define NWE_SEM_INVALID_INIT_VAL        0x89FF  /* 255 */
#define NWE_SEM_INVALID_HANDLE          0x89FF  /* 255 */
#define NWE_NO_FILES_FOUND_ERROR        0x89FF  /* 255 */
#define NWE_NO_RESPONSE_FROM_SERVER     0x89FF  /* 255 */
#define NWE_NO_OBJ_OR_BAD_PASSWORD      0x89FF  /* 255 */
#define NWE_PATH_NOT_LOCATABLE          0x89FF  /* 255 */
#define NWE_Q_FULL_ERROR                0x89FF  /* 255 */
#define NWE_REQ_NOT_OUTSTANDING         0x89FF  /* 255 */
#define NWE_SOCKET_ALREADY_OPEN         0x89FF  /* 255 */
#define NWE_LOCK_ERROR                  0x89FF  /* 255 */
#define NWE_FAILURE                     0x89FF  /* 255 Generic Failure */

#endif /* !_NWERROR_H_ */


code:
/*-
 * Copyright (c) 2000-2001 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netsmb/netbios.h 206361 2010-04-07 16:50:38Z joel $
 */
#ifndef _NETSMB_NETBIOS_H_
#define	_NETSMB_NETBIOS_H_

/*
 * make this file dirty...
 */
#ifndef _NETINET_IN_H_
#include <netinet/in.h>
#endif

#ifndef _NETIPX_IPX_H_
#include <netipx/ipx.h>
#endif

#define	NMB_TCP_PORT	137

#define	NBPROTO_TCPSSN	1		/* NETBIOS session over TCP */
#define	NBPROTO_IPXSSN	11		/* NETBIOS over IPX */

#define NB_NAMELEN	16
#define	NB_ENCNAMELEN	NB_NAMELEN * 2
#define	NB_MAXLABLEN	63

#define	NB_MINSALEN	(sizeof(struct sockaddr_nb))

/*
 * name types
 */
#define	NBT_WKSTA		0x00
#define	NBT_MESSENGER		0x03
#define	NBT_RAS_SERVER		0x06
#define	NBT_DOMAIN_MASTER_BROWSER	0x1B
#define	NBT_DOMAIN_CONTROLLER	0x1C
#define	NBT_MASTER_BROWSER	0x1D
#define	NBT_NETDDE		0x1F
#define	NBT_SERVER		0x20
#define	NBT_RAS_CLIENT		0x21

/*
 * Session packet types
 */
#define	NB_SSN_MESSAGE		0x0
#define	NB_SSN_REQUEST		0x81
#define	NB_SSN_POSRESP		0x82
#define	NB_SSN_NEGRESP		0x83
#define	NB_SSN_RTGRESP		0x84
#define	NB_SSN_KEEPALIVE	0x85

/*
 * resolver: Opcodes
 */
#define	NBNS_OPCODE_QUERY	0x00
#define	NBNS_OPCODE_REGISTER	0x05
#define	NBNS_OPCODE_RELEASE	0x06
#define	NBNS_OPCODE_WACK	0x07
#define	NBNS_OPCODE_REFRESH	0x08
#define	NBNS_OPCODE_RESPONSE	0x10	/* or'ed with other opcodes */

/*
 * resolver: NM_FLAGS
 */
#define	NBNS_NMFLAG_BCAST	0x01
#define	NBNS_NMFLAG_RA		0x08	/* recursion available */
#define	NBNS_NMFLAG_RD		0x10	/* recursion desired */
#define	NBNS_NMFLAG_TC		0x20	/* truncation occurred */
#define	NBNS_NMFLAG_AA		0x40	/* authoritative answer */

/*
 * resolver: Question types
 */
#define	NBNS_QUESTION_TYPE_NB		0x0020
#define NBNS_QUESTION_TYPE_NBSTAT	0x0021

/*
 * resolver: Question class
 */
#define NBNS_QUESTION_CLASS_IN	0x0001

/*
 * resolver: Limits
 */
#define	NBNS_MAXREDIRECTS	3	/* maximum number of accepted redirects */
#define	NBDG_MAXSIZE		576	/* maximum nbns datagram size */

/*
 * NETBIOS addressing
 */
union nb_tran {
	struct sockaddr_in	x_in;
	struct sockaddr_ipx	x_ipx;
};

struct nb_name {
	u_int		nn_type;
	u_char		nn_name[NB_NAMELEN + 1];
	u_char *	nn_scope;
};

/*
 * Socket address
 */
struct sockaddr_nb {
	u_char		snb_len;
	u_char		snb_family;
	union nb_tran	snb_tran;		/* transport */
	u_char		snb_name[1 + NB_ENCNAMELEN + 1];	/* encoded */
};

#define	snb_addrin	snb_tran.x_in

#endif /* !_NETSMB_NETBIOS_H_ */


code:
/*-
 * Copyright (c) 2000-2001 Boris Popov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD: release/9.0.0/sys/netsmb/smb.h 206361 2010-04-07 16:50:38Z joel $
 */

/*
 * Common definitions and structures for SMB/CIFS protocol
 */

#ifndef _NETSMB_SMB_H_
#define _NETSMB_SMB_H_

#define	SMB_TCP_PORT	139
/*
 * SMB dialects that we have to deal with.
 */
enum smb_dialects {
	SMB_DIALECT_NONE,
	SMB_DIALECT_CORE,		/* PC NETWORK PROGRAM 1.0, PCLAN1.0 */
	SMB_DIALECT_COREPLUS,		/* MICROSOFT NETWORKS 1.03 */
	SMB_DIALECT_LANMAN1_0,		/* MICROSOFT NETWORKS 3.0, LANMAN1.0 */
	SMB_DIALECT_LANMAN2_0,		/* LM1.2X002, DOS LM1.2X002, Samba */
	SMB_DIALECT_LANMAN2_1,		/* DOS LANMAN2.1, LANMAN2.1 */
	SMB_DIALECT_NTLM0_12		/* NT LM 0.12, Windows for Workgroups 3.1a,
					 * NT LANMAN 1.0 */
};

/*
 * Formats of data/string buffers
 */
#define	SMB_DT_DATA		1
#define	SMB_DT_DIALECT		2
#define	SMB_DT_PATHNAME		3
#define	SMB_DT_ASCII		4
#define	SMB_DT_VARIABLE		5

/*
 * SMB header
 */
#define	SMB_SIGNATURE		"\xFFSMB"
#define	SMB_SIGLEN		4
#define	SMB_HDRMID(p)		(le16toh(*(u_short*)((u_char*)(p) + 30)))
#define	SMB_HDRLEN		32
/*
 * bits in the smb_flags field
 */
#define	SMB_FLAGS_CASELESS	0x08
#define SMB_FLAGS_SERVER_RESP	0x80	/* indicates a response */

/*
 * bits in the smb_flags2 field
 */
#define	SMB_FLAGS2_KNOWS_LONG_NAMES	0x0001
#define	SMB_FLAGS2_KNOWS_EAS		0x0002	/* client know about EAs */
#define	SMB_FLAGS2_SECURITY_SIGNATURE	0x0004	/* check SMB integrity */
#define	SMB_FLAGS2_IS_LONG_NAME		0x0040	/* any path name is a long name */
#define	SMB_FLAGS2_EXT_SEC		0x0800	/* client aware of Extended
						 * Security negotiation */
#define	SMB_FLAGS2_DFS			0x1000	/* resolve paths in DFS */
#define	SMB_FLAGS2_PAGING_IO		0x2000	/* for exec */
#define	SMB_FLAGS2_ERR_STATUS		0x4000	/* 1 - status.status */
#define	SMB_FLAGS2_UNICODE		0x8000	/* use Unicode for all strings */

#define	SMB_UID_UNKNOWN		0xffff
#define	SMB_TID_UNKNOWN		0xffff

/*
 * Security mode bits
 */
#define SMB_SM_USER		0x01		/* server in the user security mode */
#define	SMB_SM_ENCRYPT		0x02		/* use challenge/response */
#define	SMB_SM_SIGS		0x04
#define	SMB_SM_SIGS_REQUIRE	0x08

/*
 * NTLM capabilities
 */
#define	SMB_CAP_RAW_MODE		0x0001
#define	SMB_CAP_MPX_MODE		0x0002
#define	SMB_CAP_UNICODE			0x0004
#define	SMB_CAP_LARGE_FILES		0x0008		/* 64 bit offsets supported */
#define	SMB_CAP_NT_SMBS			0x0010
#define	SMB_CAP_RPC_REMOTE_APIS		0x0020
#define	SMB_CAP_STATUS32		0x0040
#define	SMB_CAP_LEVEL_II_OPLOCKS	0x0080
#define	SMB_CAP_LOCK_AND_READ		0x0100
#define	SMB_CAP_NT_FIND			0x0200
#define	SMB_CAP_DFS			0x1000
#define	SMB_CAP_INFOLEVEL_PASSTHRU	0x2000
#define	SMB_CAP_LARGE_READX		0x4000
#define	SMB_CAP_LARGE_WRITEX		0x8000
#define	SMB_CAP_UNIX			0x00800000
#define	SMB_CAP_BULK_TRANSFER		0x20000000
#define	SMB_CAP_COMPRESSED_DATA		0x40000000
#define	SMB_CAP_EXT_SECURITY		0x80000000

/*
 * File attributes
 */
#define	SMB_FA_RDONLY		0x01
#define	SMB_FA_HIDDEN		0x02
#define	SMB_FA_SYSTEM		0x04
#define	SMB_FA_VOLUME		0x08
#define	SMB_FA_DIR		0x10
#define	SMB_FA_ARCHIVE		0x20

/*
 * Extended file attributes
 */
#define	SMB_EFA_RDONLY		0x0001
#define	SMB_EFA_HIDDEN		0x0002
#define	SMB_EFA_SYSTEM		0x0004
#define	SMB_EFA_DIRECTORY	0x0010
#define	SMB_EFA_ARCHIVE		0x0020
#define	SMB_EFA_NORMAL		0x0080
#define	SMB_EFA_TEMPORARY	0x0100
#define	SMB_EFA_COMPRESSED	0x0800
#define	SMB_EFA_POSIX_SEMANTICS	0x01000000
#define	SMB_EFA_BACKUP_SEMANTICS 0x02000000
#define	SMB_EFA_DELETE_ON_CLOSE	0x04000000
#define	SMB_EFA_SEQUENTIAL_SCAN	0x08000000
#define	SMB_EFA_RANDOM_ACCESS	0x10000000
#define	SMB_EFA_NO_BUFFERING	0x20000000
#define	SMB_EFA_WRITE_THROUGH	0x80000000

/*
 * Access Mode Encoding
 */
#define	SMB_AM_OPENREAD		0x0000
#define	SMB_AM_OPENWRITE	0x0001
#define	SMB_AM_OPENRW		0x0002
#define	SMB_AM_OPENEXEC		0x0003
#define	SMB_SM_COMPAT		0x0000
#define	SMB_SM_EXCLUSIVE	0x0010
#define	SMB_SM_DENYWRITE	0x0020
#define	SMB_SM_DENYREADEXEC	0x0030
#define	SMB_SM_DENYNONE		0x0040

/*
 * SMB commands
 */
#define	SMB_COM_CREATE_DIRECTORY        0x00
#define	SMB_COM_DELETE_DIRECTORY        0x01
#define	SMB_COM_OPEN                    0x02
#define	SMB_COM_CREATE                  0x03
#define	SMB_COM_CLOSE                   0x04
#define	SMB_COM_FLUSH                   0x05
#define	SMB_COM_DELETE                  0x06
#define	SMB_COM_RENAME                  0x07
#define	SMB_COM_QUERY_INFORMATION       0x08
#define	SMB_COM_SET_INFORMATION         0x09
#define	SMB_COM_READ                    0x0A
#define	SMB_COM_WRITE                   0x0B
#define	SMB_COM_LOCK_BYTE_RANGE         0x0C
#define	SMB_COM_UNLOCK_BYTE_RANGE       0x0D
#define	SMB_COM_CREATE_TEMPORARY        0x0E
#define	SMB_COM_CREATE_NEW              0x0F
#define	SMB_COM_CHECK_DIRECTORY         0x10
#define	SMB_COM_PROCESS_EXIT            0x11
#define	SMB_COM_SEEK                    0x12
#define	SMB_COM_LOCK_AND_READ           0x13
#define	SMB_COM_WRITE_AND_UNLOCK        0x14
#define	SMB_COM_READ_RAW                0x1A
#define	SMB_COM_READ_MPX                0x1B
#define	SMB_COM_READ_MPX_SECONDARY      0x1C
#define	SMB_COM_WRITE_RAW               0x1D
#define	SMB_COM_WRITE_MPX               0x1E
#define	SMB_COM_WRITE_COMPLETE          0x20
#define	SMB_COM_SET_INFORMATION2        0x22
#define	SMB_COM_QUERY_INFORMATION2      0x23
#define	SMB_COM_LOCKING_ANDX            0x24
#define	SMB_COM_TRANSACTION             0x25
#define	SMB_COM_TRANSACTION_SECONDARY   0x26
#define	SMB_COM_IOCTL                   0x27
#define	SMB_COM_IOCTL_SECONDARY         0x28
#define	SMB_COM_COPY                    0x29
#define	SMB_COM_MOVE                    0x2A
#define	SMB_COM_ECHO                    0x2B
#define	SMB_COM_WRITE_AND_CLOSE         0x2C
#define	SMB_COM_OPEN_ANDX               0x2D
#define	SMB_COM_READ_ANDX               0x2E
#define	SMB_COM_WRITE_ANDX              0x2F
#define	SMB_COM_CLOSE_AND_TREE_DISC     0x31
#define	SMB_COM_TRANSACTION2            0x32
#define	SMB_COM_TRANSACTION2_SECONDARY  0x33
#define	SMB_COM_FIND_CLOSE2             0x34
#define	SMB_COM_FIND_NOTIFY_CLOSE       0x35
#define	SMB_COM_TREE_CONNECT		0x70
#define	SMB_COM_TREE_DISCONNECT         0x71
#define	SMB_COM_NEGOTIATE               0x72
#define	SMB_COM_SESSION_SETUP_ANDX      0x73
#define	SMB_COM_LOGOFF_ANDX             0x74
#define	SMB_COM_TREE_CONNECT_ANDX       0x75
#define	SMB_COM_QUERY_INFORMATION_DISK  0x80
#define	SMB_COM_SEARCH                  0x81
#define	SMB_COM_FIND                    0x82
#define	SMB_COM_FIND_UNIQUE             0x83
#define	SMB_COM_NT_TRANSACT             0xA0
#define	SMB_COM_NT_TRANSACT_SECONDARY   0xA1
#define	SMB_COM_NT_CREATE_ANDX          0xA2
#define	SMB_COM_NT_CANCEL               0xA4
#define	SMB_COM_OPEN_PRINT_FILE         0xC0
#define	SMB_COM_WRITE_PRINT_FILE        0xC1
#define	SMB_COM_CLOSE_PRINT_FILE        0xC2
#define	SMB_COM_GET_PRINT_QUEUE         0xC3
#define	SMB_COM_READ_BULK               0xD8
#define	SMB_COM_WRITE_BULK              0xD9
#define	SMB_COM_WRITE_BULK_DATA         0xDA

/*
 * TRANS2 commands
 */
#define	SMB_TRANS2_OPEN2			0x00
#define	SMB_TRANS2_FIND_FIRST2			0x01
#define	SMB_TRANS2_FIND_NEXT2			0x02
#define	SMB_TRANS2_QUERY_FS_INFORMATION		0x03
#define	SMB_TRANS2_QUERY_PATH_INFORMATION	0x05
#define	SMB_TRANS2_SET_PATH_INFORMATION		0x06
#define	SMB_TRANS2_QUERY_FILE_INFORMATION	0x07
#define	SMB_TRANS2_SET_FILE_INFORMATION		0x08
#define	SMB_TRANS2_FSCTL			0x09
#define	SMB_TRANS2_IOCTL2			0x0A
#define	SMB_TRANS2_FIND_NOTIFY_FIRST		0x0B
#define	SMB_TRANS2_FIND_NOTIFY_NEXT		0x0C
#define	SMB_TRANS2_CREATE_DIRECTORY		0x0D
#define	SMB_TRANS2_SESSION_SETUP		0x0E
#define	SMB_TRANS2_GET_DFS_REFERRAL		0x10
#define	SMB_TRANS2_REPORT_DFS_INCONSISTENCY	0x11

/*
 * SMB_TRANS2_QUERY_FS_INFORMATION levels
 */
#define SMB_INFO_ALLOCATION		1
#define SMB_INFO_VOLUME			2
#define SMB_QUERY_FS_VOLUME_INFO	0x102
#define SMB_QUERY_FS_SIZE_INFO		0x103
#define SMB_QUERY_FS_DEVICE_INFO	0x104
#define SMB_QUERY_FS_ATTRIBUTE_INFO	0x105

/*
 * SMB_TRANS2_QUERY_PATH levels
 */
#define	SMB_QUERY_FILE_STANDARD			1
#define	SMB_QUERY_FILE_EA_SIZE			2
#define	SMB_QUERY_FILE_EAS_FROM_LIST		3
#define	SMB_QUERY_FILE_ALL_EAS			4
#define	SMB_QUERY_FILE_IS_NAME_VALID		6
#define	SMB_QUERY_FILE_BASIC_INFO		0x101
#define	SMB_QUERY_FILE_STANDARD_INFO		0x102
#define	SMB_QUERY_FILE_EA_INFO			0x103
#define	SMB_QUERY_FILE_NAME_INFO		0x104
#define	SMB_QUERY_FILE_ALL_INFO			0x107
#define	SMB_QUERY_FILE_ALT_NAME_INFO		0x108
#define	SMB_QUERY_FILE_STREAM_INFO		0x109
#define	SMB_QUERY_FILE_COMPRESSION_INFO		0x10b
#define	SMB_QUERY_FILE_UNIX_BASIC		0x200
#define	SMB_QUERY_FILE_UNIX_LINK		0x201
#define	SMB_QUERY_FILE_MAC_DT_GET_APPL		0x306
#define	SMB_QUERY_FILE_MAC_DT_GET_ICON		0x307
#define	SMB_QUERY_FILE_MAC_DT_GET_ICON_INFO	0x308

/*
 * SMB_TRANS2_FIND_FIRST2 information levels
 */
#define SMB_INFO_STANDARD		1
#define SMB_INFO_QUERY_EA_SIZE		2
#define SMB_INFO_QUERY_EAS_FROM_LIST	3
#define SMB_FIND_FILE_DIRECTORY_INFO	0x101
#define SMB_FIND_FULL_DIRECTORY_INFO	0x102
#define SMB_FIND_FILE_NAMES_INFO	0x103
#define SMB_FIND_BOTH_DIRECTORY_INFO	0x104

/*
 * Set PATH/FILE information levels
 */
#define	SMB_SET_FILE_BASIC_INFO		0x101
#define	SMB_SET_FILE_END_OF_FILE_INFO	0x104

/*
 * LOCKING_ANDX LockType flags
 */
#define SMB_LOCKING_ANDX_SHARED_LOCK	0x01
#define SMB_LOCKING_ANDX_OPLOCK_RELEASE	0x02
#define SMB_LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
#define SMB_LOCKING_ANDX_CANCEL_LOCK	0x08
#define SMB_LOCKING_ANDX_LARGE_FILES	0x10

/*
 * Some names length limitations. Some of them aren't declared by specs,
 * but we need reasonable limits.
 */
#define SMB_MAXSRVNAMELEN	15	/* NetBIOS limit */
#define SMB_MAXUSERNAMELEN	128
#define SMB_MAXPASSWORDLEN	128
#define	SMB_MAXSHARENAMELEN	128
#define	SMB_MAXPKTLEN		0x1FFFF
#define	SMB_MAXCHALLENGELEN	8
#define	SMB_MAXFNAMELEN		255	/* Keep in sync with MAXNAMLEN */

#define	SMB_MAXRCN		3	/* number of reconnect attempts */

/*
 * Error classes
 */
#define SMBSUCCESS	0x00
#define ERRDOS		0x01
#define ERRSRV		0x02
#define ERRHRD		0x03	/* Error is a hardware error. */
#define ERRCMD		0xFF	/* Command was not in the "SMB" format. */

/*
 * Error codes for the ERRDOS class
 */
#define ERRbadfunc	1	/* Invalid function */
#define ERRbadfile	2	/* File not found (last component) */
#define ERRbadpath	3	/* Directory invalid */
#define ERRnofids	4	/* Too many open files */
#define ERRnoaccess	5	/* Access denied */
#define ERRbadfid	6	/* Invalid file handle */
#define ERRbadmcb	7	/* Memory control blocks destroyed (huh ?) */
#define ERRnomem	8	/* Insufficient memory */
#define ERRbadmem	9	/* Invalid memory block address */
#define ERRbadenv	10	/* Invalid environment */
#define ERRbadformat	11	/* Invalid format */
#define ERRbadaccess	12	/* Invalid open mode */
#define ERRbaddata	13	/* Invalid data */
#define ERRbaddrive	15	/* Invalid drive specified */
#define ERRremcd	16	/* An attempt to delete current directory */
#define ERRdiffdevice	17	/* cross fs rename/move */
#define ERRnofiles	18	/* no more files found in file search */
#define ERRbadshare	32	/* Share mode can't be granted */
#define ERRlock		33	/* A lock request conflicts with existing lock */
#define ERRunsup	50	/* unsupported - Win 95 */
#define ERRnoipc	66	/* ipc unsupported */
#define ERRnosuchshare	67	/* invalid share name */
#define ERRfilexists	80	/* The file named in the request already exists */
#define	ERRquota	112	/* W2K returns this if quota space exceeds */
#define ERRcannotopen	110	/* cannot open the file */
#define ERRinvalidname	123
#define ERRunknownlevel 124
#define ERRnotlocked	158	/* region was not locked by this context */
#define ERRrename	183
#define ERRbadpipe	230	/* named pipe invalid */
#define ERRpipebusy	231	/* all pipe instances are busy */
#define ERRpipeclosing	232	/* close in progress */
#define ERRnotconnected	233	/* nobody on other end of pipe */
#define ERRmoredata	234	/* more data to be returned */
#define ERRbaddirectory	267	/* invalid directory name */
#define ERReasunsupported	282	/* extended attributes not supported */
#define ERRunknownipc	2142
#define ERRbuftoosmall	2123
#define ERRnosuchprintjob	2151

/*
 * Error codes for the ERRSRV class
 */
#define ERRerror	1	/* Non-specific error code */
#define ERRbadpw	2	/* Bad password */
#define ERRbadtype	3	/* reserved */
#define ERRaccess	4	/* The client doesn't have enough access rights */
#define ERRinvnid	5	/* The Tid specified in a command is invalid */
#define ERRinvnetname	6	/* Invalid server name in the tree connect */
#define ERRinvdevice	7	/* Printer and not printer devices are mixed */
#define ERRqfull	49	/* Print queue full */
#define ERRqtoobig	50	/* Print queue full - no space */
#define ERRinvpfid	52	/* Invalid print file FID */
#define ERRsmbcmd	64	/* The server did not recognize the command */
#define ERRsrverror	65	/* The server encountered and internal error */
#define ERRfilespecs	67	/* The Fid and path name contains an invalid combination */
#define ERRbadpermits	69	/* Access mode invalid */
#define ERRsetattrmode	71	/* Attribute mode invalid */
#define ERRpaused	81	/* Server is paused */
#define ERRmsgoff	82	/* Not receiving messages */
#define ERRnoroom	83	/* No room to buffer message */
#define ERRrmuns	87	/* Too many remote user names */
#define ERRtimeout	88	/* Operation timed out */
#define ERRnoresource	89	/* No resources currently available for request */
#define ERRtoomanyuids	90      /* Too many UIDs active on this session */
#define ERRbaduid	91	/* The UID is not known in this session */
#define ERRusempx	250	/* Temporarily unable to support Raw, use MPX mode */
#define ERRusestd	251	/* Temporarily unable to support Raw, use standard r/w */
#define ERRcontmpx	252	/* Continue in MPX mode */
#define ERRbadPassword	254
#define	ERRaccountExpired 2239
#define	ERRbadClient	2240	/* Cannot access the server from this workstation */
#define	ERRbadLogonTime	2241	/* Cannot access the server at this time **/
#define	ERRpasswordExpired 2242
#define ERRnosupport	65535	/* Invalid function */

/*
 * Error codes for the ERRHRD class
 */
#define ERRnowrite	19	/* write protected media */
#define ERRbadunit	20	/* Unknown unit */
#define ERRnotready	21	/* Drive not ready */
#define ERRbadcmd	22	/* Unknown command */
#define ERRdata		23	/* Data error (CRC) */
#define ERRbadreq	24	/* Bad request structure length */
#define ERRseek		25	/* Seek error */
#define ERRbadmedia	26	/* Unknown media type */
#define ERRbadsector	27	/* Sector not found */
#define ERRnopaper	28	/* Printer out of paper */
#define ERRwrite	29	/* Write fault */
#define ERRread		30	/* Read fault */
#define ERRgeneral	31	/* General failure */
#define	ERRbadshare	32	/* An open conflicts with an existing open */
#define	ERRlock		33	/* lock/unlock conflict */
#define ERRwrongdisk	34	/* The wrong disk was found in a drive */
#define ERRFCBunavail	35	/* No FCBs available */
#define ERRsharebufexc	36	/* A sharing buffer has been exceeded */
#define ERRdiskfull	39

/*
 * RAP error codes (it seems that they returned not only by RAP)
 */
#define	SMB_ERROR_ACCESS_DENIED		5
#define	SMB_ERROR_NETWORK_ACCESS_DENIED	65
#define	SMB_ERROR_MORE_DATA		234

typedef u_int16_t	smbfh;

#endif /* _NETSMB_SMB_H_ */