r3114: - More work on merging the various structs that describe endpoints
authorJelmer Vernooij <jelmer@samba.org>
Thu, 21 Oct 2004 12:47:02 +0000 (12:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:02:23 +0000 (13:02 -0500)
- Add protocol sequence to dcerpc transports (will be used later on)
- Add more transports to the list
(This used to be commit ab110192e6e2c1e5a3b2befe7b61158744f15d18)

source4/librpc/idl/epmapper.idl
source4/librpc/rpc/dcerpc.h
source4/librpc/rpc/dcerpc_util.c
source4/ntvfs/ipc/vfs_ipc.c
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcerpc_server.h
source4/rpc_server/dcerpc_tcp.c
source4/rpc_server/epmapper/rpc_epmapper.c

index de45675c90b73466a6fd1b63008723ce5ce3bd29..81f9b0976c24447bac3ceb9aac3cf6703b578e88 100644 (file)
@@ -62,14 +62,14 @@ interface epmapper
                EPM_PROTOCOL_NETBEUI            = 0x12,
                EPM_PROTOCOL_SPX                = 0x13,
                EPM_PROTOCOL_NB_IPX             = 0x14, /* NetBIOS over IPX */
-               EPM_PROTOCOL_ATALK_STREAM       = 0x16,
-               EPM_PROTOCOL_ATALK_DATAGRAM = 0x17,
+               EPM_PROTOCOL_DSP                        = 0x16, /* AppleTalk Data Stream Protocol */
+               EPM_PROTOCOL_DDP                    = 0x17, /* AppleTalk Data Datagram Protocol */
                EPM_PROTOCOL_APPLETALK          = 0x18, /* AppleTalk */
                EPM_PROTOCOL_VINES_SPP          = 0x1a, 
-               EPM_PROTOCOL_VINES_IPC          = 0x1b,
-               EPM_PROTOCOL_STREETTALK         = 0x1c,
+               EPM_PROTOCOL_VINES_IPC          = 0x1b, /* Inter Process Communication */
+               EPM_PROTOCOL_STREETTALK         = 0x1c, /* Vines Streettalk */
                EPM_PROTOCOL_HTTP               = 0x1f,
-               EPM_PROTOCOL_UNIX_DS            = 0x20,  /* Unix domain socket */
+               EPM_PROTOCOL_UNIX_DS            = 0x20, /* Unix domain socket */
                EPM_PROTOCOL_NULL                       = 0x21
        } epm_protocols;
 
@@ -193,8 +193,8 @@ interface epmapper
                [case(EPM_PROTOCOL_NETBEUI)] epm_rhs_netbeui netbeui;
                [case(EPM_PROTOCOL_SPX)] epm_rhs_spx spx;
                [case(EPM_PROTOCOL_NB_IPX)] epm_rhs_nb_ipx nb_ipx;
-               [case(EPM_PROTOCOL_ATALK_STREAM)] epm_rhs_atalk_stream atalk_stream;
-               [case(EPM_PROTOCOL_ATALK_DATAGRAM)] epm_rhs_atalk_datagram atalk_datagram;
+               [case(EPM_PROTOCOL_DSP)] epm_rhs_atalk_stream atalk_stream;
+               [case(EPM_PROTOCOL_DDP)] epm_rhs_atalk_datagram atalk_datagram;
                [case(EPM_PROTOCOL_APPLETALK)] epm_rhs_appletalk appletalk;
                [case(EPM_PROTOCOL_VINES_SPP)] epm_rhs_vines_spp vines_spp;
                [case(EPM_PROTOCOL_VINES_IPC)] epm_rhs_vines_ipc vines_ipc;
index 3dd81435117aa935afa29182d3f65b8499dbc77f..903759f19b28408c957e1757b284c4ba8e001e96 100644 (file)
@@ -20,7 +20,9 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-enum dcerpc_transport_t {NCACN_NP, NCACN_IP_TCP};
+enum dcerpc_transport_t {
+       NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP, 
+       NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, NCADG_UNIX_DGRAM };
 
 /*
   this defines a generic security context for signed/sealed dcerpc pipes.
index d034dd89d0589ed3173a9b0715f1c053efbe1889..bded74c40708833b24270f4bbf133f9f3a03ffd8 100644 (file)
@@ -233,13 +233,34 @@ NTSTATUS dcerpc_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
+#define MAX_PROTSEQ            10
 
 static const struct {
        const char *name;
        enum dcerpc_transport_t transport;
-} ncacn_transports[] = {
-       {"ncacn_np",     NCACN_NP},
-       {"ncacn_ip_tcp", NCACN_IP_TCP}
+       int num_protocols;
+       enum epm_protocols protseq[MAX_PROTSEQ];
+} transports[] = {
+       { "ncacn_np",     NCACN_NP, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_PIPE }},
+       { "ncacn_ip_tcp", NCACN_IP_TCP, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_TCP } }, 
+       { "ncadg_ip_udp", NCACN_IP_UDP, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_UDP } },
+       { "ncalrpc", NCALRPC, 1, 
+               { EPM_PROTOCOL_NCALRPC } },
+       { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } },
+       { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2, 
+               { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } },
+       { "ncacn_at_dsp", NCACN_AT_DSP, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } },
+       { "ncadg_at_ddp", NCADG_AT_DDP, 3, 
+               { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } },
+       { "ncacn_vns_ssp", NCACN_VNS_SPP, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } },
+       { "ncacn_vns_ipc", NCACN_VNS_IPC, 3, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, },
 };
 
 static const struct {
@@ -264,9 +285,9 @@ const char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bindi
        int i;
        const char *t_name=NULL;
 
-       for (i=0;i<ARRAY_SIZE(ncacn_transports);i++) {
-               if (ncacn_transports[i].transport == b->transport) {
-                       t_name = ncacn_transports[i].name;
+       for (i=0;i<ARRAY_SIZE(transports);i++) {
+               if (transports[i].transport == b->transport) {
+                       t_name = transports[i].name;
                }
        }
        if (!t_name) {
@@ -339,13 +360,13 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
                return NT_STATUS_NO_MEMORY;
        }
 
-       for (i=0;i<ARRAY_SIZE(ncacn_transports);i++) {
-               if (strcasecmp(type, ncacn_transports[i].name) == 0) {
-                       b->transport = ncacn_transports[i].transport;
+       for (i=0;i<ARRAY_SIZE(transports);i++) {
+               if (strcasecmp(type, transports[i].name) == 0) {
+                       b->transport = transports[i].transport;
                        break;
                }
        }
-       if (i==ARRAY_SIZE(ncacn_transports)) {
+       if (i==ARRAY_SIZE(transports)) {
                DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
                return NT_STATUS_INVALID_PARAMETER;
        }
@@ -442,7 +463,7 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p,
                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) {
+                       if (NT_STATUS_IS_OK(status) && default_binding.transport == NCACN_NP) {
                                pipe_name = default_binding.options[0]; 
                                break;
                                
@@ -603,6 +624,8 @@ NTSTATUS dcerpc_pipe_connect_b(struct dcerpc_pipe **p,
                status = dcerpc_pipe_connect_ncacn_ip_tcp(p, binding, pipe_uuid, pipe_version,
                                                          domain, username, password);
                break;
+       default:
+               return NT_STATUS_NOT_SUPPORTED;
        }
 
        return status;
@@ -677,6 +700,8 @@ NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p, struct dcerpc_pipe *
                                                          pipe_version, NULL, 
                                                          NULL, NULL);
                break;
+       default:
+               return NT_STATUS_NOT_SUPPORTED;
        }
 
        if (!NT_STATUS_IS_OK(status)) {
index f4eb007235d8ce6dc6ad0b1d6144d3b8ab2fca0c..8b1c9d2d8dd2c4113e7fc138fc5be4310947e530 100644 (file)
@@ -211,7 +211,7 @@ static NTSTATUS ipc_open_generic(struct ntvfs_module_context *ntvfs,
          will need to do that once the credentials infrastructure is
          finalised for Samba4
        */
-       ep_description.type = ENDPOINT_SMB;
+       ep_description.type = NCACN_NP;
        ep_description.info.smb_pipe = p->pipe_name;
 
        /* tell the RPC layer the session_info */
index b4cf7094aa15ca0dce14ab80d33410bafc3c5151..1ccb8f4ef29545f195daf77d1833d4e601b22d49 100644 (file)
@@ -34,16 +34,19 @@ static BOOL endpoints_match(const struct dcesrv_ep_description *ep1,
        }
 
        switch (ep1->type) {
-               case ENDPOINT_SMB:
+               case NCACN_NP:
                        if (strcasecmp(ep1->info.smb_pipe,ep2->info.smb_pipe)==0) {
                                return True;
                        }                       
                        break;
-               case ENDPOINT_TCP:
+               case NCACN_IP_TCP:
                        if (ep1->info.tcp_port == ep2->info.tcp_port) {
                                return True;
                        }
                        break;
+               default: 
+                       /* Not supported yet */
+                       return False;
        }
 
        return False;
@@ -164,19 +167,21 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                return status;
        }
 
-       if (binding.transport == NCACN_IP_TCP) {
-               ep_description.type = ENDPOINT_TCP;
+       ep_description.type = binding.transport;
+       switch (binding.transport) {
+       case NCACN_IP_TCP:
                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;
+               break;
+       case NCACN_NP:
                ep_description.info.smb_pipe = binding.options[0];
-       } else {
-               DEBUG(0, ("Unknown transport type '%d'\n", binding.transport));
-               return NT_STATUS_INVALID_PARAMETER;
+               break;
+       default:
+               DEBUG(0, ("Unsupported transport type '%d'\n", binding.transport));
+               return NT_STATUS_NOT_SUPPORTED;
        }
 
        /* check if this endpoint exists
@@ -187,16 +192,20 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                        return NT_STATUS_NO_MEMORY;
                }
                ZERO_STRUCTP(ep);
-               if (binding.transport == NCACN_IP_TCP) {
-                       ep->ep_description.type = ENDPOINT_TCP;
+               ep->ep_description.type = binding.transport;
+               switch (binding.transport) { 
+               case NCACN_IP_TCP:
                        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;
+                       break;
+               case NCACN_NP:
                        ep->ep_description.info.smb_pipe = binding.options[0];
+                       break;
+               default:
+                       return NT_STATUS_NOT_SUPPORTED;
                }
                add_ep = True;
        }
index 09e8697fa209a2cdd74df8d86e7b8b7b65f3dc6e..f04460a78b560c36e000db47218b64110d35f90f 100644 (file)
 /* version 1 - initial version - metze */
 #define DCERPC_MODULE_VERSION 1
 
-enum endpoint_type {ENDPOINT_SMB, ENDPOINT_TCP};
-
 /* a description of a single dcerpc endpoint. Not as flexible as a full epm tower,
    but much easier to work with */
 struct dcesrv_ep_description {
-       enum endpoint_type type;
+       enum dcerpc_transport_t type;
        union {
                const char *smb_pipe;
                uint16_t tcp_port;
index 9cbcea5a36ba3d22a25a633b3173b3dcfc35d0bd..ef05d74349ea7c2a842f3f5372aeed1ce6522fd3 100644 (file)
@@ -62,7 +62,7 @@ static void add_socket_rpc(struct server_service *service,
        char *ip_str = talloc_strdup(service, inet_ntoa(*ifip));
 
        for (e=dce_ctx->endpoint_list;e;e=e->next) {
-               if (e->ep_description.type == ENDPOINT_TCP) {
+               if (e->ep_description.type == NCACN_IP_TCP) {
                        struct server_socket *sock;
                        struct dcesrv_socket_context *dcesrv_sock;
 
index a39dde8da2a0e3185450e682bd513a0dce767aec..4ee2a7b7749fdb0595508975209619a50b91d8cb 100644 (file)
@@ -77,7 +77,7 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr,
        twr->floors[2].rhs.ncacn.minor_version = 0;
 
        switch (e->ep_description.type) {
-       case ENDPOINT_SMB:
+       case NCACN_NP:
                /* on a SMB pipe ... */
                twr->floors[3].lhs.protocol = EPM_PROTOCOL_SMB;
                twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
@@ -90,7 +90,7 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr,
                                                                   lp_netbios_name());
                break;
 
-       case ENDPOINT_TCP:
+       case NCACN_IP_TCP:
                /* on a TCP connection ... */
                twr->floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
                twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
@@ -276,13 +276,13 @@ static error_status_t epm_Map(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
                        continue;
                }
                switch (eps[i].ep_description.type) {
-               case ENDPOINT_SMB:
+               case NCACN_NP:
                        if (floors[3].lhs.protocol != EPM_PROTOCOL_SMB ||
                            floors[4].lhs.protocol != EPM_PROTOCOL_NETBIOS) {
                                continue;
                        }
                        break;
-               case ENDPOINT_TCP:
+               case NCACN_IP_TCP:
                        if (floors[3].lhs.protocol != EPM_PROTOCOL_TCP ||
                            floors[4].lhs.protocol != EPM_PROTOCOL_IP) {
                                continue;