r3156: Couple of fixes in the conversion functions between binding structs and
authorJelmer Vernooij <jelmer@samba.org>
Sun, 24 Oct 2004 13:00:51 +0000 (13:00 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:02:26 +0000 (13:02 -0500)
protocol towers
(This used to be commit f41dfc6c5a85bf241e4bcc0669f6191bf531e89a)

source4/librpc/rpc/dcerpc_util.c
source4/torture/local/binding_string.c
source4/torture/torture.c

index 1adcac8eab9ef7be4d71150316726c1c38443de6..9125f9e017259e97f63363f36ee1c65a87fc9ced 100644 (file)
@@ -242,11 +242,11 @@ static const struct {
        enum epm_protocols protseq[MAX_PROTSEQ];
 } transports[] = {
        { "ncacn_np",     NCACN_NP, 3, 
        enum epm_protocols protseq[MAX_PROTSEQ];
 } transports[] = {
        { "ncacn_np",     NCACN_NP, 3, 
-               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_PIPE }},
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
        { "ncacn_ip_tcp", NCACN_IP_TCP, 3, 
        { "ncacn_ip_tcp", NCACN_IP_TCP, 3, 
-               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_TCP } }, 
+               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } }, 
        { "ncadg_ip_udp", NCACN_IP_UDP, 3, 
        { "ncadg_ip_udp", NCACN_IP_UDP, 3, 
-               { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_IP, EPM_PROTOCOL_UDP } },
+               { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
        { "ncalrpc", NCALRPC, 2, 
                { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
        { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2, 
        { "ncalrpc", NCALRPC, 2, 
                { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
        { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2, 
@@ -604,23 +604,17 @@ static NTSTATUS floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *floor,
        return NT_STATUS_NOT_SUPPORTED;
 }
 
        return NT_STATUS_NOT_SUPPORTED;
 }
 
-NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower, struct dcerpc_binding *binding)
+enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
 {
        int i;
 
 {
        int i;
 
-       binding->transport = -1;
-       ZERO_STRUCT(binding->object);
-       binding->options = NULL;
-       binding->host = NULL;
-       binding->flags = 0;
-
        /* Find a transport that matches this tower */
        for (i=0;i<ARRAY_SIZE(transports);i++) {
                int j;
                if (transports[i].num_protocols != tower->num_floors - 2) {
                        continue; 
                }
        /* Find a transport that matches this tower */
        for (i=0;i<ARRAY_SIZE(transports);i++) {
                int j;
                if (transports[i].num_protocols != tower->num_floors - 2) {
                        continue; 
                }
-               
+
                for (j = 0; j < transports[i].num_protocols; j++) {
                        if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
                                break;
                for (j = 0; j < transports[i].num_protocols; j++) {
                        if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
                                break;
@@ -628,10 +622,22 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower,
                }
 
                if (j == transports[i].num_protocols) {
                }
 
                if (j == transports[i].num_protocols) {
-                       binding->transport = transports[i].transport;
-                       break;
+                       return transports[i].transport;
                }
        }
                }
        }
+       
+       /* Unknown transport */
+       return -1;
+}
+
+NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower, struct dcerpc_binding *binding)
+{
+       ZERO_STRUCT(binding->object);
+       binding->options = NULL;
+       binding->host = NULL;
+       binding->flags = 0;
+
+       binding->transport = dcerpc_transport_by_tower(tower);
 
        if (binding->transport == -1) {
                return NT_STATUS_NOT_SUPPORTED;
 
        if (binding->transport == -1) {
                return NT_STATUS_NOT_SUPPORTED;
@@ -650,16 +656,16 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower,
        binding->options = talloc_array_p(mem_ctx, const char *, 2);
 
        /* Set endpoint */
        binding->options = talloc_array_p(mem_ctx, const char *, 2);
 
        /* Set endpoint */
-       if (tower->num_floors >= 3) {
-               binding->options[0] = floor_get_rhs_data(mem_ctx, &tower->floors[tower->num_floors-1]);
+       if (tower->num_floors >= 4) {
+               binding->options[0] = floor_get_rhs_data(mem_ctx, &tower->floors[3]);
        } else {
                binding->options[0] = NULL;
        }
        binding->options[1] = NULL;
 
        /* Set network address */
        } else {
                binding->options[0] = NULL;
        }
        binding->options[1] = NULL;
 
        /* Set network address */
-       if (tower->num_floors >= 4) {
-               binding->host = floor_get_rhs_data(mem_ctx, &tower->floors[tower->num_floors-2]);
+       if (tower->num_floors >= 5) {
+               binding->host = floor_get_rhs_data(mem_ctx, &tower->floors[4]);
        }
        return NT_STATUS_OK;
 }
        }
        return NT_STATUS_OK;
 }
@@ -709,17 +715,16 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *
                ZERO_STRUCT(tower->floors[2 + i].rhs);
        }
 
                ZERO_STRUCT(tower->floors[2 + i].rhs);
        }
 
-       /* The top floor contains the endpoint */
-       if (num_protocols >= 1 && binding->options && binding->options[0]) {
-               status = floor_set_rhs_data(mem_ctx, &tower->floors[2 + num_protocols - 1], binding->options[0]);
+       /* The 4th floor contains the endpoint */
+       if (num_protocols >= 2 && binding->options && binding->options[0]) {
+               status = floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->options[0]);
                if (NT_STATUS_IS_ERR(status)) {
                        return status;
                }
        }
                if (NT_STATUS_IS_ERR(status)) {
                        return status;
                }
        }
-
-       /* The second-to-top floor contains the network address */
-       if (num_protocols >= 2 && binding->host) {
-               status = floor_set_rhs_data(mem_ctx, &tower->floors[2 + num_protocols - 2], binding->host);
+       /* The 5th contains the network address */
+       if (num_protocols >= 3 && binding->host) {
+               status = floor_set_rhs_data(mem_ctx, &tower->floors[4], binding->host);
                if (NT_STATUS_IS_ERR(status)) {
                        return status;
                }
                if (NT_STATUS_IS_ERR(status)) {
                        return status;
                }
index 6522449e64a423c9ed1ddefd4927072eca4d8c99..5e346b4831dc8aace8498e4c03cea3b76a7fda82 100644 (file)
@@ -94,7 +94,7 @@ static BOOL test_BindingString(TALLOC_CTX *mem_ctx, const char *binding)
 static const char *test_strings[] = {
        "ncacn_np:", 
        "ncalrpc:", 
 static const char *test_strings[] = {
        "ncacn_np:", 
        "ncalrpc:", 
-       "ncalrpc:[Security=Sane]", 
+       "ncalrpc:[,Security=Sane]", 
        "ncacn_np:[rpcecho]",
        "ncacn_np:127.0.0.1[rpcecho]",
        "ncacn_ip_tcp:127.0.0.1",
        "ncacn_np:[rpcecho]",
        "ncacn_np:127.0.0.1[rpcecho]",
        "ncacn_ip_tcp:127.0.0.1",
@@ -105,6 +105,9 @@ static const char *test_strings[] = {
        "ncadg_ip_udp:",
        "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:localhost",
        "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:127.0.0.1",
        "ncadg_ip_udp:",
        "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:localhost",
        "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:127.0.0.1",
+       "ncacn_unix_stream:[/tmp/epmapper]",
+       "ncalrpc:[IDENTIFIER]",
+       "ncacn_unix_stream:[/tmp/epmapper,sign]",
 };
 
 BOOL torture_local_binding_string(int dummy) 
 };
 
 BOOL torture_local_binding_string(int dummy) 
index 19e8bf266e2da2e8d1039ca31e23e6e583b1795e..e05dba7ee763ec47475cee9724f30de9959537ab 100644 (file)
@@ -2972,7 +2972,7 @@ static struct {
        {"LOCAL-ICONV", torture_local_iconv, 0},
        {"LOCAL-TALLOC", torture_local_talloc, 0},
        {"LOCAL-MESSAGING", torture_local_messaging, 0},
        {"LOCAL-ICONV", torture_local_iconv, 0},
        {"LOCAL-TALLOC", torture_local_talloc, 0},
        {"LOCAL-MESSAGING", torture_local_messaging, 0},
-       {"LOCAL-BINDINGSTRING", torture_local_binding_string, 0},
+       {"LOCAL-BINDING", torture_local_binding_string, 0},
        {"LOCAL-IDTREE", torture_local_idtree, 0},
 
        /* ldap testers */
        {"LOCAL-IDTREE", torture_local_idtree, 0},
 
        /* ldap testers */