From d862e9dcfb09f938951e8fed2145aeb8fdd8108a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 17 Apr 2011 12:46:42 +0200 Subject: [PATCH] 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. --- apps/telnetd/telnetd.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/telnetd/telnetd.c b/apps/telnetd/telnetd.c index 091db590f..012e8766a 100644 --- a/apps/telnetd/telnetd.c +++ b/apps/telnetd/telnetd.c @@ -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();