2003-08-13 01:53:07 +00:00
/*
Unix SMB / CIFS implementation .
client error handling routines
Copyright ( C ) Andrew Tridgell 1994 - 1998
Copyright ( C ) James Myers 2003
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 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 01:53:07 +00:00
( at your option ) any later version .
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 .
You should have received a copy of the GNU General Public License
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 01:53:07 +00:00
*/
# include "includes.h"
2004-11-01 01:03:22 +00:00
# include "libcli/raw/libcliraw.h"
2003-08-13 01:53:07 +00:00
/***************************************************************************
Return an error message from the last response
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-04-02 04:53:27 +02:00
_PUBLIC_ const char * smbcli_errstr ( struct smbcli_tree * tree )
2003-08-13 01:53:07 +00:00
{
2004-02-08 00:51:07 +00:00
switch ( tree - > session - > transport - > error . etype ) {
2005-07-04 01:23:38 +00:00
case ETYPE_SMB :
2004-02-08 00:51:07 +00:00
return nt_errstr ( tree - > session - > transport - > error . e . nt_status ) ;
2003-08-13 01:53:07 +00:00
case ETYPE_SOCKET :
return " socket_error " ;
case ETYPE_NBT :
return " nbt_error " ;
case ETYPE_NONE :
return " no_error " ;
}
return NULL ;
}
/* Return the 32-bit NT status code from the last packet */
2008-04-02 04:53:27 +02:00
_PUBLIC_ NTSTATUS smbcli_nt_error ( struct smbcli_tree * tree )
2003-08-13 01:53:07 +00:00
{
2004-02-08 00:51:07 +00:00
switch ( tree - > session - > transport - > error . etype ) {
2005-07-04 01:23:38 +00:00
case ETYPE_SMB :
2004-02-08 00:51:07 +00:00
return tree - > session - > transport - > error . e . nt_status ;
2003-08-13 01:53:07 +00:00
case ETYPE_SOCKET :
return NT_STATUS_UNSUCCESSFUL ;
case ETYPE_NBT :
return NT_STATUS_UNSUCCESSFUL ;
case ETYPE_NONE :
return NT_STATUS_OK ;
}
return NT_STATUS_UNSUCCESSFUL ;
}
/* Return true if the last packet was an error */
2007-09-23 21:35:03 +00:00
bool smbcli_is_error ( struct smbcli_tree * tree )
2003-08-13 01:53:07 +00:00
{
2004-08-04 13:23:35 +00:00
return NT_STATUS_IS_ERR ( smbcli_nt_error ( tree ) ) ;
2003-08-13 01:53:07 +00:00
}