summaryrefslogtreecommitdiffstats
path: root/source4/libcli
diff options
context:
space:
mode:
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/composite/composite.c1
-rw-r--r--source4/libcli/config.mk3
-rw-r--r--source4/libcli/nbt/nbtsocket.c38
-rw-r--r--source4/libcli/raw/clisocket.c27
-rw-r--r--source4/libcli/raw/clitransport.c45
-rw-r--r--source4/libcli/raw/rawrequest.c1
-rw-r--r--source4/libcli/resolve/host.c12
-rw-r--r--source4/libcli/resolve/resolve.c1
8 files changed, 64 insertions, 64 deletions
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 998631204d1..e08543a94bf 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -22,6 +22,7 @@
*/
#include "includes.h"
+#include "events.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/composite/composite.h"
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index 8458eb780d5..038b8e0ccbe 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -14,6 +14,7 @@ REQUIRED_SUBSYSTEMS = RPC_NDR_LSA
[SUBSYSTEM::LIBCLI_COMPOSITE_BASE]
ADD_OBJ_FILES = \
libcli/composite/composite.o
+REQUIRED_SUBSYSTEMS = LIBEVENTS
[SUBSYSTEM::LIBCLI_COMPOSITE]
ADD_OBJ_FILES = \
@@ -31,7 +32,7 @@ ADD_OBJ_FILES = \
libcli/nbt/namequery.o \
libcli/nbt/nameregister.o \
libcli/nbt/namerefresh.o
-REQUIRED_SUBSYSTEMS = LIBNDR_RAW NDR_NBT SOCKET LIBCLI_COMPOSITE_BASE
+REQUIRED_SUBSYSTEMS = LIBNDR_RAW NDR_NBT SOCKET LIBCLI_COMPOSITE_BASE LIBEVENTS
[SUBSYSTEM::LIBCLI_RESOLVE]
ADD_OBJ_FILES = \
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 3d1397e019a..8e6fda1ece0 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -49,11 +49,11 @@ static int nbt_name_request_destructor(void *ptr)
req->te = NULL;
}
if (req->nbtsock->send_queue == NULL) {
- req->nbtsock->fde->flags &= ~EVENT_FD_WRITE;
+ EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
}
if (req->nbtsock->num_pending == 0 &&
req->nbtsock->incoming.handler == NULL) {
- req->nbtsock->fde->flags &= ~EVENT_FD_READ;
+ EVENT_FD_NOT_READABLE(req->nbtsock->fde);
}
return 0;
}
@@ -86,12 +86,12 @@ static void nbt_name_socket_send(struct nbt_name_socket *nbtsock)
talloc_free(req);
} else {
req->state = NBT_REQUEST_WAIT;
- nbtsock->fde->flags |= EVENT_FD_READ;
+ EVENT_FD_READABLE(nbtsock->fde);
nbtsock->num_pending++;
}
}
- nbtsock->fde->flags &= ~EVENT_FD_WRITE;
+ EVENT_FD_NOT_WRITEABLE(nbtsock->fde);
talloc_free(tmp_ctx);
return;
@@ -210,9 +210,9 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
handle fd events on a nbt_name_socket
*/
static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *fde,
- struct timeval t, uint16_t flags)
+ struct timeval t, uint16_t flags, void *private)
{
- struct nbt_name_socket *nbtsock = talloc_get_type(fde->private,
+ struct nbt_name_socket *nbtsock = talloc_get_type(private,
struct nbt_name_socket);
if (flags & EVENT_FD_WRITE) {
nbt_name_socket_send(nbtsock);
@@ -231,7 +231,6 @@ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
{
struct nbt_name_socket *nbtsock;
NTSTATUS status;
- struct fd_event fde;
nbtsock = talloc(mem_ctx, struct nbt_name_socket);
if (nbtsock == NULL) goto failed;
@@ -255,11 +254,9 @@ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
nbtsock->num_pending = 0;
nbtsock->incoming.handler = NULL;
- fde.fd = socket_get_fd(nbtsock->sock);
- fde.flags = 0;
- fde.handler = nbt_name_socket_handler;
- fde.private = nbtsock;
- nbtsock->fde = event_add_fd(nbtsock->event_ctx, &fde, nbtsock);
+ nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
+ socket_get_fd(nbtsock->sock), 0,
+ nbt_name_socket_handler, nbtsock);
return nbtsock;
@@ -272,9 +269,9 @@ failed:
handle a request timeout
*/
static void nbt_name_socket_timeout(struct event_context *ev, struct timed_event *te,
- struct timeval t)
+ struct timeval t, void *private)
{
- struct nbt_name_request *req = talloc_get_type(te->private,
+ struct nbt_name_request *req = talloc_get_type(private,
struct nbt_name_request);
nbt_name_request_destructor(req);
if (req->num_replies == 0) {
@@ -299,7 +296,6 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
BOOL allow_multiple_replies)
{
struct nbt_name_request *req;
- struct timed_event te;
int id;
NTSTATUS status;
@@ -335,10 +331,8 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
request->name_trn_id = id;
req->name_trn_id = id;
- te.next_event = timeout;
- te.handler = nbt_name_socket_timeout;
- te.private = req;
- req->te = event_add_timed(nbtsock->event_ctx, &te, req);
+ req->te = event_add_timed(nbtsock->event_ctx, req, timeout,
+ nbt_name_socket_timeout, req);
talloc_set_destructor(req, nbt_name_request_destructor);
@@ -358,7 +352,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
NDR_PRINT_DEBUG(nbt_name_packet, request);
}
- nbtsock->fde->flags |= EVENT_FD_WRITE;
+ EVENT_FD_WRITEABLE(nbtsock->fde);
return req;
@@ -403,7 +397,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
- nbtsock->fde->flags |= EVENT_FD_WRITE;
+ EVENT_FD_WRITEABLE(nbtsock->fde);
return NT_STATUS_OK;
@@ -442,7 +436,7 @@ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
{
nbtsock->incoming.handler = handler;
nbtsock->incoming.private = private;
- nbtsock->fde->flags |= EVENT_FD_READ;
+ EVENT_FD_READABLE(nbtsock->fde);
return NT_STATUS_OK;
}
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 78a096fb8fb..f9e662714b4 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 1904618be93..21303a34aa8 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 7dbe6b34681..420ce0a3a20 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
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 9bf278154d9..977c804a4ac 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -83,9 +83,9 @@ static void run_child(struct composite_context *c, int fd)
handle a read event on the pipe
*/
static void pipe_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 host_state *state = talloc_get_type(c->private, struct host_state);
char address[128];
int ret;
@@ -136,7 +136,6 @@ struct composite_context *resolve_name_host_send(struct nbt_name *name,
struct host_state *state;
NTSTATUS status;
int fd[2] = { -1, -1 };
- struct fd_event fde;
int ret;
c = talloc_zero(NULL, struct composite_context);
@@ -161,11 +160,8 @@ struct composite_context *resolve_name_host_send(struct nbt_name *name,
/* we need to put the child in our event context so
we know when the gethostbyname() has finished */
- fde.fd = state->child_fd;
- fde.flags = EVENT_FD_READ;
- fde.handler = pipe_handler;
- fde.private = c;
- state->fde = event_add_fd(c->event_ctx, &fde, state);
+ state->fde = event_add_fd(c->event_ctx, state, state->child_fd, EVENT_FD_READ,
+ pipe_handler, c);
if (state->fde == NULL) {
close(fd[0]);
close(fd[1]);
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index eb35a7cb996..e2e94625619 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -21,6 +21,7 @@
*/
#include "includes.h"
+#include "events.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/composite/composite.h"