2023-03-03 20:48:25 +03:00
/*
2003-08-13 05:53:07 +04:00
Unix SMB / CIFS implementation .
NT error code constants
Copyright ( C ) Andrew Tridgell 1992 - 2000
Copyright ( C ) John H Terpstra 1996 - 2000
Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 2000
Copyright ( C ) Paul Ashton 1998 - 2000
2011-03-04 22:27:57 +03:00
2003-08-13 05:53:07 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +04:00
( at your option ) any later version .
2011-03-04 22:27:57 +03:00
2003-08-13 05:53:07 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2011-03-04 22:27:57 +03:00
2003-08-13 05:53:07 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
2007-09-24 01:35:03 +04:00
# ifndef _NTSTATUS_H
# define _NTSTATUS_H
2023-05-08 04:25:34 +03:00
# include <stdint.h>
2017-01-12 05:33:45 +03:00
# include "libcli/util/ntstatus_gen.h"
2023-03-03 20:48:25 +03:00
/* the following rather strange looking definitions of NTSTATUS
2007-09-24 01:35:03 +04:00
are there in order to catch common coding errors where different error types
are mixed up . This is especially important as we slowly convert Samba
2023-03-03 20:48:25 +03:00
from using bool for internal functions
2007-09-24 01:35:03 +04:00
*/
2007-10-05 16:05:40 +04:00
# if defined(HAVE_IMMEDIATE_STRUCTURES)
2007-09-24 01:35:03 +04:00
typedef struct { uint32_t v ; } NTSTATUS ;
# define NT_STATUS(x) ((NTSTATUS) { x })
# define NT_STATUS_V(x) ((x).v)
2007-10-05 16:05:40 +04:00
# else
typedef uint32_t NTSTATUS ;
# define NT_STATUS(x) (x)
# define NT_STATUS_V(x) (x)
# endif
2003-08-13 05:53:07 +04:00
2017-01-12 05:33:45 +03:00
/* Win32 status codes. */
2003-08-13 05:53:07 +04:00
# define ERROR_INVALID_PARAMETER NT_STATUS(0x0057)
# define ERROR_INSUFFICIENT_BUFFER NT_STATUS(0x007a)
2017-01-12 05:33:45 +03:00
# define NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS NT_STATUS(0x2071)
# define NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION NT_STATUS(0x2177)
# define NT_STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP NT_STATUS(0xC05D0000)
/* Other error codes that aren't in the list we use */
# define STATUS_MORE_ENTRIES NT_STATUS_MORE_ENTRIES
# define STATUS_BUFFER_OVERFLOW NT_STATUS_BUFFER_OVERFLOW
# define STATUS_NO_MORE_FILES NT_STATUS_NO_MORE_FILES
# define STATUS_INVALID_EA_NAME NT_STATUS_INVALID_EA_NAME
# define STATUS_SOME_UNMAPPED NT_STATUS_SOME_NOT_MAPPED
# define NT_STATUS_ABIOS_NOT_PRESENT NT_STATUS(0xC0000000 | 0x010f)
# define NT_STATUS_ABIOS_LID_NOT_EXIST NT_STATUS(0xC0000000 | 0x0110)
# define NT_STATUS_ABIOS_LID_ALREADY_OWNED NT_STATUS(0xC0000000 | 0x0111)
# define NT_STATUS_ABIOS_NOT_LID_OWNER NT_STATUS(0xC0000000 | 0x0112)
# define NT_STATUS_ABIOS_INVALID_COMMAND NT_STATUS(0xC0000000 | 0x0113)
# define NT_STATUS_ABIOS_INVALID_LID NT_STATUS(0xC0000000 | 0x0114)
# define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE NT_STATUS(0xC0000000 | 0x0115)
# define NT_STATUS_ABIOS_INVALID_SELECTOR NT_STATUS(0xC0000000 | 0x0116)
# define NT_STATUS_HANDLE_NOT_WAITABLE NT_STATUS(0xC0000000 | 0x0036)
# define NT_STATUS_DEVICE_POWER_FAILURE NT_STATUS(0xC0000000 | 0x009e)
# define NT_STATUS_VHD_SHARED NT_STATUS(0xC05CFF0A)
# define NT_STATUS_SMB_BAD_CLUSTER_DIALECT NT_STATUS(0xC05D0001)
# define NT_STATUS_NO_SUCH_JOB NT_STATUS(0xC0000000 | 0xEDE)
2003-08-13 05:53:07 +04:00
/*
- - - - - - - - - - - - - -
/ \
/ REST \
/ IN \
/ PEACE \
/ \
| NT_STATUS_NOPROBLEMO |
| |
| |
| 4 September |
| |
| 2001 |
* | * * * | *
_________ ) / \ \ _ //(\/(/\)/\//\/\///|_)_______
*/
/* I use NT_STATUS_FOOBAR when I have no idea what error code to use -
* this means we need a torture test */
# define NT_STATUS_FOOBAR NT_STATUS_UNSUCCESSFUL
2007-09-24 01:35:03 +04:00
/*****************************************************************************
returns an NT error message . not amazingly helpful , but better than a number .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
const char * nt_errstr ( NTSTATUS nt_code ) ;
/************************************************************************
2023-09-22 03:04:20 +03:00
Print friendlier version of NT error code
2007-09-24 01:35:03 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
const char * get_friendly_nt_error_msg ( NTSTATUS nt_code ) ;
/*****************************************************************************
returns an NT_STATUS constant as a string for inclusion in autogen C code
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2011-05-04 09:30:01 +04:00
const char * get_nt_error_c_code ( void * mem_ctx , NTSTATUS nt_code ) ;
2007-09-24 01:35:03 +04:00
/*****************************************************************************
returns the NT_STATUS constant matching the string supplied ( as an NTSTATUS )
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS nt_status_string_to_code ( const char * nt_status_str ) ;
2009-11-25 07:30:20 +03:00
/* we need these here for openchange */
# ifndef likely
# define likely(x) (x)
# endif
# ifndef unlikely
# define unlikely(x) (x)
# endif
2009-09-17 20:07:44 +04:00
# define NT_STATUS_IS_OK(x) (likely(NT_STATUS_V(x) == 0))
# define NT_STATUS_IS_ERR(x) (unlikely((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000))
2008-10-23 17:35:21 +04:00
# define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
2007-09-24 01:35:03 +04:00
2014-03-04 05:11:09 +04:00
/*
* These macros ( with the embedded return ) are considered poor coding
* style per README . Coding
*
* Please do not use them in new code , and do not rely on them in
* projects external to Samba as they will go away at some point .
*/
2007-09-24 01:35:03 +04:00
# define NT_STATUS_HAVE_NO_MEMORY(x) do { \
2009-09-17 20:07:44 +04:00
if ( unlikely ( ! ( x ) ) ) { \
2007-09-24 01:35:03 +04:00
return NT_STATUS_NO_MEMORY ; \
} \
} while ( 0 )
2023-09-22 03:04:20 +03:00
/* This variant is for when you want to free a local
2009-06-02 11:25:47 +04:00
temporary memory context in the error path */
# define NT_STATUS_HAVE_NO_MEMORY_AND_FREE(x, ctx) do { \
if ( ! ( x ) ) { \
talloc_free ( ctx ) ; \
return NT_STATUS_NO_MEMORY ; \
} \
} while ( 0 )
2007-09-24 01:35:03 +04:00
# define NT_STATUS_IS_OK_RETURN(x) do { \
if ( NT_STATUS_IS_OK ( x ) ) { \
return x ; \
} \
} while ( 0 )
# define NT_STATUS_NOT_OK_RETURN(x) do { \
if ( ! NT_STATUS_IS_OK ( x ) ) { \
return x ; \
} \
} while ( 0 )
2009-10-16 10:04:19 +04:00
# define NT_STATUS_NOT_OK_RETURN_AND_FREE(x, ctx) do { \
if ( ! NT_STATUS_IS_OK ( x ) ) { \
talloc_free ( ctx ) ; \
return x ; \
} \
} while ( 0 )
2007-09-24 01:35:03 +04:00
# define NT_STATUS_IS_ERR_RETURN(x) do { \
if ( NT_STATUS_IS_ERR ( x ) ) { \
return x ; \
} \
} while ( 0 )
# define NT_STATUS_NOT_ERR_RETURN(x) do { \
if ( ! NT_STATUS_IS_ERR ( x ) ) { \
return x ; \
} \
} while ( 0 )
/* this defines special NTSTATUS codes to represent DOS errors. I
have chosen this macro to produce status codes in the invalid
NTSTATUS range */
# define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
# define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
# define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
# define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
/* define ldap error codes as NTSTATUS codes */
# define NT_STATUS_LDAP(code) NT_STATUS(0xF2000000 | code)
# define NT_STATUS_IS_LDAP(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF2000000)
# define NT_STATUS_LDAP_CODE(status) (NT_STATUS_V(status) & ~0xFF000000)
2010-03-17 21:48:56 +03:00
# define NT_STATUS_IS_RPC(status) \
( ( ( NT_STATUS_V ( status ) & 0xFFFF ) = = 0xC0020000 ) | | \
( ( NT_STATUS_V ( status ) & 0xFFFF ) = = 0xC0030000 ) )
2007-09-24 01:35:03 +04:00
# endif /* _NTSTATUS_H */