summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-11-09 19:23:57 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:44:55 +0100
commit0ce646d49a70b19d7ca54e0b83422f048dd39c1a (patch)
treec7d99b5727658a016c9f7127ec6c02a97ed07af1 /source4/libcli
parentafa5f256e9023332a50a410b53e3c1c94af0e85a (diff)
downloadsamba-0ce646d49a70b19d7ca54e0b83422f048dd39c1a.tar.gz
samba-0ce646d49a70b19d7ca54e0b83422f048dd39c1a.tar.bz2
samba-0ce646d49a70b19d7ca54e0b83422f048dd39c1a.zip
r25917: ndr: move ndr_map_error2ntstatus to errormap.c
metze (This used to be commit 8fc2e7737fc15f7265816f077e2a48a7a98f75b8)
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/util/error.h6
-rw-r--r--source4/libcli/util/errormap.c25
2 files changed, 30 insertions, 1 deletions
diff --git a/source4/libcli/util/error.h b/source4/libcli/util/error.h
index dd2de3da75..e054948fbe 100644
--- a/source4/libcli/util/error.h
+++ b/source4/libcli/util/error.h
@@ -22,6 +22,7 @@
#include "libcli/util/werror.h"
#include "libcli/util/doserr.h"
#include "libcli/util/ntstatus.h"
+#include "librpc/ndr/libndr.h"
/** NT error on DOS connection! (NT_STATUS_OK) */
bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2);
@@ -46,6 +47,9 @@ WERROR ntstatus_to_werror(NTSTATUS error);
*********************************************************************/
NTSTATUS map_nt_error_from_unix(int unix_error);
-
+/*********************************************************************
+ Map an NT error code from a NDR error code.
+*********************************************************************/
+NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err);
#endif /* _SAMBA_ERROR_H */
diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c
index 8d088e1e4b..b8458d4bf3 100644
--- a/source4/libcli/util/errormap.c
+++ b/source4/libcli/util/errormap.c
@@ -1375,3 +1375,28 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
/* Default return */
return NT_STATUS_UNSUCCESSFUL;
}
+
+NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err)
+{
+ switch (ndr_err) {
+ case NDR_ERR_SUCCESS:
+ return NT_STATUS_OK;
+ case NDR_ERR_BUFSIZE:
+ return NT_STATUS_BUFFER_TOO_SMALL;
+ case NDR_ERR_TOKEN:
+ return NT_STATUS_INTERNAL_ERROR;
+ case NDR_ERR_ALLOC:
+ return NT_STATUS_NO_MEMORY;
+ case NDR_ERR_ARRAY_SIZE:
+ return NT_STATUS_ARRAY_BOUNDS_EXCEEDED;
+ case NDR_ERR_INVALID_POINTER:
+ return NT_STATUS_INVALID_PARAMETER_MIX;
+ case NDR_ERR_UNREAD_BYTES:
+ return NT_STATUS_PORT_MESSAGE_TOO_LONG;
+ default:
+ break;
+ }
+
+ /* we should map all error codes to different status codes */
+ return NT_STATUS_INVALID_PARAMETER;
+}