2003-08-13 01:53:07 +00:00
/*
Unix SMB / CIFS implementation .
client message handling routines
Copyright ( C ) Andrew Tridgell 1994 - 1998
Copyright ( C ) James J Myers 2003 < myersjj @ samba . org >
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"
2008-04-02 04:53:27 +02:00
# include "libcli/raw/raw_proto.h"
2007-09-08 13:27:14 +00:00
# include "libcli/libcli.h"
2003-08-13 01:53:07 +00:00
/****************************************************************************
start a message sequence
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-06 22:28:14 +00:00
bool smbcli_message_start ( struct smbcli_tree * tree , const char * host , const char * username ,
2004-02-08 00:51:07 +00:00
int * grp )
2003-08-13 01:53:07 +00:00
{
2004-08-04 13:23:35 +00:00
struct smbcli_request * req ;
2003-08-13 01:53:07 +00:00
2004-08-04 13:23:35 +00:00
req = smbcli_request_setup ( tree , SMBsendstrt , 0 , 0 ) ;
smbcli_req_append_string ( req , username , STR_TERMINATE ) ;
smbcli_req_append_string ( req , host , STR_TERMINATE ) ;
if ( ! smbcli_request_send ( req ) | |
! smbcli_request_receive ( req ) | |
smbcli_is_error ( tree ) ) {
smbcli_request_destroy ( req ) ;
2007-10-06 22:28:14 +00:00
return false ;
2003-08-13 01:53:07 +00:00
}
* grp = SVAL ( req - > in . vwv , VWV ( 0 ) ) ;
2004-08-04 13:23:35 +00:00
smbcli_request_destroy ( req ) ;
2003-08-13 01:53:07 +00:00
2007-10-06 22:28:14 +00:00
return true ;
2003-08-13 01:53:07 +00:00
}
/****************************************************************************
send a message
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-06 22:28:14 +00:00
bool smbcli_message_text ( struct smbcli_tree * tree , char * msg , int len , int grp )
2003-08-13 01:53:07 +00:00
{
2004-08-04 13:23:35 +00:00
struct smbcli_request * req ;
2003-08-13 01:53:07 +00:00
2004-08-04 13:23:35 +00:00
req = smbcli_request_setup ( tree , SMBsendtxt , 1 , 0 ) ;
2003-08-13 01:53:07 +00:00
SSVAL ( req - > out . vwv , VWV ( 0 ) , grp ) ;
2004-12-04 13:56:25 +00:00
smbcli_req_append_bytes ( req , ( const uint8_t * ) msg , len ) ;
2003-08-13 01:53:07 +00:00
2004-08-04 13:23:35 +00:00
if ( ! smbcli_request_send ( req ) | |
! smbcli_request_receive ( req ) | |
smbcli_is_error ( tree ) ) {
smbcli_request_destroy ( req ) ;
2007-10-06 22:28:14 +00:00
return false ;
2003-08-13 01:53:07 +00:00
}
2004-08-04 13:23:35 +00:00
smbcli_request_destroy ( req ) ;
2007-10-06 22:28:14 +00:00
return true ;
2003-08-13 01:53:07 +00:00
}
/****************************************************************************
end a message
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-06 22:28:14 +00:00
bool smbcli_message_end ( struct smbcli_tree * tree , int grp )
2003-08-13 01:53:07 +00:00
{
2004-08-04 13:23:35 +00:00
struct smbcli_request * req ;
2003-08-13 01:53:07 +00:00
2004-08-04 13:23:35 +00:00
req = smbcli_request_setup ( tree , SMBsendend , 1 , 0 ) ;
2003-08-13 01:53:07 +00:00
SSVAL ( req - > out . vwv , VWV ( 0 ) , grp ) ;
2004-08-04 13:23:35 +00:00
if ( ! smbcli_request_send ( req ) | |
! smbcli_request_receive ( req ) | |
smbcli_is_error ( tree ) ) {
smbcli_request_destroy ( req ) ;
2007-10-06 22:28:14 +00:00
return false ;
2003-08-13 01:53:07 +00:00
}
2004-08-04 13:23:35 +00:00
smbcli_request_destroy ( req ) ;
2007-10-06 22:28:14 +00:00
return true ;
2003-08-13 01:53:07 +00:00
}