r3043: Use binding strings for specifying endpoints. The property for
authorJelmer Vernooij <jelmer@samba.org>
Mon, 18 Oct 2004 15:18:05 +0000 (15:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:01:53 +0000 (13:01 -0500)
specifying a endpoint is now also 'endpoint' instead of 'endpoints'. The
default endpoint (if none is specified) is still "ncacn_np:[\\pipe\\ifacename]",
where ifacename is the name of the interface.

Examples:

[
  uuid(60a15ec5-4de8-11d7-a637-005056a20182),
  endpoint("ncacn_np:[\\pipe\\rpcecho]", "ncacn_ip_tcp:")
]
interface rpcecho
{
void dummy();
}

dcerpc_binding is now converted to ep_description in the server, but I hope to
completely eliminate ep_description later on.

The eventual goal of all these changes is to make it easier to add
 transports as I'm going to add support for
 ncalrpc (local RPC over named pipes) and ncacn_unix_stream (Unix sockets).
(This used to be commit f3da7c8b443a29b0c656c687a277384ae1353792)

17 files changed:
source4/build/pidl/parser.pm
source4/librpc/idl/drsuapi.idl
source4/librpc/idl/echo.idl
source4/librpc/idl/epmapper.idl
source4/librpc/idl/lsa.idl
source4/librpc/idl/lsads.idl
source4/librpc/idl/netlogon.idl
source4/librpc/idl/oxidresolver.idl
source4/librpc/idl/samr.idl
source4/librpc/idl/spoolss.idl
source4/librpc/idl/w32time.idl
source4/librpc/idl/winreg.idl
source4/librpc/rpc/dcerpc_smb.c
source4/librpc/rpc/dcerpc_util.c
source4/ntvfs/ipc/vfs_ipc.c
source4/rpc_server/dcerpc_server.c
source4/rpc_server/epmapper/rpc_epmapper.c

index 7d7ee7a163266eab42ce0618b79f00dd0b028e0a..15dd1cd70e5b1989fad2c3416caca8b28bf37bf9 100644 (file)
@@ -1482,20 +1482,18 @@ sub FunctionTable($)
        }
        pidl "\t{ NULL, 0, NULL, NULL }\n};\n\n";
 
-       my $endpoints;
-
-       if (! defined $interface->{PROPERTIES}->{endpoints}) {
-               $interface->{PROPERTIES}->{endpoints} = $interface->{NAME};
+       # If no endpoint is set, default to the interface name as a named pipe
+       if (! defined $interface->{PROPERTIES}->{endpoint}) {
+               $interface->{PROPERTIES}->{endpoint} = "\"ncacn_np:[\\\\pipe\\\\" . $interface->{NAME} . "]\"";
        }
 
-       my @e = split / /, $interface->{PROPERTIES}->{endpoints};
+       my @e = split / /, $interface->{PROPERTIES}->{endpoint};
        my $endpoint_count = $#e + 1;
 
-       pidl "static const char * const $interface->{NAME}\_endpoint_strings[] = {\n\t";
-       for (my $i=0; $i < $#e; $i++) {
-               pidl "\"$e[$i]\", ";
+       pidl "static const char * const $interface->{NAME}\_endpoint_strings[] = {\n";
+       foreach my $ep (@e) {
+               pidl "\t$ep, \n";
        }
-       pidl "\"$e[$#e]\"\n";
        pidl "};\n\n";
 
        pidl "static const struct dcerpc_endpoint_list $interface->{NAME}\_endpoints = {\n";
index a59dec5a290a0acf55ed55c3c33106075b50c5a1..15ebb6077d58500e7e4051dc74e9acb2c1a18406 100644 (file)
@@ -3,7 +3,7 @@
 [ 
   uuid(e3514235-4b06-11d1-ab04-00c04fc2dcd2),
   version(4.0),
-  endpoints(lsass,protected_storage,TCP-0),
+  endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]","ncacn_ip_tcp:"),
   helpstring("Active Directory Replication"),
   pointer_default(unique)
 ] 
index f8cc73451387445e9ec01e80622f6088f83e5534..e54b3914f87176c6b8126364e0255bfeca7af940 100644 (file)
@@ -3,7 +3,7 @@
 
 [
   uuid(60a15ec5-4de8-11d7-a637-005056a20182),
-  endpoints(rpcecho, TCP-0),
+  endpoint("ncacn_np:[\\pipe\\rpcecho]", "ncacn_ip_tcp:"),
   version(1.0),
   helpstring("Simple echo pipe")
 ]
index 18bb6bf7d7e7267cb678eee2c6e3af0bb947aca8..eaf2b185f658dce3e661921b21683569b3ba77b9 100644 (file)
@@ -11,7 +11,7 @@ http://www.opengroup.org/onlinepubs/9629399/chap6.htm#tagcjh_11_02_03_01: bindin
 [
  uuid(e1af8308-5d1f-11c9-91a4-08002b14a0fa), 
  version(3.0), 
- endpoints(epmapper, TCP-135),
+ endpoint("ncacn_np:[\\pipe\\epmapper]", "ncacn_ip_tcp:[135]"),
  pointer_default(unique)
 ]
 interface epmapper
index fe3aa1d51b5df69d7f8170cf3bfdbf8fd73c7526..ca1090545aa7c8e0acb273ca7186eccea40c5fe7 100644 (file)
@@ -6,7 +6,7 @@
 
 [ uuid(12345778-1234-abcd-ef00-0123456789ab),
   version(0.0),
-  endpoints(lsarpc,lsass,TCP-0),
+  endpoint("ncacn_np:[\\pipe\\lsarpc]","ncacn_np:[\\pipe\\lsass]","ncacn_ip_tcp:"),
   pointer_default(unique),
   helpstring("Local Server Authentication(?)")
 ] interface lsarpc
index 53ff69d6870614c5f55c113be5d8d958594c95fb..3caed0f92fb7dc79d83c3cb71c0fba396d41e79f 100644 (file)
@@ -3,7 +3,7 @@
 [ 
   uuid(3919286a-b10c-11d0-9ba8-00c04fd92ef5),
   version(0.0),
-  endpoints(lsarpc,lsass),
+  endpoint("ncacn_np:[\\pipe\\lsarpc]","ncacn_np:[\\pipe\\lsass]"),
   pointer_default(unique)
 ] 
 interface lsads
index d52fd2e757a6ddff14fb7012d8015a7375ec5911..9e0c3c4576c3ccb99bc88f0a509046efb0cd377e 100644 (file)
@@ -9,7 +9,7 @@
 [
   uuid(12345678-1234-abcd-ef00-01234567cffb),
   version(1.0),
-  endpoints(netlogon,TCP-0),
+  endpoint("ncacn_np:[\\pipe\\netlogon]","ncacn_ip_tcp:"),
   pointer_default(unique)
 ]
 
index 1ef20e5bf0e83a042fc4d0a38616fa0497aae248..6354e7b38008fe6605effbd7a1ebe3a3053918aa 100644 (file)
@@ -15,7 +15,7 @@
 [ 
        uuid(99fcfec4-5260-101b-bbcb-00aa0021347a),
        helpstring("Object Exporter ID Resolver"),
-       endpoints(epmapper, TCP-135),
+       endpoint("ncacn_np:[\\pipe\\epmapper]", "ncacn_ip_tcp:[135]"),
        pointer_default(unique)
 ]
 interface IOXIDResolver
index 8feb726ac88f4738b4f48a25a11d3c487fc4f8a2..42a549cc5ca1d5fe85efd8887c516e274699326f 100644 (file)
@@ -10,7 +10,7 @@
 
 [ uuid(12345778-1234-abcd-ef00-0123456789ac),
   version(1.0),
-  endpoints(samr,TCP-0),
+  endpoint("ncacn_np:[\\pipe\\samr]","ncacn_ip_tcp:"),
   pointer_default(unique)
 ] interface samr
 {
index 4ee9eab90c61ae162dd1687d967ee5bb6a4cca65..be6dae084a7fbc5746374986b60c62e0c26950be 100644 (file)
@@ -6,7 +6,7 @@
 
 [ uuid(12345678-1234-abcd-ef00-0123456789ab),
   version(1.0),
-  endpoints(spoolss),
+  endpoint("ncacn_np:[\\pipe\\spoolss]"),
   pointer_default(unique),
   helpstring("Spooler SubSystem")
 ] interface spoolss
index 568f97ef1dd317836571234ae23e13b3207b4981..3ba1bc1ed1f0fefe23664ee2c2be4b64565352e6 100644 (file)
@@ -4,7 +4,7 @@
 
 [
   uuid(8fb6d884-2388-11d0-8c35-00c04fda2795),
-  endpoints(srvsvc,atsvc,browser,keysvc,wkssvc),
+  endpoint("ncacn_np:[\\pipe\\srvsvc]","ncacn_np:[\\pipe\\atsvc]","ncacn_np:[\\pipe\\browser]","ncacn_np:[\\pipe\\keysvc]","ncacn_np:[\\pipe\\wkssvc]"),
   version(4.1),
   helpstring("Win32 Time Server")
 ]
index 428345ff30ac609f75d9b568fe38995dc28e9aef..1f7123f7f379f8c132efe57b39e7b5aff98b3159 100644 (file)
@@ -6,7 +6,7 @@
 
 [ uuid(338cd001-2244-31f1-aaaa-900038001003),
   version(1.0),
-  endpoints(winreg,TCP-0),
+  endpoint("ncacn_np:[\\pipe\\winreg]","ncacn_ip_tcp:"),
   pointer_default(unique),
   helpstring("Remote Registry Service")
 ] interface winreg
index ffe7e55a8580732c0da9b04c944fea634690ce6b..cfb02680e22445072b52c46392290f9e8753b9d5 100644 (file)
@@ -372,14 +372,8 @@ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe **p,
 {
        struct smb_private *smb;
         NTSTATUS status;
-       char *name;
        union smb_open io;
 
-       name = talloc_asprintf(tree, "\\%s", pipe_name);
-       if (!name) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       
        io.ntcreatex.level = RAW_OPEN_NTCREATEX;
        io.ntcreatex.in.flags = 0;
        io.ntcreatex.in.root_fid = 0;
@@ -398,10 +392,9 @@ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe **p,
        io.ntcreatex.in.create_options = 0;
        io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
        io.ntcreatex.in.security_flags = 0;
-       io.ntcreatex.in.fname = name;
+       io.ntcreatex.in.fname = pipe_name;
 
-       status = smb_raw_open(tree, name, &io);
-       talloc_free(name);
+       status = smb_raw_open(tree, pipe_name, &io);
 
        if (!NT_STATUS_IS_OK(status)) {
                 return status;
index 747f8d1277ae98666ab64c107dbd3d05fb631bd9..a82f30f3e5e5afa1905d58835a85bfc7bf4b4430 100644 (file)
@@ -4,6 +4,7 @@
    dcerpc utility functions
 
    Copyright (C) Andrew Tridgell 2003
+   Copyright (C) Jelmer Vernooij 2004
    
    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
@@ -129,7 +130,6 @@ NTSTATUS dcerpc_epm_map_tcp_port(const char *server,
        return NT_STATUS_OK;
 }
 
-
 /*
   find the pipe name for a local IDL interface
 */
@@ -425,24 +425,39 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
        BOOL retry;
        struct smbcli_state *cli;
        const char *pipe_name;
+       TALLOC_CTX *mem_ctx = talloc_init("dcerpc_pipe_connect_ncacn_np");
        
        if (!binding->options || !binding->options[0] || !strlen(binding->options[0])) {
                const struct dcerpc_interface_table *table = idl_iface_by_uuid(pipe_uuid);
+               struct dcerpc_binding default_binding;
+               int i;
+
                if (!table) {
                        DEBUG(0,("Unknown interface endpoint '%s'\n", pipe_uuid));
+                       talloc_destroy(mem_ctx);
                        return NT_STATUS_INVALID_PARAMETER;
                }
-               /* only try the first endpoint for now */
-               pipe_name = table->endpoints->names[0];
+
+               /* Find one of the default pipes for this interface */
+               for (i = 0; i < table->endpoints->count; i++) {
+                       status = dcerpc_parse_binding(mem_ctx, table->endpoints->names[i], &default_binding);
+
+                       if (NT_STATUS_IS_OK(status) && default_binding.transport == ENDPOINT_SMB) {
+                               pipe_name = default_binding.options[0]; 
+                               break;
+                               
+                       }
+               }
        } else {
                pipe_name = binding->options[0];
        }
 
-       if (strncasecmp(pipe_name, "\\pipe\\", 6) == 0) {
-               pipe_name += 6;
+       if (!strncasecmp(pipe_name, "/pipe/", 6)) {
+               pipe_name+=6;
        }
-       if (strncasecmp(pipe_name, "/pipe/", 6) == 0) {
-               pipe_name += 6;
+       
+       if (strncasecmp(pipe_name, "\\pipe\\", 6)) {
+               pipe_name = talloc_asprintf(mem_ctx, "\\pipe\\%s", pipe_name);
        }
            
        if (!username || !username[0]) {
@@ -459,6 +474,7 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
        }
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Failed to connect to %s - %s\n", binding->host, nt_errstr(status)));
+               talloc_destroy(mem_ctx);
                return status;
        }
 
@@ -467,8 +483,11 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
                DEBUG(0,("Failed to open pipe %s - %s\n", pipe_name, nt_errstr(status)));
                smbcli_tdis(cli);
                smbcli_shutdown(cli);
-                return status;
-        }
+               talloc_destroy(mem_ctx);
+        return status;
+    }  
+
+       talloc_destroy(mem_ctx);
        
        /* this ensures that the reference count is decremented so
           a pipe close will really close the link */
index b37b3e917daa706888c01644a59350b5347c3cbe..8c32a78512659c0b181b50a243901e3f42ab048b 100644 (file)
@@ -227,9 +227,6 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_TOO_MANY_OPENED_FILES;
        }
 
-       while (p->pipe_name[0] == '\\') {
-               p->pipe_name++;
-       }
        p->ipc_state = 0x5ff;
 
        /*
@@ -310,8 +307,6 @@ static NTSTATUS ipc_open_openx(struct ntvfs_module_context *ntvfs,
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }
 
-       fname += 4;
-
        status = ipc_open_generic(ntvfs, req, fname, &p);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
index 220c730790d931aadcfbb9f2b57e41aed72090c0..b4cf7094aa15ca0dce14ab80d33410bafc3c5151 100644 (file)
@@ -153,17 +153,30 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
        struct dcesrv_ep_description ep_description;
        struct dcesrv_endpoint *ep;
        struct dcesrv_if_list *ifl;
-       BOOL tcp;
+       struct dcerpc_binding binding;
        BOOL add_ep = False;
+       NTSTATUS status;
+       
+       status = dcerpc_parse_binding(dce_ctx, ep_name, &binding);
 
-       tcp = (strncasecmp(ep_name, "TCP-", 4) == 0);
+       if (NT_STATUS_IS_ERR(status)) {
+               DEBUG(0, ("Trouble parsing binding string '%s'\n", ep_name));
+               return status;
+       }
 
-       if (tcp) {
+       if (binding.transport == NCACN_IP_TCP) {
                ep_description.type = ENDPOINT_TCP;
-               ep_description.info.tcp_port = atoi(ep_name+4);
-       } else {
+               ep_description.info.tcp_port = 0;
+
+               if (binding.options && binding.options[0]) {
+                       ep_description.info.tcp_port = atoi(binding.options[0]);
+               }
+       } else if (binding.transport == NCACN_NP) {
                ep_description.type = ENDPOINT_SMB;
-               ep_description.info.smb_pipe = ep_name;
+               ep_description.info.smb_pipe = binding.options[0];
+       } else {
+               DEBUG(0, ("Unknown transport type '%d'\n", binding.transport));
+               return NT_STATUS_INVALID_PARAMETER;
        }
 
        /* check if this endpoint exists
@@ -174,12 +187,16 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                        return NT_STATUS_NO_MEMORY;
                }
                ZERO_STRUCTP(ep);
-               if (tcp) {
+               if (binding.transport == NCACN_IP_TCP) {
                        ep->ep_description.type = ENDPOINT_TCP;
-                       ep->ep_description.info.tcp_port = atoi(ep_name+4);
+                       ep->ep_description.info.tcp_port = 0;
+
+                       if (binding.options && binding.options[0]) {
+                               ep->ep_description.info.tcp_port = atoi(binding.options[0]);
+                       }
                } else {
                        ep->ep_description.type = ENDPOINT_SMB;
-                       ep->ep_description.info.smb_pipe = smb_xstrdup(ep_name);
+                       ep->ep_description.info.smb_pipe = binding.options[0];
                }
                add_ep = True;
        }
@@ -508,6 +525,7 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
        pkt.u.bind_ack.max_recv_frag = 0x2000;
        pkt.u.bind_ack.assoc_group_id = call->pkt.u.bind.assoc_group_id;
        if (call->conn->iface && call->conn->iface->ndr) {
+               /* FIXME: Use pipe name as specified by endpoint instead of interface name */
                pkt.u.bind_ack.secondary_address = talloc_asprintf(call, "\\PIPE\\%s", 
                                                                   call->conn->iface->ndr->name);
        } else {
index 5cf34efa7fdbe8d236ede810f561b781fe984555..7de99687b77bcd444ffc85c817f94caf9ee0a260 100644 (file)
@@ -81,8 +81,7 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_towers *twr,
                /* on a SMB pipe ... */
                twr->floors[3].lhs.protocol = EPM_PROTOCOL_SMB;
                twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
-               twr->floors[3].rhs.smb.unc = talloc_asprintf(mem_ctx, "\\PIPE\\%s", 
-                                                                  e->ep_description.info.smb_pipe);
+               twr->floors[3].rhs.smb.unc = talloc_strdup(mem_ctx, e->ep_description.info.smb_pipe);
                
                /* on an NetBIOS link ... */
                twr->floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;