mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-06-10 21:04:27 +00:00
Add option 'mtu' to udp_proxy
This commit is contained in:
parent
81f2fe9f08
commit
eb00bfd9c2
|
@ -88,6 +88,8 @@ int main( void )
|
||||||
" delay_ccs=%%d default: 0 (don't delay ChangeCipherSuite)\n" \
|
" delay_ccs=%%d default: 0 (don't delay ChangeCipherSuite)\n" \
|
||||||
" drop=%%d default: 0 (no dropped packets)\n" \
|
" drop=%%d default: 0 (no dropped packets)\n" \
|
||||||
" drop 1 packet every N packets\n" \
|
" drop 1 packet every N packets\n" \
|
||||||
|
" mtu=%%d default: 0 (unlimited)\n" \
|
||||||
|
" drop packets larger than N bytes\n" \
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -104,6 +106,7 @@ static struct options
|
||||||
int delay; /* delay 1 packet in N (none if 0) */
|
int delay; /* delay 1 packet in N (none if 0) */
|
||||||
int delay_ccs; /* delay ChangeCipherSpec */
|
int delay_ccs; /* delay ChangeCipherSpec */
|
||||||
int drop; /* drop 1 packet in N (none if 0) */
|
int drop; /* drop 1 packet in N (none if 0) */
|
||||||
|
int mtu; /* drop packets larger than this */
|
||||||
} opt;
|
} opt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -197,6 +200,12 @@ static void get_options( int argc, char *argv[] )
|
||||||
if( opt.drop < 0 || opt.drop > 10 || opt.drop == 1 )
|
if( opt.drop < 0 || opt.drop > 10 || opt.drop == 1 )
|
||||||
exit_usage( p, q );
|
exit_usage( p, q );
|
||||||
}
|
}
|
||||||
|
else if( strcmp( p, "mtu" ) == 0 )
|
||||||
|
{
|
||||||
|
opt.mtu = atoi( q );
|
||||||
|
if( opt.mtu < 0 || opt.mtu > MAX_MSG_SIZE )
|
||||||
|
exit_usage( p, q );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
exit_usage( p, NULL );
|
exit_usage( p, NULL );
|
||||||
}
|
}
|
||||||
|
@ -303,9 +312,11 @@ int handle_message( const char *way, int dst, int src )
|
||||||
print_packet( &cur, NULL );
|
print_packet( &cur, NULL );
|
||||||
|
|
||||||
/* do we want to drop, delay, or forward it? */
|
/* do we want to drop, delay, or forward it? */
|
||||||
if( opt.drop != 0 &&
|
if( ( opt.mtu != 0 &&
|
||||||
strcmp( cur.type, "ApplicationData" ) != 0 &&
|
cur.len > (unsigned) opt.mtu ) ||
|
||||||
++drop_cnt == opt.drop )
|
( opt.drop != 0 &&
|
||||||
|
strcmp( cur.type, "ApplicationData" ) != 0 &&
|
||||||
|
++drop_cnt == opt.drop ) )
|
||||||
{
|
{
|
||||||
drop_cnt = 0;
|
drop_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue