Remove useless layer of indirection, where every service called
[jelmer/samba4-debian.git] / source / rpc_server / service_rpc.c
index 9cce5292381311d22557f0f06cb14ad6821cbf76..ddcf1c2a999166172aec47e42e207786a3c57c26 100644 (file)
@@ -232,7 +232,8 @@ static NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx,
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
+       status = stream_setup_socket(event_ctx, lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
                                     "unix", e->ep_description->endpoint, &port, 
                                     lp_socket_options(lp_ctx), 
                                     dcesrv_sock);
@@ -271,7 +272,8 @@ static NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx,
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
+       status = stream_setup_socket(event_ctx, lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
                                     "unix", full_path, &port, 
                                     lp_socket_options(lp_ctx), 
                                     dcesrv_sock);
@@ -352,7 +354,8 @@ static NTSTATUS add_socket_rpc_tcp_iface(struct dcesrv_context *dce_ctx, struct
        dcesrv_sock->endpoint           = e;
        dcesrv_sock->dcesrv_ctx         = talloc_reference(dcesrv_sock, dce_ctx);
 
-       status = stream_setup_socket(event_ctx, model_ops, &dcesrv_stream_ops, 
+       status = stream_setup_socket(event_ctx, dce_ctx->lp_ctx,
+                                    model_ops, &dcesrv_stream_ops, 
                                     "ipv4", address, &port, 
                                     lp_socket_options(dce_ctx->lp_ctx), 
                                     dcesrv_sock);
@@ -377,10 +380,15 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx,
 
        /* Add TCP/IP sockets */
        if (lp_interfaces(lp_ctx) && lp_bind_interfaces_only(lp_ctx)) {
-               int num_interfaces = iface_count();
+               int num_interfaces;
                int i;
+               struct interface *ifaces;
+
+               load_interfaces(dce_ctx, lp_interfaces(lp_ctx), &ifaces);
+
+               num_interfaces = iface_count(ifaces);
                for(i = 0; i < num_interfaces; i++) {
-                       const char *address = iface_n_ip(i);
+                       const char *address = iface_n_ip(ifaces, i);
                        status = add_socket_rpc_tcp_iface(dce_ctx, e, event_ctx, model_ops, address);
                        NT_STATUS_NOT_OK_RETURN(status);
                }
@@ -449,20 +457,9 @@ failed:
        task_server_terminate(task, "Failed to startup dcerpc server task");    
 }
 
-/*
-  called on startup of the smb server service It's job is to start
-  listening on all configured sockets
-*/
-static NTSTATUS dcesrv_init(struct event_context *event_context, 
-                           struct loadparm_context *lp_ctx,
-                           const struct model_ops *model_ops)
-{      
-       return task_server_startup(event_context, model_ops, dcesrv_task_init);
-}
-
 NTSTATUS server_service_rpc_init(void)
 {
-       init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
+       init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES };
        init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
 
        run_init_functions(static_init);
@@ -470,5 +467,5 @@ NTSTATUS server_service_rpc_init(void)
 
        talloc_free(shared_init);
        
-       return register_server_service("rpc", dcesrv_init);
+       return register_server_service("rpc", dcesrv_task_init);
 }