s4:rpc_server: only use context within op_bind() hooks and dcesrv_interface_bind_...
[samba.git] / source4 / rpc_server / echo / rpc_echo.c
index f188ef0a0d7ffedbb9c547def4806264ebc93a44..e00eaecbd456cc4072623d7bbc003a09ae4c90d7 100644 (file)
 #include "librpc/gen_ndr/ndr_echo.h"
 #include "lib/events/events.h"
 
+#define DCESRV_INTERFACE_RPCECHO_BIND(call, iface) \
+       dcesrv_interface_rpcecho_bind(call, iface)
+static NTSTATUS dcesrv_interface_rpcecho_bind(struct dcesrv_call_state *dce_call,
+                                             const struct dcesrv_interface *iface)
+{
+       struct dcesrv_connection_context *context = dce_call->context;
+       return dcesrv_interface_bind_allow_connect(context, iface);
+}
 
 static NTSTATUS dcesrv_echo_AddOne(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_AddOne *r)
 {
@@ -39,7 +47,7 @@ static NTSTATUS dcesrv_echo_EchoData(struct dcesrv_call_state *dce_call, TALLOC_
                return NT_STATUS_OK;
        }
 
-       r->out.out_data = talloc_memdup(mem_ctx, r->in.in_data, r->in.len);
+       r->out.out_data = (uint8_t *)talloc_memdup(mem_ctx, r->in.in_data, r->in.len);
        if (!r->out.out_data) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -54,7 +62,7 @@ static NTSTATUS dcesrv_echo_SinkData(struct dcesrv_call_state *dce_call, TALLOC_
 
 static NTSTATUS dcesrv_echo_SourceData(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_SourceData *r)
 {
-       int i;
+       unsigned int i;
 
        r->out.data = talloc_array(mem_ctx, uint8_t, r->in.len);
        if (!r->out.data) {
@@ -156,10 +164,10 @@ struct echo_TestSleep_private {
        struct echo_TestSleep *r;
 };
 
-static void echo_TestSleep_handler(struct event_context *ev, struct timed_event *te, 
-                                  struct timeval t, void *private)
+static void echo_TestSleep_handler(struct tevent_context *ev, struct tevent_timer *te, 
+                                  struct timeval t, void *private_data)
 {
-       struct echo_TestSleep_private *p = talloc_get_type(private
+       struct echo_TestSleep_private *p = talloc_get_type(private_data,
                                                           struct echo_TestSleep_private);
        struct echo_TestSleep *r = p->r;
        NTSTATUS status;
@@ -192,7 +200,7 @@ static long dcesrv_echo_TestSleep(struct dcesrv_call_state *dce_call, TALLOC_CTX
        p->dce_call     = dce_call;
        p->r            = r;
 
-       event_add_timed(dce_call->event_ctx, p, 
+       tevent_add_timer(dce_call->event_ctx, p,
                        timeval_add(&dce_call->time, r->in.seconds, 0),
                        echo_TestSleep_handler, p);