s3-nterr: add NT_STATUS_RPC_NT_PROTOCOL_ERROR to nt_errstr().
[ira/wip.git] / source3 / libsmb / nterr.c
index 774e50e700b9cce158e9b72021037fdc5a223321..a684f8d66e030ead28731394f75b61a05245e34b 100644 (file)
@@ -534,10 +534,14 @@ static const nt_err_code_struct nt_errs[] =
        { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE },
        { "NT_STATUS_DS_NO_MORE_RIDS", NT_STATUS_DS_NO_MORE_RIDS },
        { "NT_STATUS_NOT_A_REPARSE_POINT", NT_STATUS_NOT_A_REPARSE_POINT },
+       { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED },
         { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
        { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES },
        { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED },
        { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES },
+       { "NT_STATUS_RPC_CANNOT_SUPPORT", NT_STATUS_RPC_CANNOT_SUPPORT },
+       { "NT_STATUS_RPC_NT_CALL_FAILED", NT_STATUS_RPC_NT_CALL_FAILED },
+       { "NT_STATUS_RPC_NT_PROTOCOL_ERROR", NT_STATUS_RPC_NT_PROTOCOL_ERROR },
        { NULL, NT_STATUS(0) }
 };
 
@@ -648,13 +652,19 @@ nt_err_code_struct nt_err_desc[] =
 const char *nt_errstr(NTSTATUS nt_code)
 {
         int idx = 0;
+       char *result;
 
 #ifdef HAVE_LDAP
-        if (NT_STATUS_TYPE(nt_code) == NT_STATUS_TYPE_LDAP) {
+        if (NT_STATUS_IS_LDAP(nt_code)) {
                 return ldap_err2string(NT_STATUS_LDAP_CODE(nt_code));
        }
 #endif
 
+       if (NT_STATUS_IS_DOS(nt_code)) {
+               return smb_dos_err_name(NT_STATUS_DOS_CLASS(nt_code),
+                                       NT_STATUS_DOS_CODE(nt_code));
+       }
+
        while (nt_errs[idx].nt_errstr != NULL) {
                if (NT_STATUS_EQUAL(nt_errs[idx].nt_errcode, nt_code)) {
                         return nt_errs[idx].nt_errstr;
@@ -662,8 +672,10 @@ const char *nt_errstr(NTSTATUS nt_code)
                idx++;
        }
 
-       return talloc_asprintf(talloc_tos(), "NT code 0x%08x",
-                              NT_STATUS_V(nt_code));
+       result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
+                                NT_STATUS_V(nt_code));
+       SMB_ASSERT(result != NULL);
+       return result;
 }
 
 /************************************************************************
@@ -686,11 +698,34 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
        return nt_errstr(nt_code);
 }
 
+/*****************************************************************************
+ Returns an NT_STATUS constant as a string for inclusion in autogen C code.
+ *****************************************************************************/
+
+const char *get_nt_error_c_code(NTSTATUS nt_code)
+{
+       char *result;
+        int idx = 0;
+
+       while (nt_errs[idx].nt_errstr != NULL) {
+               if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 
+                    NT_STATUS_V(nt_code)) {
+                        return nt_errs[idx].nt_errstr;
+               }
+               idx++;
+       }
+
+       result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
+                                NT_STATUS_V(nt_code));
+       SMB_ASSERT(result);
+       return result;
+}
+
 /*****************************************************************************
  Returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
  *****************************************************************************/
 
-NTSTATUS nt_status_string_to_code(char *nt_status_str)
+NTSTATUS nt_status_string_to_code(const char *nt_status_str)
 {
         int idx = 0;