summaryrefslogtreecommitdiff
path: root/source3/libsmb/clierror.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
committerAndrew Tridgell <tridge@samba.org>2001-08-27 08:19:43 +0000
commite8e98c9ea0690e3acf1126b50882e59e1056c7b3 (patch)
tree2fa75bc825f7e5da041809fe49080e3319656506 /source3/libsmb/clierror.c
parent3820578473da81b7ae0dfa978605da809be59f62 (diff)
downloadsamba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.gz
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.tar.bz2
samba-e8e98c9ea0690e3acf1126b50882e59e1056c7b3.zip
converted smbd to use NTSTATUS by default
major changes include: - added NSTATUS type - added automatic mapping between dos and nt error codes - changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT() these calls auto-translate to the client error code system - got rid of the cached error code and the writebmpx code We eventually will need to also: - get rid of BOOL, so we don't lose error info - replace all ERROR_DOS() calls with ERROR_NT() calls but that is too much for one night (This used to be commit 83d9896c1ea8be796192b51a4678c2a3b87f7518)
Diffstat (limited to 'source3/libsmb/clierror.c')
-rw-r--r--source3/libsmb/clierror.c49
1 files changed, 11 insertions, 38 deletions
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 59a11dcc60..896360ce98 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -75,7 +75,6 @@ char *cli_errstr(struct cli_state *cli)
int i;
/* Case #1: 32-bit NT errors */
-
if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) {
uint32 status = IVAL(cli->inbuf,smb_rcls);
@@ -90,7 +89,6 @@ char *cli_errstr(struct cli_state *cli)
return cli_smb_errstr(cli);
/* Case #3: RAP error */
-
for (i = 0; rap_errmap[i].message != NULL; i++) {
if (rap_errmap[i].err == cli->rap_error) {
return rap_errmap[i].message;
@@ -103,69 +101,45 @@ char *cli_errstr(struct cli_state *cli)
return error_message;
}
-/* Return the 32-bit NT status code from the last packet */
+/* Return the 32-bit NT status code from the last packet */
uint32 cli_nt_error(struct cli_state *cli)
{
int flgs2 = SVAL(cli->inbuf,smb_flg2);
if (!(flgs2 & FLAGS2_32_BIT_ERROR_CODES)) {
-
- /* Eek! We've requested a NT error when the packet that
- came back does not contain one. What do we return
- here? */
-
- DEBUG(1, ("ERROR: cli_nt_error() called to read a status code "
- "from a packet that does not contain one!\n"));
-
- return NT_STATUS_UNSUCCESSFUL;
+ int class = CVAL(cli->inbuf,smb_rcls);
+ int code = SVAL(cli->inbuf,smb_err);
+ return dos_to_ntstatus(class, code);
}
return IVAL(cli->inbuf,smb_rcls);
}
+
/* Return the DOS error from the last packet - an error class and an error
code. */
-
-void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num)
+void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode)
{
int flgs2;
char rcls;
int code;
- if (eclass)
- *eclass = 0;
-
- if (num)
- *num = 0;
-
- if(!cli->initialised)
- return;
-
- if(!cli->inbuf)
- return;
+ if(!cli->initialised) return;
flgs2 = SVAL(cli->inbuf,smb_flg2);
if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) {
- /* Eek! We've requested a DOS error when the packet that
- came back does not contain one. What do we return
- here? */
-
- DEBUG(1, ("ERROR: cli_dos_error() called to read a dos error "
- "code from a packet that does not contain one!\n"));
-
+ uint32 ntstatus = IVAL(cli->inbuf, smb_rcls);
+ ntstatus_to_dos(ntstatus, eclass, ecode);
return;
}
rcls = CVAL(cli->inbuf,smb_rcls);
code = SVAL(cli->inbuf,smb_err);
- if (rcls == 0)
- return;
-
if (eclass) *eclass = rcls;
- if (num ) *num = code;
+ if (ecode) *ecode = code;
}
/* Return a UNIX errno from a dos error class, error number tuple */
@@ -256,9 +230,7 @@ BOOL cli_is_error(struct cli_state *cli)
uint32 flgs2 = SVAL(cli->inbuf,smb_flg2), rcls = 0;
if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) {
-
/* Return error is error bits are set */
-
rcls = IVAL(cli->inbuf, smb_rcls);
return (rcls & 0xF0000000) == 0xC0000000;
}
@@ -286,3 +258,4 @@ BOOL cli_is_dos_error(struct cli_state *cli)
return cli_is_error(cli) && !(flgs2 & FLAGS2_32_BIT_ERROR_CODES);
}
+