From: dak664 <da...@us...> - 2011-07-25 19:13:05
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "contiki". The branch, master has been updated via 0774fef8279ed5d8e96313a0315f008f8a808933 (commit) via e3368ffb67acf6aff7d0681ff1539070b0e1b803 (commit) from 0e59a0360e33edc7b12d19bfa79e14c6def7f3cc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0774fef8279ed5d8e96313a0315f008f8a808933 Author: David Kopf <da...@em...> Date: Mon Jul 25 15:12:12 2011 -0400 Add explicit RADIOSTATS to platform contiki-conf.h diff --git a/platform/avr-atmega128rfa1/contiki-conf.h b/platform/avr-atmega128rfa1/contiki-conf.h index 34c8cab..39b1eeb 100644 --- a/platform/avr-atmega128rfa1/contiki-conf.h +++ b/platform/avr-atmega128rfa1/contiki-conf.h @@ -88,6 +88,9 @@ unsigned long clock_seconds(void); /* Starting address for code received via the codeprop facility. Not tested on Raven */ //#define EEPROMFS_ADDR_CODEPROP 0x8000 +/* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */ +#define RADIOSTATS 1 + /* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */ #if RF230BB #undef PACKETBUF_CONF_HDR_SIZE //Use the packetbuf default for header size diff --git a/platform/avr-raven/contiki-conf.h b/platform/avr-raven/contiki-conf.h index 0970093..fa79218 100644 --- a/platform/avr-raven/contiki-conf.h +++ b/platform/avr-raven/contiki-conf.h @@ -88,6 +88,9 @@ unsigned long clock_seconds(void); /* Starting address for code received via the codeprop facility. Not tested on Raven */ //#define EEPROMFS_ADDR_CODEPROP 0x8000 +/* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */ +#define RADIOSTATS 1 + /* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */ #if RF230BB #undef PACKETBUF_CONF_HDR_SIZE //Use the packetbuf default for header size @@ -100,7 +103,7 @@ unsigned long clock_seconds(void); #define UIP_CONF_ICMP6 1 #define UIP_CONF_UDP 1 #define UIP_CONF_TCP 1 -#define UIP_CONF_IPV6_RPL 0 +#define UIP_CONF_IPV6_RPL 1 #define NETSTACK_CONF_NETWORK sicslowpan_driver #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06 #else commit e3368ffb67acf6aff7d0681ff1539070b0e1b803 Author: David Kopf <da...@em...> Date: Mon Jul 25 15:08:49 2011 -0400 Fix avr progmem string accesses, add DEBUGLOGIC, configure sky defaults diff --git a/apps/webserver-nano/httpd-fs.c b/apps/webserver-nano/httpd-fs.c index 23552a2..b87b13d 100644 --- a/apps/webserver-nano/httpd-fs.c +++ b/apps/webserver-nano/httpd-fs.c @@ -58,27 +58,6 @@ httpd_fs_get_size() return HTTPD_FS_SIZE; } /*-----------------------------------------------------------------------------------*/ -static u8_t -httpd_fs_strcmp(const char *str1, const char *str2) -{ - u8_t i; - i = 0; - -loop: - if(str2[i] == 0 || - str1[i] == '\r' || - str1[i] == '\n') { - return 0; - } - - if(str1[i] != str2[i]) { - return 1; - } - - ++i; - goto loop; -} -/*-----------------------------------------------------------------------------------*/ uint16_t httpd_fs_open(const char *name, struct httpd_fs_file *file) { diff --git a/apps/webserver-nano/httpd.c b/apps/webserver-nano/httpd.c index 52cb357..6c4afa7 100644 --- a/apps/webserver-nano/httpd.c +++ b/apps/webserver-nano/httpd.c @@ -355,6 +355,9 @@ PT_THREAD(handle_output(struct httpd_state *s)) char *ptr; PT_BEGIN(&s->outputpt); +#if DEBUGLOGIC + httpd_strcpy(s->filename,httpd_indexfn); +#endif if(!httpd_fs_open(s->filename, &s->file)) { #if WEBSERVER_CONF_INCLUDE || WEBSERVER_CONF_CGI /* If index.html not found try index.shtml */ @@ -410,22 +413,22 @@ PT_THREAD(handle_input(struct httpd_state *s)) if(s->inputbuf[1] == ISO_space) { httpd_strcpy(s->filename, httpd_indexfn); } else { - s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0; - strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename)); -#if WEBSERVER_CONF_PASSQUERY -/* Query string is left in the buffer until zeroed by the application! */ -{uint8_t i; + uint8_t i; for (i=0;i<sizeof(s->filename)+1;i++) { - if (s->inputbuf[i]==ISO_space) break; + if (i >= (PSOCK_DATALEN(&s->sin)-1)) break; + if (s->inputbuf[i]==ISO_space) break; + #if WEBSERVER_CONF_PASSQUERY + /* Query string is left in the httpd_query buffer until zeroed by the application! */ if (s->inputbuf[i]==ISO_qmark) { - s->inputbuf[i]=0; - strncpy(httpd_query,&s->inputbuf[i+1],sizeof(httpd_query)); -// raven_lcd_show_text(&s->inputbuf[i]); + strncpy(httpd_query,&s->inputbuf[i+1],sizeof(httpd_query)); + break; } - } -} #endif + s->filename[i]=s->inputbuf[i]; + } + s->filename[i]=0; } + #if WEBSERVER_CONF_LOG webserver_log_file(&uip_conn->ripaddr, s->filename); // webserver_log(httpd_query); @@ -447,6 +450,9 @@ PT_THREAD(handle_input(struct httpd_state *s)) static void handle_connection(struct httpd_state *s) { +#if DEBUGLOGIC + handle_output(s); +#endif handle_input(s); if(s->state == STATE_OUTPUT) { handle_output(s); @@ -456,6 +462,11 @@ handle_connection(struct httpd_state *s) void httpd_appcall(void *state) { +#if DEBUGLOGIC + struct httpd_state *s; //Enter here for debugging with output directed to TCPBUF + s = sg = (struct httpd_state *)memb_alloc(&conns); + if (1) { +#else struct httpd_state *s = (struct httpd_state *)state; if(uip_closed() || uip_aborted() || uip_timedout()) { if(s != NULL) { @@ -467,6 +478,7 @@ httpd_appcall(void *state) uip_abort(); return; } +#endif tcp_markconn(uip_conn, s); PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1); PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1); diff --git a/apps/webserver-nano/httpd.h b/apps/webserver-nano/httpd.h index 0f07ca9..d810597 100644 --- a/apps/webserver-nano/httpd.h +++ b/apps/webserver-nano/httpd.h @@ -44,6 +44,7 @@ * The RAM needed for each entry depends on script enabling and buffer sizes; see struct httpd_state below. * Typical range is 100 - 200 bytes per connection */ +#if CONTIKI_TARGET_SKY #define WEBSERVER_CONF_CONNS 2 #define WEBSERVER_CONF_NAMESIZE 16 #define WEBSERVER_CONF_BUFSIZE 40 @@ -83,6 +84,47 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY]; /* Include referrer in log */ #define WEBSERVER_CONF_REFERER 0 +#else /* !sky */ +#define WEBSERVER_CONF_CONNS 6 +#define WEBSERVER_CONF_NAMESIZE 20 +#define WEBSERVER_CONF_BUFSIZE 40 +/* Allow include in .shtml pages, e.g. %!: /header.html */ +#define WEBSERVER_CONF_INCLUDE 1 +/* Allow cgi in .shtml pages, e.g. %! file-stats . */ +#define WEBSERVER_CONF_CGI 1 +/* MAX_SCRIPT_NAME_LENGTH should be at least the maximum file name length+2 for %!: includes */ +#define MAX_SCRIPT_NAME_LENGTH WEBSERVER_CONF_NAMESIZE+2 +/* Enable specific cgi's */ +#define WEBSERVER_CONF_HEADER 1 +//#define WEBSERVER_CONF_HEADER_W3C 1 //Proper header +#define WEBSERVER_CONF_HEADER_MENU 1 //with links to other pages +//#define WEBSERVER_CONF_HEADER_ICON 1 //with favicon +#define WEBSERVER_CONF_FILESTATS 1 +#define WEBSERVER_CONF_TCPSTATS 1 +#define WEBSERVER_CONF_PROCESSES 1 +#define WEBSERVER_CONF_ADDRESSES 1 +#define WEBSERVER_CONF_NEIGHBORS 1 +#define WEBSERVER_CONF_ROUTES 1 +#define WEBSERVER_CONF_SENSORS 1 +#define WEBSERVER_CONF_TICTACTOE 1 //Needs passquery of at least 10 chars +#define WEBSERVER_CONF_PASSQUERY 10 +#if WEBSERVER_CONF_PASSQUERY +extern char httpd_query[WEBSERVER_CONF_PASSQUERY]; +#endif +/* Enable specific file types */ +#define WEBSERVER_CONF_JPG 1 +#define WEBSERVER_CONF_PNG 1 +#define WEBSERVER_CONF_GIF 1 +#define WEBSERVER_CONF_TXT 1 +#define WEBSERVER_CONF_CSS 1 +#define WEBSERVER_CONF_BIN 1 + +/* Log page accesses */ +#define WEBSERVER_CONF_LOG 1 +/* Include referrer in log */ +#define WEBSERVER_CONF_REFERER 1 +#endif + /* Address printing used by cgi's and logging, but it can be turned off if desired */ #if WEBSERVER_CONF_LOG || WEBSERVER_CONF_ADDRESSES || WEBSERVER_CONF_NEIGHBORS || WEBSERVER_CONF_ROUTES #define WEBSERVER_CONF_PRINTADDR 1 @@ -108,6 +150,7 @@ uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result); #define httpd_strlen strlen_P #define httpd_snprintf snprintf_P #define httpd_fs_cpy memcpy_P +#define httpd_fs_strcmp strcmp_P #define httpd_fs_strchr strchr_P #define httpd_fs_getchar(x) pgm_read_byte(x) @@ -122,6 +165,7 @@ uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result); #define httpd_strncmp strncmp #define httpd_strlen strlen #define httpd_fs_strchr strchr +#define httpd_fs_strcmp strcmp #define httpd_fs_getchar(c) *(c) #endif @@ -152,4 +196,27 @@ struct httpd_state { void httpd_init(void); void httpd_appcall(void *state); +/* DEBUGLOGIC is a convenient way to debug without a tcp/ip connection. + * After initialization, break the program and set the program counter + * to the beginning of httpd.c::httpd_appcall: + * s = sg = (struct httpd_state *)memb_alloc(&conns); + * The global sg points to the s data to get around "not in scope" optimization. + * The input file is forced to /index.html and the output directed to TCPBUF. + * However the socket will hang on acknowledgement when any data is sent. + * To prevent this just add a break to /core/net/psock.c::psock_generator_send + * ... + * // Wait until all data is sent and acknowledged. + * break; //<---add this line + * PT_YIELD_UNTIL(&s->psockpt, uip_acked() || uip_rexmit()); + * ... + */ +#define DEBUGLOGIC 0 +#if DEBUGLOGIC +struct httpd_state *sg; +#define uip_mss(...) 512 +#define uip_appdata TCPBUF +char TCPBUF[512]; +#endif + + #endif /* __HTTPD_H__ */ diff --git a/examples/webserver-ipv6/README b/examples/webserver-ipv6/README index c6e34b4..1c42e7a 100644 --- a/examples/webserver-ipv6/README +++ b/examples/webserver-ipv6/README @@ -26,5 +26,9 @@ code as follows: The default webserver and content is in /apps/webserver/... Change that using e.g. + $make clean $make WITH_WEBSERVER=webserver-nano - $make TARGET=avr-raven WITH_WEBSERVER=raven-webserver \ No newline at end of file + $make TARGET=redbee-econotag WITH_WEBSERVER=webserver-nano + $make TARGET=avr-raven WITH_WEBSERVER=raven-webserver + + ******** Make clean when switching webservers! ********** \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: apps/webserver-nano/httpd-fs.c | 21 --------- apps/webserver-nano/httpd.c | 34 ++++++++++----- apps/webserver-nano/httpd.h | 67 +++++++++++++++++++++++++++++ examples/webserver-ipv6/README | 6 ++- platform/avr-atmega128rfa1/contiki-conf.h | 3 + platform/avr-raven/contiki-conf.h | 5 ++- 6 files changed, 102 insertions(+), 34 deletions(-) hooks/post-receive -- contiki |