~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to helpers/ntlm_auth/smb_lm/smbval/smblib-priv.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

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