waf: added top level build rules
[samba.git] / librpc / rpc / dcerpc_error.c
index 69cd08b7c1c693a376dae65a705db007cee396b6..17095e50576f44c5d9bc548470b2c2f81021d68d 100644 (file)
@@ -61,7 +61,7 @@ static const struct dcerpc_fault_table dcerpc_faults[] =
        _FAULT_STR(DCERPC_NCA_S_FAULT_REMOTE_COMM_FAILURE),
        _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_EMPTY),
        _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_CLOSED),
-       _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_ORDER        ),
+       _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_ORDER),
        _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_DISCIPLINE),
        _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_COMM_ERROR),
        _FAULT_STR(DCERPC_NCA_S_FAULT_PIPE_MEMORY),
@@ -77,7 +77,7 @@ static const struct dcerpc_fault_table dcerpc_faults[] =
        _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
        _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
        _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
-       _FAULT_STR(NULL),
+       { NULL, 0 }
 #undef _FAULT_STR
 };
 
@@ -95,3 +95,29 @@ _PUBLIC_ const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code)
 
        return win_errstr(werr);
 }
+
+_PUBLIC_ NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code)
+{
+       /* TODO: add more mappings */
+       switch (fault_code) {
+       case DCERPC_FAULT_OP_RNG_ERROR:
+               return NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE;
+       case DCERPC_FAULT_UNK_IF:
+               return NT_STATUS_RPC_UNKNOWN_IF;
+       case DCERPC_FAULT_NDR:
+               return NT_STATUS_RPC_BAD_STUB_DATA;
+       case DCERPC_FAULT_INVALID_TAG:
+               return NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE;
+       case DCERPC_FAULT_CONTEXT_MISMATCH:
+               return NT_STATUS_RPC_SS_CONTEXT_MISMATCH;
+       case DCERPC_FAULT_OTHER:
+               return NT_STATUS_RPC_CALL_FAILED;
+       case DCERPC_FAULT_ACCESS_DENIED:
+               return NT_STATUS_ACCESS_DENIED;
+       case DCERPC_FAULT_SEC_PKG_ERROR:
+               return NT_STATUS_RPC_SEC_PKG_ERROR;
+       }
+
+       return NT_STATUS_RPC_PROTOCOL_ERROR;
+}
+