Automated merge with ssh://dev/flexnbd-c

This commit is contained in:
nick
2012-06-06 12:35:18 +01:00
6 changed files with 93 additions and 38 deletions

View File

@@ -111,6 +111,7 @@ void params_readwrite(
struct mode_readwrite_params* out,
char* s_ip_address,
char* s_port,
char* s_bind_address,
char* s_from,
char* s_length_or_filename
)
@@ -128,6 +129,9 @@ void params_readwrite(
SERVER_ERROR("Couldn't parse connection address '%s'",
s_ip_address);
if (s_bind_address != NULL && parse_ip_to_sockaddr(&out->connect_from.generic, s_bind_address) == 0)
SERVER_ERROR("Couldn't parse bind address '%s'", s_bind_address);
/* FIXME: duplicated from above */
out->connect_to.v4.sin_port = atoi(s_port);
if (out->connect_to.v4.sin_port < 0 || out->connect_to.v4.sin_port > 65535)
@@ -198,7 +202,7 @@ void read_serve_param( int c, char **ip_addr, char **ip_port, char **file, char
}
void read_readwrite_param( int c, char **ip_addr, char **ip_port, char **from, char **size)
void read_readwrite_param( int c, char **ip_addr, char **ip_port, char **bind_addr, char **from, char **size)
{
switch(c){
case 'h':
@@ -217,6 +221,9 @@ void read_readwrite_param( int c, char **ip_addr, char **ip_port, char **from, c
case 'S':
*size = optarg;
break;
case 'b':
*bind_addr = optarg;
break;
case 'v':
set_debug(1);
break;
@@ -250,7 +257,7 @@ void read_acl_param( int c, char **sock )
read_sock_param( c, sock, acl_help_text );
}
void read_mirror_param( int c, char **sock, char **ip_addr, char **ip_port )
void read_mirror_param( int c, char **sock, char **ip_addr, char **ip_port, char **bind_addr )
{
switch( c ){
case 'h':
@@ -266,6 +273,8 @@ void read_mirror_param( int c, char **sock, char **ip_addr, char **ip_port )
case 'p':
*ip_port = optarg;
break;
case 'b':
*bind_addr = optarg;
case 'v':
set_debug(1);
break;
@@ -320,8 +329,9 @@ int mode_serve( int argc, char *argv[] )
int mode_read( int argc, char *argv[] )
{
int c;
char *ip_addr = NULL;
char *ip_port = NULL;
char *ip_addr = NULL;
char *ip_port = NULL;
char *bind_addr = NULL;
char *from = NULL;
char *size = NULL;
int err = 0;
@@ -330,8 +340,11 @@ int mode_read( int argc, char *argv[] )
while (1){
c = getopt_long(argc, argv, read_short_options, read_options, NULL);
if ( c == -1 ) break;
read_readwrite_param( c, &ip_addr, &ip_port, &from, &size );
if ( c == -1 )
break;
read_readwrite_param( c, &ip_addr, &ip_port, &bind_addr, &from, &size );
}
if ( NULL == ip_addr || NULL == ip_port ) {
@@ -345,7 +358,7 @@ int mode_read( int argc, char *argv[] )
if ( err ) { exit_err( read_help_text ); }
memset( &readwrite, 0, sizeof( readwrite ) );
params_readwrite( 0, &readwrite, ip_addr, ip_port, from, size );
params_readwrite( 0, &readwrite, ip_addr, ip_port, bind_addr, from, size );
do_read( &readwrite );
return 0;
}
@@ -353,8 +366,9 @@ int mode_read( int argc, char *argv[] )
int mode_write( int argc, char *argv[] )
{
int c;
char *ip_addr = NULL;
char *ip_port = NULL;
char *ip_addr = NULL;
char *ip_port = NULL;
char *bind_addr = NULL;
char *from = NULL;
char *size = NULL;
int err = 0;
@@ -363,8 +377,10 @@ int mode_write( int argc, char *argv[] )
while (1){
c = getopt_long(argc, argv, write_short_options, write_options, NULL);
if ( c == -1 ) break;
read_readwrite_param( c, &ip_addr, &ip_port, &from, &size );
if ( c == -1 )
break;
read_readwrite_param( c, &ip_addr, &ip_port, &bind_addr, &from, &size );
}
if ( NULL == ip_addr || NULL == ip_port ) {
@@ -378,7 +394,7 @@ int mode_write( int argc, char *argv[] )
if ( err ) { exit_err( write_help_text ); }
memset( &readwrite, 0, sizeof( readwrite ) );
params_readwrite( 1, &readwrite, ip_addr, ip_port, from, size );
params_readwrite( 1, &readwrite, ip_addr, ip_port, bind_addr, from, size );
do_write( &readwrite );
return 0;
}
@@ -412,13 +428,13 @@ int mode_mirror( int argc, char *argv[] )
{
int c;
char *sock = NULL;
char *remote_argv[3] = {0};
char *remote_argv[4] = {0};
int err = 0;
while (1) {
c = getopt_long( argc, argv, mirror_short_options, mirror_options, NULL);
if ( -1 == c ) break;
read_mirror_param( c, &sock, &remote_argv[0], &remote_argv[1] );
read_mirror_param( c, &sock, &remote_argv[0], &remote_argv[1], &remote_argv[2] );
}
if ( NULL == sock ){
@@ -430,8 +446,11 @@ int mode_mirror( int argc, char *argv[] )
err = 1;
}
if ( err ) { exit_err( mirror_help_text ); }
do_remote_command( "mirror", sock, 2, remote_argv );
if (argv[2] == NULL)
do_remote_command( "mirror", sock, 2, remote_argv );
else
do_remote_command( "mirror", sock, 3, remote_argv );
return 0;
}