Author: jelmer
Date: 2005-09-28 14:35:51 +0000 (Wed, 28 Sep 2005)
New Revision: 10580

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10580

Log:
More generic approach for adding endpoints

Modified:
   branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c
   branches/SAMBA_4_0/source/rpc_server/dcerpc_sock.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c        2005-09-28 
14:12:09 UTC (rev 10579)
+++ branches/SAMBA_4_0/source/rpc_server/dcerpc_server.c        2005-09-28 
14:35:51 UTC (rev 10580)
@@ -30,6 +30,7 @@
 #include "rpc_server/dcerpc_server.h"
 #include "lib/events/events.h"
 #include "smbd/service_stream.h"
+#include "system/filesys.h"
 
 /*
   see if two endpoints match
@@ -1286,12 +1287,13 @@
 }
 
 /*
-  initialise the dcerpc server context for socket based services
+  initialise the dcerpc server context 
 */
 static NTSTATUS dcesrv_init(struct event_context *event_context, const struct 
model_ops *model_ops)
 {
        NTSTATUS status;
        struct dcesrv_context *dce_ctx;
+       struct dcesrv_endpoint *e;
 
        status = dcesrv_init_context(event_context,
                                     lp_dcerpc_endpoint_servers(),
@@ -1299,10 +1301,41 @@
                                     &dce_ctx);
        NT_STATUS_NOT_OK_RETURN(status);
 
-       return dcesrv_sock_init(dce_ctx, event_context, model_ops);
+       /* Make sure the directory for NCALRPC exists */
+       if (!directory_exist(lp_ncalrpc_dir())) {
+               mkdir(lp_ncalrpc_dir(), 0755);
+       }
+
+       for (e=dce_ctx->endpoint_list;e;e=e->next) {
+               switch (e->ep_description->transport) {
+               case NCACN_UNIX_STREAM:
+                       status = dcesrv_add_ep_unix(dce_ctx, e, event_context, 
model_ops);
+                       NT_STATUS_NOT_OK_RETURN(status);
+                       break;
+               
+               case NCALRPC:
+                       status = dcesrv_add_ep_ncalrpc(dce_ctx, e, 
event_context, model_ops);
+                       NT_STATUS_NOT_OK_RETURN(status);
+                       break;
+
+               case NCACN_IP_TCP:
+                       status = dcesrv_add_ep_tcp(dce_ctx, e, event_context, 
model_ops);
+                       NT_STATUS_NOT_OK_RETURN(status);
+                       break;
+                       
+               case NCACN_NP:
+/*                     FIXME: status = dcesrv_add_ep_np(dce_ctx, e, 
event_context, model_ops);
+                       NT_STATUS_NOT_OK_RETURN(status); */
+                       break;
+
+               default:
+                       return NT_STATUS_NOT_SUPPORTED;
+               }
+       }
+
+       return NT_STATUS_OK;    
 }
 
-
 NTSTATUS server_service_rpc_init(void)
 {
        return register_server_service("rpc", dcesrv_init);

Modified: branches/SAMBA_4_0/source/rpc_server/dcerpc_sock.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/dcerpc_sock.c  2005-09-28 14:12:09 UTC 
(rev 10579)
+++ branches/SAMBA_4_0/source/rpc_server/dcerpc_sock.c  2005-09-28 14:35:51 UTC 
(rev 10580)
@@ -157,7 +157,7 @@
 
 
 
-static NTSTATUS add_socket_rpc_unix(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
+NTSTATUS dcesrv_add_ep_unix(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
                                    struct event_context *event_ctx, const 
struct model_ops *model_ops)
 {
        struct dcesrv_socket_context *dcesrv_sock;
@@ -182,7 +182,7 @@
        return status;
 }
 
-static NTSTATUS add_socket_rpc_ncalrpc(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
+NTSTATUS dcesrv_add_ep_ncalrpc(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
                                       struct event_context *event_ctx, const 
struct model_ops *model_ops)
 {
        struct dcesrv_socket_context *dcesrv_sock;
@@ -251,7 +251,7 @@
        return status;
 }
 
-static NTSTATUS add_socket_rpc_tcp(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
+NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx, struct 
dcesrv_endpoint *e,
                                   struct event_context *event_ctx, const 
struct model_ops *model_ops)
 {
        NTSTATUS status;
@@ -273,42 +273,4 @@
        return NT_STATUS_OK;
 }
 
-/****************************************************************************
- Open the listening sockets for RPC over NCACN_IP_TCP/NCALRPC/NCACN_UNIX_STREAM
-****************************************************************************/
-NTSTATUS dcesrv_sock_init(struct dcesrv_context *dce_ctx, 
-                         struct event_context *event_ctx, const struct 
model_ops *model_ops)
-{
-       struct dcesrv_endpoint *e;
-       NTSTATUS status;
 
-       /* Make sure the directory for NCALRPC exists */
-       if (!directory_exist(lp_ncalrpc_dir())) {
-               mkdir(lp_ncalrpc_dir(), 0755);
-       }
-
-       for (e=dce_ctx->endpoint_list;e;e=e->next) {
-               switch (e->ep_description->transport) {
-               case NCACN_UNIX_STREAM:
-                       status = add_socket_rpc_unix(dce_ctx, e, event_ctx, 
model_ops);
-                       NT_STATUS_NOT_OK_RETURN(status);
-                       break;
-               
-               case NCALRPC:
-                       status = add_socket_rpc_ncalrpc(dce_ctx, e, event_ctx, 
model_ops);
-                       NT_STATUS_NOT_OK_RETURN(status);
-                       break;
-
-               case NCACN_IP_TCP:
-                       status = add_socket_rpc_tcp(dce_ctx, e, event_ctx, 
model_ops);
-                       NT_STATUS_NOT_OK_RETURN(status);
-                       break;
-
-               default:
-                       break;
-               }
-       }
-
-       return NT_STATUS_OK;    
-}
-

Reply via email to