Allow only one Telnet connection at a time.

As the session state management of Telnet server is a single static variable allowing more than one connection leads to inconsistencies.
This commit is contained in:
Oliver Schmidt 2011-04-17 12:46:42 +02:00
parent 831312e311
commit d862e9dcfb

View File

@ -186,15 +186,14 @@ PROCESS_THREAD(telnetd_process, ev, data)
{
PROCESS_BEGIN();
tcp_listen(UIP_HTONS(23));
buf_init(&buf);
shell_init();
#if TELNETD_CONF_GUI
telnetd_gui_init();
#endif /* TELNETD_CONF_GUI */
tcp_listen(UIP_HTONS(23));
while(1) {
PROCESS_WAIT_EVENT();
if(ev == tcpip_event) {
@ -229,11 +228,6 @@ senddata(void)
}
/*---------------------------------------------------------------------------*/
static void
closed(void)
{
}
/*---------------------------------------------------------------------------*/
static void
get_char(u8_t c)
{
PRINTF("telnetd: get_char '%c' %d %d\n", c, c, s.bufptr);
@ -347,6 +341,7 @@ void
telnetd_appcall(void *ts)
{
if(uip_connected()) {
tcp_unlisten(UIP_HTONS(23));
tcp_markconn(uip_conn, &s);
buf_init(&buf);
s.bufptr = 0;
@ -363,7 +358,7 @@ telnetd_appcall(void *ts)
uip_aborted() ||
uip_timedout()) {
shell_stop();
closed();
tcp_listen(UIP_HTONS(23));
}
if(uip_acked()) {
acked();