#include "libcli/smb2/smb2_calls.h"
#include "lib/socket/socket.h"
#include "lib/events/events.h"
-#include "lib/stream/packet.h"
#include "../lib/util/dlinklist.h"
#include "../libcli/smb/smbXcli_base.h"
+#include "librpc/ndr/libndr.h"
/*
destroy a transport
transport->ev = sock->event.ctx;
transport->options = *options;
+ if (transport->options.max_protocol == PROTOCOL_DEFAULT) {
+ transport->options.max_protocol = PROTOCOL_LATEST;
+ }
+
+ if (transport->options.max_protocol < PROTOCOL_SMB2_02) {
+ transport->options.max_protocol = PROTOCOL_LATEST;
+ }
+
TALLOC_FREE(sock->event.fde);
TALLOC_FREE(sock->event.te);
sock->hostname,
options->signing,
0, /* smb1_capabilities */
- NULL); /* client_guid */
+ &options->client_guid,
+ options->smb2_capabilities);
if (transport->conn == NULL) {
talloc_free(transport);
return NULL;
uint16_t cmd = SVAL(req->out.hdr, SMB2_HDR_OPCODE);
uint32_t additional_flags = IVAL(req->out.hdr, SMB2_HDR_FLAGS);
uint32_t clear_flags = 0;
- uint32_t pid = IVAL(req->out.hdr, SMB2_HDR_PID);
- uint32_t tid = IVAL(req->out.hdr, SMB2_HDR_TID);
+ struct smbXcli_tcon *tcon = NULL;
struct smbXcli_session *session = NULL;
bool need_pending_break = false;
size_t hdr_ofs;
0, /* additional_flags */
0, /*clear_flags */
0, /* timeout_msec */
- 0, /* pid */
- 0, /* tid */
+ NULL, /* tcon */
NULL, /* session */
NULL, /* body */
0, /* body_fixed */
NULL, /* dyn */
- 0); /* dyn_len */
+ 0, /* dyn_len */
+ 0); /* max_dyn_len */
if (subreq != NULL) {
smbXcli_req_set_pending(subreq);
tevent_req_set_callback(subreq,
session = req->session->smbXcli;
}
+ if (req->tree) {
+ tcon = req->tree->smbXcli;
+ }
+
if (transport->compound.related) {
additional_flags |= SMB2_HDR_FLAG_CHAINED;
}
additional_flags,
clear_flags,
timeout_msec,
- pid,
- tid,
+ tcon,
session,
body.data, body.length,
- dyn.data, dyn.length);
+ dyn.data, dyn.length,
+ 0); /* max_dyn_len */
if (req->subreq == NULL) {
req->state = SMB2_REQUEST_ERROR;
req->status = NT_STATUS_NO_MEMORY;
status = smb2cli_req_compound_submit(reqs, num_reqs);
TALLOC_FREE(transport->compound.reqs);
+ transport->compound.related = false;
if (!NT_STATUS_IS_OK(status)) {
+ req->status = status;
+ req->state = SMB2_REQUEST_ERROR;
smbXcli_conn_disconnect(transport->conn, status);
}
}
tevent_req_callback_data(subreq,
struct smb2_transport);
NTSTATUS status;
- uint8_t *hdr;
uint8_t *body;
uint16_t len = 0;
bool lease;
0, /* additional_flags */
0, /*clear_flags */
0, /* timeout_msec */
- 0, /* pid */
- 0, /* tid */
+ NULL, /* tcon */
NULL, /* session */
NULL, /* body */
0, /* body_fixed */
NULL, /* dyn */
- 0); /* dyn_len */
+ 0, /* dyn_len */
+ 0); /* max_dyn_len */
if (subreq != NULL) {
smbXcli_req_set_pending(subreq);
tevent_req_set_callback(subreq,
transport->break_subreq = subreq;
}
- hdr = recv_iov[0].iov_base;
body = recv_iov[1].iov_base;
len = recv_iov[1].iov_len;
struct smb2_lease_break lb;
ZERO_STRUCT(lb);
+ lb.new_epoch = SVAL(body, 0x2);
lb.break_flags = SVAL(body, 0x4);
memcpy(&lb.current_lease.lease_key, body+0x8,
sizeof(struct smb2_lease_key));
{
struct smb2_transport *transport = talloc_get_type(private_data,
struct smb2_transport);
- struct timeval next = timeval_add(&t, 0, transport->idle.period);
- tevent_add_timer(transport->ev,
- transport,
- next,
- idle_handler, transport);
+ struct timeval next;
+
transport->idle.func(transport, transport->idle.private_data);
+
+ if (transport->idle.func == NULL) {
+ return;
+ }
+
+ if (!smbXcli_conn_is_connected(transport->conn)) {
+ return;
+ }
+
+ next = timeval_current_ofs_usec(transport->idle.period);
+ transport->idle.te = tevent_add_timer(transport->ev,
+ transport,
+ next,
+ idle_handler,
+ transport);
}
/*
uint64_t period,
void *private_data)
{
+ TALLOC_FREE(transport->idle.te);
+ ZERO_STRUCT(transport->idle);
+
+ if (idle_func == NULL) {
+ return;
+ }
+
+ if (!smbXcli_conn_is_connected(transport->conn)) {
+ return;
+ }
+
transport->idle.func = idle_func;
transport->idle.private_data = private_data;
transport->idle.period = period;
- tevent_add_timer(transport->ev,
- transport,
- timeval_current_ofs(0, period),
- idle_handler, transport);
+ transport->idle.te = tevent_add_timer(transport->ev,
+ transport,
+ timeval_current_ofs_usec(period),
+ idle_handler,
+ transport);
}