--- old/usr/src/common/smbsrv/smb_door_legacy.c	Sun Mar 18 01:13:02 2018
+++ new/usr/src/common/smbsrv/smb_door_legacy.c	Sun Mar 18 01:13:02 2018
@@ -39,7 +39,7 @@
 #include <sys/errno.h>
 #endif
 
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/smb_share.h>
 #include <smbsrv/smb_door.h>
 #include <smbsrv/alloc.h>
--- old/usr/src/common/smbsrv/smb_token_xdr.c	Sun Mar 18 01:13:03 2018
+++ new/usr/src/common/smbsrv/smb_token_xdr.c	Sun Mar 18 01:13:03 2018
@@ -32,7 +32,7 @@
 #if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
 #include <stdlib.h>
 #endif /* !_KERNEL */
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/smb_sid.h>
 #include <smbsrv/smb_xdr.h>
 #include <smbsrv/smb_token.h>
--- old/usr/src/lib/smbsrv/Makefile	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/Makefile	Sun Mar 18 01:13:03 2018
@@ -29,7 +29,6 @@
 SUBDIRS = \
 	libfksmbsrv \
 	libmlsvc \
-	libmlrpc \
 	libsmb \
 	libsmbns \
 	libsmbrp
@@ -36,7 +35,6 @@
 
 include ./Makefile.subdirs
 
-libmlrpc: libsmb
 libsmbns: libsmb
-libmlsvc: libsmb libmlrpc libsmbns
+libmlsvc: libsmb libsmbns
 libfksmbsrv: libsmb
--- old/usr/src/lib/smbsrv/Makefile.targ	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/Makefile.targ	Sun Mar 18 01:13:03 2018
@@ -22,7 +22,8 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
+# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+#
 
 #
 # Common targets for smbsrv Makefiles
@@ -29,12 +30,14 @@
 #
 
 %_ndr.c: $(NDLDIR)/%.ndl
-	$(NDRGEN) -Y $(CC) $<
+	$(NDRGEN) -Y $(ANSI_CPP) $(CPPFLAGS) $<
 
 pics/%.o:	$(SRC)/common/smbsrv/%.c
 	$(COMPILE.c) -o $@ $<
 	$(POST_PROCESS_O)
 
+pics/%.o := CPPFLAGS += -I$(ROOTSMBHDRDIR)/ndl
+
 .KEEP_STATE:
 
 all: $(LIBS)
--- old/usr/src/lib/smbsrv/libmlsvc/common/dssetup_clnt.c	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/dssetup_clnt.c	Sun Mar 18 01:13:03 2018
@@ -29,7 +29,7 @@
 
 #include <string.h>
 #include <strings.h>
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/libsmb.h>
 #include <smbsrv/ndl/dssetup.ndl>
 #include <smbsrv/libmlsvc.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/dssetup_svc.c	Sun Mar 18 01:13:03 2018
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -32,8 +33,8 @@
 #include <stdlib.h>
 #include <netdb.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/ndl/dssetup.ndl>
 #include <smbsrv/smbinfo.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/eventlog_svc.c	Sun Mar 18 01:13:03 2018
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -29,8 +30,8 @@
 #include <sys/utsname.h>
 #include <unistd.h>
 #include <strings.h>
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/nmpipes.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/ndl/eventlog.ndl>
--- old/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/libmlsvc.h	Sun Mar 18 01:13:03 2018
@@ -26,17 +26,22 @@
 #ifndef	_LIBMLSVC_H
 #define	_LIBMLSVC_H
 
-#include <uuid/uuid.h>
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <sys/ksynch.h>
+#include <uuid/uuid.h>
+
 #include <time.h>
 #include <stdio.h>
 #include <string.h>
+#include <syslog.h>
 #include <netdb.h>
 #include <libuutil.h>
-#include <smbsrv/wintypes.h>
+
+#include <smb/wintypes.h>
+#include <libmlrpc/libmlrpc.h>
+
 #include <smbsrv/hash_table.h>
 #include <smbsrv/smb_token.h>
 #include <smbsrv/smb_privilege.h>
@@ -44,8 +49,6 @@
 #include <smbsrv/smb_xdr.h>
 #include <smbsrv/smb_dfs.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
-#include <smbsrv/ndl/lsarpc.ndl>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -127,9 +130,6 @@
 	uint32_t high_part;
 } ms_luid_t;
 
-int srvsvc_net_remote_tod(char *, char *, struct timeval *, struct tm *);
-
-
 /*
  * A client_t is created while binding a client connection to hold the
  * context for calls made using that connection.
@@ -138,26 +138,23 @@
  * ensure that each handle has a pointer to the client_t.  When the top
  * level (bind) handle is released, we close the connection.
  */
-typedef struct mlsvc_handle {
-	ndr_hdid_t			handle;
-	ndr_client_t			*clnt;
-} mlsvc_handle_t;
+typedef struct mlrpc_handle mlsvc_handle_t;
 
+/* mlsvc_client.c */
 void ndr_rpc_init(void);
 void ndr_rpc_fini(void);
 uint32_t ndr_rpc_bind(mlsvc_handle_t *, char *, char *, char *, const char *);
 void ndr_rpc_unbind(mlsvc_handle_t *);
-int ndr_rpc_call(mlsvc_handle_t *, int, void *);
-void ndr_rpc_set_nonull(mlsvc_handle_t *);
-int ndr_rpc_get_ssnkey(mlsvc_handle_t *, unsigned char *, size_t);
-void *ndr_rpc_malloc(mlsvc_handle_t *, size_t);
-ndr_heap_t *ndr_rpc_get_heap(mlsvc_handle_t *);
-void ndr_rpc_release(mlsvc_handle_t *);
-boolean_t ndr_is_null_handle(mlsvc_handle_t *);
-boolean_t ndr_is_bind_handle(mlsvc_handle_t *);
-void ndr_inherit_handle(mlsvc_handle_t *, mlsvc_handle_t *);
 void ndr_rpc_status(mlsvc_handle_t *, int, uint32_t);
 
+/* These three get info about the connected client. */
+boolean_t ndr_is_admin(ndr_xa_t *);
+boolean_t ndr_is_poweruser(ndr_xa_t *);
+int32_t ndr_native_os(ndr_xa_t *);
+
+/* SRVSVC */
+int srvsvc_net_remote_tod(char *, char *, struct timeval *, struct tm *);
+
 /* SVCCTL service */
 /*
  * Calculate the wide-char equivalent string length required to
--- old/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c	Sun Mar 18 01:13:03 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/lsar_svc.c	Sun Mar 18 01:13:03 2018
@@ -33,8 +33,8 @@
 #include <pwd.h>
 #include <grp.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/ndl/lsarpc.ndl>
 #include <lsalib.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_client.c	Sun Mar 18 01:13:04 2018
@@ -39,12 +39,11 @@
 #include <syslog.h>
 #include <synch.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <netsmb/smbfs_api.h>
+
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libsmbns.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
-#include <smbsrv/ndl/srvsvc.ndl>
 #include <libsmbrdr.h>
 #include <mlsvc.h>
 
@@ -62,13 +61,15 @@
  * unbind and teardown the connection.  As each handle is initialized it
  * will inherit a reference to the client context.
  *
- * Returns 0 or an NT_STATUS:
+ * Returns 0 or an NT_STATUS:		(failed in...)
+ *
  *	NT_STATUS_BAD_NETWORK_PATH	(get server addr)
  *	NT_STATUS_NETWORK_ACCESS_DENIED	(connect, auth)
- *	NT_STATUS_BAD_NETWORK_NAME	(tcon, open)
+ *	NT_STATUS_BAD_NETWORK_NAME	(tcon)
+ *	RPC_NT_SERVER_TOO_BUSY		(open pipe)
+ *	RPC_NT_SERVER_UNAVAILABLE	(open pipe)
  *	NT_STATUS_ACCESS_DENIED		(open pipe)
  *	NT_STATUS_INVALID_PARAMETER	(rpc bind)
- *
  *	NT_STATUS_INTERNAL_ERROR	(bad args etc)
  *	NT_STATUS_NO_MEMORY
  */
@@ -77,10 +78,8 @@
     char *username, const char *service)
 {
 	struct smb_ctx		*ctx = NULL;
-	ndr_client_t		*clnt = NULL;
 	ndr_service_t		*svc;
 	DWORD			status;
-	int			fd = -1;
 	int			rc;
 
 	if (handle == NULL || server == NULL || server[0] == '\0' ||
@@ -113,127 +112,79 @@
 		    "(Srv=%s Dom=%s User=%s), %s (0x%x)",
 		    server, domain, username,
 		    xlate_nt_status(status), status);
-		/* Tell the DC Locator this DC failed. */
-		smb_ddiscover_bad_dc(server);
-		goto errout;
-	}
-
-	/*
-	 * Open the named pipe.
-	 */
-	fd = smb_fh_open(ctx, svc->endpoint, O_RDWR);
-	if (fd < 0) {
-		rc = errno;
-		syslog(LOG_DEBUG, "ndr_rpc_bind: "
-		    "smb_fh_open (%s) err=%d",
-		    svc->endpoint, rc);
-		switch (rc) {
-		case EACCES:
-			status = NT_STATUS_ACCESS_DENIED;
-			break;
+		/*
+		 * If the error is one where changing to a new DC
+		 * might help, try looking for a different DC.
+		 */
+		switch (status) {
+		case NT_STATUS_BAD_NETWORK_PATH:
+		case NT_STATUS_BAD_NETWORK_NAME:
+			/* Look for a new DC */
+			smb_ddiscover_bad_dc(server);
 		default:
-			status = NT_STATUS_BAD_NETWORK_NAME;
 			break;
 		}
-		goto errout;
+		return (status);
 	}
 
 	/*
 	 * Setup the RPC client handle.
 	 */
-	if ((clnt = malloc(sizeof (ndr_client_t))) == NULL) {
-		status = NT_STATUS_NO_MEMORY;
-		goto errout;
+	rc = mlrpc_clh_create(handle, ctx);
+	if (rc != 0) {
+		syslog(LOG_ERR, "ndr_rpc_bind: mlrpc_clh_create: rc=%d", rc);
+		smbrdr_ctx_free(ctx);
+		switch (rc) {
+		case ENOMEM:
+			return (NT_STATUS_NO_MEMORY);
+		case EINVAL:
+			return (NT_STATUS_INVALID_PARAMETER);
+		default:
+			return (NT_STATUS_INTERNAL_ERROR);
+		}
 	}
-	bzero(clnt, sizeof (ndr_client_t));
 
-	clnt->handle = &handle->handle;
-	clnt->xa_init = ndr_xa_init;
-	clnt->xa_exchange = ndr_xa_exchange;
-	clnt->xa_read = ndr_xa_read;
-	clnt->xa_preserve = ndr_xa_preserve;
-	clnt->xa_destruct = ndr_xa_destruct;
-	clnt->xa_release = ndr_xa_release;
-	clnt->xa_private = ctx;
-	clnt->xa_fd = fd;
-
-	ndr_svc_binding_pool_init(&clnt->binding_list,
-	    clnt->binding_pool, NDR_N_BINDING_POOL);
-
-	if ((clnt->heap = ndr_heap_create()) == NULL) {
-		status = NT_STATUS_NO_MEMORY;
-		goto errout;
-	}
-
 	/*
-	 * Fill in the caller's handle.
+	 * This does the pipe open and OtW RPC bind.
+	 * Handles pipe open retries.
 	 */
-	bzero(&handle->handle, sizeof (ndr_hdid_t));
-	handle->clnt = clnt;
-
-	/*
-	 * Do the OtW RPC bind.
-	 */
-	rc = ndr_clnt_bind(clnt, service, &clnt->binding);
-	switch (rc) {
-	case NDR_DRC_FAULT_OUT_OF_MEMORY:
-		status = NT_STATUS_NO_MEMORY;
-		break;
-	case NDR_DRC_FAULT_API_SERVICE_INVALID:	/* not registered */
-		status = NT_STATUS_INTERNAL_ERROR;
-		break;
-	default:
-		if (NDR_DRC_IS_FAULT(rc)) {
-			status = NT_STATUS_INVALID_PARAMETER;
+	status = mlrpc_clh_bind(handle, svc);
+	if (status != 0) {
+		syslog(LOG_DEBUG, "ndr_rpc_bind: "
+		    "mlrpc_clh_bind, %s (0x%x)",
+		    xlate_nt_status(status), status);
+		switch (status) {
+		case RPC_NT_SERVER_TOO_BUSY:
+			/* Look for a new DC */
+			smb_ddiscover_bad_dc(server);
 			break;
+		default:
+			break;
 		}
-		/* FALLTHROUGH */
-	case NDR_DRC_OK:
-		return (NT_STATUS_SUCCESS);
+		ctx = mlrpc_clh_free(handle);
+		if (ctx != NULL) {
+			smbrdr_ctx_free(ctx);
+		}
 	}
 
-	syslog(LOG_DEBUG, "ndr_rpc_bind: "
-	    "ndr_clnt_bind, %s (0x%x)",
-	    xlate_nt_status(status), status);
-
-errout:
-	handle->clnt = NULL;
-	if (clnt != NULL) {
-		ndr_heap_destroy(clnt->heap);
-		free(clnt);
-	}
-	if (ctx != NULL) {
-		if (fd != -1)
-			(void) smb_fh_close(fd);
-		smbrdr_ctx_free(ctx);
-	}
-
 	return (status);
 }
 
 /*
- * Unbind and close the pipe to an RPC service.
+ * Unbind and close the pipe to an RPC service
+ * and cleanup the smb_ctx.
  *
- * If the heap has been preserved we need to go through an xa release.
- * The heap is preserved during an RPC call because that's where data
- * returned from the server is stored.
- *
- * Otherwise we destroy the heap directly.
+ * The heap may or may not be destroyed (see mlrpc_clh_free)
  */
 void
 ndr_rpc_unbind(mlsvc_handle_t *handle)
 {
-	ndr_client_t *clnt = handle->clnt;
-	struct smb_ctx *ctx = clnt->xa_private;
+	struct smb_ctx *ctx;
 
-	if (clnt->heap_preserved)
-		ndr_clnt_free_heap(clnt);
-	else
-		ndr_heap_destroy(clnt->heap);
+	ctx = mlrpc_clh_free(handle);
+	if (ctx != NULL)
+		smbrdr_ctx_free(ctx);
 
-	(void) smb_fh_close(clnt->xa_fd);
-	smbrdr_ctx_free(ctx);
-	free(clnt);
 	bzero(handle, sizeof (mlsvc_handle_t));
 }
 
--- old/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_util.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/mlsvc_util.c	Sun Mar 18 01:13:04 2018
@@ -425,3 +425,43 @@
 {
 	smbrdr_disconnect(server);
 }
+
+/*
+ * A few more helper functions for RPC services.
+ */
+
+/*
+ * Check whether or not the specified user has administrator privileges,
+ * i.e. is a member of Domain Admins or Administrators.
+ * Returns true if the user is an administrator, otherwise returns false.
+ */
+boolean_t
+ndr_is_admin(ndr_xa_t *xa)
+{
+	smb_netuserinfo_t *ctx = xa->pipe->np_user;
+
+	return (ctx->ui_flags & SMB_ATF_ADMIN);
+}
+
+/*
+ * Check whether or not the specified user has power-user privileges,
+ * i.e. is a member of Domain Admins, Administrators or Power Users.
+ * This is typically required for operations such as managing shares.
+ * Returns true if the user is a power user, otherwise returns false.
+ */
+boolean_t
+ndr_is_poweruser(ndr_xa_t *xa)
+{
+	smb_netuserinfo_t *ctx = xa->pipe->np_user;
+
+	return ((ctx->ui_flags & SMB_ATF_ADMIN) ||
+	    (ctx->ui_flags & SMB_ATF_POWERUSER));
+}
+
+int32_t
+ndr_native_os(ndr_xa_t *xa)
+{
+	smb_netuserinfo_t *ctx = xa->pipe->np_user;
+
+	return (ctx->ui_native_os);
+}
--- old/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/msgsvc_svc.c	Sun Mar 18 01:13:04 2018
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -30,8 +31,8 @@
 #include <syslog.h>
 #include <stdlib.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/ndl/msgsvc.ndl>
 #include <smbsrv/smbinfo.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/netr_logon.c	Sun Mar 18 01:13:04 2018
@@ -37,8 +37,8 @@
 #include <netdb.h>
 #include <thread.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/ndl/netlogon.ndl>
 #include <smbsrv/netrauth.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/samr_clnt.c	Sun Mar 18 01:13:04 2018
@@ -44,8 +44,8 @@
 #include <netdb.h>
 #include <sys/param.h>
 
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/smbinfo.h>
 #include <smbsrv/ntaccess.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/samr_svc.c	Sun Mar 18 01:13:04 2018
@@ -39,8 +39,8 @@
 #include <netdb.h>
 #include <assert.h>
 #include <grp.h>
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/smbinfo.h>
 #include <smbsrv/nmpipes.h>
--- old/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c	Sun Mar 18 01:13:04 2018
@@ -35,8 +35,8 @@
 #include <strings.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <libmlrpc/libmlrpc.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/libmlrpc.h>
 #include <smbsrv/libmlsvc.h>
 #include <smbsrv/smb.h>
 #include <smbsrv/ndl/spoolss.ndl>
--- old/usr/src/lib/smbsrv/libsmb/common/libsmb.h	Sun Mar 18 01:13:04 2018
+++ new/usr/src/lib/smbsrv/libsmb/common/libsmb.h	Sun Mar 18 01:13:04 2018
@@ -44,17 +44,18 @@
 #include <synch.h>
 #include <stdarg.h>
 
+#include <smb/nterror.h>
+#include <smb/ntstatus.h>
+#include <smb/wintypes.h>
+
 #include <smbsrv/string.h>
 #include <smbsrv/smb_idmap.h>
 #include <smbsrv/netbios.h>
 #include <smbsrv/smb_share.h>
-#include <smb/nterror.h>
-#include <smb/ntstatus.h>
 #include <smbsrv/smb_door.h>
 #include <smbsrv/alloc.h>
 #include <smbsrv/hash_table.h>
 #include <smbsrv/msgbuf.h>
-#include <smbsrv/wintypes.h>
 #include <smbsrv/smb_xdr.h>
 #include <smbsrv/smbinfo.h>
 #include <smbsrv/ntifs.h>
--- old/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c	Sun Mar 18 01:13:05 2018
+++ new/usr/src/lib/smbsrv/libsmb/common/smb_doorclnt.c	Sun Mar 18 01:13:05 2018
@@ -33,8 +33,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/mman.h>
+#include <smb/wintypes.h>
 #include <smbsrv/libsmb.h>
-#include <smbsrv/wintypes.h>
 #include <smbsrv/smb_door.h>
 
 static int smb_door_call(uint32_t, void *, xdrproc_t, void *, xdrproc_t);
--- old/usr/src/tools/quick/make-smbsrv	Sun Mar 18 01:13:05 2018
+++ new/usr/src/tools/quick/make-smbsrv	Sun Mar 18 01:13:05 2018
@@ -287,7 +287,7 @@
 usr/lib/reparse/libreparse_smb.so.1
 usr/lib/security/pam_smb_passwd.so.1
 usr/lib/smbsrv/dtrace
-usr/lib/smbsrv/libmlrpc.so.1
+usr/lib/libmlrpc.so.1
 usr/lib/smbsrv/libmlsvc.so.1
 usr/lib/smbsrv/libsmb.so.1
 usr/lib/smbsrv/libsmbns.so.1
--- old/usr/src/uts/common/smbsrv/Makefile	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/Makefile	Sun Mar 18 01:13:05 2018
@@ -33,7 +33,6 @@
 	mailslot.h		\
 	mbuf.h			\
 	msgbuf.h		\
-	ndr.h			\
 	netbios.h		\
 	netrauth.h		\
 	nmpipes.h		\
@@ -63,8 +62,7 @@
 	string.h		\
 	svrapi.h		\
 	winioctl.h		\
-	winsvc.h		\
-	wintypes.h
+	winsvc.h
 
 NDLHDRS= dssetup.ndl		\
 	eventlog.ndl		\
@@ -71,10 +69,8 @@
 	llsrpc.ndl		\
 	lsarpc.ndl		\
 	msgsvc.ndl		\
-	ndrtypes.ndl		\
 	netdfs.ndl		\
 	netlogon.ndl		\
-	rpcpdu.ndl		\
 	samrpc.ndl		\
 	security.ndl		\
 	spoolss.ndl		\
--- old/usr/src/uts/common/smbsrv/ndl/dssetup.ndl	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/ndl/dssetup.ndl	Sun Mar 18 01:13:05 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _DSSETUP_NDL_
@@ -34,7 +36,7 @@
  * except DsRoleGetPrimaryDomainInfo have been deprecated (MS04-011).
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 
 #define	DSSETUP_OPNUM_DsRoleGetPrimaryDomainInfo	0x00
--- old/usr/src/uts/common/smbsrv/ndl/eventlog.ndl	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/ndl/eventlog.ndl	Sun Mar 18 01:13:05 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_LOGR_NDL_
@@ -34,7 +36,7 @@
  ***********************************************************************
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 #define LOGR_OPNUM_EventLogClose		0x02
 #define LOGR_OPNUM_EventLogQueryCount		0x04
--- old/usr/src/uts/common/smbsrv/ndl/llsrpc.ndl	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/ndl/llsrpc.ndl	Sun Mar 18 01:13:05 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_LLSR_NDL_
@@ -41,7 +43,7 @@
  *	0x3b	closes the handle obtained via 0x3a
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 #define LLSR_OPNUM_Open			0x00
 #define LLSR_OPNUM_Close		0x01
--- old/usr/src/uts/common/smbsrv/ndl/lsarpc.ndl	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/ndl/lsarpc.ndl	Sun Mar 18 01:13:05 2018
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_LSA_NDL_
@@ -38,7 +39,7 @@
  * user principal name (UPN) form, such as john@example.com.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 
 #define	LSARPC_OPNUM_CloseHandle			0x00
--- old/usr/src/uts/common/smbsrv/ndl/msgsvc.ndl	Sun Mar 18 01:13:05 2018
+++ new/usr/src/uts/common/smbsrv/ndl/msgsvc.ndl	Sun Mar 18 01:13:05 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MSGSVC_NDL_
@@ -30,7 +32,7 @@
  * Message Service
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 #define	MSGSVCSEND_OPNUM_NetrSendMessage	0x00
 
--- old/usr/src/uts/common/smbsrv/ndl/netdfs.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/netdfs.ndl	Sun Mar 18 01:13:06 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _NETDFS_NDL_
@@ -30,7 +32,7 @@
  * NT Distributed File Service (NETDFS) RPC interface definition.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 
 #define	NETDFS_ABSTRACT_UUID		"4fc742e0-4a10-11cf-8273-00aa004ae673"
--- old/usr/src/uts/common/smbsrv/ndl/netlogon.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/netlogon.ndl	Sun Mar 18 01:13:06 2018
@@ -36,7 +36,7 @@
  ***********************************************************************
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 
 #define NETR_OPNUM_UasLogon			0x00
--- old/usr/src/uts/common/smbsrv/ndl/samrpc.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/samrpc.ndl	Sun Mar 18 01:13:06 2018
@@ -31,7 +31,7 @@
  * Security Accounts Manager RPC (SAMR) interface definition.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 /* Windows NT */
 #define SAMR_OPNUM_Connect			0x00	/* SamrConnect */
@@ -363,7 +363,7 @@
 #ifndef	NDRGEN
 #define SAMR_USER_PWLEN	256
 struct samr_user_password {
-	smb_wchar_t	Buffer[SAMR_USER_PWLEN];
+	ndr_wchar_t	Buffer[SAMR_USER_PWLEN];
 	DWORD Length;
 };
 #endif	/* NDRGEN */
--- old/usr/src/uts/common/smbsrv/ndl/spoolss.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/spoolss.ndl	Sun Mar 18 01:13:06 2018
@@ -20,12 +20,13 @@
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _SPOOLSS_NDL_
 #define	_SPOOLSS_NDL_
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 #include "security.ndl"
 
 #define TABLE_STRING 1
--- old/usr/src/uts/common/smbsrv/ndl/srvsvc.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/srvsvc.ndl	Sun Mar 18 01:13:06 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_LANMAN_NDL_
@@ -30,7 +32,7 @@
  * LanMan RPC (WKSSVC and SRVSVC) interface definitions.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 /*
  * WARNING: The cpp(1) macros in this file are not understood by
--- old/usr/src/uts/common/smbsrv/ndl/svcctl.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/svcctl.ndl	Sun Mar 18 01:13:06 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_SVCCTL_NDL_
@@ -32,7 +34,7 @@
  * stop services.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 /* Windows NT */
 #define SVCCTL_OPNUM_Close			0x00
--- old/usr/src/uts/common/smbsrv/ndl/winreg.ndl	Sun Mar 18 01:13:06 2018
+++ new/usr/src/uts/common/smbsrv/ndl/winreg.ndl	Sun Mar 18 01:13:06 2018
@@ -21,6 +21,8 @@
 /*
  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef _MLSVC_WINREG_NDL_
@@ -43,7 +45,7 @@
  * HKEY_PERFORMANCE_NLS  (HKPN)	Runtime performance information.
  */
 
-#include "ndrtypes.ndl"
+#include <libmlrpc/ndrtypes.ndl>
 
 /* Windows NT */
 #define WINREG_OPNUM_OpenHKCR		0x00
--- old/usr/src/uts/common/smbsrv/netrauth.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/netrauth.h	Sun Mar 18 01:13:07 2018
@@ -33,7 +33,7 @@
  */
 
 #include <sys/types.h>
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/netbios.h>
 #include <smbsrv/smbinfo.h>
 #include <netdb.h>
--- old/usr/src/uts/common/smbsrv/smb_door.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/smb_door.h	Sun Mar 18 01:13:07 2018
@@ -27,7 +27,7 @@
 #define	_SMBSRV_SMB_DOOR_H
 
 #include <sys/door.h>
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/smb_xdr.h>
 #include <smbsrv/smb_token.h>
 
--- old/usr/src/uts/common/smbsrv/smb_privilege.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/smb_privilege.h	Sun Mar 18 01:13:07 2018
@@ -28,7 +28,7 @@
 #ifndef _SMB_PRIVILEGE_H
 #define	_SMB_PRIVILEGE_H
 
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 
 #ifdef __cplusplus
 extern "C" {
--- old/usr/src/uts/common/smbsrv/smb_share.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/smb_share.h	Sun Mar 18 01:13:07 2018
@@ -29,11 +29,11 @@
 #define	_SMB_SHARE_H
 
 #include <sys/param.h>
+#include <smb/lmerr.h>
+#include <smb/wintypes.h>
 #include <smbsrv/string.h>
 #include <smbsrv/smb_inet.h>
 #include <smbsrv/hash_table.h>
-#include <smbsrv/wintypes.h>
-#include <smb/lmerr.h>
 
 #if !defined(_KERNEL) && !defined(_FAKE_KERNEL)
 #include <libshare.h>
--- old/usr/src/uts/common/smbsrv/smb_sid.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/smb_sid.h	Sun Mar 18 01:13:07 2018
@@ -29,7 +29,7 @@
 /*
  * Security Identifier (SID) interface definition.
  */
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 
 #ifdef __cplusplus
 extern "C" {
--- old/usr/src/uts/common/smbsrv/smb_xdr.h	Sun Mar 18 01:13:07 2018
+++ new/usr/src/uts/common/smbsrv/smb_xdr.h	Sun Mar 18 01:13:07 2018
@@ -34,7 +34,7 @@
 #include <sys/param.h>
 #include <sys/avl.h>
 #include <sys/list.h>
-#include <smbsrv/wintypes.h>
+#include <smb/wintypes.h>
 #include <smbsrv/smb_sid.h>
 #include <smbsrv/smbinfo.h>
 #include <smbsrv/smb_ioctl.h>
@@ -41,7 +41,6 @@
 #include <smbsrv/smb_sid.h>
 #include <smbsrv/smb_share.h>
 #include <smbsrv/smb_dfs.h>
-#include <smbsrv/wintypes.h>
 
 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
 #include <sys/sysmacros.h>
