1 |
|
|
2 |
/* UNIX SMBlib NetBIOS implementation |
/* UNIX SMBlib NetBIOS implementation |
3 |
|
|
4 |
Version 1.0 |
Version 1.0 |
30 |
#include <unistd.h> |
#include <unistd.h> |
31 |
|
|
32 |
typedef unsigned short uint16; |
typedef unsigned short uint16; |
33 |
typedef unsigned int uint32; |
typedef unsigned int uint32; |
34 |
|
|
35 |
#include "byteorder.h" /* Hmmm ... hot good */ |
#include "byteorder.h" /* Hmmm ... hot good */ |
36 |
|
|
37 |
#define max(a,b) (a < b ? b : a) |
#define max(a,b) (a < b ? b : a) |
38 |
|
|
39 |
#define SMB_DEF_IDF 0x424D53FF /* "\377SMB" */ |
#define SMB_DEF_IDF 0x424D53FF /* "\377SMB" */ |
40 |
|
|
41 |
/* Core protocol commands */ |
/* Core protocol commands */ |
42 |
|
|
43 |
#define SMBmkdir 0x00 /* create directory */ |
#define SMBmkdir 0x00 /* create directory */ |
44 |
#define SMBrmdir 0x01 /* delete directory */ |
#define SMBrmdir 0x01 /* delete directory */ |
45 |
#define SMBopen 0x02 /* open file */ |
#define SMBopen 0x02 /* open file */ |
46 |
#define SMBcreate 0x03 /* create file */ |
#define SMBcreate 0x03 /* create file */ |
47 |
#define SMBclose 0x04 /* close file */ |
#define SMBclose 0x04 /* close file */ |
48 |
#define SMBflush 0x05 /* flush file */ |
#define SMBflush 0x05 /* flush file */ |
49 |
#define SMBunlink 0x06 /* delete file */ |
#define SMBunlink 0x06 /* delete file */ |
50 |
#define SMBmv 0x07 /* rename file */ |
#define SMBmv 0x07 /* rename file */ |
51 |
#define SMBgetatr 0x08 /* get file attributes */ |
#define SMBgetatr 0x08 /* get file attributes */ |
52 |
#define SMBsetatr 0x09 /* set file attributes */ |
#define SMBsetatr 0x09 /* set file attributes */ |
53 |
#define SMBread 0x0A /* read from file */ |
#define SMBread 0x0A /* read from file */ |
54 |
#define SMBwrite 0x0B /* write to file */ |
#define SMBwrite 0x0B /* write to file */ |
55 |
#define SMBlock 0x0C /* lock byte range */ |
#define SMBlock 0x0C /* lock byte range */ |
56 |
#define SMBunlock 0x0D /* unlock byte range */ |
#define SMBunlock 0x0D /* unlock byte range */ |
57 |
#define SMBctemp 0x0E /* create temporary file */ |
#define SMBctemp 0x0E /* create temporary file */ |
58 |
#define SMBmknew 0x0F /* make new file */ |
#define SMBmknew 0x0F /* make new file */ |
59 |
#define SMBchkpth 0x10 /* check directory path */ |
#define SMBchkpth 0x10 /* check directory path */ |
60 |
#define SMBexit 0x11 /* process exit */ |
#define SMBexit 0x11 /* process exit */ |
61 |
#define SMBlseek 0x12 /* seek */ |
#define SMBlseek 0x12 /* seek */ |
62 |
#define SMBtcon 0x70 /* tree connect */ |
#define SMBtcon 0x70 /* tree connect */ |
63 |
#define SMBtdis 0x71 /* tree disconnect */ |
#define SMBtdis 0x71 /* tree disconnect */ |
64 |
#define SMBnegprot 0x72 /* negotiate protocol */ |
#define SMBnegprot 0x72 /* negotiate protocol */ |
65 |
#define SMBdskattr 0x80 /* get disk attributes */ |
#define SMBdskattr 0x80 /* get disk attributes */ |
66 |
#define SMBsearch 0x81 /* search directory */ |
#define SMBsearch 0x81 /* search directory */ |
67 |
#define SMBsplopen 0xC0 /* open print spool file */ |
#define SMBsplopen 0xC0 /* open print spool file */ |
68 |
#define SMBsplwr 0xC1 /* write to print spool file */ |
#define SMBsplwr 0xC1 /* write to print spool file */ |
69 |
#define SMBsplclose 0xC2 /* close print spool file */ |
#define SMBsplclose 0xC2 /* close print spool file */ |
70 |
#define SMBsplretq 0xC3 /* return print queue */ |
#define SMBsplretq 0xC3 /* return print queue */ |
71 |
#define SMBsends 0xD0 /* send single block message */ |
#define SMBsends 0xD0 /* send single block message */ |
72 |
#define SMBsendb 0xD1 /* send broadcast message */ |
#define SMBsendb 0xD1 /* send broadcast message */ |
73 |
#define SMBfwdname 0xD2 /* forward user name */ |
#define SMBfwdname 0xD2 /* forward user name */ |
74 |
#define SMBcancelf 0xD3 /* cancel forward */ |
#define SMBcancelf 0xD3 /* cancel forward */ |
75 |
#define SMBgetmac 0xD4 /* get machine name */ |
#define SMBgetmac 0xD4 /* get machine name */ |
76 |
#define SMBsendstrt 0xD5 /* send start of multi-block message */ |
#define SMBsendstrt 0xD5 /* send start of multi-block message */ |
77 |
#define SMBsendend 0xD6 /* send end of multi-block message */ |
#define SMBsendend 0xD6 /* send end of multi-block message */ |
78 |
#define SMBsendtxt 0xD7 /* send text of multi-block message */ |
#define SMBsendtxt 0xD7 /* send text of multi-block message */ |
79 |
|
|
80 |
/* CorePlus protocol */ |
/* CorePlus protocol */ |
81 |
|
|
82 |
#define SMBlockread 0x13 /* Lock a range and read it */ |
#define SMBlockread 0x13 /* Lock a range and read it */ |
83 |
#define SMBwriteunlock 0x14 /* Unlock a range and then write */ |
#define SMBwriteunlock 0x14 /* Unlock a range and then write */ |
84 |
#define SMBreadbraw 0x1a /* read a block of data without smb header ohead*/ |
#define SMBreadbraw 0x1a /* read a block of data without smb header ohead */ |
85 |
#define SMBwritebraw 0x1d /* write a block of data without smb header ohead*/ |
#define SMBwritebraw 0x1d /* write a block of data without smb header ohead */ |
86 |
#define SMBwritec 0x20 /* secondary write request */ |
#define SMBwritec 0x20 /* secondary write request */ |
87 |
#define SMBwriteclose 0x2c /* write a file and then close it */ |
#define SMBwriteclose 0x2c /* write a file and then close it */ |
88 |
|
|
89 |
/* DOS Extended Protocol */ |
/* DOS Extended Protocol */ |
90 |
|
|
91 |
#define SMBreadBraw 0x1A /* read block raw */ |
#define SMBreadBraw 0x1A /* read block raw */ |
92 |
#define SMBreadBmpx 0x1B /* read block multiplexed */ |
#define SMBreadBmpx 0x1B /* read block multiplexed */ |
93 |
#define SMBreadBs 0x1C /* read block (secondary response) */ |
#define SMBreadBs 0x1C /* read block (secondary response) */ |
94 |
#define SMBwriteBraw 0x1D /* write block raw */ |
#define SMBwriteBraw 0x1D /* write block raw */ |
95 |
#define SMBwriteBmpx 0x1E /* write block multiplexed */ |
#define SMBwriteBmpx 0x1E /* write block multiplexed */ |
96 |
#define SMBwriteBs 0x1F /* write block (secondary request) */ |
#define SMBwriteBs 0x1F /* write block (secondary request) */ |
97 |
#define SMBwriteC 0x20 /* write complete response */ |
#define SMBwriteC 0x20 /* write complete response */ |
98 |
#define SMBsetattrE 0x22 /* set file attributes expanded */ |
#define SMBsetattrE 0x22 /* set file attributes expanded */ |
99 |
#define SMBgetattrE 0x23 /* get file attributes expanded */ |
#define SMBgetattrE 0x23 /* get file attributes expanded */ |
100 |
#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */ |
#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */ |
101 |
#define SMBtrans 0x25 /* transaction - name, bytes in/out */ |
#define SMBtrans 0x25 /* transaction - name, bytes in/out */ |
102 |
#define SMBtranss 0x26 /* transaction (secondary request/response) */ |
#define SMBtranss 0x26 /* transaction (secondary request/response) */ |
103 |
#define SMBioctl 0x27 /* IOCTL */ |
#define SMBioctl 0x27 /* IOCTL */ |
104 |
#define SMBioctls 0x28 /* IOCTL (secondary request/response) */ |
#define SMBioctls 0x28 /* IOCTL (secondary request/response) */ |
105 |
#define SMBcopy 0x29 /* copy */ |
#define SMBcopy 0x29 /* copy */ |
106 |
#define SMBmove 0x2A /* move */ |
#define SMBmove 0x2A /* move */ |
107 |
#define SMBecho 0x2B /* echo */ |
#define SMBecho 0x2B /* echo */ |
108 |
#define SMBopenX 0x2D /* open and X */ |
#define SMBopenX 0x2D /* open and X */ |
109 |
#define SMBreadX 0x2E /* read and X */ |
#define SMBreadX 0x2E /* read and X */ |
110 |
#define SMBwriteX 0x2F /* write and X */ |
#define SMBwriteX 0x2F /* write and X */ |
111 |
#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ |
#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ |
112 |
#define SMBtconX 0x75 /* tree connect and X */ |
#define SMBtconX 0x75 /* tree connect and X */ |
113 |
#define SMBffirst 0x82 /* find first */ |
#define SMBffirst 0x82 /* find first */ |
114 |
#define SMBfunique 0x83 /* find unique */ |
#define SMBfunique 0x83 /* find unique */ |
115 |
#define SMBfclose 0x84 /* find close */ |
#define SMBfclose 0x84 /* find close */ |
116 |
#define SMBinvalid 0xFE /* invalid command */ |
#define SMBinvalid 0xFE /* invalid command */ |
117 |
|
|
118 |
/* Any more ? */ |
/* Any more ? */ |
119 |
|
|
120 |
#define SMBdatablockID 0x01 /* A data block identifier */ |
#define SMBdatablockID 0x01 /* A data block identifier */ |
121 |
#define SMBdialectID 0x02 /* A dialect id */ |
#define SMBdialectID 0x02 /* A dialect id */ |
122 |
#define SMBpathnameID 0x03 /* A pathname ID */ |
#define SMBpathnameID 0x03 /* A pathname ID */ |
123 |
#define SMBasciiID 0x04 /* An ascii string ID */ |
#define SMBasciiID 0x04 /* An ascii string ID */ |
124 |
#define SMBvariableblockID 0x05 /* A variable block ID */ |
#define SMBvariableblockID 0x05 /* A variable block ID */ |
125 |
|
|
126 |
/* some other defines we need */ |
/* some other defines we need */ |
127 |
|
|
128 |
/* Flags defines ... */ |
/* Flags defines ... */ |
129 |
|
|
130 |
#define SMB_FLG2_NON_DOS 0x01 /* We know non dos names */ |
#define SMB_FLG2_NON_DOS 0x01 /* We know non dos names */ |
131 |
#define SMB_FLG2_EXT_ATR 0x02 /* We know about Extended Attributes */ |
#define SMB_FLG2_EXT_ATR 0x02 /* We know about Extended Attributes */ |
132 |
#define SMB_FLG2_LNG_NAM 0x04 /* Long names ? */ |
#define SMB_FLG2_LNG_NAM 0x04 /* Long names ? */ |
133 |
|
|
134 |
typedef unsigned short WORD; |
typedef unsigned short WORD; |
135 |
typedef unsigned short UWORD; |
typedef unsigned short UWORD; |
138 |
typedef unsigned char UCHAR; |
typedef unsigned char UCHAR; |
139 |
|
|
140 |
/* Some macros to allow access to actual packet data so that we */ |
/* Some macros to allow access to actual packet data so that we */ |
141 |
|
|
142 |
/* can change the underlying representation of packets. */ |
/* can change the underlying representation of packets. */ |
143 |
|
|
144 |
/* */ |
/* */ |
145 |
|
|
146 |
/* The current formats vying for attention are a fragment */ |
/* The current formats vying for attention are a fragment */ |
147 |
|
|
148 |
/* approach where the SMB header is a fragment linked to the */ |
/* approach where the SMB header is a fragment linked to the */ |
149 |
|
|
150 |
/* data portion with the transport protocol (rfcnb or whatever) */ |
/* data portion with the transport protocol (rfcnb or whatever) */ |
151 |
|
|
152 |
/* being linked on the front. */ |
/* being linked on the front. */ |
153 |
|
|
154 |
/* */ |
/* */ |
155 |
|
|
156 |
/* The other approach is where the whole packet is one array */ |
/* The other approach is where the whole packet is one array */ |
157 |
|
|
158 |
/* of bytes with space allowed on the front for the packet */ |
/* of bytes with space allowed on the front for the packet */ |
159 |
|
|
160 |
/* headers. */ |
/* headers. */ |
161 |
|
|
162 |
#define SMB_Hdr(p) (char *)(p -> data) |
#define SMB_Hdr(p) (char *)(p -> data) |
163 |
|
|
164 |
/* SMB Hdr def for File Sharing Protocol? From MS and Intel, */ |
/* SMB Hdr def for File Sharing Protocol? From MS and Intel, */ |
165 |
|
|
166 |
/* Intel PN 138446 Doc Version 2.0, Nov 7, 1988. This def also */ |
/* Intel PN 138446 Doc Version 2.0, Nov 7, 1988. This def also */ |
167 |
|
|
168 |
/* applies to LANMAN1.0 as well as the Core Protocol */ |
/* applies to LANMAN1.0 as well as the Core Protocol */ |
169 |
|
|
170 |
/* The spec states that wct and bcc must be present, even if 0 */ |
/* The spec states that wct and bcc must be present, even if 0 */ |
171 |
|
|
172 |
/* We define these as offsets into a char SMB[] array for the */ |
/* We define these as offsets into a char SMB[] array for the */ |
173 |
|
|
174 |
/* sake of portability */ |
/* sake of portability */ |
175 |
|
|
176 |
/* NOTE!. Some of the lenght defines, SMB_<protreq>_len do not include */ |
/* NOTE!. Some of the lenght defines, SMB_<protreq>_len do not include */ |
177 |
|
|
178 |
/* the data that follows in the SMB packet, so the code will have to */ |
/* the data that follows in the SMB packet, so the code will have to */ |
179 |
|
|
180 |
/* take that into account. */ |
/* take that into account. */ |
181 |
|
|
182 |
#define SMB_hdr_idf_offset 0 /* 0xFF,'SMB' 0-3 */ |
#define SMB_hdr_idf_offset 0 /* 0xFF,'SMB' 0-3 */ |
183 |
#define SMB_hdr_com_offset 4 /* BYTE 4 */ |
#define SMB_hdr_com_offset 4 /* BYTE 4 */ |
184 |
#define SMB_hdr_rcls_offset 5 /* BYTE 5 */ |
#define SMB_hdr_rcls_offset 5 /* BYTE 5 */ |
185 |
#define SMB_hdr_reh_offset 6 /* BYTE 6 */ |
#define SMB_hdr_reh_offset 6 /* BYTE 6 */ |
186 |
#define SMB_hdr_err_offset 7 /* WORD 7 */ |
#define SMB_hdr_err_offset 7 /* WORD 7 */ |
187 |
#define SMB_hdr_reb_offset 9 /* BYTE 9 */ |
#define SMB_hdr_reb_offset 9 /* BYTE 9 */ |
188 |
#define SMB_hdr_flg_offset 9 /* same as reb ...*/ |
#define SMB_hdr_flg_offset 9 /* same as reb ... */ |
189 |
#define SMB_hdr_res_offset 10 /* 7 WORDs 10 */ |
#define SMB_hdr_res_offset 10 /* 7 WORDs 10 */ |
190 |
#define SMB_hdr_res0_offset 10 /* WORD 10 */ |
#define SMB_hdr_res0_offset 10 /* WORD 10 */ |
191 |
#define SMB_hdr_flg2_offset 10 /* WORD */ |
#define SMB_hdr_flg2_offset 10 /* WORD */ |
192 |
#define SMB_hdr_res1_offset 12 /* WORD 12 */ |
#define SMB_hdr_res1_offset 12 /* WORD 12 */ |
193 |
#define SMB_hdr_res2_offset 14 |
#define SMB_hdr_res2_offset 14 |
194 |
#define SMB_hdr_res3_offset 16 |
#define SMB_hdr_res3_offset 16 |
195 |
#define SMB_hdr_res4_offset 18 |
#define SMB_hdr_res4_offset 18 |
201 |
#define SMB_hdr_mid_offset 30 |
#define SMB_hdr_mid_offset 30 |
202 |
#define SMB_hdr_wct_offset 32 |
#define SMB_hdr_wct_offset 32 |
203 |
|
|
204 |
#define SMB_hdr_len 33 /* 33 byte header? */ |
#define SMB_hdr_len 33 /* 33 byte header? */ |
205 |
|
|
206 |
#define SMB_hdr_axc_offset 33 /* AndX Command */ |
#define SMB_hdr_axc_offset 33 /* AndX Command */ |
207 |
#define SMB_hdr_axr_offset 34 /* AndX Reserved */ |
#define SMB_hdr_axr_offset 34 /* AndX Reserved */ |
208 |
#define SMB_hdr_axo_offset 35 /* Offset from start to WCT of AndX cmd */ |
#define SMB_hdr_axo_offset 35 /* Offset from start to WCT of AndX cmd */ |
209 |
|
|
210 |
/* Format of the Negotiate Protocol SMB */ |
/* Format of the Negotiate Protocol SMB */ |
211 |
|
|
212 |
#define SMB_negp_bcc_offset 33 |
#define SMB_negp_bcc_offset 33 |
213 |
#define SMB_negp_buf_offset 35 /* Where the buffer starts */ |
#define SMB_negp_buf_offset 35 /* Where the buffer starts */ |
214 |
#define SMB_negp_len 35 /* plus the data */ |
#define SMB_negp_len 35 /* plus the data */ |
215 |
|
|
216 |
/* Format of the Negotiate Response SMB, for CoreProtocol, LM1.2 and */ |
/* Format of the Negotiate Response SMB, for CoreProtocol, LM1.2 and */ |
217 |
|
|
218 |
/* NT LM 0.12. wct will be 1 for CoreProtocol, 13 for LM 1.2, and 17 */ |
/* NT LM 0.12. wct will be 1 for CoreProtocol, 13 for LM 1.2, and 17 */ |
219 |
|
|
220 |
/* for NT LM 0.12 */ |
/* for NT LM 0.12 */ |
221 |
|
|
222 |
#define SMB_negrCP_idx_offset 33 /* Response to the neg req */ |
#define SMB_negrCP_idx_offset 33 /* Response to the neg req */ |
223 |
#define SMB_negrCP_bcc_offset 35 |
#define SMB_negrCP_bcc_offset 35 |
224 |
#define SMB_negrLM_idx_offset 33 /* dialect index */ |
#define SMB_negrLM_idx_offset 33 /* dialect index */ |
225 |
#define SMB_negrLM_sec_offset 35 /* Security mode */ |
#define SMB_negrLM_sec_offset 35 /* Security mode */ |
226 |
#define SMB_sec_user_mask 0x01 /* 0 = share, 1 = user */ |
#define SMB_sec_user_mask 0x01 /* 0 = share, 1 = user */ |
227 |
#define SMB_sec_encrypt_mask 0x02 /* pick out encrypt */ |
#define SMB_sec_encrypt_mask 0x02 /* pick out encrypt */ |
228 |
#define SMB_negrLM_mbs_offset 37 /* max buffer size */ |
#define SMB_negrLM_mbs_offset 37 /* max buffer size */ |
229 |
#define SMB_negrLM_mmc_offset 39 /* max mpx count */ |
#define SMB_negrLM_mmc_offset 39 /* max mpx count */ |
230 |
#define SMB_negrLM_mnv_offset 41 /* max number of VCs */ |
#define SMB_negrLM_mnv_offset 41 /* max number of VCs */ |
231 |
#define SMB_negrLM_rm_offset 43 /* raw mode support bit vec*/ |
#define SMB_negrLM_rm_offset 43 /* raw mode support bit vec */ |
232 |
#define SMB_read_raw_mask 0x01 |
#define SMB_read_raw_mask 0x01 |
233 |
#define SMB_write_raw_mask 0x02 |
#define SMB_write_raw_mask 0x02 |
234 |
#define SMB_negrLM_sk_offset 45 /* session key, 32 bits */ |
#define SMB_negrLM_sk_offset 45 /* session key, 32 bits */ |
235 |
#define SMB_negrLM_st_offset 49 /* Current server time */ |
#define SMB_negrLM_st_offset 49 /* Current server time */ |
236 |
#define SMB_negrLM_sd_offset 51 /* Current server date */ |
#define SMB_negrLM_sd_offset 51 /* Current server date */ |
237 |
#define SMB_negrLM_stz_offset 53 /* Server Time Zone */ |
#define SMB_negrLM_stz_offset 53 /* Server Time Zone */ |
238 |
#define SMB_negrLM_ekl_offset 55 /* encryption key length */ |
#define SMB_negrLM_ekl_offset 55 /* encryption key length */ |
239 |
#define SMB_negrLM_res_offset 57 /* reserved */ |
#define SMB_negrLM_res_offset 57 /* reserved */ |
240 |
#define SMB_negrLM_bcc_offset 59 /* bcc */ |
#define SMB_negrLM_bcc_offset 59 /* bcc */ |
241 |
#define SMB_negrLM_len 61 /* 61 bytes ? */ |
#define SMB_negrLM_len 61 /* 61 bytes ? */ |
242 |
#define SMB_negrLM_buf_offset 61 /* Where the fun begins */ |
#define SMB_negrLM_buf_offset 61 /* Where the fun begins */ |
243 |
|
|
244 |
#define SMB_negrNTLM_idx_offset 33 /* Selected protocol */ |
#define SMB_negrNTLM_idx_offset 33 /* Selected protocol */ |
245 |
#define SMB_negrNTLM_sec_offset 35 /* Security more */ |
#define SMB_negrNTLM_sec_offset 35 /* Security more */ |
246 |
#define SMB_negrNTLM_mmc_offset 36 /* Different format above */ |
#define SMB_negrNTLM_mmc_offset 36 /* Different format above */ |
247 |
#define SMB_negrNTLM_mnv_offset 38 /* Max VCs */ |
#define SMB_negrNTLM_mnv_offset 38 /* Max VCs */ |
248 |
#define SMB_negrNTLM_mbs_offset 40 /* MBS now a long */ |
#define SMB_negrNTLM_mbs_offset 40 /* MBS now a long */ |
249 |
#define SMB_negrNTLM_mrs_offset 44 /* Max raw size */ |
#define SMB_negrNTLM_mrs_offset 44 /* Max raw size */ |
250 |
#define SMB_negrNTLM_sk_offset 48 /* Session Key */ |
#define SMB_negrNTLM_sk_offset 48 /* Session Key */ |
251 |
#define SMB_negrNTLM_cap_offset 52 /* Capabilities */ |
#define SMB_negrNTLM_cap_offset 52 /* Capabilities */ |
252 |
#define SMB_negrNTLM_stl_offset 56 /* Server time low */ |
#define SMB_negrNTLM_stl_offset 56 /* Server time low */ |
253 |
#define SMB_negrNTLM_sth_offset 60 /* Server time high */ |
#define SMB_negrNTLM_sth_offset 60 /* Server time high */ |
254 |
#define SMB_negrNTLM_stz_offset 64 /* Server time zone */ |
#define SMB_negrNTLM_stz_offset 64 /* Server time zone */ |
255 |
#define SMB_negrNTLM_ekl_offset 66 /* Encrypt key len */ |
#define SMB_negrNTLM_ekl_offset 66 /* Encrypt key len */ |
256 |
#define SMB_negrNTLM_bcc_offset 67 /* Bcc */ |
#define SMB_negrNTLM_bcc_offset 67 /* Bcc */ |
257 |
#define SMB_negrNTLM_len 69 |
#define SMB_negrNTLM_len 69 |
258 |
#define SMB_negrNTLM_buf_offset 69 |
#define SMB_negrNTLM_buf_offset 69 |
259 |
|
|
260 |
/* Offsets related to Tree Connect */ |
/* Offsets related to Tree Connect */ |
261 |
|
|
262 |
#define SMB_tcon_bcc_offset 33 |
#define SMB_tcon_bcc_offset 33 |
263 |
#define SMB_tcon_buf_offset 35 /* where the data is for tcon */ |
#define SMB_tcon_buf_offset 35 /* where the data is for tcon */ |
264 |
#define SMB_tcon_len 35 /* plus the data */ |
#define SMB_tcon_len 35 /* plus the data */ |
265 |
|
|
266 |
#define SMB_tconr_mbs_offset 33 /* max buffer size */ |
#define SMB_tconr_mbs_offset 33 /* max buffer size */ |
267 |
#define SMB_tconr_tid_offset 35 /* returned tree id */ |
#define SMB_tconr_tid_offset 35 /* returned tree id */ |
268 |
#define SMB_tconr_bcc_offset 37 |
#define SMB_tconr_bcc_offset 37 |
269 |
#define SMB_tconr_len 39 |
#define SMB_tconr_len 39 |
270 |
|
|
271 |
#define SMB_tconx_axc_offset 33 /* And X Command */ |
#define SMB_tconx_axc_offset 33 /* And X Command */ |
272 |
#define SMB_tconx_axr_offset 34 /* reserved */ |
#define SMB_tconx_axr_offset 34 /* reserved */ |
273 |
#define SMB_tconx_axo_offset 35 /* Next command offset */ |
#define SMB_tconx_axo_offset 35 /* Next command offset */ |
274 |
#define SMB_tconx_flg_offset 37 /* Flags, bit0=1 means disc TID */ |
#define SMB_tconx_flg_offset 37 /* Flags, bit0=1 means disc TID */ |
275 |
#define SMB_tconx_pwl_offset 39 /* Password length */ |
#define SMB_tconx_pwl_offset 39 /* Password length */ |
276 |
#define SMB_tconx_bcc_offset 41 /* bcc */ |
#define SMB_tconx_bcc_offset 41 /* bcc */ |
277 |
#define SMB_tconx_buf_offset 43 /* buffer */ |
#define SMB_tconx_buf_offset 43 /* buffer */ |
278 |
#define SMB_tconx_len 43 /* up to data ... */ |
#define SMB_tconx_len 43 /* up to data ... */ |
279 |
|
|
280 |
#define SMB_tconxr_axc_offset 33 /* Where the AndX Command is */ |
#define SMB_tconxr_axc_offset 33 /* Where the AndX Command is */ |
281 |
#define SMB_tconxr_axr_offset 34 /* Reserved */ |
#define SMB_tconxr_axr_offset 34 /* Reserved */ |
282 |
#define SMB_tconxr_axo_offset 35 /* AndX offset location */ |
#define SMB_tconxr_axo_offset 35 /* AndX offset location */ |
283 |
|
|
284 |
/* Offsets related to tree_disconnect */ |
/* Offsets related to tree_disconnect */ |
285 |
|
|
286 |
#define SMB_tdis_bcc_offset 33 /* bcc */ |
#define SMB_tdis_bcc_offset 33 /* bcc */ |
287 |
#define SMB_tdis_len 35 /* total len */ |
#define SMB_tdis_len 35 /* total len */ |
288 |
|
|
289 |
#define SMB_tdisr_bcc_offset 33 /* bcc */ |
#define SMB_tdisr_bcc_offset 33 /* bcc */ |
290 |
#define SMB_tdisr_len 35 |
#define SMB_tdisr_len 35 |
291 |
|
|
292 |
/* Offsets related to Open Request */ |
/* Offsets related to Open Request */ |
293 |
|
|
294 |
#define SMB_open_mod_offset 33 /* Mode to open with */ |
#define SMB_open_mod_offset 33 /* Mode to open with */ |
295 |
#define SMB_open_atr_offset 35 /* Attributes of file */ |
#define SMB_open_atr_offset 35 /* Attributes of file */ |
296 |
#define SMB_open_bcc_offset 37 /* bcc */ |
#define SMB_open_bcc_offset 37 /* bcc */ |
297 |
#define SMB_open_buf_offset 39 /* File name */ |
#define SMB_open_buf_offset 39 /* File name */ |
298 |
#define SMB_open_len 39 /* Plus the file name */ |
#define SMB_open_len 39 /* Plus the file name */ |
299 |
|
|
300 |
#define SMB_openx_axc_offset 33 /* Next command */ |
#define SMB_openx_axc_offset 33 /* Next command */ |
301 |
#define SMB_openx_axr_offset 34 /* Reserved */ |
#define SMB_openx_axr_offset 34 /* Reserved */ |
302 |
#define SMB_openx_axo_offset 35 /* offset of next wct */ |
#define SMB_openx_axo_offset 35 /* offset of next wct */ |
303 |
#define SMB_openx_flg_offset 37 /* Flags, bit0 = need more info */ |
#define SMB_openx_flg_offset 37 /* Flags, bit0 = need more info */ |
304 |
/* bit1 = exclusive oplock */ |
/* |
305 |
/* bit2 = batch oplock */ |
* bit1 = exclusive oplock |
306 |
#define SMB_openx_mod_offset 39 /* mode to open with */ |
*/ |
307 |
#define SMB_openx_atr_offset 41 /* search attributes */ |
/* |
308 |
#define SMB_openx_fat_offset 43 /* File attributes */ |
* bit2 = batch oplock |
309 |
#define SMB_openx_tim_offset 45 /* time and date of creat */ |
*/ |
310 |
#define SMB_openx_ofn_offset 49 /* Open function */ |
#define SMB_openx_mod_offset 39 /* mode to open with */ |
311 |
#define SMB_openx_als_offset 51 /* Space to allocate on */ |
#define SMB_openx_atr_offset 41 /* search attributes */ |
312 |
#define SMB_openx_res_offset 55 /* reserved */ |
#define SMB_openx_fat_offset 43 /* File attributes */ |
313 |
#define SMB_openx_bcc_offset 63 /* bcc */ |
#define SMB_openx_tim_offset 45 /* time and date of creat */ |
314 |
#define SMB_openx_buf_offset 65 /* Where file name goes */ |
#define SMB_openx_ofn_offset 49 /* Open function */ |
315 |
|
#define SMB_openx_als_offset 51 /* Space to allocate on */ |
316 |
|
#define SMB_openx_res_offset 55 /* reserved */ |
317 |
|
#define SMB_openx_bcc_offset 63 /* bcc */ |
318 |
|
#define SMB_openx_buf_offset 65 /* Where file name goes */ |
319 |
#define SMB_openx_len 65 |
#define SMB_openx_len 65 |
320 |
|
|
321 |
#define SMB_openr_fid_offset 33 /* FID returned */ |
#define SMB_openr_fid_offset 33 /* FID returned */ |
322 |
#define SMB_openr_atr_offset 35 /* Attributes opened with */ |
#define SMB_openr_atr_offset 35 /* Attributes opened with */ |
323 |
#define SMB_openr_tim_offset 37 /* Last mod time of file */ |
#define SMB_openr_tim_offset 37 /* Last mod time of file */ |
324 |
#define SMB_openr_fsz_offset 41 /* File size 4 bytes */ |
#define SMB_openr_fsz_offset 41 /* File size 4 bytes */ |
325 |
#define SMB_openr_acc_offset 45 /* Access allowed */ |
#define SMB_openr_acc_offset 45 /* Access allowed */ |
326 |
#define SMB_openr_bcc_offset 47 |
#define SMB_openr_bcc_offset 47 |
327 |
#define SMB_openr_len 49 |
#define SMB_openr_len 49 |
328 |
|
|
329 |
#define SMB_openxr_axc_offset 33 /* And X command */ |
#define SMB_openxr_axc_offset 33 /* And X command */ |
330 |
#define SMB_openxr_axr_offset 34 /* reserved */ |
#define SMB_openxr_axr_offset 34 /* reserved */ |
331 |
#define SMB_openxr_axo_offset 35 /* offset to next command */ |
#define SMB_openxr_axo_offset 35 /* offset to next command */ |
332 |
#define SMB_openxr_fid_offset 37 /* FID returned */ |
#define SMB_openxr_fid_offset 37 /* FID returned */ |
333 |
#define SMB_openxr_fat_offset 39 /* File attributes returned*/ |
#define SMB_openxr_fat_offset 39 /* File attributes returned */ |
334 |
#define SMB_openxr_tim_offset 41 /* File creation date etc */ |
#define SMB_openxr_tim_offset 41 /* File creation date etc */ |
335 |
#define SMB_openxr_fsz_offset 45 /* Size of file */ |
#define SMB_openxr_fsz_offset 45 /* Size of file */ |
336 |
#define SMB_openxr_acc_offset 49 /* Access granted */ |
#define SMB_openxr_acc_offset 49 /* Access granted */ |
337 |
|
|
338 |
#define SMB_clos_fid_offset 33 /* FID to close */ |
#define SMB_clos_fid_offset 33 /* FID to close */ |
339 |
#define SMB_clos_tim_offset 35 /* Last mod time */ |
#define SMB_clos_tim_offset 35 /* Last mod time */ |
340 |
#define SMB_clos_bcc_offset 39 /* bcc */ |
#define SMB_clos_bcc_offset 39 /* bcc */ |
341 |
#define SMB_clos_len 41 |
#define SMB_clos_len 41 |
342 |
|
|
343 |
/* Offsets related to Write requests */ |
/* Offsets related to Write requests */ |
344 |
|
|
345 |
#define SMB_write_fid_offset 33 /* FID to write */ |
#define SMB_write_fid_offset 33 /* FID to write */ |
346 |
#define SMB_write_cnt_offset 35 /* bytes to write */ |
#define SMB_write_cnt_offset 35 /* bytes to write */ |
347 |
#define SMB_write_ofs_offset 37 /* location to write to */ |
#define SMB_write_ofs_offset 37 /* location to write to */ |
348 |
#define SMB_write_clf_offset 41 /* advisory count left */ |
#define SMB_write_clf_offset 41 /* advisory count left */ |
349 |
#define SMB_write_bcc_offset 43 /* bcc = data bytes + 3 */ |
#define SMB_write_bcc_offset 43 /* bcc = data bytes + 3 */ |
350 |
#define SMB_write_buf_offset 45 /* Data=0x01, len, data */ |
#define SMB_write_buf_offset 45 /* Data=0x01, len, data */ |
351 |
#define SMB_write_len 45 /* plus the data ... */ |
#define SMB_write_len 45 /* plus the data ... */ |
352 |
|
|
353 |
#define SMB_writr_cnt_offset 33 /* Count of bytes written */ |
#define SMB_writr_cnt_offset 33 /* Count of bytes written */ |
354 |
#define SMB_writr_bcc_offset 35 /* bcc */ |
#define SMB_writr_bcc_offset 35 /* bcc */ |
355 |
#define SMB_writr_len 37 |
#define SMB_writr_len 37 |
356 |
|
|
357 |
/* Offsets related to read requests */ |
/* Offsets related to read requests */ |
358 |
|
|
359 |
#define SMB_read_fid_offset 33 /* FID of file to read */ |
#define SMB_read_fid_offset 33 /* FID of file to read */ |
360 |
#define SMB_read_cnt_offset 35 /* count of words to read */ |
#define SMB_read_cnt_offset 35 /* count of words to read */ |
361 |
#define SMB_read_ofs_offset 37 /* Where to read from */ |
#define SMB_read_ofs_offset 37 /* Where to read from */ |
362 |
#define SMB_read_clf_offset 41 /* Advisory count to go */ |
#define SMB_read_clf_offset 41 /* Advisory count to go */ |
363 |
#define SMB_read_bcc_offset 43 |
#define SMB_read_bcc_offset 43 |
364 |
#define SMB_read_len 45 |
#define SMB_read_len 45 |
365 |
|
|
366 |
#define SMB_readr_cnt_offset 33 /* Count of bytes returned */ |
#define SMB_readr_cnt_offset 33 /* Count of bytes returned */ |
367 |
#define SMB_readr_res_offset 35 /* 4 shorts reserved, 8 bytes */ |
#define SMB_readr_res_offset 35 /* 4 shorts reserved, 8 bytes */ |
368 |
#define SMB_readr_bcc_offset 43 /* bcc */ |
#define SMB_readr_bcc_offset 43 /* bcc */ |
369 |
#define SMB_readr_bff_offset 45 /* buffer format char = 0x01 */ |
#define SMB_readr_bff_offset 45 /* buffer format char = 0x01 */ |
370 |
#define SMB_readr_len_offset 46 /* buffer len */ |
#define SMB_readr_len_offset 46 /* buffer len */ |
371 |
#define SMB_readr_len 45 /* length of the readr before data */ |
#define SMB_readr_len 45 /* length of the readr before data */ |
372 |
|
|
373 |
/* Offsets for Create file */ |
/* Offsets for Create file */ |
374 |
|
|
375 |
#define SMB_creat_atr_offset 33 /* Attributes of new file ... */ |
#define SMB_creat_atr_offset 33 /* Attributes of new file ... */ |
376 |
#define SMB_creat_tim_offset 35 /* Time of creation */ |
#define SMB_creat_tim_offset 35 /* Time of creation */ |
377 |
#define SMB_creat_dat_offset 37 /* 4004BCE :-) */ |
#define SMB_creat_dat_offset 37 /* 4004BCE :-) */ |
378 |
#define SMB_creat_bcc_offset 39 /* bcc */ |
#define SMB_creat_bcc_offset 39 /* bcc */ |
379 |
#define SMB_creat_buf_offset 41 |
#define SMB_creat_buf_offset 41 |
380 |
#define SMB_creat_len 41 /* Before the data */ |
#define SMB_creat_len 41 /* Before the data */ |
381 |
|
|
382 |
#define SMB_creatr_fid_offset 33 /* FID of created file */ |
#define SMB_creatr_fid_offset 33 /* FID of created file */ |
383 |
|
|
384 |
/* Offsets for Delete file */ |
/* Offsets for Delete file */ |
385 |
|
|
386 |
#define SMB_delet_sat_offset 33 /* search attribites */ |
#define SMB_delet_sat_offset 33 /* search attribites */ |
387 |
#define SMB_delet_bcc_offset 35 /* bcc */ |
#define SMB_delet_bcc_offset 35 /* bcc */ |
388 |
#define SMB_delet_buf_offset 37 |
#define SMB_delet_buf_offset 37 |
389 |
#define SMB_delet_len 37 |
#define SMB_delet_len 37 |
390 |
|
|
391 |
/* Offsets for SESSION_SETUP_ANDX for both LM and NT LM protocols */ |
/* Offsets for SESSION_SETUP_ANDX for both LM and NT LM protocols */ |
392 |
|
|
393 |
#define SMB_ssetpLM_mbs_offset 37 /* Max buffer Size, allow for AndX */ |
#define SMB_ssetpLM_mbs_offset 37 /* Max buffer Size, allow for AndX */ |
394 |
#define SMB_ssetpLM_mmc_offset 39 /* max multiplex count */ |
#define SMB_ssetpLM_mmc_offset 39 /* max multiplex count */ |
395 |
#define SMB_ssetpLM_vcn_offset 41 /* VC number if new VC */ |
#define SMB_ssetpLM_vcn_offset 41 /* VC number if new VC */ |
396 |
#define SMB_ssetpLM_snk_offset 43 /* Session Key */ |
#define SMB_ssetpLM_snk_offset 43 /* Session Key */ |
397 |
#define SMB_ssetpLM_pwl_offset 47 /* password length */ |
#define SMB_ssetpLM_pwl_offset 47 /* password length */ |
398 |
#define SMB_ssetpLM_res_offset 49 /* reserved */ |
#define SMB_ssetpLM_res_offset 49 /* reserved */ |
399 |
#define SMB_ssetpLM_bcc_offset 53 /* bcc */ |
#define SMB_ssetpLM_bcc_offset 53 /* bcc */ |
400 |
#define SMB_ssetpLM_len 55 /* before data ... */ |
#define SMB_ssetpLM_len 55 /* before data ... */ |
401 |
#define SMB_ssetpLM_buf_offset 55 |
#define SMB_ssetpLM_buf_offset 55 |
402 |
|
|
403 |
#define SMB_ssetpNTLM_mbs_offset 37 /* Max Buffer Size for NT LM 0.12 */ |
#define SMB_ssetpNTLM_mbs_offset 37 /* Max Buffer Size for NT LM 0.12 */ |
404 |
/* and above */ |
/* |
405 |
#define SMB_ssetpNTLM_mmc_offset 39 /* Max Multiplex count */ |
* and above |
406 |
#define SMB_ssetpNTLM_vcn_offset 41 /* VC Number */ |
*/ |
407 |
#define SMB_ssetpNTLM_snk_offset 43 /* Session key */ |
#define SMB_ssetpNTLM_mmc_offset 39 /* Max Multiplex count */ |
408 |
#define SMB_ssetpNTLM_cipl_offset 47 /* Case Insensitive PW Len */ |
#define SMB_ssetpNTLM_vcn_offset 41 /* VC Number */ |
409 |
#define SMB_ssetpNTLM_cspl_offset 49 /* Unicode pw len */ |
#define SMB_ssetpNTLM_snk_offset 43 /* Session key */ |
410 |
#define SMB_ssetpNTLM_res_offset 51 /* reserved */ |
#define SMB_ssetpNTLM_cipl_offset 47 /* Case Insensitive PW Len */ |
411 |
#define SMB_ssetpNTLM_cap_offset 55 /* server capabilities */ |
#define SMB_ssetpNTLM_cspl_offset 49 /* Unicode pw len */ |
412 |
#define SMB_ssetpNTLM_bcc_offset 59 /* bcc */ |
#define SMB_ssetpNTLM_res_offset 51 /* reserved */ |
413 |
#define SMB_ssetpNTLM_len 61 /* before data */ |
#define SMB_ssetpNTLM_cap_offset 55 /* server capabilities */ |
414 |
|
#define SMB_ssetpNTLM_bcc_offset 59 /* bcc */ |
415 |
|
#define SMB_ssetpNTLM_len 61 /* before data */ |
416 |
#define SMB_ssetpNTLM_buf_offset 61 |
#define SMB_ssetpNTLM_buf_offset 61 |
417 |
|
|
418 |
#define SMB_ssetpr_axo_offset 35 /* Offset of next response ... */ |
#define SMB_ssetpr_axo_offset 35 /* Offset of next response ... */ |
419 |
#define SMB_ssetpr_act_offset 37 /* action, bit 0 = 1 => guest */ |
#define SMB_ssetpr_act_offset 37 /* action, bit 0 = 1 => guest */ |
420 |
#define SMB_ssetpr_bcc_offset 39 /* bcc */ |
#define SMB_ssetpr_bcc_offset 39 /* bcc */ |
421 |
#define SMB_ssetpr_buf_offset 41 /* Native OS etc */ |
#define SMB_ssetpr_buf_offset 41 /* Native OS etc */ |
422 |
|
|
423 |
/* Offsets for SMB create directory */ |
/* Offsets for SMB create directory */ |
424 |
|
|
425 |
#define SMB_creatdir_bcc_offset 33 /* only a bcc here */ |
#define SMB_creatdir_bcc_offset 33 /* only a bcc here */ |
426 |
#define SMB_creatdir_buf_offset 35 /* Where things start */ |
#define SMB_creatdir_buf_offset 35 /* Where things start */ |
427 |
#define SMB_creatdir_len 35 |
#define SMB_creatdir_len 35 |
428 |
|
|
429 |
/* Offsets for SMB delete directory */ |
/* Offsets for SMB delete directory */ |
430 |
|
|
431 |
#define SMB_deletdir_bcc_offset 33 /* only a bcc here */ |
#define SMB_deletdir_bcc_offset 33 /* only a bcc here */ |
432 |
#define SMB_deletdir_buf_offset 35 /* where things start */ |
#define SMB_deletdir_buf_offset 35 /* where things start */ |
433 |
#define SMB_deletdir_len 35 |
#define SMB_deletdir_len 35 |
434 |
|
|
435 |
/* Offsets for SMB check directory */ |
/* Offsets for SMB check directory */ |
436 |
|
|
437 |
#define SMB_checkdir_bcc_offset 33 /* Only a bcc here */ |
#define SMB_checkdir_bcc_offset 33 /* Only a bcc here */ |
438 |
#define SMB_checkdir_buf_offset 35 /* where things start */ |
#define SMB_checkdir_buf_offset 35 /* where things start */ |
439 |
#define SMB_checkdir_len 35 |
#define SMB_checkdir_len 35 |
440 |
|
|
441 |
/* Offsets for SMB search */ |
/* Offsets for SMB search */ |
442 |
|
|
443 |
#define SMB_search_mdc_offset 33 /* Max Dir ents to return */ |
#define SMB_search_mdc_offset 33 /* Max Dir ents to return */ |
444 |
#define SMB_search_atr_offset 35 /* Search attributes */ |
#define SMB_search_atr_offset 35 /* Search attributes */ |
445 |
#define SMB_search_bcc_offset 37 /* bcc */ |
#define SMB_search_bcc_offset 37 /* bcc */ |
446 |
#define SMB_search_buf_offset 39 /* where the action is */ |
#define SMB_search_buf_offset 39 /* where the action is */ |
447 |
#define SMB_search_len 39 |
#define SMB_search_len 39 |
448 |
|
|
449 |
#define SMB_searchr_dec_offset 33 /* Dir ents returned */ |
#define SMB_searchr_dec_offset 33 /* Dir ents returned */ |
450 |
#define SMB_searchr_bcc_offset 35 /* bcc */ |
#define SMB_searchr_bcc_offset 35 /* bcc */ |
451 |
#define SMB_searchr_buf_offset 37 /* Where the action starts */ |
#define SMB_searchr_buf_offset 37 /* Where the action starts */ |
452 |
#define SMB_searchr_len 37 /* before the dir ents */ |
#define SMB_searchr_len 37 /* before the dir ents */ |
453 |
|
|
454 |
#define SMB_searchr_dirent_len 43 /* 53 bytes */ |
#define SMB_searchr_dirent_len 43 /* 53 bytes */ |
455 |
|
|
456 |
/* Defines for SMB transact and transact2 calls */ |
/* Defines for SMB transact and transact2 calls */ |
457 |
|
|
458 |
#define SMB_trans_tpc_offset 33 /* Total param count */ |
#define SMB_trans_tpc_offset 33 /* Total param count */ |
459 |
#define SMB_trans_tdc_offset 35 /* total Data count */ |
#define SMB_trans_tdc_offset 35 /* total Data count */ |
460 |
#define SMB_trans_mpc_offset 37 /* Max params bytes to return */ |
#define SMB_trans_mpc_offset 37 /* Max params bytes to return */ |
461 |
#define SMB_trans_mdc_offset 39 /* Max data bytes to return */ |
#define SMB_trans_mdc_offset 39 /* Max data bytes to return */ |
462 |
#define SMB_trans_msc_offset 41 /* Max setup words to return */ |
#define SMB_trans_msc_offset 41 /* Max setup words to return */ |
463 |
#define SMB_trans_rs1_offset 42 /* Reserved byte */ |
#define SMB_trans_rs1_offset 42 /* Reserved byte */ |
464 |
#define SMB_trans_flg_offset 43 /* flags */ |
#define SMB_trans_flg_offset 43 /* flags */ |
465 |
#define SMB_trans_tmo_offset 45 /* Timeout, long */ |
#define SMB_trans_tmo_offset 45 /* Timeout, long */ |
466 |
#define SMB_trans_rs2_offset 49 /* Next reserved */ |
#define SMB_trans_rs2_offset 49 /* Next reserved */ |
467 |
#define SMB_trans_pbc_offset 51 /* Param Byte count in buf */ |
#define SMB_trans_pbc_offset 51 /* Param Byte count in buf */ |
468 |
#define SMB_trans_pbo_offset 53 /* Offset to param bytes */ |
#define SMB_trans_pbo_offset 53 /* Offset to param bytes */ |
469 |
#define SMB_trans_dbc_offset 55 /* Data byte count in buf */ |
#define SMB_trans_dbc_offset 55 /* Data byte count in buf */ |
470 |
#define SMB_trans_dbo_offset 57 /* Data byte offset */ |
#define SMB_trans_dbo_offset 57 /* Data byte offset */ |
471 |
#define SMB_trans_suc_offset 59 /* Setup count - byte */ |
#define SMB_trans_suc_offset 59 /* Setup count - byte */ |
472 |
#define SMB_trans_rs3_offset 60 /* Reserved to pad ... */ |
#define SMB_trans_rs3_offset 60 /* Reserved to pad ... */ |
473 |
#define SMB_trans_len 61 /* Up to setup, still need bcc */ |
#define SMB_trans_len 61 /* Up to setup, still need bcc */ |
474 |
|
|
475 |
#define SMB_transr_tpc_offset 33 /* Total param bytes returned */ |
#define SMB_transr_tpc_offset 33 /* Total param bytes returned */ |
476 |
#define SMB_transr_tdc_offset 35 |
#define SMB_transr_tdc_offset 35 |
477 |
#define SMB_transr_rs1_offset 37 |
#define SMB_transr_rs1_offset 37 |
478 |
#define SMB_transr_pbc_offset 39 |
#define SMB_transr_pbc_offset 39 |
479 |
#define SMB_transr_pbo_offset 41 |
#define SMB_transr_pbo_offset 41 |
480 |
#define SMB_transr_pdi_offset 43 /* parameter displacement */ |
#define SMB_transr_pdi_offset 43 /* parameter displacement */ |
481 |
#define SMB_transr_dbc_offset 45 |
#define SMB_transr_dbc_offset 45 |
482 |
#define SMB_transr_dbo_offset 47 |
#define SMB_transr_dbo_offset 47 |
483 |
#define SMB_transr_ddi_offset 49 |
#define SMB_transr_ddi_offset 49 |
502 |
|
|
503 |
#define SMB_LMapi_SetUserInfo 0x0072 |
#define SMB_LMapi_SetUserInfo 0x0072 |
504 |
#define SMB_LMapi_UserPasswordSet 0x0073 |
#define SMB_LMapi_UserPasswordSet 0x0073 |
505 |
|
|
506 |
/* Structures and defines we use in the client interface */ |
/* Structures and defines we use in the client interface */ |
507 |
|
|
508 |
/* The protocols we might support. Perhaps a bit ambitious, as only RFCNB */ |
/* The protocols we might support. Perhaps a bit ambitious, as only RFCNB */ |
|
/* has any support so far 0(sometimes called NBT) */ |
|
509 |
|
|
510 |
typedef enum {SMB_RFCNB, SMB_IPXNB, SMB_NETBEUI, SMB_X25} SMB_Transport_Types; |
/* has any support so far 0(sometimes called NBT) */ |
|
|
|
|
typedef enum {SMB_Con_FShare, SMB_Con_PShare, SMB_Con_IPC} SMB_Con_Types; |
|
511 |
|
|
512 |
typedef enum {SMB_State_NoState, SMB_State_Stopped, SMB_State_Started} SMB_State_Types; |
typedef enum |
513 |
|
{ SMB_RFCNB, SMB_IPXNB, SMB_NETBEUI, SMB_X25 } |
514 |
|
SMB_Transport_Types; |
515 |
|
|
516 |
|
typedef enum |
517 |
|
{ SMB_Con_FShare, SMB_Con_PShare, SMB_Con_IPC } |
518 |
|
SMB_Con_Types; |
519 |
|
|
520 |
|
typedef enum |
521 |
|
{ SMB_State_NoState, SMB_State_Stopped, SMB_State_Started } |
522 |
|
SMB_State_Types; |
523 |
|
|
524 |
/* The following two arrays need to be in step! */ |
/* The following two arrays need to be in step! */ |
525 |
|
|
526 |
/* We must make it possible for callers to specify these ... */ |
/* We must make it possible for callers to specify these ... */ |
527 |
|
|
528 |
|
static char *SMB_Prots[] = { "PC NETWORK PROGRAM 1.0", |
529 |
|
"MICROSOFT NETWORKS 1.03", |
530 |
|
"MICROSOFT NETWORKS 3.0", |
531 |
|
"DOS LANMAN1.0", |
532 |
|
"LANMAN1.0", |
533 |
|
"DOS LM1.2X002", |
534 |
|
"LM1.2X002", |
535 |
|
"DOS LANMAN2.1", |
536 |
|
"LANMAN2.1", |
537 |
|
"Samba", |
538 |
|
"NT LM 0.12", |
539 |
|
"NT LANMAN 1.0", |
540 |
|
NULL |
541 |
|
}; |
542 |
|
|
543 |
|
static int SMB_Types[] = { SMB_P_Core, |
544 |
|
SMB_P_CorePlus, |
545 |
|
SMB_P_DOSLanMan1, |
546 |
|
SMB_P_DOSLanMan1, |
547 |
|
SMB_P_LanMan1, |
548 |
|
SMB_P_DOSLanMan2, |
549 |
|
SMB_P_LanMan2, |
550 |
|
SMB_P_LanMan2_1, |
551 |
|
SMB_P_LanMan2_1, |
552 |
|
SMB_P_NT1, |
553 |
|
SMB_P_NT1, |
554 |
|
SMB_P_NT1, |
555 |
|
-1 |
556 |
|
}; |
557 |
|
|
558 |
|
typedef struct SMB_Status |
559 |
|
{ |
560 |
|
|
561 |
static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0", |
union |
562 |
"MICROSOFT NETWORKS 1.03", |
{ |
563 |
"MICROSOFT NETWORKS 3.0", |
struct |
564 |
"DOS LANMAN1.0", |
{ |
565 |
"LANMAN1.0", |
unsigned char ErrorClass; |
566 |
"DOS LM1.2X002", |
unsigned char Reserved; |
567 |
"LM1.2X002", |
unsigned short Error; |
568 |
"DOS LANMAN2.1", |
} |
569 |
"LANMAN2.1", |
DosError; |
570 |
"Samba", |
unsigned int NtStatus; |
571 |
"NT LM 0.12", |
} |
572 |
"NT LANMAN 1.0", |
status; |
573 |
NULL}; |
} |
574 |
|
SMB_Status; |
575 |
static int SMB_Types[] = {SMB_P_Core, |
|
576 |
SMB_P_CorePlus, |
typedef struct SMB_Tree_Structure *SMB_Tree_Handle; |
577 |
SMB_P_DOSLanMan1, |
|
578 |
SMB_P_DOSLanMan1, |
typedef struct SMB_Connect_Def *SMB_Handle_Type; |
579 |
SMB_P_LanMan1, |
|
580 |
SMB_P_DOSLanMan2, |
struct SMB_Connect_Def |
581 |
SMB_P_LanMan2, |
{ |
582 |
SMB_P_LanMan2_1, |
|
583 |
SMB_P_LanMan2_1, |
SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */ |
584 |
SMB_P_NT1, |
int protocol; /* What is the protocol */ |
585 |
SMB_P_NT1, |
int prot_IDX; /* And what is the index */ |
586 |
SMB_P_NT1, |
void *Trans_Connect; /* The connection */ |
587 |
-1}; |
|
588 |
|
/* |
589 |
typedef struct SMB_Status { |
* All these strings should be malloc'd |
590 |
|
*/ |
591 |
union { |
|
592 |
struct { |
char service[80], username[80], password[80], desthost[80], |
593 |
unsigned char ErrorClass; |
sock_options[80]; |
594 |
unsigned char Reserved; |
char address[80], myname[80]; |
595 |
unsigned short Error; |
|
596 |
} DosError; |
SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */ |
597 |
unsigned int NtStatus; |
|
598 |
} status; |
int gid; /* Group ID, do we need it? */ |
599 |
} SMB_Status; |
int mid; /* Multiplex ID? We might need one per con */ |
600 |
|
int pid; /* Process ID */ |
601 |
typedef struct SMB_Tree_Structure * SMB_Tree_Handle; |
|
602 |
|
int uid; /* Authenticated user id. */ |
603 |
typedef struct SMB_Connect_Def * SMB_Handle_Type; |
|
604 |
|
/* |
605 |
struct SMB_Connect_Def { |
* It is pretty clear that we need to bust some of |
606 |
|
*/ |
607 |
SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */ |
/* |
608 |
int protocol; /* What is the protocol */ |
* these out into a per TCon record, as there may |
609 |
int prot_IDX; /* And what is the index */ |
*/ |
610 |
void *Trans_Connect; /* The connection */ |
/* |
611 |
|
* be multiple TCon's per server, etc ... later |
612 |
/* All these strings should be malloc'd */ |
*/ |
613 |
|
|
614 |
char service[80], username[80], password[80], desthost[80], sock_options[80]; |
int port; /* port to use in case not default, this is a TCPism! */ |
615 |
char address[80], myname[80]; |
|
616 |
|
int max_xmit; /* Max xmit permitted by server */ |
617 |
SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */ |
int Security; /* 0 = share, 1 = user */ |
618 |
|
int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */ |
619 |
int gid; /* Group ID, do we need it? */ |
BOOL encrypt_passwords; /* FALSE = don't */ |
620 |
int mid; /* Multiplex ID? We might need one per con */ |
int MaxMPX, MaxVC, MaxRaw; |
621 |
int pid; /* Process ID */ |
unsigned int SessionKey, Capabilities; |
622 |
|
int SvrTZ; /* Server Time Zone */ |
623 |
int uid; /* Authenticated user id. */ |
int Encrypt_Key_Len; |
624 |
|
char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40]; |
625 |
/* It is pretty clear that we need to bust some of */ |
char Svr_OS[80], Svr_LMType[80], Svr_PDom[80]; |
|
/* these out into a per TCon record, as there may */ |
|
|
/* be multiple TCon's per server, etc ... later */ |
|
|
|
|
|
int port; /* port to use in case not default, this is a TCPism! */ |
|
|
|
|
|
int max_xmit; /* Max xmit permitted by server */ |
|
|
int Security; /* 0 = share, 1 = user */ |
|
|
int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */ |
|
|
BOOL encrypt_passwords; /* FALSE = don't */ |
|
|
int MaxMPX, MaxVC, MaxRaw; |
|
|
unsigned int SessionKey, Capabilities; |
|
|
int SvrTZ; /* Server Time Zone */ |
|
|
int Encrypt_Key_Len; |
|
|
char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40]; |
|
|
char Svr_OS[80], Svr_LMType[80], Svr_PDom[80]; |
|
626 |
|
|
627 |
}; |
}; |
628 |
|
|
636 |
|
|
637 |
/* A Tree_Structure */ |
/* A Tree_Structure */ |
638 |
|
|
639 |
struct SMB_Tree_Structure { |
struct SMB_Tree_Structure |
640 |
|
{ |
641 |
|
|
642 |
SMB_Tree_Handle next, prev; |
SMB_Tree_Handle next, prev; |
643 |
SMB_Handle_Type con; |
SMB_Handle_Type con; |
644 |
char path[129]; |
char path[129]; |
645 |
char device_type[20]; |
char device_type[20]; |
646 |
int mbs; /* Local MBS */ |
int mbs; /* Local MBS */ |
647 |
int tid; |
int tid; |
648 |
|
|
649 |
}; |
}; |
650 |
|
|
651 |
typedef struct SMB_File_Def SMB_File; |
typedef struct SMB_File_Def SMB_File; |
652 |
|
|
653 |
struct SMB_File_Def { |
struct SMB_File_Def |
654 |
|
{ |
655 |
|
|
656 |
SMB_Tree_Handle tree; |
SMB_Tree_Handle tree; |
657 |
char filename[256]; /* We should malloc this ... */ |
char filename[256]; /* We should malloc this ... */ |
658 |
UWORD fid; |
UWORD fid; |
659 |
unsigned int lastmod; |
unsigned int lastmod; |
660 |
unsigned int size; /* Could blow up if 64bit files supported */ |
unsigned int size; /* Could blow up if 64bit files supported */ |
661 |
UWORD access; |
UWORD access; |
662 |
off_t fileloc; |
off_t fileloc; |
663 |
|
|
664 |
}; |
}; |
665 |
|
|
669 |
|
|
670 |
#ifndef SMBLIB_ERRNO |
#ifndef SMBLIB_ERRNO |
671 |
extern int SMBlib_errno; |
extern int SMBlib_errno; |
672 |
extern int SMBlib_SMB_Error; /* last Error */ |
extern int SMBlib_SMB_Error; /* last Error */ |
673 |
#endif |
#endif |
674 |
|
|
675 |
SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, SMB_Tree_Handle tree, |
SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, |
676 |
char *path, char *password, char *dev); |
SMB_Tree_Handle tree, |
677 |
|
char *path, |
678 |
|
char *password, |
679 |
|
char *dev); |