From ac293f85342a77777c2164a53c8ec43ddc1c1aed Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 04:45:38 +0000 Subject: r11662: the beginnings of a SMB2 client library. Very hackish, meant for experimentation (This used to be commit 68422dc73f6ea51bf906f3db223ae8abf077aba1) --- source4/libcli/smb2/smb2.h | 154 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 source4/libcli/smb2/smb2.h (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h new file mode 100644 index 0000000000..2e01159355 --- /dev/null +++ b/source4/libcli/smb2/smb2.h @@ -0,0 +1,154 @@ +/* + Unix SMB/CIFS implementation. + + SMB2 client library header + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +struct smb2_options { + uint32_t timeout; +}; + +/* + information returned from the negotiate response +*/ +struct smb2_negotiate { + DATA_BLOB secblob; + +}; + +/* this is the context for the smb2 transport layer */ +struct smb2_transport { + /* socket level info */ + struct smbcli_socket *socket; + + struct smb2_options options; + struct smb2_negotiate negotiate; + + /* next seqnum to allocate */ + uint64_t seqnum; + + /* a list of requests that are pending for receive on this + connection */ + struct smb2_request *pending_recv; + + /* context of the stream -> packet parser */ + struct packet_context *packet; +}; + + +struct smb2_request_buffer { + /* the raw SMB2 buffer, including the 4 byte length header */ + uint8_t *buffer; + + /* the size of the raw buffer, including 4 byte header */ + uint_t size; + + /* how much has been allocated - on reply the buffer is over-allocated to + prevent too many realloc() calls + */ + uint_t allocated; + + /* the start of the SMB2 header - this is always buffer+4 */ + uint8_t *hdr; + + /* the packet body */ + uint8_t *body; + uint_t body_size; + + /* ptr is used as a moving pointer into the data area + * of the packet. The reason its here and not a local + * variable in each function is that when a realloc of + * a send packet is done we need to move this + * pointer */ + uint8_t *ptr; +}; + + +/* + a client request moves between the following 4 states. +*/ +enum smb2_request_state {SMB2_REQUEST_INIT, /* we are creating the request */ + SMB2_REQUEST_RECV, /* we are waiting for a matching reply */ + SMB2_REQUEST_DONE, /* the request is finished */ + SMB2_REQUEST_ERROR}; /* a packet or transport level error has occurred */ + +/* the context for a single SMB2 request */ +struct smb2_request { + /* allow a request to be part of a list of requests */ + struct smb2_request *next, *prev; + + /* each request is in one of 3 possible states */ + enum smb2_request_state state; + + struct smb2_transport *transport; + + uint64_t seqnum; + + /* the NT status for this request. Set by packet receive code + or code detecting error. */ + NTSTATUS status; + + struct smb2_request_buffer in; + struct smb2_request_buffer out; + + /* information on what to do with a reply when it is received + asyncronously. If this is not setup when a reply is received then + the reply is discarded + + The private pointer is private to the caller of the client + library (the application), not private to the library + */ + struct { + void (*fn)(struct smb2_request *); + void *private; + } async; +}; + + +#define SMB2_MIN_SIZE 0x40 + +/* offsets into header elements */ +#define SMB2_HDR_LENGTH 0x04 +#define SMB2_HDR_PAD1 0x06 +#define SMB2_HDR_STATUS 0x08 +#define SMB2_HDR_OPCODE 0x0c +#define SMB2_HDR_PAD2 0x0e +#define SMB2_HDR_FLAGS 0x10 +#define SMB2_HDR_UNKNOWN 0x14 +#define SMB2_HDR_SEQNUM 0x18 +#define SMB2_HDR_PID 0x20 +#define SMB2_HDR_TID 0x24 +#define SMB2_HDR_UID 0x28 +#define SMB2_HDR_UID2 0x2c /* whats this? */ +#define SMB2_HDR_SIG 0x30 /* guess ... */ +#define SMB2_HDR_BODY 0x40 + +/* SMB2 opcodes */ +#define SMB2_OP_NEGPROT 0x00 +#define SMB2_OP_SESSSETUP 0x01 +#define SMB2_OP_TCON 0x03 +#define SMB2_OP_TDIS 0x04 +#define SMB2_OP_CREATE 0x05 +#define SMB2_OP_CLOSE 0x06 +#define SMB2_OP_READ 0x08 +#define SMB2_OP_WRITE 0x09 +#define SMB2_OP_FIND 0x0e + +#define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ + -- cgit From 555b45e12c281eb3980d15b12728c59c6b73c302 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 05:53:54 +0000 Subject: r11665: started to put some meat on the structure used for the SMB2 library the call definitions will be in smb2_calls.h, which will play a similar role that smb_interfaces.h plays for the old SMB protocol (This used to be commit 4ef3902a8a99a0b8caa81a07ba07830d7cbbc32c) --- source4/libcli/smb2/smb2.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 2e01159355..79b983206a 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -29,7 +29,6 @@ struct smb2_options { */ struct smb2_negotiate { DATA_BLOB secblob; - }; /* this is the context for the smb2 transport layer */ @@ -52,6 +51,13 @@ struct smb2_transport { }; +/* + SMB2 session context +*/ +struct smb2_session { + struct smb2_transport *transport; +}; + struct smb2_request_buffer { /* the raw SMB2 buffer, including the 4 byte length header */ uint8_t *buffer; -- cgit From 86c1370cb03a244fd5644d30732a1fbda762fe6a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 06:26:42 +0000 Subject: r11666: filled in the basic session setup. Vista happily accepts the first stage of the session setup, and waits for more. (This used to be commit 804c229c3ba7f866a7f3d66684e268d5ddc820ce) --- source4/libcli/smb2/smb2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 79b983206a..2262040b51 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -56,6 +56,7 @@ struct smb2_transport { */ struct smb2_session { struct smb2_transport *transport; + struct gensec_security *gensec; }; struct smb2_request_buffer { -- cgit From 7a78d2d6b083fbd408c766116693d01b57628f28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 07:23:45 +0000 Subject: r11668: yay! we get a successful session setup with SMB2, and get back a 64bit uid (This used to be commit 72b34a7c1b66af6be02f66639efc55a19c73e387) --- source4/libcli/smb2/smb2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 2262040b51..8ed51b2351 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -57,6 +57,7 @@ struct smb2_transport { struct smb2_session { struct smb2_transport *transport; struct gensec_security *gensec; + uint64_t uid; }; struct smb2_request_buffer { @@ -141,8 +142,7 @@ struct smb2_request { #define SMB2_HDR_SEQNUM 0x18 #define SMB2_HDR_PID 0x20 #define SMB2_HDR_TID 0x24 -#define SMB2_HDR_UID 0x28 -#define SMB2_HDR_UID2 0x2c /* whats this? */ +#define SMB2_HDR_UID 0x28 /* 64 bit */ #define SMB2_HDR_SIG 0x30 /* guess ... */ #define SMB2_HDR_BODY 0x40 -- cgit From 3e54c36fa459ec6f5e721b90ce4e4c1d0e31d85c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 09:11:51 +0000 Subject: r11674: SMB2 tree connect now works. We do 2 session setups and 2 tree connects, giving the following output: Running SMB2-CONNECT Negprot reply: current_time = Fri Nov 11 20:10:42 2005 EST boot_time = Sat Nov 12 10:34:33 2005 EST Session setup gave UID 0x40000000071 Session setup gave UID 0x140000000075 Tree connect gave tid = 0x7500000001 Tree connect gave tid = 0x7500000005 SMB2-CONNECT took 0.049024 secs (This used to be commit a24a4c311005dec4c5638e9c7c10e5e2f9872f4d) --- source4/libcli/smb2/smb2.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 8ed51b2351..353f9687d7 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -51,6 +51,14 @@ struct smb2_transport { }; +/* + SMB2 tree context +*/ +struct smb2_tree { + struct smb2_session *session; + uint64_t tid; +}; + /* SMB2 session context */ @@ -60,6 +68,7 @@ struct smb2_session { uint64_t uid; }; + struct smb2_request_buffer { /* the raw SMB2 buffer, including the 4 byte length header */ uint8_t *buffer; -- cgit From 2e753f851885930000eadbd4b69660d85124c716 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 12:37:16 +0000 Subject: r11679: opening/creating files in SMB2 now works. Lots of unknown parameters in the call tho. (This used to be commit 548fbd86b3b114493943b50669bdcba2f4ed87f2) --- source4/libcli/smb2/smb2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 353f9687d7..76f00cc573 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -56,7 +56,7 @@ struct smb2_transport { */ struct smb2_tree { struct smb2_session *session; - uint64_t tid; + uint32_t tid; }; /* -- cgit From 91e1893741741de04b73a098495c697434105803 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 11 Nov 2005 23:27:47 +0000 Subject: r11691: added reply buffer code checks and oplock flags for create request/reply (This used to be commit 26ed781375c03958241d8c93324e04e948944d01) --- source4/libcli/smb2/smb2.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 76f00cc573..f6847bfc9b 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -168,3 +168,14 @@ struct smb2_request { #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ +/* + check that a buffer code matches the expected value +*/ +#define SMB2_CHECK_BUFFER_CODE(req, code) do { \ + io->out.buffer_code = SVAL(req->in.body, 0); \ + if (io->out.buffer_code != (code)) { \ + DEBUG(0,("Unexpected buffer code 0x%x. Expected 0x%x\n", \ + io->out.buffer_code, code)); \ + return NT_STATUS_INVALID_PARAMETER; \ + } \ +} while (0) -- cgit From 2b7ee2ceee0a1b2be596a602997908f72a3af14d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Nov 2005 01:08:43 +0000 Subject: r11692: added a full composite (async) spnego session setup for SMB2. This simplies the torture code a lot. (This used to be commit 7bf1046fbb7fd83fecb2fa645628ba9a17aab037) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index f6847bfc9b..f452852cf9 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -114,6 +114,8 @@ struct smb2_request { enum smb2_request_state state; struct smb2_transport *transport; + struct smb2_session *session; + struct smb2_tree *tree; uint64_t seqnum; -- cgit From a1562e23800caef20730db9d1e5006d3a9ea4298 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Nov 2005 02:45:49 +0000 Subject: r11696: added a few more opcode names (This used to be commit 2a45476e94a248733333df29da57513bd114f213) --- source4/libcli/smb2/smb2.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index f452852cf9..f77eab22d1 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -167,6 +167,9 @@ struct smb2_request { #define SMB2_OP_READ 0x08 #define SMB2_OP_WRITE 0x09 #define SMB2_OP_FIND 0x0e +#define SMB2_OP_GETINFO 0x10 +#define SMB2_OP_SETINFO 0x11 +#define SMB2_OP_BREAK 0x12 #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ -- cgit From 67a85b3f1bca7e0590ae97d07a6ef32c418e64d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Nov 2005 07:48:56 +0000 Subject: r11697: - added a generic SMB2 getinfo call - added a SMB2-SCANGETINFO test for scanning for available info levels - added names for the info levels I recognise to smb2.h (This used to be commit fe5986067e2aaca039d70393ccc8761434f18fe6) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index f77eab22d1..e99e8d3945 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -166,7 +166,9 @@ struct smb2_request { #define SMB2_OP_CLOSE 0x06 #define SMB2_OP_READ 0x08 #define SMB2_OP_WRITE 0x09 +#define SMB2_OP_CANCEL 0x0c #define SMB2_OP_FIND 0x0e +#define SMB2_OP_NOTIFY 0x0f #define SMB2_OP_GETINFO 0x10 #define SMB2_OP_SETINFO 0x11 #define SMB2_OP_BREAK 0x12 -- cgit From e9eb56068573d89f8ce45f08220ca870b3daa669 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Nov 2005 11:01:15 +0000 Subject: r11741: - the buffer code (first 2 bytes in the SMB2 body) seem to be the length of the fixed body part, and +1 if there's a dynamic part - there're 3 types of dynamic blobs with uint16_t offset/uint16_t size with uint16_t offset/uint32_t size with uint32_t offset/uint32_t size /* aligned to 8 bytes */ - strings are transmitted in UTF-16 with no termination and packet into a uint16/uint16 blob metze (This used to be commit 79103c51e5c752fbdb4d25a0047b65002828df89) --- source4/libcli/smb2/smb2.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index e99e8d3945..47dd6fd272 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -87,13 +87,11 @@ struct smb2_request_buffer { /* the packet body */ uint8_t *body; uint_t body_size; - - /* ptr is used as a moving pointer into the data area - * of the packet. The reason its here and not a local - * variable in each function is that when a realloc of - * a send packet is done we need to move this - * pointer */ - uint8_t *ptr; + + /* this point to the next dynamic byte that can be used + * this will be moved when some dynamic data is pushed + */ + uint8_t *dynamic; }; @@ -176,13 +174,20 @@ struct smb2_request { #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ /* - check that a buffer code matches the expected value + check that a body has the expected size */ -#define SMB2_CHECK_BUFFER_CODE(req, code) do { \ - io->out.buffer_code = SVAL(req->in.body, 0); \ - if (io->out.buffer_code != (code)) { \ - DEBUG(0,("Unexpected buffer code 0x%x. Expected 0x%x\n", \ - io->out.buffer_code, code)); \ +#define SMB2_CHECK_PACKET_RECV(req, size, dynamic) do { \ + uint_t is_size = req->in.body_size; \ + uint16_t field_size = SVAL(req->in.body, 0); \ + uint16_t want_size = ((dynamic)?(size)+1:(size)); \ + if (is_size < (size)) { \ + DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \ + __location__, is_size, want_size)); \ + return NT_STATUS_BUFFER_TOO_SMALL; \ + }\ + if (field_size != want_size) { \ + DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \ + __location__, field_size, want_size)); \ return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) -- cgit From 94ae534128a28e7a3f2f4124283bd8c1acbff6d7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Nov 2005 00:48:24 +0000 Subject: r11752: setup the dynamic pointer for incoming packets too (This used to be commit 583f3c415ea33ddf5f4065a66f6fae49ab48455e) --- source4/libcli/smb2/smb2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 47dd6fd272..0ff8b87143 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -138,7 +138,7 @@ struct smb2_request { }; -#define SMB2_MIN_SIZE 0x40 +#define SMB2_MIN_SIZE 0x42 /* offsets into header elements */ #define SMB2_HDR_LENGTH 0x04 -- cgit From 310fa875091a85bb5d7be196906723f14305d406 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Nov 2005 05:23:55 +0000 Subject: r11888: - added SMB2 trans support - added session key to SMB2 - renamed 'unknown2' in create to 'impersonation' (This used to be commit aef915f312a78bf8a4123f7c40fcd14ff293d934) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 0ff8b87143..7b6824f4d9 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -66,6 +66,7 @@ struct smb2_session { struct smb2_transport *transport; struct gensec_security *gensec; uint64_t uid; + DATA_BLOB session_key; }; @@ -164,6 +165,7 @@ struct smb2_request { #define SMB2_OP_CLOSE 0x06 #define SMB2_OP_READ 0x08 #define SMB2_OP_WRITE 0x09 +#define SMB2_OP_TRANS 0x0b #define SMB2_OP_CANCEL 0x0c #define SMB2_OP_FIND 0x0e #define SMB2_OP_NOTIFY 0x0f -- cgit From a399cd3cea5efb644785ca63052ff18b765d5888 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Nov 2005 11:04:42 +0000 Subject: r11901: added smb2_logoff() support (metze correctly guessed opcode 2 was logoff) (This used to be commit 6884ce66f2881eba834b419370f74111852fe022) --- source4/libcli/smb2/smb2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 7b6824f4d9..3f17f994df 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -159,6 +159,7 @@ struct smb2_request { /* SMB2 opcodes */ #define SMB2_OP_NEGPROT 0x00 #define SMB2_OP_SESSSETUP 0x01 +#define SMB2_OP_LOGOFF 0x02 #define SMB2_OP_TCON 0x03 #define SMB2_OP_TDIS 0x04 #define SMB2_OP_CREATE 0x05 -- cgit From 1e3583475fbe6be46383866f3e061637f2f20c2a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Nov 2005 11:33:57 +0000 Subject: r11905: added SMB2_FLUSH as opcode 7. Thanks to metze and volker for help brainstorming this one. (This used to be commit a969ad592ae4cd8f7c66b1df4763fdc70328c967) --- source4/libcli/smb2/smb2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 3f17f994df..6083fcb26e 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -164,6 +164,7 @@ struct smb2_request { #define SMB2_OP_TDIS 0x04 #define SMB2_OP_CREATE 0x05 #define SMB2_OP_CLOSE 0x06 +#define SMB2_OP_FLUSH 0x07 #define SMB2_OP_READ 0x08 #define SMB2_OP_WRITE 0x09 #define SMB2_OP_TRANS 0x0b -- cgit From 1e935fcbde889a0f3735d4698e61bde6b93eaa39 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Nov 2005 11:51:15 +0000 Subject: r11906: opcode 13 appears to be keepalive. Metze guessed this one :-) (This used to be commit afe2323dc10748b97e6b30dc0c783dbe04446d8c) --- source4/libcli/smb2/smb2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 6083fcb26e..d12725f70f 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -169,6 +169,7 @@ struct smb2_request { #define SMB2_OP_WRITE 0x09 #define SMB2_OP_TRANS 0x0b #define SMB2_OP_CANCEL 0x0c +#define SMB2_OP_KEEPALIVE 0x0d #define SMB2_OP_FIND 0x0e #define SMB2_OP_NOTIFY 0x0f #define SMB2_OP_GETINFO 0x10 -- cgit From 6615907b94eb2395ddf907e92a543ff0525b9d02 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 1 Dec 2005 00:18:29 +0000 Subject: r11980: ronnie worked out that opcode 0xb in SMB2 is in fact ioctl, and that it only appeared to be like a SMBtrans request as it was being called with function 0x11c017 which is "named pipe read write" I wonder if this means we could do DCE/RPC over SMB using ntioctl calls as well? (This used to be commit f2b8857797328be64b0b85e875ae6d108e2aeaaa) --- source4/libcli/smb2/smb2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index d12725f70f..ceafacf9d4 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -167,7 +167,8 @@ struct smb2_request { #define SMB2_OP_FLUSH 0x07 #define SMB2_OP_READ 0x08 #define SMB2_OP_WRITE 0x09 -#define SMB2_OP_TRANS 0x0b +#define SMB2_OP_LOCK 0x0a +#define SMB2_OP_IOCTL 0x0b #define SMB2_OP_CANCEL 0x0c #define SMB2_OP_KEEPALIVE 0x0d #define SMB2_OP_FIND 0x0e -- cgit From 2cd5ca7d25f12aa9198bf8c2deb6aea282f573ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Dec 2005 15:38:36 +0000 Subject: r12542: Move some more prototypes out to seperate headers (This used to be commit 0aca5fd5130d980d07398f3291d294202aefe3c2) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index ceafacf9d4..eb7c10ed9d 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -197,3 +197,5 @@ struct smb2_request { return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) + +#include "libcli/smb2/smb2_proto.h" -- cgit From 78c50015bb8bd5a1d831a6e7ec796b3367c73145 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 15:40:05 +0000 Subject: r12694: Move some headers to the directory of the subsystem they belong to. (This used to be commit c722f665c90103f3ed57621c460e32ad33e7a8a3) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index eb7c10ed9d..cf84f34442 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -20,6 +20,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "smb.h" + struct smb2_options { uint32_t timeout; }; -- cgit From 63d718e243fd03e6ea24c47e7442975ec088a5b5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Jan 2006 17:27:33 +0000 Subject: r12696: Reduce the size of include/structs.h (This used to be commit 63917616016133c623fc6ff59454bc313ee7dd8f) --- source4/libcli/smb2/smb2.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index cf84f34442..913d58409b 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -199,5 +199,3 @@ struct smb2_request { return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) - -#include "libcli/smb2/smb2_proto.h" -- cgit From 5b0051e0325aea7e46715aa61bba0a1dc025132c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 17 Mar 2006 13:55:10 +0000 Subject: r14511: Install more headers (This used to be commit e1f896948fad8cf5a1aec300865c250c5721ee7d) --- source4/libcli/smb2/smb2.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 913d58409b..ceafacf9d4 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -20,8 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "smb.h" - struct smb2_options { uint32_t timeout; }; -- cgit From 0eddf14b307e905663b95296aa695a10d3fb90f7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Apr 2006 09:36:09 +0000 Subject: r15191: Avoid uint_t as it's not standard. (This used to be commit 7af59357b94e3819415b3a9257be0ced745ce130) --- source4/libcli/smb2/smb2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index ceafacf9d4..33df4daabe 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -75,19 +75,19 @@ struct smb2_request_buffer { uint8_t *buffer; /* the size of the raw buffer, including 4 byte header */ - uint_t size; + size_t size; /* how much has been allocated - on reply the buffer is over-allocated to prevent too many realloc() calls */ - uint_t allocated; + size_t allocated; /* the start of the SMB2 header - this is always buffer+4 */ uint8_t *hdr; /* the packet body */ uint8_t *body; - uint_t body_size; + size_t body_size; /* this point to the next dynamic byte that can be used * this will be moved when some dynamic data is pushed @@ -183,7 +183,7 @@ struct smb2_request { check that a body has the expected size */ #define SMB2_CHECK_PACKET_RECV(req, size, dynamic) do { \ - uint_t is_size = req->in.body_size; \ + size_t is_size = req->in.body_size; \ uint16_t field_size = SVAL(req->in.body, 0); \ uint16_t want_size = ((dynamic)?(size)+1:(size)); \ if (is_size < (size)) { \ -- cgit From bd0dcebe36ea926e2ad9a32a6eb103a88325c930 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Jun 2006 23:11:07 +0000 Subject: r16705: fix a bug found by valgrind... as we setup the 1 padding byte for non present dynamic part, we need to overwrite it when we're getting a real dynamic part, so we need to remove the buf->size +=1 when we do the first push to the dynamic part (when buf->dynamic is still but->body + buf->body_fixed) metze (This used to be commit f309209629ad1b63a76fc06163a3eeb07dce4c86) --- source4/libcli/smb2/smb2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 33df4daabe..14e6e8d835 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -87,6 +87,7 @@ struct smb2_request_buffer { /* the packet body */ uint8_t *body; + size_t body_fixed; size_t body_size; /* this point to the next dynamic byte that can be used -- cgit From 6acd9aed93b09b74e53a3b854085c6c8fab41819 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 1 Jul 2006 14:14:11 +0000 Subject: r16734: the 2 bytes after the opcode and before the flags, is no padding... the following patch is needed for vista beta2 to connect to samba4 metze (This used to be commit 58baae8fc463cd2c4e4ce532c153ad80313b03eb) --- source4/libcli/smb2/smb2.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 14e6e8d835..2c1892cafc 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -143,19 +143,19 @@ struct smb2_request { #define SMB2_MIN_SIZE 0x42 /* offsets into header elements */ -#define SMB2_HDR_LENGTH 0x04 -#define SMB2_HDR_PAD1 0x06 -#define SMB2_HDR_STATUS 0x08 -#define SMB2_HDR_OPCODE 0x0c -#define SMB2_HDR_PAD2 0x0e -#define SMB2_HDR_FLAGS 0x10 -#define SMB2_HDR_UNKNOWN 0x14 -#define SMB2_HDR_SEQNUM 0x18 -#define SMB2_HDR_PID 0x20 -#define SMB2_HDR_TID 0x24 -#define SMB2_HDR_UID 0x28 /* 64 bit */ -#define SMB2_HDR_SIG 0x30 /* guess ... */ -#define SMB2_HDR_BODY 0x40 +#define SMB2_HDR_LENGTH 0x04 +#define SMB2_HDR_PAD1 0x06 +#define SMB2_HDR_STATUS 0x08 +#define SMB2_HDR_OPCODE 0x0c +#define SMB2_HDR_UNKNOWN1 0x0e +#define SMB2_HDR_FLAGS 0x10 +#define SMB2_HDR_UNKNOWN2 0x14 +#define SMB2_HDR_SEQNUM 0x18 +#define SMB2_HDR_PID 0x20 +#define SMB2_HDR_TID 0x24 +#define SMB2_HDR_UID 0x28 /* 64 bit */ +#define SMB2_HDR_SIG 0x30 /* guess ... */ +#define SMB2_HDR_BODY 0x40 /* SMB2 opcodes */ #define SMB2_OP_NEGPROT 0x00 -- cgit From 73b066281e6f80beb46bbfdb9742e26d3550dfce Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 17 Jul 2006 07:45:23 +0000 Subject: r17081: add idle handler support to the smb2 client lib too metze (This used to be commit 1f48e7dca6a06078f3655a7f7a8f109bd6c0cb8e) --- source4/libcli/smb2/smb2.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 2c1892cafc..cee414b6e2 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -48,6 +48,15 @@ struct smb2_transport { /* context of the stream -> packet parser */ struct packet_context *packet; + + /* an idle function - if this is defined then it will be + called once every period microseconds while we are waiting + for a packet */ + struct { + void (*func)(struct smb2_transport *, void *); + void *private; + uint_t period; + } idle; }; -- cgit From a5bafffd66f511375dda4c974e6a1f152fc7aa16 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 17 Jul 2006 09:36:52 +0000 Subject: r17083: - implement SMB2 Cancel in the client - the 0xffffffffffffffff seqnum is reserved for SMB2 Break (oplock breaks) so don't use it in a request. we should someday try to test this... metze (This used to be commit 730cdc4475822e28cb400116641294a7f98ad0b5) --- source4/libcli/smb2/smb2.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index cee414b6e2..070eaf54ab 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -128,6 +128,12 @@ struct smb2_request { uint64_t seqnum; + struct { + BOOL do_cancel; + BOOL can_cancel; + uint32_t pending_id; + } cancel; + /* the NT status for this request. Set by packet receive code or code detecting error. */ NTSTATUS status; -- cgit From 30ee8beb9316a99e8a49993306252591106cb349 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 10:05:58 +0000 Subject: r18301: I discovered how to load the warnings from a build farm build into emacs compile mode (hint, paste to a file, and compile as "cat filename"). This allowed me to fix nearly all the warnings for a IA_64 SuSE build very quickly. (This used to be commit eba6c84efff735bb0ca941ac4b755ce2b0591667) --- source4/libcli/smb2/smb2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 070eaf54ab..586acaccf6 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -204,12 +204,12 @@ struct smb2_request { uint16_t want_size = ((dynamic)?(size)+1:(size)); \ if (is_size < (size)) { \ DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \ - __location__, is_size, want_size)); \ + __location__, (unsigned)is_size, (unsigned)want_size)); \ return NT_STATUS_BUFFER_TOO_SMALL; \ }\ if (field_size != want_size) { \ DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \ - __location__, field_size, want_size)); \ + __location__, (unsigned)field_size, (unsigned)want_size)); \ return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) -- cgit From bf62b6642c77e14142cdb724dc99dd3f8bfd89ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 14 May 2007 18:02:49 +0000 Subject: r22866: handle incoming chained smb2 requests in our server code to let the windows explorer in longhorn beta3 work. metze (This used to be commit 2390c9f24daccec917608cac0870890cdc73cb1c) --- source4/libcli/smb2/smb2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 586acaccf6..4db7c126d8 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -164,7 +164,7 @@ struct smb2_request { #define SMB2_HDR_OPCODE 0x0c #define SMB2_HDR_UNKNOWN1 0x0e #define SMB2_HDR_FLAGS 0x10 -#define SMB2_HDR_UNKNOWN2 0x14 +#define SMB2_HDR_CHAIN_OFFSET 0x14 #define SMB2_HDR_SEQNUM 0x18 #define SMB2_HDR_PID 0x20 #define SMB2_HDR_TID 0x24 -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/libcli/smb2/smb2.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 4db7c126d8..cad9ebd38e 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ struct smb2_options { -- cgit From 61ffa08f4c95e29d301de9fbabd6e71c2dbc1056 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 18:10:19 +0000 Subject: r24712: No longer expose the 'BOOL' data type in any interfaces. (This used to be commit 1ce32673d960c8b05b6c1b1b99e1976a402417ae) --- source4/libcli/smb2/smb2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index cad9ebd38e..33876c6f7c 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -128,8 +128,8 @@ struct smb2_request { uint64_t seqnum; struct { - BOOL do_cancel; - BOOL can_cancel; + bool do_cancel; + bool can_cancel; uint32_t pending_id; } cancel; -- cgit From a2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Feb 2008 17:00:35 +1100 Subject: updated SMB2 header defines to match WSPP docs (This used to be commit d2c6ad55eca27f50a38fc6e2a85032eddb3f0aae) --- source4/libcli/smb2/smb2.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 33876c6f7c..60cf3e0173 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -156,19 +156,20 @@ struct smb2_request { #define SMB2_MIN_SIZE 0x42 -/* offsets into header elements */ +/* offsets into header elements for a sync SMB2 request */ +#define SMB2_HDR_PROTOCOL_ID 0x00 #define SMB2_HDR_LENGTH 0x04 -#define SMB2_HDR_PAD1 0x06 +#define SMB2_HDR_EPOCH 0x06 #define SMB2_HDR_STATUS 0x08 #define SMB2_HDR_OPCODE 0x0c -#define SMB2_HDR_UNKNOWN1 0x0e +#define SMB2_HDR_CREDIT 0x0e #define SMB2_HDR_FLAGS 0x10 -#define SMB2_HDR_CHAIN_OFFSET 0x14 -#define SMB2_HDR_SEQNUM 0x18 +#define SMB2_HDR_NEXT_COMMAND 0x14 +#define SMB2_HDR_MESSAGE_ID 0x18 #define SMB2_HDR_PID 0x20 #define SMB2_HDR_TID 0x24 -#define SMB2_HDR_UID 0x28 /* 64 bit */ -#define SMB2_HDR_SIG 0x30 /* guess ... */ +#define SMB2_HDR_SESSION_ID 0x28 +#define SMB2_HDR_SIGNATURE 0x30 /* 16 bytes */ #define SMB2_HDR_BODY 0x40 /* SMB2 opcodes */ -- cgit From e94d710b0b959d8e69eb02ef0704ebcff56485fb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 10:13:28 +1100 Subject: updated SMB2 tcon as per WSPP docs (This used to be commit 5913e3e549e71affc66c28cacb6563331fb0c790) --- source4/libcli/smb2/smb2.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 60cf3e0173..549b477ffd 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -195,6 +195,28 @@ struct smb2_request { #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ +/* SMB2 negotiate security_mode */ +#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x01 +#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x02 + +/* SMB2 capabilities - only 1 so far. I'm sure more will be added */ +#define SMB2_CAP_DFS 0x0 +/* so we can spot new caps as added */ +#define SMB2_CAP_ALL SMB2_CAP_DFS + +/* SMB2 share flags */ +#define SMB2_SHAREFLAG_MANUAL_CACHING 0x0000 +#define SMB2_SHAREFLAG_AUTO_CACHING 0x0010 +#define SMB2_SHAREFLAG_VDO_CACHING 0x0020 +#define SMB2_SHAREFLAG_NO_CACHING 0x0030 +#define SMB2_SHAREFLAG_DFS 0x0001 +#define SMB2_SHAREFLAG_DFS_ROOT 0x0002 +#define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x0100 +#define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x0200 +#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x0400 +#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x0800 +#define SMB2_SHAREFLAG_ALL 0x0F33 + /* check that a body has the expected size */ -- cgit From 88d2e0522737fb8856fb0f52c2af8a2f56130f19 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 15:05:44 +1100 Subject: updated SMB2 create operation to match WSPP. Adding some defined for various new create options (This used to be commit d037dc23ced3df6bce98cbf4810fb5f1247336bd) --- source4/libcli/smb2/smb2.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 549b477ffd..db13ab69b3 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -217,6 +217,34 @@ struct smb2_request { #define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x0800 #define SMB2_SHAREFLAG_ALL 0x0F33 +/* SMB2 create security flags */ +#define SMB2_SECURITY_DYNAMIC_TRACKING 0x01 +#define SMB2_SECURITY_EFFECTIVE_ONLY 0x02 + +/* SMB2 requested oplock levels */ +#define SMB2_OPLOCK_LEVEL_NONE 0x00 +#define SMB2_OPLOCK_LEVEL_II 0x01 +#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 +#define SMB2_OPLOCK_LEVEL_BATCH 0x09 + +/* SMB2 impersonation levels */ +#define SMB2_IMPERSONATION_ANONYMOUS 0x00 +#define SMB2_IMPERSONATION_IDENTIFICATION 0x01 +#define SMB2_IMPERSONATION_IMPERSONATION 0x02 +#define SMB2_IMPERSONATION_DELEGATE 0x03 + +/* SMB2 create tags */ +#define SMB2_CREATE_TAG_EXTA "ExtA" +#define SMB2_CREATE_TAG_MXAC "MxAc" +#define SMB2_CREATE_TAG_SECD "SecD" +#define SMB2_CREATE_TAG_DHNQ "DHnQ" +#define SMB2_CREATE_TAG_DHNC "DHnC" +#define SMB2_CREATE_TAG_ALSI "AlSi" +#define SMB2_CREATE_TAG_TWRP "TWrp" +#define SMB2_CREATE_TAG_QFID "QFid" + + + /* check that a body has the expected size */ -- cgit From e870cfec9f3512b0f1bd3110d7b975652525e28a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 10:12:33 +1100 Subject: Convert SMB and SMB2 code to use a common buffer handling structure This converts our SMB and SMB2 code to use a common structure "struct request_bufinfo" for information on the buffer bounds of a packet, alignment information and string handling. This allows us to use a common backend for SMB and SMB2 code, while still using all the same string and blob handling functions. Up to now we had been passing a NULL req handle into these common routines from the SMB2 side of the server, which meant that we failed any operation which did a bounds checked string extraction (such as a RenameInformation setinfo call, which is what Vista uses for renaming files) There is still some more work to be done on this - for example we can now remove many of the SMB2 specific buffer handling functions that we had, and use the SMB ones. (This used to be commit ca6d9be6cb6a403a81b18fa6e9a6a0518d7f0f68) --- source4/libcli/smb2/smb2.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index db13ab69b3..af08b0180a 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -19,6 +19,8 @@ along with this program. If not, see . */ +#include "libcli/raw/request.h" + struct smb2_options { uint32_t timeout; }; @@ -102,6 +104,9 @@ struct smb2_request_buffer { * this will be moved when some dynamic data is pushed */ uint8_t *dynamic; + + /* this is used to range check and align strings and buffers */ + struct request_bufinfo bufinfo; }; -- cgit From b640f475be9b0f83e7812a5c7756344c5891cba3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Feb 2008 17:11:36 +1100 Subject: updated SMB2 code for getinfo according to WSPP docs - Updated getinfo structures and field names - also updated the protocol revision number handling to reflect new docs (This used to be commit 3aaa2e86d94675c6c68d66d75292c3e34bfbc81b) --- source4/libcli/smb2/smb2.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index af08b0180a..726df64090 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -200,6 +200,9 @@ struct smb2_request { #define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */ +/* the dialect we support */ +#define SMB2_DIALECT_REVISION 0x202 + /* SMB2 negotiate security_mode */ #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x01 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x02 -- cgit From 132852f44ac24824d2247d3d873f217c5b8207a9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 18 Apr 2008 22:27:24 +0200 Subject: libcli/smb2: make it possible to handle incoming oplock requests metze (This used to be commit 58189b87eade62b717c2c17c679e482786bf2098) --- source4/libcli/smb2/smb2.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 726df64090..ae66a6e0d3 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -21,6 +21,8 @@ #include "libcli/raw/request.h" +struct smb2_handle; + struct smb2_options { uint32_t timeout; }; @@ -58,6 +60,15 @@ struct smb2_transport { void *private; uint_t period; } idle; + + struct { + /* a oplock break request handler */ + bool (*handler)(struct smb2_transport *transport, + const struct smb2_handle *handle, + uint8_t level, void *private_data); + /* private data passed to the oplock handler */ + void *private_data; + } oplock; }; -- cgit From c7d7577fb978dfa822b4aab238440816188099c6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 May 2008 15:03:58 +1000 Subject: private -> private_data for struct smb2_request (This used to be commit 67290e0ad69df2f2fe651249c6550b8e32dd641b) --- source4/libcli/smb2/smb2.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index ae66a6e0d3..964dcf320c 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -19,6 +19,9 @@ along with this program. If not, see . */ +#ifndef __LIBCLI_SMB2_SMB2_H__ +#define __LIBCLI_SMB2_SMB2_H__ + #include "libcli/raw/request.h" struct smb2_handle; @@ -165,7 +168,7 @@ struct smb2_request { */ struct { void (*fn)(struct smb2_request *); - void *private; + void *private_data; } async; }; @@ -282,3 +285,5 @@ struct smb2_request { return NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) + +#endif -- cgit From 9c6a35ad9ba9458fe9d3a73ba1f785a61305e2aa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 May 2008 11:57:43 +1000 Subject: remember the server time fields on negotiate. Needed for gentest (This used to be commit 7989ca861dcc700b52be3a47ea5ae8b03fbb9330) --- source4/libcli/smb2/smb2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 964dcf320c..b55da05e21 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -35,6 +35,8 @@ struct smb2_options { */ struct smb2_negotiate { DATA_BLOB secblob; + NTTIME system_time; + NTTIME server_start_time; }; /* this is the context for the smb2 transport layer */ -- cgit From beaa01e403dda7557a6acdf0181d79d58a33bbbe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 30 May 2008 17:03:54 +1000 Subject: implemented client side SMB2 signing This doessn't work against Windows yet, and I've submitted a WSPP request for clarification of the docs to try and find out why. Meanwhile this is no worse than what we had, as it only gets used when the server demands signing, and we didn't work then anyway. (This used to be commit b788096add3586d7277efcd3bf5ca7f3a604cb7a) --- source4/libcli/smb2/smb2.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index b55da05e21..0903509528 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -23,20 +23,24 @@ #define __LIBCLI_SMB2_SMB2_H__ #include "libcli/raw/request.h" +#include "libcli/raw/libcliraw.h" struct smb2_handle; -struct smb2_options { - uint32_t timeout; +struct smb2_signing_context { + bool doing_signing; + bool signing_started; + DATA_BLOB session_key; }; /* - information returned from the negotiate response + information returned from the negotiate process */ struct smb2_negotiate { DATA_BLOB secblob; NTTIME system_time; NTTIME server_start_time; + uint16_t security_mode; }; /* this is the context for the smb2 transport layer */ @@ -44,7 +48,6 @@ struct smb2_transport { /* socket level info */ struct smbcli_socket *socket; - struct smb2_options options; struct smb2_negotiate negotiate; /* next seqnum to allocate */ @@ -74,6 +77,9 @@ struct smb2_transport { /* private data passed to the oplock handler */ void *private_data; } oplock; + + struct smbcli_options options; + struct smb2_signing_context signing; }; @@ -92,7 +98,6 @@ struct smb2_session { struct smb2_transport *transport; struct gensec_security *gensec; uint64_t uid; - DATA_BLOB session_key; }; @@ -193,6 +198,13 @@ struct smb2_request { #define SMB2_HDR_SIGNATURE 0x30 /* 16 bytes */ #define SMB2_HDR_BODY 0x40 +/* header flags */ +#define SMB2_HDR_FLAG_REDIRECT 0x01 +#define SMB2_HDR_FLAG_ASYNC 0x02 +#define SMB2_HDR_FLAG_CHAINED 0x04 +#define SMB2_HDR_FLAG_SIGNED 0x08 +#define SMB2_HDR_FLAG_DFS 0x10000000 + /* SMB2 opcodes */ #define SMB2_OP_NEGPROT 0x00 #define SMB2_OP_SESSSETUP 0x01 -- cgit From 1c33953ae21384f04de11539afaf9ead5e413b96 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 7 Jun 2008 08:30:51 -0700 Subject: make signing per session in the SMB2 client library Thanks to Metze for spotting this (This used to be commit e9fd9b821c04d1cb7b574f539dd8169611e662aa) --- source4/libcli/smb2/smb2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 0903509528..2b468d3dc9 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -30,7 +30,6 @@ struct smb2_handle; struct smb2_signing_context { bool doing_signing; bool signing_started; - DATA_BLOB session_key; }; /* @@ -98,6 +97,7 @@ struct smb2_session { struct smb2_transport *transport; struct gensec_security *gensec; uint64_t uid; + DATA_BLOB session_key; }; -- cgit From 35bd7a6378cc25ed6b24d153c3cf1557d6126788 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Jun 2008 21:57:41 +0200 Subject: libcli/smb2: fix per session signing state metze (This used to be commit 8bc12dc77a59e792830d96e84a4e8d1b2c651505) --- source4/libcli/smb2/smb2.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 2b468d3dc9..5d6341a15b 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -27,11 +27,6 @@ struct smb2_handle; -struct smb2_signing_context { - bool doing_signing; - bool signing_started; -}; - /* information returned from the negotiate process */ @@ -78,7 +73,8 @@ struct smb2_transport { } oplock; struct smbcli_options options; - struct smb2_signing_context signing; + + bool signing_required; }; @@ -98,6 +94,7 @@ struct smb2_session { struct gensec_security *gensec; uint64_t uid; DATA_BLOB session_key; + bool signing_active; }; -- cgit From 2a336a63d704b1a5cf8e9a2961f48285081256ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Aug 2008 12:48:37 +0200 Subject: libcli/smb2: add SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK SMB2 returns NOT_SUPPORTED to some more NTCREATE_OPTIONS. metze (This used to be commit 3ea08d430370717463ffab44fed9c42db1002d97) --- source4/libcli/smb2/smb2.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/libcli/smb2/smb2.h') diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h index 5d6341a15b..f00107de60 100644 --- a/source4/libcli/smb2/smb2.h +++ b/source4/libcli/smb2/smb2.h @@ -276,7 +276,9 @@ struct smb2_request { #define SMB2_CREATE_TAG_TWRP "TWrp" #define SMB2_CREATE_TAG_QFID "QFid" - +/* SMB2 Create ignore some more create_options */ +#define SMB2_CREATE_OPTIONS_NOT_SUPPORTED_MASK (NTCREATEX_OPTIONS_TREE_CONNECTION | \ + NTCREATEX_OPTIONS_OPFILTER) /* check that a body has the expected size -- cgit