Bump versions.
[gsasl.git] / doc / specification / draft-leach-cifs-v1-spec-02.txt
blobfe80e677dd1e5e53e22d004e5138f1a8f3d9aa10
7 Network Working Group                    Paul J. Leach, Microsoft
8 INTERNET-DRAFT                           Dilip C. Naik, Microsoft
9 draft-leach-cifs-v1-spec-02.txt
10 Category: Informational
11 Expires September 13, 1997                         March 13, 1997
15            A Common Internet File System (CIFS/1.0) Protocol
17                            Preliminary Draft
20 Status of this Memo
22 This document is an Internet-Draft. Internet-Drafts are working
23 documents of the Internet Engineering Task Force (IETF), its areas, and
24 its working groups. Note that other groups may also distribute working
25 documents as Internet-Drafts.
27 Internet-Drafts are draft documents valid for a maximum of six months
28 and may be updated, replaced, or made obsolete by other documents at any
29 time. It is inappropriate to use Internet-Drafts as reference material
30 or to cite them other than as "work in progress".
32 To learn the current status of any Internet-Draft, please check the
33 "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow
34 Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe),
35 munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), or
36 ftp.isi.edu (US West Coast).
38 Distribution of this document is unlimited. Please send comments to the
39 authors at <cifs@microsoft.com>. Discussion of CIFS is on the mailing
40 list <cifs@listserv.msn.com>; subscribe by sending a message to
41 <ListServ@listserv.msn.com> with a body of "subscribe CIFS
42 you@your.domain". There is a CIFS home page at
43 <http://www.microsoft.com/intdev/cifs>.
46  Abstract
48 This document describes the CIFS file sharing protocol, version 1.0.
49 Client systems use this protocol to request file and  print services
50 from server systems over a network. It is based on the Server Message
51 Block protocol widely in use by personal computers and workstations
52 running a wide variety of operating systems.
54 Table Of Contents
56 STATUS OF THIS MEMO...................................................1
57 ABSTRACT..............................................................1
58 TABLE OF CONTENTS.....................................................1
59 1 INTRODUCTION.......................................................5
60  1.1 SUMMARY OF FEATURES.............................................5
62 Leach, Naik       expires September, 1997          [Page 1] \f
65 INTERNET-DRAFT            CIFS/1.0                  03/19/97
68   1.1.1  File access..........................................5
69   1.1.2  File and record locking..............................6
70   1.1.3  Safe caching, read-ahead, and write-behind...........6
71   1.1.4  File change notification.............................6
72   1.1.5  Protocol version negotiation.........................6
73   1.1.6  Extended attributes..................................6
74   1.1.7  Distributed replicated virtual volumes...............6
75   1.1.8  Server name resolution independence..................7
76   1.1.9  Batched requests.....................................7
77 2 PROTOCOL OPERATION OVERVIEW........................................7
78  2.1 SERVER NAME DETERMINATION.......................................7
79  2.2 SERVER NAME RESOLUTION..........................................8
80  2.3 SAMPLE MESSAGE FLOW.............................................8
81  2.4 MESSAGE FORMAT..................................................9
82   2.4.1  Notation.............................................9
83   2.4.2  SMB header..........................................10
84  2.5 CIFS PROTOCOL DIALECT NEGOTIATION..............................11
85  2.6 MESSAGE TRANSPORT..............................................11
86   2.6.1  Connection Establishment............................11
87   2.6.2  Server-side Connection Procedures...................12
88   2.6.3  Connection Management...............................12
89  2.7 OPPORTUNISTIC LOCKS............................................13
90   2.7.1  Exclusive Oplocks...................................13
91   2.7.2  Batch Oplocks.......................................14
92   2.7.3  Level II Oplocks....................................16
93  2.8 SECURITY MODEL.................................................17
94  2.9 RESOURCE SHARE/ACCESS EXAMPLE..................................18
95  2.10AUTHENTICATION.................................................19
96   2.10.1 Pre NT LM 0.12......................................20
97   2.10.2 NT LM 0.12..........................................21
98  2.11DISTRIBUTED FILESYSTEM (DFS) SUPPORT...........................21
99 3 SMB MESSAGE FORMATS AND DATA TYPES................................22
100  3.1 SMB HEADER.....................................................22
101   3.1.1  Flags field.........................................22
102   3.1.2  Flags2 Field........................................24
103   3.1.3  Tid Field...........................................24
104   3.1.4  Pid Field...........................................25
105   3.1.5  Mid Field...........................................25
106   3.1.6  Status Field........................................26
107   3.1.7  Timeouts............................................26
108   3.1.8  Data Buffer (BUFFER) and String Formats.............26
109  3.2 FILE NAMES.....................................................27
110  3.3 WILDCARDS......................................................28
111  3.4 DFS PATHNAMES..................................................28
112  3.5 TIME AND DATE ENCODING.........................................29
113  3.6 ACCESS MODE ENCODING...........................................30
114  3.7 ACCESS MASK ENCODING...........................................31
115  3.8 OPEN FUNCTION ENCODING.........................................32
116  3.9 OPEN ACTION ENCODING...........................................32
117  3.10FILE ATTRIBUTE ENCODING........................................33
118  3.11EXTENDED FILE ATTRIBUTE ENCODING...............................33
119  3.12BATCHING REQUESTS ("ANDX" MESSAGES)............................36
120  3.13"TRANSACTION" STYLE SUBPROTOCOLS...............................37
121   3.13.1 SMB_COM_TRANSACTION and SMB_COM_TRANSACTION2 Formats38
123 Leach, Naik       expires September, 1997          [Page 2] \f
126 INTERNET-DRAFT            CIFS/1.0                  03/19/97
129   3.13.2 SMB_COM_NT_TRANSACTION Formats......................40
130   3.13.3 Functional Description..............................42
131  3.14VALID SMB REQUESTS BY NEGOTIATED DIALECT.......................46
132 4 SMB REQUESTS......................................................47
133  4.1 SESSION REQUESTS...............................................48
134   4.1.1  NEGOTIATE: Negotiate Protocol.......................48
135   4.1.2  SESSION_SETUP_ANDX: Session Setup...................51
136   4.1.3  LOGOFF_ANDX: User Logoff............................56
137   4.1.4  TREE_CONNECT_ANDX:  Tree Connect....................56
138   4.1.5  TREE_DISCONNECT:  Tree Disconnect...................59
139   4.1.6  TRANS2_QUERY_FS_INFORMATION: Get File System Information    59
140   4.1.7  ECHO: Ping the Server...............................65
141   4.1.8  NT_CANCEL: Cancel request...........................65
142  4.2 FILE REQUESTS..................................................66
143   4.2.1  NT_CREATE_ANDX: Create or Open File.................66
144   4.2.2  NT_TRANSACT_CREATE: Create or Open File with EAs or SD69
145   4.2.3  CREATE_TEMPORARY: Create Temporary File.............70
146   4.2.4  READ_ANDX:  Read Bytes..............................71
147   4.2.5  WRITE_ANDX:  Write Bytes to file or resource........72
148   4.2.6  LOCKING_ANDX:  Lock or Unlock Byte Ranges...........73
149   4.2.7  SEEK: Seek in File..................................76
150   4.2.8  FLUSH: Flush File...................................78
151   4.2.9  CLOSE: Close File...................................78
152   4.2.10 DELETE: Delete File.................................79
153   4.2.11 RENAME: Rename File.................................80
154   4.2.12 MOVE:  Rename File..................................81
155   4.2.13 COPY: Copy File.....................................83
156   4.2.14 TRANS2_QUERY_PATH_INFORMATION: Get File Attributes given Path
157     84
158   4.2.15 TRANS2_QUERY_FILE_INFORMATION: Get File Attributes Given FID
159     91
160   4.2.16 TRANS2_SET_PATH_INFORMATION: Set File Attributes given Path 91
161   4.2.17 TRANS2_SET_FILE_INFORMATION: Set File Attributes Given FID  93
162  4.3 DIRECTORY REQUESTS.............................................94
163   4.3.1  DELETE_DIRECTORY: Delete Directory..................95
164   4.3.2  CHECK_DIRECTORY: Check Directory....................95
165   4.3.3  TRANS2_FIND_FIRST2: Search Directory using Wildcards96
166   4.3.4  TRANS2_FIND_NEXT2: Resume Directory Search Using Wildcards
167     101
168   4.3.5  FIND_CLOSE2: Close Directory Search................102
169   4.3.6  NT_TRANSACT_NOTIFY_CHANGE: Request Change Notification102
170  4.4 DFS OPERATIONS................................................104
171   4.4.1  TRANS2_GET_DFS_REFERRAL: Retrieve Distributed Filesystem
172   Referral..................................................104
173   4.4.2  TRANS2_REPORT_DFS_INCONSISTENCY: Inform a server about DFS
174   Error  107
175  4.5 PRINT SPOOLING OPERATIONS.....................................107
176   4.5.1  OPEN_PRINT_FILE: Create Print Spool file...........107
177   4.5.2  GET_PRINT_QUEUE: Get Printer Queue Entries.........108
178  4.6 MISCELLANEOUS OPERATIONS......................................110
179   4.6.1  NT_TRANSACT_IOCTL..................................110
180   4.6.2  NT_TRANSACT_QUERY_SECURITY_DESC....................110
181   4.6.3  NT_TRANSACT_SET_SECURITY_DESC......................111
182 5 OBSOLESCENT SMB REQUESTS.........................................111
184 Leach, Naik       expires September, 1997          [Page 3] \f
187 INTERNET-DRAFT            CIFS/1.0                  03/19/97
190  5.1 CLOSE_PRINT_FILE:  CLOSE AND SPOOL PRINT JOB..................111
191  5.2 CREATE: CREATE FILE...........................................112
192  5.3 CREATE_DIRECTORY: CREATE DIRECTORY............................113
193  5.4 CREATE_NEW: CREATE FILE.......................................113
194  5.5 LOCK_AND_READ: LOCK AND READ BYTES............................114
195  5.6 LOCK_BYTE_RANGE: LOCK BYTES...................................115
196  5.7 OPEN: OPEN FILE...............................................116
197  5.8 OPEN_ANDX:  OPEN FILE.........................................118
198  5.9 PROCESS_EXIT: PROCESS EXIT....................................119
199  5.10QUERY_INFORMATION:  GET FILE ATTRIBUTES.......................120
200  5.11QUERY_INFORMATION2: GET FILE INFORMATION......................120
201  5.12READ: READ FILE...............................................121
202  5.13READ_MPX: READ BLOCK MULTIPLEX................................122
203  5.14READ_RAW: READ RAW............................................124
204  5.15SEARCH: SEARCH DIRECTORY USING WILDCARDS......................126
205  5.16SET_INFORMATION: SET FILE ATTRIBUTES..........................128
206  5.17SET_INFORMATION2: SET FILE INFORMATION........................129
207  5.18QUERY_INFORMATION_DISK: GET DISK ATTRIBUTES...................129
208  5.19TRANS2_OPEN2: CREATE OR OPEN FILE WITH EXTENDED ATTRIBUTES....130
209  5.20TREE_CONNECT: TREE CONNECT....................................132
210  5.21UNLOCK_BYTE_RANGE: UNLOCK BYTES...............................132
211  5.22WRITE: WRITE BYTES............................................133
212  5.23WRITE_AND_UNLOCK: WRITE BYTES AND UNLOCK RANGE................134
213  5.24WRITE_AND_CLOSE:  WRITE BYTES AND CLOSE FILE..................135
214  5.25WRITE_MPX: WRITE BLOCK MULTIPLEX..............................136
215  5.26WRITE_PRINT_FILE: WRITE TO PRINT FILE.........................138
216  5.27WRITE_RAW: WRITE RAW BYTES....................................139
217 6 SMB SYMBOLIC CONSTANTS...........................................142
218  6.1 SMB COMMAND CODES.............................................142
219  6.2 SMB_COM_TRANSACTION2 SUBCOMMAND CODES.........................144
220  6.3 SMB_COM_NT_TRANSACTION SUBCOMMAND CODES.......................145
221  6.4 SMB PROTOCOL DIALECT CONSTANTS................................145
222 7 ERROR CODES AND CLASSES..........................................146
223 8 LEGAL NOTICE.....................................................150
224 9 REFERENCES.......................................................150
225 10SECURITY CONSIDERATIONS..........................................151
226  10.1SHARE LEVEL PROTECTION........................................151
227  10.2PLAINTEXT PASSWORD AUTHENTICATION.............................151
228  10.3LANMAN 2.1 (AND EARLIER) CHALLENGE/RESPONSE...................151
229   10.3.1 Known Plaintext Attacks............................152
230   10.3.2 Small Key Space....................................152
231   10.3.3 Chosen Plaintext Attacks...........................152
232   10.3.4 Dictionary Attacks.................................152
233   10.3.5 Badly Chosen Passwords.............................152
234  10.4NT LM 0.12 CHALLENGE/RESPONSE.................................153
235  10.5OTHER ATTACKS.................................................153
236   10.5.1 Hijack connections.................................153
237   10.5.2 Downgrade attack...................................153
238   10.5.3 Spoofing by Counterfeit Servers....................154
239   10.5.4 Storing Passwords Safely...........................154
240 11AUTHORS’ ADDRESSES...............................................154
245 Leach, Naik       expires September, 1997          [Page 4] \f
248 INTERNET-DRAFT            CIFS/1.0                  03/19/97
251 1  Introduction
253 This document describes the file and print sharing protocol for a
254 proposed Common Internet File System (CIFS). CIFS is intended to provide
255 an open cross-platform mechanism for client systems to request file and
256 print services from server systems over a network. It is based on the
257 standard Server Message Block (SMB) protocol widely in use by personal
258 computers and workstations running a wide variety of operating systems.
259 An earlier version of this protocol was documented as part of the X/OPEN
260 (now Open Group) CAE series of standards [7]; this document updates the
261 specification to include the latest shipping versions, and is published
262 to allow the creation of implementations that interoperate with those
263 implementations.
265 Use of the Internet and the World Wide Web has been characterized by
266 read-only access. Existing protocols such as FTP are good solutions for
267 one-way file transfer. However, new read/write interfaces will become
268 increasingly necessary as the Internet becomes more interactive and
269 collaborative. Adoption of a common file sharing protocol having modern
270 semantics such as shared files, byte-range locking, coherent caching,
271 change notification, replicated storage, etc. would provide important
272 benefits to the Internet community.
275 1.1  Summary of features
277 The protocol supports the following features:
279 o File access
281 o File and record locking
283 o Safe caching, read-ahead, and write-behind
285 o File change notification
287 o Protocol version negotiation
289 o Extended attributes
291 o Distributed replicated virtual volumes
293 o Server name resolution independence
295 o Batched requests
297 o Unicode file names
300 1.1.1        File access
302 The protocol supports the usual set of file operations: open, close,
303 read, write, and seek.
307 Leach, Naik       expires September, 1997          [Page 5] \f
310 INTERNET-DRAFT            CIFS/1.0                  03/19/97
313 1.1.2        File and record locking
315 The protocol supports file and record locking, as well as unlocked
316 access to files. Applications that lock files can not be improperly
317 interfered with by applications that do not; once a file or record is
318 locked, non-locking applications are denied access to the file.
321 1.1.3        Safe caching, read-ahead, and write-behind
323 The protocol supports caching, read-ahead, and write-behind, even for
324 unlocked files, as long as they are safe. All these optimizations are
325 safe as long as only one client is accessing a file; read-caching and
326 read-ahead are safe with many clients accessing a file as long as all
327 are just reading. If many clients are writing a file simultaneously,
328 then none are safe, and all file operations have to go to the server.
329 The protocol notifies all clients accessing a file of changes in the
330 number and access mode of clients accessing the file, so that they can
331 use the most optimized safe access method.
334 1.1.4        File change notification
336 Applications can register with a server to be notified if and when file
337 or directory contents are modified. They can use this to (for example)
338 know when a display needs to be refreshed, without having to constantly
339 poll the server.
342 1.1.5        Protocol version negotiation
344 There are several different versions and sub-versions of this protocol;
345 a particular version is referred to as a dialect.  When two machines
346 first come into network contact they negotiate the dialect to be used.
347 Different dialects can include both new messages as well as changes to
348 the fields and semantics of existing messages in other dialects.
351 1.1.6        Extended attributes
353 In addition to many built-in file attributes, such as creation and
354 modification times,  non-file system attributes can be added by
355 applications, such as the author's name, content description, etc.
358 1.1.7        Distributed replicated virtual volumes
360 The protocol supports file system subtrees which look like to clients as
361 if they are on a single volume and server, but which actually span
362 multiple volumes and servers. The files and directories of such a
363 subtree can be physically moved to different servers, and their names do
364 not have to change, isolating clients from changes in the server
365 configuration. These subtrees can also be transparently replicated for
366 load sharing and fault tolerance. When a client requests a file, the
368 Leach, Naik       expires September, 1997          [Page 6] \f
371 INTERNET-DRAFT            CIFS/1.0                  03/19/97
374 protocol uses referrals to transparently direct a client to the server
375 that stores it.
378 1.1.8        Server name resolution independence
380 The protocol allows clients to resolve server names using any name
381 resolution mechanism. In particular, it allows using the DNS, permitting
382 access to the file systems of other organizations over the Internet, or
383 hierarchical organization of servers' names within an organization.
384 Earlier versions of the protocol only supported a flat server name
385 space.
388 1.1.9       Batched requests
390 The protocol supports the batching of multiple requests into a single
391 message, in order to minimize round trip latencies, even when a later
392 request depends on the results of an earlier one.
395 2   Protocol Operation Overview
397 In order to access a file on a server, a client has to:
399 o Parse the full file name to determine the server name, and the
400   relative name within that server.
402 o Resolve the server name to a transport address (this may be cached)
404 o Make a connection to the server (if no connection is already
405   available)
407 o Exchange CIFS messages (see below for an example)
409 This process may be repeated as many times as desired. Once the
410 connection has been idle for a while, it may be torn down.
413 2.1  Server Name Determination
415 How the client determines the name of the server and the relative name
416 within the server  is outside of the scope of this specification.
417 However, just for expository purposes, here are three examples.
419 In the  URL "f               ile://fs.megacorp.com/users/fred/stuff.tx                                                                                                                t", the client
420 could take the part between the leading double slashes and the next
421 slash as the server name and the remainder as the relative name -- in
422 this example "fs.megacorp.com" and "/users/fred/stuff.txt",
423 respectively.
425 In the path name "\\corpserver\public\policy.doc" the client could take
426 the part between the leading double backslashes and the next slash as
430 Leach, Naik       expires September, 1997          [Page 7] \f
433 INTERNET-DRAFT            CIFS/1.0                  03/19/97
436 the server name, and the remainder as the relative name -- in this
437 example, "corpserver" and "\public\policy.doc" respectively.
439 In the path name "x:\policy.doc" the client could use "x" as an index
440 into a table that contains a server name and a file name prefix. If the
441 contents of such a table for "x" were "corpserver" and "\public", then
442 the server name and relative name would be the same as in the previous
443 example.
446 2.2  Server Name Resolution
448 Like server name determination, how the client resolves the name to the
449 transport address of the server is outside the scope of this
450 specification. All that is required by CIFS is that a CIFS client MUST
451 have some means to resolve the name of a CIFS server to a transport
452 address, and that a CIFS server MUST register its name with a name
453 resolution service known its clients.
455 Some examples of name resolution mechanisms include: using the Domain
456 Name System (DNS) [1,2], and using NETBIOS name resolution (see RFC 1001
457 and RFC 1002 [3,4]). The server name can also be specified as the string
458 form of an IPv4 address in the usual dotted decimal notation, e.g.,
459 "157.33.135.101"; in this case, "resolution" consists of converting to
460 the 32 bit IPv4 address.
462 Which method is used is configuration dependent; the default SHOULD be
463 DNS to encourage interoperability over the Internet.
465 Note: The name resolution mechanism used may place constraints on the
466 form of the server name; for example, in the case of NETBIOS, the server
467 name must be 15 characters or less, and be upper case.
470 2.3  Sample Message Flow
472 The following illustrates a typical message exchange sequence for a
473 client connecting to a user level server, opening a file, reading its
474 data, closing the file, and disconnecting from the server. Note: using
475 the CIFS request batching mechanism (called the "AndX" mechanism), the
476 second to sixth messages in this sequence can be combined into one, so
477 there are really only three round trips in the sequence, and the last
478 one can be done asynchronously by the client.
491 Leach, Naik       expires September, 1997          [Page 8] \f
494 INTERNET-DRAFT            CIFS/1.0                  03/19/97
498  Client Command             Server Response
499  ========================== =========================================
501  SMB_COM_NEGOTIATE          Must be the first message sent by client
502                             to the server.  Includes a list of SMB
503                             dialects supported by the client.  Server
504                             response indicates which SMB dialect
505                             should be used.
506  SMB_COM_SESSION_SETUP_ANDX Transmits the user's name and credentials
507                             to the server for verification.
508                             Successful server response has Uid field
509                             set in SMB header used for subsequent
510                             SMBs on behalf of this user.
511  SMB_COM_TREE_CONNECT       Transmits the name of the disk share the
512                             client wants to access.  Successful
513                             server response has Tid field set in SMB
514                             header used for subsequent SMBs referring
515                             to this resource.
516  SMB_COM_OPEN               Transmits the name of the file, relative
517                             to Tid, the client wants to open.
518                             Successful server response includes a
519                             file id (Fid) the client should supply
520                             for subsequent operations on this file.
521  SMB_COM_READ               Client supplies Tid, Fid, file offset,
522                             and number of bytes to read.  Successful
523                             server response includes the requested
524                             file data.
525  SMB_COM_CLOSE              Client closes the file represented by Tid
526                             and Fid.  Server responds with success
527                             code.
528  SMB_COM_TREE_DISCONNECT    Client disconnects from resource
529                             represented by Tid.
532 2.4  Message Format
534 Clients exchange messages with a server to access resources on that
535 server.  These messages are called Server Message Blocks (SMBs), and
536 every SMB message has a common format.
539 2.4.1        Notation
541 This specification makes use of "C"-like notation to describe the
542 formats of messages. Unlike the "C" language, which allows for
543 implementation flexibility in laying out structures, this specification
544 adopts the following rules.  Multi-byte values are always transmitted
545 least significant byte first. All fields, except "bit-fields", are
546 aligned on the nearest byte boundary (even if longer than a byte), and
547 there is no implicit padding. Fields using the "bit field" notation are
548 defined to be laid out within the structure with the first-named field
549 occupying the lowest order bits, the next named field the next lowest
550 order bits, and so on.
555 Leach, Naik       expires September, 1997          [Page 9] \f
558 INTERNET-DRAFT            CIFS/1.0                  03/19/97
561 2.4.2        SMB header
564 typedef unsigned char UCHAR;          // 8 unsigned bits
565 typedef unsigned short USHORT;        // 16 unsigned bits
566 typedef unsigned long ULONG;          // 32 unsigned bits
568 typedef struct {
569     ULONG LowPart;
570     LONG HighPart;
571 } LARGE_INTEGER;                      // 64 bits of data
573 typedef struct  {
574     UCHAR Protocol[4];                // Contains 0xFF,'SMB'
575     UCHAR Command;                    // Command code
576     union {
577         struct {
578             UCHAR ErrorClass;         // Error class
579             UCHAR Reserved;           // Reserved for future use
580             USHORT Error;             // Error code
581         } DosError;
582         ULONG Status;                 // 32-bit error code
583     } Status;
584     UCHAR Flags;                      // Flags
585     USHORT Flags2;                    // More flags
586     union {
587         USHORT Pad[6];                // Ensure section is 12 bytes long
588         struct {
589             USHORT PidHigh;           // High part of PID
590             ULONG  Unused;            // Not used
591             ULONG  Unused2;
592     } Extra;
593     };
594     USHORT Tid;                       // Tree identifier
595     USHORT Pid;                       // Caller's process id
596     USHORT Uid;                       // Unauthenticated user id
597     USHORT Mid;                       // multiplex id
598     UCHAR  WordCount;                 // Count of parameter words
599     USHORT ParameterWords[ WordCount ];    // The parameter words
600     USHORT ByteCount;                 // Count of bytes
601     UCHAR  Buffer[ ByteCount ];       // The bytes
602 } SMB_HEADER;
605 All SMBs have identical format up to the ParameterWords fields.
606 Different SMBs have a different number and interpretation of
607 ParameterWords and Buffer.  All reserved fields in the SMB header must
608 be zero.
610 o Command is the operation code which this SMB is requesting, or
611   responding to.
613 o Status.DosError.ErrorClass and Status.DosError.Error are set by the
614   server and combine to give the error code of any failed server
615   operation.  If the client is capable of receiving 32 bit error
617 Leach, Naik       expires September, 1997         [Page 10] \f
620 INTERNET-DRAFT            CIFS/1.0                  03/19/97
623   returns, the status is returned in Status.Status instead.  When an
624   error is returned, the server may choose to return only the header
625   portion of the response SMB.
627 o Flags and Flags2 contain bits which, depending on the negotiated
628   protocol dialect, indicate various client capabilities.
630 o PidHigh is used in the NtCreateAndX request SMB
632 o Tid identifies the subdirectory, or "tree", on the server which the
633   client is accessing.  SMBs which do not reference a particular tree
634   should set Tid to 0xFFFF.
636 o Pid is the caller's process id, and is generated by the client to
637   uniquely identify a process within the client computer.
639 o Mid is reserved for multiplexing multiple messages on a single
640   transport connection.  A response message will always contain the
641   same value as the corresponding request message. The client MUST not
642   have multiple outstanding requests to a server with the same Mid.
645 2.5  CIFS Protocol Dialect Negotiation
647 The first message sent from an CIFS client to an CIFS server must be one
648 whose Command field is SMB_COM_NEGOTIATE.  The format of this client
649 request includes an array of NULL terminated strings indicating the
650 dialects of the CIFS protocol which the client supports.  The server
651 compares this list against the list of dialects the server supports and
652 returns the index of the chosen dialect in the response message.
655 2.6  Message Transport
657 When using a reliable connection oriented transport, the CIFS protocol
658 makes no higher level attempts to ensure sequenced delivery of messages
659 between the client and server.  The transport must have some mechanism
660 to detect failures of either the client or server node, and to deliver
661 such an indication to the client or server software so they can clean up
662 state.  When a reliable transport connection from a client terminates,
663 all work in progress by that client is terminated by the server and all
664 resources open by that client on the server are closed. Message
665 transport is done using NETBIOS session service (see section 5.3 of RFC
666 1001 and section 4.3 of RFC 1002).
669 2.6.1        Connection Establishment
671 After the server name has been resolved to an IP address, then a
672 connection to the server needs to be established if one has not already
673 been set up. Connection establishment is done using the Call primitive
674 of the NETBIOS session service, which requires the client to provide a
675 "calling name" and a "called name". The calling name is not significant
676 in CIFS, except that an identical name from the same transport address
678 Leach, Naik       expires September, 1997         [Page 11] \f
681 INTERNET-DRAFT            CIFS/1.0                  03/19/97
684 is assumed to represent the same client; the called name is always
685 "*SMBSERVER      ". Over TCP, the Call primitive results in a "Session
686 Request" packet to port 139 (see section 4.3.2 of RFC 1002).
689 2.6.1.1   Backwards compatability
691 If a CIFS client wishes to interoperate with older SMB servers, then if
692 the Call is rejected by the server, it can retry with a new called name.
693 The choice of the new called name depends on the name resolution
694 mechanism used. If DNS was used, the called name should be constructed
695 from the first component of the server's DNS name, truncated to 15
696 characters if necessary, and then padded to 16 characters with blank (20
697 hex) characters. If NETBIOS was used, then the called named is just the
698 NETBIOS name. If these fail, then a NETBIOS "Adapter Status" request may
699 be made to obtain the server's NETBIOS name, and the connection
700 establishment retried with that as the called name.
703 2.6.2        Server-side Connection Procedures
705 A CIFS server MUST register a NETBIOS Listen that accepts any calling
706 name on the name "*SMBSERVER     ".
708 In addition, if it wishes to support older SMB clients, it MAY have a
709 NETBIOS name and register a Listen on that name.
712 2.6.3        Connection Management
714 Once a connection is established, the rules for reliable transport
715 connection dissolution are:
717 o If a server receives a transport establishment request from a client
718   with which it is already conversing, the server may terminate all
719   other transport connections to that client.  This is to recover from
720   the situation where the client was suddenly rebooted and was unable
721   to cleanly terminate its resource sharing activities with the server.
723 o A server may drop the transport connection to a client at any time if
724   the client is generating malformed or illogical requests.  However,
725   wherever possible the server should first return an error code to the
726   client indicating the cause of the abort.
728 o If a server gets a hard error on the transport (such as a send
729   failure) the transport connection to that client may be aborted.
731 o A server may terminate the transport connection when the client has
732   no open resources on the server, however, we recommend that the
733   termination be performed only after some time has passed or if
734   resources are scarce on the server.  This will help performance in
735   that the transport connection will not need to be reestablished if
736   activity soon begins anew. Client software is expected to be able to
737   automatically reconnect to the server if this happens..
739 Leach, Naik       expires September, 1997         [Page 12] \f
742 INTERNET-DRAFT            CIFS/1.0                  03/19/97
745 2.7  Opportunistic Locks
747 Network performance can be increased if the client can locally buffer
748 file data.  For example, the client does not have to write information
749 into a file on the server if the client knows that no other process is
750 accessing the data.  Likewise, the client can buffer read-ahead data
751 from the file if the client knows that no other process is writing the
752 data.
754 The mechanism which allows clients to dynamically alter their buffering
755 strategy in a consistent manner is knows as "opportunistic locks", or
756 oplocks for short.  Versions of the CIFS file sharing protocol including
757 and newer than the "LANMAN1.0" dialect support oplocks.
759 There are three different types of oplocks:
761 o An exclusive oplock allows a client to open a file for exclusive
762   access and allows the client to perform arbitrary buffering
764 o A batch oplock allows a client to keep a file open on the server even
765   though the local accessor on the client machine has closed the file.
767 o A Level II oplock indicates there are multiple readers of a file, and
768   no writers.  Level II oplocks are supported if the negotiated dialect
769   is NT LM 0.12 or later.
771 When a client opens a file, it requests the server to grant it a
772 particular type of oplock on the file.  The response from the server
773 indicates the type of oplock granted to the client.  The client uses the
774 granted oplock type to adjust its buffering policy.
776 The SMB_COM_LOCKING_ANDX SMB is used to convey oplock break and response
777 information.
780 2.7.1        Exclusive Oplocks
782 If a client is granted an exclusive oplock, it may buffer lock
783 information, read-ahead data, and write data on the client because the
784 client knows that it is the only accessor to the file.  The basic
785 protocol is that the redirector on the client opens the file requesting
786 that an oplock be given to the client.  If the file is open by anyone
787 else, then the client is refused the oplock and no local buffering may
788 be performed on the local client.  This also means that no readahead may
789 be performed to the file, unless the redirector knows that it has the
790 read ahead range locked.  If the server grants the exclusive oplock, the
791 client can perform certain optimizations for the file such as buffering
792 lock, read, and write data.
800 Leach, Naik       expires September, 1997         [Page 13] \f
803 INTERNET-DRAFT            CIFS/1.0                  03/19/97
806 The exclusive oplock protocol is:
809    Client                       <-> Server
811    A               B
812    ==============  ===========  === ================================
814    Open ("foo")                 ->
815                                 <-  Open OK.  Exclusive oplock
816                                      granted.
817                    Open("foo")  ->
818                                 <-  oplock break to A
819    lock(s)                      ->
820                                 <-  lock(s) response(s)
821    write(s)                     ->
822                                 <-  write(s) response(s)
823    close or done                ->
824                                 <-  open response to B
828 As can be seen, when client A opens the file, it can request an
829 exclusive oplock.  Provided no one else has the file open on the server,
830 then the oplock is granted to client A.  If, at some point in the
831 future, another client, such as client B, requests an open to the same
832 file, then the server must have client A break its oplock.  Breaking the
833 oplock involves client A sending the server any lock or write data that
834 it has buffered, and then letting the server know that it has
835 acknowledged that the oplock has been broken.  This synchronization
836 message informs the server that it is now permissible to allow client B
837 to complete its open.
839 Client A must also purge any readahead buffers that it has for the file.
840 This is not shown in the above diagram since no network traffic is
841 needed to do this.
844 2.7.2        Batch Oplocks
846 Batch oplocks are used where common programs on a client behave in such
847 a way that causes the amount of network traffic on a wire to go beyond
848 an acceptable level for the functionality provided by the program.
850 For example, the command processor executes commands from within a
851 command procedure by performing the following steps:
853   o Opening the command procedure.
855   o Seeking to the "next" line in the file.
857   o Reading the line from the file.
859   o Closing the file.
861   o Executing the command.
865 Leach, Naik       expires September, 1997         [Page 14] \f
868 INTERNET-DRAFT            CIFS/1.0                  03/19/97
871 This process is repeated for each command executed from the command
872 procedure file.  As is obvious, this type of programming model causes an
873 inordinate amount of processing of files, thereby creating a lot of
874 network traffic that could otherwise be curtailed if the program were to
875 simply open the file, read a line, execute the command, and then read
876 the next line.
878 Batch oplocking curtails the amount of network traffic by allowing the
879 client to skip the extraneous open and close requests.  When the command
880 processor then asks for the next line in the file, the client can either
881 ask for the next line from the server, or it may have already read the
882 data from the file as readahead data.  In either case, the amount of
883 network traffic from the client is greatly reduced.
885 If the server receives either a rename or a delete request for the file
886 that has a batch oplock, it must inform the client that the oplock is to
887 be broken.  The client can then change to a mode where the file is
888 repeatedly opened and closed.
890 The batch oplock protocol is:
894    Client                    <->  Server
896    A            B
897    ===========  ============ ==== ===============================
899    Open("foo")               ->
900                              <-   Open OK.  Batch oplock granted.
901    Read                      ->
902                              <-   data
903    <close>
904    <open>
905    <seek>
906                              ->   read
907                              <-   data
908    <close>
909                 Open("foo")  ->
910                              <-   Oplock break to A
911    Close                     ->
912                              <-   Close OK to A
913                              <-   Open OK to B
917 When client A opens the file, it can request an oplock.  Provided no one
918 else has the file open on the server, then the oplock is granted to
919 client A.  Client A, in this case, keeps the file open for its caller
920 across multiple open/close operations.  Data may be read ahead for the
921 caller and other optimizations, such as buffering locks, can also be
922 performed.
924 When another client requests an open, rename, or delete operation to the
925 server for the file, however, client A must cleanup its buffered data
926 and synchronize with the server.  Most of the time this involves
927 actually closing the file, provided that client A's caller actually
930 Leach, Naik       expires September, 1997         [Page 15] \f
933 INTERNET-DRAFT            CIFS/1.0                  03/19/97
936 believes that he has closed the file.  Once the file is actually closed,
937 client B's open request can be completed.
940 2.7.3        Level II Oplocks
942 Level II oplocks allow multiple clients to have the same file open,
943 providing that no client is performing write operations to the file.
944 This is important for many environments because most compatibility mode
945 opens from down-level clients map to an open request for shared
946 read/write access to the file.  While it makes sense to do this, it also
947 tends to break oplocks for other clients even though neither client
948 actually intends to write to the file.
950 The Level II oplock protocol is:
954    Client                    <->  Server
956    A            B
957    ===========  ===========  ==== ====================================
959    Open("foo")               ->
960                              <-   Open OK.  Exclusive oplock granted.
961    Read                      ->
962                              <-   data
963                 Open("foo")  ->
964                              <-   Break to Level II oplock to A
965    lock(s)                   ->
966                              <-   lock(s) response(s)
967    done                      ->
968                              <-   Open OK.  Oplock II oplock granted
969                                    to B
972 This sequence of events is very much like an exclusive oplock.  The
973 basic difference is that the server informs the client that it should
974 break to a level II lock when no one has been writing the file.  That
975 is, client A, for example, may have opened the file for a desired access
976 of READ, and a share access of READ/WRITE.  This means, by definition,
977 that client A will not performed any writes to the file.
979 When client B opens the file, the server must synchronize with client A
980 in case client A has any buffered locks.  Once it is synchronized,
981 client B's open request may be completed.  Client B, however, is
982 informed that he has a level II oplock, rather than an exclusive oplock
983 to the file.
985 In this case, no client that has the file open with a level II oplock
986 may buffer any lock information on the local client machine.  This
987 allows the server to guarantee that if any write operation is performed,
988 it need only notify the level II clients that the lock should be broken
989 without having to synchronize all of the accessors of the file.
991 The level II oplock may be broken to none, meaning that some client that
992 had the file opened has now performed a write operation to the file.
995 Leach, Naik       expires September, 1997         [Page 16] \f
998 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1001 Because no level II client may buffer lock information, the server is in
1002 a consistent state.  The writing client, for example, could not have
1003 written to a locked range, by definition.  Read ahead data may be
1004 buffered in the client machines, however, thereby cutting down on the
1005 amount of network traffic required to the file.  Once the level II
1006 oplock is broken, however, the buffering client must flush its buffers
1007 and degrade to performing all operations on the file across the network.
1008 No oplock break response is expected from a client when the server
1009 breaks a client from level II to none.
1012 2.8  Security Model
1014 Each server makes a set of resources available to clients on the
1015 network.  A resource being shared may be a directory tree, named pipe,
1016 printer, etc.  So far as clients are concerned, the server has no
1017 storage or service dependencies on any other servers; a client considers
1018 the server to be the sole provider of the file (or other resource) being
1019 accessed.
1021 The CIFS protocol requires server authentication of users before file
1022 accesses are allowed, and each server authenticates its own users.  A
1023 client system must send authentication information to the server before
1024 the server will allow access to its resources.
1026 The CIFS protocol defines two methods which can be selected by the
1027 server for security:  share level and user level:
1030 o A share level server makes some directory on a disk device (or other
1031   resource) available.  An optional password may be required to gain
1032   access.  Thus any user on the network who knows the name of the
1033   server, the name of the resource and the password has access to the
1034   resource.  Share level security servers may use different passwords
1035   for the same shared resource with different passwords allowing
1036   different levels of access.
1039 o A user level server makes some directory on a disk device (or other
1040   resource) available but in addition requires the client to provide a
1041   user name and corresponding user password to gain access. User level
1042   servers are preferred over share level servers for any new server
1043   implementation, since organizations generally find user level servers
1044   easier to administer as employees come and go. User level servers may 
1045   use the account name to check access control lists on individual
1046   files, or may have one access control list that applies to all files
1047   in the directory.
1049 When a user level server validates the account name and password
1050 presented by the client, an identifier representing that authenticated
1051 instance of the user is returned to the client in the Uid field of the
1052 response SMB.  This Uid must be included in all further requests made on
1053 behalf of the user from that client.  A share level server returns no
1054 useful information in the Uid field.
1058 Leach, Naik       expires September, 1997         [Page 17] \f
1061 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1064 The user level security model was added after the original dialect of
1065 the CIFS protocol was issued, and subsequently some clients may not be
1066 capable of sending account name and passwords to the server.  A server
1067 in user level security mode communicating with one of these clients will
1068 allow a client to connect to resources even if the client has not sent
1069 account name and password information:
1071 1. If the client's computer name is identical to an account-name known
1072 on the server, and if the password supplied to connect to the shared
1073 resource matches that account’s password, an implicit "user logon" will
1074 be performed using those values.
1076 If the above fails, the server may fail the request or assign a default
1077 account name of its choice.
1079 2. The value of Uid in subsequent requests by the client will be ignored
1080 and all access will be validated assuming the account name selected
1081 above.
1084 2.9  Resource Share/Access Example
1086 The following examples illustrate a possible command line user interface
1087 for a server to offer a disk resource, and for a client to connect to
1088 and use that resource.
1090 a) NET SHARE
1092 The NET SHARE command, when executed on the server, specifies a
1093 directory name to be made available to clients on the network.  A share
1094 name must be given, and this name is presented by clients wishing to
1095 access the directory.
1097   Examples:
1099      NET SHARE  src=c:\dir1\src  "bonzo"
1101      assigns password bonzo to all files within directory c:\dir1\src
1102      and its subdirectories with the share name src being the name used
1103      to connect to this resource.
1105   NET SHARE  c=c:\        " "        RO
1107   NET SHARE  work=c:\work  "flipper"  RW
1109      offers read-only access to everything on the C drive. Offers read-
1110      write access to all files within the C:\work directory and its
1111      subdirectories.
1113 The above example is appropriate for servers operating as a share level
1114 server.  A user level server would not require the permissions or
1115 password, since the combination of the client's account name and
1116 specific access control lists on files is sufficient to govern access.
1119 Leach, Naik       expires September, 1997         [Page 18] \f
1122 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1125 b) NET USE
1127 Clients can gain access to one or more offered directories via the NET
1128 USE command.  Once the NET USE command is issued the user can access the
1129 files freely without further special requirements.
1131   Examples:
1133   1.  NET USE  d: \\Server1\src  "bonzo"
1135      gains full access to the files and directories on Server1 matching
1136      the offer defined by the netname src with the password of bonzo.
1137      The user may now address files on Server1 c:\dir1\src by
1138      referencing d:. E.g. "type d:srcfile1.c".
1140   2.  NET USE  e: \\Server1\c
1142   3.  NET USE  f: \\Server1\work   "flipper"
1144      Now any read request to any file on that node (drive c) is valid
1145      (e.g. "type e:\bin\foo.bat").  Read-write requests only succeed to
1146      files whose pathnames start with f: (e.g. "copy foo f:foo.tmp"
1147      copies foo to Server1 c:\work\foo.tmp).
1149 For user level servers, the client would not provide a password with the
1150 NET USE command.
1152 The client software must remember the drive identifier supplied with the
1153 NET USE request and associate it with the Tid value returned by the
1154 server in the SMB header.  Subsequent requests using this Tid must
1155 include only the pathname relative to the connected subtree as the
1156 server treats the subtree as the root directory (virtual root).  When
1157 the user references one of the remote drives, the client software looks
1158 through its list of drives for that node and includes the tree id
1159 associated with this drive in the Tid field of each request.
1161 Note that one shares a directory and all files underneath that directory
1162 are then affected.  If a particular file is within the range of multiple
1163 shares, connecting to any of the share ranges gains access to the file
1164 with the permissions specified for the offer named in the NET USE.  The
1165 server will not check for nested directories with more restrictive
1166 permissions.
1169 2.10       Authentication
1171 An CIFS server keeps an encrypted form of a client’s password.  To gain
1172 authenticated access to server resources, the server sends a challenge
1173 to the client, which the client responds to in a way that proves it
1174 knows the client's password.
1176 Authentication makes use of DES encryption [5] in block mode.  We denote
1177 the DES encryption function as E(K,D), which accepts a seven byte key
1178 (K) and an eight byte data block (D) and produces an eight byte
1180 Leach, Naik       expires September, 1997         [Page 19] \f
1183 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1186 encrypted data block as its value.  If the data to be encrypted is
1187 longer than eight bytes, the encryption function is applied to each
1188 block of eight bytes in sequence and the results are appended together.
1189 If the key is longer than seven bytes, the data is first completely
1190 encrypted using the first seven bytes of the key, then the second seven
1191 bytes, etc., appending the results each time.  In other words, to
1192 encrypt the 16 byte quantity D0D1 with the 14 byte key K0K1,
1194     E(K0K1,D0D1) = E(K0,D0)E(K0,D1)E(K1,D0)E(K1,D1)
1196 The EncryptionKey field in the SMB_COM_NEGPROT response contains an 8
1197 byte challenge denoted below as "C8", chosen to be unique to prevent
1198 replay attacks; the client responds with a 24 byte response denoted
1199 "P24", and computed as described below. (Note: the name "EncryptionKey"
1200 is historical -- it doesn't actually hold an encryption key.)
1202 Clients send the response to the challenge in the SMB_COM_TREE_CONNECT,
1203 SMB_COM_TREE_CONNECT_ANDX, and/or SMB_COM_SESSION_SETUP_ANDX request
1204 which follows the SMB_COM_NEGPROT message exchange.  The server must
1205 validate the response by performing the same computations the client did
1206 to create it, and ensuring the strings match.
1208 If the comparisons fail, the client system may be incapable of
1209 encryption; if so the string may be the user password in clear text.
1210 The server should try to validating the string as though it were the
1211 unencrypted password.
1213 The SMB field used to store the response depends upon the request:
1215      o Password in SMB_COM_TREE_CONNECT
1217      o Password in SMB_COM_TREE_CONNECT_ANDX
1219      o AccountPassword in SMB_COM_SESSION_SETUP_ANDX
1221 (Note: again, the names are historical, and do not reflect this usage.)
1223 The contents of the response to the challenge depends on the CIFS
1224 dialect, as outlined in the following sections:
1227 2.10.1     Pre NT LM 0.12
1229 o The client and server both compute
1231     P16 = E(P14,S8)
1233         and
1235     P24 = E(P21,C8)
1237 where:
1241 Leach, Naik       expires September, 1997         [Page 20] \f
1244 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1247   o P14 is a 14 byte string containing the user’s password in clear
1248      text, upper cased, padded with spaces
1250   o S8 is an eight byte string whose value is available from Microsoft
1251      upon request.
1253   o P21 is a twenty one byte string obtained by appending five null
1254      bytes to the string P16, just computed
1256   o C8 is the value of the challenge sent in the EncryptionKey field in
1257      the SMB_COM_NEGPROT response for this connection.
1260 2.10.2     NT LM 0.12
1262 The client and server both compute
1264     P16 = MD4(U(PN))
1266         and
1268     P24 = E(P21, C8)
1270 where:
1272   o PN is a string containing the user’s password in clear text, case
1273      sensitive, no maximum length
1275   o U(x) of an ASCII string "x" is that string converted to Unicode
1277   o MD4(x) of an octet string "x" is the 16 byte MD4 message digest [6]
1278      of that string
1280   o P21 and C8 are as above.
1283 2.11       Distributed Filesystem (DFS) Support
1285 Protocol dialects of NT LM 0.12 and later support distributed filesystem
1286 operations. The distributed filesystem gives a way for this protocol to
1287 use a single consistent file naming scheme which may span a collection
1288 of different servers and shares. The distributed filesystem model
1289 employed is a referral - based model. This protocol specifies the manner
1290 in which clients receive referrals.
1292 The client can set a flag in the request SMB header indicating that the
1293 client wants the server to resolve this SMB's paths within the DFS known
1294 to the server. The server attempts to resolve the requested name to a
1295 file contained within the local directory tree indicated by the TID of
1296 the request and proceeds normally. If the request pathname resolves to a
1297 file on a different system, the server returns the following error:
1299   STATUS_DFS_PATH_NOT_COVERED - the server does not support the part
1300   of the DFS namespace needed to resolved the pathname in the request.
1302 Leach, Naik       expires September, 1997         [Page 21] \f
1305 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1308   The client should request a referral from this server for further
1309   information.
1311 A client asks for a referral with the TRANS2_DFS_GET_REFERRAL request
1312 containing the DFS pathname of interest. The response from the server
1313 indicates how the client should proceed.
1315 The method by which the topological knowledge of the DFS is stored and
1316 maintained by the servers is not specified by this protocol.
1319 3   SMB Message Formats and Data Types
1321 This section describes the entire set of SMB commands and responses
1322 exchanged between CIFS clients and servers.  It also details which SMBs
1323 are introduced into the protocol as higher dialect levels are
1324 negotiated.
1327 3.1  SMB Header
1329 While each SMB command has specific encodings, there are some fields in
1330 the SMB header which have meaning to all SMBs.  These fields and
1331 considerations are described in the following sections.
1334 3.1.1        Flags field
1336 This field contains 8 individual flags, numbered from least significant
1337 to most significant, and have the following meanings:
1364 Leach, Naik       expires September, 1997         [Page 22] \f
1367 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1371 Bit  Meaning                                           Earliest
1372 ===  ================================================  Dialect
1373                                                        ============
1375  0   When set (returned) from the server in the        LANMAN1.0
1376      SMB_COM_NEGOTIATE response SMB, this bit
1377      indicates that the server  supports the "sub
1378      dialect" consisting of the LockandRead and
1379      WriteandUnlock protocols defined later in this
1380      document.
1381 1    When on (on an SMB request being sent to the
1382      server), the client guarantees that there is a
1383      receive buffer posted such that a send without
1384      acknowledgment can be used by the server to
1385      respond to the client's request.
1386 2    Reserved (must be zero).
1387 3    When on, all pathnames in this SMB must be        LANMAN1.0
1388      treated as caseless.  When off, the pathnames
1389      are case sensitive.
1390 4    When on (in  SMB_COM_SESSION_SETUP_ANDX  defined  LANMAN1.0
1391      later in this document), all paths sent to the
1392      server by the client are already canonicalized.
1393      This means that file/directory names are in
1394      upper case, are valid characters, . and .. have
1395      been removed, and single backslashes are used as
1396      separators.
1397 5    When on (in  SMB_COM_OPEN, SMB_COM_CREATE and     LANMAN1.0
1398      SMB_COM_CREATE_NEW), this indicates that the
1399      client is requesting that the file be
1400      "opportunistically" locked if this process is
1401      the only process which has the file open at the
1402      time of the open request.  If the server
1403      "grants" this oplock request, then this bit
1404      should remain set in the corresponding response
1405      SMB to indicate to the client that the oplock
1406      request was granted.  See the discussion of
1407      "oplock" in the sections defining the
1408      SMB_COM_OPEN_ANDX and SMB_COM_LOCKING_ANDX
1409      protocols later in this document (this bit has
1410      the same function as bit 1 of Flags if the
1411      SMB_COM_OPEN_ANDX SMB).
1412 6    When on (in core protocols SMB_COM_OPEN_ANDX,     LANMAN1.0
1413      SMB_COM_CREATE and SMB_COM_CREATE_NEW), this
1414      indicates that the server should notify the
1415      client on any action which can modify the file
1416      (delete, setattrib, rename, etc.) by another
1417      client.  If not set, the server need only notify
1418      the client about another open request by a
1419      different client.  See the discussion of
1420      "oplock" in the sections defining the
1421      SMB_COM_OPEN_ANDX  and SMB_COM_LOCKING_ANDX SMBs
1422      later in this document (this bit has the same
1423      function as bit 2 of smb_flags of the
1424      SMB_COM_OPEN_ANDX SMB).  Bit6 only has meaning
1427 Leach, Naik       expires September, 1997         [Page 23] \f
1430 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1434      if bit5 is set..
1435 7    When on, this SMB is being sent from the server   PC NETWORK
1436      in response to a client request.  The Command     PROGRAM 1.0
1437      field usually contains the same value in a
1438      protocol request from the client to the server
1439      as in the matching response from the server to
1440      the client.  This bit unambiguously
1441      distinguishes the command request from the
1442      command response.
1445 3.1.2        Flags2 Field
1447 This field contains six individual flags, numbered from least
1448 significant bit to most significant bit, which are defined below.  Flags
1449 which not defined must be set to zero.
1452  Bit  Meaning                                          Earliest
1453  ===  ===============================================  Dialect
1454                                                        ============
1456  0    If set in a request, the server may return long
1457       components in path names in the response.
1458  1    If set, the client is aware of extended
1459       attributes.
1460  12   If set, any request pathnames in this SMB        NT LM 0.12
1461       should be resolved in the Distributed File
1462       System.
1463  13   If set, indicates that a read will be permitted
1464       if the client does not have read permission but
1465       does have execute permission.  This flag is
1466       only useful on a read request.
1467  14   If set, specifies that the returned error code   NT LM 0.12
1468       is a 32 bit error code in Status.Status.
1469       Otherwise the Status.DosError.ErrorClass and
1470       Status.DosError.Error fields contain the DOS-
1471       style error information.  When passing NT
1472       status codes is negotiated, this flag should be
1473       set for every SMB.
1474  15   If set, any fields of datatype STRING in this    NT LM 0.12
1475       SMB message are encoded as UNICODE.  Otherwise,
1476       they are in ASCII.
1479 3.1.3        Tid Field
1481 Tid represents an instance of an authenticated connection to a server
1482 resource.  Tid is returned by the server to the client when the client
1483 successfully connects to a resource, and the client uses Tid in
1484 subsequent requests referring to the resource.
1486 If the server is executing in share level security mode, Tid is the only
1487 thing used to allow access to the shared resource. Thus if the user is
1488 able to perform a successful connection to the server specifying the
1489 appropriate netname and passwd (if any) the resource may be accessed
1493 Leach, Naik       expires September, 1997         [Page 24] \f
1496 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1499 according to the access rights associated with the shared resource (same
1500 for all who gained access this way).
1502 If however the server is executing in user level security mode, access
1503 to the resource is based on the Uid (validated on the
1504 SMB_COM_SESSION_SETUP_ANDX request) and the Tid is NOT associated with
1505 access control but rather merely defines the resource (such as the
1506 shared directory tree).
1508 In most SMB requests, Tid must contain a valid value. Exceptions include
1509 prior to getting a Tid established including SMB_COM_NEGOTIATE,
1510 SMB_COM_TREE_CONNECT, SMB_COM_ECHO, and SMB_COM_SESSION_SETUP_ANDX.
1511 0xFFFF should be used for Tid for these situations.  The server is
1512 always responsible for enforcing use of a valid Tid where appropriate.
1515 3.1.4        Pid Field
1517 Pid uniquely identifies a client process.  Clients inform servers of the
1518 creation of a new process by simply introducing a new Pid value into the
1519 dialogue for new processes.
1521 In the core protocol, the SMB_COM_PROCESS_EXIT SMB was used to indicate
1522 the catastrophic termination of a process on the client.  In the single
1523 tasking DOS system, it was possible for hard errors to occur causing the
1524 destruction of the process with files remaining open.  Thus a
1525 SMB_COM_PROCESS_EXIT SMB was sent for this occurrence to allow the
1526 server to close all files opened by that process.
1528 In the LANMAN 1.0 and newer dialects, no SMB_COM_PROCESS_EXIT SMB is
1529 sent.  The client operating system must ensure that the appropriate
1530 close and cleanup SMBs will be sent when the last process referencing
1531 the file closes it.  From the server's point of view, there is no
1532 concept of FIDs "belonging to" processes.  A FID returned by the server
1533 to one process may be used by any other process using the same transport
1534 connection and Tid.  There is no process creation SMB sent to the
1535 server; it is up to the client to ensure only valid client processes
1536 gain access to Fids (and Tids).  On SMB_COM_TREE_DISCONNECT (or when the
1537 client and server session is terminated) the server will invalidate any
1538 files opened by any process on that client.
1541 3.1.5        Mid Field
1543 Clients using the LANMAN 1.0 and newer dialects will typically be
1544 multitasked and allow multiple asynchronous input/output requests per
1545 task.  Therefore a multiplex ID (Mid) is used along with Pid to allow
1546 multiplexing the single client and server connection among the client's
1547 multiple processes, threads, and requests per thread.
1549 Regardless of negotiated dialect, the server is responsible for ensuring
1550 that every response contains the same Mid and Pid values as its request.
1551 The client may then use the Mid and Pid values for associating requests
1554 Leach, Naik       expires September, 1997         [Page 25] \f
1557 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1560 and responses and may have up to the negotiated number of requests
1561 outstanding at any time to a particular server.
1564 3.1.6        Status Field
1566 An SMB returns error information to the client in the Status field.
1567 Protocol dialects prior to NT LM 0.12 return status to the client using
1568 the combination of Status.DosError.ErrorClass and Status.DosError.Error.
1569 Beginning with NT LM 0.12 CIFS servers can return 32 bit error
1570 information to clients using Status.Status if the incoming client SMB
1571 has bit 14 set in the Flags2 field of the SMB header. The contents of
1572 response parameters is not guaranteed in the case of an error return,
1573 and must be ignored.  For write behind activity, a subsequent write or
1574 close of the file may return the fact that a previous write failed.
1575 Normally write behind failures are limited to hard disk errors and
1576 device out of space.
1579 3.1.7        Timeouts
1581 In general, SMBs are not expected to block at the server; they should
1582 return "immediately".  But some SMB requests do indicate timeout periods
1583 for the completion of the request on the server.  If a server
1584 implementation can not support timeouts, then an error can be returned
1585 just as if a timeout had occurred if the resource is not available
1586 immediately upon request.
1589 3.1.8        Data Buffer (BUFFER) and String Formats
1591 The data portion of SMBs typically contains the data to be read or
1592 written, file paths, or directory paths.  The format of the data portion
1593 depends on the message.  All fields in the data portion have the same
1594 format.  In every case it consists of an identifier byte followed by the
1595 data.
1600            Identifier       Description               Value
1601            ===============  ========================= =====
1603            Data Block       See Below                 1
1604            Dialect          Null terminated String    2
1605            Pathname         Null terminated String    3
1606            ASCII            Null terminated String    4
1607            Variable block   See Below                 5
1611 When the identifier indicates a data block or variable block then the
1612 format is a word indicating the length followed by the data.
1614 In all dialects prior to NT LM 0.12, all strings are encoded in ASCII.
1615 If the agreed dialect is NT LM 0.12 or later, Unicode strings may be
1618 Leach, Naik       expires September, 1997         [Page 26] \f
1621 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1624 exchanged. Unicode strings include file names, resource names, and user
1625 names.  This applies to null-terminated strings, length specified
1626 strings and the type-prefixed strings.  In all cases where a string is
1627 passed in Unicode format, the Unicode string must be word-aligned with
1628 respect to the beginning of the SMB.  Should the string not naturally
1629 fall on a two-byte boundary, a null byte of padding will be inserted,
1630 and the Unicode string will begin at the next address.  In the
1631 description of the SMBs, items that may be encoded in Unicode or ASCII
1632 are labeled as STRING.  If the encoding is ASCII, even if the negotiated
1633 string is Unicode, the quantity is labeled as UCHAR.
1635 For type-prefixed Unicode strings, the padding byte is found after the
1636 type byte.  The type byte is 4 (indicating SMB_FORMAT_ASCII) independent
1637 of whether the string is ASCII or Unicode. For strings whose start
1638 addresses are found using offsets within the fixed part of the SMB (as
1639 opposed to simply being found at the byte following the preceding
1640 field,) it is guaranteed that the offset will be properly aligned.
1642 Strings that are never passed in Unicode are:
1644   o The protocol strings in the Negotiate SMB request.
1646   o The service name string in the Tree Connect And X SMB.
1648 When Unicode is negotiated, bit 15 should be set in the Flags2 field of
1649 every SMB header.
1651 Despite the flexible encoding scheme, no field of a data portion may be
1652 omitted or included out of order.  In addition, neither an WordCount nor
1653 ByteCount of value 0 at the end of a message may be omitted.
1656 3.2  File Names
1658 File names in the CIFS protocol consist of components separated by a
1659 backslash ('\').  Early clients of the CIFS protocol required that the
1660 name components adhere to an 8.3 format name.   These names consist of
1661 two parts:  a basename of no more than 8 characters, and an extension of
1662 no more than 3 characters.  The basename and extension are separated by
1663 a '.'.  All characters are legal in the basename and extension except
1664 the space character (0x20) and:
1666      " . / \[]:+|<>=;,*?
1668 If the client has indicated long name support by setting bit2 in the
1669 Flags2 field of the SMB header, this indicates that the client is not
1670 bound by the 8.3 convention.  Specifically this indicates that any SMB
1671 which returns file names to the client may return names which do not
1672 adhere to the 8.3 convention, and have a total length of up to 255
1673 characters.  This capability was introduced with the LM1.2X002 protocol
1674 dialect.
1679 Leach, Naik       expires September, 1997         [Page 27] \f
1682 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1685 3.3  Wildcards
1687 Some SMB requests allow wildcards to be given for the filename.  The
1688 wildcard allows a number of files to be operated on as a unit without
1689 having to separately enumerate the files and individually operate on
1690 each one from the client.
1692 If the client is using 8.3 names, each part of the name ( base (8) or
1693 extension (3) ) is treated separately.  For long filenames the . in the
1694 name is significant even though there is no longer a restriction on the
1695 size of each of the components.
1697 The ? character is a wild card for a single character. If a filename
1698 part commences with one or more "?"s then exactly that number of
1699 characters will be matched by the wildcards, e.g., "??x" equals "abx"
1700 but not "abcx" or "ax".  When a filename part has trailing "?"s then it
1701 matches the specified number of characters or less, e.g., "x??" matches
1702 "xab", "xa" and "x", but not "xabc".  If only "?"s are present in the
1703 filename part, then it is handled as for trailing "?"s
1705 The * character matches an entire part of the name, as does an empty
1706 specification for that part.  A part consisting of * means that the rest
1707 of the component should be filled with ? and the search should be
1708 performed with this wildcard character.  For example, "*.abc" or ".abc"
1709 match any file with an extension of "abc".  "*.*", "*" or "null" match
1710 all files in a directory.
1712 If the negotiated dialect is "NT LM 0.12" or later, and the client
1713 requires MS-DOS wildcard matching semantics,  UNICODE wildcards should
1714 be translated according to the following rules:
1716     Translate the ? literal to >
1718     Translate the . literal to " if it is followed by a ? or a *
1720     Translate the * literal to < if it is followed by a .
1722 The translation can be performed in-place.
1725 3.4  DFS Pathnames
1727 A DFS pathname adheres to the standard described in the FileNames
1728 section.  A DFS enabled client accessing a DFS share should set the
1729 Flags2 bit 12 in all name based SMB requests indicating to the server
1730 that the enclosed pathname should be resolved in the Distributed File
1731 System namespace. The pathname should always have the full file name,
1732 including the server name and share name. If the server can resolve the
1733 DFS name to a piece of local storage, the local storage will be
1734 accessed. If the server determines that the DFS name actually maps to a
1735 different server share, the access to the name will fail with the 32 bit
1736 status STATUS_PATH_NOT_COVERED (0xC0000257), or DOS error
1737 ERRsrv/ERRbadpath.
1740 Leach, Naik       expires September, 1997         [Page 28] \f
1743 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1746 On receiving this error, the DFS enabled client should ask the server
1747 for a referral (see TRANS2_GET_DFS_REFERRAL). The referral request
1748 should contain the full file name.
1750 The response to the request will contain a list of server and share
1751 names to try, and the part of the request file name that junctions to
1752 the list of server shares. If the ServerType field of the referral is
1753 set to 1 (SMB server), then the client should resubmit the request with
1754 the original file name to one of the server shares in the list, once
1755 again setting the Flags2 bit 12 bit in the SMB. If the ServerType field
1756 is not 1, then the client should strip off the part of the file name
1757 that junctions to the server share before resubmitting the request to
1758 one of servers in the list.
1760 A response to a referral request may elicit a response that does not
1761 have the StorageServers bit set. In that case, the client should
1762 resubmit the referral request to one of the servers in the list, until
1763 it finally obtains a referral response that has the StorageServers bit
1764 set, at which point the client can resubmit the request SMB to one of
1765 the listed server shares.
1767 If, after getting a referral with the StorageServers bit set and
1768 resubmitting the request to one of the server shares in the list, the
1769 server fails the request with STATUS_PATH_NOT_COVERED, it must be the
1770 case that there is an inconsistency between the view of the DFS
1771 namespace held by the server granting the referral and the server listed
1772 in that referral. In this case, the client may inform the server
1773 granting the referral of this inconsistency via the
1774 TRANS2_REPORT_DFS_INCONSISTENCY SMB.
1777 3.5  Time And Date Encoding
1779 When SMB requests or responses encode time values, the following
1780 describes the various encodings used.
1782 struct {
1783         USHORT Day : 5;
1784         USHORT Month : 4;
1785         USHORT Year : 7;
1786 } SMB_DATE;
1790 The Year field has a range of 0-119, which represents years 1980 - 2099.
1791 The Month is encoded as 1-12, and the day ranges from 1-31
1793 struct {
1794         USHORT TwoSeconds : 5;
1795         USHORT Minutes : 6;
1796         USHORT Hours : 5;
1797 } SMB_TIME;
1801 Leach, Naik       expires September, 1997         [Page 29] \f
1804 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1807 Hours ranges from 0-23, Minutes range from 0-59, and TwoSeconds ranges
1808 from 0-29 representing two second increments within the minute.
1810 typedef struct {
1811     ULONG LowTime;
1812     LONG HighTime;
1813 } TIME;
1817 TIME indicates a signed 64-bit integer representing either an absolute
1818 time or a time interval.  Times are specified in units of 100ns.  A
1819 positive value expresses an absolute time, where the base time (the 64-
1820 bit integer with value 0) is the beginning of the year 1601 AD in the
1821 Gregorian calendar.  A negative value expresses a time interval relative
1822 to some base time, usually the current time.
1824 typedef unsigned long UTIME;
1826 UTIME is the number of seconds since Jan 1, 1970, 00:00:00.0.
1829 3.6  Access Mode Encoding
1831 Various client requests and server responses, such as SMB_COM_OPEN, pass
1832 file access modes encoded into a USHORT.  The encoding of these is as
1833 follows:
1835     1111 11
1836     5432 1098 7654 3210
1837     rWrC rLLL rSSS rAAA
1839  where:
1841     W - Write through mode.  No read ahead or write behind allowed on
1842         this file or device.  When the response is returned, data is
1843         expected to be on the disk or device.
1845     S - Sharing mode:
1846         0 - Compatibility mode
1847         1 - Deny read/write/execute (exclusive)
1848         2 - Deny write
1849         3 - Deny read/execute
1850         4 - Deny none
1852     A - Access mode
1853         0 - Open for reading
1854         1 - Open for writing
1855         2 - Open for reading and writing
1856         3 - Open for execute
1858     rSSSrAAA = 11111111 (hex FF) indicates FCB open (???)
1862 Leach, Naik       expires September, 1997         [Page 30] \f
1865 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1868     C - Cache mode
1869         0 - Normal file
1870         1 - Do not cache this file
1872     L - Locality of reference
1873         0 - Locality of reference is unknown
1874         1 - Mainly sequential access
1875         2 - Mainly random access
1876         3 - Random access with some locality
1877         4 to 7 - Currently undefined
1880 3.7  Access Mask Encoding
1882 typedef ULONG ACCESS_MASK;
1886 The ACCESS_MASK structure is one 32 bit value containing standard,
1887 specific, and generic rights. These rights are used in access-control
1888 entries (ACEs) and are the primary means of specifying the requested or
1889 granted access to an object.
1891 The bits in this value are allocated as follows:   
1894   Bits      Meaning
1895   0         Specific rights. Contains the access mask specific to the
1896   through   object type associated with the mask.
1897   15
1898   16        Standard rights. Contains the object's standard access rights
1899   through   and can be a combination of the following predefined flags:
1900   23
1903   Bit   Flag          Meaning
1906   16    DELETE        Delete access
1907   17    READ_CONTROL  Read access to the owner, group, and
1908                        discretionary access-control list (ACL) of the
1909                        security descriptor
1910   18    WRITE_DAC     Write access to the discretionary access-
1911                        control list (ACL)
1912   19    WRITE_OWNER   Write access to owner
1913   20    SYNCHRONIZE   Windows NT: Synchronize access
1916   Bits      Meaning
1926 Leach, Naik       expires September, 1997         [Page 31] \f
1929 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1933   24        Access system security (ACCESS_SYSTEM_SECURITY). This flag is
1934             not a typical access type. It is used to indicate access to a
1935             system ACL. This type of access requires the calling process
1936             to have a specific privilege.
1937   25        Maximum allowed (MAXIMUM_ALLOWED)
1938   26        Reserved
1939   through
1940   27
1941   28        Generic all (GENERIC_ALL)
1942   29        Generic execute (GENERIC_EXECUTE)
1943   30        Generic write (GENERIC_WRITE)
1944   31        Generic read (GENERIC_READ)
1946 3.8  Open Function Encoding
1948 OpenFunction specifies the action to be taken depending on whether or
1949 not the file exists.  This word has the following format:
1951 bits:
1953     1111 11
1954     5432 1098 7654 3210
1955     rrrr rrrr rrrC rrOO
1957 where:
1959     C - Create (action to be taken if file does not exist).
1960     0 -- Fail.
1961     1 -- Create file.
1963     r - reserved (must be zero).
1965     O - Open (action to be taken if file exists).
1966     0 - Fail.
1967     1 - Open file.
1968     2 - Truncate file.
1971 3.9  Open Action Encoding
1973 Action in the response to an open or create request describes the action
1974 taken as a result of the request.  It has the following format:
1976 bits:
1978     1111 11
1979     5432 1098 7654 3210
1980     Lrrr rrrr rrrr rrOO
1982 where:
1984     L - Lock (single user total file lock status).
1985     0 -- file opened by another user (or mode not supported by server).
1986     1 -- file is opened only by this user at the present  time.
1988 Leach, Naik       expires September, 1997         [Page 32] \f
1991 INTERNET-DRAFT            CIFS/1.0                  03/19/97
1994     r - reserved (must be zero).
1996     O - Open (action taken on Open).
1997     1 - The file existed and was opened.
1998     2 - The file did not exist but was created.
1999     3 - The file existed and was truncated.
2002 3.10       File Attribute Encoding
2004 When SMB messages exchange file attribute information, it is encoded in
2005 16 bits as:
2008    Value   Description
2009    ======= =====================
2011    0x01    Read only file
2012    0x02    Hidden file
2013    0x04    System file
2014    0x08    Volume
2015    0x10    Directory
2016    0x20    Archive file
2017    others  Reserved - must be 0
2022 3.11       Extended File Attribute Encoding
2024 The extended file attributes is a 32 bit value composed of attributes
2025 and flags.
2052 Leach, Naik       expires September, 1997         [Page 33] \f
2055 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2058 Any combination of the following attributes is acceptable, except all
2059 other file attributes override FILE_ATTR_NORMAL:
2062 Name             Value Meaning
2063 ====             ===== =======
2064 ATTR_ARCHIVE     0x020 The file has not been archived since it was
2065                        last modified. Applications use this
2066                        attribute to mark files for backup or
2067                        removal.
2068 ATTR_COMPRESSED  0x800 The file or directory is compressed. For a
2069                        file, this means that all of the data in the
2070                        file is compressed. For a directory, this
2071                        means that compression is the default for
2072                        newly created files and subdirectories.
2073 ATTR_NORMAL      0x080 The file has no other attributes set. This
2074                        attribute is valid only if used alone.
2075 ATTR_HIDDEN      0x002 The file is hidden. It is not to be included
2076                        in an ordinary directory listing.
2077 ATTR_READONLY    0x001 The file is read only. Applications can read
2078                        the file but cannot write to it or delete it.
2079 ATTR_TEMPORARY   0x100 The file is temporary
2080 ATTR_DIRECTORY   0x010 The file is a directory
2081 ATTR_SYSTEM      0x004 The file is part of or is used exclusively by
2082                        the operating system.
2114 Leach, Naik       expires September, 1997         [Page 34] \f
2117 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2120 Any combination of the following flags is acceptable:
2123 Name             Value      Meaning
2124 ====             =====      =======
2125 WRITE_THROUGH    0x80000000 Instructs the operating system to write
2126                              through any intermediate cache and go
2127                              directly to the file. The operating
2128                              system can still cache write
2129                              operations, but cannot lazily flush
2130                              them.
2131 NO_BUFFERING     0x20000000 Requests the server to open the file
2132                              with no intermediate buffering or
2133                              caching; the server is not obliged to
2134                              honor the request. An application must
2135                              meet certain requirements when working
2136                              with files opened with
2137                              FILE_FLAG_NO_BUFFERING. File access
2138                              must begin at offsets within the file
2139                              that are integer multiples of the
2140                              volume's sector size; and must be for
2141                              numbers of bytes that are integer
2142                              multiples of the volume's sector size.
2143                              For example, if the sector size is 512
2144                              bytes, an application can request reads
2145                              and writes of 512, 1024, or 2048 bytes,
2146                              but not of 335, 981, or 7171 bytes.
2147 RANDOM_ACCESS    0x10000000 Indicates that the application intends
2148                              to access the file randomly. The server
2149                              MAY use this flag to optimize file
2150                              caching.
2151 SEQUENTIAL_SCAN  0x08000000 Indicates that the file is to be
2152                              accessed sequentially from beginning to
2153                              end. Windows uses this flag to optimize
2154                              file caching. If an application moves
2155                              the file pointer for random access,
2156                              optimum caching may not occur; however,
2157                              correct operation is still guaranteed.
2158                              Specifying this flag can increase
2159                              performance for applications that read
2160                              large files using sequential access.
2161                              Performance gains can be even more
2162                              noticeable for applications that read
2163                              large files mostly sequentially, but
2164                              occasionally skip over small ranges of
2165                              bytes.
2166 DELETE_ON_CLOSE  0x04000000 Requests that the server is delete the
2167                              file immediately after all of its
2168                              handles have been closed.
2169 BACKUP_SEMANTICS 0x02000000 Indicates that the file is being opened
2170                              or created for a backup or restore
2171                              operation. The server SHOULD allow the
2172                              client to override normal file security
2173                              checks, provided it has the necessary
2174                              permission to do so.
2176 Leach, Naik       expires September, 1997         [Page 35] \f
2179 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2183 POSIX_SEMANTICS  0x01000000 Indicates that the file is to be
2184                              accessed according to POSIX rules. This
2185                              includes allowing multiple files with
2186                              names differing only in case, for file
2187                              systems that support such naming. (Use
2188                              care when using this option because
2189                              files created with this flag may not be
2190                              accessible by applications written for
2191                              MS-DOS, Windows 3.x, or Windows NT.)
2195 3.12       Batching Requests ("AndX" Messages)
2197 LANMAN1.0 and later dialects of the CIFS protocol allow multiple SMB
2198 requests to be sent in one message to the server.  Messages of this type
2199 are called AndX SMBs, and they obey the following rules:
2201 o The embedded command does not repeat the SMB header information.
2202   Rather the next SMB starts at the WordCount field.
2204 o All multiple (chained) requests must fit within the negotiated
2205   transmit size.  For example, if SMB_COM_TREE_CONNECT_ANDX included
2206   OPENandX SMB_COM_OPEN_ANDX which included SMB_COM_WRITE were sent,
2207   they would all have to fit within the negotiated buffer size.  This
2208   would limit the size of the write.
2210 o There is one message sent containing the chained requests and there
2211   is one response message to the chained requests.  The server may NOT
2212   elect to send separate responses to each of the chained requests.
2214 o All chained responses must fit within the negotiated transmit size.
2215   This limits the maximum value on an embedded SMB_COM_READ for
2216   example.  It is the client's responsibility to not request more bytes
2217   than will fit within the multiple response.
2219 o The server will implicitly use the result of the first command in the
2220   "X" command.  For example the Tid obtained via
2221   SMB_COM_TREE_CONNECT_ANDX would be used in the embedded
2222   SMB_COM_OPEN_ANDX and the Fid obtained in the SMB_COM_OPEN_ANDX would
2223   be used in the embedded SMB_COM_READ.
2225 o Each chained request can only reference the same Fid and Tid as the
2226   other commands in the combined request.  The chained requests can be
2227   thought of as performing a single (multi-part) operation on the same
2228   resource.
2230 o The first Command to encounter an error will stop all further
2231   processing of embedded commands.  The server will not back out
2232   commands that succeeded.  Thus if a chained request contained
2233   SMB_COM_OPEN_ANDX and SMB_COM_READ and the server was able to open
2234   the file successfully but the read encountered an error, the file
2235   would remain open.  This is exactly the same as if the requests had
2236   been sent separately.
2238 Leach, Naik       expires September, 1997         [Page 36] \f
2241 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2244 o If an error occurs while processing chained requests, the last
2245   response (of the chained responses in the buffer) will be the one
2246   which encountered the error.  Other unprocessed chained requests will
2247   have been ignored when the server encountered the error and will not
2248   be represented in the chained response.  Actually the last valid
2249   AndXCommand (if any) will represent the SMB on which the error
2250   occurred.  If no valid AndXCommand is present, then the error
2251   occurred on the first request/response and Command contains the
2252   command which failed.  In all cases the error information are
2253   returned in the SMB header at the start of the response buffer.
2255 o Each chained request and response contains the offset (from the start
2256   of the SMB header) to the next chained request/response (in the
2257   AndXOffset field in the various "and X" protocols defined later e.g.
2258   SMB_COM_OPEN_ANDX).  This allows building the requests unpacked.
2259   There may be space between the end of the previous request (as
2260   defined by WordCount and ByteCount) and the start of the next chained
2261   request.  This simplifies the building of chained protocol requests.
2262   Note that because the client must know the size of the data being
2263   returned in order to post the correct number of receives (e.g.
2264   SMB_COM_TRANSACTION, SMB_COM_READ_MPX), the data in each response SMB
2265   is expected to be truncated to the maximum number of 512 byte blocks
2266   (sectors) which will fit (starting at a 32 bit boundary) in the
2267   negotiated buffer size with the odd bytes remaining (if any) in the
2268   final buffer.
2271 3.13       "Transaction" Style Subprotocols
2273 SMB_COM_TRANSACTION performs a symbolically named transaction.  This
2274 transaction is known only by a name (no file handle used).
2275 SMB_COM_TRANSACTION2 likewise performs a transaction, but a word
2276 parameter is used to identify the transaction instead of a name.
2277 SMB_COM_NT_TRANSACTION is used for commands that potentially need to
2278 transfer a large amount of data (greater than 64K bytes).
2299 Leach, Naik       expires September, 1997         [Page 37] \f
2302 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2305 3.13.1     SMB_COM_TRANSACTION and SMB_COM_TRANSACTION2 Formats
2308  Primary Client Request           Description
2309  ===============================  ====================================
2311  Command                          SMB_COM_TRANSACTION or
2312                                   SMB_COM_TRANSACTION2
2313  UCHAR WordCount;                 Count of parameter words;   value =
2314                                   (14 + SetupCount)
2315  USHORT TotalParameterCount;      Total parameter bytes being sent
2316  USHORT TotalDataCount;           Total data bytes being sent
2317  USHORT MaxParameterCount;        Max parameter bytes to return
2318  USHORT MaxDataCount;             Max data bytes to return
2319  UCHAR MaxSetupCount;             Max setup words to return
2320  UCHAR Reserved;
2321  USHORT Flags;                    Additional information:
2322                                   bit 0 - also disconnect TID in TID
2323                                   bit 1 - one-way transaction (no
2324                                   response)
2325  ULONG Timeout;
2326  USHORT Reserved2;
2327  USHORT ParameterCount;           Parameter bytes sent this buffer
2328  USHORT ParameterOffset;          Offset (from header start) to
2329                                   Parameters
2330  USHORT DataCount;                Data bytes sent this buffer
2331  USHORT DataOffset;               Offset (from header start) to data
2332  UCHAR SetupCount;                Count of setup words
2333  UCHAR Reserved3;                 Reserved (pad above to word)
2334  USHORT Setup[SetupCount];        Setup words (# = SetupWordCount)
2335  USHORT ByteCount;                Count of data bytes
2336  STRING Name[];                   Name of transaction (NULL if
2337                                   SMB_COM_TRANSACTION2)
2338  UCHAR Pad[];                     Pad to SHORT or LONG
2339  UCHAR Parameters[                Parameter bytes (# = ParameterCount)
2340  ParameterCount];
2341  UCHAR Pad1[];                    Pad to SHORT or LONG
2342  UCHAR Data[ DataCount ];         Data bytes (# = DataCount)
2346  Interim Server Response          Description
2347  ===============================  ====================================
2349  UCHAR WordCount;                 Count of parameter words = 0
2350  USHORT ByteCount;                Count of data bytes = 0
2364 Leach, Naik       expires September, 1997         [Page 38] \f
2367 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2371  Secondary Client Request         Description
2372  ===============================  ====================================
2374  Command                          SMB_COM_TRANSACTION_SECONDARY
2376  UCHAR WordCount;                 Count of parameter words = 8
2377  USHORT TotalParameterCount;      Total parameter bytes being sent
2378  USHORT TotalDataCount;           Total data bytes being sent
2379  USHORT ParameterCount;           Parameter bytes sent this buffer
2380  USHORT ParameterOffset;          Offset (from header start) to
2381                                   Parameters
2382  USHORT ParameterDisplacement;    Displacement of these Parameter
2383                                   bytes
2384  USHORT DataCount;                Data bytes sent this buffer
2385  USHORT DataOffset;               Offset (from header start) to data
2386  USHORT DataDisplacement;         Displacement of these data bytes
2387  USHORT Fid;                      FID for handle based requests, else
2388                                   0xFFFF.  This field is present only
2389                                   if this is an SMB_COM_TRANSACTION2
2390                                   request.
2391  USHORT ByteCount;                Count of data bytes
2392  UCHAR Pad[];                     Pad to SHORT or LONG
2393  UCHAR                            Parameter bytes (# = ParameterCount)
2394  Parameters[ParameterCount];
2395  UCHAR Pad1[];                    Pad to SHORT or LONG
2396  UCHAR Data[DataCount];           Data bytes (# = DataCount)
2427 Leach, Naik       expires September, 1997         [Page 39] \f
2430 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2434  Server Response                  Description
2435  ===============================  ====================================
2437  UCHAR WordCount;                 Count of data bytes; value = 10 +
2438                                   SETUPCOUNT
2439  USHORT TotalParameterCount;      Total parameter bytes being sent
2440  USHORT TotalDataCount;           Total data bytes being sent
2441  USHORT Reserved;
2442  USHORT ParameterCount;           Parameter bytes sent this buffer
2443  USHORT ParameterOffset;          Offset (from header start) to
2444                                   Parameters
2445  USHORT ParameterDisplacement;    Displacement of these Parameter
2446                                   bytes
2447  USHORT DataCount;                Data bytes sent this buffer
2448  USHORT DataOffset;               Offset (from header start) to data
2449  USHORT DataDisplacement;         Displacement of these data bytes
2450  UCHAR SetupCount;                Count of setup words
2451  UCHAR Reserved2;                 Reserved (pad above to word)
2452  USHORT Setup[SetupWordCount];    Setup words (# = SetupWordCount)
2453  USHORT ByteCount;                Count of data bytes
2454  UCHAR Pad[];                     Pad to SHORT or LONG
2455  UCHAR                            Parameter bytes (# = ParameterCount)
2456  Parameters[ParameterCount];
2457  UCHAR Pad1[];                    Pad to SHORT or LONG
2458  UCHAR Data[DataCount];           Data bytes (# = DataCount)
2461 3.13.2     SMB_COM_NT_TRANSACTION Formats
2464  Primary Client Request           Description
2465  ===============================  ====================================
2467  UCHAR WordCount;                 Count of parameter words;   value =
2468                                   (19 + SetupCount)
2469  UCHAR MaxSetupCount;             Max setup words to return
2470  USHORT Reserved;
2471  ULONG TotalParameterCount;       Total parameter bytes being sent
2472  ULONG TotalDataCount;            Total data bytes being sent
2473  ULONG MaxParameterCount;         Max parameter bytes to return
2474  ULONG MaxDataCount;              Max data bytes to return
2475  ULONG ParameterCount;            Parameter bytes sent this buffer
2476  ULONG ParameterOffset;           Offset (from header start) to
2477                                   Parameters
2478  ULONG DataCount;                 Data bytes sent this buffer
2479  ULONG DataOffset;                Offset (from header start) to data
2480  UCHAR SetupCount;                Count of setup words
2481  USHORT Function;                 The transaction function code
2482  UCHAR Buffer[1];
2483  USHORT Setup[SetupWordCount];    Setup words
2484  USHORT ByteCount;                Count of data bytes
2485  UCHAR Pad1[];                    Pad to LONG
2486  UCHAR                            Parameter bytes
2487  Parameters[ParameterCount];
2488  UCHAR Pad2[];                    Pad to LONG
2489  UCHAR Data[DataCount];   Data
2490  bytes
2493 Leach, Naik       expires September, 1997         [Page 40] \f
2496 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2502  Interim Server Response          Description
2503  ===============================  ====================================
2505  UCHAR WordCount;                 Count of parameter words = 0
2506  USHORT ByteCount;                Count of data bytes = 0
2510  Secondary Client Request         Description
2511  ===============================  ====================================
2513  UCHAR WordCount;                 Count of parameter words = 18
2514  UCHAR Reserved[3];               MBZ
2515  ULONG TotalParameterCount;       Total parameter bytes being sent
2516  ULONG TotalDataCount;            Total data bytes being sent
2517  ULONG ParameterCount;            Parameter bytes sent this buffer
2518  ULONG ParameterOffset;           Offset (from header start) to
2519                                   Parameters
2520  ULONG ParameterDisplacement;     Specifies the offset from the start
2521                                   of the overall parameter block to
2522                                   the parameter bytes that are
2523                                   contained in this message
2524  ULONG DataCount;                 Data bytes sent this buffer
2525  ULONG DataOffset;                Offset (from header start) to data
2526  ULONG DataDisplacement;          Specifies the offset from the start
2527                                   of the overall data block to the
2528                                   data bytes that are contained in
2529                                   this message.
2530  UCHAR Reserved1;
2531  USHORT ByteCount;                Count of data bytes
2532  UCHAR Pad1[];                    Pad to LONG
2533  UCHAR                            Parameter bytes
2534  Parameters[ParameterCount];
2535  UCHAR Pad2[];                    Pad to LONG
2536  UCHAR Data[DataCount];           Data bytes
2558 Leach, Naik       expires September, 1997         [Page 41] \f
2561 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2565  Server Response                  Description
2566  ===============================  ====================================
2568  UCHAR WordCount;                 Count of data bytes;  value = 18 +
2569                                   SetupCount
2570  UCHAR Reserved[3];
2571  ULONG TotalParameterCount;       Total parameter bytes being sent
2572  ULONG TotalDataCount;            Total data bytes being sent
2573  ULONG ParameterCount;            Parameter bytes sent this buffer
2574  ULONG ParameterOffset;           Offset (from header start) to
2575                                   Parameters
2576  ULONG ParameterDisplacement;     Specifies the offset from the start
2577                                   of the overall parameter block to
2578                                   the parameter bytes that are
2579                                   contained in this message
2580  ULONG DataCount;                 Data bytes sent this buffer
2581  ULONG DataOffset;                Offset (from header start) to data
2582  ULONG DataDisplacement;          Specifies the offset from the start
2583                                   of the overall data block to the
2584                                   data bytes that are contained in
2585                                   this message.
2586  UCHAR SetupCount;                Count of setup words
2587  USHORT Setup[SetupWordCount];    Setup words
2588  USHORT ByteCount;                Count of data bytes
2589  UCHAR Pad1[];                    Pad to LONG
2590  UCHAR                            Parameter bytes
2591  Parameters[ParameterCount];
2592  UCHAR Pad2[];                    Pad to SHORT or LONG
2593  UCHAR Data[DataCount];           Data bytes
2596 3.13.3     Functional Description
2598 The SMB_COM_TRANSACTION command's scope includes named pipes and
2599 mailslots.  Where the resource is unidirectional (such as class 2 writes
2600 to mailslots), bit1 of Flags in the request can be set indicating that
2601 no response is needed.  The other transactions accommodate IOCTL
2602 requests and file system requests which require the transfer of an
2603 extended attribute list.
2605 The transaction Setup information and/or Parameters define functions
2606 specific to a particular resource on a particular server.  Therefore the
2607 functions supported are not defined by the protocol, but by client and
2608 server implementations.  The transaction protocol simply provides a
2609 means of delivering them and retrieving the results.
2611 The number of bytes needed in order to perform the transaction request
2612 may be more than will fit in a single buffer.
2614 At the time of the request, the client knows the number of parameter and
2615 data bytes expected to be sent and passes this information to the server
2616 via the primary request (TotalParameterCount and TotalDataCount).  This
2617 may be reduced by lowering the total number of bytes expected
2618 (TotalParameterCount and TotalDataCount) in each (if any) secondary
2619 request.
2622 Leach, Naik       expires September, 1997         [Page 42] \f
2625 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2628 When the amount of parameter bytes received (total of each
2629 ParameterCount) equals the total amount of parameter bytes expected
2630 (smallest TotalParameterCount) received, then the server has received
2631 all the parameter bytes.
2633 Likewise, when the amount of data bytes received (total of each
2634 DataCount) equals the total amount of data bytes expected (smallest
2635 TotalDataCount) received, then the server has received all the data
2636 bytes.
2638 The parameter bytes should normally be sent first followed by the data
2639 bytes.  However, the server knows where each begins and ends in each
2640 buffer by the offset fields (ParameterOffset and DataOffset) and the
2641 length fields (ParameterCount and DataCount).  The displacement of the
2642 bytes (relative to start of each) is also known (ParameterDisplacement
2643 and DataDisplacement).  Thus the server is able to reassemble the
2644 parameter and data bytes should the individual requests be received out
2645 of sequence.
2647 If all parameter bytes and data bytes fit into a single buffer, then no
2648 interim response is expected and no secondary request is sent.
2650 The client knows the maximum amount of data bytes and parameter bytes
2651 which the server may return (from MaxParameterCount and MaxDataCount of
2652 the request).  Thus the client initializes its bytes expected variables
2653 to these values.  The server then informs the client of the actual
2654 amounts being returned via each message of the server response
2655 (TotalParameterCount and TotalDataCount).  The server may reduce the
2656 expected bytes by lowering the total number of bytes expected
2657 (TotalParameterCount and/or TotalDataCount) in each (any) response.
2659 When the amount of parameter bytes received (total of each
2660 ParameterCount) equals the total amount of parameter bytes expected
2661 (smallest TotalParameterCount) received, then the client has received
2662 all the parameter bytes.
2664 Likewise, when the amount of data bytes received (total of each
2665 DataCount) equals the total amount of data bytes expected (smallest
2666 TotalDataCount) received, then the client has received all the data
2667 bytes.
2669 The parameter bytes should normally be returned first followed by the
2670 data bytes.  However, the client knows where each begins and ends in
2671 each buffer by the offset fields (ParameterOffset and DataOffset) and
2672 the length fields (ParameterCount and DataCount).  The displacement of
2673 the bytes (relative to start of each) is also known
2674 (ParameterDisplacement and DataDisplacement).  The client is able to
2675 reassemble the parameter and data bytes should the server responses be
2676 received out of sequence.
2678 If a connectionless transport is being used, the transaction requests
2679 must be properly sequenced in the Connectionless.SequenceNumber SMB
2680 header field.  The Mid of any secondary client requests must match the
2681 Mid of the primary client request.  The server responds to each request
2683 Leach, Naik       expires September, 1997         [Page 43] \f
2686 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2689 piece except the last one with a response indicating that the server is
2690 ready for the next piece.  The last piece is responded to with the first
2691 piece of the result data.  The client then sends an
2692 SMB_COM_TRANSACTION_SECONDARY SMB with ParameterDisplacement set to the
2693 number of parameter bytes received so far and DataDisplacement set to
2694 the number of data bytes received so far and ParameterCount,
2695 ParameterOffset, DataCount, and DataOffset set to zero (0).  The server
2696 responds with the next piece of the transaction result.  The process is
2697 repeated until all of the response information has been received.  When
2698 the transaction has been completed, the client must send another
2699 sequenced command (such as an SMB_COM_ECHO) to the server to allow the
2700 server to know that the final piece was received and that resources
2701 allocated to the transaction command may be released.
2703 The flow for these transactions over a connection oriented transport is:
2705 1.     The client sends the primary client request identifying the total
2706 bytes (both parameters and data) which are expected to be sent and
2707 contains the set up words and as many of the parameter and data bytes
2708 as will fit in a negotiated size buffer.  This request also identifies
2709 the maximum number of bytes (setup, parameters and data) the server is
2710 to return on the transaction completion.  If all the bytes fit in the
2711 single buffer, skip to step 4.
2713 2.     The server responds with a single interim response meaning "OK, send
2714 the remainder of the bytes" or (if error response) terminate the
2715 transaction.
2717 3.     The client then sends another buffer full of bytes to the server.
2718 This step is repeated until all of the bytes are sent and received.
2720 4.     The Server sets up and performs the transaction with the information
2721 provided.
2723 5.     Upon completion of the transaction, the server sends back (up to)
2724 the number of parameter and data bytes requested (or as many as will
2725 fit in the negotiated buffer size).  This step is repeated until all
2726 result bytes have been returned.
2728 The flow for the transaction protocol when the request parameters and
2729 data do not all fit in a single buffer is:
2744 Leach, Naik       expires September, 1997         [Page 44] \f
2747 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2751  Client                           <->  Server
2752  ===============================  ==== ==============================
2754  Primary TRANSACTION request      ->
2755                                   <-   Interim Server Response
2756  Secondary TRANSACTION request 1  ->
2757  Secondary TRANSACTION request 2  ->
2758  Secondary TRANSACTION request N  ->
2759                                   <-   TRANSACTION response 1
2760                                   <-   TRANSACTION response 2
2761                                   <-   TRANSACTION response m
2763 The flow for the transaction protocol when the request parameters and
2764 data does all fit in a single buffer is:
2767  Client                           <->  Server
2768  ===============================  ==== ==============================
2770  Primary TRANSACTION request      ->
2771                                   <-   TRANSACTION response 1
2772                                   <-   TRANSACTION response 2
2773                                   <-   TRANSACTION response m
2777 The flow for the transaction protocol over a connectionless transport
2780 1.     The client sends the primary client request identifying the total
2781 bytes (both parameters and data) which are expected to be sent and
2782 contains the set up words and as many of the parameter and data bytes
2783 as will fit in a negotiated size buffer.  This request also identifies
2784 the maximum number of bytes (setup, parameters and data) the server is
2785 to return on completion.  If all the bytes fit in the single buffer,
2786 skip to step 4.
2788 2.     The server responds with a single interim response meaning "OK, send
2789 the remainder of the bytes" or (if error response) terminate the
2790 transaction.
2792 3.     The client then sends another buffer full of bytes to the server.
2793 The server responds with an interim server response. This step is
2794 repeated until all of the bytes are sent and received.
2796 4.     The Server sets up and performs the transaction with the information
2797 provided.
2799 5.     Upon completion of the transaction, the server sends back (up to)
2800 the number of parameter and data bytes requested (or as many as will
2801 fit in the negotiated buffer size).
2803 6.     The client responds with a transaction secondary request.  The
2804 server sends back more response data. This step is repeated until all
2805 result bytes have been returned.
2807 7.    The client sends a sequenced request to the server such as
2808   SMB_COM_ECHO
2811 Leach, Naik       expires September, 1997         [Page 45] \f
2814 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2817 The primary transaction request through the final response make up the
2818 complete transaction exchange, thus the Tid, Pid, Uid and Mid must remain
2819 constant and can be used as appropriate by both the server and the
2820 client.  Of course, other SMB requests may intervene as well.
2822 There are (at least) three ways that actual server responses have been
2823 observed to differ from what might be expected.  First, some servers will
2824 send Pad bytes to move the DataOffset to a 2- or 4-byte boundary even if
2825 there are no data bytes; the point here is that the ByteCount must be
2826 used instead of ParameterOffset plus ParameterCount to infer the actual
2827 message length.  Second, some servers always return MaxParameterCount
2828 bytes even if the particular Transact2 has no parameter response.
2829 Finally, in case of an error, some servers send the "traditional
2830 WordCount==0/ByteCount==0" response while others generate a Transact
2831 response format.
2834 3.14       Valid SMB Requests by Negotiated Dialect
2836 The following SMB messages may be exchanged by CIFS clients and servers
2837 if the "PC NETWORK PROGRAM 1.0" dialect is negotiated:
2840 SMB_COM_CREATE_DIRECTORY        SMB_COM_DELETE_DIRECTORY
2841 SMB_COM_OPEN                    SMB_COM_CREATE
2842 SMB_COM_CLOSE                   SMB_COM_FLUSH
2843 SMB_COM_DELETE                  SMB_COM_RENAME
2844 SMB_COM_QUERY_INFORMATION       SMB_COM_SET_INFORMATION
2845 SMB_COM_READ                    SMB_COM_WRITE
2846 SMB_COM_LOCK_BYTE_RANGE         SMB_COM_UNLOCK_BYTE_RANGE
2847 SMB_COM_CREATE_TEMPORARY        SMB_COM_CREATE_NEW
2848 SMB_COM_CHECK_DIRECTORY         SMB_COM_PROCESS_EXIT
2849 SMB_COM_SEEK                    SMB_COM_TREE_CONNECT
2850 SMB_COM_TREE_DISCONNECT         SMB_COM_NEGOTIATE
2851 SMB_COM_QUERY_INFORMATION_DISK  SMB_COM_SEARCH
2852 SMB_COM_OPEN_PRINT_FILE         SMB_COM_WRITE_PRINT_FILE
2853 SMB_COM_CLOSE_PRINT_FILE        SMB_COM_GET_PRINT_QUEUE
2856 If the "LANMAN 1.0" dialect is negotiated, all of the messages in the
2857 previous list must be supported.  Clients negotiating LANMAN 1.0 and
2858 higher dialects will probably no longer send SMB_COM_PROCESS_EXIT, and
2859 the response format for SMB_COM_NEGOTIATE is modified as well.  New
2860 messages introduced with the LANMAN 1.0 dialect are:
2873 Leach, Naik       expires September, 1997         [Page 46] \f
2876 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2880 SMB_COM_LOCK_AND_READ         SMB_COM_WRITE_AND_UNLOCK
2881 SMB_COM_READ_RAW              SMB_COM_READ_MPX
2882 SMB_COM_WRITE_MPX             SMB_COM_WRITE_RAW
2883 SMB_COM_WRITE_COMPLETE        SMB_COM_WRITE_MPX_SECONDARY
2884 SMB_COM_SET_INFORMATION2      SMB_COM_QUERY_INFORMATION2
2885 SMB_COM_LOCKING_ANDX          SMB_COM_TRANSACTION
2886 SMB_COM_TRANSACTION_SECONDARY SMB_COM_IOCTL
2887 SMB_COM_IOCTL_SECONDARY       SMB_COM_COPY
2888 SMB_COM_MOVE                  SMB_COM_ECHO
2889 SMB_COM_WRITE_AND_CLOSE       SMB_COM_OPEN_ANDX
2890 SMB_COM_READ_ANDX             SMB_COM_WRITE_ANDX
2891 SMB_COM_SESSION_SETUP_ANDX    SMB_COM_TREE_CONNECT_ANDX
2892 SMB_COM_FIND                  SMB_COM_FIND_UNIQUE
2893 SMB_COM_FIND_CLOSE
2896 The "LM1.2X002" dialect introduces these new SMBs:
2899 SMB_COM_TRANSACTION2          SMB_COM_TRANSACTION2_SECONDARY
2900 SMB_COM_FIND_CLOSE2           SMB_COM_LOGOFF_ANDX
2903 "NT LM 0.12" dialect introduces:
2906 SMB_COM_NT_TRANSACT           SMB_COM_NT_TRANSACT_SECONDARY
2907 SMB_COM_NT_CREATE_ANDX        SMB_COM_NT_CANCEL
2908 SMB_COM_NT_RENAME             SMB_COM_READ_BULK
2909 SMB_COM_WRITE_BULK            SMB_COM_WRITE_BULK_DATA
2911 4   SMB Requests
2913 This section lists the "best practice" SMB requests -- ones that would
2914 permit a client to exercise full CIFS functionality and optimum
2915 performance when interoperating with a server speaking the latest
2916 dialect as of this writing ("NT LM 0.12").
2918 Note that, as of this writing, no existing client restricts itself to
2919 only these requests, so no useful server can be written that supports
2920 just them. The classification is provided so that future clients will be
2921 written to permit future servers to be simpler.
2938 Leach, Naik       expires September, 1997         [Page 47] \f
2941 INTERNET-DRAFT            CIFS/1.0                  03/19/97
2944 4.1  Session Requests
2947 4.1.1        NEGOTIATE: Negotiate Protocol
2950 Client Request                Description
2951 ============================  =======================================
2953 UCHAR WordCount;              Count of parameter words = 0
2954 USHORT ByteCount;             Count of data bytes; min = 2
2955 struct {
2956    UCHAR BufferFormat;        0x02 -- Dialect
2957    UCHAR DialectName[];       ASCII null-terminated string
2958 } Dialects[];
2962 The Client sends a list of dialects that it can communicate with.  The
2963 response is a selection of one of those dialects (numbered 0 through n)
2964 or -1 (hex FFFF) indicating that none of the dialects were acceptable.
2965 The negotiate message is binding on the virtual circuit and must be
2966 sent.  One and only one negotiate message may be sent, subsequent
2967 negotiate requests will be rejected with an error response and no action
2968 will be taken.
2970 The protocol does not impose any particular structure to the dialect
2971 strings.  Implementers of particular protocols may choose to include,
2972 for example, version numbers in the string.
2974 If the server does not understand any of the dialect strings, or if PC
2975 NETWORK PROGRAM 1.0 is the chosen dialect, the response format is
2978 Server Response               Description
2979 ============================  =======================================
2981 UCHAR WordCount;              Count of parameter words = 1
2982 USHORT DialectIndex;          Index of selected dialect
2983 USHORT ByteCount;             Count of data bytes = 0
3004 Leach, Naik       expires September, 1997         [Page 48] \f
3007 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3010 If the chosen dialect is greater than core up to and including
3011 LANMAN2.1, the protocol response format is
3014 Server Response               Description
3015 ============================  =======================================
3017 UCHAR WordCount;              Count of parameter words = 13
3018 USHORT  DialectIndex;         Index of selected dialect
3019 USHORT  SecurityMode;         Security mode:
3020                               bit 0: 0 = share, 1 = user
3021                               bit 1: 1 = use challenge/response
3022                               authentication
3023 USHORT  MaxBufferSize;        Max transmit buffer size (>= 1024)
3024 USHORT  MaxMpxCount;          Max pending multiplexed requests
3025 USHORT  MaxNumberVcs;         Max VCs between client and server
3026 USHORT  RawMode;              Raw modes supported:
3027                                bit 0: 1 = Read Raw supported
3028                                bit 1: 1 = Write Raw supported
3029 ULONG SessionKey;             Unique token identifying this session
3030 SMB_TIME ServerTime;          Current time at server
3031 SMB_DATE ServerDate;          Current date at server
3032 USHORT ServerTimeZone;        Current time zone at server
3033 USHORT  EncryptionKeyLength;  MBZ if this is not LM2.1
3034 USHORT  Reserved;             MBZ
3035 USHORT  ByteCount             Count of data bytes
3036 UCHAR EncryptionKey[];        The challenge encryption key
3037 STRING PrimaryDomain[];       The server's primary domain
3041 MaxBufferSize is the size of the largest message which the client can
3042 legitimately send to the server
3044 If  bit0 of the Flags field is set in the negotiate response, this
3045 indicates the server supports the SMB_COM_LOCK_AND_READ and
3046 SMB_COM_WRITE_AND_UNLOCK client requests.
3048 If the SecurityMode field indicates the server is running in user mode,
3049 the client must send appropriate SMB_COM_SESSION_SETUP_ANDX requests
3050 before the server will allow the client to access resources.   If the
3051 SecurityMode fields indicates the client should use challenge/response
3052 authentication, the client should use the authentication mechanism
3053 specified in section 2.10.
3055 Clients should submit no more than MaxMpxCount distinct unanswered SMBs
3056 to the server when using multiplexed reads or writes (see sections 5.13
3057 and 5.25)
3059 Clients using the  "MICROSOFT NETWORKS 1.03" dialect use a different
3060 form of raw reads than documented here, and servers are better off
3061 setting RawMode in this response to 0 for such sessions.
3063 If the negotiated dialect is "DOS LANMAN2.1" or "LANMAN2.1", then
3064 PrimaryDomain string should be included in this response.
3068 Leach, Naik       expires September, 1997         [Page 49] \f
3071 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3074 If the negotiated dialect is NT LM 0.12, the response format is
3077 Server Response            Description
3078 ========================== =========================================
3080 UCHAR WordCount;           Count of parameter words = 17
3081 USHORT DialectIndex;       Index of selected dialect
3082 UCHAR SecurityMode;        Security mode:
3083                             bit 0: 0 = share, 1 = user
3084                             bit 1: 1 = encrypt passwords
3085 USHORT MaxMpxCount;        Max pending multiplexed requests
3086 USHORT MaxNumberVcs;       Max VCs between client and server
3087 ULONG MaxBufferSize;       Max transmit buffer size
3088 ULONG MaxRawSize;          Maximum raw buffer size
3089 ULONG SessionKey;          Unique token identifying this session
3090 ULONG Capabilities;        Server capabilities
3091 ULONG SystemTimeLow;       System (UTC) time of the server (low).
3092 ULONG SystemTimeHigh;      System (UTC) time of the server (high).
3093 USHORT ServerTimeZone;     Time zone of server (min from UTC)
3094 UCHAR EncryptionKeyLength; Length of encryption key.
3095 USHORT ByteCount;          Count of data bytes
3096 UCHAR EncryptionKey[];     The challenge encryption key
3097 UCHAR OemDomainName[];     The name of the domain (in OEM chars)
3101 In addition to the definitions above, MaxBufferSize is the size of the
3102 largest message which the client can legitimately send to the server.
3103 If the client is using a connectionless protocol,  MaxBufferSize must be
3104 set to the smaller of the server's internal buffer size and the amount
3105 of data which can be placed in a response packet.
3107 MaxRawSize specifies the maximum message size the server can send or
3108 receive for SMB_COM_WRITE_RAW or SMB_COM_READ_RAW.
3110 Connectionless clients must set Sid to 0 in the SMB request header.
3132 Leach, Naik       expires September, 1997         [Page 50] \f
3135 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3138 Capabilities allows the server to tell the client what it supports.  The
3139 bit definitions are:
3142 Capability Name      Encoding  Meaning
3143 ==================== ========  =====================================
3145 CAP_RAW_MODE         0x0001    The server supports SMB_COM_READ_RAW
3146                                 and SMB_COM_WRITE_RAW
3147 CAP_MPX_MODE         0x0002    The server supports SMB_COM_READ_MPX
3148                                 and SMB_COM_WRITE_MPX
3149 CAP_UNICODE          0x0004    The server supports Unicode strings
3150 CAP_LARGE_FILES      0x0008    The server supports large files with
3151                                 64 bit offsets
3152 CAP_NT_SMBS          0x0010    The server supports the SMBs
3153                                 particular to the NT LM 0.12 dialect
3154 CAP_RPC_REMOTE_APIS  0x0020    The sever supports remote API
3155                                 requests via RPC
3156 CAP_STATUS32         0x0040    The server can respond with 32 bit
3157                                 status codes in Status.Status
3158 CAP_LEVEL_II_OPLOCKS 0x0080    The server supports level 2 oplocks
3159 CAP_LOCK_AND_READ    0x0100    The server supports the
3160                                 SMB_COM_LOCK_AND_READ SMB
3161 CAP_NT_FIND          0x0200
3162 CAP_DFS              0x1000    This server is DFS aware
3168 4.1.1.1   Errors
3170 SUCCESS/SUCCESS
3171 ERRSRV/ERRerror
3174 4.1.2        SESSION_SETUP_ANDX: Session Setup
3176 This SMB is used to further "Set up" the session normally just
3177 established via the negotiate protocol.
3179 One primary function is to perform a "user logon" in the case where the
3180 server is in user level security mode.  The Uid in the SMB header is set
3181 by the client to be the userid desired for the AccountName and validated
3182 by the AccountPassword.
3196 Leach, Naik       expires September, 1997         [Page 51] \f
3199 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3202 If the negotiated protocol is prior to NT LM 0.12, the format of
3203 SMB_COM_SESSION_SETUP_ANDX is:
3206 Client Request                 Description
3207 ============================== =====================================
3209 UCHAR WordCount;               Count of parameter words = 10
3210 UCHAR AndXCommand;             Secondary (X) command; 0xFF = none
3211 UCHAR AndXReserved;            Reserved (must be 0)
3212 USHORT AndXOffset;             Offset to next command WordCount
3213 USHORT MaxBufferSize;          Client maximum buffer size
3214 USHORT MaxMpxCount;            Actual maximum multiplexed pending
3215                                 requests
3216 USHORT VcNumber;               0 = first (only), nonzero=additional
3217                                 VC number
3218 ULONG SessionKey;              Session key (valid iff VcNumber != 0)
3219 USHORT PasswordLength;         Account password size
3220 ULONG Reserved;                Must be 0
3221 USHORT ByteCount;              Count of data bytes;    min = 0
3222 UCHAR AccountPassword[];       Account Password
3223 STRING AccountName[];          Account Name
3224 STRING PrimaryDomain[];        Client's primary domain
3225 STRING NativeOS[];             Client's native operating system
3226 STRING NativeLanMan[];         Client's native LAN Manager type
3230 and the response is:
3233 Server Response                    Description
3234 ================================== =================================
3236 UCHAR WordCount;                   Count of parameter words = 3
3237 UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
3238                                     none
3239 UCHAR AndXReserved;                Reserved (must be 0)
3240 USHORT AndXOffset;                 Offset to next command WordCount
3241 USHORT Action;                     Request mode:
3242                                     bit0 = logged in as GUEST
3243 USHORT ByteCount;                  Count of data bytes
3244 STRING NativeOS[];                 Server's native operating system
3245 STRING NativeLanMan[];             Server's native LAN Manager type
3246 STRING PrimaryDomain[];            Server's primary domain
3250 If the server is in "share level security mode", the account name and
3251 passwd should be ignored by the server.
3253 If challenge/response authentication is not being used, AccountPassword
3254 should be a null terminated ASCII string with PasswordLength set to the
3255 string size including the null; the password will case insensitive. If
3256 challenge/response authentication is being used (see section 2.10), then
3257 AccountPassword will be the response to the server's challenge, and
3258 PasswordLength should be set to its length.
3263 Leach, Naik       expires September, 1997         [Page 52] \f
3266 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3269 The server validates the name and password supplied and if valid, it
3270 registers the user identifier on this session as representing the
3271 specified AccountName.  The Uid  field in the SMB header will then be
3272 used to validate access on subsequent SMB requests.  The SMB requests
3273 where permission checks are required are those which refer to a
3274 symbolically named resource such as SMB_COM_OPEN, SMB_COM_RENAME,
3275 SMB_COM_DELETE, etc..  The value of the Uid is relative to a specific
3276 client/server session so it is possible to have the same Uid value
3277 represent two different users on two different sessions at the server.
3279 Multiple session setup commands may be sent to register additional users
3280 on this session.  If the server receives an additional
3281 SMB_COM_SESSION_SETUP_ANDX, only the Uid, AccountName and
3282 AccountPassword fields need contain valid values (the server MUST ignore
3283 the other fields).
3285 The client writes the name of its domain in PrimaryDomain if it knows
3286 what the domain name is.  If the domain name is unknown, the client
3287 either encodes it as a NULL string, or as a question mark.
3289 If bit0 of Action is set, this informs the client that although the
3290 server did not recognize the AccountName, it logged the user in as a
3291 guest.  This is optional behavior by the server, and in any case one
3292 would ordinarily expect guest privileges to limited.
3294 Another function of the Session Set Up protocol is to inform the server
3295 of the maximum values which will be utilized by this client.  Here
3296 MaxBufferSize is the maximum message size which the client can receive.
3297 Thus although the server may support 16k buffers (as returned in the
3298 SMB_COM_NEGOTIATE response), if the client only has 4k buffers, the
3299 value of MaxBufferSize here would be 4096.  The minimum allowable value
3300 for MaxBufferSize is 1024.  The SMB_COM_NEGOTIATE response includes the
3301 server buffer size supported.  Thus this is the maximum SMB message size
3302 which the client can send to the server.  This size may be larger than
3303 the size returned to the server from the client via the
3304 SMB_COM_SESSION_SETUP_AND X protocol which is the maximum SMB message
3305 size which the server may send to the client.  Thus if the server's
3306 buffer size were 4k and the client's buffer size were only 2K,  the
3307 client could send up to 4k (standard) write requests but must only
3308 request up to 2k for (standard) read requests.
3310 The field, MaxMpxCount informs the server of the maximum number of
3311 requests which the client will have outstanding to the server
3312 simultaneously (see sections 5.13 and 5.25).
3314 The VcNumber field specifies whether the client wants this to be the
3315 first VC or an additional VC.
3317 The values for MaxBufferSize, MaxMpxCount, and VcNumber must be less
3318 than or equal to the maximum values supported by the server as returned
3319 in the SMB_COM_NEGOTIATE response.
3321 If the server gets a SMB_COM_SESSION_SETUP_ANDX request with VcNumber of
3322 0 and other VCs are still connected to that client, they will be aborted
3324 Leach, Naik       expires September, 1997         [Page 53] \f
3327 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3330 thus freeing any resources held by the server.  This condition could
3331 occur if the client was rebooted and reconnected to the server before
3332 the transport level had informed the server of the previous VC
3333 termination.
3335 If the negotiated SMB dialect is "NT LM 0.12" or later, the format of
3336 the response SMB is unchanged, but the request is:
3339 Client Request                 Description
3340 ============================== =====================================
3342 UCHAR WordCount;               Count of parameter words = 13
3343 UCHAR AndXCommand;             Secondary (X) command;  0xFF = none
3344 UCHAR AndXReserved;            Reserved (must be 0)
3345 USHORT AndXOffset;             Offset to next command WordCount
3346 USHORT MaxBufferSize;          Client's maximum buffer size
3347 USHORT MaxMpxCount;            Actual maximum multiplexed pending
3348                                 requests
3349 USHORT VcNumber;               0 = first (only), nonzero=additional
3350                                 VC number
3351 ULONG SessionKey;              Session key (valid iff VcNumber != 0)
3352 USHORT                         Account password size, ANSI
3353 CaseInsensitivePasswordLength;
3354 USHORT                         Account password size, Unicode
3355 CaseSensitivePasswordLength;
3356 ULONG Reserved;                must be 0
3357 ULONG Capabilities;            Client capabilities
3358 USHORT ByteCount;              Count of data bytes;    min = 0
3359 UCHAR                          Account Password, ANSI
3360 CaseInsensitivePassword[];
3361 UCHAR CaseSensitivePassword[]; Account Password, Unicode
3362 STRING AccountName[];          Account Name, Unicode
3363 STRING PrimaryDomain[];        Client's primary domain, Unicode
3364 STRING NativeOS[];             Client's native operating system,
3365                                 Unicode
3366 STRING NativeLanMan[];         Client's native LAN Manager type,
3367                                 Unicode
3387 Leach, Naik       expires September, 1997         [Page 54] \f
3390 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3393 The client expresses its capabilities to the server encoded in the
3394 Capabilities field:
3397 Capability Name           Encoding  Description
3398 ========================  ========= ================================
3400 CAP_UNICODE               0x0004    The client can use UNICODE
3401                                      strings
3402 CAP_LARGE_FILES           0x0008    The client can deal with files
3403                                      having 64 bit offsets
3404 CAP_NT_SMBS               0x0010    The client understands the SMBs
3405                                      introduced with the NT LM 0.12
3406                                      dialect.  Implies CAP_NT_FIND.
3407 CAP_NT_FIND               0x0200
3408 CAP_ STATUS32             0x0040    The client can receive 32 bit
3409                                      errors encoded in Status.Status
3410 CAP_LEVEL_II_OPLOCKS      0x0080    The client understands Level II
3411                                      oplocks
3415 The entire message sent and received including the optional ANDX SMB
3416 must fit in the negotiated maximum transfer size.  The following are the
3417 only valid SMB commands for AndXCommand for SMB_COM_SESSION_SETUP_ANDX
3420 SMB_COM_TREE_CONNECT_ANDX     SMB_COM_OPEN
3421 SMB_COM_OPEN_ANDX             SMB_COM_CREATE
3422 SMB_COM_CREATE_NEW            SMB_COM_CREATE_DIRECTORY
3423 SMB_COM_DELETE                SMB_COM_DELETE_DIRECTORY
3424 SMB_COM_FIND                  SMB_COM_FIND_UNIQUE
3425 SMB_COM_COPY                  SMB_COM_RENAME
3426 SMB_COM_NT_RENAME             SMB_COM_CHECK_DIRECTORY
3427 SMB_COM_QUERY_INFORMATION     SMB_COM_SET_INFORMATION
3428 SMB_COM_NO_ANDX_COMMAND       SMB_COM_OPEN_PRINT_FILE
3429 SMB_COM_GET_PRINT_QUEUE       SMB_COM_TRANSACTION
3432 4.1.2.1   Errors
3434 ERRSRV/ERRerror     - no NEG_PROT issued
3435 ERRSRV/ERRbadpw     - password not correct for given username
3436 ERRSRV/ERRtoomanyuids    - maximum number of users per session exceeded
3437 ERRSRV/ERRnosupport - chaining of this request to the previous one is
3438 not supported
3452 Leach, Naik       expires September, 1997         [Page 55] \f
3455 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3458 4.1.3        LOGOFF_ANDX: User Logoff
3460 This SMB is the inverse of SMB_COM_SESSION_SETUP_ANDX.
3463 Client Request                     Description
3464 ================================== =================================
3466 UCHAR WordCount;                   Count of parameter words = 2
3467 UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
3468                                     none
3469 UCHAR AndXReserved;                Reserved (must be 0)
3470 USHORT AndXOffset;                 Offset to next command WordCount
3471 USHORT ByteCount;                  Count of data bytes = 0
3475 Server Response                    Description
3476 ================================== =================================
3478 UCHAR WordCount;                   Count of parameter words = 2
3479 UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
3480                                     none
3481 UCHAR AndXReserved;                Reserved (must be 0)
3482 USHORT AndXOffset;                 Offset to next command WordCount
3483 USHORT ByteCount;                  Count of data bytes = 0
3487 The user represented by Uid in the SMB header is logged off.  The server
3488 closes all files currently open by this user, and invalidates any
3489 outstanding requests with this Uid.
3491 SMB_COM_SESSION_SETUP_ANDX is the only valid AndXCommand. for this SMB.
3494 4.1.3.1   Errors
3496 ERRSRV/invnid  - TID was invalid
3497 ERRSRV/baduid  - UID was invalid
3500 4.1.4        TREE_CONNECT_ANDX:  Tree Connect
3503 Client Request                     Description
3504 =================================  =================================
3506 UCHAR WordCount;                   Count of parameter words = 4
3507 UCHAR AndXCommand;                 Secondary (X) command; 0xFF = none
3508 UCHAR AndXReserved;                Reserved (must be 0)
3509 USHORT AndXOffset;                 Offset to next command WordCount
3510 USHORT Flags;                      Additional information
3511                                    bit 0 set = disconnect Tid
3512 USHORT PasswordLength;             Length of Password[]
3513 USHORT ByteCount;                  Count of data bytes;    min = 3
3514 UCHAR Password[];                  Password
3515 STRING Path[];                     Server name and share name
3516 STRING Service[];                  Service name
3520 Leach, Naik       expires September, 1997         [Page 56] \f
3523 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3526 The serving machine verifies the combination and returns an error code
3527 or an identifier.  The full name is included in this request message and
3528 the identifier identifying the connection is returned in the Tid field
3529 of the SMB header.  The Tid field in the client request is ignored.  The
3530 meaning of this identifier (Tid) is server specific; the client must not
3531 associate any specific meaning to it.
3533 If the negotiated dialect is LANMAN1.0 or later, then it is a protocol
3534 violation for the client to send this message prior to a successful
3535 SMB_COM_SESSION_SETUP_ANDX, and the server ignores Password.
3537 If the negotiated dialect is prior to LANMAN1.0 and the client has not
3538 sent a successful SMB_COM_SESSION_SETUP_ANDX request when the tree
3539 connect arrives, a user level security mode server must nevertheless
3540 validate the client's credentials as discussed earlier in this document.
3542 Path follows UNC style syntax, that is to say it is encoded as
3543 \\server\share and it indicates the name of the resource to which the
3544 client wishes to connect.
3546 Because Password may be an authentication response, it is a variable
3547 length field with the length specified by PasswordLength.   If
3548 authentication is not being used, Password should be a null terminated
3549 ASCII string with PasswordLength set to the string size including the
3550 terminating null.
3552 The server can enforce whatever policy it desires to govern share
3553 access. Typically, if the server is paused, administrative privilege is
3554 required to connect to any share; if the server is not paused,
3555 administrative privilege is required only for administrative shares (C$,
3556 etc.). Other such policies may include valid times of day, software
3557 usage license limits, number of simultaneous server users or share
3558 users, etc.
3560 The Service component indicates the type of resource the client intends
3561 to access.  Valid values are:
3564 Service   Description               Earliest Dialect Allowed
3565 ========  ========================  ================================
3567 A:        disk share                PC NETWORK PROGRAM 1.0
3568 LPT1:     printer                   PC NETWORK PROGRAM 1.0
3569 IPC       named pipe                MICROSOFT NETWORKS 3.0
3570 COMM      communications device     MICROSOFT NETWORKS 3.0
3571 ?????     any type of device        MICROSOFT NETWORKS 3.0
3575 If bit0 of Flags is set, the tree connection to Tid in the SMB header
3576 should be disconnected.  If this tree disconnect fails, the error should
3577 be ignored.
3579 If the negotiated dialect is earlier than DOS LANMAN2.1, the response to
3580 this SMB is:
3584 Leach, Naik       expires September, 1997         [Page 57] \f
3587 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3591 Server Response                  Description
3592 ================================ ===================================
3594 UCHAR WordCount;                 Count of parameter words = 2
3595 UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
3596 UCHAR AndXReserved;              Reserved (must be 0)
3597 USHORT AndXOffset;               Offset to next command WordCount
3598 USHORT ByteCount;                Count of data bytes;    min = 3
3602 If the negotiated is DOS LANMAN2.1 or later, the response to this SMB
3606 Server Response                  Description
3607 ================================ ===================================
3609 UCHAR WordCount;                 Count of parameter words = 3
3610 UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
3611 UCHAR AndXReserved;              Reserved (must be 0)
3612 USHORT AndXOffset;               Offset to next command WordCount
3613 USHORT OptionalSupport;          Optional support bits
3614 USHORT ByteCount;                Count of data bytes;    min = 3
3615 UCHAR Service[];                 Service type connected to.  Always
3616                                   ANSII.
3617 STRING NativeFileSystem[];       Native file system for this tree
3621 NativeFileSystem is the name of the filesystem; values to be expected
3622 include FAT, NTFS, etc.
3624 OptionalSupport bits has the encoding:
3627 Name                           Encoding   Description
3628 =============================  =========  ==========================
3630 SMB_SUPPORT_SEARCH_BITS        0x0001
3632 SMB_SHARE_IS_IN_DFS            0x0002
3636 Some servers negotiate "DOS LANMAN2.1" dialect or later and still send
3637 the "downlevel" (i.e. wordcount==2) response.  Valid AndX following
3638 commands are
3641 SMB_COM_OPEN              SMB_COM_OPEN_ANDX          SMB_COM_CREATE
3642 SMB_COM_CREATE_NEW        SMB_COM_CREATE_DIRECTORY   SMB_COM_DELETE
3643 SMB_COM_DELETE_DIRECTORY  SMB_COM_FIND               SMB_COM_COPY
3644 SMB_COM_FIND_UNIQUE       SMB_COM_RENAME
3645 SMB_COM_CHECK_DIRECTORY   SMB_COM_QUERY_INFORMATION
3646 SMB_COM_GET_PRINT_QUEUE   SMB_COM_OPEN_PRINT_FILE
3647 SMB_COM_TRANSACTION       SMB_COM_NO_ANDX_CMD
3648 SMB_COM_SET_INFORMATION   SMB_COM_NT_RENAME
3650 4.1.4.1   Errors
3652 ERRDOS/ERRnomem
3653 ERRDOS/ERRbadpath
3656 Leach, Naik       expires September, 1997         [Page 58] \f
3659 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3662 ERRDOS/ERRinvdevice
3663 ERRSRV/ERRaccess
3664 ERRSRV/ERRbadpw
3665 ERRSRV/ERRinvnetname
3668 4.1.5        TREE_DISCONNECT:  Tree Disconnect
3670 This message informs the server that the client no longer wishes to
3671 access the resource connected to with a prior SMB_COM_TREE_CONNECT or
3672 SMB_COM_TREE_CONNECT_ANDX.
3675 Client Request                     Description
3676 ================================== =================================
3678 UCHAR WordCount;                   Count of parameter words = 0
3679 USHORT ByteCount;                  Count of data bytes = 0
3683 The resource sharing connection identified by Tid in the SMB header is
3684 logically disconnected from the server. Tid is invalidated; it will not
3685 be recognized if used by the client for subsequent requests. All locks,
3686 open files, etc. created on behalf of Tid are released.
3689 Server Response                    Description
3690 ================================== =================================
3692 UCHAR WordCount;                   Count of parameter words = 0
3693 USHORT ByteCount;                  Count of data bytes = 0
3696 4.1.5.1   Errors
3698 ERRSRV/ERRinvnid
3699 ERRSRV/ERRbaduid
3702 4.1.6        TRANS2_QUERY_FS_INFORMATION: Get File System Information
3704 This transaction requests information about a filesystem on the server.
3707  Client Request                     Value
3708  ================================== =================================
3710  WordCount;                         15
3711  TotalParameterCount;               2 or 4
3712  MaxSetupCount;                     0
3713  SetupCount;                        1 or 2
3714  Setup[0];                          TRANS2_QUERY_FS_INFORMATION
3718  Parameter Block Encoding           Description
3719  ================================== =================================
3721  USHORT Information Level;          Level of information requested
3725 The  filesystem is identified by Tid in the SMB header.
3728 Leach, Naik       expires September, 1997         [Page 59] \f
3731 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3734 MaxDataCount in the transaction request must be large enough to
3735 accommodate the response.
3737 The encoding of the response parameter block depends on the
3738 InformationLevel requested.  Information levels whose values are greater
3739 than 0x102 are mapped to corresponding calls to
3740 NtQueryVolumeInformationFile calls by the server.  The two levels below
3741 0x102 are described below.  The requested information is placed in the
3742 Data portion of the transaction response.
3745  InformationLevel               Value
3747  =============================  ======
3749  SMB_INFO_ALLOCATION            1
3750  SMB_INFO_VOLUME                2
3751  SMB_QUERY_FS_VOLUME_INFO       0x102
3752  SMB_QUERY_FS_SIZE_INFO         0x103
3753  SMB_QUERY_FS_DEVICE_INFO       0x104
3754  SMB_QUERY_FS_ATTRIBUTE_INFO    0x105
3758 The following sections describe the InformationLevel dependent encoding
3759 of the data part of the transaction response.
3792 Leach, Naik       expires September, 1997         [Page 60] \f
3795 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3798 4.1.6.1   SMB_INFO_ALLOCATION
3801  Data Block Encoding Description
3802  =================== ================================================
3804  ULONG idFileSystem; File system identifier.  NT server always
3805                       returns 0
3806  ULONG cSectorUnit;  Number of sectors per allocation unit
3807  ULONG cUnit;        Total number of allocation units
3808  ULONG cUnitAvail;   Total number of available allocation units
3809  USHORT cbSector;    Number of bytes per sector
3812 4.1.6.2   SMB_INFO_VOLUME
3815  Data Block Encoding Description
3816  =================== ================================================
3818  ULONG ulVsn;        Volume serial number
3819  UCHAR cch;          Number of  characters in Label
3820  STRING Label;       The volume label
3823 4.1.6.3   SMB_QUERY_FS_VOLUME_INFO
3826  Data Block Encoding Description
3827  =================== ================================================
3829  LARGE_INTEGER       Volume Creation Time
3830  ULONG               Volume Serial Number
3831  ULONG               Length of Volume Label in bytes
3833  BYTE                Reserved
3835  BYTE                Reserved
3837  STRING Label;       The volume label
3844 4.1.6.4   SMB_QUERY_FS_SIZE_INFO
3847  Data Block Encoding Description
3848  =================== ================================================
3850  LARGE_INTEGER       Total Number of Allocation units on the Volume
3851  LARGE_INTEGER       Number of free Allocation units on the Volume
3852  ULONG               Number of sectors in each Allocation unit
3854  ULONG               Number of bytes in each sector
3868 Leach, Naik       expires September, 1997         [Page 61] \f
3871 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3874 4.1.6.5   SMB_QUERY_FS_DEVICE_INFO
3877  Data Block Encoding  Value
3878  ==================== ===============================================
3880  ULONG                DeviceType; Values as specified below
3881  ULONG                Characteristics of the device; Values as
3882                        specified below
3885 For DeviceType, note that the values 0-32767 are reserved for the
3886 exclusive use of Microsoft Corporation. The following device types are
3887 currently defined:
3931 Leach, Naik       expires September, 1997         [Page 62] \f
3934 INTERNET-DRAFT            CIFS/1.0                  03/19/97
3938 FILE_DEVICE_BEEP             0x00000001
3940 FILE_DEVICE_CD_ROM           0x00000002
3941 FILE_DEVICE_CD_ROM_FILE_SYST 0x00000003
3943 FILE_DEVICE_CONTROLLER       0x00000004
3944 FILE_DEVICE_DATALINK         0x00000005
3945 FILE_DEVICE_DFS              0x00000006
3946 FILE_DEVICE_DISK             0x00000007
3947 FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
3948 FILE_DEVICE_FILE_SYSTEM      0x00000009
3949 FILE_DEVICE_INPORT_PORT      0x0000000a
3950 FILE_DEVICE_KEYBOARD         0x0000000b
3951 FILE_DEVICE_MAILSLOT         0x0000000c
3952 FILE_DEVICE_MIDI_IN          0x0000000d
3953 FILE_DEVICE_MIDI_OUT         0x0000000e
3954 FILE_DEVICE_MOUSE            0x0000000f
3955 FILE_DEVICE_MULTI_UNC_PROVID 0x00000010
3957 FILE_DEVICE_NAMED_PIPE       0x00000011
3958 FILE_DEVICE_NETWORK          0x00000012
3959 FILE_DEVICE_NETWORK_BROWSER  0x00000013
3960 FILE_DEVICE_NETWORK_FILE_SYS 0x00000014
3962 FILE_DEVICE_NULL             0x00000015
3963 FILE_DEVICE_PARALLEL_PORT    0x00000016
3964 FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
3965 FILE_DEVICE_PRINTER          0x00000018
3966 FILE_DEVICE_SCANNER          0x00000019
3967 FILE_DEVICE_SERIAL_MOUSE_POR 0x0000001a
3969 FILE_DEVICE_SERIAL_PORT      0x0000001b
3970 FILE_DEVICE_SCREEN           0x0000001c
3971 FILE_DEVICE_SOUND            0x0000001d
3972 FILE_DEVICE_STREAMS          0x0000001e
3973 FILE_DEVICE_TAPE             0x0000001f
3974 FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
3975 FILE_DEVICE_TRANSPORT        0x00000021
3976 FILE_DEVICE_UNKNOWN          0x00000022
3977 FILE_DEVICE_VIDEO            0x00000023
3978 FILE_DEVICE_VIRTUAL_DISK     0x00000024
3979 FILE_DEVICE_WAVE_IN          0x00000025
3980 FILE_DEVICE_WAVE_OUT         0x00000026
3981 FILE_DEVICE_8042_PORT        0x00000027
3982 FILE_DEVICE_NETWORK_REDIRECT 0x00000028
3984 FILE_DEVICE_BATTERY          0x00000029
3985 FILE_DEVICE_BUS_EXTENDER     0x0000002a
3986 FILE_DEVICE_MODEM            0x0000002b
3987 FILE_DEVICE_VDM              0x0000002c
3991 Some of these device types are not currently accesible over the network
3992 and may never be accessible over the network. Some may change to be
3995 Leach, Naik       expires September, 1997         [Page 63] \f
3998 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4001 accessible over the network. The values for device types that may never
4002 be accessible over the network may be redefined to be just resrved at
4003 some date in the future.
4005 Characteristics is the sum of any of the following:
4008 FILE_REMOVABLE_MEDIA         0x00000001
4009 FILE_READ_ONLY_DEVICE        0x00000002
4010 FILE_FLOPPY_DISKETTE         0x00000004
4011 FILE_WRITE_ONE_MEDIA         0x00000008
4012 FILE_REMOTE_DEVICE           0x00000010
4013 FILE_DEVICE_IS_MOUNTED       0x00000020
4014 FILE_VIRTUAL_VOLUME          0x00000040
4019 4.1.6.6   SMB_QUERY_FS_ATTRIBUTE_INFO
4022  Data Block Encoding Description
4023  =================== ================================================
4025  ULONG               File System Attributes; possible values
4026                       described below
4027  LONG                Maximum length of each file name component in
4028                       number of bytes
4029  ULONG               Length, in bytes, of the name of the file system
4031  STRING              Name of the file system
4035 Where FileSystemAttributes is the sum of any of the following:
4038 FILE_CASE_SENSITIVE_SEARCH   0x00000001
4039 FILE_CASE_PRESERVED_NAMES    0x00000002
4040 FILE_PRSISTENT_ACLS          0x00000004
4041 FILE_FILE_COMPRESSION        0x00000008
4042 FILE_VOLUME_QUOTAS           0x00000010
4043 FILE_DEVICE_IS_MOUNTED       0x00000020
4044 FILE_VOLUME_IS_COMPRESSED    0x00008000
4049 4.1.6.7   Errors
4051 ERRSRV/invnid  - TID was invalid
4052 ERRSRV/baduid  - UID was invalid
4053 ERRHRD/ERRnotready  - the file system has been removed
4054 ERRHRD/ERRdata - disk I/O error
4055 ERRSRV/ERRaccess    - user does not have the right to perform this
4056 operation
4057 ERRSRV/ERRinvdevice - resource identified by TID is not a file system
4064 Leach, Naik       expires September, 1997         [Page 64] \f
4067 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4070 4.1.7        ECHO: Ping the Server
4072 This request is used to test the connection to the server, and to see if
4073 the server is still responding.
4076  Client Request                     Description
4077  ================================== =================================
4079  UCHAR WordCount;                   Count of parameter words = 1
4080  USHORT EchoCount;                  Number of times to echo data back
4081  USHORT ByteCount;                  Count of data bytes;    min = 1
4082  UCHAR Buffer[1];                   Data to echo
4086  Server Response                    Description
4087  ================================== =================================
4089  UCHAR WordCount;                   Count of parameter words = 1
4090  USHORT SequenceNumber;             Sequence number of this echo
4091  USHORT ByteCount;                  Count of data bytes;    min = 4
4092  UCHAR Buffer[1];                   Echoed data
4096 Each response echoes the data sent, though ByteCount may indicate no
4097 data  If EchoCount is zero, no response is sent.
4099 Tid in the SMB header is ignored, so this request may be sent to the
4100 server even if there are no valid tree connections to the server.
4102 The flow for the ECHO protocol is:
4105  Client Request                     <->  Server Response
4106  =================================  ==== ============================
4108  Echo Request (EchoCount == n)      ->
4109                                     <-   Echo Response 1
4110                                     <-   Echo Response 2
4111                                     <-   Echo Response n
4116 4.1.7.1   Errors
4118 ERRSRV/ERRbaduid    - UID was invalid
4119 ERRSRV/ERRnoaccess  - session has not been established
4120 ERRSRV/ERRnosupport - ECHO function is not supported
4123 4.1.8        NT_CANCEL: Cancel request
4125 This SMB allows a client to cancel a request currently pending at the
4126 server.
4133 Leach, Naik       expires September, 1997         [Page 65] \f
4136 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4140 Client Request                     Description
4141 ================================== =================================
4143 UCHAR WordCount;                   No words are sent (== 0)
4144 USHORT ByteCount;                  No bytes (==0)
4148 The Sid, Uid, Pid, Tid, and Mid fields of the SMB are used to locate an
4149 pending server request from this session.  If a pending request is
4150 found, it is "hurried along" which may result in success or failure of
4151 the original request.  No other response is generated for this SMB.
4154 4.2  File Requests
4159 4.2.1        NT_CREATE_ANDX: Create or Open File
4161 This command is used to create or open a file or a directory.
4164  Client Request                     Description
4165  =================================  ==================================
4167  UCHAR WordCount;                   Count of parameter words = 24
4168  UCHAR AndXCommand;                 Secondary command;  0xFF = None
4169  UCHAR AndXReserved;                Reserved (must be 0)
4170  USHORT AndXOffset;                 Offset to next command WordCount
4171  UCHAR Reserved;                    Reserved (must be 0)
4172  USHORT NameLength;                 Length of Name[] in bytes
4173  ULONG Flags;                       Create bit set:
4174                                     0x02 - Request an oplock
4175                                     0x04 - Request a batch oplock
4176                                     0x08 - Target of open must be
4177                                     directory
4178  ULONG RootDirectoryFid;            If non-zero, open is relative to
4179                                     this directory
4180  ACCESS_MASK DesiredAccess;         access desired
4181  LARGE_INTEGER AllocationSize;      Initial allocation size
4182  ULONG ExtFileAttributes;           File attributes
4183  ULONG ShareAccess;                 Type of share access
4184  ULONG CreateDisposition;           Action to take if file exists or
4185                                     not
4186  ULONG CreateOptions;               Options to use if creating a file
4187  ULONG ImpersonationLevel;          Security QOS information
4188  UCHAR SecurityFlags;               Security tracking mode flags:
4189                                     0x1 - SECURITY_CONTEXT_TRACKING
4190                                     0x2 - SECURITY_EFFECTIVE_ONLY
4191  USHORT ByteCount;                  Length of byte parameters
4192  STRING Name[];                     File to open or create
4196 The DesiredAccess parameter is specified in section 3.7 on  Access Mask
4197 Encoding.
4200 Leach, Naik       expires September, 1997         [Page 66] \f
4203 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4206 If no value is specified, it still allows an application to query
4207 attributes without actually accessing the file.
4209 The ExtFIleAttributes parameter specifies the file attributes and flags
4210 for the file. The parameter's value is the sum of allowed attributes and
4211 flags defined in section 3.11 on  Extended File Attribute Encoding
4213 The ShareAccess field Specifies how this file can be shared. This
4214 parameter must be some combination of the following values:
4217 Name              Value      Meaning
4218                   0          Prevents the file from being shared.
4219 FILE_SHARE_READ   0x00000001 Other open operations can be performed on
4220                               the file for read access.
4221 FILE_SHARE_WRITE  0x00000002 Other open operations can be performed on
4222                               the file for write access.
4223 FILE_SHARE_DELETE 0x00000004 Other open operations can be performed on
4224                               the file for delete access.
4227 The CreateDisposition parameter can contain one of the following values:
4230 CREATE_NEW        Creates a new file. The function fails if the
4231                   specified file already exists.
4232 CREATE_ALWAYS     Creates a new file. The function overwrites the file
4233                   if it exists.
4234 OPEN_EXISTING     Opens the file. The function fails if the file does
4235                   not exist.
4236 OPEN_ALWAYS       Opens the file, if it exists. If the file does not
4237                   exist, act like CREATE_NEW.
4238 TRUNCATE_EXISTING Opens the file. Once opened, the file is truncated so
4239                   that its size is zero bytes. The calling process must
4240                   open the file with at least GENERIC_WRITE access. The
4241                   function fails if the file does not exist.
4244 The ImpersonationLevel parameter can contain one or more of the
4245 following values:
4248 SECURITY_ANONYMOUS        Specifies to impersonate the client at the
4249                           Anonymous impersonation level.
4250 SECURITY_IDENTIFICATION   Specifies to impersonate the client at the
4251                           Identification impersonation level.
4252 SECURITY_IMPERSONATION    Specifies to impersonate the client at the
4253                           Impersonation impersonation level.
4254 SECURITY_DELEGATION       Specifies to impersonate the client at the
4255                           Delegation impersonation level.
4258 The SecurityFlags parameter can have either of the following two flags
4259 set:
4264 Leach, Naik       expires September, 1997         [Page 67] \f
4267 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4271 SECURITY_CONTEXT_TRACKING  Specifies that the security tracking mode is
4272                            dynamic. If this flag is not specified,
4273                            Security Tracking Mode is static.
4274 SECURITY_EFFECTIVE_ONLY    Specifies that only the enabled aspects of
4275                            the client's security context are available
4276                            to the server. If you do not specify this
4277                            flag, all aspects of the client's security
4278                            context are available. This flag allows the
4279                            client to limit the groups and privileges
4280                            that a server can use while impersonating the
4281                            client.
4284 The response is as follows:
4287  Server Response                    Description
4288  =================================  ==================================
4290  UCHAR WordCount;                   Count of parameter words = 26
4291  UCHAR AndXCommand;  Secondary      0xFF = None
4292  command;
4293  UCHAR AndXReserved;                MBZ
4294  USHORT AndXOffset;                 Offset to next command WordCount
4295  UCHAR OplockLevel;                 The oplock level granted
4296                                     0 - No oplock granted
4297                                     1 - Exclusive oplock granted
4298                                     2 - Batch oplock granted
4299                                     3 - Level II oplock granted
4300  USHORT Fid;                        The file ID
4301  ULONG CreateAction;                The action taken
4302  TIME CreationTime;                 The time the file was created
4303  TIME LastAccessTime;               The time the file was accessed
4304  TIME LastWriteTime;                The time the file was last written
4305  TIME ChangeTime;                   The time the file was last changed
4306  ULONG ExtFileAttributes;           The file attributes
4307  LARGE_INTEGER AllocationSize;      The number of byes allocated
4308  LARGE_INTEGER EndOfFile;           The end of file offset
4309  USHORT FileType;
4310  USHORT DeviceState;                state of IPC device (e.g. pipe)
4311  BOOLEAN Directory;                 TRUE if this is a directory
4312  USHORT ByteCount;                  = 0
4316 The following SMBs may follow SMB_COM_NT_CREATE_ANDX:
4319    SMB_COM_READ    SMB_COM_READ_ANDX
4320    SMB_COM_IOCTL
4330 Leach, Naik       expires September, 1997         [Page 68] \f
4333 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4336 4.2.2N       T_TRANSACT_CREATE: Create or Open File with EAs or SD
4338 This command is used to create or open a file or a directory, when EAs
4339 or an SD must be applied to the file.
4342  Request Parameter Block Encoding    Description
4343  =================================== ================================
4345  ULONG Flags;                        Creation flags (see below)
4346  ULONG RootDirectoryFid;             Optional directory for relative
4347                                       open
4348  ACCESS_MASK DesiredAccess;          Desired access
4349  LARGE_INTEGER AllocationSize;       The initial allocation size in
4350                                       bytes, if file created
4351  ULONG ExtFileAttributes;            The extended file attributes
4352  ULONG ShareAccess;                  The share access
4353  ULONG CreateDisposition;            Action to take if file exists or
4354                                       not
4355  ULONG CreateOptions;                Options for creating a new file
4356  ULONG SecurityDescriptorLength;     Length of SD in bytes
4357  ULONG EaLength;                     Length of EA in bytes
4358  ULONG NameLength;                   Length of name in characters
4359  ULONG ImpersonationLevel;           Security QOS information
4360  UCHAR SecurityFlags;                Security QOS information
4361  STRING Name[NameLength];            The name of the file (not NULL
4362                                       terminated)
4366  Data Block Encoding                 Description
4367  =================================== ================================
4369  UCHAR SecurityDescriptor[
4370  SecurityDescriptorLength];
4371  UCHAR ExtendedAttributes[EaLength];
4375  Creation Flag Name         Value   Description
4376  ========================== ======  ==================================
4378  NT_CREATE_REQUEST_OPLOCK   0x02    Level I oplock requested
4379  NT_CREATE_REQUEST_OPBATCH  0x04    Batch oplock requested
4380  NT_CREATE_OPEN_TARGET_DIR  0x08    Target for open is a directory
4397 Leach, Naik       expires September, 1997         [Page 69] \f
4400 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4404  Output Parameter Block Encoding    Description
4405  ================================== ==================================
4407  UCHAR OplockLevel;                 The oplock level granted
4408  UCHAR Reserved;
4409  USHORT Fid;                        The file ID
4410  ULONG CreateAction;                The action taken
4411  ULONG EaErrorOffset;               Offset of the EA error
4412  TIME CreationTime;                 The time the file was created
4413  TIME LastAccessTime;               The time the file was accessed
4414  TIME LastWriteTime;                The time the file was last written
4415  TIME ChangeTime;                   The time the file was last changed
4416  ULONG ExtFileAttributes;           The file attributes
4417  LARGE_INTEGER AllocationSize;      The number of byes allocated
4418  LARGE_INTEGER EndOfFile;           The end of file offset
4419  USHORT FileType;
4420  USHORT DeviceState;                state of IPC device (e.g. pipe)
4421  BOOLEAN Directory;                 TRUE if this is a directory
4425 See the description of NT_CREATE_ANDX for the definition of the
4426 parameters.
4429 4.2.3        CREATE_TEMPORARY: Create Temporary File
4431 The server creates a data file in Directory relative to Tid in the SMB
4432 header and assigns a unique name to it.
4435 Client Request                     Server Response
4436 ================================== =================================
4438 UCHAR WordCount;                   Count of parameter words = 3
4439 USHORT reserved;                   Ignored by the server
4440 UTIME CreationTime;                New file's creation time stamp
4441 USHORT ByteCount;                  Count of data bytes;  min = 2
4442 UCHAR BufferFormat;                0x04
4443 STRING DirectoryName[];            Directory name
4447 Server Response                    Description
4448 ================================== =================================
4450 UCHAR WordCount;                   Count of parameter words = 1
4451 USHORT Fid;                        File handle
4452 USHORT ByteCount;                  Count of data bytes;  min = 2
4453 UCHAR BufferFormat;                0x04
4454 STRING Filename[];                 File name
4458 Fid is the returned handle for future file access. Filename is the name
4459 of the file which was created within the requested Directory.   It is
4460 opened in compatibility mode with read/write access for the client.
4462 Support of CreationTime by the server is optional.
4466 Leach, Naik       expires September, 1997         [Page 70] \f
4469 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4472 4.2.4        READ_ANDX:  Read Bytes
4475  Large File Client Request        Description
4476  ================================ ===================================
4478  UCHAR WordCount;                 Count of parameter words = 10 or 12
4479  UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
4480  UCHAR AndXReserved;              Reserved (must be 0)
4481  USHORT AndXOffset;               Offset to next command WordCount
4482  USHORT Fid;                      File handle
4483  ULONG Offset;                    Offset in file to begin read
4484  USHORT MaxCount;                 Max number of bytes to return
4485  USHORT MinCount;                 Reserved
4486  ULONG Reserved;                  Must be 0
4487  USHORT Remaining;                Reserved
4488  ULONG OffsetHigh;                Upper 32 bits of offset (only if
4489                                    WordCount is 12)
4490  USHORT ByteCount;                Count of data bytes = 0
4494  Server Response                  Description
4495  ================================ ===================================
4497  UCHAR WordCount;                 Count of parameter words = 12
4498  UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
4499  UCHAR AndXReserved;              Reserved (must be 0)
4500  USHORT AndXOffset;               Offset to next command WordCount 
4501  USHORT Remaining;                Reserved -- must be -1
4502  USHORT DataCompactionMode;
4503  USHORT Reserved;                 Reserved (must be 0)
4504  USHORT DataLength;               Number of data bytes (min = 0)
4505  USHORT DataOffset;               Offset (from header start) to data
4506  USHORT Reserved[5];              Reserved (must be 0)
4507  USHORT ByteCount;                Count of data bytes
4508  UCHAR Pad[];
4509  UCHAR Data[ DataLength];         Data from resource
4513 If the negotiated dialect is NT LM 0.12 or later, the client may use the
4514 12 parameter word  version of the request.  This version allows
4515 specification of 64 bit file offsets.
4517 If CAP_LARGE_READX was indicated by the server in the negotiate protocol
4518 response, the request's MaxCount field may exceed the negotiated buffer
4519 size if Fid refers to a disk file.  The server may arbitrarily elect to
4520 return fewer than MaxCount bytes in response.
4522 The following SMBs may follow SMB_COM_READ_ANDX:
4523 SMB_COM_CLOSE
4526 4.2.4.1   Errors
4528 ERRDOS/ERRnoaccess
4529 ERRDOS/ERRbadfid
4532 Leach, Naik       expires September, 1997         [Page 71] \f
4535 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4538 ERRDOS/ERRlock
4539 ERRDOS/ERRbadaccess
4540 ERRSRV/ERRinvid
4541 ERRSRV/ERRbaduid
4544 4.2.5        WRITE_ANDX:  Write Bytes to file or resource
4547  Client Request                   Description
4548  ===============================  ====================================
4550  UCHAR WordCount;                 Count of parameter words = 12 or 14
4551  UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
4552  UCHAR AndXReserved;              Reserved (must be 0)
4553  USHORT AndXOffset;               Offset to next command WordCount
4554  USHORT Fid;                      File handle
4555  ULONG Offset;                    Offset in file to begin write
4556  ULONG Reserved;                  Must be 0
4557  USHORT WriteMode;                Write mode bits:
4558                                   0 - write through
4559  USHORT Remaining;                Bytes remaining to satisfy request
4560  USHORT Reserved;
4561  USHORT DataLength;               Number of data bytes in buffer (>=0)
4562  USHORT DataOffset;               Offset to data bytes
4563  ULONG OffsetHigh;                Upper 32 bits of offset (only
4564                                   present if WordCount = 14)
4565  USHORT ByteCount;                Count of data bytes
4566  UCHAR Pad[];                     Pad to SHORT or LONG
4567  UCHAR Data[DataLength];          Data to write
4571  Server Response                  Description
4572  ===============================  ====================================
4574  UCHAR WordCount;                 Count of parameter words = 6
4575  UCHAR AndXCommand;               Secondary (X) command;  0xFF = none
4576  UCHAR AndXReserved;              Reserved (must be 0)
4577  USHORT AndXOffset;               Offset to next command WordCount
4578  USHORT Count;                    Number of bytes written
4579  USHORT Remaining;                Reserved
4580  ULONG Reserved;
4581  USHORT ByteCount;                Count of data bytes = 0
4585 A ByteCount of 0 does not truncate the file.  Rather a zero length write
4586 merely transfers zero bytes of information to the file.  A request such
4587 as SMB_COM_WRITE must be used to truncate the file.
4589 If WriteMode has bit0 set in the request and Fid refers to a disk file,
4590 the response is not sent from the server until the data is on stable
4591 storage.
4593 If the negotiated dialect is NT LM 0.12 or later, the 14 word format of
4594 this SMB may be used to access portions of files requiring offsets
4598 Leach, Naik       expires September, 1997         [Page 72] \f
4601 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4604 expressed as 64 bits. Otherwise, the OffsetHigh field must be omitted
4605 from the request.
4607 The following are the valid AndXCommand values for this SMB:
4610    SMB_COM_READ          SMB_COM_READ_ANDX
4611    SMB_COM_LOCK_AND_READ SMB_COM_WRITE_ANDX
4612    SMB_COM_CLOSE
4614 4.2.5.1   Errors
4616 ERRDOS/ERRnoaccess
4617 ERRDOS/ERRbadfid
4618 ERRDOS/ERRlock
4619 ERRDOS/ERRbadaccess
4620 ERRSRV/ERRinvid
4621 ERRSRV/ERRbaduid
4624 4.2.6        LOCKING_ANDX:  Lock or Unlock Byte Ranges
4626 SMB_COM_LOCKING_ANDX allows both locking and/or unlocking of file range(s).
4629  Client Request                     Description
4630  ================================== =================================
4632  UCHAR WordCount;                   Count of parameter words = 8
4633  UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
4634                                      none
4635  UCHAR AndXReserved;                Reserved (must be 0)
4636  USHORT AndXOffset;                 Offset to next command WordCount
4637  USHORT Fid;                        File handle
4638  UCHAR LockType;                    See LockType table below
4639  UCHAR OplockLevel;                 The new oplock level
4640  ULONG Timeout;                     Milliseconds to wait for unlock
4641  USHORT NumberOfUnlocks;            Num. unlock range structs
4642                                      following
4643  USHORT NumberOfLocks;              Num. lock range structs following
4644  USHORT ByteCount;                  Count of data bytes
4645  LOCKING_ANDX_RANGE Unlocks[];      Unlock ranges
4646  LOCKING_ANDX_RANGE Locks[];        Lock ranges
4650  LockType Flag Name            Value Description
4651  ============================  ===== ================================
4653  LOCKING_ANDX_SHARED_LOCK      0x01  Read-only lock
4654  LOCKING_ANDX_OPLOCK_RELEASE   0x02  Oplock break notification
4655  LOCKING_ANDX_CHANGE_LOCKTYPE  0x04  Change lock type
4656  LOCKING_ANDX_CANCEL_LOCK      0x08  Cancel outstanding request
4657  LOCKING_ANDX_LARGE_FILES      0x10  Large file locking format
4664 Leach, Naik       expires September, 1997         [Page 73] \f
4667 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4671  LOCKING_ANDX_RANGE Format
4672  =====================================================================
4674  USHORT Pid;                        PID of process "owning" lock
4675  ULONG Offset;                      Offset to bytes to [un]lock
4676  ULONG Length;                      Number of bytes to [un]lock
4680  Large File LOCKING_ANDX_RANGE Format
4681  =====================================================================
4683  USHORT Pid;                        PID of process "owning" lock
4684  USHORT Pad;                        Pad to DWORD align (mbz)
4685  ULONG OffsetHigh;                  Offset to bytes to [un]lock
4686                                      (high)
4687  ULONG OffsetLow;                   Offset to bytes to [un]lock (low)
4688  ULONG LengthHigh;                  Number of bytes to [un]lock
4689                                      (high)
4690  ULONG LengthLow;                   Number of bytes to [un]lock (low)
4694  Server Response                    Description
4695  ================================== =================================
4697  UCHAR WordCount;                   Count of parameter words = 2
4698  UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
4699                                      none
4700  UCHAR AndXReserved;                Reserved (must be 0)
4701  USHORT AndXOffset;                 Offset to next command WordCount
4702  USHORT ByteCount;                  Count of data bytes = 0
4706 Locking is a simple mechanism for excluding other processes read/write
4707 access to regions of a file.  The locked regions can be anywhere in the
4708 logical file.  Locking beyond end-of-file is permitted.  Any process
4709 using the Fid specified in this request's Fid has access to the locked
4710 bytes, other processes will be denied the locking of the same bytes.
4712 The proper method for using locks is not to rely on being denied read or
4713 write access on any of the read/write protocols but rather to attempt
4714 the locking protocol and proceed with the read/write only if the locks
4715 succeeded.
4717 Locking a range of bytes will fail if any subranges or overlapping
4718 ranges are locked.  In other words, if any of the specified bytes are
4719 already locked, the lock will fail.
4721 If NumberOfUnlocks is non-zero, the Unlocks vector contains
4722 NumberOfUnlocks elements.  Each element requests that a lock at Offset
4723 of Length be released.  If NumberOfLocks is nonzero, the Locks vector
4724 contains NumberOfLocks elements.  Each element requests the acquisition
4725 of a lock at Offset of Length.
4727 Timeout is the maximum amount of time to wait for the byte range(s)
4728 specified to become unlocked.  A timeout value of 0 indicates that the
4729 server should fail immediately if any lock range specified is locked.  A
4732 Leach, Naik       expires September, 1997         [Page 74] \f
4735 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4738 timeout value of -1 indicates that the server should wait as long as it
4739 takes for each byte range specified to become unlocked so that it may be
4740 again locked by this protocol.  Any other value of smb_timeout specifies
4741 the maximum number of milliseconds to wait for all lock range(s)
4742 specified to become available.
4744 If any of the lock ranges timeout because of the area to be locked is
4745 already locked (or the lock fails), the other ranges in the protocol
4746 request which were successfully locked as a result of this protocol will
4747 be unlocked (either all requested ranges will be locked when this
4748 protocol returns to the client or none).
4750 If LockType has the LOCKING_ANDX_SHARED_LOCK flag set, the lock is
4751 specified as a shared lock.  Locks for both read and write (where
4752 LOCKING_ANDX_SHARED_LOCK is clear) should be prohibited, but other
4753 shared locks should be permitted.  If shared locks can not be supported
4754 by a server, the server should map the lock to a lock for both read and
4755 write.  Closing a file with locks still in force causes the locks to be
4756 released in no defined order.
4758 If LockType has the LOCKING_ANDX_LARGE_FILES flag set and if the
4759 negotiated protocol is NT LM 0.12 or later, then the Locks and Unlocks
4760 vectors are in the Large File LOCKING_ANDX_RANGE format.  This allows
4761 specification of 64 bit offsets for very large files.
4763 If the one and only member of the Locks vector has the
4764 LOCKING_ANDX_CANCEL_LOCK flag set in the LockType field, the client is
4765 requesting the server to cancel a previously requested, but not yet
4766 responded to, lock.
4768 If LockType has the LOCKING_ANDX_CHANGE_LOCKTYPE flag set, the client is
4769 requesting that the server atomically change the lock type from a shared
4770 lock to an exclusive lock or vice versa.  If the server can not do this
4771 in an atomic fashion, the server must reject this request.  NT and W95
4772 servers do not support this capability.
4774 Oplocks are described in the "Opportunistic Locks" section elsewhere in
4775 this document.  A client requests an oplock by setting the appropriate
4776 bit in the SMB_COM_OPEN_ANDX request when the file is being opened in a
4777 mode which is not exclusive.  The server responds by setting the
4778 appropriate bit in the response SMB indicating whether or not the oplock
4779 was granted.  By granting the oplock, the server tells the client the
4780 file is currently only being used by this one client process at the
4781 current time.  The client can therefore safely do read ahead and write
4782 behind as well as local caching of file locks knowing that the file will
4783 not be accessed/changed in any way by another process while the oplock
4784 is in effect.  The client will be notified when any other process
4785 attempts to open or modify the oplocked file.
4787 When another user attempts to open or otherwise modify the file which a
4788 client has oplocked, the server delays the second attempt and notifies
4789 the client via an SMB_LOCKING_ANDX SMB asynchronously sent from the
4790 server to the client.  This message has the LOCKING_ANDX_OPLOCK_RELEASE
4791 flag set indicating to the client that the oplock is being broken.
4793 Leach, Naik       expires September, 1997         [Page 75] \f
4796 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4799 OplockLevel indicates the type of oplock the client now owns. If
4800 OplockLevel is 0, the client possesses no oplocks on the file at all, if
4801 OplockLevel is 1 the client possesses a Level II oplock.  The client is
4802 expected to flush any dirty buffers to the server, submit any file locks
4803 and respond to the server with either an SMB_LOCKING_ANDX SMB having the
4804 LOCKING_ANDX_OPLOCK_RELEASE flag set, or with a file close if the file
4805 is no longer in use by the client.  If the client sends an
4806 SMB_LOCKING_ANDX SMB with the LOCKING_ANDX_OPLOCK_RELEASE flag set and
4807 NumberOfLocks is zero, the server does not send a response.  Since a
4808 close being sent to the server and break oplock notification from the
4809 server could cross on the wire, if the client gets an oplock
4810 notification on a file which it does not have open, that notification
4811 should be ignored.
4813 Due to timing, the client could get an "oplock broken" notification in a
4814 user's data buffer as a result of this notification crossing on the wire
4815 with a SMB_COM_READ_RAW request.  The client must detect this (use
4816 length of msg, "FFSMB", MID of -1 and Command of SMB_COM_LOCKING_ANDX)
4817 and honor the "oplock broken" notification as usual.  The server must
4818 also note on receipt of an SMB_COM_READ_RAW request that there is an
4819 outstanding (unanswered) "oplock broken" notification to the client and
4820 return a zero length response denoting failure of the read raw request.
4821 The client should (after responding to the "oplock broken"
4822 notification), use a standard read protocol to redo the read request.
4823 This allows a file to actually contain data matching an "oplock broken"
4824 notification and still be read correctly.
4826 The entire message sent and received including the optional second
4827 protocol must fit in the negotiated maximum transfer size.  The
4828 following are the only valid SMB commands for AndXCommand for
4829 SMB_COM_LOCKING_ANDX:
4832     SMB_COM_READ       SMB_COM_READ_ANDX
4833     SMB_COM_WRITE      SMB_COM_WRITE_ANDX
4834     SMB_COM_FLUSH
4836 4.2.6.1   Errors
4838 ERRDOS/ERRbadfile
4839 ERRDOS/ERRbadfid
4840 ERRDOS/ERRlock
4841 ERRDOS/ERRinvdevice
4842 ERRSRV/ERRinvid
4843 ERRSRV/ERRbaduid
4846 4.2.7        SEEK: Seek in File
4848 The seek message is sent to set the current file pointer for Fid.
4855 Leach, Naik       expires September, 1997         [Page 76] \f
4858 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4862 Client Request                     Description
4863 ================================== =================================
4865 UCHAR WordCount;                   Count of parameter words = 4
4866 USHORT Fid;                        File handle
4867 USHORT Mode;                       Seek mode:
4868                                     0 = from start of file
4869                                     1 = from current position
4870                                     2 = from end of file
4871 LONG Offset;                       Relative offset
4872 USHORT ByteCount;                  Count of data bytes = 0
4876  The starting point of the seek is set by Mode:
4878      0  seek from start of file
4879      1  seek from current file pointer
4880      2  seek from end of file
4883 The "current position" reflects the offset plus data length specified in
4884 the previous read, write or seek request, and the pointer set by this
4885 command will be replaced by the offset specified in the next read, write
4886 or seek command.
4889 Server Response                    Description
4890 ================================== =================================
4892  UCHAR WordCount;                  Count of parameter words = 2
4893  ULONG Offset;                     Offset from start of file
4894  USHORT ByteCount;                 Count of data bytes = 0
4898 The response returns the new file pointer in Offset which is expressed
4899 as the offset from the start of the file, and may be beyond the current
4900 end of file.  An attempt to seek to before the start of file sets the
4901 current file pointer to start of the file.
4903 This request should generally only be issued by clients wishing to find
4904 the size of a file, since all read and write requests include the read
4905 or write file position as part of the SMB.  This request is
4906 inappropriate for  very large files, as the offsets specified are only
4907 32 bits.  A seek which results in an Offset which can not be expressed
4908 in 32 bits returns the least significant.
4911 4.2.7.1   Errors
4913 ERRDOS/ERRbadfid
4914 ERRDOS/ERRnoaccess
4915 ERRSRV/ERRinvdevice
4916 ERRSRV/ERRinvid
4917 ERRSRV/ERRbaduid
4922 Leach, Naik       expires September, 1997         [Page 77] \f
4925 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4928 4.2.8        FLUSH: Flush File
4930 The flush SMB is sent to ensure all data and allocation information for
4931 the corresponding file has been written to stable storage.  When the Fid
4932 has a value -1 (hex FFFF) the server performs a flush for all file
4933 handles associated with the client and Pid.  The response is not sent
4934 until the writes are complete.
4937 Client Request                     Description
4938 ================================== =================================
4940 UCHAR WordCount;                   Count of parameter words = 1
4941 USHORT Fid;                        File handle
4942 USHORT ByteCount;                  Count of data bytes = 0
4946 This client request is probably expensive to perform at the server,
4947 since the server's operating system is generally scheduling disk writes
4948 is a way which is optimal for the system's read and write activity
4949 integrated over the entire population of clients.  This message from a
4950 client "interferes" with the server's ability to optimally schedule the
4951 disk activity; clients are discouraged from overuse of this SMB request.
4954 Server Response                    Description
4955 ================================== =================================
4957 UCHAR WordCount;                   Count of parameter words = 0
4958 USHORT ByteCount;                  Count of data bytes = 0
4961 4.2.8.1   Errors
4963 ERRDOS/ERRbadfid
4964 ERRSRV/ERRinvid
4965 ERRSRV/ERRbaduid
4968 4.2.9        CLOSE: Close File
4970 The close message is sent to invalidate a file handle for the requesting
4971 process.  All locks or other resources held by the requesting process on
4972 the file should be released by the server.  The requesting process can
4973 no longer use Fid for further file access requests.
4976 Client Request                     Description
4977 ================================== =================================
4979 UCHAR WordCount;                   Count of parameter words = 3
4980 USHORT Fid;                        File handle
4981 UTIME LastWriteTime                Time of last write
4982 USHORT ByteCount;                  Count of data bytes = 0
4986 If LastWriteTime is 0, the server should allow its local operating
4987 system to set the file's times.  Otherwise, the server should set the
4988 time to the values requested.  Failure to set the times, even if
4992 Leach, Naik       expires September, 1997         [Page 78] \f
4995 INTERNET-DRAFT            CIFS/1.0                  03/19/97
4998 requested by the client in the request message, should not result in an
4999 error response from the server.
5001 If Fid refers to a print spool file, the file should be spooled to the
5002 printer at this time.
5005 Server Response                    Description
5006 ================================== =================================
5008 UCHAR WordCount;                   Count of parameter words = 0
5009 USHORT ByteCount;                  Count of data bytes = 0
5012 4.2.9.1   Errors
5014 ERRDOS/ERRbadfid
5015 ERRSRV/ERRinvdevice
5016 ERRSRV/ERRinvid
5017 ERRSRV/ERRbaduid
5020 4.2.10     DELETE: Delete File
5022 The delete file message is sent to delete a data file.  The appropriate
5023 Tid and additional pathname are passed.  Read only files may not be
5024 deleted, the read-only attribute must be reset prior to file deletion.
5027 Client Request                     Description
5028 ================================== =================================
5030 UCHAR WordCount;                   Count of parameter words = 1
5031 USHORT SearchAttributes;
5032 USHORT ByteCount;                  Count of data bytes;    min = 2
5033 UCHAR BufferFormat;                0x04
5034 STRING FileName[];                 File name
5038 Multiple files may be deleted in response to a single request as
5039 SMB_COM_DELETE supports wildcards
5041 SearchAttributes indicates the attributes that the target file(s) must
5042 have.  If the attribute is zero then only normal files are deleted.  If
5043 the system file or hidden attributes are specified then the delete is
5044 inclusive -both the specified type(s) of files and normal files are
5045 deleted.  Attributes are described in the "Attribute Encoding" section
5046 of this document.
5048 If bit0 of the Flags2 field of the SMB header is set, a pattern is
5049 passed in, and the file has a long name, then the passed pattern  much
5050 match the long file name for the delete to succeed.  If bit0 is clear, a
5051 pattern is passed in, and the file has a long name, then the passed
5052 pattern must match the file's short name for the deletion to succeed.
5059 Leach, Naik       expires September, 1997         [Page 79] \f
5062 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5066 Server Response                    Description
5067 ================================== =================================
5069 UCHAR WordCount;                   Count of parameter words = 0
5070 USHORT ByteCount;                  Count of data bytes = 0
5073 4.2.10.1  Errors
5075 ERRDOS/ERRbadpath
5076 ERRDOS/ERRbadfile
5077 ERRDOS/ERRnoaccess
5078 ERRHRD/ERRnowrite
5079 ERRSRV/ERRaccess
5080 ERRSRV/ERRinvdevice
5081 ERRSRV/ERRinvid
5082 ERRSRV/ERRbaduid
5085 4.2.11    RENAME: Rename File
5087 The rename file message is sent to change the name of a file.
5090 Client Request                     Description
5091 ================================== =================================
5093 UCHAR WordCount;                   Count of parameter words = 1
5094 USHORT SearchAttributes;           Target file attributes
5095 USHORT ByteCount;                  Count of data bytes;    min = 4
5096 UCHAR BufferFormat1;               0x04
5097 STRING OldFileName[];              Old file name
5098 UCHAR BufferFormat2;               0x04
5099 STRING NewFileName[];              New file name
5103 Files OldFileName must exist and NewFileName must not.  Both pathnames
5104 must be relative to the Tid specified in the request.  Open files may be
5105 renamed.
5107 Multiple files may be renamed in response to a single request as Rename
5108 File supports wildcards in the file name (last component of the
5109 pathname).
5111 SearchAttributes indicates the attributes that the target file(s) must
5112 have.  If SearchAttributes is zero then only normal files are renamed.
5113 If the system file or hidden attributes are specified then the rename is
5114 inclusive -both the specified type(s) of files and normal files are
5115 renamed.  The encoding of SearchAttributes is described in section 3.10
5116 -  File Attribute Encoding.
5126 Leach, Naik       expires September, 1997         [Page 80] \f
5129 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5133 Server Response                    Description
5134 ================================== =================================
5136 UCHAR WordCount;                   Count of parameter words = 0
5137 USHORT ByteCount;                  Count of data bytes = 0
5140 4.2.11.1  Errors
5142 ERRDOS/ERRbadpath
5143 ERRDOS/ERRbadfile
5144 ERRDOS/ERRnoaccess
5145 ERRDOS/ERRdiffdevice
5146 ERRHRD/ERRnowrite
5147 ERRSRV/ERRaccess
5148 ERRSRV/ERRinvdevice
5149 ERRSRV/ERRinvid
5150 ERRSRV/ERRbaduid
5153 4.2.12    MOVE:  Rename File
5155 The source file is copied to the destination and the source is
5156 subsequently deleted.
5159  Client Request                     Description
5160  ================================== =================================
5162  UCHAR WordCount;                   Count of parameter words = 3
5163  USHORT Tid2;                       Second (target) file id
5164  USHORT OpenFunction;               what to do if target file exists
5165  USHORT Flags;                      Flags to control move operations:
5166                                      0 - target must be a file
5167                                      1 - target must be a directory
5168                                      2 - reserved (must be 0)
5169                                      3 - reserved (must be 0)
5170                                      4 - verify all writes
5171  USHORT ByteCount;                  Count of data bytes;    min = 2
5172  UCHAR Format1;                     0x04
5173  STRING OldFileName[];              Old file name
5174  UCHAR FormatNew;                   0x04
5175  STRING NewFileName[];              New file name
5179 OldFileName is copied to NewFileName, then OldFileName is deleted.  Both
5180 OldFileName and  NewFileName must refer to paths on the same server.
5181 NewFileName can refer to either a file or a directory.  All file
5182 components except the last must exist; directories will not be created.
5184 NewFileName can be required to be a file or a directory by the Flags
5185 field.
5187 The Tid in the header is associated with the source while Tid2 is
5188 associated with the destination.  These fields may contain the same or
5189 differing valid values. Tid2 can be set to -1 indicating that this is to
5193 Leach, Naik       expires September, 1997         [Page 81] \f
5196 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5199 be the same Tid as in the SMB header.  This allows use of the move
5200 protocol with SMB_TREE_CONNECT_ANDX.
5203  Server Response                    Description
5204  ================================== =================================
5206  UCHAR WordCount;                   Count of parameter words = 1
5207  USHORT Count;                      Number of files moved
5208  USHORT ByteCount;                  Count of data bytes;    min = 0
5209  UCHAR ErrorFileFormat;             0x04  (only if error)
5210  STRING ErrorFileName[];            Pathname of file where error
5211                                      occurred
5215 The source path must refer to an existing file or files.  Wildcards are
5216 permitted.  Source files specified by wildcards are processed until an
5217 error is encountered. If an error is encountered, the expanded name of
5218 the file is returned in ErrorFileName.  Wildcards are not permitted in
5219 NewFileName.
5221 OpenFunction controls what should happen if the destination file exists.
5222 If (OpenFunction & 0x30) == 0, the operation should fail if the
5223 destination exists.  If (OpenFunction & 0x30) == 0x20, the destination
5224 file should be overwritten.
5227 4.2.12.1  Errors
5229 ERRDOS/ERRfilexists
5230 ERRDOS/ERRbadfile
5231 ERRDOS/ERRnoaccess
5232 ERRDOS/ERRnofiles
5233 ERRDOS/ERRbadshare
5234 ERRHRD/ERRnowrite
5235 ERRSRV/ERRnoaccess
5236 ERRSRV/ERRinvdevice
5237 ERRSRV/ERRinvid
5238 ERRSRV/ERRbaduid
5239 ERRSRV/ERRnosupport
5240 ERRSRV/ERRaccess
5257 Leach, Naik       expires September, 1997         [Page 82] \f
5260 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5263 4.2.13    COPY: Copy File
5266  Client Request                     Description
5267  ================================== =================================
5269  UCHAR WordCount;                   Count of parameter words = 3
5270  USHORT Tid2;                       Second (target) path TID
5271  USHORT OpenFunction;               What to do if target file exists
5272  USHORT Flags;                      Flags to control copy operation:
5273                                      bit 0 - target must be a file
5274                                      bit 1 - target must be a dir.
5275                                      bit 2 - copy target mode:
5276                                      0 = binary, 1 = ASCII
5277                                      bit 3 - copy source mode:
5278                                      0 = binary, 1 = ASCII
5279                                      bit 4 - verify all writes
5280                                      bit 5 - tree copy
5281  USHORT ByteCount;                  Count of data bytes;    min = 2
5282  UCHAR SourceFileNameFormat;        0x04
5283  STRING SourceFileName;             Pathname of source file
5284  UCHAR TargetFileNameFormat;        0x04
5285  STRING TargetFileName;             Pathname of target file
5289 The file at SourceName is copied to TargetFileName, both of which must refer
5290 to paths on the same server.
5292 The Tid in the header is associated with the source while Tid2 is
5293 associated with the destination.  These fields may contain the same or
5294 differing valid values. Tid2 can be set to -1 indicating that this is to
5295 be the same Tid as in the SMB header.  This allows use of the move
5296 protocol with SMB_TREE_CONNECT_ANDX.
5299  Server Response                    Description
5300  ================================== =================================
5302  UCHAR WordCount;                   Count of parameter words = 1
5303  USHORT Count;                      Number of files copied
5304  USHORT ByteCount;                  Count of data bytes;    min = 0
5305  UCHAR ErrorFileFormat;             0x04 (only if error)
5306  STRING ErrorFileName;
5310 The source path must refer to an existing file or files.  Wildcards are
5311 permitted.  Source files specified by wildcards are processed until an
5312 error is encountered. If an error is encountered, the expanded name of
5313 the file is returned in ErrorFileName.  Wildcards are not permitted in
5314 TargetFileName.  TargetFileName can refer to either a file or a direc-
5315 tory.
5317 The destination can be required to be a file or a directory by the bits
5318 in Flags.  If neither bit0 nor bit1 are set, the destination may be
5319 either a file or a directory.  Flags also controls the copy mode.  In a
5320 binary copy for the source, the copy stops the first time an EOF
5321 (control-Z) is encountered. In a binary copy for the target, the server
5324 Leach, Naik       expires September, 1997         [Page 83] \f
5327 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5330 must make sure that there is exactly one EOF in the target file and that
5331 it is the last character of the file.
5333 If the destination is a file and the source contains wildcards, the
5334 destination file will either be truncated or appended to at the start of
5335 the operation depending on bits in OpenFunction (see section 3.7).
5336 Subsequent files will then be appended to the file.
5338 If the negotiated dialect is  LM1.2X002 or later, bit5 of Flags is used
5339 to specify a tree copy on the remote server.  When this option is
5340 selected the destination must not be an existing file and the source
5341 mode must be binary.  A request with bit5 set and either bit0 or bit3
5342 set is therefore an error.  When the tree copy mode is selected, the
5343 Count field in the server response is undefined.
5346 4.2.13.1  Errors
5348 ERRDOS/ERRfilexists
5349 ERRDOS/ERRshare
5350 ERRDOS/ERRnofids
5351 ERRDOS/ERRbadfile
5352 ERRDOS/ERRnoaccess
5353 ERRDOS/ERRnofiles
5354 ERRDOS/ERRbadshare
5355 ERRSRV/ERRnoaccess
5356 ERRSRV/ERRinvdevice
5357 ERRSRV/ERRinvid
5358 ERRSRV/ERRbaduid
5359 ERRSRV/ERRaccess
5362 4.2.14     TRANS2_QUERY_PATH_INFORMATION: Get File Attributes given
5363      Path
5365 This request is used to get information about a specific file or
5366 subdirectory.
5369  Client Request             Value
5370  ========================== =========================================
5372  WordCount                  15
5373  MaxSetupCount              0
5374  SetupCount                 1
5375  Setup[0]                   TRANS2_QUERY_PATH_INFORMATION
5379  Parameter Block Encoding   Description
5380  ========================== =========================================
5382  USHORT InformationLevel;   Level of information requested
5383  ULONG Reserved;            Must be zero
5384  STRING FileName;           File or directory name
5389 Leach, Naik       expires September, 1997         [Page 84] \f
5392 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5395 The following InformationLevels may be requested:
5398  Information Level                Value
5400  ================================ =====
5402  SMB_INFO_STANDARD                1
5403  SMB_INFO_QUERY_EA_SIZE           2
5404  SMB_INFO_QUERY_EAS_FROM_LIST     3
5405  SMB_INFO_QUERY_ALL_EAS           4
5406  SMB_INFO_IS_NAME_VALID           6
5407  SMB_QUERY_FILE_BASIC_INFO        0x101
5408  SMB_QUERY_FILE_STANDARD_INFO     0x102
5409  SMB_QUERY_FILE_EA_INFO           0x103
5410  SMB_QUERY_FILE_NAME_INFO         0x104
5411  SMB_QUERY_FILE_ALL_INFO          0x107
5412  SMB_QUERY_FILE_ALT_NAME_INFO     0x108
5413  SMB_QUERY_FILE_STREAM_INFO       0x109
5414  SMB_QUERY_FILE_COMPRESSION_INFO  0x10B
5418 The requested information is placed in the Data portion of the
5419 transaction response.  For the information levels greater than 0x100,
5420 the transaction response has 1 parameter word which should be ignored by
5421 the client.
5423 The following sections describe the InformationLevel dependent encoding
5424 of the data part of the transaction response.
5453 Leach, Naik       expires September, 1997         [Page 85] \f
5456 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5459 4.2.14.1  SMB_INFO_STANDARD & SMB_INFO_QUERY_EA_SIZE
5462  Data Block Encoding              Description
5463  ===============================  ====================================
5465  SMB_DATE CreationDate;           Date when file was created
5466  SMB_TIME CreationTime;           Time when file was created
5467  SMB_DATE LastAccessDate;         Date of last file access
5468  SMB_TIME LastAccessTime;         Time of last file access
5469  SMB_DATE LastWriteDate;          Date of last write to the file
5470  SMB_TIME LastWriteTime;          Time of last write to the file
5471  ULONG  DataSize;                 File Size
5472  ULONG AllocationSize;            Size of filesystem allocation unit
5473  USHORT Attributes;               File Attributes
5474  ULONG EaSize;                    Size of file's EA information
5475                                   (SMB_INFO_QUERY_EA_SIZE)
5478 4.2.14.2  SMB_INFO_QUERY_EAS_FROM_LIST & SMB_INFO_QUERY_ALL_EAS
5481  Response Field       Value
5482  ==================== ===============================================
5484  MaxDataCount         Length of EAlist found (minimum value is 4)
5486  Parameter Block      Description
5487  Encoding             ===============================================
5488  ====================
5490  USHORT EaErrorOffset Offset into EAList of EA error
5492  Data Block Encoding  Description
5493  ==================== ===============================================
5495  ULONG ListLength;    Length of the remaining data
5496  UCHAR EaList[]       The extended attributes list
5499 4.2.14.3  SMB_INFO_IS_NAME_VALID
5501 This requests checks to see if the name of the file contained in the
5502 request's Data field has a valid path syntax.  No parameters or data are
5503 returned on this information request. An error is returned if the syntax
5504 of the name is incorrect.  Success indicates the server accepts the path
5505 syntax, but it does not ensure the file or directory actually exists.
5508 4.2.14.4  SMB_QUERY_FILE_BASIC_INFO
5511  Data Block Encoding              Description
5512  ===============================  ====================================
5514  LARGE_INTEGER CreationTime;      Time when file was created
5515  LARGE_INTEGER LastAccessTime;    Time of last file access
5516  LARGE_INTEGER LastWriteTime;     Time of last write to the file
5517  LARGE_INTEGER ChangeTime         Time when file was last changed
5518  USHORT Attributes;               File Attributes
5526 Leach, Naik       expires September, 1997         [Page 86] \f
5529 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5532 4.2.14.5  SMB_QUERY_FILE_STANDARD_INFO
5535  Data Block Encoding              Description
5536  ===============================  ====================================
5538  LARGE_INTEGER AllocationSize     Allocated size of the file in number
5539                                   of bytes
5540  LARGE_INTEGER EndofFile;         Offset to the first free byte in the
5541                                   file
5542  ULONG NumberOfLinks              Number of hard links to the file
5543  BOOLEAN DeletePending            Indicates whether the file is marked
5544                                   for deletion
5545  BOOLEAN Directory                Indicates whether the file is a
5546                                   directory
5550 4.2.14.6  SMB_QUERY_FILE_EA_INFO
5553  Data Block Encoding              Description
5554  ===============================  ====================================
5556  ULONG EASize                     Size of the file’s extended
5557                                   attributes in number of bytes
5561 4.2.14.7  SMB_QUERY_FILE_NAME_INFO
5564  Data Block Encoding              Description
5565  ===============================  ====================================
5567  ULONG FileNameLength             Length of the file name in number of
5568                                   bytes
5569  STRING FileName                  Name of the file
5593 Leach, Naik       expires September, 1997         [Page 87] \f
5596 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5599 4.2.14.8  SMB_QUERY_FILE_ALL_INFO
5602  Data Block Encoding              Description
5603  ===============================  ====================================
5605  LARGE_INTEGER CreationTime;      Time when file was created
5606  LARGE_INTEGER LastAccessTime;    Time of last file access
5607  LARGE_INTEGER LastWriteTime;     Time of last write to the file
5608  LARGE_INTEGER ChangeTime         Time when file was last changed
5609  USHORT Attributes;               File Attributes
5610  LARGE_INTEGER AllocationSize     Allocated size of the file in number
5611                                   of bytes
5612  LARGE_INTEGER EndofFile;         Offset to the first free byte in the
5613                                   file
5614  ULONG NumberOfLinks              Number of hard links to the file
5615  BOOLEAN DeletePending            Indicates whether the file is marked
5616                                   for deletion
5617  BOOLEAN Directory                Indicates whether the file is a
5618                                   directory
5619  LARGE_INTEGER Index Number       A file system unique identifier
5620  ULONG EASize                     Size of the file’s extended
5621                                   attributes in number of bytes
5622  ULONG AccessFlags                Access that a caller has to the
5623                                   file; Possible values and meanings
5624                                   are specified below
5625  LARGE_INTEGER Index Number       A file system unique identifier
5626  LARGE_INTEGER CurrentByteOffset  Current byte offset within the file
5627  ULONG Mode                       Current Open mode of the file handle
5628                                   to the file; possible values and
5629                                   meanings are detailed below
5630  ULONG AlignmentRequirement       Buffer Alignment required by device;
5631                                   possible values detailed below
5632  ULONG FileNameLength             Length of the file name in number of
5633                                   bytes
5634  STRING FileName                  Name of the file
5639 The AccessFlags specifies the access permissions a caller has to the
5640 file and can have any suitable combination of the following values:
5656 Leach, Naik       expires September, 1997         [Page 88] \f
5659 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5663  Value                           Meaning
5665 ILE_READ_DATA        0x00000001 Data can be read from the file
5666 ILE_WRITE_DATA       0x00000002 Data can be written to the file
5667 ILE_APPEND_DATA      0x00000004 Data can be appended to the file
5668 ILE_READ_EA          0x00000008 Extended attributes associated
5669                                  with the file can be read
5670 ILE_WRITE_EA         0x00000010 Extended attributes associated
5671                                  with the file can be written
5672 ILE_EXECUTE          0x00000020 Data can be read into memory from
5673                                  the file using system paging I/O
5674 ILE_READ_ATTRIBUTES  0x00000080 Attributes associated with the
5675                                  file can be read
5676 ILE_WRITE_ATTRIBUTES 0x00000100 Attributes associated with the
5677                                  file can be written
5678 ELETE                0x00010000 The file can be deleted
5679 EAD_CONTROL          0x00020000 The access control list and
5680                                  ownership associated with the
5681                                  file can be read
5682 RITE_DAC             0x00040000 The access control list and
5683                                  ownership associated with the
5684                                  file can be written.
5685 RITE_OWNER           0x00080000 Ownership information associated
5686                                  with the file can be written
5687 YNCHRONIZE           0x00100000 The file handle can waited on to
5688                                  synchronize with the completion
5689                                  of an input/output request
5693 The Mode field specifies the mode in which the file is currently opened.
5694 The possible values may be a suitable and logical combination of the
5695 following:
5698 Value                                       Meaning
5700 FILE_WRITE_THROUGH           0x00000002     File is opened in mode
5701                                             where data is written to
5702                                             file before the driver
5703                                             completes a write request
5704 FILE_SEQUENTIAL_ONLY         0x00000004     All access to the file is
5705                                             sequential
5706 FILE_SYNCHRONOUS_IO_ALERT    0x00000010     All operations on the
5707                                             file are performed
5708                                             synchronously
5709 FILE_SYNCHRONOUS_IO_NONALER  0x00000020     All operations on the
5710 T                                           file are to be performed
5711                                             synchronously. Waits  in
5712                                             the system to synchronize
5713                                             I/O queuing and
5714                                             completion are not
5715                                             subject to alerts.
5722 Leach, Naik       expires September, 1997         [Page 89] \f
5725 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5728 The AlignmentRequirement field specifies buffer alignment required by
5729 the device and can have any one of the following values:
5732   Value                              Meaning
5734 FILE_BYTE_ALIGNMENT      0x00000000  The buffer needs to be aligned
5735                                      on a byte boundary
5736 FILE_WORD_ALIGNMENT      0x00000001  The buffer needs to be aligned
5737                                      on a word boundary
5738 FILE_LONG_ALIGNMENT      0x00000003  The buffer needs to be aligned
5739                                      on a 4 byte boundary
5740 FILE_QUAD_ALIGNMENT      0x00000007  The buffer needs to be aligned
5741                                      on an 8 byte boundary
5742 FILE_OCTA_ALIGNMENT      0x0000000f  The buffer needs to be aligned
5743                                      on a 16 byte boundary
5744 FILE_32_BYTE_ALIGNMENT   0x0000001f  The buffer needs to be aligned
5745                                      on a 32 byte boundary
5746 FILE_64_BYTE_ALIGNMENT   0x0000003f  The buffer needs to be aligned
5747                                      on a 64 byte boundary
5748 FILE_128_BYTE_ALIGNMENT  0x0000007f  The buffer needs to be aligned
5749                                      on a 128 byte boundary
5750 FILE_256_BYTE_ALIGNMENT  0x000000ff  The buffer needs to be aligned
5751                                      on a 256 byte boundary
5752 FILE_512_BYTE_ALIGNMENT  0x000001ff  The buffer needs to be aligned
5753                                      on a 512 byte boundary
5758 4.2.14.9  SMB_QUERY_FILE_ALT_NAME_INFO
5761  Data Block Encoding   Description
5762  ===================== =================================
5763  ===                   ===
5765  ULONG FileNameLength  Length of the file name in number
5766                         of bytes
5767  STRING FileName       Name of the file
5771 4.2.14.10 SMB_QUERY_FILE_STREAM_INFO
5774  Data Block Encoding              Description
5775  ===============================  ====================================
5777  ULONG NextEntryOffset            Offset to the next entry (in bytes)
5778  ULONG StreamNameLength           Length of the stream name in number
5779                                   of bytes
5780  LARGE_INTEGER StreamSize         Size of the stream in number of
5781                                   bytes
5782  LARGE_INTEGER                    Allocated size of the stream in
5783  StreamAllocationSize             number of bytes
5784  STRING FileName                  Name of the stream
5790 Leach, Naik       expires September, 1997         [Page 90] \f
5793 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5796 4.2.14.11 SMB_QUERY_FILE_COMPRESSION_INFO
5799  Data Block Encoding              Description
5800  ===============================  ====================================
5802  LARGE_INTEGER                    Size of the compressed file in
5803  CompressedFileSize               number of bytes
5804  USHORT CompressionFormat         A constant signifying the
5805                                   compression algorithm used
5806  UCHAR CompressionUnitShift       Size of the stream in number of
5807                                   bytes
5808  UCHAR ChunkShift                 Allocated size of the stream in
5809                                   number of bytes
5810  UCHAR ClusterShift               Allocated size of the stream in
5811                                   number of bytes
5812  UCHAR Reserved[3]                Name of the stream
5815 typedef struct {
5816     LARGE_INTEGER CompressedFileSize;
5817     USHORT CompressionFormat;
5818     UCHAR CompressionUnitShift;
5819     UCHAR ChunkShift;
5820     UCHAR ClusterShift;
5821     UCHAR Reserved[3];
5822 } FILE_COMPRESSION_INFORMATION;
5825 4.2.15     TRANS2_QUERY_FILE_INFORMATION: Get File Attributes Given FID
5827 This request is used to get information about a specific file or
5828 subdirectory given a handle to it.
5831  Client Request             Value
5832  ========================== ==========================================
5834  WordCount                  15
5835  MaxSetupCount              0
5836  SetupCount                 1
5837  Setup[0]                   TRANS2_QUERY_FILE_INFORMATION
5839  Parameter Block Encoding   Description
5840  ========================== ==========================================
5842  USHORT Fid;                Handle of file for request
5843  USHORT InformationLevel;   Level of information requested
5847 The available information levels, as well as the format of the response
5848 are identical to TRANS2_QUERY_PATH_INFORMATION.
5851 4.2.16     TRANS2_SET_PATH_INFORMATION: Set File Attributes given Path
5853 This request is used to set information about a specific file or
5854 subdirectory.
5858 Leach, Naik       expires September, 1997         [Page 91] \f
5861 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5865  Client Request             Value
5866  ========================== =========================================
5868  WordCount                  15
5869  MaxSetupCount              0
5870  SetupCount                 1
5871  Setup[0]                   TRANS2_SET_PATH_INFORMATION
5873  Parameter Block Encoding   Description
5874  ========================== =========================================
5876  USHORT InformationLevel;   Level of information to set
5877  ULONG Reserved;            Must be zero
5878  STRING FileName;           File or directory name
5882 The following InformationLevels may be set:
5885  Information Level           Value
5886  ==========================  =========================================
5888  SMB_INFO_STANDARD           1
5889  SMB_INFO_QUERY_EA_SIZE      2
5890  SMB_INFO_QUERY_ALL_EAS      4
5894 The response formats are:
5897 4.2.16.1  SMB_INFO_STANDARD & SMB_INFO_QUERY_EA_SIZE
5900  Parameter Block Encoding           Description
5901  ================================== =================================
5903  USHORT Reserved                    0
5905  Data Block Encoding                Description
5906  ================================== =================================
5908  SMB_DATE CreationDate;             Date when file was created
5909  SMB_TIME CreationTime;             Time when file was created
5910  SMB_DATE LastAccessDate;           Date of last file access
5911  SMB_TIME LastAccessTime;           Time of last file access
5912  SMB_DATE LastWriteDate;            Date of last write to the file
5913  SMB_TIME LastWriteTime;            Time of last write to the file
5914  ULONG  DataSize;                   File Size
5915  ULONG AllocationSize;              Size of filesystem allocation
5916                                      unit
5917  USHORT Attributes;                 File Attributes
5918  ULONG EaSize;                      Size of file's EA information
5919                                      (SMB_INFO_QUERY_EA_SIZE)
5931 Leach, Naik       expires September, 1997         [Page 92] \f
5934 INTERNET-DRAFT            CIFS/1.0                  03/19/97
5937 4.2.16.2  SMB_INFO_QUERY_ALL_EAS
5940  Response Field       Value
5941  ==================== ===============================================
5943  MaxDataCount         Length of FEAlist found (minimum value is 4)
5945  Parameter Block      Description
5946  Encoding             ===============================================
5947  ====================
5949  USHORT EaErrorOffset Offset into EAList of EA error
5951  Data Block Encoding  Description
5952  ==================== ===============================================
5954  ULONG ListLength;    Length of the remaining data
5955  UCHAR EaList[]       The extended attributes list
5960 4.2.17     TRANS2_SET_FILE_INFORMATION: Set File Attributes Given FID
5962 This request is used to set information about a specific file or
5963 subdirectory given a handle to the file or subdirectory.
5966  Client Request             Value
5967  ========================== ==========================================
5969  WordCount                  15
5970  MaxSetupCount              0
5971  SetupCount                 1
5972  Setup[0]                   TRANS2_SET_FILE_INFORMATION
5974  Parameter Block Encoding   Description
5975  ========================== ==========================================
5977  USHORT Fid;                Handle of file for request
5978  USHORT InformationLevel;   Level of information requested
5979  USHORT Reserved;           Ignored by the server
5983 The following InformationLevels may be set:
5986  Information Level                Value
5987  ================================ =====
5989  SMB_INFO_STANDARD                1
5990  SMB_INFO_QUERY_EA_SIZE           2
5991  SMB_SET_FILE_BASIC_INFO          0x101
5992  SMB_SET_FILE_DISPOSITION_INFO    0x102
5993  SMB_SET_FILE_ALLOCATION_INFO     0x103
5994  SMB_SET_FILE_END_OF_FILE_INFO    0x104
5998 The two levels below 0x101 are as described in the
5999 NT_SET_PATH_INFORMATION transaction.  The requested information is
6000 placed in the Data portion of the transaction response. For the
6001 information levels greater than 0x100, the transaction response has 1
6002 parameter word which should be ignored by the client.
6007 Leach, Naik       expires September, 1997         [Page 93] \f
6010 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6013 4.2.17.1  SMB_FILE_DISPOSITION_INFO
6016  Response Field       Value
6017  ==================== ===============================================
6019  BOOLEAN              A boolean which is TRUE if the file is marked
6020  FileIsDeleted        for deletion
6024 4.2.17.2  SMB_FILE_ALLOCATION_INFO
6027  Response Field       Value
6028  ==================== ===============================================
6030  LARGE_INTEGER        File Allocation size in number of bytes
6034 4.2.17.3  SMB_FILE_END_OF_FILE_INFO
6037  Response Field       Value
6038  ==================== ===============================================
6040  LARGE_INTEGER        The total number of bytes that need to be
6041                        traversed from the beginning of the file in
6042                        order to locate the end of the file
6048 4.3  Directory Requests
6051 4.3.1         TRANS2_CREATE_DIRECTORY: Create Directory (with optional EAs)
6053 This requests the server to create a directory relative to Tid in the
6054 SMB header, optionally assigning extended attributes to it.
6057  Client Request             Value
6058  ========================== =========================================
6060  WordCount                  15
6061  MaxSetupCount              0
6062  SetupCount                 1
6063  Setup[0]                   TRANS2_CREATE_DIRECTORY
6065  Parameter Block Encoding   Description
6066  ========================== =========================================
6068  ULONG Reserved;            Reserved--must be zero
6069  STRING Name[];             Directory name to create
6070  UCHAR Data[];              Optional FEAList for the new directory
6078 Leach, Naik       expires September, 1997         [Page 94] \f
6081 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6085  Response Parameter Block   Description
6086  ========================== =========================================
6088  USHORT EaErrorOffset       Offset into FEAList of first error which
6089                             occurred while setting EAs
6092 4.3.2        DELETE_DIRECTORY: Delete Directory
6094 The delete directory message is sent to delete an empty directory.  The
6095 appropriate Tid and additional pathname are passed.  The directory must
6096 be empty for it to be deleted.
6099 Client Request                     Description
6100 ================================== =================================
6102 UCHAR WordCount;                   Count of parameter words = 0
6103 USHORT ByteCount;                  Count of data bytes;    min = 2
6104 UCHAR BufferFormat;                0x04
6105 STRING DirectoryName[];            Directory name
6109 The directory to be deleted cannot be the root of the share specified by
6110 Tid.
6113 Server Response                    Description
6114 ================================== =================================
6116 UCHAR WordCount;                   Count of parameter words = 0
6117 USHORT ByteCount;                  Count of data bytes = 0
6120 4.3.3        CHECK_DIRECTORY: Check Directory
6122 This SMB is used to verify that a path exists and is a directory.  No
6123 error is returned if the given path exists and the client has read
6124 access to it.  Client machines which maintain a concept of a "working
6125 directory" will find this useful to verify the validity of a "change
6126 working directory" command.  Note that the servers do NOT have a concept
6127 of working directory for a particular client.  The client must always
6128 supply full pathnames relative to the Tid in the SMB header.
6131 Client Request                     Description
6132 ================================== =================================
6134 UCHAR WordCount;                   Count of parameter words = 0
6135 USHORT ByteCount;                  Count of data bytes;    min = 2
6136 UCHAR BufferFormat;                0x04
6137 STRING DirectoryPath[];            Directory path
6141 Server Response                    Description
6142 ================================== =================================
6144 UCHAR WordCount;                   Count of parameter words = 0
6145 USHORT ByteCount;                  Count of data bytes = 0
6149 DOS clients, in particular, depend on the SMB_ERR_BAD_PATH return code
6150 if the directory is not found.
6153 Leach, Naik       expires September, 1997         [Page 95] \f
6156 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6159 4.3.3.1   Errors
6161 ERRDOS/ERRbadfile
6162 ERRDOS/ERRbadpath
6163 ERRDOS/ERRnoaccess
6164 ERRHRD/ERRdata
6165 ERRSRV/ERRinvid
6166 ERRSRV/ERRbaduid
6167 ERRSRV/ERRaccess
6170 4.3.4        TRANS2_FIND_FIRST2: Search Directory using Wildcards
6173  Client Request                Value
6174  ============================  ==================================
6176  WordCount                     15
6177  TotalDataCount                Total size of extended attribute list
6178  SetupCount                    1
6179  Setup[0]                      TRANS2_FIND_FIRST2
6183  Parameter Block Encoding      Description
6184  ============================  ==================================
6185  ======
6187  USHORT SearchAttributes;
6188  USHORT SearchCount;           Maximum number of entries to return
6189  USHORT Flags;                 Additional information:
6190                                Bit 0 - close search after this request
6191                                Bit 1 - close search if end of search
6192                                reached
6193                                Bit 2 - return resume keys for each
6194                                entry found
6195                                Bit 3 - continue search from previous
6196                                ending place
6197                                Bit 4 - find with backup intent
6198  USHORT InformationLevel;      See below
6199  ULONG SearchStorageType;
6200  STRING FileName;              Pattern for the search
6201  UCHAR Data[ TotalDataCount ]  FEAList if InformationLevel is
6202                                QUERY_EAS_FROM_LIST
6218 Leach, Naik       expires September, 1997         [Page 96] \f
6221 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6225  Response Parameter Block      Description
6226  ============================  ==================================
6228  USHORT Sid;                   Search handle
6229  USHORT SearchCount;           Number of entries returned
6230  USHORT EndOfSearch;           Was last entry returned?
6231  USHORT EaErrorOffset;         Offset into EA list if EA error
6232  USHORT LastNameOffset;        Offset into data to file name of last
6233                                entry, if server needs it to resume
6234                                search; else 0
6235  UCHAR Data[ TotalDataCount ]  Level dependent info about the matches
6236                                found in the search
6240 This request allows the client to search for the file(s) which match the
6241 file specification.  The search can be continued if necessary with
6242 TRANS2_FIND_NEXT2. There are numerous levels of information which may be
6243 obtained for the returned files, the desired level is specified in the
6244 InformationLevel field of the request.
6247  InformationLevel Name              Value
6248  =================================  ================
6250  SMB_INFO_STANDARD                  1
6251  SMB_INFO_QUERY_EA_SIZE             2
6252  SMB_INFO_QUERY_EAS_FROM_LIST       3
6253  SMB_FIND_FILE_DIRECTORY_INFO       0x101
6254  SMB_FIND_FILE_FULL_DIRECTORY_INFO  0x102
6255  SMB_FIND_FILE_NAMES_INFO           0x103
6256  SMB_FIND_FILE_BOTH_DIRECTORY_INFO  0x104
6260 The following sections detail the data returned for each
6261 InformationLevel. The requested information is placed in the Data
6262 portion of the transaction response. Note: a client which does not
6263 support long names can only request SMB_INFO_STANDARD.
6265 A four-byte resume key precedes each data item (described below) if bit
6266 2 in the Flags field is set, i.e. if the request indicates the server
6267 should return resume keys.
6285 Leach, Naik       expires September, 1997         [Page 97] \f
6288 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6291 4.3.4.1   SMB_INFO_STANDARD
6294  Response Field                    Description
6295  ================================  ==================================
6297  SMB_DATE CreationDate;            Date when file was created
6298  SMB_TIME CreationTime;            Time when file was created
6299  SMB_DATE LastAccessDate;          Date of last file access
6300  SMB_TIME LastAccessTime;          Time of last file access
6301  SMB_DATE LastWriteDate;           Date of last write to the file
6302  SMB_TIME LastWriteTime;           Time of last write to the file
6303  ULONG  DataSize;                  File Size
6304  ULONG AllocationSize;             Size of filesystem allocation unit
6305  USHORT Attributes;                File Attributes
6306  UCHAR FileNameLength;             Length of filename in bytes
6307  STRING FileName;                  Name of found file
6310 4.3.4.2   SMB_INFO_QUERY_EA_SIZE
6313  Response Field                     Description
6314  =================================  ==================================
6316  SMB_DATE CreationDate;             Date when file was created
6317   SMB_TIME CreationTime;            Time when file was created
6318   SMB_DATE LastAccessDate;          Date of last file access
6319   SMB_TIME LastAccessTime;          Time of last file access
6320   SMB_DATE LastWriteDate;           Date of last write to the file
6321   SMB_TIME LastWriteTime;           Time of last write to the file
6322   ULONG DataSize;                   File Size
6323   ULONG AllocationSize;             Size of filesystem allocation unit
6324   USHORT Attributes;                File Attributes
6325   ULONG EaSize;                     Size of file's EA information
6326   UCHAR FileNameLength;             Length of filename in bytes
6327   STRING FileName;                  Name of found file
6330 4.3.4.3   SMB_INFO_QUERY_EAS_FROM_LIST
6332 This request returns the same information as SMB_INFO_QUERY_EA_SIZE, but
6333 only for files which have an EA list which match the EA information in
6334 the Data part of the request.
6352 Leach, Naik       expires September, 1997         [Page 98] \f
6355 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6358 4.3.4.4   SMB_FIND_FILE_DIRECTORY_INFO
6361  Response Field                     Description
6362  =================================  ==================================
6364  ULONG NextEntryOffset;             Offset from this structure to
6365                                     beginning of next one
6366  ULONG FileIndex;
6367  LARGE_INTEGER CreationTime;        file creation time
6368  LARGE_INTEGER LastAccessTime;      last access time
6369  LARGE_INTEGER LastWriteTime;       last write time
6370  LARGE_INTEGER ChangeTime;          last attribute change time
6371  LARGE_INTEGER EndOfFile;           file size
6372  LARGE_INTEGER AllocationSize;      size of filesystem allocation
6373                                     information
6374  ULONG ExtFileAttributes;           Extended file attributes (see
6375                                     section 3.11)
6376  ULONG FileNameLength;              Length of filename in bytes
6377  STRING FileName;                   Name of the file
6382 4.3.4.5   SMB_FIND_FILE_FULL_DIRECTORY_INFO
6385  Response Field                     Description
6386  =================================  ==================================
6388  ULONG NextEntryOffset;             Offset from this structure to
6389                                     beginning of next one
6390  ULONG FileIndex;
6391  LARGE_INTEGER CreationTime;        file creation time
6392  LARGE_INTEGER LastAccessTime;      last access time
6393  LARGE_INTEGER LastWriteTime;       last write time
6394  LARGE_INTEGER ChangeTime;          last attribute change time
6395  LARGE_INTEGER EndOfFile;           file size
6396  LARGE_INTEGER AllocationSize;      size of filesystem allocation
6397                                     information
6398  ULONG ExtFileAttributes;           Extended file attributes (see
6399                                     section 3.11)
6400  ULONG FileNameLength;              Length of filename in bytes
6401  ULONG EaSize;                      Size of file's extended attributes
6402  STRING FileName;                   Name of the file
6418 Leach, Naik       expires September, 1997         [Page 99] \f
6421 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6424 4.3.4.6   SMB_FIND_FILE_BOTH_DIRECTORY_INFO
6427  Response Field                     Description
6428  =================================  ==================================
6430  ULONG NextEntryOffset;             Offset from this structure to
6431                                     beginning of next one
6432  ULONG FileIndex;
6433  LARGE_INTEGER CreationTime;        file creation time
6434  LARGE_INTEGER LastAccessTime;      last access time
6435  LARGE_INTEGER LastWriteTime;       last write time
6436  LARGE_INTEGER ChangeTime;          last attribute change time
6437  LARGE_INTEGER EndOfFile;           file size
6438  LARGE_INTEGER AllocationSize;      size of filesystem allocation
6439                                     information
6440  ULONG ExtFileAttributes;           Extended file attributes (see
6441                                     section 3.11)
6442  ULONG FileNameLength;              Length of FileName in bytes
6443  ULONG EaSize;                      Size of file's extended attributes
6444  UCHAR ShortNameLength;             Length of file's short name in
6445                                     bytes
6446  UCHAR Reserved
6447  WCHAR ShortName[12];               File's 8.3 conformant name in
6448                                     Unicode
6449  STRING FileName;                   Files full length name
6454 4.3.4.7   SMB_FIND_FILE_NAMES_INFO
6457  Response Field                     Description
6458  =================================  ==================================
6460  ULONG NextEntryOffset;             Offset from this structure to
6461                                     beginning of next one
6462  ULONG FileIndex;
6463  ULONG FileNameLength;              Length of FileName in bytes
6464  STRING FileName;                   Files full length name
6484 Leach, Naik       expires September, 1997        [Page 100] \f
6487 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6490 4.3.5T       RANS2_FIND_NEXT2: Resume Directory Search Using Wildcards
6492 This request resumes a search which was begun with a previous
6493 TRANS2_FIND_FIRST2 request.
6496  Client Request                     Value
6497  ================================== =================================
6499  WordCount                          15
6500  SetupCount                         1
6501  Setup[0]                           TRANS2_FIND_NEXT2
6503  Parameter Block Encoding           Description
6504  ================================== =================================
6506  USHORT Sid;                        Search handle
6507  USHORT SearchCount;                Maximum number of entries to
6508                                      return
6509  USHORT InformationLevel;           Levels described in
6510                                      TRANS2_FIND_FIRST2 request
6511  ULONG ResumeKey;                   Value returned by previous find2
6512                                      call
6513  USHORT Flags;                      Additional information: bit set-
6514                                      0 - close search after this
6515                                      request
6516                                      1 - close search if end of search
6517                                      reached
6518                                      2 - return resume keys for each
6519                                      entry found
6520                                      3 - resume/continue from previous
6521                                      ending place
6522                                      4 - find with backup intent
6523  STRING FileName;                   Resume file name
6527 Sid is the value returned by a previous successful TRANS2_FIND_FIRST2
6528 call.  If Bit3 of Flags is set, then FileName may be the NULL string,
6529 since the search is continued from the previous TRANS2_FIND request.
6530 Otherwise, FileName must not be more than 256 characters long.
6533  Response Field                     Description
6534  ================================== =================================
6536  USHORT SearchCount;                Number of entries returned
6537  USHORT EndOfSearch;                Was last entry returned?
6538  USHORT EaErrorOffset;              Offset into EA list if EA error
6539  USHORT LastNameOffset;             Offset into data to file name of
6540                                      last entry, if server needs it to
6541                                      resume search; else 0
6542  UCHAR Data[TotalDataCount]         Level dependent info about the
6543                                      matches found in the search
6552 Leach, Naik       expires September, 1997        [Page 101] \f
6555 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6558 4.3.6        FIND_CLOSE2: Close Directory Search
6560 This SMB closes a search started by the TRANS2_FIND_FIRST2 transaction
6561 request.
6564 Client Request                     Description
6565 ================================== ==================================
6567 UCHAR WordCount;                   Count of parameter words = 1
6568 USHORT Sid;                        Find handle
6569 USHORT ByteCount;                  Count of data bytes = 0
6573 Server Response                    Description
6574 ================================== ==================================
6576 UCHAR WordCount;                   Count of parameter words = 0
6577  USHORT ByteCount;                 Count of data bytes = 0
6580 4.3.6.1   Errors
6582 ERRDOS/ERRbadfid
6583 ERRSRV/ERRinvid
6584 ERRSRV/ERRaccess
6587 4.3.7        NT_TRANSACT_NOTIFY_CHANGE: Request Change Notification
6590  Client Setup Words                 Description
6591  ================================== =================================
6593  ULONG CompletionFilter;            Specifies operation to monitor
6594  USHORT Fid;                        Fid of directory to monitor
6595  BOOLEAN WatchTree;                 TRUE = watch all subdirectories
6596                                      too
6597  UCHAR Reserved;                    MBZ
6601 This command notifies the client when the directory specified by Fid is
6602 modified.  It also returns the name(s) of the file(s) that changed.  The
6603 command completes once the directory has been modified based on the
6604 supplied CompletionFilter.  The command is a "single shot" and therefore
6605 needs to be reissued to watch for more directory changes.
6607 A directory file must be opened before this command may be used.  Once
6608 the directory is open, this command may be used to begin watching files
6609 and subdirectories in the specified directory for changes.  The first
6610 time the command is issued, the MaxParameterCount field in the transact
6611 header determines the size of the buffer that will be used at the server
6612 to buffer directory change information between issuances of the notify
6613 change commands.
6615 When a change that is in the CompletionFilter is made to the directory,
6616 the command completes.  The names of the files that have changed since
6617 the last time the command was issued are returned to the client.  The
6618 ParameterCount field of the response indicates the number of bytes that
6621 Leach, Naik       expires September, 1997        [Page 102] \f
6624 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6627 are being returned.  If too many files have changed since the last time
6628 the command was issued, then zero bytes are returned and an alternate
6629 status code is returned in the Status field of the response.
6631 The CompletionFilter is a mask created as the sum of any of the
6632 following flags:
6635 FILE_NOTIFY_CHANGE_FILE_NAME        0x00000001
6636 FILE_NOTIFY_CHANGE_DIR_NAME         0x00000002
6637 FILE_NOTIFY_CHANGE_NAME             0x00000003
6638 FILE_NOTIFY_CHANGE_ATTRIBUTES       0x00000004
6639 FILE_NOTIFY_CHANGE_SIZE             0x00000008
6640 FILE_NOTIFY_CHANGE_LAST_WRITE       0x00000010
6641 FILE_NOTIFY_CHANGE_LAST_ACCESS      0x00000020
6642 FILE_NOTIFY_CHANGE_CREATION         0x00000040
6643 FILE_NOTIFY_CHANGE_EA               0x00000080
6644 FILE_NOTIFY_CHANGE_SECURITY         0x00000100
6645 FILE_NOTIFY_CHANGE_STREAM_NAME      0x00000200
6646 FILE_NOTIFY_CHANGE_STREAM_SIZE      0x00000400
6647 FILE_NOTIFY_CHANGE_STREAM_WRITE     0x00000800
6651  Server Response                    Description
6652  ================================== ================================
6653                                      ==
6655  ParameterCount                     # of bytes of change data
6656  Parameters[ ParameterCount ]       FILE_NOTIFY_INFORMATION
6657                                      structures
6661 The response contains FILE_NOTIFY_INFORMATION structures, as defined
6662 below.  The NextEntryOffset field of the structure specifies the offset,
6663 in bytes, from the start of the current entry to the next entry in the
6664 list.  If this is the last entry in the list, this field is zero.  Each
6665 entry in the list must be longword aligned, so NextEntryOffset must be a
6666 multiple of four.
6669 typedef struct {
6670     ULONG NextEntryOffset;
6671     ULONG Action;
6672     ULONG FileNameLength;
6673     WCHAR FileName[1];
6674 } FILE_NOTIFY_INFORMATION;
6676 Where Action describes what happened to the file named FileName:
6687 Leach, Naik       expires September, 1997        [Page 103] \f
6690 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6694 FILE_ACTION_ADDED            0x00000001
6695 FILE_ACTION_REMOVED          0x00000002
6696 FILE_ACTION_MODIFIED         0x00000003
6697 FILE_ACTION_RENAMED_OLD_NAME 0x00000004
6698 FILE_ACTION_RENAMED_NEW_NAME 0x00000005
6699 FILE_ACTION_ADDED_STREAM     0x00000006
6700 FILE_ACTION_REMOVED_STREAM   0x00000007
6701 FILE_ACTION_MODIFIED_STREAM  0x00000008
6705 4.4  DFS Operations
6710 4.4.1        TRANS2_GET_DFS_REFERRAL: Retrieve Distributed Filesystem Referral
6712 The client sends this request to ask the server to convert
6713 RequestFilename into an alternate name for this file.  This request can
6714 be sent to the server if the server response to the NEGOTIATE SMB
6715 included the CAP_DFS capability.  The TID of the request must be IPC$.
6716 Bit15 of Flags2 in the SMB header must be set, indicating this is a
6717 UNICODE request.
6720 Client Request              Description
6721 ==========================  =========================================
6723 WordCount                   15
6724 TotalDataCount              0
6726 SetupCount                  1
6727 Setup[0]                    TRANS2_GET_DFS_REFERRAL
6731 Parameter Block Encoding    Description
6732 ==========================  =========================================
6734 USHORT MaxReferralLevel     Latest referral version number understood
6735 WCHAR RequestFileName;      DFS name of file for which referral is
6736                             sought
6753 Leach, Naik       expires September, 1997        [Page 104] \f
6756 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6760 Response Data Block         Description
6761 ==========================  =========================================
6763 USHORT PathConsumed;        Number of RequestFilename bytes client
6764 USHORT NumberOfReferrals;   Number of referrals contained in this
6765                             response
6766 USHORT Flags;               bit0 - The servers in Referrals are
6767                             capable of fielding
6768                             TRANS2_GET_DFS_REFERRAL.
6769                             bit1 - The servers in Referrals should
6770                             hold the storage for the requested file.
6771 REFERRAL_LIST Referrals[]   Set of referrals for this file
6773 UNICODESTRINGE Strings      Used to hold the strings pointed to by
6774                             Version 2 Referrals in REFERRALS.
6778 The server response is a list of Referrals which inform the client where
6779 it should resubmit the request to obtain access to the file.
6780 PathConsumed in the response indicates to the client how many characters
6781 of  RequestFilename have been consumed by the server.  When the client
6782 chooses one of the referrals to use for file access, the client may need
6783 to strip the leading PathConsumed characters from the front of
6784 RequestFileName before submitting the name to the target server.
6785 Whether or not the pathname should be trimmed is indicated by the
6786 individual referral as detailed below.
6788 Flags indicates how this referral should be treated.  If bit0 is clear,
6789 any entity in the Referrals list holds the storage for RequestFileName.
6790 If bit0 is set, any entity in the Referrals list has further referral
6791 information for RequestFilename â€“ a TRANS2_GET_DFS_REFERRAL request
6792 should be sent to an entity in the Referrals list for further
6793 resolution.
6795 The format of an individual referral contains version and  length
6796 information allowing the client to skip referrals it does not
6797 understand.  MaxReferralLevel indicates to the server the latest version
6798 of referral which the client can digest.  Since each referral has a
6799 uniform element, MaxReferralLevel is advisory only. Each element in
6800 Referrals has this envelope:
6803 REFERRAL_LIST element
6804 ======================================================================
6806 USHORT VersionNumber        Version of this referral element
6808 USHORT ReferralSize         Size of this referral element
6812 The following referral element versions are defined:
6822 Leach, Naik       expires September, 1997        [Page 105] \f
6825 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6829 Version 1 Referral Element Format
6830 ======================================================================
6832 USHORT ServerType           Type of Node handling referral:
6833                             0 - Don't know
6834                             1 - SMB Server
6835                             2 - Netware Server
6836                             3 - Domain
6838 USHORT ReferralFlags        Flags which describe this referral:
6839                             01 - Strip off PathConsumed characters
6840                             before submitting RequestFileName to Node
6842 UNICODESTRING Node          Name of entity to visit next
6846 Version 2 Referral Element Format
6847 ======================================================================
6849 USHORT ServerType              Type of Node handling referral:
6850                                 0 - Don't know
6851                                 1 - SMB Server
6852                                 2 - Netware Server
6853                                 3 - Domain
6855 USHORT ReferralFlags           Flags which describe this referral:
6856                                 01 - Strip off PathConsumed characters
6857                                 before submitting RequestFileName to
6858                                 Node
6860 ULONG Proximity                A hint describing the proximity of this
6861                                 server to the client. 0 indicates the
6862                                 closest, higher numbers indicate
6863                                 increasingly "distant" servers. The
6864                                 number is only relevant within the
6865                                 context of the servers listed in this
6866                                 particular SMB.
6868 ULONG TimeToLive               Number of seconds for which the client
6869                                 can cache this referral.
6871 USHORT DfsPathOffset           Offset, in bytes from the beginning of
6872                                 this referral, of  the DFS Path that
6873                                 matched PathConsumed bytes of the
6874                                 RequestFileName.
6876 USHORT DfsAlternatePathOffset  Offset, in bytes from the beginning of
6877                                 this referral, of an alternate name
6878                                 (8.3 format) of the DFS Path that
6879                                 matched PathConsumed bytes of the
6880                                 RequestFileName.
6882 USHORT NetworkAddressOffset    Offset, in bytes from the beginning of
6883                                 this referral, of the entity to visit
6884                                 next.
6888 The CIFS protocol imposes no referral selection policy.
6896 Leach, Naik       expires September, 1997        [Page 106] \f
6899 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6902 4.4.2        TRANS2_REPORT_DFS_INCONSISTENCY: Inform a server about DFS Error
6904 As part of the Distributed Name Resolution algorithm, a DFS client may
6905 discover a  knowledge inconsistency between the referral server (i.e.,
6906 the server that handed out a referral), and the storage server (i.e.,
6907 the server to which the client was redirected to by the referral
6908 server). When such an inconsistency is discovered, the DFS client
6909 optionally sends this SMB to the referral server, allowing the referral
6910 server to take corrective action.
6913 Client Request                     Description
6914 ================================== ==================================
6916 WordCount                          15
6917 MaxParameterCount                  0
6918 SetupCount                         1
6919 Setup[0]                           TRANS2_REPORT_DFS_INCONSISTENCY
6923 Parameter Block Encoding           Description
6924 ================================== ==================================
6926 UNICODESTRING RequestFileName;     DFS Name of file for which
6927                                     referral was sought
6931 The data part of this request contains the referral element (Version 1
6932 format only) believed to be in error.  These are encoded as described in
6933 the TRANS2_GET_DFS_REFERRAL response.  If the server returns success,
6934 the client can resubmit the TRANS2_GET_DFS_REFERRAL request to this
6935 server to get a new referral.  It is not mandatory for the DFS knowledge
6936 to be automatically repaired â€“ the client must be prepared to receive
6937 further errant referrals and must not wind up looping between this
6938 request and the TRANS2_GET_DFS_REFERRAL request.
6940 Bit15 of Flags2 in the SMB header must be set, indicating this is a
6941 UNICODE request.
6944 4.5  Print Spooling Operations
6947 4.5.1        OPEN_PRINT_FILE: Create Print Spool file
6949 This message is sent to create a new printer file which will be deleted
6950 once it has been closed and printed.
6962 Leach, Naik       expires September, 1997        [Page 107] \f
6965 INTERNET-DRAFT            CIFS/1.0                  03/19/97
6969 Client Request                     Description
6970 ================================== =================================
6972 UCHAR WordCount;                   Count of parameter words = 2
6973 USHORT SetupLength;                Length of printer setup data
6974 USHORT Mode;                       0 = Text mode (DOS expands TABs)
6975                                     1 = Graphics mode
6976 USHORT ByteCount;                  Count of data bytes;  min = 2
6977 UCHAR BufferFormat;                0x04
6978 STRING IdentifierString[];         Identifier string
6982 Tid in the SMB header must refer to a printer resource type.
6984 SetupLength is the number of bytes in the first part of the resulting
6985 print spool file which contains printer-specific control strings.
6987 Mode can have the following values:
6990      0     Text mode.  The server may optionally
6991            expand tabs to a series of spaces.
6992      1     Graphics mode.  No conversion of data
6993            should be done by the server.
6996 IdentifierString can be used by the server to provide some sort of per-
6997 client identifying component to the print file.
7000 Server Response                    Description
7001 ================================== =================================
7003 UCHAR WordCount;                   Count of parameter words = 1
7004 USHORT Fid;                        File handle
7005 USHORT ByteCount;                  Count of data bytes = 0
7009 Fid is the returned handle which may be used by subsequent write and
7010 close operations.  When the file is finally closed, it will be sent to
7011 the spooler and printed.
7014 4.5.1.1   Errors
7016 ERRDOS/ERRnoaccess
7017 ERRDOS/ERRnofids
7018 ERRSRV/ERRinvdevice
7019 ERRSRV/ERRbaduid
7020 ERRSRV/ERRqfull
7021 ERRSRV/ERRqtoobig
7024 4.5.2        GET_PRINT_QUEUE: Get Printer Queue Entries
7026 This message obtains a list of the elements currently in the print queue
7027 on the server.
7030 Leach, Naik       expires September, 1997        [Page 108] \f
7033 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7037   Client Request                     Description
7038   ================================== =================================
7040   UCHAR WordCount;                   Count of parameter words = 2
7041   USHORT MaxCount;                   Max number of entries to return
7042   USHORT StartIndex;                 First queue entry to return
7043   USHORT ByteCount;                  Count of data bytes = 0
7047 StartIndex specifies the first entry in the queue to return.
7049 MaxCount specifies the maximum number of entries to return, this may be
7050 a positive or negative number.  A positive number requests a forward
7051 search, a negative number indicates a backward search.
7054   Server Response                    Description
7055   ================================== =================================
7057   UCHAR WordCount;                   Count of parameter words = 2
7058   USHORT Count;                      Number of entries returned
7059   USHORT RestartIndex;               Index of entry after last
7060                                       returned
7061   USHORT ByteCount;                  Count of data bytes;  min = 3
7062   UCHAR BufferFormat;                0x01 -- Data block
7063   USHORT DataLength;                 Length of data
7064   UCHAR Data[];                      Queue elements
7068 Count indicates how many entries were actually returned.  RestartIndex
7069 is the index of the entry following the last entry returned; it may be
7070 used as the StartIndex in a subsequent request to resume the queue
7071 listing.
7073 The format of each returned queue element is:
7076   Queue Element Member             Description
7077   ================================ ===================================
7079   SMB_DATE FileDate;               Date file was queued
7080   SMB_TIME FileTime;               Time file was queued
7081   UCHAR Status;                    Entry status.  One of:
7082                                     01 = held or stopped
7083                                     02 = printing
7084                                     03 = awaiting print
7085                                     04 = in intercept
7086                                     05 = file had error
7087                                     06 = printer error
7088                                     07-FF = reserved
7089   USHORT SpoolFileNumber;          Assigned by the spooler
7090   ULONG SpoolFileSize;             Number of bytes in spool file
7091   UCHAR Reserved;
7092   UCHAR SpoolFileName[16];         Client which created the spool file
7096 SMB_COM_GET_PRINT_QUEUE will return less than the requested number of
7097 elements only when the top or end of the queue is encountered.
7100 Leach, Naik       expires September, 1997        [Page 109] \f
7103 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7106 Support for this SMB is server optional.  In particular, no current
7107 Microsoft client software issues this request.
7110 4.5.2.1   Errors
7112 ERRHRD/ERRnotready
7113 ERRHRD/ERRerror
7114 ERRSRV/ERRbaduid
7117 4.6  Miscellaneous Operations
7120 4.6.1        NT_TRANSACT_IOCTL
7123 This command allows device and file system control functions to be
7124 transferred transparently from client to server.
7127   Setup Words Encoding        Description
7128   =========================== =========================================
7130   ULONG FunctionCode;         NT device or file system control code
7131   USHORT Fid;                 Handle for io or fs control.  Unless BIT0
7132                                of ISFLAGS is set.
7133   BOOLEAN IsFsctl;            Indicates whether the command is a device
7134                                control (FALSE) or a file system control
7135                                (TRUE).
7136   UCHAR   IsFlags;            BIT0 - command is to be applied to share
7137                                root handle.  Share must be a DFS share.
7141   Data Block Encoding         Description
7142   =========================== =========================================
7144   Data[ TotalDataCount ]      Passed to the Fsctl or Ioctl
7148   Server Response                    Description
7149   ================================== ==================================
7151   SetupCount                         1
7152   Setup[0]                           Length of information returned by
7153                                       io or fs control
7154   DataCount                          Length of information returned by
7155                                       io or fs control
7156   Data[ DataCount ]                  The results of the io or fs
7157                                       control
7160 4.6.2        NT_TRANSACT_QUERY_SECURITY_DESC
7162 This command allows the client to retrieve the security descriptor on a
7163 file.
7169 Leach, Naik       expires September, 1997        [Page 110] \f
7172 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7176   Client Parameter Block             Description
7177   ================================== =================================
7179   USHORT Fid;                        FID of target
7180   USHORT Reserved;                   MBZ
7181   ULONG SecurityInformation;         Fields of descriptor to set
7185 NtQuerySecurityObject() is called, requesting SecurityInformation.  The
7186 result of the call is returned to the client in the Data part of the
7187 transaction response.
7190 4.6.3        NT_TRANSACT_SET_SECURITY_DESC
7192 This command allows the client to change the security descriptor on a
7193 file.
7196   Client Parameter Block Encoding    Description
7197   ================================== ==================================
7199   USHORT Fid;                        FID of target
7200   USHORT Reserved;                   MBZ
7201   ULONG SecurityInformation;         Fields of SD that to set
7205   Data Block Encoding                Description
7206   ================================== ==================================
7208   Data[TotalDataCount]               Security Descriptor information
7212 Data is passed directly to NtSetSecurityObject(), with
7213 SecurityInformation describing which information to set.  The
7214 transaction response contains no parameters or data.
7217 5   Obsolescent SMB Requests
7219 This section lists the "obsolescent" SMB requests -- ones that are
7220 superseded by "best practice" requests, either in function or
7221 performance. Clients need not use them to get full function or
7222 performance, however, servers do need to support them in order to
7223 interoperate with existing clients.
7226 5.1  CLOSE_PRINT_FILE:  Close and Spool Print Job
7228 This message invalidates the specified file handle and queues the file
7229 for printing.
7232   Client Request                     Description
7233   ================================== =================================
7235   UCHAR WordCount;                   Count of parameter words = 1
7236   USHORT Fid;                        File handle
7237   USHORT ByteCount;                  Count of data bytes = 0
7241 Leach, Naik       expires September, 1997        [Page 111] \f
7244 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7247 Fid refers to a file previously created with SMB_COM_OPEN_PRINT_FILE.
7248 On successful completion of this request, the file is queued for
7249 printing by the server.
7252   Server Response                    Description
7253   ================================== =================================
7255   UCHAR WordCount;                   Count of parameter words = 0
7256   USHORT ByteCount;                  Count of data bytes = 0
7260 Servers which negotiate dialects of LANMAN1.0 and newer allow all the
7261 other types of Fid closing requests to invalidate the Fid and begin
7262 spooling.
7265 5.2  CREATE: Create File
7267 This message is sent to create a new data file or truncate an existing
7268 data file to length zero, and open the file.  The handle returned can be
7269 used in subsequent read, write, lock, unlock and close messages.
7272   Client Request                     Description
7273   ================================== =================================
7275   UCHAR WordCount;                   Count of parameter words = 3
7276   USHORT FileAttributes;             New file attributes
7277   UTIME CreationTime;                Time file was created
7278   USHORT ByteCount;                  Count of data bytes;    min = 2
7279   UCHAR BufferFormat;                0x04
7280   STRING FileName[];                 File name
7284 FileName is the fully qualified name of the file relative to Tid.
7286 FileAttributes are encoded as described in "File Attribute Encoding",
7287 section 3.10.
7289 Server support of the CreationTime field is optional.  Encoding of these
7290 fields is discussed in the "Time And Date Encoding" section.
7293   Server Response                    Description
7294   ================================== =================================
7296   UCHAR WordCount;                   Count of parameter words = 1
7297   USHORT Fid;                        File handle
7298   USHORT ByteCount;                  Count of data bytes = 0
7302 Clients must have write permission on the file's parent directory in
7303 order to create a new file, or write permission on the file itself in
7304 order to truncate it.  The access permissions granted on a created file
7305 will be read/write permission for the creator.  Access permissions for
7306 truncated files are not modified.  The newly created  or  truncated file
7307 is opened in read/write/compatibility mode.
7311 Leach, Naik       expires September, 1997        [Page 112] \f
7314 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7317 5.3  CREATE_DIRECTORY: Create Directory
7319 The create directory message is sent to create a new directory.  The
7320 appropriate Tid and additional pathname are passed.  The directory must
7321 not exist for it to be created.
7324 Client Request                     Description
7325 ================================== =================================
7327 UCHAR WordCount;                   Count of parameter words = 0
7328 USHORT ByteCount;                  Count of data bytes;    min = 2
7329 UCHAR BufferFormat;                0x04
7330 STRING DirectoryName[];            Directory name
7334 Servers require clients to have at least create permission for the
7335 subtree containing the directory in order to create a new directory.
7336 The creator's access rights to the new directory are be determined by
7337 local policy on the server.
7340 Server Response                    Description
7341 ================================== =================================
7344 UCHAR WordCount;                   Count of parameter words = 0
7346 USHORT ByteCount;                  Count of data bytes = 0
7352 5.4  CREATE_NEW: Create File
7354 This message is sent to create a new data file or truncate an existing
7355 data file to length zero, and open the file.
7358 Client Request                     Description
7359 ================================== =================================
7361 UCHAR WordCount;                   Count of parameter words = 3
7362 USHORT FileAttributes;             New file attributes
7363 UTIME CreationTime;                Creation time for created file
7364 USHORT ByteCount;                  Count of data bytes;  min = 2
7365 UCHAR BufferFormat;                0x04
7366 STRING FileName[];                 File name
7370 FileAttributes specify the attributes of the newly created file, their
7371 encoding is described in the "Attribute Encoding" section of this
7372 document.
7374 CreationTime is  the creation timestamp the file should be given, server
7375 support for these is optional.
7381 Leach, Naik       expires September, 1997        [Page 113] \f
7384 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7388 Server Response                    Description
7389 ================================== =================================
7391 UCHAR WordCount;                   Count of parameter words = 1
7392 USHORT Fid;                        File handle
7393 USHORT ByteCount;                  Count of data bytes = 0
7397 The returned Fid can be used in subsequent Fid-related messages.
7399 The access permissions granted on a created file are read/write
7400 permission for the creator.  Access permissions for truncated files are
7401 not modified.  The newly created or truncated file is opened in
7402 read/write/compatibility mode.
7405 5.5  LOCK_AND_READ: Lock and Read Bytes
7407 This  request is used to lock and "read ahead" the specified bytes of
7408 the file indicated by Fid in the SMB header
7411 Client Request                 Description
7412 ============================== =====================================
7414 UCHAR WordCount;               Count of parameter words = 5
7415 USHORT Fid;                    File handle
7416 USHORT Count;                  Count of bytes being requested
7417 ULONG Offset;                  Offset in file of first byte to read
7418 USHORT Remaining;              Estimate of bytes to read if nonzero
7419 USHORT ByteCount;              Count of data bytes = 0
7423 Fid must refer to a disk file.  Count specifies the requested number of
7424 bytes.  Offset specifies the offset in the file of the first byte to be
7425 locked then read.  Note that this offset is limited to 32 bits, so this
7426 client request is inappropriate for files having 64 bit offsets.
7428 Remaining is advisory.  If the value is not zero, then it is taken as an
7429 estimate of the total number of bytes that will be read, including those
7430 read by this request.  This additional information may be used by the
7431 server to optimize buffer allocation or read-ahead.  Remaining is not
7432 included in the byte range to be locked.
7435 Server Response                    Description
7436 ================================== =================================
7438 UCHAR WordCount;                   Count of parameter words = 5
7439 USHORT Count;                      Count of bytes actually returned
7440 USHORT Reserved [4];               Reserved (must be 0)
7441 USHORT ByteCount;                  Count of data bytes
7442 UCHAR BufferFormat;                0x01 -- Data block
7443 USHORT DataLength;                 Length of data
7447 ByteCount is the number of bytes actually being returned. ByteCount may
7448 be less than the count requested only if a read specifies bytes beyond
7451 Leach, Naik       expires September, 1997        [Page 114] \f
7454 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7457 the current file size.  In this case only the bytes that exist are
7458 returned.  A read completely beyond the end of file results in a
7459 response of length zero.  This is the only circumstance when a zero
7460 length response is generated.  A count returned which is less than the
7461 count requested is the end of file indicator.
7463 As in the core SMB_LOCK_BYTE_RANGE request,  if the lock can not be
7464 immediately granted an error should be returned to the client.  If an
7465 error occurs on the lock, the bytes should not be read.  If a Read
7466 requests more data than can be placed in a message of the maximum-xmit-
7467 size for the Tid specified, the server will abort the connection to the
7468 client.
7471 5.6  LOCK_BYTE_RANGE: Lock Bytes
7473 The lock record message is sent to lock the given byte range.  More than
7474 one non-overlapping byte range may be locked in a given file.  Locks
7475 prevent attempts to lock, read or write the locked portion of the file
7476 by other clients or Pids.  Overlapping locks are not allowed. Offsets
7477 beyond the current end of file may be locked.  Such locks will not cause
7478 allocation of file space.
7480 Since Offset is a 32 bit quantity, this request is inappropriate for
7481 general locking within a very large file.
7484 Client Request                     Description
7485 ================================== =================================
7487 UCHAR WordCount;                   Count of parameter words = 5
7488 USHORT Fid;                        File handle
7489 ULONG Count;                       Count of bytes to lock
7490 ULONG Offset;                      Offset from start of file
7491 USHORT ByteCount;                  Count of data bytes = 0
7495 Locks may only be unlocked by the Pid that performed the lock.
7498 Server Response                    Description
7499 ================================== =================================
7501 UCHAR WordCount;                   Count of parameter words = 0
7502 USHORT ByteCount;                  Count of data bytes = 0
7506 This client request does not wait for the lock to be granted.  If the
7507 lock can not be immediately granted (within 200-300 ms), the server
7508 should return failure to the client
7518 Leach, Naik       expires September, 1997        [Page 115] \f
7521 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7524 5.7  OPEN: Open File
7526 This message is sent to obtain a file handle for a data file.  This
7527 returned Fid is used in subsequent client requests such as read, write,
7528 close, etc.
7531 Client Request                     Description
7532 ================================== =================================
7534 UCHAR WordCount;                   Count of parameter words = 2
7535 USHORT DesiredAccess;              Mode - read/write/share
7536 USHORT SearchAttributes;
7537 USHORT ByteCount;                  Count of data bytes;    min = 2
7538 UCHAR BufferFormat;                0x04
7539 STRING FileName[];                 File name
7543 FileName is the fully qualified file name, relative to the root of the
7544 share specified in the Tid field of the SMB header.  If Tid in the SMB
7545 header refers to a print share, this SMB creates a new file which will
7546 be spooled to the printer when closed.  In this case, FileName is
7547 ignored.
7549 SearchAttributes specifies the type of file desired.  The encoding is
7550 described in the "File Attribute Encoding" section.
7552 DesiredAccess controls the mode under which the file is opened, and the
7553 file will be opened only if the client has the appropriate permissions.
7554 The encoding of DesiredAccess is discussed in the section entitled
7555 "Access Mode Encoding".
7558 Server Response                    Description
7559 ================================== =================================
7561 UCHAR WordCount;                   Count of parameter words = 7
7562 USHORT Fid;                        File handle
7563 USHORT FileAttributes;             Attributes of opened file
7564 UTIME LastWriteTime;               Time file was last written
7565 ULONG DataSize;                    File size
7566 USHORT GrantedAccess;              Access allowed
7567 USHORT ByteCount;                  Count of data bytes = 0
7571 Fid is the handle value which should be used for subsequent file
7572 operations.
7574 FileAttributes specifies the type of file obtained.  The encoding is
7575 described in the "File Attribute Encoding" section.
7577 GrantedAccess indicates the access permissions actually allowed, and may
7578 have one of the following values:
7585 Leach, Naik       expires September, 1997        [Page 116] \f
7588 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7592    0  read-only
7593    1  write-only
7594    2 read/write
7596 File Handles (Fids) are scoped per client.  A Pid may reference any Fid
7597 established by itself or any other Pid on the client (so far as the
7598 server is concerned).  The actual accesses allowed through the Fid
7599 depends on the open and deny modes specified when the file was opened
7600 (see below).
7602 The MS-DOS compatibility mode of file open provides exclusion at the
7603 client level.  A file open in compatibility mode may be opened (also in
7604 compatibility mode) any number of times for any combination of reading
7605 and writing (subject to the user's permissions) by any Pid on the same
7606 client.  If the first client has the file open for writing, then the
7607 file may not be opened in any way by any other client.  If the first
7608 client has the file open only for reading, then other clients may open
7609 the file, in compatibility mode, for reading..  The above
7610 notwithstanding, if the filename has an extension of .EXE, .DLL, .SYM,
7611 or .COM other clients are permitted to open the file regardless of
7612 read/write open modes of other compatibility mode opens.  However, once
7613 multiple clients have the file open for reading, no client is permitted
7614 to open the file for writing and no other client may open the file in
7615 any mode other than compatibility mode.
7617 The other file exclusion modes (Deny read/write, Deny write, Deny read,
7618 Deny none) provide exclusion at the file level.  A file opened in any
7619 "Deny" mode may be opened again only for the accesses allowed by the
7620 Deny mode (subject to the user's permissions).  This is true regardless
7621 of the identity of the second opener -a different client, a Pid from the
7622 same client, or the Pid that already has the file open.  For example, if
7623 a file is open in "Deny write" mode a second open may only obtain read
7624 permission to the file.
7626 Although Fids are available to all Pids on a client, Pids other than the
7627 owner may not have the full access rights specified in the open mode by
7628 the Fid's creator.  If the open creating the Fid specified a deny mode,
7629 then any Pid using the Fid, other than the creating Pid, will have only
7630 those access rights determined by "anding" the open mode rights and the
7631 deny mode rights, i.e., the deny mode is checked on all file accesses.
7632 For example, if a file is opened for Read/Write in Deny write mode, then
7633 other clients may only read the file and cannot write; if a file is
7634 opened for Read in Deny read mode, then the other clients can neither
7635 read nor write the file.
7647 Leach, Naik       expires September, 1997        [Page 117] \f
7650 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7653 5.8  OPEN_ANDX:  Open File
7656  Client Request                     Description
7657  ================================== =================================
7659  UCHAR WordCount;                   Count of parameter words = 15
7660  UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
7661                                      none
7662  UCHAR AndXReserved;                Reserved (must be 0)
7663  USHORT AndXOffset;                 Offset to next command WordCount
7664  USHORT Flags;                      Additional information: bit set-
7665                                      0 - return additional info
7666                                      1 - exclusive oplock requested
7667                                      2 - batch oplock requested
7668  USHORT DesiredAccess;              File open mode
7669  USHORT SearchAttributes;
7670  USHORT FileAttributes;
7671  UTIME CreationTime;                Creation timestamp for file if it
7672                                      gets created
7673  USHORT OpenFunction;               Action to take if file exists
7674  ULONG AllocationSize;              Bytes to reserve on create or
7675                                      truncate
7676  ULONG Reserved[2];                 Must be 0
7677  USHORT ByteCount;                  Count of data bytes;    min = 1
7678  UCHAR BufferFormat                 0x04
7679  STRING FileName;
7683  Server Response                    Description
7684  ================================== =================================
7686  UCHAR WordCount;                   Count of parameter words = 15
7687  UCHAR AndXCommand;                 Secondary (X) command;  0xFF =
7688                                      none
7689  UCHAR AndXReserved;                Reserved (must be 0)
7690  USHORT AndXOffset;                 Offset to next command WordCount
7691  USHORT Fid;                        File handle
7692  USHORT FileAttributes;
7693  UTIME LastWriteTime;
7694  ULONG DataSize;                    Current file size
7695  USHORT GrantedAccess;              Access permissions actually
7696                                      allowed
7697  USHORT FileType;                   Type of file opened
7698  USHORT DeviceState;                State of the named pipe
7699  USHORT Action;                     Action taken
7700  ULONG ServerFid;                   Server unique file id
7701  USHORT Reserved;                   Reserved (must be 0)
7702  USHORT ByteCount;                  Count of data bytes = 0
7706 DesiredAccess describes the access the client desires for the file (see
7707 section 3.6 -  Access Mode Encoding).
7709 OpenFunction specifies the action to be taken depending on whether or
7710 not the file exists (see section 3.8 -  Open Function Encoding).  Action
7713 Leach, Naik       expires September, 1997        [Page 118] \f
7716 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7719 in the response specifies the action as a result of the Open request
7720 (see section 3.9 -  Open Action Encoding).
7722 SearchAttributes indicates the attributes that the file must have to be
7723 found while searching to see if it exists.  The encoding of this field
7724 is described in the "File Attribute Encoding" section elsewhere in this
7725 document.  If SearchAttributes is zero then only normal files are
7726 returned.  If the system file, hidden or directory attributes are
7727 specified then the search is inclusive -- both the specified type(s) of
7728 files and normal files are returned.
7730 FileType returns the kind of resource actually opened:
7733  Name                       Value  Description
7734  ========================== ====== ==================================
7736  FileTypeDisk               0      Disk file or directory as defined
7737                                     in the attribute field
7738  FileTypeByteModePipe       1      Named pipe in byte mode
7739  FileTypeMessageModePipe    2      Named pipe in message mode
7740  FileTypePrinter            3      Spooled printer
7741  FileTypeUnknown            0xFFFF Unrecognized resource type
7745 If bit0 of Flags is clear, the FileAttributes, LastWriteTime, DataSize,
7746 FileType, and DeviceState have indeterminate values in the response.
7748 This SMB can request an oplock on the opened file.  Oplocks are fully
7749 described in the "Oplocks" section elsewhere in this document, and there
7750 is also discussion of oplocks in the SMB_COM_LOCKING_ANDX SMB
7751 description.  Bit1 and bit2 of the Flags field are used to request
7752 oplocks during open.
7754 The following SMBs may follow SMB_COM_OPEN_ANDX:
7757    SMB_COM_READ    SMB_COM_READ_ANDX
7758    SMB_COM_IOCTL
7760 5.9  PROCESS_EXIT: Process Exit
7762 This command informs the server that a client process has terminated.
7763 The server must close all files opened by Pid in the SMB header.  This
7764 must automatically release all locks the process holds.
7767 Client Request                     Description
7768 ================================== =================================
7770 UCHAR WordCount;                   Count of parameter words = 0
7771 USHORT ByteCount;                  Count of data bytes = 0
7780 Leach, Naik       expires September, 1997        [Page 119] \f
7783 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7787 Server Response                    Description
7788 ================================== =================================
7790 UCHAR WordCount;                   Count of parameter words = 0
7791  USHORT ByteCount;                 Count of data bytes = 0
7795 This SMB should not generate any errors from the server, unless the
7796 server is a user mode server and Uid in the SMB header is invalid.
7798 Clients are not required to send this SMB, they can do all cleanup
7799 necessary by sending close SMBs to the server to release resources.  In
7800 fact, clients who have negotiated LANMAN 1.0 and later probably do not
7801 send this message at all.
7804 5.10       QUERY_INFORMATION:  Get File Attributes
7806 This request is sent to obtain information about a file.
7809 Client Request                     Description
7810 ================================== =================================
7812 UCHAR WordCount;                   Count of parameter words = 0
7813 USHORT ByteCount;                  Count of data bytes;    min = 2
7814 UCHAR BufferFormat;                0x04
7815 STRING FileName[];                 File name
7819 FileName is the fully qualified name of the file relative to the Tid in
7820 the header.
7823 Server Response                    Description
7824 ================================== =================================
7826 UCHAR WordCount;                   Count of parameter words = 10
7827 USHORT FileAttributes;
7828 UTIME LastWriteTime;               Time of last write
7829 ULONG FileSize;                    File size
7830 USHORT Reserved [5];               Reserved - client should ignore
7831 USHORT ByteCount;                  Count of data bytes = 0
7835 FileAttributes are as described in the "Attributes Encoding" section of
7836 this document.
7838 Note that FileSize is limited to 32 bits, this request is inappropriate
7839 for files whose size is too large.
7842 5.11       QUERY_INFORMATION2: Get File Information
7844 This SMB is gets information about the file represented by Fid.
7850 Leach, Naik       expires September, 1997        [Page 120] \f
7853 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7857  Client Request                     Description
7858  ================================== =================================
7860  UCHAR WordCount;                   Count of parameter words = 2
7861  USHORT Fid;                        File handle
7862  USHORT ByteCount;                  Count of data bytes = 0
7866  Server Response                    Description
7867  ================================== =================================
7869  UCHAR WordCount;                   Count of parameter words = 11
7870  SMB_DATE CreationDate;
7871  SMB_TIME CreationTime;
7872  SMB_DATE LastAccessDate;
7873  SMB_TIME LastAccessTime;
7874  SMB_DATE LastWriteDate;
7875  SMB_TIME LastWriteTime;
7876  ULONG FileDataSize;                File end of data
7877  ULONG FileAllocationSize;          File allocation size
7878  USHORT FileAttributes;
7879  USHORT ByteCount;                  Count of data bytes;  min = 0
7883 The file being interrogated is specified by Fid, which must possess at
7884 least read permission.
7886 FileAttributes are described in the "File Attribute Encoding" section
7887 elsewhere in this document.
7890 5.12       READ: Read File
7892 The read message is sent to read bytes of a resource indicated by Fid in
7893 the SMB header.
7896 Client Request                   Description
7897 ===============================  ====================================
7899 UCHAR WordCount;                 Count of parameter words = 5
7900 USHORT Fid;                      File handle
7901 USHORT Count;                    Count of bytes being requested
7902 ULONG Offset;                    Offset in file of first byte to read
7903 USHORT Remaining;                Estimate of bytes to read if nonzero
7904 USHORT ByteCount;                Count of data bytes = 0
7908 Count is used to specify the requested number of bytes.
7910 Offset specifies the offset in the file of the first byte to be read.
7911 Note that this offset is limited to 32 bits, so this client request is
7912 inappropriate for files having 64 bit offsets.
7914 Remaining is advisory.  If the value is not zero, then it is taken as an
7915 estimate of the total number of bytes that will be read, including those
7919 Leach, Naik       expires September, 1997        [Page 121] \f
7922 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7925 read by this request.  This additional information may be used by the
7926 server to optimize buffer allocation or read-ahead.
7929 Server Response                    Description
7930 ================================== =================================
7932 UCHAR WordCount;                   Count of parameter words = 5
7933 USHORT Count;                      Count of bytes actually returned
7934 USHORT Reserved [4];               Reserved (must be 0)
7935 USHORT ByteCount;                  Count of data bytes
7936 UCHAR BufferFormat;                0x01 -- Data block
7937 USHORT DataLength;                 Length of data
7941 ByteCount is the number of bytes actually being returned.  If Fid refers
7942 to a disk file, ByteCount may be less than the count requested only if a
7943 read specifies bytes beyond the current file size.  In this case only
7944 the bytes that exist are returned.  A read completely beyond the end of
7945 file results in a response of length zero.  This is the only
7946 circumstance when a zero length response is generated.  A count returned
7947 which is less than the count requested is the end of file indicator.
7949 If a Read requests more data than can be placed in a message of the
7950 maximum-xmit-size for the Tid specified, the server will abort the
7951 connection to the client.
7954 5.13       READ_MPX: Read Block Multiplex
7956  The Read Block Multiplexed protocol is used to maximize the performance
7957 of reading a large block of data from the server to the client while
7958 still allowing other operations to take place between the client and
7959 server in the meantime.  The NT server supports SMB_COM_READ_MPX only
7960 over connectionless transports.
7963  Client Request                   Description
7964  ================================ ===================================
7966  UCHAR WordCount;                 Count of parameter words = 8
7967  USHORT Fid;                      File handle
7968  ULONG Offset;                    Offset in file to begin read
7969  USHORT MaxCount;                 Max bytes to return (maximum 65535)
7970  USHORT MinCount;                 Min bytes to return (normally 0)
7971  ULONG Reserved1;
7972  USHORT Reserved2;
7973  USHORT ByteCount;                Count of data bytes = 0
7977 Fid identifies the resource being read, and may refer to a disk file or
7978 a spooled printer.
7980 Timeout is the number of milliseconds to wait for completion Fid refers
7981 to a named pipe.
7986 Leach, Naik       expires September, 1997        [Page 122] \f
7989 INTERNET-DRAFT            CIFS/1.0                  03/19/97
7993  Server Response                    Description
7994  ================================== =================================
7996  UCHAR WordCount;                   Count of parameter words = 8
7997  ULONG Offset;                      Offset in file where data read
7998  USHORT Count;                      Total bytes being returned
7999  USHORT Reserved;
8000  USHORT DataCompactionMode;
8001  USHORT Reserved;
8002  USHORT DataLength;                 Number of data bytes this buffer
8003  USHORT DataOffset;                 Offset (from header start) to
8004                                      data
8005  USHORT ByteCount;                  Count of data bytes
8006  UCHAR Pad[];                       Pad to SHORT or LONG
8007  UCHAR Data[];                      Data (size = DataLength)
8011 Other requests may be active between the client and server.  The server
8012 responds with the one or more response messages as defined above until
8013 the requested data amount has been returned.  Each response contains the
8014 Pid and Mid of the original request and the Offset and Count of
8015 describing the placement of the data within the file.
8017 The client knows the maximum amount of data bytes which the server may
8018 return (from MaxCount of the request).  Thus the client initializes its
8019 bytes expected variable to this value.  The server then informs the
8020 client of the actual amount being returned via each part of the response
8021 in Count.  The server may reduce the expected bytes by lowering the
8022 total number of bytes expected in Count in any response.
8024 When the amount of data bytes received (sum of the DataLength fields)
8025 equals the total amount of data bytes expected (smallest Count
8026 received), then the client  has received all the data bytes.  This
8027 allows the protocol to work even if the responses are received out of
8028 sequence.
8030 Note that DataLength being returned here can not be larger than the
8031 smaller of the client's buffer size (as specified in MaxBufferSize on
8032 the COM_SESSION_SETUP_AND_X client request SMB) or the server's buffer
8033 size (as specified in MaxBufferSize of the COM_NEGOTIATE server response
8034 SMB).
8036 As is true in SMB_COM_READ, the total number of bytes returned may be
8037 less than the number requested only if a read specifies bytes beyond the
8038 current file size and Fid refers to a disk file.  In this case only the
8039 bytes that exist are returned.  A read completely beyond the end of file
8040 will result in a single response with a zero value in Count.  If the
8041 total number of bytes returned is less than the number of bytes
8042 requested, this indicates end of file (if reading other than a standard
8043 blocked disk file, only ZERO bytes returned indicates end of file).
8045 Once started, the Read Block Multiplexed operation is expected to go to
8046 completion.  The client is expected to receive all the responses
8050 Leach, Naik       expires September, 1997        [Page 123] \f
8053 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8056 generated by the server.  Conflicting commands (such as file close) must
8057 not be sent to the server while a multiplexed operation is in progress.
8059 The flow for the SMB_COM_READ_MPX protocol is:
8061 client ---------------> Read MPX. request >---------------------> server
8062 client <--------------< Read MPX response 1 with data <---------- server
8063 client <--------------< Read MPX response 2 with data <---------- server
8065 client <--------------< Read MPX response n with data <---------- server
8070 5.14       READ_RAW: Read Raw
8072 The SMB_COM_READ_RAW protocol is used to maximize the performance of
8073 reading a large block of data from the server to the client.  This
8074 request can be applied to files and named pipes.
8077 Client Request                   Description
8078 ================================ ===================================
8080 UCHAR WordCount;                 Count of parameter words = 8
8081 USHORT Fid;                      File handle
8082 ULONG Offset;                    Offset in file to begin read
8083 USHORT MaxCount;                 Max bytes to return (maximum 65535)
8084 USHORT MinCount;                 Min bytes to return (normally 0)
8085 ULONG Timeout;                   Wait time if named pipe
8086 USHORT Reserved;
8087 USHORT ByteCount;                Count of data bytes = 0
8091 Fid identifies the resource being read, and may refer to a disk file or
8092 a named pipe.
8094 Timeout is the number of milliseconds to wait for completion Fid refers
8095 to a named pipe.
8097 When the client issues this request, the client must guarantee that
8098 there is (and will be) no other request to the server for the duration
8099 of the SMB_COM_READ_RAW.  The server will respond, in one send, with the
8100 raw data being read.  Thus the client is able to request up to 65,535
8101 bytes of data and receive it directly into the user's buffer, since the
8102 server response has no header or trailer.  Note that the amount of data
8103 requested is expected to be larger than the negotiated buffer size for
8104 this protocol.
8106 The reason that no other requests can be active on the client's
8107 connection to the server for the duration of the request is that if
8108 other receives are present, there is normally no way to guarantee that
8109 the data will be received into the user space, rather the data may fill
8110 one (or more) of the other buffers.
8114 Leach, Naik       expires September, 1997        [Page 124] \f
8117 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8120 The number of bytes actually returned is determined by the length of the
8121 message the client receives as reported by the transport layer.  If the
8122 request is to read more bytes than are present in the file, the read
8123 response will be of the length actually read from the file.
8125 If none of the requested bytes exist (EOF) or an error occurs on the
8126 read, the server responds with a zero byte send.  Upon receipt of a zero
8127 length response, the client should send a different type of request to
8128 the server.  The response to that read will then tell the client that
8129 EOF was hit or identify the error condition.
8131 The number of bytes returned may be less than the number requested only
8132 if a read specifies bytes beyond the current file size.  In this case
8133 only the bytes that exist are returned.  A read completely beyond the
8134 end of file results in a response of zero length.  If the number of
8135 bytes returned is less than the number of bytes requested, this
8136 indicates end of file (if reading other than a standard blocked disk
8137 file, only ZERO bytes returned indicates end of file).
8139 The transport layer guarantees delivery of all response bytes to the
8140 client.  Thus no  SMB level confirmation protocol is required.  If an
8141 error should occur at the clients end, all bytes must be received and
8142 thrown away.  There is no need to inform the server of the error.
8144 This message was introduced with the LANMAN1.0 SMB dialect.  Whether or
8145 not this request is supported is returned in the response to
8146 SMB_COM_NEGOTIATE.
8148 The flow for reading a sequential file using SMB_COM_READ_BOCK_RAW is:
8151  Client Request                 Server Response
8152  ============================== =====================================
8154  SMB_COM_OPEN file              Success
8155  SMB_COM_READ_RAW
8156                                  raw data returned
8157  SMB_COM_READ_RAW
8158                                  more raw data returned
8159  SMB_COM_READ_RAW
8160                                  short (or 0 length) response returned
8161  SMB_COM_READ
8162                                  0 bytes returned indicating EOF
8163  SMB_COM_CLOSE                  Success
8167 SMB_COM_READ_RAW has no way to return errors.  Because the response is
8168 raw data only, a zero length response indicates EOF, a read error or
8169 that the server is temporarily out of large buffers.  The client should
8170 then retry using a different type of read request.  This request will
8171 then either return the EOF condition, an error if the read is still
8172 failing, or will work if the problem was due to a temporary server
8173 condition.
8178 Leach, Naik       expires September, 1997        [Page 125] \f
8181 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8184 If the negotiated dialect is NT LM 0.12 or later, and the response to
8185 the SMB_COM_NEGOTIATE SMB has CAP_LARGE_FILES set in the Capabilities
8186 field, a new format of  the SMB_COM_READ_RAW request is allowed which
8187 accommodates very large files having 64 bit offsets.
8190  Client Request                   Description
8191  ================================ ===================================
8193  UCHAR WordCount;                 Count of parameter words = 10
8194  USHORT Fid;                      File handle
8195  ULONG Offset;                    Offset in file to begin read
8196  USHORT MaxCount;                 Max bytes to return (maximum 65535)
8197  USHORT MinCount;                 Min bytes to return (normally 0)
8198  ULONG Timeout;                   Wait time if named pipe
8199  USHORT Reserved;
8200  ULONG OffsetHigh;                Upper 32 bits of offset
8201  USHORT ByteCount;                Count of data bytes = 0
8203 This form of the request is differentiated from the previous form of the
8204 request by the WordCount field.  In this case, the final offset to read
8205 from is used by combining OffsetHigh and Offset, the resulting value can
8206 not be negative or the request will be rejected by the server.
8208 SMB_COM_READ_RAW can not be used over connectionless transports.
8211 5.15       SEARCH: Search Directory using Wildcards
8213 This command is used to search directories.
8216 Client Request                     Description
8217 ================================== =================================
8219 UCHAR WordCount;                   Count of parameter words = 2
8220 USHORT MaxCount;                   Number of dir. entries to return
8221 USHORT SearchAttributes;
8222 USHORT ByteCount;                  Count of data bytes;  min = 5
8223 UCHAR BufferFormat1;               0x04 -- ASCII
8224 UCHAR FileName[];                  File name, may be null
8225 UCHAR BufferFormat2;               0x05 -- Variable block
8226 USHORT ResumeKeyLength;            Length of resume key, may be 0
8227 UCHAR ResumeKey[];                 Resume key
8231 FileName specifies the file to be sought.  SearchAttributes indicates
8232 the attributes that the file must have, and is described in the "File
8233 Attribute Encoding" section of this document.  If  SearchAttributes is
8234 zero then only normal files are returned.  If the system file, hidden or
8235 directory attributes are specified then the search is inclusive@both the
8236 specified type(s) of files and normal files are returned.  If the volume
8237 label attribute is specified then the search is exclusive, and only the
8238 volume label entry is returned.
8240 MaxCount specifies the number of directory entries to be returned.
8245 Leach, Naik       expires September, 1997        [Page 126] \f
8248 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8252 Server Response                    Description
8253 ================================== =================================
8255 UCHAR WordCount;                   Count of parameter words = 1
8256 USHORT Count;                      Number of entries returned
8257 USHORT ByteCount;                  Count of data bytes;  min = 3
8258 UCHAR BufferFormat;                0x05 -- Variable block
8259 USHORT DataLength;                 Length of data
8260 UCHAR DirectoryInformationData[];  Data
8264 The response will contain one or more directory entries as determined by
8265 the Count field.  No more than MaxCount entries will be returned.  Only
8266 entries that match the sought FileName and SearchAttributes combination
8267 will be returned.
8269  ResumeKey must be null (length = 0) on the initial search request.
8270 Subsequent search requests intended to continue a search must contain
8271 the ResumeKey field extracted from the last directory entry of the
8272 previous response.  ResumeKey is self-contained, for on calls containing
8273 a non-zero ResumeKey neither the SearchAttributes or FileName fields
8274 will be valid in the request.  ResumeKey has the following format:
8277 Resume Key Field                   Description
8278 ================================== =================================
8280 UCHAR Reserved;                    bit 7 - consumer use
8281                                     bits 5,6 - system use (must
8282                                     preserve)
8283                                     bits 0-4 - server use (must
8284                                     preserve)
8285 UCHAR FileName[11];                Name of the returned file
8286 UCHAR ReservedForServer[5];        Client must not modify
8287 UCHAR ReservedForConsumer[4];      Server must not modify
8291 FileName is 8.3 format, with the three character extension left
8292 justified into FileName[9-11].  If the client is prior to the LANMAN1.0
8293 dialect, the returned FileName should be uppercased.
8295 SMB_COM_SEARCH terminates when either the requested maximum number of
8296 entries that match the named file are found, or the end of directory is
8297 reached without the maximum number of matches being found.  A response
8298 containing no entries indicates that no matching entries were found
8299 between the starting point of the search and the end of directory.
8301 There may be multiple matching entries in response to a single request
8302 as SMB_COM_SEARCH supports wildcards in the last component of FileName
8303 of the initial request.
8305 Returned directory entries in the DirectoryInformationData field of the
8306 response each have the following format:
8312 Leach, Naik       expires September, 1997        [Page 127] \f
8315 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8319 Directory Information Field        Description
8320 ================================== =================================
8322 SMB_RESUME_KEY ResumeKey;          Described above
8323 UCHAR FileAttributes;              Attributes of the found file
8324 SMB_TIME LastWriteTime;            Time file was last written
8325 SMB_DATE LastWriteDate;            Date file was last written
8326 ULONG FileSize;                    Size of the file
8327 UCHAR FileName[13];                ASCII, space-filled null
8328                                     terminated
8332 FileName must conform to 8.3 rules, and is padded after the extension
8333 with 0x20 characters if necessary.  If the client has negotiated a
8334 dialect prior to the LANMAN1.0 dialect, or if bit0 of the Flags2 SMB
8335 header field of the request is clear, the returned FileName should be
8336 uppercased.
8338 As can be seen from the above structure, SMB_COM_SEARCH can not return
8339 long filenames, and can not return UNICODE filenames.  Files which have
8340 a size greater than 2^32 bytes should have the least significant 32 bits
8341 of their size returned in FileSize.
8344 5.16       SET_INFORMATION: Set File Attributes
8346 This message is sent to change the information about a file.
8349 Client Request                     Description
8350 ================================== =================================
8352 UCHAR WordCount;                   Count of parameter words = 8
8353 USHORT FileAttributes;             Attributes of the file
8354 UTIME LastWriteTime;               Time of last write
8355 USHORT Reserved [5];               Reserved (must be 0)
8356 USHORT ByteCount;                  Count of data bytes;    min = 2
8357 UCHAR BufferFormat;                0x04
8358 STRING FileName[];                 File name
8362 FileName is the fully qualified name of the file relative to the Tid.
8364 Support of all parameters is optional.  A server which does not
8365 implement one of the parameters will ignore that field.  If the
8366 LastWriteTime field contain zero then the file's time is not changed.
8369 Server Response                    Description
8370 ================================== =================================
8372 UCHAR WordCount;                   Count of parameter words = 0
8373 USHORT ByteCount;                  Count of data bytes = 0
8381 Leach, Naik       expires September, 1997        [Page 128] \f
8384 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8387 5.17       SET_INFORMATION2: Set File Information
8390  Client Request                     Description
8391  ================================== =================================
8393  UCHAR WordCount;                   Count of parameter words = 7
8394  USHORT Fid;                        File handle
8395  SMB_DATE CreationDate;
8396  SMB_TIME CreationTime;
8397  SMB_DATE LastAccessDate;
8398  SMB_TIME LastAccessTime;
8399  SMB_DATE LastWriteDate;
8400  SMB_TIME LastWriteTime;
8401  USHORT ByteCount;                  Count of data bytes = 0
8405 SMB_COM_SET_INFORMATION2 sets information about the file represented by
8406 Fid.  The target file is updated from the values specified.  A date or
8407 time value or zero indicates to leave that specific date and time
8408 unchanged.
8411  Server Response                    Description
8412  ================================== =================================
8414  UCHAR WordCount;                   Count of parameter words = 0
8415  USHORT ByteCount;                  Count of data bytes = 0
8419 Fid must be open with (at least) write permission.
8422 5.18       QUERY_INFORMATION_DISK: Get Disk Attributes
8424 The SMB_COM_QUERY_INFORMATION_DISK command is used to determine the
8425 capacity and remaining free space on the drive hosting the directory
8426 structure indicated by Tid in the SMB header.
8429 Client Request                     Description
8430 ================================== =================================
8432 UCHAR WordCount;                   Count of parameter words = 0
8433 USHORT ByteCount;                  Count of data bytes = 0
8437 Server Response                    Description
8438 ================================== =================================
8440 UCHAR WordCount;                   Count of parameter words = 5
8441 USHORT TotalUnits;                 Total allocation units per server
8442 USHORT BlocksPerUnit;              Blocks per allocation unit
8443 USHORT BlockSize;                  Block size (in bytes)
8444 USHORT FreeUnits;                  Number of free units
8445 USHORT Reserved;                   Reserved (client should ignore)
8446 USHORT ByteCount;                  Count of data bytes = 0
8452 Leach, Naik       expires September, 1997        [Page 129] \f
8455 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8458 The blocking/allocation units used in this response may be independent
8459 of the actual physical or logical blocking/allocation algorithm(s) used
8460 internally by the server.  However, they must accurately reflect the
8461 amount of space on the server.
8463 This SMB only returns 16 bits of information for each field, which may
8464 not be large enough for some disk systems.  In particular TotalUnits is
8465 commonly > 64K.  Fortunately, it turns out the all the client cares
8466 about is the total disk size, in bytes, and the free space, in bytes.
8467 So,  it is reasonable for a server to adjust the relative values of
8468 BlocksPerUnit and BlockSize to accommodate.  If after all adjustment,
8469 the numbers are still too high, the largest possible values for
8470 TotalUnit or FreeUnits (i.e. 0xFFFF) should be returned.
8473 5.19       TRANS2_OPEN2: Create or Open File with Extended Attributes
8475 This transaction is used to open or create a file having extended
8476 attributes.
8479 Client Request                Value
8480 ============================  =======================================
8482 WordCount                     15
8483 TotalDataCount                Total size of extended attribute list
8484 DataOffset                    Offset to extended attribute list in
8485                               this request
8486 SetupCount                    1
8487 Setup[0]                      TRANS2_OPEN2
8491 Parameter Block Encoding      Description
8492 ============================  =======================================
8494 USHORT Flags;                 Additional information: bit set-
8495                               0 - return additional info
8496                               1 - exclusive oplock requested
8497                               2 - batch oplock requested
8498                               3 - return total length of EAs
8499 USHORT DesiredAccess;         Requested file access
8500 USHORT Reserved1;             Ought to be zero.  Ignored by the
8501                               server.
8502 USHORT FileAttributes;        Attributes for file if create
8503 SMB_TIME CreationTime;        Creation time to apply to file if
8504                               create
8505 SMB_DATE CreationDate;        Creation date to apply to file if
8506                               create
8507 USHORT OpenFunction;          Open function
8508 ULONG AllocationSize;         Bytes to reserve on create or truncate
8509 USHORT Reserved [5];          Must be zero
8510 STRING FileName;              Name of file to open or create
8511 UCHAR Data[ TotalDataCount ]  FEAList structure for file to be
8512                               created
8517 Leach, Naik       expires September, 1997        [Page 130] \f
8520 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8523 If secondary requests are required, they must contain 0 parameter bytes,
8524 and the Fid in the secondary request is 0xFFFF.
8526 DesiredAccess is encoded as described in the "Access Mode Encoding"
8527 section elsewhere in this document.
8529 FileAttributes are encoded as described in the "File Attribute Encoding"
8530 section elsewhere in this document.
8532 OpenFunction specifies the action to be taken depending on whether or
8533 not the file exists (see section 3.7) .
8535 Action in the response specifies the action as a result of this request
8536 (see section 3.8).
8539  Response Parameter Block    Description
8540  ==========================  =========================================
8542  USHORT Fid;                 File handle
8543  USHORT FileAttributes;      Attributes of file
8544  SMB_TIME CreationTime;      Last modification time
8545  SMB_DATE CreationDate;      Last modification date
8546  ULONG DataSize;             Current file size
8547  USHORT GrantedAccess;       Access permissions actually allowed
8548  USHORT FileType;            Type of file
8549  USHORT DeviceState;         State of IPC device (e.g. pipe)
8550  USHORT Action;              Action taken
8551  ULONG Reserved;
8552  USHORT EaErrorOffset;       Offset into EA list if EA error
8553  ULONG EaLength;             Total EA length for opened file
8557 FileType returns the kind of resource actually opened:
8560  Name                     Value  Description
8561  =======================  ====== =====================================
8563  FileTypeDisk             0      Disk file or directory as defined in
8564                                  the attribute field
8565  FileTypeByteModePipe     1      Named pipe in byte mode
8566  FileTypeMessageModePipe  2      Named pipe in message mode
8567  FileTypePrinter          3      Spooled printer
8568  FileTypeUnknown          0xFFFF Unrecognized resource type
8572 DeviceState is applicable only if the FileType is FileTypeByteModePipe
8573 or FileTypeMessageModePipe and is encoded as in section 3.9.
8575 If an error was detected in the incoming EA list, the offset of the
8576 error is returned in EaErrorOffset.
8578 If bit0 of Flags in the request is clear, the FileAttributes,
8579 CreationTime, CreationDate, DataSize, GrantedAccess, FileType, and
8580 DeviceState have indeterminate values in the response.  Similarly, if
8584 Leach, Naik       expires September, 1997        [Page 131] \f
8587 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8590 bit3 of the request is clear, EaLength in the response has an
8591 indeterminate value in the response.
8593 This SMB can request an oplock on the opened file.  Oplocks are fully
8594 described in the "Oplocks" section elsewhere in this document, and there
8595 is also discussion of oplocks in the SMB_COM_LOCKING_ANDX SMB
8596 description.  Bit1 and bit2 of the Flags field are used to request
8597 oplocks during open.
8600 5.20       TREE_CONNECT: Tree Connect
8602 When a client connects to a server resource, an SMB_COM_TREE_CONNECT
8603 message is generated to the server. This command is almost exactly like
8604 SMB_COM_TREE_CONNECT_ANDX, except that no AndX command may follow; see
8605 section 4.1.4.
8608 Client Request                     Description
8609 ================================== =================================
8611 UCHAR WordCount;                   Count of parameter words = 0
8612 USHORT ByteCount;                  Count of data bytes;    min = 4
8613 UCHAR BufferFormat1;               0x04
8614 STRING Path[];                     Server name and share name
8615 UCHAR BufferFormat2;               0x04
8616 STRING Password[];                 Password
8617 UCHAR BufferFormat3;               0x04
8618 STRING Service[];                  Service name
8622 The CIFS server responds with:
8625 Server Response                  Description
8626 ================================ =================================
8628 UCHAR WordCount;                 Count of parameter words = 2
8629 USHORT MaxBufferSize;            Max size message the server handles
8630 USHORT Tid;                      Tree ID
8631 USHORT ByteCount;                Count of data bytes = 0
8635 If the negotiated dialect is MICROSOFT NETWORKS 1.03 or earlier,
8636 MaxBufferSize in the response message indicates the maximum size message
8637 that the server can handle.  The client should not generate messages,
8638 nor expect to receive responses, larger than this.  This must be
8639 constant for a given server.  For newer dialects, this field is ignored.
8641 Tid should be included in any future SMBs referencing this tree
8642 connection.
8645 5.21       UNLOCK_BYTE_RANGE: Unlock Bytes
8647 This message is sent to unlock the given byte range.  Offset, Count, and
8648 Pid must be identical to that specified in a prior successful lock.  If
8651 Leach, Naik       expires September, 1997        [Page 132] \f
8654 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8657 an unlock references an address range that is not locked, no error is
8658 generated.
8660 Since Offset is a 32 bit quantity, this request is inappropriate for
8661 general locking within a very large file.
8664 Client Request                     Description
8665 ================================== =================================
8667 UCHAR WordCount;                   Count of parameter words = 5
8668 USHORT Fid;                        File handle
8669 ULONG Count;                       Count of bytes to unlock
8670 ULONG Offset;                      Offset from start of file
8671 USHORT ByteCount;                  Count of data bytes = 0
8675 Server Response                    Description
8676 ================================== =================================
8678 UCHAR WordCount;                   Count of parameter words = 0
8679 USHORT ByteCount;                  Count of data bytes = 0
8682 5.22       WRITE: Write Bytes
8684 The write message is sent to write bytes into the resource indicated by
8685 Fid in the SMB header.
8688 Client Request                     Description
8689 ================================== =================================
8691 UCHAR WordCount;                   Count of parameter words = 5
8692 USHORT Fid;                        File handle
8693 USHORT Count;                      Number of bytes to be written
8694 ULONG Offset;                      Offset in file to begin write
8695 USHORT Remaining;                  Bytes remaining to satisfy
8696                                     request
8697 USHORT ByteCount;                  Count of data bytes
8698 UCHAR BufferFormat;                0x01 -- Data block
8699 USHORT DataLength;                 Length of data
8700 UCHAR Data[ Count ];               The data to write
8704 Count specifies the number of bytes to be written.  Offset is the offset
8705 in the file of the first byte to be written.  Since offset is 32 bits,
8706 this request is inappropriate for general use in a very large file.
8707 Remaining is advisory:  if the value is not zero, then it is taken as an
8708 estimate of the number of bytes that will be written -including those
8709 written by this request.  This additional information may be used by the
8710 server to optimize cache behavior.
8712 When Fid represents a disk file and the request specifies a byte range
8713 beyond the current end of file, the file will be extended.  Any bytes
8714 between the previous end of file and the requested offset are
8715 initialized to 0.  When a write specifies a length of zero, the file is
8716 truncated (or extended) to the length specified by the offset.
8720 Leach, Naik       expires September, 1997        [Page 133] \f
8723 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8727 Server Response                    Description
8728 ================================== =================================
8730 UCHAR WordCount;                   Count of parameter words = 1
8731 USHORT Count;                      Count of bytes actually written
8732 USHORT ByteCount;                  Count of data bytes = 0
8736 Count in the response indicates the actual number of bytes written, and
8737 for successful writes will always equal the count in the request
8738 message.  If the number of bytes written differs from the number
8739 requested and no error is indicated, then the server has no resources
8740 available with which to satisfy the complete write.
8742 If a Write sends a message of length greater than the MaxBufferSize for
8743 the TID specified, the server may abort the connection to the client.
8746 5.23       WRITE_AND_UNLOCK: Write Bytes and Unlock Range
8748 This request is used to first write the specified bytes and then unlock
8749 them. The locked portion of a file is "safe" to write behind because no
8750 other process can access the locked bytes until this process unlocks the
8751 bytes.  Thus the client can buffer the locked bytes locally while they
8752 are being updated, then when the unlock request is received submit this
8753 protocol to both write and then unlock bytes.  Whether or not this SMB
8754 is supported (along with SMB_COM_READ_AND_LOCK) is returned in bit0 of
8755 the Flags field of the negotiate response.
8758 Client Request                   Description
8759 ================================ ===================================
8761 UCHAR WordCount;                 Count of parameter words = 5
8762 USHORT Fid;                      File handle
8763 USHORT Count;                    Number of bytes to be written
8764 ULONG Offset;                    Offset in file to begin write
8765 USHORT Remaining;                Bytes remaining to satisfy request
8766 USHORT ByteCount;                Count of data bytes
8767 UCHAR BufferFormat;              0x01 -- Data block
8768 USHORT DataLength;               Length of data
8772 Count specifies the number of bytes to be written.  Offset is the offset
8773 in the file of the first byte to be written.  Since offset is 16 bits,
8774 this request is inappropriate for general use in a very large file.
8775 Remaining is advisory:  if the value is not zero, then it is taken as an
8776 estimate of the number of bytes that will be written -including those
8777 written by this request.  This additional information may be used by the
8778 server to optimize cache behavior.  A value of 0 for Count is an error.
8780 If the request specifies a byte range beyond the current end of file,
8781 the file will be extended.  Any bytes between the previous end of file
8782 and the requested offset are initialized to 0.
8787 Leach, Naik       expires September, 1997        [Page 134] \f
8790 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8794 Server Response                    Description
8795 ================================== =================================
8797 UCHAR WordCount;                   Count of parameter words = 1
8798 USHORT Count;                      Count of bytes actually written
8799 USHORT ByteCount;                  Count of data bytes = 0
8803 Count in the response indicates the actual number of bytes written, and
8804 for successful writes will always equal the count in the request
8805 message.  If the number of bytes written differs from the number
8806 requested and no error is indicated, then the server has no resources
8807 available with which to satisfy the complete write.
8809 If a Write sends a message of length greater than the MaxBufferSize for
8810 the TID specified, the server may abort the connection to the client. If
8811 an error occurs on the write, the bytes remain locked.
8814 5.24       WRITE_AND_CLOSE:  Write Bytes and Close File
8816 This request is used to first write the specified bytes and then close
8817 the file.
8820  Client Request                     Description
8821  ================================== =================================
8823  UCHAR WordCount;                   Count of parameter words = 6
8824  USHORT Fid;                        File handle
8825  USHORT Count;                      Number of bytes to write
8826  ULONG Offset;                      Offset in file of first byte to
8827                                      write
8828  UTIME LastWriteTime;               Time of last write
8829  USHORT ByteCount;                  1 (for pad) + value of Count
8830  UCHAR Pad;                         To force to doubleword boundary
8831  UCHAR Buffer[ Count ];             Data to write
8835  Client Request                     Description
8836  ================================== =================================
8838  UCHAR WordCount;                   Count of parameter words = 12
8839  USHORT Fid;                        File handle
8840  USHORT Count;                      Number of bytes to write
8841  ULONG Offset;                      Offset in file of first byte to
8842                                      write
8843  UTIME LastWriteTime;               Time of last write
8844  ULONG Reserved[3];                 Reserved, must be 0
8845  USHORT ByteCount;                  1 (for pad) + value of Count
8846  UCHAR Pad;                         To force to doubleword boundary
8847  UCHAR Buffer[Count];               Data to write
8855 Leach, Naik       expires September, 1997        [Page 135] \f
8858 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8862  Server Response                    Description
8863  ================================== =================================
8865  UCHAR WordCount;                   Count of parameter words = 1
8866  USHORT Count;                      Count of bytes actually written
8867  USHORT ByteCount;                  Count of data bytes = 0
8871 Since clients can formulate the request in either of two ways, WordCount
8872 must be used in order to correctly locate the data to be written.
8874 Count specifies the number of bytes to be written.  Offset is the offset
8875 in the file of the first byte to be written.  Since Offset is 32 bits,
8876 this request is inappropriate for general use in a very large file.
8878 If LastWriteTime and LastWriteDate are 0, the server should allow its
8879 local operating system to set the file's times.  Otherwise, the server
8880 should set the time to the values requested.  Failure to set the times,
8881 even if requested by the client in this message, should not result in an
8882 error response from the server.
8884 If Count is 0, the file is truncated (or extended) to Offset.
8886 If an error occurs on the write, the file should still be closed.
8889 5.25       WRITE_MPX: Write Block Multiplex
8892  Client Request                     Description
8893  ================================== =================================
8895  UCHAR WordCount;                   Count of parameter words = 12
8896  USHORT Fid;                        File handle
8897  USHORT Count;                      Total bytes, including this
8898                                      buffer
8899  USHORT Reserved;
8900  ULONG Offset;                      Offset in file to begin write
8901  ULONG Timeout;                     milliseconds to wait for
8902                                      completion
8903  USHORT WriteMode;                  Write mode:
8904                                      bit 0 - complete write to disk
8905                                      and send final result response
8906                                      bit 1 - return Remaining
8907                                      bit 7 - Connectionless mode
8908  ULONG RequestMask;                 Connectionless mode mask
8909  USHORT DataLength;                 Number of data bytes this buffer
8910  USHORT DataOffset;                 Offset (from header start) to
8911                                      data
8912  USHORT ByteCount;                  Count of data bytes
8913  UCHAR Pad[];                       Pad to SHORT or LONG
8914  UCHAR Data[];                      Data (# = DataLength)
8921 Leach, Naik       expires September, 1997        [Page 136] \f
8924 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8928  Server Response                    Description
8929  ================================== =================================
8931  UCHAR WordCount;                   Count of parameter words = 1
8932  ULONG ResponseMask;                OR of all masks received
8933  USHORT ByteCount;                  Count of data bytes = 0
8937 SMB_COM_WRITE_MPX is used to maximize the performance of writing a large
8938 block of data from the client to the server.  The NT server supports
8939 SMB_COM_WRITE_MPX only over connectionless transports, consequently bit7
8940 of WriteMode in the request must be set.
8942 Fid in the request must refer to either a file or a spooled printer.
8944 Mask contains a bit mask indicating where in the transfer that the SMB
8945 belongs.  The  response which contains the logical OR of all of the Mask
8946 values received and is always generated.  All in this exchange use the
8947 same SMB header Mid value but only final message is a connectionless
8948 sequenced request (SequenceNumber is non-zero).
8950 The server keeps a ResponseMask which is the logical or-ing of the
8951 RequestMask value contained in each SMB_COM_WRITE_MPX received since the
8952 last sequenced SMB_COM_WRITE_MPX.  The server only responds to the final
8953 (sequenced) command, and this response contains the accumulated
8954 ResponseMask. The client uses the ResponseMask received to determine
8955 which packets, if any, must be retransmitted.  The server imposes no
8956 restrictions on the values in the mask nor upon the order or contiguity
8957 of the data being sent.  The client uses this behavior to only send the
8958 missing parts in the next write sequence when retransmitting.  The next
8959 SMB_COM_WRITE_MPX sequence sent must use a new SequenceNumber value or
8960 the server will incorrectly respond with the mask from the previous
8961 SMB_COM_WRITE_MPX command.
8963 The flow is:
8966      Client             Sequence  <->  Server
8967                         Number
8968      =================  ========= ==== =====================
8970      SMB_COM_WRITE_MPX  0         ->
8971      SMB_COM_WRITE_MPX  0         ->
8972      ...
8973      SMB_COM_WRITE_MPX  S         ->
8974                         S         <-   SMB_COM_WRITE_MPX OK
8975      SMB_COM_WRITE_MPX  0         ->
8976      SMB_COM_WRITE_MPX  0         ->
8977      ....
8978      SMB_COM_WRITE_MPX  S+1       ->
8979                         S+1       <-   SMB_COM_WRITE_MPX OK
8983 Other SMB requests can intervene during this protocol exchange.
8988 Leach, Naik       expires September, 1997        [Page 137] \f
8991 INTERNET-DRAFT            CIFS/1.0                  03/19/97
8994 A server response will be generated only after the sequenced
8995 SMB_COM_WRITE_MPX has been received unless this SMB is received over a
8996 connection oriented transport (in which case the error response is
8997 immediately sent).
8999 At the time of the request, the client knows the number of data bytes
9000 expected to be sent and passes this information to the server in Count.
9001 The server can use this information to reserve buffer space, if
9002 possible.
9004 If bit0 of WriteMode is clear, the request assumed to be a form of write
9005 behind on the part of the client.  If an error occurs while writing data
9006 to disk such as disk full, the next access of the file handle (another
9007 write, close, read, etc.) will return the fact that the error occurred.
9008 If bit0 of WriteMode is set, the server will collect all the data, write
9009 it to disk and then send a final response indicating the result of the
9010 write .  The total number of bytes written is also returned in this
9011 response.
9014 5.26       WRITE_PRINT_FILE: Write to Print File
9016 This message is sent to write bytes into a print spool file.
9019 Client Request                     Description
9020 ================================== =================================
9022 UCHAR WordCount;                   Count of parameter words = 1
9023 USHORT Fid;                        File handle
9024 USHORT ByteCount;                  Count of data bytes;  min = 4
9025 UCHAR BufferFormat;                0x01 -- Data block
9026 USHORT DataLength;                 Length of data
9027 UCHAR Data[];                      Data
9031 Fid indicates the print spool file to be written, it must refer to a
9032 print spool file.
9034 ByteCount specifies the number of bytes to be written, and must be less
9035 than MaxBufferSize for the Tid specified.
9037 Data contains the bytes to append to the print spool file.  The first
9038 SetupLength bytes in the resulting print spool file contain printer
9039 setup data.  SetupLength is specified in the SMB_COM_OPEN_PRINT_FILE SMB
9040 request.
9043 Server Response                    Description
9044 ================================== =================================
9046 UCHAR WordCount;                   Count of parameter words = 0
9047 USHORT ByteCount;                  Count of data bytes = 0
9051 Servers which negotiate a protocol dialect of LANMAN1.0 or later also
9052 support the application of normal write requests to print spool files.
9055 Leach, Naik       expires September, 1997        [Page 138] \f
9058 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9061 5.27       WRITE_RAW: Write Raw Bytes
9063 The Write Block Raw protocol is used to maximize the performance of
9064 writing a large block of data from the client to the server.  The Write
9065 Block Raw command's scope includes files, Named Pipes, and spooled
9066 output (can be used in place COM_WRITE_PRINT_FILE ).
9069  Client Request              Description
9070  ==========================  =========================================
9072  UCHAR WordCount;            Count of parameter words = 12
9073  USHORT Fid;                 File handle
9074  USHORT Count;               Total bytes, including this buffer
9075  USHORT Reserved;
9076  ULONG Offset;               Offset in file to begin write
9077  ULONG Timeout;
9078  USHORT WriteMode;           Write mode:
9079                              bit 0 - complete write to disk and send
9080                              final result response
9081                              bit 1 - return Remaining (pipe/dev)
9082                              (see WriteAndX for #defines)
9083  ULONG Reserved2;
9084  USHORT DataLength;          Number of data bytes this buffer
9085  USHORT DataOffset;          Offset (from header start) to data
9086  USHORT ByteCount;           Count of data bytes
9087  UCHAR Pad[];                Pad to SHORT or LONG
9088  UCHAR Data[];               Data (# = DataLength)
9092  First Server Response          Description
9093  ============================== =====================================
9095  UCHAR WordCount;               Count of parameter words = 1
9096  USHORT Remaining;              Bytes remaining to be read if pipe
9097  USHORT ByteCount;              Count of data bytes = 0
9101  Final Server Response              Description
9102  ================================== =================================
9104  UCHAR Command (in SMB header)      SMB_COM_WRITE_COMPLETE
9106  UCHAR WordCount;                   Count of parameter words = 1
9107  USHORT Count;                      Total number of bytes written
9108  USHORT ByteCount;                  Count of data bytes = 0
9112 The first response format will be that of the final server response in
9113 the case where the server gets an error while writing the data sent
9114 along with the request.  Thus Count is the number of bytes which did get
9115 written any time an error is returned.  If an error occurs after the
9116 first response has been sent allowing the client to send the remaining
9117 data, the final response should not be sent unless write through is set.
9118 Rather the server should return this "write behind" error on the next
9119 access to the Fid.
9123 Leach, Naik       expires September, 1997        [Page 139] \f
9126 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9129 The client must guarantee that there is (and will be) no other request
9130 on the connection for the duration of this request.  The server will
9131 reserve enough resources to receive the data and respond with a response
9132 SMB as defined above.  The client then sends the raw data in one send.
9133 Thus the server is able to receive up to 65,535 bytes of data directly
9134 into the server buffer.  The amount of data transferred is expected to
9135 be larger than the negotiated buffer size for this protocol.
9137 The reason that no other requests can be active on the connection for
9138 the duration of the request is that if other receives are present on the
9139 connection, there is normally no way to guarantee that the data will be
9140 received into the correct server buffer, rather the data may fill one
9141 (or more) of the other buffers.  Also if the client is sending other
9142 requests on the connection, a request may land in the buffer that the
9143 server has allocated for the this SMB's data.
9145 Whether or not SMB_COM_WRITE_RAW is supported is returned in the
9146 response to SMB_COM_NEGOTIATE.  SMB_COM_WRITE_RAW is not supported for
9147 connectionless clients.
9149 When write through is not specified ((WriteMode & 01) == 0) this SMB is
9150 assumed to be a form of write behind.  The transport layer guarantees
9151 delivery of all secondary requests from the client.  Thus no "got the
9152 data you sent" SMB is needed.  If an error should occur at the server
9153 end, all bytes must be received and thrown away.  If an error occurs
9154 while writing data to disk such as disk full, the next access of the
9155 file handle (another write, close, read, etc.) will return the fact that
9156 the error occurred.
9158 If write through is specified ((WriteMode & 01) != 0), the server will
9159 receive the data, write it to disk and then send a final response
9160 indicating the result of the write.  The total number of bytes written
9161 is also returned in this response in the Count field.
9163 The flow for the SMB_COM_WRITE_RAW SMB is:
9165 client -----> SMB_COM_WRITE_RAW request (optional data) >-------> server
9166 client <------------------< OK send (more) data <---------------- server
9167 client  ----------------------> raw data >----------------------> server
9168 client  <---< data on disk or error (write through only) <------- server
9171 This protocol is set up such that the SMB_COM_WRITE_RAW request may also
9172 carry data.  This is an optimization in that up to the server's buffer
9173 size (MaxCount from SMB_COM_NEGOTIATE response), minus the size of the
9174 SMB_COM_WRITE_RAW SMB request, may be sent along with the request.  Thus
9175 if the server is busy and unable to support the raw write of the
9176 remaining data, the data sent along with the request has been delivered
9177 and need not be sent again.  The server will write any data sent in the
9178 request (and wait for it to be on the disk or device if write through is
9179 set), prior to sending the response.
9181 The specific responses error class ERRSRV, error codes ERRusempx and
9182 ERRusestd, indicate that the server is temporarily out of the resources
9184 Leach, Naik       expires September, 1997        [Page 140] \f
9187 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9190 needed to support the raw write of the remaining data, but that any data
9191 sent along with the request has been successfully written.  The client
9192 should then write the remaining data using a different type of SMB write
9193 request, or delay and retry using SMB_COM_WRITE_RAW.  If a write error
9194 occurs writing the initial data, it will be returned and the write raw
9195 request is implicitly denied.
9197 The return field Remaining is returned for named pipes only.  It is used
9198 to return the number of bytes currently available in the pipe.  This
9199 information can then be used by the client to know when a subsequent
9200 (non blocking) read of the pipe may return some data.  Of course when
9201 the read request is actually received by the server there may be more or
9202 less actual data in the pipe (more data has been written to the pipe /
9203 device or another reader drained it).  If the information is currently
9204 not available or the request is NOT for a pipe or the server does not
9205 support this feature, a -1 value should be returned.
9207 If the negotiated dialect is NT LM 0.12 or later, and the response to
9208 the SMB_COM_NEGOTIATE SMB has CAP_LARGE_FILES set in the Capabilities
9209 field, an additional request format is allowed which accommodates very
9210 large files having 64 bit offsets:
9213  Client Request                     Description
9214  ================================== =================================
9216  UCHAR WordCount;                   Count of parameter words = 14
9217   USHORT Fid;                       File handle
9218   USHORT Count;                     Total bytes, including this
9219                                      buffer
9220   USHORT Reserved;
9221   ULONG Offset;                     Offset in file to begin write
9222   ULONG Timeout;
9223   USHORT WriteMode;                 Write mode:
9224                                      bit 0 - complete write to disk
9225                                      and send final result response
9226                                      bit 1 - return Remaining
9227                                      (pipe/dev)
9228   ULONG Reserved2;
9229   USHORT DataLength;                Number of data bytes this buffer
9230   USHORT DataOffset;                Offset (from header start) to
9231                                      data
9232   ULONG OffsetHigh;                 Upper 32 bits of offset
9233  USHORT ByteCount;                  Count of data bytes
9234  UCHAR Pad[];                       Pad to SHORT or LONG
9235   UCHAR Data[];                     Data (# = DataLength)
9239 In this case the final offset in the file is formed by combining
9240 OffsetHigh and Offset, the resulting offset must not be negative.
9248 Leach, Naik       expires September, 1997        [Page 141] \f
9251 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9254 6   SMB Symbolic Constants
9257 6.1  SMB Command Codes
9259 The following values have been assigned for the SMB Commands.
9310 Leach, Naik       expires September, 1997        [Page 142] \f
9313 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9317 SMB_COM_CREATE_DIRECTORY    0x00
9318 SMB_COM_DELETE_DIRECTORY    0x01
9319 SMB_COM_OPEN                0x02
9320 SMB_COM_CREATE              0x03
9321 SMB_COM_CLOSE               0x04
9322 SMB_COM_FLUSH               0x05
9323 SMB_COM_DELETE              0x06
9324 SMB_COM_RENAME              0x07
9325 SMB_COM_QUERY_INFORMATION   0x08
9326 SMB_COM_SET_INFORMATION     0x09
9327 SMB_COM_READ                0x0A
9328 SMB_COM_WRITE               0x0B
9329 SMB_COM_LOCK_BYTE_RANGE     0x0C
9330 SMB_COM_UNLOCK_BYTE_RANGE   0x0D
9331 SMB_COM_CREATE_TEMPORARY    0x0E
9332 SMB_COM_CREATE_NEW          0x0F
9333 SMB_COM_CHECK_DIRECTORY     0x10
9334 SMB_COM_PROCESS_EXIT        0x11
9335 SMB_COM_SEEK                0x12
9336 SMB_COM_LOCK_AND_READ       0x13
9337 SMB_COM_WRITE_AND_UNLOCK    0x14
9338 SMB_COM_READ_RAW            0x1A
9339 SMB_COM_READ_MPX            0x1B
9340 SMB_COM_READ_MPX_SECONDARY  0x1C
9341 SMB_COM_WRITE_RAW           0x1D
9342 SMB_COM_WRITE_MPX           0x1E
9343 SMB_COM_WRITE_COMPLETE      0x20
9344 SMB_COM_SET_INFORMATION2    0x22
9345 SMB_COM_QUERY_INFORMATION2  0x23
9346 SMB_COM_LOCKING_ANDX        0x24
9347 SMB_COM_TRANSACTION         0x25
9348 SMB_COM_TRANSACTION_SECONDA 0x26
9350 SMB_COM_IOCTL               0x27
9351 SMB_COM_IOCTL_SECONDARY     0x28
9352 SMB_COM_COPY                0x29
9353 SMB_COM_MOVE                0x2A
9354 SMB_COM_ECHO                0x2B
9355 SMB_COM_WRITE_AND_CLOSE     0x2C
9356 SMB_COM_OPEN_ANDX           0x2D
9357 SMB_COM_READ_ANDX           0x2E
9358 SMB_COM_WRITE_ANDX          0x2F
9359 SMB_COM_CLOSE_AND_TREE_DISC 0x31
9360 SMB_COM_TRANSACTION2        0x32
9361 SMB_COM_TRANSACTION2_SECOND 0x33
9363 SMB_COM_FIND_CLOSE2         0x34
9364 SMB_COM_FIND_NOTIFY_CLOSE   0x35
9365 SMB_COM_TREE_CONNECT        0x70
9366 SMB_COM_TREE_DISCONNECT     0x71
9367 SMB_COM_NEGOTIATE           0x72
9368 SMB_COM_SESSION_SETUP_ANDX  0x73
9369 SMB_COM_LOGOFF_ANDX         0x74
9370 SMB_COM_TREE_CONNECT_ANDX   0x75
9372 Leach, Naik       expires September, 1997        [Page 143] \f
9375 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9379 SMB_COM_QUERY_INFORMATION_D 0x80
9381 SMB_COM_SEARCH              0x81
9382 SMB_COM_FIND                0x82
9383 SMB_COM_FIND_UNIQUE         0x83
9384 SMB_COM_NT_TRANSACT         0xA0
9385 SMB_COM_NT_TRANSACT_SECONDA 0xA1
9387 SMB_COM_NT_CREATE_ANDX      0xA2
9388 SMB_COM_NT_CANCEL           0xA4
9389 SMB_COM_OPEN_PRINT_FILE     0xC0
9390 SMB_COM_WRITE_PRINT_FILE    0xC1
9391 SMB_COM_CLOSE_PRINT_FILE    0xC2
9392 SMB_COM_GET_PRINT_QUEUE     0xC3
9394 6.2  SMB_COM_TRANSACTION2 Subcommand codes
9396 The subcommand code for SMB_COM_TRANSACTION2 request is placed in
9397 Setup[0].  The parameters associated with any particular request are
9398 placed in the Parameters vector of the request.  The defined subcommand
9399 codes are:
9434 Leach, Naik       expires September, 1997        [Page 144] \f
9437 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9441 Setup[0] Transaction2           Value Description
9442 Subcommand Code
9443 =============================== ===== =============================
9445 TRANS2_OPEN2                    0x00  Create file with extended
9446                                         attributes
9447 TRANS2_FIND_FIRST2              0x01  Begin search for files
9448 TRANS2_FIND_NEXT2               0x02  Resume search for files
9449 TRANS2_QUERY_FS_INFORMATION     0x03  Get file system information
9450                                  0x04  Reserved
9451 TRANS2_QUERY_PATH_INFORMATION   0x05  Get information about a named
9452                                         file or directory
9453 TRANS2_SET_PATH_INFORMATION     0x06  Set information about a named
9454                                         file or directory
9455 TRANS2_QUERY_FILE_INFORMATION   0x07  Get information about a
9456                                         handle
9457 TRANS2_SET_FILE_INFORMATION     0x08  Set information by handle
9458 TRANS2_FSCTL                    0x09  Not implemented by NT server
9459 TRANS2_IOCTL2                   0x0A  Not implemented by NT server
9460 TRANS2_FIND_NOTIFY_FIRST        0x0B  Not implemented by NT server
9461 TRANS2_FIND_NOTIFY_NEXT         0x0C  Not implemented by NT server
9462 TRANS2_CREATE_DIRECTORY         0x0D  Create directory with
9463                                         extended attributes
9464 TRANS2_SESSION_SETUP            0x0E  Session setup with extended
9465                                         security information
9466 TRANS2_GET_DFS_REFERRAL         0x10  Get a DFS referral
9467 TRANS2_REPORT_DFS_INCONSISTENCY 0x11  Report a DFS knowledge
9468                                         inconsistency
9471 6.3  SMB_COM_NT_TRANSACTION Subcommand Codes
9473 For these transactions, Function in the primary client request indicates
9474 the operation to be performed.  It may assume one of the following
9475 values:
9478  SubCommand Code                    Value Description
9479  ================================== ===== ===========================
9481  NT_TRANSACT_CREATE                 1     File open/create
9482  NT_TRANSACT_IOCTL                  2     Device IOCTL
9483  NT_TRANSACT_SET_SECURITY_DESC      3     Set security descriptor
9484  NT_TRANSACT_NOTIFY_CHANGE          4     Start directory watch
9485  NT_TRANSACT_RENAME                 5     Reserved (Handle-based
9486                                            rename)
9487  NT_TRANSACT_QUERY_SECURITY_DESC    6     Retrieve security
9488                                            descriptor info
9493 6.4  SMB Protocol Dialect Constants
9495 This is the list of  CIFS protocol dialects, ordered from least
9496 functional (earliest) version to most functional (most recent) version:
9501 Leach, Naik       expires September, 1997        [Page 145] \f
9504 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9508 Dialect Name           Comment
9509 ====================== ========================================
9510 =====
9512 PC NETWORK PROGRAM 1.0 The original MSNET SMB protocol (otherwise
9513                         known as the "core protocol")
9514 PCLAN1.0               Some versions of the original MSNET defined
9515                         this as an alternate to the core protocol
9516                         name
9517 MICROSOFT NETWORKS     This is used for the MS-NET 1.03 product.  It
9518 1.03                   defines Lock&Read,Write&Unlock, and a special
9519                         version of raw read and raw write.
9520 MICROSOFT NETWORKS 3.0 This is the  DOS LANMAN 1.0 specific
9521                         protocol.  It is equivalent to the LANMAN 1.0
9522                         protocol, except the server is required to
9523                         map errors from the OS/2 error to an
9524                         appropriate DOS error.
9525 LANMAN1.0              This is the first version of the full LANMAN
9526                         1.0 protocol
9527 LM1.2X002              This is the first version of the full LANMAN
9528                         2.0 protocol
9529 DOS LM1.2X002          This is the DOS equivalent of the LM1.2X002
9530                         protocol.  It is identical to the LM1.2X002
9531                         protocol, but the server will perform error
9532                         mapping to appropriate DOS errors.
9533 DOS LANMAN2.1          DOS LANMAN2.1
9534 LANMAN2.1              OS/2 LANMAN2.1
9535 Windows for Workgroups Windows for Workgroups Version 1.0
9536 3.1a
9537 NT LM 0.12             The SMB protocol designed for NT networking.
9538                         This has special SMBs which duplicate the NT
9539                         semantics.
9543 CIFS servers select the most recent version of the protocol known to
9544 both client and server.  Any CIFS server which supports dialects newer
9545 than the original core dialect must support all the messages and
9546 semantics of the dialects between the core dialect and the newer one.
9547 This is to say that a server which supports the NT LM 0.12 dialect must
9548 also support all of the messages of the previous 10 dialects.  It is the
9549 client's responsibility to ensure it only sends SMBs which are
9550 appropriate to the dialect negotiated.  Clients must be prepared to
9551 receive an SMB response from an earlier protocol dialect -- even if the
9552 client used the most recent form of the request.
9555 7   Error Codes and Classes
9557 This section lists all of the valid values for
9558 Status.DosError.ErrorClass, and most of the error codes for
9559 Status.DosError.Error.
9561 The following error classes may be returned by the server to the client.
9566 Leach, Naik       expires September, 1997        [Page 146] \f
9569 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9573 Class      Code Comment
9574 =======    ==== ====================================================
9576 SUCCESS    0    The request was successful.
9577 ERRDOS     0x01 Error is from the core DOS operating system set.
9578 ERRSRV     0x02 Error is generated by the server network file
9579                  manager.
9580 ERRHRD     0x03 Error is an hardware error.
9581 ERRCMD     0xFF Command was not in the "SMB" format.
9585 The following error codes may be generated with the  SUCCESS error
9586 class.
9589 Class      Code Comment
9590 =======    ==== ====================================================
9592 SUCCESS    0    The request was successful.
9596 The following error codes may be generated with the ERRDOS error class.
9633 Leach, Naik       expires September, 1997        [Page 147] \f
9636 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9640 Error           Code  Description
9641 =============== ===== =============================================
9643 ERRbadfunc      1     Invalid function.  The server did not
9644                         recognize or could not perform a system call
9645                         generated by the server, e.g., set the
9646                         DIRECTORY attribute on a data file, invalid
9647                         seek mode.
9648 ERRbadfile      2     File not found.  The last component of a
9649                         file's pathname could not be found.
9650 ERRbadpath      3     Directory invalid.  A directory component in
9651                         a pathname could not be found.
9652 ERRnofids       4     Too many open files.  The server has no file
9653                         handles available.
9654 ERRnoaccess     5     Access denied, the client's context does not
9655                         permit the requested function.  This includes
9656                         the following conditions:
9657                         invalid rename command
9658                         write to Fid open for read only
9659                         read on Fid open for write only
9660                         attempt to delete a non-empty directory
9661 ERRbadfid       6     Invalid file handle.  The file handle
9662                         specified was not recognized by the server.
9663 ERRbadmcb       7     Memory control blocks destroyed.
9664 ERRnomem        8     Insufficient server memory to perform the
9665                         requested function.
9666 ERRbadmem       9     Invalid memory block address.
9667 ERRbadenv       10    Invalid environment.
9668 ERRbadformat    11    Invalid format.
9669 ERRbadaccess    12    Invalid open mode.
9670 ERRbaddata      13    Invalid data (generated only by IOCTL calls
9671                         within the server).
9672 ERRbaddrive     15    Invalid drive specified.
9673 ERRremcd        16    A Delete Directory request attempted to
9674                         remove the server's current directory.
9675 ERRdiffdevice   17    Not same device (e.g., a cross volume rename
9676                         was attempted)
9677 ERRnofiles      18    A File Search command can find no more files
9678                         matching the specified criteria.
9679 ERRbadshare     32    The sharing mode specified for an Open
9680                         conflicts with existing FIDs on the file.
9681 ERRlock         33    A Lock request conflicted with an existing
9682                         lock or specified an invalid mode, or an
9683                         Unlock requested attempted to remove a lock
9684                         held by another process.
9685 ERRfilexists    80    The file named in the request already exists.
9696 Leach, Naik       expires September, 1997        [Page 148] \f
9699 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9702 The following error codes may be generated with the ERRSRV error class.
9705 Error           Code  Description
9706 =============== ===== =============================================
9708 ERRerror        1     Non-specific error code.  It is returned
9709                         under the following conditions:
9710                         @ resource other than disk space exhausted
9711                           (e.g.  TIDs)
9712                         @ first SMB command was not negotiate
9713                         @ multiple negotiates attempted
9714                         @ internal server error
9715 ERRbadpw        2     Bad password - name/password pair in a Tree
9716                         Connect or Session Setup are invalid.
9717 ERRaccess       4     The client does not have the necessary access
9718                         rights within the specified context for the
9719                         requested function.
9720 ERRinvnid       5     The Tid specified in a command was invalid.
9721 ERRinvnetname   6     Invalid network name in tree connect.
9722 ERRinvdevice    7     Invalid device - printer request made to non-
9723                         printer connection or non-printer request
9724                         made to printer connection.
9725 ERRqfull        49    Print queue full (files) -- returned by open
9726                         print file.
9727 ERRqtoobig      50    Print queue full -- no space.
9728 ERRqeof         51    EOF on print queue dump.
9729 ERRinvpfid      52    Invalid print file FID.
9730 ERRsmbcmd       64    The server did not recognize the command
9731                         received.
9732 ERRsrverror     65    The server encountered an internal error,
9733                         e.g., system file unavailable.
9734 ERRfilespecs    67    The Fid and pathname parameters contained an
9735                         invalid combination of values.
9736 ERRbadpermits   69    The access permissions specified for a file
9737                         or directory are not a valid combination.
9738                         The server cannot set the requested
9739                         attribute.
9740 ERRsetattrmode  71    The attribute mode in the Set File Attribute
9741                         request is invalid.
9742 ERRpaused       81    Server is paused.  (reserved for messaging)
9743 ERRmsgoff       82    Not receiving messages.  (reserved for
9744                         messaging).
9745 ERRnoroom       83    No room to buffer message.  (reserved for
9746                         messaging).
9747 ERRrmuns        87    Too many remote user names.  (reserved for
9748                         messaging).
9749 ERRtimeout      88    Operation timed out.
9750 ERRnoresource   89    No resources currently available for request.
9751 ERRtoomanyuids  90    Too many Uids active on this session.
9752 ERRbaduid       91    The Uid is not known as a valid user
9753                         identifier on this session.
9754 ERRusempx       250   Temporarily unable to support Raw, use MPX
9755                         mode.
9756 ERRusestd       251   Temporarily unable to support Raw, use
9759 Leach, Naik       expires September, 1997        [Page 149] \f
9762 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9766                         standard read/write.
9767 ERRcontmpx      252   Continue in MPX mode.
9768 ERRnosupport    65535 Function not supported.
9772 The following error codes may be generated with the ERRHRD error class.
9775 Error           Code  Description
9776 =============== ===== =============================================
9778 ERRnowrite      19    Attempt to write on write-protected media
9779 ERRbadunit      20    Unknown unit.
9780 ERRnotready     21    Drive not ready.
9781 ERRbadcmd       22    Unknown command.
9782 ERRdata         23    Data error (CRC).
9783 ERRbadreq       24    Bad request structure length.
9784 ERRseek         25    Seek error.
9785 ERRbadmedia     26    Unknown media type.
9786 ERRbadsector    27    Sector not found.
9787 ERRnopaper      28    Printer out of paper.
9788 ERRwrite        29    Write fault.
9789 ERRread         30    Read fault.
9790 ERRgeneral      31    General failure.
9791 ERRbadshare     32    A open conflicts with an existing open.
9792 ERRlock         33    A Lock request conflicted with an existing
9793                         lock or specified an invalid mode, or an
9794                         Unlock requested attempted to remove a lock
9795                         held by another process.
9796 ERRwrongdisk    34    The wrong disk was found in a drive.
9797 ERRFCBUnavail   35    No FCBs are available to process request.
9798 ERRsharebufexc  36    A sharing buffer has been exceeded.
9803 8   Legal Notice
9805 Microsoft does not know of any third-party rights that are violated by
9806 this contribution.  Microsoft makes no other representations regarding
9807 this contribution.
9810 9   References
9812  [1] P. Mockapetris, "Domain Names - Concepts And Facilities", RFC 1034,
9813     November 1987
9815 [2] P. Mockapetris, "Domain Names - Implementation And Specification",
9816     RFC 1035, November 1987
9818 [3] Karl Auerbach, "Protocol Standard For A Netbios Service On A Tcp/Udp
9819     Transport: Concepts And Methods", RFC 1001, March 1987
9821 [4] Karl Auerbach, "Protocol Standard For A Netbios Service On A Tcp/Udp
9822     Transport: Detailed Specifications", RFC 1002, March 1987
9827 Leach, Naik       expires September, 1997        [Page 150] \f
9830 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9833 [5] US National Bureau of Standards, "Data Encryption Standard",
9834     Federal Information Processing Standard (FIPS) Publication
9835     46-1, January 1988
9837 [6] Rivest, R. - MIT and RSA Data Security, Inc., "The MD4 Message
9838     Digest Algorithm", RFC 1320, April 1992
9840 [7] X/Open Company Ltd., "X/Open CAE Specification - Protocols for
9841     X/Open PC Interworking: SMB, Version 2", X/Open Document Number:
9842     CAE 209, September 1992.
9845 10  Security Considerations
9847 There are four authentication mechanisms, each with their own strengths
9848 and weaknesses, as well as attacks that are independent of the
9849 authentication protocol.
9852 10.1       Share level protection
9854 In share level protection, there are no per-user passwords; knowledge of
9855 the read or write password is what gives read or write access. Since the
9856 passwords must be disclosed to be used, and hence known by many people,
9857 the scheme is quite weak.
9859 In addition, the passwords are sent in the clear over the network, so
9860 they have all the weaknesses of clear text passwords in user level
9861 security.
9864 10.2       Plaintext Password Authentication
9866 This authentication protocol sends the client's password in the clear.
9867 It should be used only when needed for backwards compatibility, and only
9868 where the chances of eavesdropping is deemed acceptable, such as
9869 relatively isolated networks. Passwords sent to such servers should
9870 never be the same as passwords used for more secure servers.
9873 10.3       LANMAN 2.1 (and earlier) Challenge/Response
9875 This authentication protocol is subject to the following
9876 vulnerabilities:
9878 o Known plaintext attack
9880 o Small key space
9882 o Chosen plaintext attack
9884 o Dictionary attack
9886 o Badly chosen passwords
9889 Leach, Naik       expires September, 1997        [Page 151] \f
9892 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9895 These attacks, if successful, compromise the client's password, and
9896 allow the attacker access to the client's files even after the client's
9897 session has ended. Because of these attacks, it should be used only when
9898 needed for backwards compatibility, or where the chances of
9899 eavesdropping are deemed acceptable, such as relatively isolated
9900 networks. It is more secure than plaintext password authentication,
9901 because passwords are never seen in the clear on the network. Whenever
9902 possible, the use of the NT LM 0.12 authentication is to be preferred.
9905 10.3.1     Known Plaintext Attacks
9907 Because the challenge is plaintext, an eavesdropper can acquire known
9908 plaintext/ciphertext pairs. It can then test a guess at a password by
9909 using it to generate a key, encrypting the plaintext, and comparing it
9910 to the corresponding ciphertext.
9913 10.3.2     Small Key Space
9915 The combination of the use of only uppercase characters, the usual user
9916 practice of  choosing passwords that have alpha and perhaps numeric
9917 characters, plus the fact that the protocol treats the upper and lower
9918 halves of the 14 bytes key almost identically means that the key space
9919 is rather small. Enumerating 7 uppercase characters and digits leads to
9920 a key space of 36**7, or 78.3 billion combinations. When this mechanism
9921 was introduced nearly a decade ago, this was probably an adequately
9922 large key space, but with today's much more powerful systems, it is now
9923 small enough to make a brute force search feasible upon a
9924 plaintext/ciphertext pair obtained via a known plaintext attack.
9927 10.3.3     Chosen Plaintext Attacks
9929 A "main-in-the-middle" or a counterfeit server can choose the challenge
9930 "C8" which the client will then encrypt using a key derived from the
9931 client's password. The ability to choose the plaintext to be encrypted
9932 is known to make breaking many ciphers much easier.
9935 10.3.4     Dictionary Attacks
9937 The attacker can precompute the response for many common passwords to a
9938 challenge of its choice, and build a dictionary of (response, password)
9939 pairs. It can then use the chosen plaintext attack to acquire a response
9940 corresponding to that challenge, and just look up the password in the
9941 dictionary.
9944 10.3.5     Badly Chosen Passwords
9946 Passwords that are not long enough, or that are words in the language of
9947 the clients, make the above attacks even easier by reducing the key
9948 space even more.
9950 Leach, Naik       expires September, 1997        [Page 152] \f
9953 INTERNET-DRAFT            CIFS/1.0                  03/19/97
9956 10.4       NT LM 0.12 Challenge/Response
9958 Because it uses MD4 to generate the keying material from the password,
9959 and because it preserves the password's case, the key space of this
9960 protocol is essentially the full 56 bits that single DES allows; this is
9961 probably an acceptable length for most purposes (although future
9962 dialects may use triple-DES for more assurance). However, it is still
9963 subject to the same chosen plaintext and dictionary attacks as LANMAN
9964 2.1 challenge/response if passwords are badly chosen. The only cure is
9965 to make sure that passwords are well-chosen, and long enough to have at
9966 least 56 bits of randomness.
9968 Other considerations:
9970 o Transforming the password into Unicode leaves a pattern of
9971   alternating zeros and characters in the input to MD4.  This may allow
9972   MD4 to be reversed much more easily, although there is currently no
9973   known way to exploit this.
9975 o MD4 is known to be weak with respect to collisions.  There may be a
9976   way to exploit this to attack its one-wayness, or to exploit the
9977   collision properties to limit key search time, although there is
9978   currently no known way to do so.
9981 10.5       Other attacks
9986 10.5.1     Hijack connections
9988 Any attacker that can inject packets into the network that appear to the
9989 server to be coming from a particular client, can hijack that client's
9990 connection. Once a connection is set up and the client has
9991 authenticated, subsequent packets are not authenticated, so the attacker
9992 can inject requests to read, write, or delete files to which the client
9993 has access. Doing so require that the injected packets have the right
9994 transport level sequence numbers, which can be tricky, especially if the
9995 client is sending packets at the same time. It is significantly more
9996 difficult to hijack a connection than to eavesdrop, and doing so only
9997 permits the attacker to access files as the client for the duration of
9998 the session.
10001 10.5.2     Downgrade attack
10003 A "man-in-the-middle" can remove the bit in the SMB_COM_NEGPROT response
10004 that says the server supports challenge/response, thus fooling a client
10005 into thinking that it should supply a plaintext password. This attack
10006 can be mitigated if clients are able to be configured to require
10007 challenge/response, either in general or for particular servers.
10011 Leach, Naik       expires September, 1997        [Page 153] \f
10014 INTERNET-DRAFT            CIFS/1.0                  03/19/97
10017 10.5.3     Spoofing by Counterfeit Servers
10019 A counterfeit server is one that spoofs the DNS name resolution process
10020 so that the client gets the counterfeit's IP address instead of the
10021 genuine server's IP address, thus fooling the client into connecting to
10022 the counterfeit while believing it is connecting to the genuine server.
10023 Counterfeit servers are not detectable by the challenge/response
10024 authentication mechanism, which only authenticates clients. A
10025 counterfeit server can use the downgrade attack above to obtain a
10026 client's password; it can also execute a denial of service attack by
10027 denying the client's requests or returning bogus results. Counterfeit
10028 server attacks can be mitigated by deployment of DNSSEC.
10031 10.5.4     Storing Passwords Safely
10033 The passwords used in any of the authentication mechanisms used by this
10034 protocol have to be protected from access from over the network and from
10035 physical access. If the server does not support access control at the
10036 individual file level, but only at the file tree level, then password
10037 files can not be placed in a file tree that is accessible from the
10038 network, as all files in such a tree have to be at least equally
10039 readable.
10042 11  Authors’ Addresses
10044 Paul Leach
10045 Dilip Naik
10046 Microsoft
10047 1 Microsoft Way
10048 Redmond, WA  98052
10049 paulle@microsoft.com
10073 Leach, Naik       expires September, 1997        [Page 154] \f