From 300343d16c2d7f1f10bbd3c5e484131bf8fa5dfc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 20 Sep 2011 20:59:45 +0200 Subject: s4:libcli/smb2: implement on top of smbXcli_conn/req metze --- source4/libcli/smb2/request.c | 50 ++++++------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) (limited to 'source4/libcli/smb2/request.c') diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c index cf416a61cf..fae995a396 100644 --- a/source4/libcli/smb2/request.c +++ b/source4/libcli/smb2/request.c @@ -42,18 +42,6 @@ void smb2_setup_bufinfo(struct smb2_request *req) } } - -/* destroy a request structure */ -static int smb2_request_destructor(struct smb2_request *req) -{ - if (req->transport) { - /* remove it from the list of pending requests (a null op if - its not in the list) */ - DLIST_REMOVE(req->transport->pending_recv, req); - } - return 0; -} - /* initialise a smb2 request */ @@ -62,9 +50,7 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_ uint32_t body_dynamic_size) { struct smb2_request *req; - uint64_t seqnum; uint32_t hdr_offset; - uint32_t flags = 0; bool compound = false; if (body_dynamic_present) { @@ -78,36 +64,17 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_ req = talloc(transport, struct smb2_request); if (req == NULL) return NULL; - seqnum = transport->seqnum; - if (transport->credits.charge > 0) { - transport->seqnum += transport->credits.charge; - } else { - transport->seqnum += 1; - } - req->state = SMB2_REQUEST_INIT; req->transport = transport; req->session = NULL; req->tree = NULL; - req->seqnum = seqnum; + req->recv_iov = NULL; req->status = NT_STATUS_OK; req->async.fn = NULL; - req->next = req->prev = NULL; ZERO_STRUCT(req->cancel); ZERO_STRUCT(req->in); - - if (transport->compound.missing > 0) { - compound = true; - transport->compound.missing -= 1; - req->out = transport->compound.buffer; - ZERO_STRUCT(transport->compound.buffer); - if (transport->compound.related) { - flags |= SMB2_HDR_FLAG_CHAINED; - } - } else { - ZERO_STRUCT(req->out); - } + ZERO_STRUCT(req->out); if (req->out.size > 0) { hdr_offset = req->out.size; @@ -133,13 +100,13 @@ 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_EPOCH, transport->credits.charge); + SSVAL(req->out.hdr, SMB2_HDR_CREDIT_CHARGE, 0); SIVAL(req->out.hdr, SMB2_HDR_STATUS, 0); SSVAL(req->out.hdr, SMB2_HDR_OPCODE, opcode); - SSVAL(req->out.hdr, SMB2_HDR_CREDIT, transport->credits.ask_num); - SIVAL(req->out.hdr, SMB2_HDR_FLAGS, flags); + SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0); + SIVAL(req->out.hdr, SMB2_HDR_FLAGS, 0); SIVAL(req->out.hdr, SMB2_HDR_NEXT_COMMAND, 0); - SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, req->seqnum); + SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, 0); SIVAL(req->out.hdr, SMB2_HDR_PID, 0); SIVAL(req->out.hdr, SMB2_HDR_TID, 0); SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, 0); @@ -157,8 +124,6 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_ SCVAL(req->out.dynamic, 0, 0); } - talloc_set_destructor(req, smb2_request_destructor); - return req; } @@ -174,7 +139,6 @@ 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_SESSION_ID, tree->session->uid); SIVAL(req->out.hdr, SMB2_HDR_PID, tree->session->pid); SIVAL(req->out.hdr, SMB2_HDR_TID, tree->tid); req->session = tree->session; @@ -214,7 +178,7 @@ bool smb2_request_receive(struct smb2_request *req) /* keep receiving packets until this one is replied to */ while (req->state <= SMB2_REQUEST_RECV) { - if (tevent_loop_once(req->transport->socket->event.ctx) != 0) { + if (tevent_loop_once(req->transport->ev) != 0) { return false; } } -- cgit