r23959: add more monitor messages support that's been sitting around on my
[bbaumbach/samba-autobuild/.git] / source4 / libnet / libnet_domain.c
index 864141fffa74a2ba5b6df350c7bf823f904656a7..d2be697055d2243a58a9b275cf4e46fb338534bb 100644 (file)
@@ -1,11 +1,11 @@
- /* 
+/* 
    Unix SMB/CIFS implementation.
 
    Copyright (C) Rafal Szczesniak 2005
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
@@ -101,6 +100,15 @@ static void continue_domain_open_close(struct rpc_request *req)
        c->status = dcerpc_ndr_request_recv(req);
        if (!composite_is_ok(c)) return;
 
+       if (s->monitor_fn) {
+               struct monitor_msg msg;
+               
+               msg.type = rpc_close;
+               msg.data = NULL;
+               msg.data_size = 0;
+               s->monitor_fn(&msg);
+       }
+
        /* reset domain handle and associated data in libnet_context */
        s->ctx->samr.name        = NULL;
        s->ctx->samr.access_mask = 0;
@@ -137,6 +145,15 @@ static void continue_domain_open_connect(struct rpc_request *req)
        c->status = dcerpc_ndr_request_recv(req);
        if (!composite_is_ok(c)) return;
 
+       if (s->monitor_fn) {
+               struct monitor_msg msg;
+
+               msg.type = rpc_connect;
+               msg.data = NULL;
+               msg.data_size = 0;
+               s->monitor_fn(&msg);
+       }
+
        r = &s->lookup;
 
        /* prepare for samr_LookupDomain call */
@@ -166,6 +183,18 @@ static void continue_domain_open_lookup(struct rpc_request *req)
        /* receive samr_LookupDomain reply */
        c->status = dcerpc_ndr_request_recv(req);
 
+       if (s->monitor_fn) {
+               struct monitor_msg msg;
+               struct msg_rpc_lookup_domain data;
+
+               data.domain_name = s->domain_name.string;
+
+               msg.type = rpc_lookup_domain;
+               msg.data = (void*)&data;
+               msg.data_size = sizeof(data);
+               s->monitor_fn(&msg);
+       }
+
        r = &s->open;
 
        /* check the rpc layer status */
@@ -205,6 +234,15 @@ static void continue_domain_open_open(struct rpc_request *req)
        c->status = dcerpc_ndr_request_recv(req);
        if (!composite_is_ok(c)) return;
 
+       if (s->monitor_fn) {
+               struct monitor_msg msg;
+               
+               msg.type = rpc_open_domain;
+               msg.data = NULL;
+               msg.data_size = 0;
+               s->monitor_fn(&msg);
+       }
+
        composite_done(c);
 }
 
@@ -249,7 +287,7 @@ struct composite_context *libnet_DomainOpenSamr_send(struct libnet_context *ctx,
                s->rpcconn.in.dcerpc_iface = &dcerpc_table_samr;
                
                /* send rpc pipe connect request */
-               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn);
+               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn, s->monitor_fn);
                if (composite_nomem(rpcconn_req, c)) return c;
 
                composite_continue(c, rpcconn_req, continue_domain_open_rpc_connect, c);
@@ -390,7 +428,7 @@ struct composite_context* libnet_DomainOpenLsa_send(struct libnet_context *ctx,
                s->rpcconn.in.dcerpc_iface = &dcerpc_table_lsarpc;
                
                /* send rpc pipe connect request */
-               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn);
+               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn, s->monitor_fn);
                if (composite_nomem(rpcconn_req, c)) return c;
 
                composite_continue(c, rpcconn_req, continue_rpc_connect_lsa, c);
@@ -1080,7 +1118,7 @@ struct composite_context* libnet_DomainList_send(struct libnet_context *ctx,
                s->rpcconn.in.name         = s->hostname;
                s->rpcconn.in.dcerpc_iface = &dcerpc_table_samr;
 
-               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn);
+               rpcconn_req = libnet_RpcConnect_send(ctx, c, &s->rpcconn, s->monitor_fn);
                if (composite_nomem(rpcconn_req, c)) return c;
                
                composite_continue(c, rpcconn_req, continue_rpc_connect, c);