2006-05-02 17:08:38 +04:00
/*
Unix SMB / CIFS implementation .
dcerpc torture tests
Copyright ( C ) Andrew Tridgell 2003
Copyright ( C ) Rafal Szczesniak 2006
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
2006-05-02 17:08:38 +04: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 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2006-05-02 17:08:38 +04:00
*/
# include "includes.h"
# include "torture/torture.h"
# include "lib/events/events.h"
2006-05-05 13:52:12 +04:00
# include "libcli/composite/composite.h"
2006-05-02 17:08:38 +04:00
# include "librpc/gen_ndr/ndr_lsa.h"
# include "lib/cmdline/popt_common.h"
# include "librpc/rpc/dcerpc.h"
# include "torture/rpc/rpc.h"
/*
This test initiates multiple rpc bind requests and verifies
whether all of them are served .
*/
BOOL torture_async_bind ( struct torture_context * torture )
{
NTSTATUS status ;
TALLOC_CTX * mem_ctx ;
struct event_context * evt_ctx ;
int i ;
const char * binding_string ;
struct cli_credentials * creds ;
2006-05-05 13:52:12 +04:00
extern int torture_numasync ;
2006-05-02 17:08:38 +04:00
2006-05-05 13:52:12 +04:00
struct composite_context * * bind_req ;
struct dcerpc_pipe * * pipe ;
2007-08-20 00:46:45 +04:00
const struct ndr_interface_table * * table ;
2006-05-02 17:08:38 +04:00
2006-10-18 18:23:19 +04:00
if ( ! torture_setting_bool ( torture , " async " , False ) ) {
2006-05-07 23:26:48 +04:00
printf ( " async bind test disabled - enable async tests to use \n " ) ;
2006-05-03 15:24:17 +04:00
return True ;
}
2006-05-05 13:52:12 +04:00
2006-10-18 18:23:19 +04:00
binding_string = torture_setting_string ( torture , " binding " , NULL ) ;
2006-05-02 17:08:38 +04:00
/* talloc context */
mem_ctx = talloc_init ( " torture_async_bind " ) ;
if ( mem_ctx = = NULL ) return False ;
2006-05-05 13:52:12 +04:00
bind_req = talloc_array ( torture , struct composite_context * , torture_numasync ) ;
if ( bind_req = = NULL ) return False ;
pipe = talloc_array ( torture , struct dcerpc_pipe * , torture_numasync ) ;
if ( pipe = = NULL ) return False ;
2007-08-20 00:46:45 +04:00
table = talloc_array ( torture , const struct ndr_interface_table * , torture_numasync ) ;
2006-05-05 13:52:12 +04:00
if ( table = = NULL ) return False ;
2006-05-02 17:08:38 +04:00
/* credentials */
creds = cmdline_credentials ;
2007-05-17 12:47:04 +04:00
/* event context */
evt_ctx = cli_credentials_get_event_context ( creds ) ;
if ( evt_ctx = = NULL ) return False ;
2006-05-05 13:52:12 +04:00
/* send bind requests */
for ( i = 0 ; i < torture_numasync ; i + + ) {
2007-08-20 01:23:03 +04:00
table [ i ] = & ndr_table_lsarpc ;
2006-10-13 17:01:48 +04:00
bind_req [ i ] = dcerpc_pipe_connect_send ( mem_ctx , binding_string ,
2006-05-02 17:08:38 +04:00
table [ i ] , creds , evt_ctx ) ;
}
2006-05-05 13:52:12 +04:00
/* recv bind requests */
for ( i = 0 ; i < torture_numasync ; i + + ) {
2006-05-02 17:08:38 +04:00
status = dcerpc_pipe_connect_recv ( bind_req [ i ] , mem_ctx , & pipe [ i ] ) ;
2006-05-05 13:52:12 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
printf ( " async rpc connection failed: %s \n " , nt_errstr ( status ) ) ;
return False ;
}
2006-05-02 17:08:38 +04:00
}
talloc_free ( mem_ctx ) ;
return True ;
}