Expose httpd-cgi ipv6 address print to other modules

This commit is contained in:
dak664 2010-02-09 14:41:18 +00:00
parent d67d1f7340
commit 03c0245465
3 changed files with 22 additions and 13 deletions

View File

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.c,v 1.4 2009/07/24 15:41:52 dak664 Exp $
* $Id: httpd-cgi.c,v 1.5 2010/02/09 14:41:18 dak664 Exp $
*
*/
@ -100,9 +100,6 @@ static const char *states[] = {
char sensor_temperature[12];
uint8_t sprint_ip6(uip_ip6addr_t addr, char * result);
void
web_set_temp(char *s)
{
@ -210,7 +207,7 @@ make_tcp_stats(void *arg)
conn = &uip_conns[s->u.count];
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_tcpstat1, htons(conn->lport));
numprinted += sprint_ip6(conn->ripaddr, uip_appdata + numprinted);
numprinted += httpd_cgi_sprint_ip6(conn->ripaddr, uip_appdata + numprinted);
httpd_strcpy(tstate,states[conn->tcpstateflags & UIP_TS_MASK]);
numprinted += httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted,
httpd_cgi_tcpstat2,
@ -318,7 +315,7 @@ httpd_cgi_init(void)
}
/*---------------------------------------------------------------------------*/
uint8_t sprint_ip6(uip_ip6addr_t addr, char * result)
uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result)
{
unsigned char zerocnt = 0;
unsigned char numprinted = 0;

View File

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.h,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $
* $Id: httpd-cgi.h,v 1.2 2010/02/09 14:41:18 dak664 Exp $
*
*/
@ -55,5 +55,6 @@ static struct httpd_cgi_call name = {NULL, str, function}
void httpd_cgi_init(void);
void web_set_temp(char *s);
uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result);
#endif /* __HTTPD_CGI_H__ */

View File

@ -29,7 +29,7 @@
*
* This file is part of the Contiki OS.
*
* $Id: webserver-nogui.c,v 1.2 2009/06/19 17:11:28 dak664 Exp $
* $Id: webserver-nogui.c,v 1.3 2010/02/09 14:41:18 dak664 Exp $
*
*/
@ -42,6 +42,7 @@
#include "http-strings.h"
#include "webserver-nogui.h"
#include "httpd.h"
#include "httpd-cgi.h"
PROCESS(webserver_nogui_process, "Web server");
@ -61,19 +62,29 @@ PROCESS_THREAD(webserver_nogui_process, ev, data)
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
void
webserver_log_file(uip_ipaddr_t *requester, char *file)
{
#if LOG_CONF_ENABLED
char buf[18];
/* Print out IP address of requesting host. */
sprintf_P(buf, PSTR("%d.%d.%d.%d: "), requester->u8[0], requester->u8[1],
requester->u8[2], requester->u8[3]);
#if LOG_CONF_ENABLED
#if UIP_CONF_IPV6
char buf[48];
uint8_t j;
j=httpd_cgi_sprint_ip6((uip_ip6addr_t)*requester, buf);
buf[j]=':';buf[j+1]=' ';buf[j+2]=0;
#else
char buf[20];
sprintf(buf, "%d.%d.%d.%d: ", requester->u8[0], requester->u8[1],
requester->u8[2], requester->u8[3]);
#endif /* UIP_CONF_IPV6 */
log_message(buf, file);
#endif /* LOG_CONF_ENABLED */
}
/*---------------------------------------------------------------------------*/
void
webserver_log(char *msg)