mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
more fixes in the TELNET code
This commit is contained in:
parent
d5d0618f50
commit
5eb1f51e2d
6
TODO.txt
6
TODO.txt
@ -1,9 +1,13 @@
|
|||||||
- the aborted/timedout/closed condition in elua_uip_appcall is called more than once for the same socket ? add logs and check
|
x the aborted/timedout/closed condition in elua_uip_appcall is called more than once for the same socket ? add logs and check
|
||||||
|
x this seems to be a problem with PuTTY only, Windows and Linux 'telnet' commands do not exhibit this behaviour
|
||||||
- does the telnet socket need to be buffered? might be if there are clients that send data char by char (check Windows)
|
- does the telnet socket need to be buffered? might be if there are clients that send data char by char (check Windows)
|
||||||
- test telnet thoroughly
|
- test telnet thoroughly
|
||||||
- what happens with a TCP socket state when the connection is closed from the remote end for whatever reason? are the buffers freed?
|
- what happens with a TCP socket state when the connection is closed from the remote end for whatever reason? are the buffers freed?
|
||||||
- check if calling the uIP mainloop at only 2Hz is the right thing to do; doesn't this violate uIP's internal timeout mechanism?
|
- check if calling the uIP mainloop at only 2Hz is the right thing to do; doesn't this violate uIP's internal timeout mechanism?
|
||||||
- is uip_forced_poll used properly in uip.c ? what's the point of forced_poll anyway ?
|
- is uip_forced_poll used properly in uip.c ? what's the point of forced_poll anyway ?
|
||||||
|
- add per socket callbacks for remote close events (and maybe other error conditions)
|
||||||
|
- add C/Lua interrupts for different socket events: data received, socket closed, network link up/down ...
|
||||||
|
- the socket without buffers OR callback should probably be completely removed; the Lua side will only be able to create sockets with buffers?
|
||||||
- clean elua_uip.c after testing:
|
- clean elua_uip.c after testing:
|
||||||
- remove #ifdef/#define BUILD_CON_TCP at start of file
|
- remove #ifdef/#define BUILD_CON_TCP at start of file
|
||||||
- uncomment #ifndef in elua_uip_log
|
- uncomment #ifndef in elua_uip_log
|
||||||
|
@ -33,7 +33,6 @@ static p_elua_net_state_cb elua_uip_state_cb;
|
|||||||
|
|
||||||
#define TCPIP_LOG_BUFSIZE 80
|
#define TCPIP_LOG_BUFSIZE 80
|
||||||
#ifdef TCPIP_LOGS
|
#ifdef TCPIP_LOGS
|
||||||
const char *elua_uip_log_header = "[elua_uip] ";
|
|
||||||
|
|
||||||
static void elua_uip_log( const char *fmt, ... )
|
static void elua_uip_log( const char *fmt, ... )
|
||||||
{
|
{
|
||||||
@ -41,15 +40,12 @@ static void elua_uip_log( const char *fmt, ... )
|
|||||||
|
|
||||||
va_start( ap, fmt );
|
va_start( ap, fmt );
|
||||||
#ifndef BUILD_CON_TCP
|
#ifndef BUILD_CON_TCP
|
||||||
printf( elua_uip_log_header );
|
|
||||||
vprintf( fmt, ap );
|
vprintf( fmt, ap );
|
||||||
#else // #ifndef BUILD_CON_TCP
|
#else // #ifndef BUILD_CON_TCP
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char dstr[ TCPIP_LOG_BUFSIZE + 1 ];
|
char dstr[ TCPIP_LOG_BUFSIZE + 1 ];
|
||||||
|
|
||||||
vsnprintf( dstr, TCPIP_LOG_BUFSIZE, fmt, ap );
|
vsnprintf( dstr, TCPIP_LOG_BUFSIZE, fmt, ap );
|
||||||
for( i = 0; i < strlen( elua_uip_log_header ); i ++ )
|
|
||||||
platform_uart_send( CON_UART_ID, elua_uip_log_header[ i ] );
|
|
||||||
for( i = 0; i < strlen( dstr ); i ++ )
|
for( i = 0; i < strlen( dstr ); i ++ )
|
||||||
{
|
{
|
||||||
if( dstr[ i ] == '\n' )
|
if( dstr[ i ] == '\n' )
|
||||||
|
@ -30,9 +30,9 @@ static unsigned stdh_telnet_handle_input( char *buf, unsigned buflen )
|
|||||||
{
|
{
|
||||||
int skip;
|
int skip;
|
||||||
char *pdata = buf;
|
char *pdata = buf;
|
||||||
unsigned datalen = buflen;
|
int datalen = buflen;
|
||||||
|
|
||||||
while( ( pdata < buf + buflen ) && datalen )
|
while( ( pdata < buf + buflen ) && datalen > 0 )
|
||||||
{
|
{
|
||||||
if( *pdata != TELNET_IAC_CHAR ) // regular char, skip it
|
if( *pdata != TELNET_IAC_CHAR ) // regular char, skip it
|
||||||
pdata ++;
|
pdata ++;
|
||||||
@ -52,6 +52,8 @@ static unsigned stdh_telnet_handle_input( char *buf, unsigned buflen )
|
|||||||
}
|
}
|
||||||
else if( pdata[ 1 ] == TELNET_EOF ) // replace with EOF, remove one char from input
|
else if( pdata[ 1 ] == TELNET_EOF ) // replace with EOF, remove one char from input
|
||||||
*pdata ++ = STD_CTRLZ_CODE;
|
*pdata ++ = STD_CTRLZ_CODE;
|
||||||
|
else // assume that next character must be consumed anyway
|
||||||
|
skip = 2;
|
||||||
datalen -= skip;
|
datalen -= skip;
|
||||||
memmove( pdata, pdata + skip, datalen - ( pdata - buf ) );
|
memmove( pdata, pdata + skip, datalen - ( pdata - buf ) );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user