summaryrefslogtreecommitdiff
path: root/source4/libcli/raw
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r--source4/libcli/raw/clisocket.c27
-rw-r--r--source4/libcli/raw/clitransport.c45
-rw-r--r--source4/libcli/raw/rawrequest.c1
3 files changed, 40 insertions, 33 deletions
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 78a096fb8f..f9e662714b 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -65,16 +65,17 @@ struct smbcli_socket *smbcli_sock_init(TALLOC_CTX *mem_ctx,
}
static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
- const char *hostaddr, int port);
+ const char *hostaddr, int port,
+ struct composite_context *c);
/*
handle socket write events during an async connect. These happen when the OS
has either completed the connect() or has returned an error
*/
static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_event *fde,
- struct timeval t, uint16_t flags)
+ struct timeval t, uint16_t flags, void *private)
{
- struct composite_context *c = talloc_get_type(fde->private, struct composite_context);
+ struct composite_context *c = talloc_get_type(private, struct composite_context);
struct clisocket_connect *conn = talloc_get_type(c->private, struct clisocket_connect);
int i;
@@ -94,10 +95,9 @@ static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_even
conn->port_num = i;
c->status = smbcli_sock_connect_one(conn->sock,
conn->dest_host,
- conn->iports[i]);
+ conn->iports[i], c);
if (NT_STATUS_IS_OK(c->status) ||
NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- conn->sock->event.fde->private = c;
return;
}
}
@@ -113,9 +113,9 @@ static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_even
try to connect to the given address/port
*/
static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
- const char *hostaddr, int port)
+ const char *hostaddr, int port,
+ struct composite_context *c)
{
- struct fd_event fde;
NTSTATUS status;
if (sock->sock) {
@@ -133,15 +133,11 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
/* we initially look for write - see the man page on
non-blocking connect */
- fde.fd = socket_get_fd(sock->sock);
- fde.flags = EVENT_FD_WRITE;
- fde.handler = smbcli_sock_connect_handler;
- fde.private = sock;
-
- sock->event.fde = event_add_fd(sock->event.ctx, &fde, sock);
+ sock->event.fde = event_add_fd(sock->event.ctx, sock, socket_get_fd(sock->sock),
+ EVENT_FD_WRITE, smbcli_sock_connect_handler, c);
sock->port = port;
- set_blocking(fde.fd, False);
+ set_blocking(socket_get_fd(sock->sock), False);
return socket_connect(sock->sock, NULL, 0, hostaddr, port, 0);
}
@@ -200,10 +196,9 @@ struct composite_context *smbcli_sock_connect_send(struct smbcli_socket *sock,
conn->sock->port = conn->iports[i];
c->status = smbcli_sock_connect_one(sock,
conn->dest_host,
- conn->iports[i]);
+ conn->iports[i], c);
if (NT_STATUS_IS_OK(c->status) ||
NT_STATUS_EQUAL(c->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- sock->event.fde->private = c;
return c;
}
}
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 1904618be9..21303a34aa 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -33,11 +33,13 @@ static void smbcli_transport_process_send(struct smbcli_transport *transport);
/*
an event has happened on the socket
*/
-static void smbcli_transport_event_handler(struct event_context *ev, struct fd_event *fde,
- struct timeval t, uint16_t flags)
+static void smbcli_transport_event_handler(struct event_context *ev,
+ struct fd_event *fde,
+ struct timeval t,
+ uint16_t flags, void *private)
{
- struct smbcli_transport *transport = fde->private;
-
+ struct smbcli_transport *transport = talloc_get_type(private,
+ struct smbcli_transport);
if (flags & EVENT_FD_READ) {
smbcli_transport_process_recv(transport);
return;
@@ -87,9 +89,13 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
/* take over event handling from the socket layer - it only
handles events up until we are connected */
- transport->socket->event.fde->handler = smbcli_transport_event_handler;
- transport->socket->event.fde->private = transport;
- transport->socket->event.fde->flags = EVENT_FD_READ;
+ talloc_free(transport->socket->event.fde);
+ transport->socket->event.fde = event_add_fd(transport->socket->event.ctx,
+ transport->socket,
+ socket_get_fd(transport->socket->sock),
+ EVENT_FD_READ,
+ smbcli_transport_event_handler,
+ transport);
talloc_set_destructor(transport, transport_destructor);
@@ -132,7 +138,8 @@ void smbcli_transport_dead(struct smbcli_transport *transport)
*/
static void smbcli_transport_write_enable(struct smbcli_transport *transport)
{
- transport->socket->event.fde->flags |= EVENT_FD_WRITE;
+ struct fd_event *fde = transport->socket->event.fde;
+ EVENT_FD_WRITEABLE(fde);
}
/*
@@ -140,7 +147,8 @@ static void smbcli_transport_write_enable(struct smbcli_transport *transport)
*/
static void smbcli_transport_write_disable(struct smbcli_transport *transport)
{
- transport->socket->event.fde->flags &= ~EVENT_FD_WRITE;
+ struct fd_event *fde = transport->socket->event.fde;
+ EVENT_FD_NOT_WRITEABLE(fde);
}
/*
@@ -296,10 +304,15 @@ again:
}
static void idle_handler(struct event_context *ev,
- struct timed_event *te, struct timeval t)
+ struct timed_event *te, struct timeval t, void *private)
{
- struct smbcli_transport *transport = te->private;
- te->next_event = timeval_add(&te->next_event, 0, transport->idle.period);
+ struct smbcli_transport *transport = talloc_get_type(private,
+ 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);
}
@@ -312,7 +325,6 @@ void smbcli_transport_idle_handler(struct smbcli_transport *transport,
uint64_t period,
void *private)
{
- struct timed_event te;
transport->idle.func = idle_func;
transport->idle.private = private;
transport->idle.period = period;
@@ -321,11 +333,10 @@ void smbcli_transport_idle_handler(struct smbcli_transport *transport,
talloc_free(transport->socket->event.te);
}
- te.next_event = timeval_current_ofs(0, period);
- te.handler = idle_handler;
- te.private = transport;
transport->socket->event.te = event_add_timed(transport->socket->event.ctx,
- &te, transport);
+ transport,
+ timeval_current_ofs(0, period),
+ idle_handler, transport);
}
/*
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 7dbe6b3468..420ce0a3a2 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -26,6 +26,7 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "dlinklist.h"
+#include "events.h"
/* we over allocate the data buffer to prevent too many realloc calls */
#define REQ_OVER_ALLOCATION 0