windows-smb-and-symlinks-20041213
[openafs.git] / src / WINNT / afsd / smb3.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __SMB3_H_ENV__
11 #define __SMB3_H_ENV__ 1
12
13 typedef struct smb_tran2Packet {
14         osi_queue_t q;                  /* queue of all packets */
15                 int com;                        /* Trans or Trans2 (0x25 or 0x32) */
16         int totalData;                  /* total # of expected data bytes */
17         int totalParms;                 /* total # of expected parm bytes */
18         int oldTotalParms;              /* initial estimate of parm bytes */
19         int curData;                    /* current # of received data bytes */
20         int curParms;                   /* current # of received parm bytes */
21         int maxReturnData;              /* max # of returned data bytes */
22         int maxReturnParms;             /* max # of returned parm bytes */
23         int opcode;                     /* subopcode we're handling */
24         long flags;                     /* flags */
25         smb_vc_t *vcp;                  /* virtual circuit we're dealing with */
26         unsigned short tid;             /* tid to match */
27         unsigned short mid;             /* mid to match */
28         unsigned short pid;             /* pid to remember */
29         unsigned short uid;             /* uid to remember */
30         unsigned short res[6];          /* contains PidHigh */
31         unsigned short *parmsp;         /* parms */
32         unsigned char *datap;           /* data bytes */
33 } smb_tran2Packet_t;
34
35 /* for flags field */
36 #define SMB_TRAN2PFLAG_ALLOC    1
37
38 typedef struct smb_tran2Dispatch {
39         long (*procp)(smb_vc_t *, smb_tran2Packet_t *, smb_packet_t *);
40         long flags;
41 } smb_tran2Dispatch_t;
42
43 typedef struct smb_tran2QFSInfo {
44     union {
45 #pragma pack(push, 2)
46         struct {
47             long FSID;                  /* file system ID */
48             long sectorsPerAllocUnit;
49             long totalAllocUnits;               /* on the disk */
50             long availAllocUnits;               /* free blocks */
51             unsigned short bytesPerSector;      /* bytes per sector */
52         } allocInfo;
53 #pragma pack(pop)
54         struct {
55             long vsn;           /* volume serial number */
56             char vnCount;       /* count of chars in label, incl null */
57             char label[12];     /* pad out with nulls */
58         } volumeInfo;
59         struct {
60             FILETIME vct;       /* volume creation time */
61             long vsn;           /* volume serial number */
62             long vnCount;       /* length of volume label in bytes */
63             char res[2];        /* reserved */
64             char label[10];     /* volume label */
65         } FSvolumeInfo;
66         struct {
67             osi_hyper_t totalAllocUnits;        /* on the disk */
68             osi_hyper_t availAllocUnits;        /* free blocks */
69             long sectorsPerAllocUnit;
70             long bytesPerSector;                /* bytes per sector */
71         } FSsizeInfo;
72         struct {
73             long devType;       /* device type */
74             long characteristics;
75         } FSdeviceInfo;
76         struct {
77             long attributes;
78             long maxCompLength; /* max path component length */
79             long FSnameLength;  /* length of file system name */
80             char FSname[12];
81         } FSattributeInfo;
82     } u;
83 } smb_tran2QFSInfo_t;
84
85 /* more than enough opcodes for today, anyway */
86 #define SMB_TRAN2_NOPCODES              20
87
88 extern smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES];
89
90 #define SMB_RAP_NOPCODES        64
91
92 extern smb_tran2Dispatch_t smb_rapDispatchTable[SMB_RAP_NOPCODES];
93
94 extern long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
95
96 extern long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
97
98 extern long smb_ReceiveV3Trans(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
99
100 extern long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
101
102 extern long smb_ReceiveRAPNetShareEnum(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
103
104 extern long smb_ReceiveRAPNetShareGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
105
106 extern long smb_ReceiveRAPNetWkstaGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
107
108 extern long smb_ReceiveRAPNetServerGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
109
110 extern long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p,
111         smb_packet_t *outp);
112
113 extern long smb_ReceiveTran2FindFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
114         smb_packet_t *outp);
115
116 extern long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p,
117         smb_packet_t *outp);
118
119 extern long smb_ReceiveTran2FindNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
120         smb_packet_t *outp);
121
122 extern long smb_ReceiveTran2QFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
123         smb_packet_t *outp);
124
125 extern long smb_ReceiveTran2SetFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
126         smb_packet_t *outp);
127
128 extern long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
129         smb_packet_t *outp);
130
131 extern long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
132         smb_packet_t *outp);
133
134 extern long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
135         smb_packet_t *outp);
136
137 extern long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
138         smb_packet_t *outp);
139
140 extern long smb_ReceiveTran2FSCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
141         smb_packet_t *outp);
142
143 extern long smb_ReceiveTran2IOCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
144         smb_packet_t *outp);
145
146 extern long smb_ReceiveTran2FindNotifyFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
147         smb_packet_t *outp);
148
149 extern long smb_ReceiveTran2FindNotifyNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
150         smb_packet_t *outp);
151
152 extern long smb_ReceiveTran2CreateDirectory(smb_vc_t *vcp, smb_tran2Packet_t *p,
153         smb_packet_t *outp);
154
155 extern long smb_ReceiveTran2SessionSetup(smb_vc_t *vcp, smb_tran2Packet_t *p,
156         smb_packet_t *outp);
157
158 extern long smb_ReceiveTran2GetDFSReferral(smb_vc_t *vcp, smb_tran2Packet_t *p,
159         smb_packet_t *outp);
160
161 extern long smb_ReceiveTran2ReportDFSInconsistency(smb_vc_t *vcp, smb_tran2Packet_t *p,
162         smb_packet_t *outp);
163
164 extern long smb_ReceiveV3FindClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
165
166 extern long smb_ReceiveV3FindNotifyClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
167
168 extern long smb_ReceiveV3UserLogoffX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
169
170 extern long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
171
172 extern long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
173
174 extern long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
175
176 extern long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
177
178 extern long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
179
180 extern long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
181
182 extern long smb_ReceiveNTTransact(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
183
184 extern void smb_NotifyChange(DWORD action, DWORD notifyFilter,
185         cm_scache_t *dscp, char *filename, char *otherFilename,
186         BOOL isDirectParent);
187
188 extern long smb_ReceiveNTCancel(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
189
190 extern long smb_ReceiveNTRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
191
192 extern int smb_V3MatchMask(char *namep, char *maskp, int flags);
193
194 extern void smb3_Init();
195 extern cm_user_t *smb_FindCMUserByName(/*smb_vc_t *vcp,*/ char *usern, char *machine);
196
197 /* SMB auth related functions */
198 extern void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength);
199
200 #ifdef DJGPP
201 #define DELETE (0x00010000)
202 #define READ_CONTROL (0x00020000)
203 #define SYNCHRONIZE (0x00100000)
204 #define FILE_WRITE_ATTRIBUTES ( 0x0100 )
205 #define FILE_GENERIC_READ (0x00120089)
206 #define FILE_GENERIC_WRITE (0x00120116)
207 #define FILE_GENERIC_EXECUTE (0x001200a0)
208 #endif /* DJGPP */
209
210 #endif /*  __SMB3_H_ENV__ */