this software.\r
*/\r
\r
+#if defined(ENABLE_TELNET_SERVER) || defined(__DOXYGEN__)\r
+\r
/** \file\r
*\r
* TELNET Webserver Application. When connected to the uIP stack,\r
- * this will serve out connection information to the client.\r
+ * this will serve out raw TELNET to the client on port 23.\r
*/\r
\r
#define INCLUDE_FROM_TELNETSERVERAPP_C\r
#include "TELNETServerApp.h"\r
\r
/** Welcome message to send to a TELNET client when a connection is first made. */\r
-char PROGMEM WelcomeHeader[] = "********************************************\r\n"\r
- "* LUFA uIP Webserver (TELNET) *\r\n"\r
- "********************************************\r\n";\r
+const char PROGMEM WelcomeHeader[] = "********************************************\r\n"\r
+ "* LUFA uIP Webserver (TELNET) *\r\n"\r
+ "********************************************\r\n";\r
\r
/** Main TELNET menu, giving the user the list of available commands they may issue */\r
-char PROGMEM TELNETMenu[] = "\r\n"\r
- " Available Commands:\r\n"\r
- " c) List Active TCP Connections\r\n"\r
- "\r\nCommand>";\r
+const char PROGMEM TELNETMenu[] = "\r\n"\r
+ " == Available Commands: ==\r\n"\r
+ " c) List Active TCP Connections\r\n"\r
+ " =========================\r\n"\r
+ "\r\n>";\r
+ \r
+/** Header to print before the current connections are printed to the client */\r
+const char PROGMEM CurrentConnectionsHeader[] = "\r\n* Current TCP Connections: *\r\n";\r
\r
/** Initialization function for the simple HTTP webserver. */\r
void TELNETServerApp_Init(void)\r
\r
if (uip_connected())\r
{\r
+ /* New connection - initialize connection state values */\r
AppState->TELNETServer.CurrentState = TELNET_STATE_SendHeader;\r
}\r
\r
if (uip_acked())\r
{\r
+ /* Progress to the next state once the current state's data has been ACKed */\r
AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState; \r
}\r
\r
{\r
case 'c':\r
TELNETServerApp_DisplayTCPConnections();\r
- break; \r
+ break;\r
+ default:\r
+ strcpy_P(AppData, PSTR("Invalid Command.\r\n"));\r
+ uip_send(AppData, strlen(AppData));\r
+ break;\r
}\r
\r
AppState->TELNETServer.NextState = TELNET_STATE_SendMenu;\r
{\r
char* const AppData = (char*)uip_appdata;\r
\r
- strcpy(AppData, "\r\n* Current TCP Connections: *\r\n");\r
+ strcpy_P(AppData, CurrentConnectionsHeader);\r
\r
uint16_t ResponseLen = strlen(AppData);\r
uint8_t ActiveConnCount = 0;\r
if (CurrConnection->tcpstateflags != UIP_CLOSED)\r
{\r
/* Add the current connection's details to the out buffer */\r
- ResponseLen += sprintf(&AppData[ResponseLen], "%u) %02d.%02d.%02d.%02d (Local %u, Remote %u)\r\n",\r
- ++ActiveConnCount, CurrConnection->ripaddr.u8[0],\r
- CurrConnection->ripaddr.u8[1],\r
- CurrConnection->ripaddr.u8[2],\r
- CurrConnection->ripaddr.u8[3],\r
- HTONS(CurrConnection->lport), HTONS(CurrConnection->rport));\r
+ ResponseLen += sprintf_P(&AppData[ResponseLen], PSTR("%u) %02d.%02d.%02d.%02d (Local %u, Remote %u)\r\n"),\r
+ ++ActiveConnCount,\r
+ CurrConnection->ripaddr.u8[0],\r
+ CurrConnection->ripaddr.u8[1],\r
+ CurrConnection->ripaddr.u8[2],\r
+ CurrConnection->ripaddr.u8[3],\r
+ HTONS(CurrConnection->lport), HTONS(CurrConnection->rport));\r
}\r
}\r
\r
uip_send(AppData, ResponseLen);\r
-}
\ No newline at end of file
+}\r
+\r
+#endif\r