svn commit: samba r3156 - in branches/SAMBA_4_0/source: librpc/rpc torture torture/local

jelmer at samba.org jelmer at samba.org
Sun Oct 24 13:00:51 GMT 2004


Author: jelmer
Date: 2004-10-24 13:00:51 +0000 (Sun, 24 Oct 2004)
New Revision: 3156

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=3156&nolog=1

Log:
Couple of fixes in the conversion functions between binding structs and 
protocol towers

Modified:
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
   branches/SAMBA_4_0/source/torture/local/binding_string.c
   branches/SAMBA_4_0/source/torture/torture.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2004-10-24 12:55:12 UTC (rev 3155)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2004-10-24 13:00:51 UTC (rev 3156)
@@ -242,11 +242,11 @@
 	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, 
-		{ 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, 
-		{ 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, 
@@ -604,23 +604,17 @@
 	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;
 
-	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; 
 		}
-		
+
 		for (j = 0; j < transports[i].num_protocols; j++) {
 			if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
 				break;
@@ -628,11 +622,23 @@
 		}
 
 		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;
 	}
@@ -650,16 +656,16 @@
 	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 */
-	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;
 }
@@ -709,17 +715,16 @@
 		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;
 		}
 	}
-
-	/* 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;
 		}

Modified: branches/SAMBA_4_0/source/torture/local/binding_string.c
===================================================================
--- branches/SAMBA_4_0/source/torture/local/binding_string.c	2004-10-24 12:55:12 UTC (rev 3155)
+++ branches/SAMBA_4_0/source/torture/local/binding_string.c	2004-10-24 13:00:51 UTC (rev 3156)
@@ -94,7 +94,7 @@
 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",
@@ -105,6 +105,9 @@
 	"ncadg_ip_udp:",
 	"308FB580-1EB2-11CA-923B-08002B1075A7 at ncacn_np:localhost",
 	"308FB580-1EB2-11CA-923B-08002B1075A7 at 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) 

Modified: branches/SAMBA_4_0/source/torture/torture.c
===================================================================
--- branches/SAMBA_4_0/source/torture/torture.c	2004-10-24 12:55:12 UTC (rev 3155)
+++ branches/SAMBA_4_0/source/torture/torture.c	2004-10-24 13:00:51 UTC (rev 3156)
@@ -2972,7 +2972,7 @@
 	{"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 */



More information about the samba-cvs mailing list