2 Unix SMB/CIFS implementation.
3 client error handling routines
4 Copyright (C) Andrew Tridgell 1994-1998
5 Copyright (C) James Myers 2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /***************************************************************************
26 Return an error message from the last response
27 ****************************************************************************/
28 const char *cli_errstr(struct cli_tree *tree)
30 switch (tree->session->transport->error.etype) {
33 tree->session->transport->error.e.dos.eclass,
34 tree->session->transport->error.e.dos.ecode);
36 return nt_errstr(tree->session->transport->error.e.nt_status);
39 return "socket_error";
51 /* Return the 32-bit NT status code from the last packet */
52 NTSTATUS cli_nt_error(struct cli_tree *tree)
54 switch (tree->session->transport->error.etype) {
56 return tree->session->transport->error.e.nt_status;
59 return dos_to_ntstatus(
60 tree->session->transport->error.e.dos.eclass,
61 tree->session->transport->error.e.dos.ecode);
63 return NT_STATUS_UNSUCCESSFUL;
66 return NT_STATUS_UNSUCCESSFUL;
72 return NT_STATUS_UNSUCCESSFUL;
76 /* Return the DOS error from the last packet - an error class and an error
78 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32_t *ecode)
80 if (cli->transport->error.etype == ETYPE_DOS) {
81 ntstatus_to_dos(cli->transport->error.e.nt_status,
86 if (eclass) *eclass = cli->transport->error.e.dos.eclass;
87 if (ecode) *ecode = cli->transport->error.e.dos.ecode;
91 /* Return true if the last packet was an error */
92 BOOL cli_is_error(struct cli_tree *tree)
94 return NT_STATUS_IS_ERR(cli_nt_error(tree));
97 /* Return true if the last error was a DOS error */
98 BOOL cli_is_dos_error(struct cli_tree *tree)
100 return tree->session->transport->error.etype == ETYPE_DOS;