{
struct pipe_state *p;
NTSTATUS status;
- struct dcesrv_ep_description ep_description;
+ struct dcerpc_binding ep_description;
struct auth_session_info *session_info = NULL;
struct ipc_private *private = ntvfs->private_data;
int fnum;
will need to do that once the credentials infrastructure is
finalised for Samba4
*/
- ep_description.type = NCACN_NP;
- ep_description.info.smb_pipe = p->pipe_name;
+ ep_description.transport = NCACN_NP;
+ ep_description.options = talloc_array_p(req, char *, 2);
+ ep_description.options[0] = p->pipe_name;
+ ep_description.options[1] = NULL;
/* tell the RPC layer the session_info */
if (req->session) {
/*
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) {
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;
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;
}
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)
{
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),
/* 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;
/* 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 *);
};
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 */
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;
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"));
/* 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;
};
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;
/* 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;
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) {