/*
an event has happened on the socket
*/
-static void smbcli_transport_event_handler(struct event_context *ev,
- struct fd_event *fde,
- uint16_t flags, void *private)
+static void smbcli_transport_event_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
{
- struct smbcli_transport *transport = talloc_get_type(private,
+ struct smbcli_transport *transport = talloc_get_type(private_data,
struct smbcli_transport);
if (flags & EVENT_FD_READ) {
packet_recv(transport->packet);
/*
handle receive errors
*/
-static void smbcli_transport_error(void *private, NTSTATUS status)
+static void smbcli_transport_error(void *private_data, NTSTATUS status)
{
- struct smbcli_transport *transport = talloc_get_type(private, struct smbcli_transport);
+ struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport);
smbcli_transport_dead(transport, status);
}
-static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
+static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob);
/*
create a transport structure based on an established socket
struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
TALLOC_CTX *parent_ctx,
bool primary,
- struct smbcli_options *options,
- struct smb_iconv_convenience *iconv_convenience)
+ struct smbcli_options *options)
{
struct smbcli_transport *transport;
transport->negotiate.protocol = PROTOCOL_NT1;
transport->options = *options;
transport->negotiate.max_xmit = transport->options.max_xmit;
- transport->iconv_convenience = iconv_convenience;
/* setup the stream -> packet parser */
transport->packet = packet_init(transport);
packet_set_error_handler(transport->packet, smbcli_transport_error);
packet_set_event_context(transport->packet, transport->socket->event.ctx);
packet_set_nofree(transport->packet);
+ packet_set_initial_read(transport->packet, 4);
smbcli_init_signing(transport);
status = nbt_name_dup(transport, called, &transport->called);
if (!NT_STATUS_IS_OK(status)) goto failed;
- status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience, &calling_blob, calling);
+ status = nbt_name_to_blob(tmp_ctx, &calling_blob, calling);
if (!NT_STATUS_IS_OK(status)) goto failed;
- status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience, &called_blob, called);
+ status = nbt_name_to_blob(tmp_ctx, &called_blob, called);
if (!NT_STATUS_IS_OK(status)) goto failed;
/* allocate output buffer */
return mid;
}
-static void idle_handler(struct event_context *ev,
- struct timed_event *te, struct timeval t, void *private)
+static void idle_handler(struct tevent_context *ev,
+ struct tevent_timer *te, struct timeval t, void *private_data)
{
- struct smbcli_transport *transport = talloc_get_type(private,
+ struct smbcli_transport *transport = talloc_get_type(private_data,
struct smbcli_transport);
struct timeval next = timeval_add(&t, 0, transport->idle.period);
transport->socket->event.te = event_add_timed(transport->socket->event.ctx,
transport,
next,
idle_handler, transport);
- transport->idle.func(transport, transport->idle.private);
+ transport->idle.func(transport, transport->idle.private_data);
}
/*
_PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport,
void (*idle_func)(struct smbcli_transport *, void *),
uint64_t period,
- void *private)
+ void *private_data)
{
transport->idle.func = idle_func;
- transport->idle.private = private;
+ transport->idle.private_data = private_data;
transport->idle.period = period;
if (transport->socket->event.te != NULL) {
we have a full request in our receive buffer - match it to a pending request
and process
*/
-static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob)
+static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob)
{
- struct smbcli_transport *transport = talloc_get_type(private,
+ struct smbcli_transport *transport = talloc_get_type(private_data,
struct smbcli_transport);
uint8_t *buffer, *hdr, *vwv;
int len;
smb_setup_bufinfo(req);
if (!(req->flags2 & FLAGS2_32_BIT_ERROR_CODES)) {
- int class = CVAL(req->in.hdr,HDR_RCLS);
+ int eclass = CVAL(req->in.hdr,HDR_RCLS);
int code = SVAL(req->in.hdr,HDR_ERR);
- if (class == 0 && code == 0) {
+ if (eclass == 0 && code == 0) {
transport->error.e.nt_status = NT_STATUS_OK;
} else {
- transport->error.e.nt_status = NT_STATUS_DOS(class, code);
+ transport->error.e.nt_status = NT_STATUS_DOS(eclass, code);
}
} else {
transport->error.e.nt_status = NT_STATUS(IVAL(req->in.hdr, HDR_RCLS));
/*
handle timeouts of individual smb requests
*/
-static void smbcli_timeout_handler(struct event_context *ev, struct timed_event *te,
- struct timeval t, void *private)
+static void smbcli_timeout_handler(struct tevent_context *ev, struct tevent_timer *te,
+ struct timeval t, void *private_data)
{
- struct smbcli_request *req = talloc_get_type(private, struct smbcli_request);
+ struct smbcli_request *req = talloc_get_type(private_data, struct smbcli_request);
if (req->state == SMBCLI_REQUEST_RECV) {
DLIST_REMOVE(req->transport->pending_recv, req);
return;
}
+ packet_queue_run(req->transport->packet);
+ if (req->transport->socket->sock == NULL) {
+ req->state = SMBCLI_REQUEST_ERROR;
+ req->status = NT_STATUS_NET_WRITE_FAULT;
+ return;
+ }
+
if (req->one_way_request) {
req->state = SMBCLI_REQUEST_DONE;
smbcli_request_destroy(req);