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