smb-auth-20040711
[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 totalData;                  /* total # of expected data bytes */
16         int totalParms;                 /* total # of expected parm bytes */
17         int oldTotalParms;              /* initial estimate of parm bytes */
18         int curData;                    /* current # of received data bytes */
19         int curParms;                   /* current # of received parm bytes */
20         int maxReturnData;              /* max # of returned data bytes */
21         int maxReturnParms;             /* max # of returned parm bytes */
22         int opcode;                     /* subopcode we're handling */
23         long flags;                     /* flags */
24         smb_vc_t *vcp;                  /* virtual circuit we're dealing with */
25         unsigned short tid;             /* tid to match */
26         unsigned short mid;             /* mid to match */
27         unsigned short pid;             /* pid to remember */
28         unsigned short uid;             /* uid to remember */
29         unsigned short res[6];          /* contains PidHigh */
30         unsigned short *parmsp;         /* parms */
31         unsigned char *datap;           /* data bytes */
32 } smb_tran2Packet_t;
33
34 /* for flags field */
35 #define SMB_TRAN2PFLAG_ALLOC    1
36
37 typedef struct smb_tran2Dispatch {
38         long (*procp)(smb_vc_t *, smb_tran2Packet_t *, smb_packet_t *);
39         long flags;
40 } smb_tran2Dispatch_t;
41
42 typedef struct smb_tran2QFSInfo {
43         union {
44 #pragma pack(push, 2)
45                 struct {
46                         long FSID;                      /* file system ID */
47                         long sectorsPerAllocUnit;
48                         long totalAllocUnits;           /* on the disk */
49                         long availAllocUnits;           /* free blocks */
50                         unsigned short bytesPerSector;  /* bytes per sector */
51                 } allocInfo;
52 #pragma pack(pop)
53                 struct {
54                         long vsn;       /* volume serial number */
55                         char vnCount;   /* count of chars in label, incl null */
56                         char label[12]; /* pad out with nulls */
57                 } volumeInfo;
58                 struct {
59                         FILETIME vct;   /* volume creation time */
60                         long vsn;       /* volume serial number */
61                         long vnCount;   /* length of volume label in bytes */
62                         char res[2];    /* reserved */
63                         char label[10]; /* volume label */
64                 } FSvolumeInfo;
65                 struct {
66                         osi_hyper_t totalAllocUnits;    /* on the disk */
67                         osi_hyper_t availAllocUnits;    /* free blocks */
68                         long sectorsPerAllocUnit;
69                         long bytesPerSector;            /* bytes per sector */
70                 } FSsizeInfo;
71                 struct {
72                         long devType;   /* device type */
73                         long characteristics;
74                 } FSdeviceInfo;
75                 struct {
76                         long attributes;
77                         long maxCompLength;     /* max path component length */
78                         long FSnameLength;      /* length of file system name */
79                         char FSname[12];
80                 } FSattributeInfo;
81         } u;
82 } smb_tran2QFSInfo_t;
83
84 /* more than enough opcodes for today, anyway */
85 #define SMB_TRAN2_NOPCODES              20
86
87 extern smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES];
88
89 extern long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
90
91 extern long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
92
93 extern long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
94
95 extern long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p,
96         smb_packet_t *outp);
97
98 extern long smb_ReceiveTran2FindFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
99         smb_packet_t *outp);
100
101 extern long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p,
102         smb_packet_t *outp);
103
104 extern long smb_ReceiveTran2FindNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
105         smb_packet_t *outp);
106
107 extern long smb_ReceiveTran2QFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
108         smb_packet_t *outp);
109
110 extern long smb_ReceiveTran2SetFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
111         smb_packet_t *outp);
112
113 extern long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
114         smb_packet_t *outp);
115
116 extern long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
117         smb_packet_t *outp);
118
119 extern long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
120         smb_packet_t *outp);
121
122 extern long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
123         smb_packet_t *outp);
124
125 extern long smb_ReceiveTran2FSCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
126         smb_packet_t *outp);
127
128 extern long smb_ReceiveTran2IOCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
129         smb_packet_t *outp);
130
131 extern long smb_ReceiveTran2FindNotifyFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
132         smb_packet_t *outp);
133
134 extern long smb_ReceiveTran2FindNotifyNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
135         smb_packet_t *outp);
136
137 extern long smb_ReceiveTran2MKDir(smb_vc_t *vcp, smb_tran2Packet_t *p,
138         smb_packet_t *outp);
139
140 extern long smb_ReceiveV3FindClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
141
142 extern long smb_ReceiveV3FindNotifyClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
143
144 extern long smb_ReceiveV3UserLogoffX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
145
146 extern long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
147
148 extern long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
149
150 extern long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
151
152 extern long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
153
154 extern long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
155
156 extern long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
157
158 extern long smb_ReceiveNTTransact(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
159
160 extern void smb_NotifyChange(DWORD action, DWORD notifyFilter,
161         cm_scache_t *dscp, char *filename, char *otherFilename,
162         BOOL isDirectParent);
163
164 extern long smb_ReceiveNTCancel(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
165
166 extern int smb_V3MatchMask(char *namep, char *maskp, int flags);
167
168 extern void smb3_Init();
169 extern cm_user_t *smb_FindCMUserByName(/*smb_vc_t *vcp,*/ char *usern, char *machine);
170
171 /* SMB auth related functions */
172 extern void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength);
173
174 #ifdef DJGPP
175 #define DELETE (0x00010000)
176 #define READ_CONTROL (0x00020000)
177 #define SYNCHRONIZE (0x00100000)
178 #define FILE_WRITE_ATTRIBUTES ( 0x0100 )
179 #define FILE_GENERIC_READ (0x00120089)
180 #define FILE_GENERIC_WRITE (0x00120116)
181 #define FILE_GENERIC_EXECUTE (0x001200a0)
182 #endif /* DJGPP */
183
184 #endif /*  __SMB3_H_ENV__ */