1284345Ssjg/*
2284345Ssjg *  ncp.h
3284345Ssjg */
4284345Ssjg/*-
5284345Ssjg *  Copyright (C) 1995 by Volker Lendecke
6284345Ssjg *  New version derived from original ncp.h, 1998 Boris Popov
7284345Ssjg *
8284345Ssjg * $FreeBSD$
9284345Ssjg */
10284345Ssjg
11284345Ssjg#ifndef _NETNCP_NCP_H_
12284345Ssjg#define _NETNCP_NCP_H_
13284345Ssjg
14284345Ssjg#define NCP_VERMAJ	1
15284345Ssjg#define NCP_VERMIN	3500
16284345Ssjg#define NCP_VERSION	(NCP_VERMAJ*100000 + NCP_VERMIN)
17284345Ssjg
18284345Ssjgtypedef u_int32_t	nwdirent;
19
20typedef char		nstr8;
21typedef	nstr8*		pnstr8;
22typedef u_int8_t	nuint8;
23typedef u_int8_t*	pnuint8;
24typedef u_int16_t	nuint16;
25typedef	nuint16*	pnuint16;
26typedef u_int32_t	nuint32;
27typedef	nuint32*	pnuint32;
28
29
30#define NCP_DEFAULT_BUFSIZE 	1024
31#define NCP_MAX_BUFSIZE		1024
32#define NCP_MAX_PACKET_SIZE 	4070
33#define	NCP_MAXUSERNAMELEN	255
34#define	NCP_MAXPASSWORDLEN	255
35#define NCP_MAXPATHLEN		255
36#define NCP_MAX_FILENAME 	14
37#define NCP_FILE_ID_LEN		6
38
39#define NCP_BINDERY_USER	0x0001
40#define NCP_BINDERY_UGROUP	0x0002
41#define NCP_BINDERY_PQUEUE	0x0003
42#define NCP_BINDERY_FSERVER	0x0004
43#define NCP_BINDERY_PSERVER	0x0007
44#define NCP_BINDERY_NAME_LEN	48
45
46/* Handle Flags */
47#define	NCP_HF_DIRSHORT		0		/* short directory handle */
48#define	NCP_HF_DIRBASE		1		/* directory base */
49#define	NCP_HF_NONE		0xff		/* no handle or dirbase */
50
51/* Options to negotiate */
52#define	NCP_IPX_CHECKSUM		1
53#define	NCP_SECURITY_LEVEL_SIGN_HEADERS	2
54
55#ifndef NWCONN_HANDLE
56#define NWCONN_HANDLE   unsigned int
57#define pNWCONN_HANDLE  (unsigned int*)
58#define NWCONN_NUM      u_int16_t
59#define NWCCODE         unsigned int
60#define NWDIR_HANDLE    u_int8_t
61#define NWFILE_HANDLE   int
62#endif
63
64struct ncp_fh_s {
65	u_int16_t val1;
66	union {
67		u_int32_t val32;
68		u_int16_t val16;
69	} val;
70} __packed;
71
72typedef	struct ncp_fh_s ncp_fh;
73
74typedef struct ncpfid_s {
75	nwdirent	f_parent;
76	nwdirent	f_id;
77} ncpfid;
78
79/* -- Bindery properties -- */
80struct ncp_bindery_object {
81	u_int32_t	object_id;
82	u_int16_t	object_type;
83	u_int8_t	object_name[NCP_BINDERY_NAME_LEN];
84	u_int8_t	object_flags;
85	u_int8_t	object_security;
86	u_int8_t	object_has_prop;
87};
88
89struct nw_property {
90	u_int8_t	value[128];
91	u_int8_t	more_flag;
92	u_int8_t	property_flag;
93};
94
95struct ncp_filesearch_info {
96	u_int8_t	volume_number;
97	u_int16_t	directory_id;
98	u_int16_t	sequence_no;
99	u_int8_t	access_rights;
100};
101
102
103struct ncp_file_info {
104	u_int8_t	file_id[NCP_FILE_ID_LEN];
105	char		file_name[NCP_MAX_FILENAME + 1];
106	u_int8_t	file_attributes;
107	u_int8_t	file_mode;
108	u_int32_t	file_length;
109	u_int16_t	creation_date;
110	u_int16_t	access_date;
111	u_int16_t	update_date;
112	u_int16_t	update_time;
113};
114
115struct nw_queue_job_entry {
116	u_int16_t	InUse;
117	u_int32_t	prev;
118	u_int32_t	next;
119	u_int32_t	ClientStation;
120	u_int32_t	ClientTask;
121	u_int32_t	ClientObjectID;
122	u_int32_t	TargetServerID;
123	u_int8_t	TargetExecTime[6];
124	u_int8_t	JobEntryTime[6];
125	u_int32_t	JobNumber;
126	u_int16_t	JobType;
127	u_int16_t	JobPosition;
128	u_int16_t	JobControlFlags;
129	u_int8_t	FileNameLen;
130	char		JobFileName[13];
131	u_int32_t	JobFileHandle;
132	u_int32_t	ServerStation;
133	u_int32_t	ServerTaskNumber;
134	u_int32_t	ServerObjectID;
135	char		JobTextDescription[50];
136	char		ClientRecordArea[152];
137} __packed;
138
139struct queue_job {
140	struct nw_queue_job_entry j;
141	ncp_fh file_handle;
142};
143
144#define QJE_OPER_HOLD	0x80
145#define QJE_USER_HOLD	0x40
146#define QJE_ENTRYOPEN	0x20
147#define QJE_SERV_RESTART    0x10
148#define QJE_SERV_AUTO	    0x08
149
150/* ClientRecordArea for print jobs */
151
152#define   KEEP_ON        0x0400
153#define   NO_FORM_FEED   0x0800
154#define   NOTIFICATION   0x1000
155#define   DELETE_FILE    0x2000
156#define   EXPAND_TABS    0x4000
157#define   PRINT_BANNER   0x8000
158
159struct print_job_record {
160	u_int8_t	Version;
161	u_int8_t	TabSize;
162	u_int16_t	Copies;
163	u_int16_t	CtrlFlags;
164	u_int16_t	Lines;
165	u_int16_t	Rows;
166	char		FormName[16];
167	u_int8_t	Reserved[6];
168	char		BannerName[13];
169	char		FnameBanner[13];
170	char		FnameHeader[14];
171	char		Path[80];
172} __packed;
173
174struct ncp_station_addr {
175	u_int32_t	NetWork;
176	u_int8_t	Node[6];
177	u_int16_t	Socket;
178} __packed;
179
180struct ncp_prop_login_control {
181	u_int8_t	AccountExpireDate[3];
182	u_int8_t	Disabled;
183	u_int8_t	PasswordExpireDate[3];
184	u_int8_t	GraceLogins;
185	u_int16_t	PasswordExpireInterval;
186	u_int8_t	MaxGraceLogins;
187	u_int8_t	MinPasswordLength;
188	u_int16_t	MaxConnections;
189	u_int8_t	ConnectionTimeMask[42];
190	u_int8_t	LastLogin[6];
191	u_int8_t	RestrictionMask;
192	u_int8_t	reserved;
193	u_int32_t	MaxDiskUsage;
194	u_int16_t	BadLoginCount;
195	u_int32_t	BadLoginCountDown;
196	struct ncp_station_addr LastIntruder;
197} __packed;
198
199#define NCP_VOLNAME_LEN (16)
200#define NCP_NUMBER_OF_VOLUMES (64)
201struct ncp_volume_info {
202	u_int32_t total_blocks;
203	u_int32_t free_blocks;
204	u_int32_t purgeable_blocks;
205	u_int32_t not_yet_purgeable_blocks;
206	u_int32_t total_dir_entries;
207	u_int32_t available_dir_entries;
208	u_int8_t sectors_per_block;
209	char volume_name[NCP_VOLNAME_LEN + 1];
210};
211/*
212 * Name space constants, taken from NDK
213 */
214#define aRONLY     (ntohl(0x01000000))
215#define aHIDDEN    (ntohl(0x02000000))
216#define aSYSTEM    (ntohl(0x04000000))
217#define aEXECUTE   (ntohl(0x08000000))
218#define aDIR       (ntohl(0x10000000))
219#define aARCH      (ntohl(0x20000000))
220
221/* Defines for Name Spaces */
222#define NW_NS_DOS     0
223#define NW_NS_MAC     1
224#define NW_NS_NFS     2
225#define NW_NS_FTAM    3
226#define NW_NS_OS2     4
227
228/* for _ScanNSEntryInfo */
229#define	IM_NAME			0x00000001
230#define	IM_SPACE_ALLOCATED	0x00000002
231#define IM_ATTRIBUTES		0x00000004
232#define IM_SIZE			0x00000008
233#define IM_TOTAL_SIZE		0x00000010
234#define IM_EA			0x00000020
235#define IM_ARCHIVE		0x00000040
236#define IM_MODIFY		0x00000080
237#define IM_CREATION		0x00000100
238#define IM_OWNING_NAMESPACE	0x00000200
239#define IM_DIRECTORY		0x00000400
240#define IM_RIGHTS		0x00000800
241#define	IM_ALMOST_ALL		0x00000FED
242#define IM_ALL			0x00000FFF
243#define	IM_REFERENCE_ID		0x00001000
244#define	IM_NS_ATTRIBUTES	0x00002000
245#define IM_COMPRESSED_INFO	0x80000000UL
246
247/* open/create modes */
248#define OC_MODE_OPEN		0x01
249#define OC_MODE_TRUNCATE	0x02
250#define OC_MODE_REPLACE		0x02
251#define OC_MODE_CREATE		0x08
252
253/* open/create results */
254#define OC_ACTION_NONE		0x00
255#define OC_ACTION_OPEN		0x01
256#define OC_ACTION_CREATE	0x02
257#define OC_ACTION_TRUNCATE	0x04
258#define OC_ACTION_REPLACE	0x04
259
260/* renameFlag in NSRename */
261#define	NW_TYPE_FILE		0x8000
262#define	NW_TYPE_SUBDIR		0x0010
263
264#define	NW_NAME_CONVERT		0x0003	/* don't report error and set comp mode */
265#define	NW_NO_NAME_CONVERT	0x0004	/* only in specified name space */
266
267/* search attributes */
268#ifndef SA_HIDDEN
269#define SA_NORMAL         0x0000
270#define SA_HIDDEN         0x0002
271#define SA_SYSTEM         0x0004
272#define SA_SUBDIR_ONLY    0x0010
273#define SA_SUBDIR_FILES   0x8000
274#define SA_ALL            0x8006
275#endif
276
277/* access rights attributes */
278#ifndef AR_READ
279#define AR_READ			0x0001
280#define AR_WRITE		0x0002
281#define AR_READ_ONLY		0x0001
282#define AR_WRITE_ONLY		0x0002
283#define AR_DENY_READ		0x0004
284#define AR_DENY_WRITE		0x0008
285#define AR_COMPATIBILITY	0x0010
286#define AR_WRITE_THROUGH	0x0040
287#define AR_OPEN_COMPRESSED	0x0100
288#endif
289
290struct nw_entry_info {
291	u_int32_t	spaceAlloc;
292	u_int32_t	attributes;	/* LH */
293	u_int16_t	flags;		/* internal */
294	u_int32_t	dataStreamSize;
295	u_int32_t	totalStreamSize;
296	u_int16_t	numberOfStreams;
297	u_int16_t	creationTime;	/* LH */
298	u_int16_t	creationDate;	/* LH */
299	u_int32_t	creatorID;	/* HL */
300	u_int16_t	modifyTime;	/* LH */
301	u_int16_t	modifyDate;	/* LH */
302	u_int32_t	modifierID;	/* HL */
303	u_int16_t	lastAccessDate;	/* LH */
304	u_int16_t	archiveTime;	/* LH */
305	u_int16_t	archiveDate;	/* LH */
306	u_int32_t	archiverID;	/* HL */
307	u_int16_t	inheritedRightsMask;	/* LH */
308	u_int32_t	dirEntNum;
309	u_int32_t	DosDirNum;
310	u_int32_t	volNumber;
311	u_int32_t	EADataSize;
312	u_int32_t	EAKeyCount;
313	u_int32_t	EAKeySize;
314	u_int32_t	NSCreator;
315	u_int8_t	nameLen;
316	u_int8_t	entryName[256];
317} __packed;
318
319typedef struct nw_entry_info NW_ENTRY_INFO;
320
321/* modify mask - use with MODIFY_DOS_INFO structure */
322#define DM_ATTRIBUTES		0x0002L
323#define DM_CREATE_DATE		0x0004L
324#define DM_CREATE_TIME		0x0008L
325#define DM_CREATOR_ID		0x0010L
326#define DM_ARCHIVE_DATE		0x0020L
327#define DM_ARCHIVE_TIME		0x0040L
328#define DM_ARCHIVER_ID		0x0080L
329#define DM_MODIFY_DATE		0x0100L
330#define DM_MODIFY_TIME		0x0200L
331#define DM_MODIFIER_ID		0x0400L
332#define DM_LAST_ACCESS_DATE	0x0800L
333#define DM_INHERITED_RIGHTS_MASK	0x1000L
334#define DM_MAXIMUM_SPACE	0x2000L
335
336struct nw_modify_dos_info {
337	u_int32_t attributes;
338	u_int16_t creationDate;
339	u_int16_t creationTime;
340	u_int32_t creatorID;
341	u_int16_t modifyDate;
342	u_int16_t modifyTime;
343	u_int32_t modifierID;
344	u_int16_t archiveDate;
345	u_int16_t archiveTime;
346	u_int32_t archiverID;
347	u_int16_t lastAccessDate;
348	u_int16_t inheritanceGrantMask;
349	u_int16_t inheritanceRevokeMask;
350	u_int32_t maximumSpace;
351}  __packed;
352
353struct nw_search_seq {
354	u_int8_t	volNumber;
355	u_int32_t	dirNumber;
356	u_int32_t	searchDirNumber;
357}  __packed;
358
359typedef struct nw_search_seq SEARCH_SEQUENCE;
360
361struct ncp_file_server_info {
362	u_int8_t	ServerName[48];
363	u_int8_t	FileServiceVersion;
364	u_int8_t	FileServiceSubVersion;
365	u_int16_t	MaximumServiceConnections;
366	u_int16_t	ConnectionsInUse;
367	u_int16_t	NumberMountedVolumes;
368	u_int8_t	Revision;
369	u_int8_t	SFTLevel;
370	u_int8_t	TTSLevel;
371	u_int16_t	MaxConnectionsEverUsed;
372	u_int8_t	AccountVersion;
373	u_int8_t	VAPVersion;
374	u_int8_t	QueueVersion;
375	u_int8_t	PrintVersion;
376	u_int8_t	VirtualConsoleVersion;
377	u_int8_t	RestrictionLevel;
378	u_int8_t	InternetBridge;
379	u_int8_t	Reserved[60];
380} __packed;
381
382struct nw_time_buffer {
383	u_int8_t	year;
384	u_int8_t	month;
385	u_int8_t	day;
386	u_int8_t	hour;
387	u_int8_t	minute;
388	u_int8_t	second;
389	u_int8_t	wday;
390} __packed;
391
392#endif /*_NCP_H_ */
393