summaryrefslogtreecommitdiffstats
path: root/source4/rpc_server
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-10-21 17:40:55 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:02:23 -0500
commita9081b527b33d536ca36d61ad2f7f34a6e6e69e5 (patch)
treee4c2dd88bb9e0b65aea31e38bca7a86ae4d06c51 /source4/rpc_server
parentf30a08813cbb9b7c50625ad3c2d8476a82e65d42 (diff)
downloadsamba-a9081b527b33d536ca36d61ad2f7f34a6e6e69e5.tar.gz
samba-a9081b527b33d536ca36d61ad2f7f34a6e6e69e5.tar.xz
samba-a9081b527b33d536ca36d61ad2f7f34a6e6e69e5.zip
r3118: Eliminate struct dcesrv_ep_description and replace it with
struct dcerpc_binding. (This used to be commit 2046e14cf8d010d4e715124859df2c1c3c782266)
Diffstat (limited to 'source4/rpc_server')
-rw-r--r--source4/rpc_server/dcerpc_server.c72
-rw-r--r--source4/rpc_server/dcerpc_server.h17
-rw-r--r--source4/rpc_server/dcerpc_tcp.c19
-rw-r--r--source4/rpc_server/epmapper/rpc_epmapper.c13
4 files changed, 44 insertions, 77 deletions
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 1ccb8f4ef29..a4e31712bdb 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -26,37 +26,32 @@
/*
see if two endpoints match
*/
-static BOOL endpoints_match(const struct dcesrv_ep_description *ep1,
- const struct dcesrv_ep_description *ep2)
+static BOOL endpoints_match(const struct dcerpc_binding *ep1,
+ const struct dcerpc_binding *ep2)
{
- if (ep1->type != ep2->type) {
+ if (ep1->transport != ep2->transport) {
return False;
}
- switch (ep1->type) {
- case NCACN_NP:
- if (strcasecmp(ep1->info.smb_pipe,ep2->info.smb_pipe)==0) {
- return True;
- }
- break;
- case NCACN_IP_TCP:
- if (ep1->info.tcp_port == ep2->info.tcp_port) {
- return True;
- }
- break;
- default:
- /* Not supported yet */
- return False;
+ if (!ep1->options || !ep2->options) {
+ return ep1->options == ep2->options;
}
- return False;
+ if (!ep1->options[0] || !ep2->options[0]) {
+ return ep1->options[0] == ep2->options[0];
+ }
+
+ if (strcasecmp(ep1->options[0], ep2->options[0]) != 0)
+ return False;
+
+ return True;
}
/*
find an endpoint in the dcesrv_context
*/
static struct dcesrv_endpoint *find_endpoint(struct dcesrv_context *dce_ctx,
- const struct dcesrv_ep_description *ep_description)
+ const struct dcerpc_binding *ep_description)
{
struct dcesrv_endpoint *ep;
for (ep=dce_ctx->endpoint_list; ep; ep=ep->next) {
@@ -153,7 +148,6 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
const struct dcesrv_interface *iface,
const struct security_descriptor *sd)
{
- struct dcesrv_ep_description ep_description;
struct dcesrv_endpoint *ep;
struct dcesrv_if_list *ifl;
struct dcerpc_binding binding;
@@ -167,46 +161,15 @@ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
return status;
}
- 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]);
- }
- break;
- case NCACN_NP:
- ep_description.info.smb_pipe = binding.options[0];
- break;
- default:
- DEBUG(0, ("Unsupported transport type '%d'\n", binding.transport));
- return NT_STATUS_NOT_SUPPORTED;
- }
-
/* check if this endpoint exists
*/
- if ((ep=find_endpoint(dce_ctx, &ep_description))==NULL) {
+ if ((ep=find_endpoint(dce_ctx, &binding))==NULL) {
ep = talloc_p(dce_ctx, struct dcesrv_endpoint);
if (!ep) {
return NT_STATUS_NO_MEMORY;
}
ZERO_STRUCTP(ep);
- 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]);
- }
- break;
- case NCACN_NP:
- ep->ep_description.info.smb_pipe = binding.options[0];
- break;
- default:
- return NT_STATUS_NOT_SUPPORTED;
- }
+ ep->ep_description = binding;
add_ep = True;
}
@@ -352,7 +315,7 @@ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
search and connect to a dcerpc endpoint
*/
NTSTATUS dcesrv_endpoint_search_connect(struct dcesrv_context *dce_ctx,
- const struct dcesrv_ep_description *ep_description,
+ const struct dcerpc_binding *ep_description,
struct auth_session_info *session_info,
struct dcesrv_connection **dce_conn_p)
{
@@ -1192,7 +1155,6 @@ const struct dcesrv_critical_sizes *dcerpc_module_version(void)
sizeof(struct dcesrv_context),
sizeof(struct dcesrv_endpoint),
sizeof(struct dcesrv_endpoint_server),
- sizeof(struct dcesrv_ep_description),
sizeof(struct dcesrv_interface),
sizeof(struct dcesrv_if_list),
sizeof(struct dcesrv_connection),
diff --git a/source4/rpc_server/dcerpc_server.h b/source4/rpc_server/dcerpc_server.h
index f04460a78b5..12c93140ec0 100644
--- a/source4/rpc_server/dcerpc_server.h
+++ b/source4/rpc_server/dcerpc_server.h
@@ -31,16 +31,6 @@
/* version 1 - initial version - metze */
#define DCERPC_MODULE_VERSION 1
-/* 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 dcerpc_transport_t type;
- union {
- const char *smb_pipe;
- uint16_t tcp_port;
- } info;
-};
-
struct dcesrv_connection;
struct dcesrv_call_state;
struct dcesrv_auth;
@@ -146,13 +136,13 @@ struct dcesrv_endpoint_server {
/* this function can be used by other endpoint servers to
* ask for a dcesrv_interface implementation
- * - iface must be referenz to an allready existent struct !
+ * - iface must be reference to an already existing struct !
*/
BOOL (*interface_by_uuid)(struct dcesrv_interface *iface, const char *, uint32_t);
/* this function can be used by other endpoint servers to
* ask for a dcesrv_interface implementation
- * - iface must be referenz to an allready existent struct !
+ * - iface must be reference to an already existeng struct !
*/
BOOL (*interface_by_name)(struct dcesrv_interface *iface, const char *);
};
@@ -166,7 +156,7 @@ struct dcesrv_context {
struct dcesrv_endpoint {
struct dcesrv_endpoint *next, *prev;
/* the type and location of the endpoint */
- struct dcesrv_ep_description ep_description;
+ struct dcerpc_binding ep_description;
/* the security descriptor for smb named pipes */
struct security_descriptor *sd;
/* the list of interfaces available on this endpoint */
@@ -183,7 +173,6 @@ struct dcesrv_critical_sizes {
int sizeof_dcesrv_context;
int sizeof_dcesrv_endpoint;
int sizeof_dcesrv_endpoint_server;
- int sizeof_dcesrv_ep_description;
int sizeof_dcesrv_interface;
int sizeof_dcesrv_if_list;
int sizeof_dcesrv_connection;
diff --git a/source4/rpc_server/dcerpc_tcp.c b/source4/rpc_server/dcerpc_tcp.c
index ef05d74349e..de8b5bc069f 100644
--- a/source4/rpc_server/dcerpc_tcp.c
+++ b/source4/rpc_server/dcerpc_tcp.c
@@ -62,16 +62,29 @@ 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 == NCACN_IP_TCP) {
+ if (e->ep_description.transport == NCACN_IP_TCP) {
struct server_socket *sock;
struct dcesrv_socket_context *dcesrv_sock;
+ uint16_t port = 0;
+
+ if (e->ep_description.options && e->ep_description.options[0])
+ port = atoi(e->ep_description.options[0]);
- sock = service_setup_socket(service,model_ops, ip_str, &e->ep_description.info.tcp_port);
+ sock = service_setup_socket(service,model_ops, ip_str, &port);
if (!sock) {
- DEBUG(0,("service_setup_socket(port=%u) failed\n",e->ep_description.info.tcp_port));
+ DEBUG(0,("service_setup_socket(port=%u) failed\n",port));
continue;
}
+ /* And put the settings back into the binding. This will
+ * go away once we store the 'encoded' endpoint instead of a
+ * string describing it */
+ if (e->ep_description.options == NULL) {
+ e->ep_description.options = talloc_array_p(dce_ctx, const char *, 2);
+ e->ep_description.options[0] = talloc_asprintf(dce_ctx, "%d", port);
+ e->ep_description.options[1] = NULL;
+ }
+
dcesrv_sock = talloc_p(sock, struct dcesrv_socket_context);
if (!dcesrv_sock) {
DEBUG(0,("talloc_p(sock->mem_ctx, struct dcesrv_socket_context) failed\n"));
diff --git a/source4/rpc_server/epmapper/rpc_epmapper.c b/source4/rpc_server/epmapper/rpc_epmapper.c
index 4ee2a7b7749..52377569e3e 100644
--- a/source4/rpc_server/epmapper/rpc_epmapper.c
+++ b/source4/rpc_server/epmapper/rpc_epmapper.c
@@ -31,7 +31,7 @@ enum handle_types {HTYPE_LOOKUP};
/* a endpoint combined with an interface description */
struct dcesrv_ep_iface {
const char *name;
- struct dcesrv_ep_description ep_description;
+ struct dcerpc_binding ep_description;
const char *uuid;
uint32_t if_version;
};
@@ -76,12 +76,12 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr,
twr->floors[2].lhs.info.lhs_data = data_blob(NULL, 0);
twr->floors[2].rhs.ncacn.minor_version = 0;
- switch (e->ep_description.type) {
+ switch (e->ep_description.transport) {
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);
- twr->floors[3].rhs.smb.unc = talloc_strdup(mem_ctx, e->ep_description.info.smb_pipe);
+ twr->floors[3].rhs.smb.unc = talloc_strdup(mem_ctx, e->ep_description.options[0]);
/* on an NetBIOS link ... */
twr->floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;
@@ -94,7 +94,10 @@ static BOOL fill_protocol_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr,
/* on a TCP connection ... */
twr->floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
twr->floors[3].lhs.info.lhs_data = data_blob(NULL, 0);
- twr->floors[3].rhs.tcp.port = e->ep_description.info.tcp_port;
+ twr->floors[3].rhs.tcp.port = 0;
+ if (e->ep_description.options && e->ep_description.options[0]) {
+ twr->floors[3].rhs.tcp.port = atoi(e->ep_description.options[0]);
+ }
/* on an IP link ... */
twr->floors[4].lhs.protocol = EPM_PROTOCOL_IP;
@@ -275,7 +278,7 @@ static error_status_t epm_Map(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
floors[0].lhs.info.uuid.version != eps[i].if_version) {
continue;
}
- switch (eps[i].ep_description.type) {
+ switch (eps[i].ep_description.transport) {
case NCACN_NP:
if (floors[3].lhs.protocol != EPM_PROTOCOL_SMB ||
floors[4].lhs.protocol != EPM_PROTOCOL_NETBIOS) {