Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired.

Change over static strings in the Webserver project to use PROGMEM where possible.
pull/1469/head
Dean Camera 15 years ago
parent 92418433a5
commit aca7863350

@ -17,6 +17,7 @@
* - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project * - Increased the speed of both software and hardware TPI/PDI programming modes of the AVRISP project
* - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond * - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond
* - Webserver project now uses the board LEDs to indicate the current IP configuration state * - Webserver project now uses the board LEDs to indicate the current IP configuration state
* - Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired
* *
* <b>Fixed:</b> * <b>Fixed:</b>
* - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin

@ -28,16 +28,17 @@
this software. this software.
*/ */
#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__)
/** \file /** \file
* *
* DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the * DHCP Client Application. When connected to the uIP stack, this will retrieve IP configuration settings from the
* DHCP server on the network. * DHCP server on the network.
*/ */
#define INCLUDE_FROM_DHCPCLIENTAPP_C
#include "DHCPClientApp.h" #include "DHCPClientApp.h"
#if defined(ENABLE_DHCP_CLIENT) || defined(__DOXYGEN__)
/** Initialization function for the DHCP client. */ /** Initialization function for the DHCP client. */
void DHCPClientApp_Init(void) void DHCPClientApp_Init(void)
{ {
@ -175,7 +176,7 @@ void DHCPClientApp_Callback(void)
* *
* \return Size in bytes of the created DHCP packet * \return Size in bytes of the created DHCP packet
*/ */
uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState) static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState)
{ {
/* Erase existing packet data so that we start will all 0x00 DHCP header data */ /* Erase existing packet data so that we start will all 0x00 DHCP header data */
memset(DHCPHeader, 0, sizeof(DHCP_Header_t)); memset(DHCPHeader, 0, sizeof(DHCP_Header_t));
@ -214,7 +215,7 @@ uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMes
* *
* \return Number of bytes added to the DHCP packet * \return Number of bytes added to the DHCP packet
*/ */
uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData) static uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData)
{ {
/* Skip through the DHCP options list until the terminator option is found */ /* Skip through the DHCP options list until the terminator option is found */
while (*DHCPOptionList != DHCP_OPTION_END) while (*DHCPOptionList != DHCP_OPTION_END)
@ -238,7 +239,7 @@ uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t
* *
* \return Boolean true if the option was found in the DHCP packet's options list, false otherwise * \return Boolean true if the option was found in the DHCP packet's options list, false otherwise
*/ */
bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination) static bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination)
{ {
/* Look through the incoming DHCP packet's options list for the requested option */ /* Look through the incoming DHCP packet's options list for the requested option */
while (*DHCPOptionList != DHCP_OPTION_END) while (*DHCPOptionList != DHCP_OPTION_END)

@ -159,8 +159,11 @@
void DHCPClientApp_Init(void); void DHCPClientApp_Init(void);
void DHCPClientApp_Callback(void); void DHCPClientApp_Callback(void);
uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState); #if defined(INCLUDE_FROM_DHCPCLIENTAPP_C)
uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData); static uint16_t DHCPClientApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType,
bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination); uip_udp_appstate_t* AppState);
static uint8_t DHCPClientApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen,
void* OptionData);
static bool DHCPClientApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination);
#endif
#endif #endif

@ -56,12 +56,12 @@ const char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"
"Content-Type: text/plain\r\n\r\n" "Content-Type: text/plain\r\n\r\n"
"Error 404: File Not Found: /"; "Error 404: File Not Found: /";
/** Default MIME type sent if no other MIME type can be determined. */
const char PROGMEM DefaultMIMEType[] = "text/plain";
/** Default filename to fetch when a directory is requested */ /** Default filename to fetch when a directory is requested */
const char PROGMEM DefaultDirFileName[] = "index.htm"; const char PROGMEM DefaultDirFileName[] = "index.htm";
/** Default MIME type sent if no other MIME type can be determined. */
const char PROGMEM DefaultMIMEType[] = "text/plain";
/** List of MIME types for each supported file extension. */ /** List of MIME types for each supported file extension. */
const MIME_Type_t MIMETypes[] = const MIME_Type_t MIMETypes[] =
{ {
@ -174,7 +174,7 @@ static void HTTPServerApp_OpenRequestedFile(void)
char* RequestedFileName = strtok(NULL, " "); char* RequestedFileName = strtok(NULL, " ");
/* Must be a GET request, abort otherwise */ /* Must be a GET request, abort otherwise */
if (strcmp(RequestToken, "GET") != 0) if (strcmp_P(RequestToken, PSTR("GET")) != 0)
{ {
uip_abort(); uip_abort();
return; return;
@ -257,7 +257,7 @@ static void HTTPServerApp_SendResponseHeader(void)
} }
/* Add the end-of-line terminator and end-of-headers terminator after the MIME type */ /* Add the end-of-line terminator and end-of-headers terminator after the MIME type */
strcpy(&AppData[strlen(AppData)], "\r\n\r\n"); strcpy_P(&AppData[strlen(AppData)], PSTR("\r\n\r\n"));
/* Send the MIME header to the receiving client */ /* Send the MIME header to the receiving client */
uip_send(AppData, strlen(AppData)); uip_send(AppData, strlen(AppData));

@ -28,6 +28,8 @@
this software. this software.
*/ */
#if defined(ENABLE_TELNET_SERVER) || defined(__DOXYGEN__)
/** \file /** \file
* *
* TELNET Webserver Application. When connected to the uIP stack, * TELNET Webserver Application. When connected to the uIP stack,
@ -114,7 +116,7 @@ void TELNETServerApp_Callback(void)
TELNETServerApp_DisplayTCPConnections(); TELNETServerApp_DisplayTCPConnections();
break; break;
default: default:
strcpy(AppData, "Invalid Command.\r\n"); strcpy_P(AppData, PSTR("Invalid Command.\r\n"));
uip_send(AppData, strlen(AppData)); uip_send(AppData, strlen(AppData));
break; break;
} }
@ -144,14 +146,17 @@ static void TELNETServerApp_DisplayTCPConnections(void)
if (CurrConnection->tcpstateflags != UIP_CLOSED) if (CurrConnection->tcpstateflags != UIP_CLOSED)
{ {
/* Add the current connection's details to the out buffer */ /* Add the current connection's details to the out buffer */
ResponseLen += sprintf(&AppData[ResponseLen], "%u) %02d.%02d.%02d.%02d (Local %u, Remote %u)\r\n", ResponseLen += sprintf_P(&AppData[ResponseLen], PSTR("%u) %02d.%02d.%02d.%02d (Local %u, Remote %u)\r\n"),
++ActiveConnCount, CurrConnection->ripaddr.u8[0], ++ActiveConnCount,
CurrConnection->ripaddr.u8[1], CurrConnection->ripaddr.u8[0],
CurrConnection->ripaddr.u8[2], CurrConnection->ripaddr.u8[1],
CurrConnection->ripaddr.u8[3], CurrConnection->ripaddr.u8[2],
HTONS(CurrConnection->lport), HTONS(CurrConnection->rport)); CurrConnection->ripaddr.u8[3],
HTONS(CurrConnection->lport), HTONS(CurrConnection->rport));
} }
} }
uip_send(AppData, ResponseLen); uip_send(AppData, ResponseLen);
} }
#endif

@ -80,7 +80,9 @@ void uIPManagement_Init(void)
HTTPServerApp_Init(); HTTPServerApp_Init();
/* TELNET Server Initialization */ /* TELNET Server Initialization */
#if defined(ENABLE_TELNET_SERVER)
TELNETServerApp_Init(); TELNETServerApp_Init();
#endif
} }
/** uIP Management function. This function manages the uIP stack when called while an RNDIS device has been /** uIP Management function. This function manages the uIP stack when called while an RNDIS device has been
@ -106,9 +108,11 @@ void uIPManagement_TCPCallback(void)
case HTONS(HTTP_SERVER_PORT): case HTONS(HTTP_SERVER_PORT):
HTTPServerApp_Callback(); HTTPServerApp_Callback();
break; break;
#if defined(ENABLE_TELNET_SERVER)
case HTONS(TELNET_SERVER_PORT): case HTONS(TELNET_SERVER_PORT):
TELNETServerApp_Callback(); TELNETServerApp_Callback();
break; break;
#endif
} }
} }

@ -78,6 +78,12 @@
* <td><b>Description:</b></td> * <td><b>Description:</b></td>
* </tr> * </tr>
* <tr> * <tr>
* <td>ENABLE_TELNET_SERVER</td>
* <td>Makefile CDEFS</td>
* <td>When defined, this enables the TELNET server in addition to the HTTP webserver, which listens for incomming connections
* and processes user commands.</td>
* </tr>
* <tr>
* <td>ENABLE_DHCP_CLIENT</td> * <td>ENABLE_DHCP_CLIENT</td>
* <td>Makefile CDEFS</td> * <td>Makefile CDEFS</td>
* <td>When defined, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server.</td> * <td>When defined, this enables the DHCP client for dynamic IP allocation of the network settings from a DHCP server.</td>

@ -201,6 +201,7 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources # Place -D or -U options here for C sources
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS) CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)
CDEFS += -DENABLE_DHCP_CLIENT CDEFS += -DENABLE_DHCP_CLIENT
CDEFS += -DENABLE_TELNET_SERVER
CDEFS += -DMAX_URI_LENGTH=50 CDEFS += -DMAX_URI_LENGTH=50
CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=3 CDEFS += -DUIP_CONF_UDP="defined(ENABLE_DHCP_CLIENT)" -DUIP_CONF_TCP=1 -DUIP_CONF_UDP_CONNS=1 -DUIP_CONF_MAX_CONNECTIONS=3

Loading…
Cancel
Save