summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-02-12 17:00:35 +1100
committerAndrew Tridgell <tridge@samba.org>2008-02-12 17:00:35 +1100
commita2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7 (patch)
tree27ba4118559f6c60ac5ffe4ce6dc379171897fcb
parent416360895f36d41ce8d29c25ef08e2b8b4e38571 (diff)
downloadsamba-a2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7.tar.gz
samba-a2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7.tar.bz2
samba-a2505c5a2cc2b7b692ffbcdd8c6b86000a15d2c7.zip
updated SMB2 header defines to match WSPP docs
(This used to be commit d2c6ad55eca27f50a38fc6e2a85032eddb3f0aae)
-rw-r--r--source4/libcli/smb2/cancel.c6
-rw-r--r--source4/libcli/smb2/logoff.c2
-rw-r--r--source4/libcli/smb2/notify.c2
-rw-r--r--source4/libcli/smb2/request.c14
-rw-r--r--source4/libcli/smb2/session.c4
-rw-r--r--source4/libcli/smb2/smb2.h15
-rw-r--r--source4/libcli/smb2/tcon.c2
-rw-r--r--source4/libcli/smb2/transport.c2
-rw-r--r--source4/smb_server/smb2/negprot.c12
-rw-r--r--source4/smb_server/smb2/receive.c18
-rw-r--r--source4/smb_server/smb2/sesssetup.c12
-rw-r--r--source4/smb_server/smb2/tcon.c22
12 files changed, 56 insertions, 55 deletions
diff --git a/source4/libcli/smb2/cancel.c b/source4/libcli/smb2/cancel.c
index 096919f177..80127feea5 100644
--- a/source4/libcli/smb2/cancel.c
+++ b/source4/libcli/smb2/cancel.c
@@ -52,11 +52,11 @@ NTSTATUS smb2_cancel(struct smb2_request *r)
c->seqnum = 0;
SIVAL(c->out.hdr, SMB2_HDR_FLAGS, 0x00000002);
- SSVAL(c->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
+ SSVAL(c->out.hdr, SMB2_HDR_CREDIT, 0x0030);
SIVAL(c->out.hdr, SMB2_HDR_PID, r->cancel.pending_id);
- SBVAL(c->out.hdr, SMB2_HDR_SEQNUM, c->seqnum);
+ SBVAL(c->out.hdr, SMB2_HDR_MESSAGE_ID, c->seqnum);
if (r->session) {
- SBVAL(c->out.hdr, SMB2_HDR_UID, r->session->uid);
+ SBVAL(c->out.hdr, SMB2_HDR_SESSION_ID, r->session->uid);
}
SSVAL(c->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/logoff.c b/source4/libcli/smb2/logoff.c
index 321a4db1a6..b38a08ca43 100644
--- a/source4/libcli/smb2/logoff.c
+++ b/source4/libcli/smb2/logoff.c
@@ -33,7 +33,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, false, 0);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, session->uid);
SSVAL(req->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/notify.c b/source4/libcli/smb2/notify.c
index a3bea41eb0..e7c38a27f9 100644
--- a/source4/libcli/smb2/notify.c
+++ b/source4/libcli/smb2/notify.c
@@ -35,7 +35,7 @@ struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify
req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, false, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0030);
SSVAL(req->out.body, 0x02, io->in.recursive);
SIVAL(req->out.body, 0x04, io->in.buffer_size);
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index 73c74dcfeb..46ec24145f 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -83,17 +83,17 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->out.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->out.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, opcode);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->out.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->out.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->out.hdr, SMB2_HDR_SEQNUM, req->seqnum);
+ SIVAL(req->out.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, req->seqnum);
SIVAL(req->out.hdr, SMB2_HDR_PID, 0);
SIVAL(req->out.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->out.hdr, SMB2_HDR_UID, 0);
- memset(req->out.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->out.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* set the length of the fixed body part and +1 if there's a dynamic part also */
SSVAL(req->out.body, 0, body_fixed_size + (body_dynamic_size?1:0));
@@ -122,7 +122,7 @@ struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opc
body_dynamic_size);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, tree->session->uid);
SIVAL(req->out.hdr, SMB2_HDR_TID, tree->tid);
req->session = tree->session;
req->tree = tree;
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index d06688a598..18fe3486a4 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -74,7 +74,7 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
0x18, true, io->in.secblob.length);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, session->uid);
SCVAL(req->out.body, 0x02, io->in.vc_number);
SCVAL(req->out.body, 0x03, io->in.security_mode);
SIVAL(req->out.body, 0x04, io->in.capabilities);
@@ -112,7 +112,7 @@ NTSTATUS smb2_session_setup_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
SMB2_CHECK_PACKET_RECV(req, 0x08, true);
io->out.session_flags = SVAL(req->in.body, 0x02);
- io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ io->out.uid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x04, &io->out.secblob);
if (!NT_STATUS_IS_OK(status)) {
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 */
diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c
index ad1ba4c92d..5a09970584 100644
--- a/source4/libcli/smb2/tcon.c
+++ b/source4/libcli/smb2/tcon.c
@@ -56,7 +56,7 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
0x08, true, 0);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, tree->session->uid);
SSVAL(req->out.body, 0x02, io->in.unknown1);
status = smb2_push_o16s16_string(&req->out, 0x04, io->in.path);
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index 83e9436a58..dceb78382a 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -167,7 +167,7 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
}
flags = IVAL(hdr, SMB2_HDR_FLAGS);
- seqnum = BVAL(hdr, SMB2_HDR_SEQNUM);
+ seqnum = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
/* match the incoming request against the list of pending requests */
for (req=transport->pending_recv; req; req=req->next) {
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index 043534d777..4f44147606 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -238,17 +238,17 @@ void smb2srv_reply_smb_negprot(struct smbsrv_request *smb_req)
SIVAL(req->in.hdr, 0, SMB2_MAGIC);
SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_NEGPROT);
- SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0);
+ SIVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID, 0);
SIVAL(req->in.hdr, SMB2_HDR_PID, 0);
SIVAL(req->in.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->in.hdr, SMB2_HDR_UID, 0);
- memset(req->in.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->in.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->in.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
SSVAL(req->in.body, 0x00, 0x24);
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index cfae2dbe52..393b3f0cc5 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -94,17 +94,17 @@ NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_si
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->out.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->out.hdr, SMB2_HDR_STATUS, NT_STATUS_V(req->status));
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, SVAL(req->in.hdr, SMB2_HDR_OPCODE));
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0001);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0001);
SIVAL(req->out.hdr, SMB2_HDR_FLAGS, flags);
- SIVAL(req->out.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->out.hdr, SMB2_HDR_SEQNUM, req->seqnum);
+ SIVAL(req->out.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, req->seqnum);
SIVAL(req->out.hdr, SMB2_HDR_PID, pid);
SIVAL(req->out.hdr, SMB2_HDR_TID, tid);
- SBVAL(req->out.hdr, SMB2_HDR_UID, BVAL(req->in.hdr, SMB2_HDR_UID));
- memset(req->out.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, BVAL(req->in.hdr, SMB2_HDR_SESSION_ID));
+ memset(req->out.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* set the length of the fixed body part and +1 if there's a dynamic part also */
SSVAL(req->out.body, 0, body_fixed_size + (body_dynamic_size?1:0));
@@ -259,10 +259,10 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req)
uint64_t uid;
opcode = SVAL(req->in.hdr, SMB2_HDR_OPCODE);
- req->chain_offset = IVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET);
- req->seqnum = BVAL(req->in.hdr, SMB2_HDR_SEQNUM);
+ req->chain_offset = IVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND);
+ req->seqnum = BVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID);
tid = IVAL(req->in.hdr, SMB2_HDR_TID);
- uid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ uid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
req->session = smbsrv_session_find(req->smb_conn, uid, req->request_time);
req->tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time);
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index b4c78a2ebd..1aaacf897c 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -32,12 +32,12 @@
static void smb2srv_sesssetup_send(struct smb2srv_request *req, union smb_sesssetup *io)
{
- uint16_t unknown1;
+ uint16_t credit;
if (NT_STATUS_IS_OK(req->status)) {
- unknown1 = 0x0003;
+ credit = 0x0003;
} else if (NT_STATUS_EQUAL(req->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- unknown1 = 0x0002;
+ credit = 0x0002;
} else {
smb2srv_send_error(req, req->status);
return;
@@ -45,8 +45,8 @@ static void smb2srv_sesssetup_send(struct smb2srv_request *req, union smb_sessse
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, io->smb2.out.secblob.length));
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, unknown1);
- SBVAL(req->out.hdr, SMB2_HDR_UID, io->smb2.out.uid);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, credit);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, io->smb2.out.uid);
SSVAL(req->out.body, 0x02, io->smb2.out.session_flags);
SMB2SRV_CHECK(smb2_push_o16s16_blob(&req->out, 0x04, io->smb2.out.secblob));
@@ -112,7 +112,7 @@ static void smb2srv_sesssetup_backend(struct smb2srv_request *req, union smb_ses
io->smb2.out.uid = 0;
io->smb2.out.secblob = data_blob(NULL, 0);
- vuid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ vuid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
/*
* only when we got '0' we should allocate a new session
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index 6d0d98554c..824a57b4a1 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -57,24 +57,24 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8
SIVAL(req->in.hdr, 0, SMB2_MAGIC);
SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_BREAK);
- SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0);
+ SIVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID, 0);
SIVAL(req->in.hdr, SMB2_HDR_PID, 0);
SIVAL(req->in.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->in.hdr, SMB2_HDR_UID, 0);
- memset(req->in.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->in.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->in.hdr+SMB2_HDR_SIGNATURE, 0, 16);
SSVAL(req->in.body, 0, 2);
status = smb2srv_setup_reply(req, 0x18, false, 0);
NT_STATUS_NOT_OK_RETURN(status);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0000);
SSVAL(req->out.body, 0x02, 0x0001);
SIVAL(req->out.body, 0x04, 0x00000000);
@@ -361,7 +361,7 @@ failed:
static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io)
{
- uint16_t unknown1;
+ uint16_t credit;
if (!NT_STATUS_IS_OK(req->status)) {
smb2srv_send_error(req, req->status);
@@ -369,15 +369,15 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io)
}
if (io->smb2.out.unknown1 == 0x0002) {
/* if it's an IPC share vista returns 0x0005 */
- unknown1 = 0x0005;
+ credit = 0x0005;
} else {
- unknown1 = 0x0001;
+ credit = 0x0001;
}
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, false, 0));
SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT,credit);
SSVAL(req->out.body, 0x02, io->smb2.out.unknown1);
SIVAL(req->out.body, 0x04, io->smb2.out.unknown2);