The original uIP 1.0 sources

This commit is contained in:
Adam Dunkels
2013-03-27 21:31:37 +01:00
parent be901e957e
commit a49def743f
393 changed files with 42800 additions and 13988 deletions

16
README
View File

@@ -1,11 +1,13 @@
uIP is a very small implementation of the TCP/IP stack that is written
by Adam Dunkels <adam@dunkels.com>. More information can be obtained
at the uIP homepage at
http://dunkels.com/adam/uip/
by Adam Dunkels <adam@sics.se>. More information can be obtained
at the uIP homepage at http://www.sics.se/~adam/uip/.
This is version $Name: uip-1-0 $.
The directory structure look as follows:
apps/ - example applications
doc/ - documentation
uip/ - actual uIP TCP/IP, SLIP and ARP code
unix/ - Example of how to run uIP as a user space process under FreeBSD or Linux
apps/ - Example applications
doc/ - Documentation
lib/ - Library code used by some applications
uip/ - uIP TCP/IP stack code
unix/ - uIP as a user space process under FreeBSD or Linux

2
apps/README Normal file
View File

@@ -0,0 +1,2 @@
This directory contains a few example applications. They are not all
heavily tested, however.

View File

@@ -0,0 +1 @@
APP_SOURCES += dhcpc.c timer.c

356
apps/dhcpc/dhcpc.c Normal file
View File

@@ -0,0 +1,356 @@
/*
* Copyright (c) 2005, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack
*
* @(#)$Id: dhcpc.c,v 1.2 2006/06/11 21:46:37 adam Exp $
*/
#include <stdio.h>
#include <string.h>
#include "uip.h"
#include "dhcpc.h"
#include "timer.h"
#include "pt.h"
#define STATE_INITIAL 0
#define STATE_SENDING 1
#define STATE_OFFER_RECEIVED 2
#define STATE_CONFIG_RECEIVED 3
static struct dhcpc_state s;
struct dhcp_msg {
u8_t op, htype, hlen, hops;
u8_t xid[4];
u16_t secs, flags;
u8_t ciaddr[4];
u8_t yiaddr[4];
u8_t siaddr[4];
u8_t giaddr[4];
u8_t chaddr[16];
#ifndef UIP_CONF_DHCP_LIGHT
u8_t sname[64];
u8_t file[128];
#endif
u8_t options[312];
};
#define BOOTP_BROADCAST 0x8000
#define DHCP_REQUEST 1
#define DHCP_REPLY 2
#define DHCP_HTYPE_ETHERNET 1
#define DHCP_HLEN_ETHERNET 6
#define DHCP_MSG_LEN 236
#define DHCPC_SERVER_PORT 67
#define DHCPC_CLIENT_PORT 68
#define DHCPDISCOVER 1
#define DHCPOFFER 2
#define DHCPREQUEST 3
#define DHCPDECLINE 4
#define DHCPACK 5
#define DHCPNAK 6
#define DHCPRELEASE 7
#define DHCP_OPTION_SUBNET_MASK 1
#define DHCP_OPTION_ROUTER 3
#define DHCP_OPTION_DNS_SERVER 6
#define DHCP_OPTION_REQ_IPADDR 50
#define DHCP_OPTION_LEASE_TIME 51
#define DHCP_OPTION_MSG_TYPE 53
#define DHCP_OPTION_SERVER_ID 54
#define DHCP_OPTION_REQ_LIST 55
#define DHCP_OPTION_END 255
static const u8_t xid[4] = {0xad, 0xde, 0x12, 0x23};
static const u8_t magic_cookie[4] = {99, 130, 83, 99};
/*---------------------------------------------------------------------------*/
static u8_t *
add_msg_type(u8_t *optptr, u8_t type)
{
*optptr++ = DHCP_OPTION_MSG_TYPE;
*optptr++ = 1;
*optptr++ = type;
return optptr;
}
/*---------------------------------------------------------------------------*/
static u8_t *
add_server_id(u8_t *optptr)
{
*optptr++ = DHCP_OPTION_SERVER_ID;
*optptr++ = 4;
memcpy(optptr, s.serverid, 4);
return optptr + 4;
}
/*---------------------------------------------------------------------------*/
static u8_t *
add_req_ipaddr(u8_t *optptr)
{
*optptr++ = DHCP_OPTION_REQ_IPADDR;
*optptr++ = 4;
memcpy(optptr, s.ipaddr, 4);
return optptr + 4;
}
/*---------------------------------------------------------------------------*/
static u8_t *
add_req_options(u8_t *optptr)
{
*optptr++ = DHCP_OPTION_REQ_LIST;
*optptr++ = 3;
*optptr++ = DHCP_OPTION_SUBNET_MASK;
*optptr++ = DHCP_OPTION_ROUTER;
*optptr++ = DHCP_OPTION_DNS_SERVER;
return optptr;
}
/*---------------------------------------------------------------------------*/
static u8_t *
add_end(u8_t *optptr)
{
*optptr++ = DHCP_OPTION_END;
return optptr;
}
/*---------------------------------------------------------------------------*/
static void
create_msg(register struct dhcp_msg *m)
{
m->op = DHCP_REQUEST;
m->htype = DHCP_HTYPE_ETHERNET;
m->hlen = s.mac_len;
m->hops = 0;
memcpy(m->xid, xid, sizeof(m->xid));
m->secs = 0;
m->flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
/* uip_ipaddr_copy(m->ciaddr, uip_hostaddr);*/
memcpy(m->ciaddr, uip_hostaddr, sizeof(m->ciaddr));
memset(m->yiaddr, 0, sizeof(m->yiaddr));
memset(m->siaddr, 0, sizeof(m->siaddr));
memset(m->giaddr, 0, sizeof(m->giaddr));
memcpy(m->chaddr, s.mac_addr, s.mac_len);
memset(&m->chaddr[s.mac_len], 0, sizeof(m->chaddr) - s.mac_len);
#ifndef UIP_CONF_DHCP_LIGHT
memset(m->sname, 0, sizeof(m->sname));
memset(m->file, 0, sizeof(m->file));
#endif
memcpy(m->options, magic_cookie, sizeof(magic_cookie));
}
/*---------------------------------------------------------------------------*/
static void
send_discover(void)
{
u8_t *end;
struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
create_msg(m);
end = add_msg_type(&m->options[4], DHCPDISCOVER);
end = add_req_options(end);
end = add_end(end);
uip_send(uip_appdata, end - (u8_t *)uip_appdata);
}
/*---------------------------------------------------------------------------*/
static void
send_request(void)
{
u8_t *end;
struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
create_msg(m);
end = add_msg_type(&m->options[4], DHCPREQUEST);
end = add_server_id(end);
end = add_req_ipaddr(end);
end = add_end(end);
uip_send(uip_appdata, end - (u8_t *)uip_appdata);
}
/*---------------------------------------------------------------------------*/
static u8_t
parse_options(u8_t *optptr, int len)
{
u8_t *end = optptr + len;
u8_t type = 0;
while(optptr < end) {
switch(*optptr) {
case DHCP_OPTION_SUBNET_MASK:
memcpy(s.netmask, optptr + 2, 4);
break;
case DHCP_OPTION_ROUTER:
memcpy(s.default_router, optptr + 2, 4);
break;
case DHCP_OPTION_DNS_SERVER:
memcpy(s.dnsaddr, optptr + 2, 4);
break;
case DHCP_OPTION_MSG_TYPE:
type = *(optptr + 2);
break;
case DHCP_OPTION_SERVER_ID:
memcpy(s.serverid, optptr + 2, 4);
break;
case DHCP_OPTION_LEASE_TIME:
memcpy(s.lease_time, optptr + 2, 4);
break;
case DHCP_OPTION_END:
return type;
}
optptr += optptr[1] + 2;
}
return type;
}
/*---------------------------------------------------------------------------*/
static u8_t
parse_msg(void)
{
struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
if(m->op == DHCP_REPLY &&
memcmp(m->xid, xid, sizeof(xid)) == 0 &&
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0) {
memcpy(s.ipaddr, m->yiaddr, 4);
return parse_options(&m->options[4], uip_datalen());
}
return 0;
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_dhcp(void))
{
PT_BEGIN(&s.pt);
/* try_again:*/
s.state = STATE_SENDING;
s.ticks = CLOCK_SECOND;
do {
send_discover();
timer_set(&s.timer, s.ticks);
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
if(uip_newdata() && parse_msg() == DHCPOFFER) {
s.state = STATE_OFFER_RECEIVED;
break;
}
if(s.ticks < CLOCK_SECOND * 60) {
s.ticks *= 2;
}
} while(s.state != STATE_OFFER_RECEIVED);
s.ticks = CLOCK_SECOND;
do {
send_request();
timer_set(&s.timer, s.ticks);
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
if(uip_newdata() && parse_msg() == DHCPACK) {
s.state = STATE_CONFIG_RECEIVED;
break;
}
if(s.ticks <= CLOCK_SECOND * 10) {
s.ticks += CLOCK_SECOND;
} else {
PT_RESTART(&s.pt);
}
} while(s.state != STATE_CONFIG_RECEIVED);
#if 0
printf("Got IP address %d.%d.%d.%d\n",
uip_ipaddr1(s.ipaddr), uip_ipaddr2(s.ipaddr),
uip_ipaddr3(s.ipaddr), uip_ipaddr4(s.ipaddr));
printf("Got netmask %d.%d.%d.%d\n",
uip_ipaddr1(s.netmask), uip_ipaddr2(s.netmask),
uip_ipaddr3(s.netmask), uip_ipaddr4(s.netmask));
printf("Got DNS server %d.%d.%d.%d\n",
uip_ipaddr1(s.dnsaddr), uip_ipaddr2(s.dnsaddr),
uip_ipaddr3(s.dnsaddr), uip_ipaddr4(s.dnsaddr));
printf("Got default router %d.%d.%d.%d\n",
uip_ipaddr1(s.default_router), uip_ipaddr2(s.default_router),
uip_ipaddr3(s.default_router), uip_ipaddr4(s.default_router));
printf("Lease expires in %ld seconds\n",
ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]));
#endif
dhcpc_configured(&s);
/* timer_stop(&s.timer);*/
/*
* PT_END restarts the thread so we do this instead. Eventually we
* should reacquire expired leases here.
*/
while(1) {
PT_YIELD(&s.pt);
}
PT_END(&s.pt);
}
/*---------------------------------------------------------------------------*/
void
dhcpc_init(const void *mac_addr, int mac_len)
{
uip_ipaddr_t addr;
s.mac_addr = mac_addr;
s.mac_len = mac_len;
s.state = STATE_INITIAL;
uip_ipaddr(addr, 255,255,255,255);
s.conn = uip_udp_new(&addr, HTONS(DHCPC_SERVER_PORT));
if(s.conn != NULL) {
uip_udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
}
PT_INIT(&s.pt);
}
/*---------------------------------------------------------------------------*/
void
dhcpc_appcall(void)
{
handle_dhcp();
}
/*---------------------------------------------------------------------------*/
void
dhcpc_request(void)
{
u16_t ipaddr[2];
if(s.state == STATE_INITIAL) {
uip_ipaddr(ipaddr, 0,0,0,0);
uip_sethostaddr(ipaddr);
/* handle_dhcp(PROCESS_EVENT_NONE, NULL);*/
}
}
/*---------------------------------------------------------------------------*/

68
apps/dhcpc/dhcpc.h Normal file
View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2005, Swedish Institute of Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack
*
* @(#)$Id: dhcpc.h,v 1.3 2006/06/11 21:46:37 adam Exp $
*/
#ifndef __DHCPC_H__
#define __DHCPC_H__
#include "timer.h"
#include "pt.h"
struct dhcpc_state {
struct pt pt;
char state;
struct uip_udp_conn *conn;
struct timer timer;
u16_t ticks;
const void *mac_addr;
int mac_len;
u8_t serverid[4];
u16_t lease_time[2];
u16_t ipaddr[2];
u16_t netmask[2];
u16_t dnsaddr[2];
u16_t default_router[2];
};
void dhcpc_init(const void *mac_addr, int mac_len);
void dhcpc_request(void);
void dhcpc_appcall(void);
void dhcpc_configured(const struct dhcpc_state *s);
typedef struct dhcpc_state uip_udp_appstate_t;
#define UIP_UDP_APPCALL dhcpc_appcall
#endif /* __DHCPC_H__ */

View File

@@ -0,0 +1 @@
APP_SOURCES += hello-world.c

View File

@@ -0,0 +1,100 @@
/**
* \addtogroup helloworld
* @{
*/
/**
* \file
* An example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <adam@sics.se>
*/
/*
* This is a short example of how to write uIP applications using
* protosockets.
*/
/*
* We define the application state (struct hello_world_state) in the
* hello-world.h file, so we need to include it here. We also include
* uip.h (since this cannot be included in hello-world.h) and
* <string.h>, since we use the memcpy() function in the code.
*/
#include "hello-world.h"
#include "uip.h"
#include <string.h>
/*
* Declaration of the protosocket function that handles the connection
* (defined at the end of the code).
*/
static int handle_connection(struct hello_world_state *s);
/*---------------------------------------------------------------------------*/
/*
* The initialization function. We must explicitly call this function
* from the system initialization code, some time after uip_init() is
* called.
*/
void
hello_world_init(void)
{
/* We start to listen for connections on TCP port 1000. */
uip_listen(HTONS(1000));
}
/*---------------------------------------------------------------------------*/
/*
* In hello-world.h we have defined the UIP_APPCALL macro to
* hello_world_appcall so that this funcion is uIP's application
* function. This function is called whenever an uIP event occurs
* (e.g. when a new connection is established, new data arrives, sent
* data is acknowledged, data needs to be retransmitted, etc.).
*/
void
hello_world_appcall(void)
{
/*
* The uip_conn structure has a field called "appstate" that holds
* the application state of the connection. We make a pointer to
* this to access it easier.
*/
struct hello_world_state *s = &(uip_conn->appstate);
/*
* If a new connection was just established, we should initialize
* the protosocket in our applications' state structure.
*/
if(uip_connected()) {
PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
}
/*
* Finally, we run the protosocket function that actually handles
* the communication. We pass it a pointer to the application state
* of the current connection.
*/
handle_connection(s);
}
/*---------------------------------------------------------------------------*/
/*
* This is the protosocket function that handles the communication. A
* protosocket function must always return an int, but must never
* explicitly return - all return statements are hidden in the PSOCK
* macros.
*/
static int
handle_connection(struct hello_world_state *s)
{
PSOCK_BEGIN(&s->p);
PSOCK_SEND_STR(&s->p, "Hello. What is your name?\n");
PSOCK_READTO(&s->p, '\n');
strncpy(s->name, s->inputbuffer, sizeof(s->name));
PSOCK_SEND_STR(&s->p, "Hello ");
PSOCK_SEND_STR(&s->p, s->name);
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
/*---------------------------------------------------------------------------*/

View File

@@ -0,0 +1,52 @@
/**
* \addtogroup apps
* @{
*/
/**
* \defgroup helloworld Hello, world
* @{
*
* A small example showing how to write applications with
* \ref psock "protosockets".
*/
/**
* \file
* Header file for an example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <adam@sics.se>
*/
#ifndef __HELLO_WORLD_H__
#define __HELLO_WORLD_H__
/* Since this file will be included by uip.h, we cannot include uip.h
here. But we might need to include uipopt.h if we need the u8_t and
u16_t datatypes. */
#include "uipopt.h"
#include "psock.h"
/* Next, we define the uip_tcp_appstate_t datatype. This is the state
of our application, and the memory required for this state is
allocated together with each TCP connection. One application state
for each TCP connection. */
typedef struct hello_world_state {
struct psock p;
char inputbuffer[10];
char name[40];
} uip_tcp_appstate_t;
/* Finally we define the application function to be called by uIP. */
void hello_world_appcall(void);
#ifndef UIP_APPCALL
#define UIP_APPCALL hello_world_appcall
#endif /* UIP_APPCALL */
void hello_world_init(void);
#endif /* __HELLO_WORLD_H__ */
/** @} */
/** @} */

View File

@@ -1,211 +0,0 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* HTTP server script language C functions file.
* \author Adam Dunkels <adam@dunkels.com>
*
* This file contains functions that are called by the web server
* scripts. The functions takes one argument, and the return value is
* interpreted as follows. A zero means that the function did not
* complete and should be invoked for the next packet as well. A
* non-zero value indicates that the function has completed and that
* the web server should move along to the next script line.
*
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: cgi.c,v 1.23.2.4 2003/10/07 13:22:27 adam Exp $
*
*/
#include "uip.h"
#include "cgi.h"
#include "httpd.h"
#include "fs.h"
#include <stdio.h>
#include <string.h>
static u8_t print_stats(u8_t next);
static u8_t file_stats(u8_t next);
static u8_t tcp_stats(u8_t next);
cgifunction cgitab[] = {
print_stats, /* CGI function "a" */
file_stats, /* CGI function "b" */
tcp_stats /* CGI function "c" */
};
static const char closed[] = /* "CLOSED",*/
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
static const char syn_rcvd[] = /* "SYN-RCVD",*/
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
0x44, 0};
static const char syn_sent[] = /* "SYN-SENT",*/
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
0x54, 0};
static const char established[] = /* "ESTABLISHED",*/
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
0x45, 0x44, 0};
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x31, 0};
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x32, 0};
static const char closing[] = /* "CLOSING",*/
{0x43, 0x4c, 0x4f, 0x53, 0x49,
0x4e, 0x47, 0};
static const char time_wait[] = /* "TIME-WAIT,"*/
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
0x49, 0x54, 0};
static const char last_ack[] = /* "LAST-ACK"*/
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
0x4b, 0};
static const char *states[] = {
closed,
syn_rcvd,
syn_sent,
established,
fin_wait_1,
fin_wait_2,
closing,
time_wait,
last_ack};
/*-----------------------------------------------------------------------------------*/
/* print_stats:
*
* Prints out a part of the uIP statistics. The statistics data is
* written into the uip_appdata buffer. It overwrites any incoming
* packet.
*/
static u8_t
print_stats(u8_t next)
{
#if UIP_STATISTICS
u16_t i, j;
u8_t *buf;
u16_t *databytes;
if(next) {
/* If our last data has been acknowledged, we move on the next
chunk of statistics. */
hs->count = hs->count + 4;
if(hs->count >= sizeof(struct uip_stats)/sizeof(u16_t)) {
/* We have printed out all statistics, so we return 1 to
indicate that we are done. */
return 1;
}
}
/* Write part of the statistics into the uip_appdata buffer. */
databytes = (u16_t *)&uip_stat + hs->count;
buf = (u8_t *)uip_appdata;
j = 4 + 1;
i = hs->count;
while (i < sizeof(struct uip_stats)/sizeof(u16_t) && --j > 0) {
sprintf((char *)buf, "%5u\r\n", *databytes);
++databytes;
buf += 6;
++i;
}
/* Send the data. */
uip_send(uip_appdata, buf - uip_appdata);
return 0;
#else
return 1;
#endif /* UIP_STATISTICS */
}
/*-----------------------------------------------------------------------------------*/
static u8_t
file_stats(u8_t next)
{
/* We use sprintf() to print the number of file accesses to a
particular file (given as an argument to the function in the
script). We then use uip_send() to actually send the data. */
if(next) {
return 1;
}
uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", fs_count(&hs->script[4])));
return 0;
}
/*-----------------------------------------------------------------------------------*/
static u8_t
tcp_stats(u8_t next)
{
struct uip_conn *conn;
if(next) {
/* If the previously sent data has been acknowledged, we move
forward one connection. */
if(++hs->count == UIP_CONNS) {
/* If all connections has been printed out, we are done and
return 1. */
return 1;
}
}
conn = &uip_conns[hs->count];
if((conn->tcpstateflags & TS_MASK) == CLOSED) {
uip_send(uip_appdata, sprintf((char *)uip_appdata,
"<tr align=\"center\"><td>-</td><td>-</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' '));
} else {
uip_send(uip_appdata, sprintf((char *)uip_appdata,
"<tr align=\"center\"><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->ripaddr[0]) >> 8,
htons(conn->ripaddr[0]) & 0xff,
htons(conn->ripaddr[1]) >> 8,
htons(conn->ripaddr[1]) & 0xff,
htons(conn->rport),
states[conn->tcpstateflags & TS_MASK],
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' '));
}
return 0;
}
/*-----------------------------------------------------------------------------------*/

View File

@@ -1 +0,0 @@
<html><body bgcolor="white"><center><h1>404 - file not found</h1></center></body></html>

View File

@@ -1,18 +0,0 @@
<html>
<body bgcolor="white">
<center>
<table width="600" border="0"><tr><td>
<h2>Welcome</h2>
<p align="justify">
These web pages are served by the small web server running on top of
the <a href="http://dunkels.com/adam/uip/" target="_top">uIP TCP/IP
stack</a>.
</p>
<p align="justify">
Click on the links above to see some status information about the web
server and the TCP/IP stack.
</p>
</td></tr></table>
</center>
</body>
</html>

View File

@@ -1,28 +0,0 @@
# This script shows the access statistics for different files on the
# web server.
#
# First, we include the HTML header.
i /files_header.html
# Print out the name of the file, and call the function that prints
# the access statistics of that file.
t <tr><td><a href="/index.html">/index.html</a></td><td>
c b /index.html
t </td></tr> <tr><td><a href="/about.html">/about.html</a></td><td>
c b /about.html
t </td></tr> <tr><td><a href="/control.html">/control.html</a></td><td>
c b /control.html
t </td></tr> <tr><td><a href="/img/bg.png">/img/bg.png</a></td><td>
c b /img/bg.png
t </td></tr> <tr><td><a href="/404.html">/404.html</a></td><td>
c b /404.html
t </td></tr> <tr><td><a href="/cgi/files">/cgi/files</a></td><td>
c b /cgi/files
t </td></tr> <tr><td><a href="/cgi/stats">/cgi/stats</a></td><td>
c b /cgi/stats
t </td></tr> <tr><td><a href="/cgi/tcp">/cgi/tcp</a></td><td>
c b /cgi/tcp
t </td></tr>
# Include the HTML footer.
i /files_footer.plain
# End of script.
.

View File

@@ -1,4 +0,0 @@
i /stats_header.html
c a
i /stats_footer.plain
.

View File

@@ -1,4 +0,0 @@
i /tcp_header.html
c c
i /tcp_footer.plain
.

View File

@@ -1,14 +0,0 @@
<html>
<body bgcolor="white">
<center>
<table width="797" height="94" border="0" cellpadding="0"
cellspacing="0" background="/img/bg.png"><tr><td align="center">
<h1>uIP web server test pages</h1>
[ <a href="about.html" target="main">About</a> |
<a href="/cgi/tcp" target="main">Connections</a> |
<a href="/cgi/files" target="main">Files</a> |
<a href="/cgi/stats" target="main">Statistics</a> ]
</td></tr></table>
</center>
</body>
</html>

View File

@@ -1,3 +0,0 @@
</td></tr></table>
</body>
</html>

View File

@@ -1,4 +0,0 @@
<html>
<body bgcolor="white">
<center>
<table width="600" border="0">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,14 +0,0 @@
<html>
<head><title>uIP web server test page</title></head>
<frameset cols="*" rows="120,*" frameborder="no">
<frame src="control.html">
<frame src="about.html" name="main">
</frameset>
<noframes>
<body>
Your browser must support frames
</body>
</noframes>
</html>

View File

@@ -1,3 +0,0 @@
</td></tr></table>
</body>
</html>

View File

@@ -1,5 +0,0 @@
</td></tr></table>
</center>
</body>
</html>

View File

@@ -1,6 +0,0 @@
<html>
<body bgcolor="white">
<center>
<table width="600" border="0">
<tr><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>

View File

@@ -1,619 +0,0 @@
static const char data_cgi_files[] = {
/* /cgi/files */
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0,
0x23, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x20, 0x73, 0x68, 0x6f, 0x77, 0x73, 0x20,
0x74, 0x68, 0x65, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73,
0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63,
0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x64, 0x69, 0x66, 0x66,
0x65, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x66, 0x69, 0x6c, 0x65,
0x73, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0xa, 0x23,
0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65,
0x72, 0x2e, 0xa, 0x23, 0xa, 0x23, 0x20, 0x46, 0x69, 0x72,
0x73, 0x74, 0x2c, 0x20, 0x77, 0x65, 0x20, 0x69, 0x6e, 0x63,
0x6c, 0x75, 0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x48,
0x54, 0x4d, 0x4c, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72,
0x2e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73,
0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74,
0x6d, 0x6c, 0xa, 0x23, 0x20, 0x50, 0x72, 0x69, 0x6e, 0x74,
0x20, 0x6f, 0x75, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6e,
0x61, 0x6d, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65,
0x20, 0x66, 0x69, 0x6c, 0x65, 0x2c, 0x20, 0x61, 0x6e, 0x64,
0x20, 0x63, 0x61, 0x6c, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x20,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74,
0x68, 0x61, 0x74, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x73,
0xa, 0x23, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
0x74, 0x69, 0x63, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68,
0x61, 0x74, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0xa, 0x74,
0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69,
0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74,
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x62, 0x20,
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d,
0x6c, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
0x3d, 0x22, 0x2f, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x2e, 0x68,
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x61, 0x62, 0x6f, 0x75,
0x74, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa,
0x63, 0x20, 0x62, 0x20, 0x2f, 0x61, 0x62, 0x6f, 0x75, 0x74,
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c,
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
0x3e, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e,
0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa, 0x63, 0x20,
0x62, 0x20, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x20, 0x3c,
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69, 0x6d, 0x67,
0x2f, 0x62, 0x67, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f,
0x69, 0x6d, 0x67, 0x2f, 0x62, 0x67, 0x2e, 0x70, 0x6e, 0x67,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x62, 0x20, 0x2f, 0x69,
0x6d, 0x67, 0x2f, 0x62, 0x67, 0x2e, 0x70, 0x6e, 0x67, 0xa,
0x74, 0x20, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74,
0x72, 0x3e, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64,
0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22,
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
0x3e, 0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x62, 0x20, 0x2f, 0x34,
0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63,
0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3e,
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x62, 0x20, 0x2f, 0x63,
0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0xa, 0x74,
0x20, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72,
0x3e, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f,
0x63, 0x67, 0x69, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x22,
0x3e, 0x2f, 0x63, 0x67, 0x69, 0x2f, 0x73, 0x74, 0x61, 0x74,
0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e,
0x3c, 0x74, 0x64, 0x3e, 0xa, 0x63, 0x20, 0x62, 0x20, 0x2f,
0x63, 0x67, 0x69, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa,
0x74, 0x20, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74,
0x72, 0x3e, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64,
0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22,
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e,
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x3c, 0x2f,
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
0x3e, 0xa, 0x63, 0x20, 0x62, 0x20, 0x2f, 0x63, 0x67, 0x69,
0x2f, 0x74, 0x63, 0x70, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74,
0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x23, 0x20,
0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x74, 0x68,
0x65, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20, 0x66, 0x6f, 0x6f,
0x74, 0x65, 0x72, 0x2e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x69,
0x6c, 0x65, 0x73, 0x5f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72,
0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0x23, 0x20, 0x45,
0x6e, 0x64, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x63, 0x72, 0x69,
0x70, 0x74, 0x2e, 0xa, 0x2e, };
static const char data_cgi_stats[] = {
/* /cgi/stats */
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0,
0x69, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x5f, 0x68,
0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
0xa, 0x63, 0x20, 0x61, 0xa, 0x69, 0x20, 0x2f, 0x73, 0x74,
0x61, 0x74, 0x73, 0x5f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72,
0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xa, 0x2e, 0xa, };
static const char data_cgi_tcp[] = {
/* /cgi/tcp */
0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
0x69, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x5f, 0x68, 0x65, 0x61,
0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x63,
0x20, 0x63, 0xa, 0x69, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x5f,
0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61,
0x69, 0x6e, 0xa, 0x2e, };
static const char data_img_bg_png[] = {
/* /img/bg.png */
0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x62, 0x67, 0x2e, 0x70, 0x6e, 0x67, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69,
0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa,
0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa,
00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00,
0x3, 0x1d, 00, 00, 00, 0x5e, 0x8, 0x6, 00, 00,
00, 0x46, 0xbd, 0x79, 0xcc, 00, 00, 00, 0x6, 0x62,
0x4b, 0x47, 0x44, 00, 0xff, 00, 0xff, 00, 0xff, 0xa0,
0xbd, 0xa7, 0x93, 00, 00, 00, 0x9, 0x70, 0x48, 0x59,
0x73, 00, 00, 0xb, 0x12, 00, 00, 0xb, 0x12, 0x1,
0xd2, 0xdd, 0x7e, 0xfc, 00, 00, 00, 0x7, 0x74, 0x49,
0x4d, 0x45, 0x7, 0xd3, 0xa, 0x5, 0x12, 0x22, 0x33, 0x22,
0xd0, 0x7c, 0x9a, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50,
0xef, 0x64, 0x25, 0x6e, 00, 00, 0x3, 0xa0, 0x49, 0x44,
0x41, 0x54, 0x78, 0xda, 0xed, 0xdd, 0xc1, 0x76, 0x9a, 0x40,
0x18, 0x80, 0x51, 0x27, 0xc7, 0x5, 0x6c, 0xd1, 0x65, 0x1a,
0xec, 0xe9, 0xfb, 0xbf, 0x45, 0x9e, 0x23, 0xd5, 0xb4, 0x4b,
0x71, 0x19, 0xdd, 0x4d, 0x97, 0x36, 0x8a, 0x6, 0x1c, 0x82,
0x20, 0xf7, 0xee, 0x92, 0xa8, 0x3f, 0xc, 0x68, 0xfa, 0xa1,
0x3d, 0x9, 0x6f, 0xaf, 0x1f, 0x71, 0x76, 0x26, 0xcc, 0x6e,
0x15, 0x9e, 0xce, 0xbf, 0x17, 0xe3, 0x71, 0x44, 0xb8, 0xfd,
0xa1, 0x93, 0xd5, 0x6d, 0x5b, 0x7f, 0xc3, 0x13, 0xef, 0x1e,
0x86, 0xb3, 0x2d, 0x5d, 0x6d, 0xdb, 0xf2, 0x57, 0x96, 0x34,
0x77, 0xfb, 0xfb, 0x90, 0x74, 0xff, 0xe5, 0xcf, 0xb4, 0xf9,
0xbb, 0x4d, 0xda, 0xfc, 0xa2, 0xcc, 0x92, 0xd6, 0xb4, 0x5a,
0x5f, 0x99, 0xdf, 0xe0, 0x5c, 0x5f, 0xae, 0xb2, 0xd9, 0x20,
0x85, 0x6f, 0x5c, 0xff, 0x70, 0x7c, 0x2d, 0x5a, 0x94, 0xf9,
0xf0, 0x76, 0xfd, 0x69, 0x36, 0x39, 0x53, 0xdc, 0xe7, 0x41,
0xfc, 0x1e, 0x18, 0xe1, 0xef, 0x41, 0xc6, 0xf1, 0x7c, 0xa9,
0x3d, 0x4f, 0xe3, 0x83, 0x1f, 0xfc, 0xb1, 0x1e, 0x17, 0xcb,
0x4, 00, 00, 0x68, 0x33, 00, 00, 00, 0xd1, 0x1,
00, 00, 0x88, 0xe, 00, 00, 0x40, 0x74, 00, 00,
00, 0x88, 0xe, 00, 00, 0x40, 0x74, 00, 00, 00,
0xa2, 0x3, 00, 00, 0x40, 0x74, 00, 00, 00, 0xa2,
0x3, 00, 00, 0x40, 0x74, 00, 00, 00, 0xa2, 0x3,
00, 00, 0x10, 0x1d, 00, 0x1d, 0xa, 0x96, 00, 00,
0x44, 0x7, 00, 00, 0x40, 0x4b, 0xe1, 0xed, 0xf5, 0x23,
0xd6, 0x7c, 0xfb, 0xf6, 0x7, 0xac, 0xc9, 0x98, 0x18, 0x8f,
0x23, 0xc2, 0x1d, 0xaf, 0x64, 0x86, 0x7b, 0x26, 0x56, 0xe2,
0x7e, 0x77, 0xba, 0x6e, 0x1d, 0x1f, 0x83, 0xa4, 0x6d, 0xb,
0xfd, 0x6e, 0x6b, 0x97, 0x6b, 0x1a, 0xee, 0x7c, 0x55, 0x7e,
0xb1, 0xca, 0x92, 0x9e, 0xb, 0xdb, 0xf5, 0x21, 0x69, 0xfe,
0x32, 0x61, 0xfe, 0x18, 0x8f, 0xf7, 0xc3, 0xbf, 0x46, 0xd9,
0xe7, 0xe1, 0xaf, 0xd5, 0xd8, 0xdf, 0x9, 0xf4, 0x4e, 0xe6,
0x24, 0x9e, 0x2f, 0xb5, 0xe7, 0x69, 0x7c, 0xf0, 0x83, 0x3f,
0xd6, 0xe3, 0x62, 0x99, 00, 00, 00, 0x6d, 0x6, 00,
00, 0x20, 0x3a, 00, 00, 00, 0xd1, 0x1, 00, 00,
0x88, 0xe, 00, 00, 00, 0xd1, 0x1, 00, 00, 0x88,
0xe, 00, 00, 0x40, 0x74, 00, 00, 00, 0x88, 0xe,
00, 00, 0x40, 0x74, 00, 00, 00, 0x88, 0xe, 0x98,
0xaa, 0xe0, 0x59, 0xf, 00, 0x88, 0xe, 00, 0x86, 0x53,
0xa9, 0x96, 00, 00, 0xd1, 0x1, 00, 00, 0x88, 0xe,
00, 00, 0x40, 0x74, 00, 00, 00, 0x7c, 0x93, 0xb9,
0x25, 0x80, 0xfb, 0x28, 0xca, 0xec, 0xe2, 0xcf, 0x42, 0x83,
0xcf, 0xd1, 0x57, 0xeb, 0xc3, 0xe5, 0x1f, 0x36, 0xb8, 0x9c,
0xb0, 0x5c, 0x65, 0x49, 0xdb, 0xbf, 0xbd, 0x30, 0x3f, 0x34,
0xfc, 0x3f, 00, 0x8b, 0x32, 0x6d, 0xfe, 0x6e, 0x73, 0x68,
0x7f, 0xa7, 0x10, 0xff, 0x9b, 0x9f, 0x27, 0xcd, 0xaf, 0xde,
0xf7, 0xed, 0x46, 0x9f, 0x1c, 0x93, 0xe2, 0x39, 0xf7, 0x24,
00, 0x60, 0x32, 0xbc, 0xd3, 0x1, 00, 00, 0x88, 0xe,
00, 00, 0x40, 0x74, 00, 00, 00, 0x88, 0xe, 00,
00, 0x40, 0x74, 00, 00, 00, 0x8f, 0x1f, 0x1d, 0xdd,
0xfe, 0xf9, 0xd9, 0x18, 0xa3, 0x55, 0x6, 00, 00, 0xd1,
0xc1, 0x64, 0x84, 0x8e, 0x1f, 0x2e, 0x58, 0x52, 00, 00,
0x44, 0x7, 00, 00, 0x20, 0x3a, 00, 00, 00, 0xd1,
0x1, 00, 00, 0x20, 0x3a, 00, 00, 00, 0xd1, 0x1,
00, 00, 0x88, 0xe, 00, 00, 00, 0xd1, 0x1, 00,
00, 0x88, 0xe, 00, 00, 0x80, 0xb9, 0x25, 0x80, 0xfb,
0xd8, 0x6d, 0xe, 0x77, 0x9d, 0xbf, 0x5d, 0xa7, 0xcd, 0x5f,
0xae, 0xb2, 0xa4, 0xfb, 0x57, 0x35, 0xfb, 0xdf, 0xe6, 0x8f,
0x4d, 0x16, 0x65, 0xbb, 0xf9, 0xa7, 0x8f, 0x5d, 0x6d, 0xf6,
0xe7, 0x37, 0x88, 0xf1, 0xca, 0x3, 0x7c, 0xfe, 0x72, 0xf1,
0x92, 0x3b, 0x89, 0x1, 0xa0, 0x21, 0xef, 0x74, 00, 00,
00, 0xa2, 0x3, 00, 00, 0x10, 0x1d, 00, 00, 00,
0xa2, 0x63, 0xac, 0xda, 0x7c, 0xce, 0x1d, 00, 00, 0x44,
0x7, 0xe0, 0x59, 0xd, 00, 0xf8, 0xe7, 0x9, 00, 00,
0x80, 0xe8, 00, 00, 00, 0x44, 0x7, 00, 00, 0x80,
0xe8, 00, 00, 00, 0x44, 0x7, 00, 00, 0x20, 0x3a,
00, 00, 00, 0x44, 0x7, 00, 00, 0x20, 0x3a, 00,
00, 00, 0xd1, 0x1, 00, 00, 0x20, 0x3a, 00, 00,
0x80, 0x81, 0x98, 0x5b, 0x2, 0xe0, 0x16, 0xdb, 0xf5, 0xa1,
0xf6, 0xfb, 0x21, 0xf4, 0x33, 0x7f, 0xb7, 0x39, 0xb4, 0xbb,
0x43, 0x88, 0x9f, 0xbe, 0x5c, 0x94, 0x79, 0xd2, 0xfc, 0xea,
0x7d, 0xdf, 0x6e, 0xfc, 0xc9, 0x25, 0x9e, 0xe2, 0xb9, 0xbf,
0xf9, 0x75, 0xc7, 0xa4, 0xf8, 0x91, 0x3b, 0x89, 0x1, 0xe8,
0x8d, 0x77, 0x3a, 00, 00, 00, 0xd1, 0x1, 0x43, 0xd3,
0xd7, 0xd5, 0x7c, 0xeb, 0x2, 00, 0x88, 0xe, 00, 0xbe,
0x8e, 0x31, 0xaf, 0xb4, 00, 0x88, 0xe, 00, 00, 00,
0xd1, 0x1, 00, 00, 0x88, 0xe, 00, 00, 00, 0xd1,
0x1, 00, 00, 0x88, 0xe, 00, 00, 0x40, 0x74, 00,
00, 00, 0x88, 0xe, 00, 00, 0x40, 0x74, 00, 00,
00, 0xa2, 0x3, 00, 00, 0x60, 0x34, 0xd1, 0x11, 0x82,
0x5, 0x7, 00, 00, 0xd1, 0x1, 0x43, 0x21, 0x52, 0x1,
00, 0x44, 0x7, 00, 00, 0xc0, 0x57, 0xe6, 0x96, 00,
0x18, 0xa3, 0xa2, 0xcc, 0x5a, 0xdd, 0xfe, 0xf4, 0xe3, 0x9d,
0xd5, 0x66, 0x7f, 0x7e, 0x83, 0x18, 0xaf, 0x3c, 0x40, 0xb7,
0xdb, 0xbf, 0xfb, 0xbb, 0x4f, 0xba, 0xff, 0xe2, 0x25, 0x4f,
0x9b, 0xff, 0xa7, 0xe1, 0xfc, 0xb, 0xfb, 0x5d, 0x3c, 0xe7,
0xdf, 0xbe, 0xff, 0xe1, 0xca, 0x65, 0xb1, 0x3e, 0xe6, 0x5f,
0x3d, 0xff, 0x12, 0xe7, 0x3, 0x4c, 0x8d, 0x77, 0x3a, 00,
00, 00, 0xd1, 0x1, 00, 00, 0x88, 0xe, 00, 00,
00, 0xd1, 0x1, 00, 00, 0x88, 0xe, 00, 00, 0x40,
0x74, 00, 00, 00, 0x88, 0xe, 00, 00, 0x40, 0x74,
00, 00, 00, 0xa2, 0x3, 00, 00, 0x40, 0x74, 0x34,
0x13, 0xe4, 0x15, 00, 00, 0x88, 0xe, 00, 00, 0x40,
0x74, 00, 00, 00, 0x88, 0xe, 00, 00, 0x40, 0x74,
00, 00, 00, 0x13, 0xf1, 0xf, 0x24, 0xa1, 0x5c, 0xab,
0x41, 0xd8, 0x92, 0xa4, 00, 00, 00, 00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
static const char data_about_html[] = {
/* /about.html */
0x2f, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22,
0x3e, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0xa,
0x3c, 0x68, 0x32, 0x3e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d,
0x65, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xa, 0x3c, 0x70, 0x20,
0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x6a, 0x75, 0x73,
0x74, 0x69, 0x66, 0x79, 0x22, 0x3e, 0xa, 0x54, 0x68, 0x65,
0x73, 0x65, 0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67,
0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72,
0x76, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
0x20, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x65, 0x62,
0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x75,
0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x6f, 0x6e, 0x20, 0x74,
0x6f, 0x70, 0x20, 0x6f, 0x66, 0xa, 0x74, 0x68, 0x65, 0x20,
0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68,
0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b,
0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64,
0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x20, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x3d, 0x22, 0x5f, 0x74, 0x6f,
0x70, 0x22, 0x3e, 0x75, 0x49, 0x50, 0x20, 0x54, 0x43, 0x50,
0x2f, 0x49, 0x50, 0xa, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x3c,
0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x3c, 0x2f, 0x70, 0x3e, 0xa,
0x3c, 0x70, 0x20, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22,
0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x79, 0x22, 0x3e, 0xa,
0x43, 0x6c, 0x69, 0x63, 0x6b, 0x20, 0x6f, 0x6e, 0x20, 0x74,
0x68, 0x65, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x20, 0x61,
0x62, 0x6f, 0x76, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x73, 0x65,
0x65, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x20, 0x73, 0x74, 0x61,
0x74, 0x75, 0x73, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x62, 0x6f, 0x75,
0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x65, 0x62, 0xa,
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x61, 0x6e, 0x64,
0x20, 0x74, 0x68, 0x65, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49,
0x50, 0x20, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0xa, 0x3c,
0x2f, 0x70, 0x3e, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x2f, 0x74, 0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c,
0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65,
0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e,
0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
static const char data_control_html[] = {
/* /control.html */
0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x37, 0x39, 0x37, 0x22, 0x20,
0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x22, 0x39, 0x34,
0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22,
0x30, 0x22, 0x20, 0x63, 0x65, 0x6c, 0x6c, 0x70, 0x61, 0x64,
0x64, 0x69, 0x6e, 0x67, 0x3d, 0x22, 0x30, 0x22, 0xa, 0x9,
0x63, 0x65, 0x6c, 0x6c, 0x73, 0x70, 0x61, 0x63, 0x69, 0x6e,
0x67, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x3d, 0x22, 0x2f, 0x69,
0x6d, 0x67, 0x2f, 0x62, 0x67, 0x2e, 0x70, 0x6e, 0x67, 0x22,
0x3e, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x61,
0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x63, 0x65, 0x6e, 0x74,
0x65, 0x72, 0x22, 0x3e, 0xa, 0x3c, 0x68, 0x31, 0x3e, 0x75,
0x49, 0x50, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x70,
0x61, 0x67, 0x65, 0x73, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa,
0x5b, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d,
0x22, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x2e, 0x68, 0x74, 0x6d,
0x6c, 0x22, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x3d,
0x22, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x3e, 0x41, 0x62, 0x6f,
0x75, 0x74, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x7c, 0xa, 0x3c,
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63,
0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x20, 0x74, 0x61,
0x72, 0x67, 0x65, 0x74, 0x3d, 0x22, 0x6d, 0x61, 0x69, 0x6e,
0x22, 0x3e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x7c, 0xa,
0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f,
0x63, 0x67, 0x69, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22,
0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x3d, 0x22, 0x6d,
0x61, 0x69, 0x6e, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x73,
0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x7c, 0xa, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 0x69,
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x22, 0x20, 0x74, 0x61,
0x72, 0x67, 0x65, 0x74, 0x3d, 0x22, 0x6d, 0x61, 0x69, 0x6e,
0x22, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69,
0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x5d, 0xa, 0x3c,
0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0x3c,
0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f,
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x3c, 0x2f,
0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74,
0x6d, 0x6c, 0x3e, };
static const char data_404_html[] = {
/* /404.html */
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34,
0x30, 0x34, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f,
0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50,
0x2f, 0x30, 0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f,
0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e,
0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a,
0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c,
0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f,
0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65,
0x22, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20,
0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66,
0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c,
0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f,
0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
0x6c, 0x3e, };
static const char data_files_footer_plain[] = {
/* /files_footer.plain */
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c,
0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68,
0x74, 0x6d, 0x6c, 0x3e, 0xa, };
static const char data_files_header_html[] = {
/* /files_header.html */
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22,
0x3e, 0xa, };
static const char data_index_html[] = {
/* /index.html */
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c,
0x65, 0x3e, 0x75, 0x49, 0x50, 0x20, 0x77, 0x65, 0x62, 0x20,
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x74, 0x65, 0x73,
0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c, 0x2f, 0x74, 0x69,
0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
0x3e, 0xa, 0xa, 0x3c, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73,
0x65, 0x74, 0x20, 0x63, 0x6f, 0x6c, 0x73, 0x3d, 0x22, 0x2a,
0x22, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x3d, 0x22, 0x31, 0x32,
0x30, 0x2c, 0x2a, 0x22, 0x20, 0x66, 0x72, 0x61, 0x6d, 0x65,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x6e, 0x6f,
0x22, 0x3e, 0x20, 0xa, 0x20, 0x20, 0x3c, 0x66, 0x72, 0x61,
0x6d, 0x65, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x63, 0x6f,
0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x66, 0x72, 0x61, 0x6d,
0x65, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x61, 0x62, 0x6f,
0x75, 0x74, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x20, 0x6e,
0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6d, 0x61, 0x69, 0x6e, 0x22,
0x3e, 0xa, 0x3c, 0x2f, 0x66, 0x72, 0x61, 0x6d, 0x65, 0x73,
0x65, 0x74, 0x3e, 0xa, 0xa, 0x3c, 0x6e, 0x6f, 0x66, 0x72,
0x61, 0x6d, 0x65, 0x73, 0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64,
0x79, 0x3e, 0xa, 0x59, 0x6f, 0x75, 0x72, 0x20, 0x62, 0x72,
0x6f, 0x77, 0x73, 0x65, 0x72, 0x20, 0x6d, 0x75, 0x73, 0x74,
0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x66,
0x72, 0x61, 0x6d, 0x65, 0x73, 0xa, 0x3c, 0x2f, 0x62, 0x6f,
0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x6e, 0x6f, 0x66, 0x72,
0x61, 0x6d, 0x65, 0x73, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74,
0x6d, 0x6c, 0x3e, };
static const char data_stats_footer_plain[] = {
/* /stats_footer.plain */
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x5f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c,
0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68,
0x74, 0x6d, 0x6c, 0x3e, 0xa, };
static const char data_stats_header_html[] = {
/* /stats_header.html */
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22,
0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
0xa, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49, 0x50, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 0x72,
0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x72, 0x65, 0x63,
0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e,
0x74, 0xa, 0x49, 0x50, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x73, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x76, 0x65,
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x68, 0x65, 0x61, 0x64,
0x65, 0x72, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0xa,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67,
0x74, 0x68, 0x2c, 0x20, 0x68, 0x69, 0x67, 0x68, 0x20, 0x62,
0x79, 0x74, 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20,
0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x6c, 0x6f,
0x77, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x49, 0x50, 0x20, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e,
0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x48, 0x65, 0x61, 0x64,
0x65, 0x72, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75,
0x6d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x57, 0x72, 0x6f, 0x6e, 0x67,
0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0xa,
0x49, 0x43, 0x4d, 0x50, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 0x72,
0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x72, 0x65, 0x63,
0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e,
0x74, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x54, 0x79, 0x70, 0x65, 0x20,
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x54, 0x43, 0x50,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64, 0x72,
0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x72, 0x65, 0x63,
0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x73, 0x65, 0x6e,
0x74, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x68, 0x65, 0x63, 0x6b,
0x73, 0x75, 0x6d, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73,
0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x44, 0x61, 0x74, 0x61, 0x20, 0x70,
0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x77, 0x69, 0x74,
0x68, 0x6f, 0x75, 0x74, 0x20, 0x41, 0x43, 0x4b, 0x73, 0xa,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x52, 0x65, 0x73, 0x65, 0x74, 0x73, 0xa,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73,
0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0xa, 0x9,
0x20, 0x20, 0x20, 0x20, 0x20, 0x4e, 0x6f, 0x20, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61,
0x76, 0x61, 0x6c, 0x69, 0x61, 0x62, 0x6c, 0x65, 0xa, 0x9,
0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, 0x74, 0x74, 0x65,
0x6d, 0x70, 0x74, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x63, 0x6c,
0x6f, 0x73, 0x65, 0x64, 0x20, 0x70, 0x6f, 0x72, 0x74, 0x73,
0xa, 0x3c, 0x2f, 0x70, 0x72, 0x65, 0x3e, 0x9, 0x20, 0x20,
0x20, 0x20, 0x20, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, };
static const char data_tcp_footer_plain[] = {
/* /tcp_footer.plain */
0x2f, 0x74, 0x63, 0x70, 0x5f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72,
0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa,
0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa,
0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f,
0x68, 0x74, 0x6d, 0x6c, 0x3e, };
static const char data_tcp_header_html[] = {
/* /tcp_header.html */
0x2f, 0x74, 0x63, 0x70, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x30,
0x2e, 0x39, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69,
0x70, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65,
0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa,
0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22,
0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e,
0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68,
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x65,
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52,
0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73,
0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x3c, 0x2f,
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 0x6c, 0x61,
0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74,
0x72, 0x3e, 0xa, 0xa, };
const struct fsdata_file file_cgi_files[] = {{NULL, data_cgi_files, data_cgi_files + 11, sizeof(data_cgi_files) - 11}};
const struct fsdata_file file_cgi_stats[] = {{file_cgi_files, data_cgi_stats, data_cgi_stats + 11, sizeof(data_cgi_stats) - 11}};
const struct fsdata_file file_cgi_tcp[] = {{file_cgi_stats, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
const struct fsdata_file file_img_bg_png[] = {{file_cgi_tcp, data_img_bg_png, data_img_bg_png + 12, sizeof(data_img_bg_png) - 12}};
const struct fsdata_file file_about_html[] = {{file_img_bg_png, data_about_html, data_about_html + 12, sizeof(data_about_html) - 12}};
const struct fsdata_file file_control_html[] = {{file_about_html, data_control_html, data_control_html + 14, sizeof(data_control_html) - 14}};
const struct fsdata_file file_404_html[] = {{file_control_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
const struct fsdata_file file_files_footer_plain[] = {{file_404_html, data_files_footer_plain, data_files_footer_plain + 20, sizeof(data_files_footer_plain) - 20}};
const struct fsdata_file file_files_header_html[] = {{file_files_footer_plain, data_files_header_html, data_files_header_html + 19, sizeof(data_files_header_html) - 19}};
const struct fsdata_file file_index_html[] = {{file_files_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
const struct fsdata_file file_stats_footer_plain[] = {{file_index_html, data_stats_footer_plain, data_stats_footer_plain + 20, sizeof(data_stats_footer_plain) - 20}};
const struct fsdata_file file_stats_header_html[] = {{file_stats_footer_plain, data_stats_header_html, data_stats_header_html + 19, sizeof(data_stats_header_html) - 19}};
const struct fsdata_file file_tcp_footer_plain[] = {{file_stats_header_html, data_tcp_footer_plain, data_tcp_footer_plain + 18, sizeof(data_tcp_footer_plain) - 18}};
const struct fsdata_file file_tcp_header_html[] = {{file_tcp_footer_plain, data_tcp_header_html, data_tcp_header_html + 17, sizeof(data_tcp_header_html) - 17}};
#define FS_ROOT file_tcp_header_html
#define FS_NUMFILES 14

View File

@@ -1,371 +0,0 @@
/**
* \addtogroup exampleapps
* @{
*/
/**
* \defgroup httpd Web server
* @{
*
* The uIP web server is a very simplistic implementation of an HTTP
* server. It can serve web pages and files from a read-only ROM
* filesystem, and provides a very small scripting language.
*
* The script language is very simple and works as follows. Each
* script line starts with a command character, either "i", "t", "c",
* "#" or ".". The "i" command tells the script interpreter to
* "include" a file from the virtual file system and output it to the
* web browser. The "t" command should be followed by a line of text
* that is to be output to the browser. The "c" command is used to
* call one of the C functions from the httpd-cgi.c file. A line that
* starts with a "#" is ignored (i.e., the "#" denotes a comment), and
* the "." denotes the last script line.
*
* The script that produces the file statistics page looks somewhat
* like this:
*
\code
i /header.html
t <h1>File statistics</h1><br><table width="100%">
t <tr><td><a href="/index.html">/index.html</a></td><td>
c a /index.html
t </td></tr> <tr><td><a href="/cgi/files">/cgi/files</a></td><td>
c a /cgi/files
t </td></tr> <tr><td><a href="/cgi/tcp">/cgi/tcp</a></td><td>
c a /cgi/tcp
t </td></tr> <tr><td><a href="/404.html">/404.html</a></td><td>
c a /404.html
t </td></tr></table>
i /footer.plain
.
\endcode
*
*/
/**
* \file
* HTTP server.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd.c,v 1.28.2.6 2003/10/07 13:22:27 adam Exp $
*
*/
#include "uip.h"
#include "httpd.h"
#include "fs.h"
#include "fsdata.h"
#include "cgi.h"
#define NULL (void *)0
/* The HTTP server states: */
#define HTTP_NOGET 0
#define HTTP_FILE 1
#define HTTP_TEXT 2
#define HTTP_FUNC 3
#define HTTP_END 4
#ifdef DEBUG
#include <stdio.h>
#define PRINT(x) printf("%s", x)
#define PRINTLN(x) printf("%s\n", x)
#else /* DEBUG */
#define PRINT(x)
#define PRINTLN(x)
#endif /* DEBUG */
struct httpd_state *hs;
extern const struct fsdata_file file_index_html;
extern const struct fsdata_file file_404_html;
static void next_scriptline(void);
static void next_scriptstate(void);
#define ISO_G 0x47
#define ISO_E 0x45
#define ISO_T 0x54
#define ISO_slash 0x2f
#define ISO_c 0x63
#define ISO_g 0x67
#define ISO_i 0x69
#define ISO_space 0x20
#define ISO_nl 0x0a
#define ISO_cr 0x0d
#define ISO_a 0x61
#define ISO_t 0x74
#define ISO_hash 0x23
#define ISO_period 0x2e
/*-----------------------------------------------------------------------------------*/
/**
* Initialize the web server.
*
* Starts to listen for incoming connection requests on TCP port 80.
*/
/*-----------------------------------------------------------------------------------*/
void
httpd_init(void)
{
fs_init();
/* Listen to port 80. */
uip_listen(HTONS(80));
}
/*-----------------------------------------------------------------------------------*/
void
httpd_appcall(void)
{
struct fs_file fsfile;
u8_t i;
switch(uip_conn->lport) {
/* This is the web server: */
case HTONS(80):
/* Pick out the application state from the uip_conn structure. */
hs = (struct httpd_state *)(uip_conn->appstate);
/* We use the uip_ test functions to deduce why we were
called. If uip_connected() is non-zero, we were called
because a remote host has connected to us. If
uip_newdata() is non-zero, we were called because the
remote host has sent us new data, and if uip_acked() is
non-zero, the remote host has acknowledged the data we
previously sent to it. */
if(uip_connected()) {
/* Since we have just been connected with the remote host, we
reset the state for this connection. The ->count variable
contains the amount of data that is yet to be sent to the
remote host, and the ->state is set to HTTP_NOGET to signal
that we haven't received any HTTP GET request for this
connection yet. */
hs->state = HTTP_NOGET;
hs->count = 0;
return;
} else if(uip_poll()) {
/* If we are polled ten times, we abort the connection. This is
because we don't want connections lingering indefinately in
the system. */
if(hs->count++ >= 10) {
uip_abort();
}
return;
} else if(uip_newdata() && hs->state == HTTP_NOGET) {
/* This is the first data we receive, and it should contain a
GET. */
/* Check for GET. */
if(uip_appdata[0] != ISO_G ||
uip_appdata[1] != ISO_E ||
uip_appdata[2] != ISO_T ||
uip_appdata[3] != ISO_space) {
/* If it isn't a GET, we abort the connection. */
uip_abort();
return;
}
/* Find the file we are looking for. */
for(i = 4; i < 40; ++i) {
if(uip_appdata[i] == ISO_space ||
uip_appdata[i] == ISO_cr ||
uip_appdata[i] == ISO_nl) {
uip_appdata[i] = 0;
break;
}
}
PRINT("request for file ");
PRINTLN(&uip_appdata[4]);
/* Check for a request for "/". */
if(uip_appdata[4] == ISO_slash &&
uip_appdata[5] == 0) {
fs_open(file_index_html.name, &fsfile);
} else {
if(!fs_open((const char *)&uip_appdata[4], &fsfile)) {
PRINTLN("couldn't open file");
fs_open(file_404_html.name, &fsfile);
}
}
if(uip_appdata[4] == ISO_slash &&
uip_appdata[5] == ISO_c &&
uip_appdata[6] == ISO_g &&
uip_appdata[7] == ISO_i &&
uip_appdata[8] == ISO_slash) {
/* If the request is for a file that starts with "/cgi/", we
prepare for invoking a script. */
hs->script = fsfile.data;
next_scriptstate();
} else {
hs->script = NULL;
/* The web server is now no longer in the HTTP_NOGET state, but
in the HTTP_FILE state since is has now got the GET from
the client and will start transmitting the file. */
hs->state = HTTP_FILE;
/* Point the file pointers in the connection state to point to
the first byte of the file. */
hs->dataptr = fsfile.data;
hs->count = fsfile.len;
}
}
if(hs->state != HTTP_FUNC) {
/* Check if the client (remote end) has acknowledged any data that
we've previously sent. If so, we move the file pointer further
into the file and send back more data. If we are out of data to
send, we close the connection. */
if(uip_acked()) {
if(hs->count >= uip_conn->len) {
hs->count -= uip_conn->len;
hs->dataptr += uip_conn->len;
} else {
hs->count = 0;
}
if(hs->count == 0) {
if(hs->script != NULL) {
next_scriptline();
next_scriptstate();
} else {
uip_close();
}
}
}
} else {
/* Call the CGI function. */
if(cgitab[hs->script[2] - ISO_a](uip_acked())) {
/* If the function returns non-zero, we jump to the next line
in the script. */
next_scriptline();
next_scriptstate();
}
}
if(hs->state != HTTP_FUNC && !uip_poll()) {
/* Send a piece of data, but not more than the MSS of the
connection. */
uip_send(hs->dataptr, hs->count);
}
/* Finally, return to uIP. Our outgoing packet will soon be on its
way... */
return;
default:
/* Should never happen. */
uip_abort();
break;
}
}
/*-----------------------------------------------------------------------------------*/
/* next_scriptline():
*
* Reads the script until it finds a newline. */
static void
next_scriptline(void)
{
/* Loop until we find a newline character. */
do {
++(hs->script);
} while(hs->script[0] != ISO_nl);
/* Eat up the newline as well. */
++(hs->script);
}
/*-----------------------------------------------------------------------------------*/
/* next_sciptstate:
*
* Reads one line of script and decides what to do next.
*/
static void
next_scriptstate(void)
{
struct fs_file fsfile;
u8_t i;
again:
switch(hs->script[0]) {
case ISO_t:
/* Send a text string. */
hs->state = HTTP_TEXT;
hs->dataptr = &hs->script[2];
/* Calculate length of string. */
for(i = 0; hs->dataptr[i] != ISO_nl; ++i);
hs->count = i;
break;
case ISO_c:
/* Call a function. */
hs->state = HTTP_FUNC;
hs->dataptr = NULL;
hs->count = 0;
cgitab[hs->script[2] - ISO_a](0);
break;
case ISO_i:
/* Include a file. */
hs->state = HTTP_FILE;
if(!fs_open(&hs->script[2], &fsfile)) {
uip_abort();
}
hs->dataptr = fsfile.data;
hs->count = fsfile.len;
break;
case ISO_hash:
/* Comment line. */
next_scriptline();
goto again;
break;
case ISO_period:
/* End of script. */
hs->state = HTTP_END;
uip_close();
break;
default:
uip_abort();
break;
}
}
/*-----------------------------------------------------------------------------------*/
/** @} */
/** @} */

View File

@@ -1,93 +0,0 @@
#!/usr/bin/perl
open(OUTPUT, "> fsdata.c");
chdir("fs");
open(FILES, "find . -type f |");
while($file = <FILES>) {
# Do not include files in CVS directories nor backup files.
if($file =~ /(CVS|~)/) {
next;
}
chop($file);
open(HEADER, "> /tmp/header") || die $!;
if($file =~ /404.html/) {
print(HEADER "HTTP/1.0 404 File not found\r\n");
} else {
print(HEADER "HTTP/1.0 200 OK\r\n");
}
print(HEADER "Server: uIP/0.9 (http://dunkels.com/adam/uip/)\r\n");
if($file =~ /\.html$/) {
print(HEADER "Content-type: text/html\r\n");
} elsif($file =~ /\.gif$/) {
print(HEADER "Content-type: image/gif\r\n");
} elsif($file =~ /\.png$/) {
print(HEADER "Content-type: image/png\r\n");
} elsif($file =~ /\.jpg$/) {
print(HEADER "Content-type: image/jpeg\r\n");
} else {
print(HEADER "Content-type: text/plain\r\n");
}
print(HEADER "\r\n");
close(HEADER);
unless($file =~ /\.plain$/ || $file =~ /cgi/) {
system("cat /tmp/header $file > /tmp/file");
} else {
system("cp $file /tmp/file");
}
open(FILE, "/tmp/file");
unlink("/tmp/file");
unlink("/tmp/header");
$file =~ s/\.//;
$fvar = $file;
$fvar =~ s-/-_-g;
$fvar =~ s-\.-_-g;
print(OUTPUT "static const char data".$fvar."[] = {\n");
print(OUTPUT "\t/* $file */\n\t");
for($j = 0; $j < length($file); $j++) {
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
}
printf(OUTPUT "0,\n");
$i = 0;
while(read(FILE, $data, 1)) {
if($i == 0) {
print(OUTPUT "\t");
}
printf(OUTPUT "%#02x, ", unpack("C", $data));
$i++;
if($i == 10) {
print(OUTPUT "\n");
$i = 0;
}
}
print(OUTPUT "};\n\n");
close(FILE);
push(@fvars, $fvar);
push(@files, $file);
}
for($i = 0; $i < @fvars; $i++) {
$file = $files[$i];
$fvar = $fvars[$i];
if($i == 0) {
$prevfile = "NULL";
} else {
$prevfile = "file" . $fvars[$i - 1];
}
print(OUTPUT "const struct fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
}
print(OUTPUT "#define FS_ROOT file$fvars[$i - 1]\n\n");
print(OUTPUT "#define FS_NUMFILES $i");

View File

@@ -0,0 +1 @@
APP_SOURCES += resolv.c

View File

@@ -1,10 +1,10 @@
/**
* \addtogroup uip
* \addtogroup apps
* @{
*/
/**
* \defgroup uipdns uIP hostname resolver functions
* \defgroup resolv DNS resolver
* @{
*
* The uIP DNS resolver functions are used to lookup a hostname and
@@ -22,25 +22,25 @@
* \file
* DNS host name to IP address resolver.
* \author Adam Dunkels <adam@dunkels.com>
*
*
* This file implements a DNS host name to IP address resolver.
*/
/*
* Copyright (c) 2002-2003, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -52,15 +52,16 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: resolv.c,v 1.1.2.5 2003/10/06 22:56:44 adam Exp $
* $Id: resolv.c,v 1.5 2006/06/11 21:46:37 adam Exp $
*
*/
#include "resolv.h"
#include "uip.h"
#include <string.h>
@@ -100,7 +101,7 @@ struct dns_answer {
u16_t class;
u16_t ttl[2];
u16_t len;
u16_t ipaddr[2];
uip_ipaddr_t ipaddr;
};
struct namemap {
@@ -115,7 +116,7 @@ struct namemap {
u8_t seqno;
u8_t err;
char name[32];
u16_t ipaddr[2];
uip_ipaddr_t ipaddr;
};
#ifndef UIP_CONF_RESOLV_ENTRIES
@@ -132,13 +133,13 @@ static u8_t seqno;
static struct uip_udp_conn *resolv_conn = NULL;
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/** \internal
* Walk through a compact encoded DNS name and return the end of it.
*
* \return The end of the name.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static unsigned char *
parse_name(unsigned char *query)
{
@@ -157,12 +158,12 @@ parse_name(unsigned char *query)
/* printf("\n");*/
return query + 1;
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/** \internal
* Runs through the list of names to see if there are any that have
* not yet been queried and, if so, sends out a query.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
check_entries(void)
{
@@ -183,7 +184,7 @@ check_entries(void)
resolv_found(namemapptr->name, NULL);
continue;
}
namemapptr->tmr = namemapptr->retries;
namemapptr->tmr = namemapptr->retries;
} else {
/* printf("Timer %d\n", namemapptr->tmr);*/
/* Its timer has not run out, so we move on to next
@@ -225,11 +226,11 @@ check_entries(void)
}
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/** \internal
* Called when new UDP data arrives.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
newdata(void)
{
@@ -282,7 +283,7 @@ newdata(void)
while(nanswers > 0) {
/* The first byte in the answer resource record determines if it
is a compressed record or a normal one. */
if(*nameptr & 0xc0) {
if(*nameptr & 0xc0) {
/* Compressed name. */
nameptr +=2;
/* printf("Compressed anwser\n");*/
@@ -321,13 +322,13 @@ newdata(void)
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/** \internal
* The main UDP function.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
udp_appcall(void)
resolv_appcall(void)
{
if(uip_udp_conn->rport == HTONS(53)) {
if(uip_poll()) {
@@ -335,16 +336,16 @@ udp_appcall(void)
}
if(uip_newdata()) {
newdata();
}
}
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Queues a name so that a question for the name will be sent out.
*
* \param name The hostname that is to be queried.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
resolv_query(char *name)
{
@@ -376,12 +377,8 @@ resolv_query(char *name)
nameptr->state = STATE_NEW;
nameptr->seqno = seqno;
++seqno;
/* if(resolv_conn != NULL) {
dispatcher_emit(uip_signal_poll_udp, resolv_conn, DISPATCHER_BROADCAST);
} */
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Look up a hostname in the array of known hostnames.
*
@@ -394,7 +391,7 @@ resolv_query(char *name)
* address, or NULL if the hostname was not found in the array of
* hostnames.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
u16_t *
resolv_lookup(char *name)
{
@@ -406,13 +403,13 @@ resolv_lookup(char *name)
for(i = 0; i < RESOLV_ENTRIES; ++i) {
nameptr = &names[i];
if(nameptr->state == STATE_DONE &&
strcmp(name, nameptr->name) == 0) {
strcmp(name, nameptr->name) == 0) {
return nameptr->ipaddr;
}
}
return NULL;
}
/*-----------------------------------------------------------------------------------*/
}
/*---------------------------------------------------------------------------*/
/**
* Obtain the currently configured DNS server.
*
@@ -420,7 +417,7 @@ resolv_lookup(char *name)
* the currently configured DNS server or NULL if no DNS server has
* been configured.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
u16_t *
resolv_getserver(void)
{
@@ -429,14 +426,14 @@ resolv_getserver(void)
}
return resolv_conn->ripaddr;
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Configure which DNS server to use for queries.
*
* \param dnsserver A pointer to a 4-byte representation of the IP
* address of the DNS server to be configured.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
resolv_conf(u16_t *dnsserver)
{
@@ -444,13 +441,13 @@ resolv_conf(u16_t *dnsserver)
uip_udp_remove(resolv_conn);
}
resolv_conn = uip_udp_new(dnsserver, 53);
resolv_conn = uip_udp_new(dnsserver, HTONS(53));
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Initalize the resolver.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
resolv_init(void)
{
@@ -461,7 +458,7 @@ resolv_init(void)
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/** @} */
/** @} */

View File

@@ -1,5 +1,5 @@
/**
* \addtogroup uipdns
* \addtogroup resolv
* @{
*/
/**
@@ -10,19 +10,19 @@
/*
* Copyright (c) 2002-2003, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -34,17 +34,21 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: resolv.h,v 1.1.2.3 2003/10/04 21:18:59 adam Exp $
* $Id: resolv.h,v 1.4 2006/06/11 21:46:37 adam Exp $
*
*/
#ifndef __RESOLV_H__
#define __RESOLV_H__
#include "uip.h"
typedef int uip_udp_appstate_t;
void resolv_appcall(void);
#define UIP_UDP_APPCALL resolv_appcall
#include "uipopt.h"
/**
* Callback function which is called when a hostname is found.

1
apps/smtp/Makefile.smtp Normal file
View File

@@ -0,0 +1 @@
APP_SOURCES += smtp.c smtp-strings.c memb.c

View File

@@ -1,27 +0,0 @@
#!/usr/bin/perl
open(OUTPUTC, "> smtp-strings.c");
open(OUTPUTH, "> smtp-strings.h");
open(FILE, "smtp-strings");
while(<FILE>) {
if(/(.+) "(.+)"/) {
$var = $1;
$data = $2;
printf(OUTPUTC "char $var\[%d] = \n", length($data) + 1);
printf(OUTPUTC "/* $data */\n");
printf(OUTPUTC "{");
for($j = 0; $j < length($data); $j++) {
printf(OUTPUTC "%#02x, ", unpack("C", substr($data, $j, 1)));
}
printf(OUTPUTC "};\n");
printf(OUTPUTH "extern char $var\[%d];\n", length($data) + 1);
}
}
exit 0;
printf(OUTPUT "%#02x, ", unpack("C", $data));

40
apps/smtp/makestrings Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/perl
sub stringify {
my $name = shift(@_);
open(OUTPUTC, "> $name.c");
open(OUTPUTH, "> $name.h");
open(FILE, "$name");
while(<FILE>) {
if(/(.+) "(.+)"/) {
$var = $1;
$data = $2;
$datan = $data;
$datan =~ s/\\r/\r/g;
$datan =~ s/\\n/\n/g;
$datan =~ s/\\01/\01/g;
$datan =~ s/\\0/\0/g;
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
printf(OUTPUTC "/* \"$data\" */\n");
printf(OUTPUTC "{");
for($j = 0; $j < length($datan); $j++) {
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
}
printf(OUTPUTC "};\n");
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
}
}
close(OUTPUTC);
close(OUTPUTH);
}
stringify("smtp-strings");
exit 0;

View File

@@ -2,8 +2,10 @@ smtp_220 "220"
smtp_helo "HELO "
smtp_mail_from "MAIL FROM: "
smtp_rcpt_to "RCPT TO: "
smtp_data "DATA"
smtp_data "DATA\r\n"
smtp_to "To: "
smtp_from "From: "
smtp_subject "Subject: "
smtp_quit "QUIT"
smtp_quit "QUIT\r\n"
smtp_crnl "\r\n"
smtp_crnlperiodcrnl "\r\n.\r\n"

View File

@@ -1,27 +1,70 @@
char smtp_220[4] =
/* 220 */
/*
* Copyright (c) 2004, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $
*/
const char smtp_220[4] =
/* "220" */
{0x32, 0x32, 0x30, };
char smtp_helo[6] =
/* HELO */
const char smtp_helo[6] =
/* "HELO " */
{0x48, 0x45, 0x4c, 0x4f, 0x20, };
char smtp_mail_from[12] =
/* MAIL FROM: */
const char smtp_mail_from[12] =
/* "MAIL FROM: " */
{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
char smtp_rcpt_to[10] =
/* RCPT TO: */
const char smtp_rcpt_to[10] =
/* "RCPT TO: " */
{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
char smtp_data[5] =
/* DATA */
{0x44, 0x41, 0x54, 0x41, };
char smtp_to[5] =
/* To: */
const char smtp_data[7] =
/* "DATA\r\n" */
{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
const char smtp_to[5] =
/* "To: " */
{0x54, 0x6f, 0x3a, 0x20, };
char smtp_from[7] =
/* From: */
const char smtp_cc[5] =
/* "Cc: " */
{0x43, 0x63, 0x3a, 0x20, };
const char smtp_from[7] =
/* "From: " */
{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
char smtp_subject[10] =
/* Subject: */
const char smtp_subject[10] =
/* "Subject: " */
{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
char smtp_quit[5] =
/* QUIT */
{0x51, 0x55, 0x49, 0x54, };
const char smtp_quit[7] =
/* "QUIT\r\n" */
{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
const char smtp_crnl[3] =
/* "\r\n" */
{0xd, 0xa, };
const char smtp_crnlperiodcrnl[6] =
/* "\r\n.\r\n" */
{0xd, 0xa, 0x2e, 0xd, 0xa, };

View File

@@ -1,9 +1,46 @@
extern char smtp_220[4];
extern char smtp_helo[6];
extern char smtp_mail_from[12];
extern char smtp_rcpt_to[10];
extern char smtp_data[5];
extern char smtp_to[5];
extern char smtp_from[7];
extern char smtp_subject[10];
extern char smtp_quit[5];
/*
* Copyright (c) 2004, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: smtp-strings.h,v 1.3 2006/06/11 21:46:37 adam Exp $
*/
extern const char smtp_220[4];
extern const char smtp_helo[6];
extern const char smtp_mail_from[12];
extern const char smtp_rcpt_to[10];
extern const char smtp_data[7];
extern const char smtp_to[5];
extern const char smtp_cc[5];
extern const char smtp_from[7];
extern const char smtp_subject[10];
extern const char smtp_quit[7];
extern const char smtp_crnl[3];
extern const char smtp_crnlperiodcrnl[6];

View File

@@ -1,10 +1,10 @@
/**
* \addtogroup exampleapps
* \addtogroup apps
* @{
*/
/**
* \defgroup smtp SMTP E-mail sender
* \defgroup smtp SMTP E-mail sender
* @{
*
* The Simple Mail Transfer Protocol (SMTP) as defined by RFC821 is
@@ -12,7 +12,7 @@
* Internet. This simple example implementation is intended as an
* example of how to implement protocols in uIP, and is able to send
* out e-mail but has not been extensively tested.
*/
*/
/**
* \file
@@ -21,61 +21,51 @@
*/
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
* Copyright (c) 2004, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: smtp.c,v 1.1.2.7 2003/10/07 13:47:50 adam Exp $
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: smtp.c,v 1.4 2006/06/11 21:46:37 adam Exp $
*/
#include "uip.h"
#include "smtp.h"
#include "smtp-strings.h"
#include "psock.h"
#include "uip.h"
#include <string.h>
#define STATE_SEND_NONE 0
#define STATE_SEND_HELO 1
#define STATE_SEND_MAIL_FROM 2
#define STATE_SEND_RCPT_TO 3
#define STATE_SEND_DATA 4
#define STATE_SEND_DATA_HEADERS 5
#define STATE_SEND_DATA_MESSAGE 6
#define STATE_SEND_DATA_END 7
#define STATE_SEND_QUIT 8
#define STATE_SEND_DONE 9
static struct smtp_state s;
static char *localhostname;
static u16_t smtpserver[2];
static uip_ipaddr_t smtpserver;
#define ISO_nl 0x0a
#define ISO_cr 0x0d
@@ -88,317 +78,129 @@ static u16_t smtpserver[2];
#define ISO_5 0x35
/*-----------------------------------------------------------------------------------*/
static void
senddata(struct smtp_state *s)
/*---------------------------------------------------------------------------*/
static
PT_THREAD(smtp_thread(void))
{
char *textptr;
PSOCK_BEGIN(&s.psock);
if(s->textlen != 0 &&
s->textlen == s->sendptr) {
return;
PSOCK_READTO(&s.psock, ISO_nl);
if(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
PSOCK_CLOSE(&s.psock);
smtp_done(2);
PSOCK_EXIT(&s.psock);
}
textptr = (char *)uip_appdata;
switch(s->state) {
case STATE_SEND_HELO:
/* Create HELO message. */
strcpy(textptr, smtp_helo);
textptr += sizeof(smtp_helo) - 1;
strcpy(textptr, localhostname);
textptr += strlen(localhostname);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
/* printf("s->sendptr %d\n", s->sendptr);*/
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
/* printf("s->textlen %d\n", s->textlen);*/
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_MAIL_FROM:
/* Create MAIL FROM message. */
strcpy(textptr, smtp_mail_from);
textptr += sizeof(smtp_mail_from) - 1;
strcpy(textptr, s->from);
textptr += strlen(s->from);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_RCPT_TO:
/* Create RCPT_TO message. */
strcpy(textptr, smtp_rcpt_to);
textptr += sizeof(smtp_rcpt_to) - 1;
strcpy(textptr, s->to);
textptr += strlen(s->to);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_DATA:
strcpy(textptr, smtp_data);
textptr += sizeof(smtp_data) - 1;
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_DATA_HEADERS:
/* Create mail headers-> */
strcpy(textptr, smtp_to);
textptr += sizeof(smtp_to) - 1;
strcpy(textptr, s->to);
textptr += strlen(s->to);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
strcpy(textptr, smtp_from);
textptr += sizeof(smtp_from) - 1;
strcpy(textptr, s->from);
textptr += strlen(s->from);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
strcpy(textptr, smtp_subject);
textptr += sizeof(smtp_subject) - 1;
strcpy(textptr, s->subject);
textptr += strlen(s->subject);
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_DATA_MESSAGE:
textptr = s->msg;
if(s->sendptr == 0) {
s->textlen = s->msglen;
}
break;
case STATE_SEND_DATA_END:
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
*textptr = ISO_period;
++textptr;
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = 5;
}
textptr = (char *)uip_appdata;
break;
case STATE_SEND_QUIT:
strcpy(textptr, smtp_quit);
textptr += sizeof(smtp_quit) - 1;
*textptr = ISO_cr;
++textptr;
*textptr = ISO_nl;
++textptr;
if(s->sendptr == 0) {
s->textlen = textptr - (char *)uip_appdata;
}
textptr = (char *)uip_appdata;
break;
default:
return;
}
textptr += s->sendptr;
if(s->textlen - s->sendptr > uip_mss()) {
s->sentlen = uip_mss();
} else {
s->sentlen = s->textlen - s->sendptr;
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_helo);
PSOCK_SEND_STR(&s.psock, localhostname);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
/* textptr[s->sentlen] = 0;
printf("Senidng '%s'\n", textptr);*/
PSOCK_READTO(&s.psock, ISO_nl);
uip_send(textptr, s->sentlen);
}
/*-----------------------------------------------------------------------------------*/
static void
acked(struct smtp_state *s)
{
s->sendptr += s->sentlen;
s->sentlen = 0;
if(s.inputbuffer[0] != ISO_2) {
PSOCK_CLOSE(&s.psock);
smtp_done(3);
PSOCK_EXIT(&s.psock);
}
if(s->sendptr == s->textlen) {
switch(s->state) {
case STATE_SEND_DATA_HEADERS:
s->state = STATE_SEND_DATA_MESSAGE;
s->sendptr = s->textlen = 0;
break;
case STATE_SEND_DATA_MESSAGE:
s->state = STATE_SEND_DATA_END;
s->sendptr = s->textlen = 0;
break;
case STATE_SEND_DATA_END:
s->state = STATE_SEND_QUIT;
s->sendptr = s->textlen = 0;
break;
case STATE_SEND_QUIT:
s->state = STATE_SEND_DONE;
smtp_done(SMTP_ERR_OK);
uip_close();
break;
PSOCK_SEND_STR(&s.psock, (char *)smtp_mail_from);
PSOCK_SEND_STR(&s.psock, s.from);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
PSOCK_CLOSE(&s.psock);
smtp_done(4);
PSOCK_EXIT(&s.psock);
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
PSOCK_SEND_STR(&s.psock, s.to);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
PSOCK_CLOSE(&s.psock);
smtp_done(5);
PSOCK_EXIT(&s.psock);
}
if(s.cc != 0) {
PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
PSOCK_SEND_STR(&s.psock, s.cc);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
PSOCK_CLOSE(&s.psock);
smtp_done(6);
PSOCK_EXIT(&s.psock);
}
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_data);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_3) {
PSOCK_CLOSE(&s.psock);
smtp_done(7);
PSOCK_EXIT(&s.psock);
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_to);
PSOCK_SEND_STR(&s.psock, s.to);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
if(s.cc != 0) {
PSOCK_SEND_STR(&s.psock, (char *)smtp_cc);
PSOCK_SEND_STR(&s.psock, s.cc);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_from);
PSOCK_SEND_STR(&s.psock, s.from);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_SEND_STR(&s.psock, (char *)smtp_subject);
PSOCK_SEND_STR(&s.psock, s.subject);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
PSOCK_SEND(&s.psock, s.msg, s.msglen);
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnlperiodcrnl);
PSOCK_READTO(&s.psock, ISO_nl);
if(s.inputbuffer[0] != ISO_2) {
PSOCK_CLOSE(&s.psock);
smtp_done(8);
PSOCK_EXIT(&s.psock);
}
PSOCK_SEND_STR(&s.psock, (char *)smtp_quit);
smtp_done(SMTP_ERR_OK);
PSOCK_END(&s.psock);
}
/*-----------------------------------------------------------------------------------*/
static void
newdata(struct smtp_state *s)
{
if(*(char *)uip_appdata == ISO_5) {
smtp_done(1);
uip_abort();
return;
}
/* printf("Got %d bytes: '%s'\n", uip_datalen(),
uip_appdata);*/
switch(s->state) {
case STATE_SEND_NONE:
if(strncmp((char *)uip_appdata, smtp_220, 3) == 0) {
/* printf("Newdata(): SEND_NONE, got 220, towards SEND_HELO\n");*/
s->state = STATE_SEND_HELO;
s->sendptr = 0;
}
break;
case STATE_SEND_HELO:
if(*(char *)uip_appdata == ISO_2) {
/* printf("Newdata(): SEND_HELO, got 2*, towards SEND_MAIL_FROM\n");*/
s->state = STATE_SEND_MAIL_FROM;
s->sendptr = 0;
}
break;
case STATE_SEND_MAIL_FROM:
if(*(char *)uip_appdata == ISO_2) {
/* printf("Newdata(): SEND_MAIL_FROM, got 2*, towards SEND_RCPT_TO\n"); */
/* printf("2\n");*/
s->state = STATE_SEND_RCPT_TO;
s->textlen = s->sendptr = 0;
}
break;
case STATE_SEND_RCPT_TO:
if(*(char *)uip_appdata == ISO_2) {
/* printf("2\n");*/
s->state = STATE_SEND_DATA;
s->textlen = s->sendptr = 0;
}
break;
case STATE_SEND_DATA:
if(*(char *)uip_appdata == ISO_3) {
/* printf("3\n");*/
s->state = STATE_SEND_DATA_HEADERS;
s->textlen = s->sendptr = 0;
}
break;
case STATE_SEND_DATA_HEADERS:
if(*(char *)uip_appdata == ISO_3) {
/* printf("3\n");*/
s->state = STATE_SEND_DATA_MESSAGE;
s->textlen = s->sendptr = 0;
}
break;
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
smtp_appcall(void)
{
struct smtp_state *s;
s = (struct smtp_state *)uip_conn->appstate;
if(uip_connected()) {
/* senddata();*/
if(uip_closed()) {
s.connected = 0;
return;
}
if(uip_acked()) {
acked(s);
if(uip_aborted() || uip_timedout()) {
s.connected = 0;
smtp_done(1);
return;
}
if(uip_newdata()) {
newdata(s);
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked()) {
senddata(s);
} else if(uip_poll()) {
senddata(s);
}
/* if(uip_closed()) {
printf("Dnoe\n");
}*/
smtp_thread();
}
/*-----------------------------------------------------------------------------------*/
/**
* Send an e-mail.
*
* \param to The e-mail address of the receiver of the e-mail.
* \param from The e-mail address of the sender of the e-mail.
* \param subject The subject of the e-mail.
* \param msg The actual e-mail message.
* \param msglen The length of the e-mail message.
*/
/*-----------------------------------------------------------------------------------*/
unsigned char
smtp_send(char *to, char *from, char *subject,
char *msg, u16_t msglen)
{
struct uip_conn *conn;
struct smtp_state *s;
conn = uip_connect(smtpserver, HTONS(25));
if(conn == NULL) {
return 0;
}
s = conn->appstate;
s->state = STATE_SEND_NONE;
s->sentlen = s->sendptr = s->textlen = 0;
s->to = to;
s->from = from;
s->subject = subject;
s->msg = msg;
s->msglen = msglen;
return 1;
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Specificy an SMTP server and hostname.
*
@@ -410,13 +212,51 @@ smtp_send(char *to, char *from, char *subject,
* \param server A pointer to a 4-byte array representing the IP
* address of the SMTP server to be configured.
*/
/*-----------------------------------------------------------------------------------*/
void
smtp_configure(char *lhostname, u16_t *server)
smtp_configure(char *lhostname, void *server)
{
localhostname = lhostname;
smtpserver[0] = server[0];
smtpserver[1] = server[1];
uip_ipaddr_copy(smtpserver, server);
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/**
* Send an e-mail.
*
* \param to The e-mail address of the receiver of the e-mail.
* \param cc The e-mail address of the CC: receivers of the e-mail.
* \param from The e-mail address of the sender of the e-mail.
* \param subject The subject of the e-mail.
* \param msg The actual e-mail message.
* \param msglen The length of the e-mail message.
*/
unsigned char
smtp_send(char *to, char *cc, char *from,
char *subject, char *msg, u16_t msglen)
{
struct uip_conn *conn;
conn = uip_connect(smtpserver, HTONS(25));
if(conn == NULL) {
return 0;
}
s.connected = 1;
s.to = to;
s.cc = cc;
s.from = from;
s.subject = subject;
s.msg = msg;
s.msglen = msglen;
PSOCK_INIT(&s.psock, s.inputbuffer, sizeof(s.inputbuffer));
return 1;
}
/*---------------------------------------------------------------------------*/
void
smtp_init(void)
{
s.connected = 0;
}
/*---------------------------------------------------------------------------*/
/** @} */
/** @} */

View File

@@ -13,19 +13,19 @@
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -37,11 +37,11 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: smtp.h,v 1.1.2.4 2003/10/06 22:56:45 adam Exp $
* $Id: smtp.h,v 1.4 2006/06/11 21:46:37 adam Exp $
*
*/
#ifndef __SMTP_H__
@@ -66,11 +66,15 @@
*/
void smtp_done(unsigned char error);
void smtp_init(void);
/* Functions. */
void smtp_configure(char *localhostname, u16_t *smtpserver);
unsigned char smtp_send(char *to, char *from,
char *subject, char *msg,
u16_t msglen);
#define SMTP_SEND(to, cc, from, subject, msg) \
smtp_send(to, cc, from, subject, msg, strlen(msg))
void smtp_appcall(void);
@@ -91,10 +95,9 @@ struct smtp_state {
#ifndef UIP_APPCALL
#define UIP_APPCALL smtp_appcall
#endif
#ifndef UIP_APPSTATE_SIZE
#define UIP_APPSTATE_SIZE (sizeof(struct smtp_state))
#endif
typedef struct smtp_state uip_tcp_appstate_t;
#endif /* __SMTP_H__ */
/** @} */

View File

@@ -1,151 +0,0 @@
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: telnet.c,v 1.1.2.3 2003/10/06 11:20:45 adam Exp $
*
*/
#include "uip.h"
#include "telnet.h"
#ifndef NULL
#define NULL (void *)0
#endif /* NULL */
#define FLAG_CLOSE 1
#define FLAG_ABORT 2
/*-----------------------------------------------------------------------------------*/
unsigned char
telnet_send(struct telnet_state *s, char *text, u16_t len)
{
if(s->text != NULL) {
return 1;
}
s->text = text;
s->textlen = len;
s->sentlen = 0;
return 0;
}
/*-----------------------------------------------------------------------------------*/
unsigned char
telnet_close(struct telnet_state *s)
{
s->flags = FLAG_CLOSE;
if(s->text != NULL) {
return 1;
}
return 0;
}
/*-----------------------------------------------------------------------------------*/
unsigned char
telnet_abort(struct telnet_state *s)
{
s->flags = FLAG_ABORT;
if(s->text != NULL) {
return 1;
}
return 0;
}
/*-----------------------------------------------------------------------------------*/
static void
acked(struct telnet_state *s)
{
s->textlen -= s->sentlen;
if(s->textlen == 0) {
s->text = NULL;
telnet_sent(s);
} else {
s->text += s->sentlen;
}
s->sentlen = 0;
}
/*-----------------------------------------------------------------------------------*/
static void
senddata(struct telnet_state *s)
{
if(s->text == NULL) {
uip_send(s->text, 0);
return;
}
if(s->textlen > uip_mss()) {
s->sentlen = uip_mss();
} else {
s->sentlen = s->textlen;
}
uip_send(s->text, s->sentlen);
}
/*-----------------------------------------------------------------------------------*/
void telnet_app(void)
{
struct telnet_state *s = (struct telnet_state *)uip_conn->appstate;
if(uip_connected()) {
s->flags = 0;
telnet_connected(s);
senddata(s);
return;
}
if(uip_closed()) {
telnet_closed(s);
}
if(uip_aborted()) {
telnet_aborted(s);
}
if(uip_timedout()) {
telnet_timedout(s);
}
if(s->flags & FLAG_CLOSE) {
uip_close();
return;
}
if(s->flags & FLAG_ABORT) {
uip_abort();
return;
}
if(uip_acked()) {
acked(s);
}
if(uip_newdata()) {
telnet_newdata(s, (char *)uip_appdata, uip_datalen());
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked()) {
senddata(s);
} else if(uip_poll()) {
senddata(s);
}
}
/*-----------------------------------------------------------------------------------*/

View File

@@ -0,0 +1 @@
APP_SOURCES += telnetd.c shell.c memb.c

View File

@@ -1,152 +0,0 @@
/**
* \addtogroup exampleapps
* @{
*/
/**
* \file
* Memory block allocation routines.
* \author Adam Dunkels <adam@sics.se>
*
* The memory block allocation routines provide a simple yet powerful
* set of functions for managing a set of memory blocks of fixed
* size. A set of memory blocks is statically declared with the
* MEMB() macro. Memory blocks are allocated from the declared
* memory by the memb_alloc() function, and are deallocated with the
* memb_free() function.
*
* \note Because of namespace clashes only one MEMB() can be
* declared per C module, and the name scope of a MEMB() memory
* block is local to each C module.
*
* The following example shows how to declare and use a memory block
* called "cmem" which has 8 chunks of memory with each memory chunk
* being 20 bytes large.
*
\code
MEMB(cmem, 20, 8);
int main(int argc, char *argv[]) {
char *ptr;
memb_init(&cmem);
ptr = memb_alloc(&cmem);
if(ptr != NULL) {
do_something(ptr);
} else {
printf("Could not allocate memory.\n");
}
if(memb_free(ptr) == 0) {
printf("Deallocation succeeded.\n");
}
}
\endcode
*
*/
#include <string.h>
#include "memb.h"
/*------------------------------------------------------------------------------*/
/**
* Initialize a memory block that was declared with MEMB().
*
* \param m A memory block previosly declared with MEMB().
*/
/*------------------------------------------------------------------------------*/
void
memb_init(struct memb_blocks *m)
{
memset(m->mem, (m->size + 1) * m->num, 0);
}
/*------------------------------------------------------------------------------*/
/**
* Allocate a memory block from a block of memory declared with MEMB().
*
* \param m A memory block previosly declared with MEMB().
*/
/*------------------------------------------------------------------------------*/
char *
memb_alloc(struct memb_blocks *m)
{
int i;
char *ptr;
ptr = m->mem;
for(i = 0; i < m->num; ++i) {
if(*ptr == 0) {
/* If this block was unused, we increase the reference count to
indicate that it now is used and return a pointer to the
first byte following the reference counter. */
++*ptr;
return ptr + 1;
}
ptr += m->size + 1;
}
/* No free block was found, so we return NULL to indicate failure to
allocate block. */
return NULL;
}
/*------------------------------------------------------------------------------*/
/**
* Deallocate a memory block from a memory block previously declared
* with MEMB().
*
* \param m m A memory block previosly declared with MEMB().
*
* \param ptr A pointer to the memory block that is to be deallocated.
*
* \return The new reference count for the memory block (should be 0
* if successfully deallocated) or -1 if the pointer "ptr" did not
* point to a legal memory block.
*/
/*------------------------------------------------------------------------------*/
char
memb_free(struct memb_blocks *m, char *ptr)
{
int i;
char *ptr2;
/* Walk through the list of blocks and try to find the block to
which the pointer "ptr" points to. */
ptr2 = m->mem;
for(i = 0; i < m->num; ++i) {
if(ptr2 == ptr - 1) {
/* We've found to block to which "ptr" points so we decrease the
reference count and return the new value of it. */
return --*ptr2;
}
ptr2 += m->size + 1;
}
return -1;
}
/*------------------------------------------------------------------------------*/
/**
* Increase the reference count for a memory chunk.
*
* \note No sanity checks are currently made.
*
* \param m m A memory block previosly declared with MEMB().
*
* \param ptr A pointer to the memory chunk for which the reference
* count should be increased.
*
* \return The new reference count.
*/
/*------------------------------------------------------------------------------*/
char
memb_ref(struct memb_blocks *m, char *ptr)
{
return ++*(ptr - 1);
}
/*------------------------------------------------------------------------------*/

View File

@@ -1,43 +0,0 @@
/**
* \addtogroup exampleapps
* @{
*/
/**
* \file
* Memory block allocation routines.
* \author Adam Dunkels <adam@sics.se>
*
*/
#ifndef __MEMB_H__
#define __MEMB_H__
/**
* Declare a memory block.
*
* \param name The name of the memory block (later used with
* memb_init(), memb_alloc() and memb_free()).
*
* \param size The size of each memory chunk, in bytes.
*
* \param num The total number of memory chunks in the block.
*
*/
#define MEMB(name, size, num) \
static char memb_mem[(size + 1) * num]; \
static struct memb_blocks name = {size, num, memb_mem}
struct memb_blocks {
unsigned short size;
unsigned short num;
char *mem;
};
void memb_init(struct memb_blocks *m);
char *memb_alloc(struct memb_blocks *m);
char memb_ref(struct memb_blocks *m, char *ptr);
char memb_free(struct memb_blocks *m, char *ptr);
#endif /* __MEMB_H__ */

123
apps/telnetd/shell.c Normal file
View File

@@ -0,0 +1,123 @@
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
*
*/
#include "shell.h"
#include <string.h>
struct ptentry {
char *commandstr;
void (* pfunc)(char *str);
};
#define SHELL_PROMPT "uIP 1.0> "
/*---------------------------------------------------------------------------*/
static void
parse(register char *str, struct ptentry *t)
{
struct ptentry *p;
for(p = t; p->commandstr != NULL; ++p) {
if(strncmp(p->commandstr, str, strlen(p->commandstr)) == 0) {
break;
}
}
p->pfunc(str);
}
/*---------------------------------------------------------------------------*/
static void
inttostr(register char *str, unsigned int i)
{
str[0] = '0' + i / 100;
if(str[0] == '0') {
str[0] = ' ';
}
str[1] = '0' + (i / 10) % 10;
if(str[0] == ' ' && str[1] == '0') {
str[1] = ' ';
}
str[2] = '0' + i % 10;
str[3] = ' ';
str[4] = 0;
}
/*---------------------------------------------------------------------------*/
static void
help(char *str)
{
shell_output("Available commands:", "");
shell_output("stats - show network statistics", "");
shell_output("conn - show TCP connections", "");
shell_output("help, ? - show help", "");
shell_output("exit - exit shell", "");
}
/*---------------------------------------------------------------------------*/
static void
unknown(char *str)
{
if(strlen(str) > 0) {
shell_output("Unknown command: ", str);
}
}
/*---------------------------------------------------------------------------*/
static struct ptentry parsetab[] =
{{"stats", help},
{"conn", help},
{"help", help},
{"exit", shell_quit},
{"?", help},
/* Default action */
{NULL, unknown}};
/*---------------------------------------------------------------------------*/
void
shell_init(void)
{
}
/*---------------------------------------------------------------------------*/
void
shell_start(void)
{
shell_output("uIP command shell", "");
shell_output("Type '?' and return for help", "");
shell_prompt(SHELL_PROMPT);
}
/*---------------------------------------------------------------------------*/
void
shell_input(char *cmd)
{
parse(cmd, parsetab);
shell_prompt(SHELL_PROMPT);
}
/*---------------------------------------------------------------------------*/

104
apps/telnetd/shell.h Normal file
View File

@@ -0,0 +1,104 @@
/**
* \file
* Interface for the Contiki shell.
* \author Adam Dunkels <adam@dunkels.com>
*
* Some of the functions declared in this file must be implemented as
* a shell back-end in the architecture specific files of a Contiki
* port.
*/
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki desktop OS.
*
* $Id: shell.h,v 1.1 2006/06/07 09:43:54 adam Exp $
*
*/
#ifndef __SHELL_H__
#define __SHELL_H__
/**
* Initialize the shell.
*
* Called when the shell front-end process starts. This function may
* be used to start listening for signals.
*/
void shell_init(void);
/**
* Start the shell back-end.
*
* Called by the front-end when a new shell is started.
*/
void shell_start(void);
/**
* Process a shell command.
*
* This function will be called by the shell GUI / telnet server whan
* a command has been entered that should be processed by the shell
* back-end.
*
* \param command The command to be processed.
*/
void shell_input(char *command);
/**
* Quit the shell.
*
*/
void shell_quit(char *);
/**
* Print a string to the shell window.
*
* This function is implemented by the shell GUI / telnet server and
* can be called by the shell back-end to output a string in the
* shell window. The string is automatically appended with a linebreak.
*
* \param str1 The first half of the string to be output.
* \param str2 The second half of the string to be output.
*/
void shell_output(char *str1, char *str2);
/**
* Print a prompt to the shell window.
*
* This function can be used by the shell back-end to print out a
* prompt to the shell window.
*
* \param prompt The prompt to be printed.
*
*/
void shell_prompt(char *prompt);
#endif /* __SHELL_H__ */

View File

@@ -1,181 +0,0 @@
/**
* \addtogroup telnetd
* @{
*/
/**
* \file
* An example telnet server shell
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the Contiki desktop OS.
*
* $Id: telnetd-shell.c,v 1.1.2.1 2003/10/06 22:56:22 adam Exp $
*
*/
#include "uip.h"
#include "telnetd.h"
#include <string.h>
struct ptentry {
char c;
void (* pfunc)(struct telnetd_state *s, char *str);
};
/*-----------------------------------------------------------------------------------*/
static void
parse(struct telnetd_state *s, register char *str, struct ptentry *t)
{
register struct ptentry *p;
char *sstr;
sstr = str;
/* Loop over the parse table entries in t in order to find one that
matches the first character in str. */
for(p = t; p->c != 0; ++p) {
if(*str == p->c) {
/* Skip rest of the characters up to the first space. */
while(*str != ' ') {
++str;
}
/* Skip all spaces.*/
while(*str == ' ') {
++str;
}
/* Call parse table entry function and return. */
p->pfunc(s, str);
return;
}
}
/* Did not find matching entry in parse table. We just call the
default handler supplied by the caller and return. */
p->pfunc(s, str);
}
/*-----------------------------------------------------------------------------------*/
static void
exitt(struct telnetd_state *s, char *str)
{
telnetd_close(s);
}
/*-----------------------------------------------------------------------------------*/
static void
inttostr(register char *str, unsigned int i)
{
str[0] = '0' + i / 100;
if(str[0] == '0') {
str[0] = ' ';
}
str[1] = '0' + (i / 10) % 10;
if(str[1] == '0') {
str[1] = ' ';
}
str[2] = '0' + i % 10;
str[3] = ' ';
str[4] = 0;
}
/*-----------------------------------------------------------------------------------*/
static void
stats(struct telnetd_state *s, char *strr)
{
char str[10];
inttostr(str, uip_stat.ip.recv);
telnetd_output(s, "IP packets received ", str);
inttostr(str, uip_stat.ip.sent);
telnetd_output(s, "IP packets sent ", str);
inttostr(str, uip_stat.ip.drop);
telnetd_output(s, "IP packets dropped ", str);
inttostr(str, uip_stat.icmp.recv);
telnetd_output(s, "ICMP packets received ", str);
inttostr(str, uip_stat.icmp.sent);
telnetd_output(s, "ICMP packets sent ", str);
inttostr(str, uip_stat.icmp.drop);
telnetd_output(s, "ICMP packets dropped ", str);
inttostr(str, uip_stat.tcp.recv);
telnetd_output(s, "TCP packets received ", str);
inttostr(str, uip_stat.tcp.sent);
telnetd_output(s, "TCP packets sent ", str);
inttostr(str, uip_stat.tcp.drop);
telnetd_output(s, "TCP packets dropped ", str);
inttostr(str, uip_stat.tcp.rexmit);
telnetd_output(s, "TCP packets retransmitted ", str);
inttostr(str, uip_stat.tcp.synrst);
telnetd_output(s, "TCP connection attempts ", str);
}
/*-----------------------------------------------------------------------------------*/
static void
help(struct telnetd_state *s, char *str)
{
telnetd_output(s, "Available commands:", "");
telnetd_output(s, "stats - show uIP statistics", "");
telnetd_output(s, "exit - exit shell", "");
telnetd_output(s, "? - show this help", "");
}
/*-----------------------------------------------------------------------------------*/
static void
none(struct telnetd_state *s, char *str)
{
if(strlen(str) > 0) {
telnetd_output(s, "Unknown command", "");
}
}
/*-----------------------------------------------------------------------------------*/
static struct ptentry configparsetab[] =
{{'s', stats},
{'e', exitt},
{'?', help},
/* Default action */
{0, none}};
/*-----------------------------------------------------------------------------------*/
void
telnetd_connected(struct telnetd_state *s)
{
telnetd_output(s, "uIP command shell", "");
telnetd_output(s, "Type '?' for help", "");
telnetd_prompt(s, "uIP-0.9> ");
}
/*-----------------------------------------------------------------------------------*/
void
telnetd_input(struct telnetd_state *s, char *cmd)
{
parse(s, cmd, configparsetab);
telnetd_prompt(s, "uIP-0.9> ");
}
/*-----------------------------------------------------------------------------------*/

View File

@@ -1,50 +1,18 @@
/**
* \addtogroup exampleapps
* @{
*/
/**
* \defgroup telnetd Telnet server
* @{
*
* The uIP telnet server provides a command based interface to uIP. It
* allows using the "telnet" application to access uIP, and implements
* the required telnet option negotiation.
*
* The code is structured in a way which makes it possible to add
* commands without having to rewrite the main telnet code. The main
* telnet code calls two callback functions, telnetd_connected() and
* telnetd_input(), when a telnet connection has been established and
* when a line of text arrives on a telnet connection. These two
* functions can be implemented in a way which suits the particular
* application or environment in which the uIP system is intended to
* be run.
*
* The uIP distribution contains an example telnet shell
* implementation that provides a basic set of commands.
*/
/**
* \file
* Implementation of the Telnet server.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -56,199 +24,199 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
* This file is part of the uIP TCP/IP stack
*
* $Id: telnetd.c,v 1.1.2.2 2003/10/07 13:47:50 adam Exp $
* $Id: telnetd.c,v 1.2 2006/06/07 09:43:54 adam Exp $
*
*/
#include "uip.h"
#include "memb.h"
#include "telnetd.h"
#include "memb.h"
#include "shell.h"
#include <string.h>
#define ISO_nl 0x0a
#define ISO_cr 0x0d
MEMB(linemem, TELNETD_LINELEN, TELNETD_NUMLINES);
static u8_t i;
struct telnetd_line {
char line[TELNETD_CONF_LINELEN];
};
MEMB(linemem, struct telnetd_line, TELNETD_CONF_NUMLINES);
#define STATE_NORMAL 0
#define STATE_IAC 1
#define STATE_WILL 2
#define STATE_WONT 3
#define STATE_DO 4
#define STATE_DO 4
#define STATE_DONT 5
#define STATE_CLOSE 6
static struct telnetd_state s;
#define TELNET_IAC 255
#define TELNET_WILL 251
#define TELNET_WONT 252
#define TELNET_DO 253
#define TELNET_DONT 254
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static char *
alloc_line(void)
{
{
return memb_alloc(&linemem);
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
dealloc_line(char *line)
{
memb_free(&linemem, line);
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
shell_quit(char *str)
{
s.state = STATE_CLOSE;
}
/*---------------------------------------------------------------------------*/
static void
sendline(struct telnetd_state *s, char *line)
sendline(char *line)
{
static unsigned int i;
for(i = 0; i < TELNETD_NUMLINES; ++i) {
if(s->lines[i] == NULL) {
s->lines[i] = line;
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
if(s.lines[i] == NULL) {
s.lines[i] = line;
break;
}
}
if(i == TELNETD_NUMLINES) {
if(i == TELNETD_CONF_NUMLINES) {
dealloc_line(line);
}
}
/*-----------------------------------------------------------------------------------*/
/**
* Close a telnet session.
*
* This function can be called from a telnet command in order to close
* the connection.
*
* \param s The connection which is to be closed.
*
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
telnetd_close(struct telnetd_state *s)
{
s->state = STATE_CLOSE;
}
/*-----------------------------------------------------------------------------------*/
/**
* Print a prompt on a telnet connection.
*
* This function can be called by the telnet command shell in order to
* print out a command prompt.
*
* \param s A telnet connection.
*
* \param str The command prompt.
*
*/
/*-----------------------------------------------------------------------------------*/
void
telnetd_prompt(struct telnetd_state *s, char *str)
shell_prompt(char *str)
{
char *line;
line = alloc_line();
if(line != NULL) {
strncpy(line, str, TELNETD_LINELEN);
sendline(s, line);
}
strncpy(line, str, TELNETD_CONF_LINELEN);
/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
sendline(line);
}
}
/*-----------------------------------------------------------------------------------*/
/**
* Print out a string on a telnet connection.
*
* This function can be called from a telnet command parser in order
* to print out a string of text on the connection. The two strings
* given as arguments to the function will be concatenated, a carrige
* return and a new line character will be added, and the line is
* sent.
*
* \param s The telnet connection.
*
* \param str1 The first string.
*
* \param str2 The second string.
*
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
telnetd_output(struct telnetd_state *s, char *str1, char *str2)
shell_output(char *str1, char *str2)
{
static unsigned len;
char *line;
line = alloc_line();
if(line != NULL) {
len = strlen(str1);
strncpy(line, str1, TELNETD_LINELEN);
if(len < TELNETD_LINELEN) {
strncpy(line + len, str2, TELNETD_LINELEN - len);
strncpy(line, str1, TELNETD_CONF_LINELEN);
if(len < TELNETD_CONF_LINELEN) {
strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
}
len = strlen(line);
if(len < TELNETD_LINELEN - 2) {
if(len < TELNETD_CONF_LINELEN - 2) {
line[len] = ISO_cr;
line[len+1] = ISO_nl;
line[len+2] = 0;
}
sendline(s, line);
/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
sendline(line);
}
}
/*-----------------------------------------------------------------------------------*/
/**
* Initialize the telnet server.
*
* This function will perform the necessary initializations and start
* listening on TCP port 23.
*/
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
telnetd_init(void)
{
memb_init(&linemem);
uip_listen(HTONS(23));
memb_init(&linemem);
shell_init();
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
acked(struct telnetd_state *s)
acked(void)
{
dealloc_line(s->lines[0]);
for(i = 1; i < TELNETD_NUMLINES; ++i) {
s->lines[i - 1] = s->lines[i];
static unsigned int i;
while(s.numsent > 0) {
dealloc_line(s.lines[0]);
for(i = 1; i < TELNETD_CONF_NUMLINES; ++i) {
s.lines[i - 1] = s.lines[i];
}
s.lines[TELNETD_CONF_NUMLINES - 1] = NULL;
--s.numsent;
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
senddata(struct telnetd_state *s)
senddata(void)
{
if(s->lines[0] != NULL) {
uip_send(s->lines[0], strlen(s->lines[0]));
static char *bufptr, *lineptr;
static int buflen, linelen;
bufptr = uip_appdata;
buflen = 0;
for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
s.lines[s.numsent] != NULL ; ++s.numsent) {
lineptr = s.lines[s.numsent];
linelen = strlen(lineptr);
if(linelen > TELNETD_CONF_LINELEN) {
linelen = TELNETD_CONF_LINELEN;
}
if(buflen + linelen < uip_mss()) {
memcpy(bufptr, lineptr, linelen);
bufptr += linelen;
buflen += linelen;
} else {
break;
}
}
uip_send(uip_appdata, buflen);
}
/*---------------------------------------------------------------------------*/
static void
closed(void)
{
static unsigned int i;
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
if(s.lines[i] != NULL) {
dealloc_line(s.lines[i]);
}
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
getchar(struct telnetd_state *s, u8_t c)
get_char(u8_t c)
{
if(c == ISO_cr) {
return;
}
s->buf[(int)s->bufptr] = c;
if(s->buf[(int)s->bufptr] == ISO_nl ||
s->bufptr == sizeof(s->buf) - 1) {
if(s->bufptr > 0) {
s->buf[(int)s->bufptr] = 0;
s.buf[(int)s.bufptr] = c;
if(s.buf[(int)s.bufptr] == ISO_nl ||
s.bufptr == sizeof(s.buf) - 1) {
if(s.bufptr > 0) {
s.buf[(int)s.bufptr] = 0;
/* petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);*/
}
telnetd_input(s, s->buf);
s->bufptr = 0;
shell_input(s.buf);
s.bufptr = 0;
} else {
++s->bufptr;
++s.bufptr;
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
sendopt(struct telnetd_state *s, u8_t option, u8_t value)
sendopt(u8_t option, u8_t value)
{
char *line;
line = alloc_line();
@@ -257,136 +225,126 @@ sendopt(struct telnetd_state *s, u8_t option, u8_t value)
line[1] = option;
line[2] = value;
line[3] = 0;
sendline(s, line);
}
sendline(line);
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static void
newdata(struct telnetd_state *s)
newdata(void)
{
u16_t len;
u8_t c;
char *dataptr;
len = uip_datalen();
dataptr = (char *)uip_appdata;
while(len > 0 && s->bufptr < sizeof(s->buf)) {
c = *uip_appdata;
++uip_appdata;
while(len > 0 && s.bufptr < sizeof(s.buf)) {
c = *dataptr;
++dataptr;
--len;
switch(s->state) {
switch(s.state) {
case STATE_IAC:
if(c == TELNET_IAC) {
getchar(s, c);
s->state = STATE_NORMAL;
get_char(c);
s.state = STATE_NORMAL;
} else {
switch(c) {
case TELNET_WILL:
s->state = STATE_WILL;
s.state = STATE_WILL;
break;
case TELNET_WONT:
s->state = STATE_WONT;
s.state = STATE_WONT;
break;
case TELNET_DO:
s->state = STATE_DO;
s.state = STATE_DO;
break;
case TELNET_DONT:
s->state = STATE_DONT;
s.state = STATE_DONT;
break;
default:
s->state = STATE_NORMAL;
s.state = STATE_NORMAL;
break;
}
}
break;
case STATE_WILL:
/* Reply with a DONT */
sendopt(s, TELNET_DONT, c);
s->state = STATE_NORMAL;
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
case STATE_WONT:
/* Reply with a DONT */
sendopt(s, TELNET_DONT, c);
s->state = STATE_NORMAL;
sendopt(TELNET_DONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DO:
/* Reply with a WONT */
sendopt(s, TELNET_WONT, c);
s->state = STATE_NORMAL;
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_DONT:
/* Reply with a WONT */
sendopt(s, TELNET_WONT, c);
s->state = STATE_NORMAL;
sendopt(TELNET_WONT, c);
s.state = STATE_NORMAL;
break;
case STATE_NORMAL:
if(c == TELNET_IAC) {
s->state = STATE_IAC;
s.state = STATE_IAC;
} else {
getchar(s, c);
}
get_char(c);
}
break;
}
}
}
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void
telnetd_app(void)
telnetd_appcall(void)
{
struct telnetd_state *s;
s = (struct telnetd_state *)uip_conn->appstate;
static unsigned int i;
if(uip_connected()) {
for(i = 0; i < TELNETD_NUMLINES; ++i) {
s->lines[i] = NULL;
/* tcp_markconn(uip_conn, &s);*/
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
s.lines[i] = NULL;
}
s->bufptr = 0;
s->state = STATE_NORMAL;
s.bufptr = 0;
s.state = STATE_NORMAL;
telnetd_connected(s);
senddata(s);
return;
shell_start();
}
if(s->state == STATE_CLOSE) {
s->state = STATE_NORMAL;
if(s.state == STATE_CLOSE) {
s.state = STATE_NORMAL;
uip_close();
return;
}
if(uip_closed()) {
telnetd_output(s, "Connection closed", "");
}
if(uip_aborted()) {
telnetd_output(s, "Connection reset", "");
}
if(uip_timedout()) {
telnetd_output(s, "Connection timed out", "");
if(uip_closed() ||
uip_aborted() ||
uip_timedout()) {
closed();
}
if(uip_acked()) {
acked(s);
acked();
}
if(uip_newdata()) {
newdata(s);
newdata();
}
if(uip_rexmit() ||
uip_newdata() ||
uip_acked()) {
senddata(s);
} else if(uip_poll()) {
senddata(s);
uip_acked() ||
uip_connected() ||
uip_poll()) {
senddata();
}
}
/*-----------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

View File

@@ -1,29 +1,19 @@
/**
* \addtogroup telnetd
* @{
*/
/**
* \file
* Header file for the telnet server.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
* Copyright (c) 2003, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -35,80 +25,39 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
* This file is part of the uIP TCP/IP stack
*
* $Id: telnetd.h,v 1.1.2.2 2003/10/07 13:22:27 adam Exp $
* $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $
*
*/
#ifndef __TELNETD_H__
#define __TELNETD_H__
#include "uip.h"
#include "uipopt.h"
/**
* The maximum length of a telnet line.
*
* \hideinitializer
*/
#define TELNETD_LINELEN 36
void telnetd_appcall(void);
/**
* The number of output lines being buffered for all telnet
* connections.
*
* \hideinitializer
*/
#define TELNETD_NUMLINES 24
#ifndef TELNETD_CONF_LINELEN
#define TELNETD_CONF_LINELEN 40
#endif
#ifndef TELNETD_CONF_NUMLINES
#define TELNETD_CONF_NUMLINES 16
#endif
/**
* A telnet connection structure.
*/
struct telnetd_state {
char *lines[TELNETD_NUMLINES];
char buf[TELNETD_LINELEN];
char *lines[TELNETD_CONF_NUMLINES];
char buf[TELNETD_CONF_LINELEN];
char bufptr;
u8_t numsent;
u8_t state;
};
/**
* Callback function that is called when a telnet connection has been
* established.
*
* \param s The telnet connection.
*/
void telnetd_connected(struct telnetd_state *s);
/**
* Callback function that is called when a line of text has arrived on
* a telnet connection.
*
* \param s The telnet connection.
*
* \param cmd The line of text.
*/
void telnetd_input(struct telnetd_state *s, char *cmd);
void telnetd_close(struct telnetd_state *s);
void telnetd_output(struct telnetd_state *s, char *s1, char *s2);
void telnetd_prompt(struct telnetd_state *s, char *str);
void telnetd_app(void);
typedef struct telnetd_state uip_tcp_appstate_t;
#ifndef UIP_APPCALL
#define UIP_APPCALL telnetd_app
#define UIP_APPCALL telnetd_appcall
#endif
#ifndef UIP_APPSTATE_SIZE
#define UIP_APPSTATE_SIZE (sizeof(struct telnetd_state))
#endif
void telnetd_init(void);
#endif /* __TELNET_H__ */
/** @} */
#endif /* __TELNETD_H__ */

View File

@@ -0,0 +1 @@
APP_SOURCES += webclient-strings.c webclient.c

View File

@@ -1,12 +0,0 @@
http_200 "200 "
http_301 "301 "
http_302 "302 "
http_get "GET "
http_10 "HTTP/1.0"
http_11 "HTTP/1.1"
http_content_type "Content-Type: "
http_texthtml "text/html"
http_location "Location: "
http_host "Host: "
http_connection_close "Connection: close"
http_user_agent "User-Agent: Contiki/1.0 (Commodore 64; http://dunkels.com/adam/contiki/)"

View File

@@ -1,39 +0,0 @@
char http_200[5] =
/* 200 */
{0x32, 0x30, 0x30, 0x20, };
char http_301[5] =
/* 301 */
{0x33, 0x30, 0x31, 0x20, };
char http_302[5] =
/* 302 */
{0x33, 0x30, 0x32, 0x20, };
char http_get[5] =
/* GET */
{0x47, 0x45, 0x54, 0x20, };
char http_10[9] =
/* HTTP/1.0 */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
char http_11[9] =
/* HTTP/1.1 */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
char http_content_type[15] =
/* Content-Type: */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, };
char http_texthtml[10] =
/* text/html */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
char http_location[11] =
/* Location: */
{0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
char http_host[7] =
/* Host: */
{0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
char http_connection_close[18] =
/* Connection: close */
{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, };
char http_user_agent[73] =
/* User-Agent: Contiki/1.0 (Commodore 64; http://dunkels.com/adam/contiki/) */
{0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x20, 0x36, 0x34, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, };
char test_httpstring[16] =
/* HTTP/1.0 200 OK */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, };

View File

@@ -1,13 +0,0 @@
extern char http_200[5];
extern char http_301[5];
extern char http_302[5];
extern char http_get[5];
extern char http_10[9];
extern char http_11[9];
extern char http_content_type[15];
extern char http_texthtml[10];
extern char http_location[11];
extern char http_host[7];
extern char http_connection_close[18];
extern char http_user_agent[73];
extern char test_httpstring[16];

View File

@@ -1,27 +0,0 @@
#!/usr/bin/perl
open(OUTPUTC, "> http-strings.c");
open(OUTPUTH, "> http-strings.h");
open(FILE, "http-strings");
while(<FILE>) {
if(/(.+) "(.+)"/) {
$var = $1;
$data = $2;
printf(OUTPUTC "char $var\[%d] = \n", length($data) + 1);
printf(OUTPUTC "/* $data */\n");
printf(OUTPUTC "{");
for($j = 0; $j < length($data); $j++) {
printf(OUTPUTC "%#02x, ", unpack("C", substr($data, $j, 1)));
}
printf(OUTPUTC "};\n");
printf(OUTPUTH "extern char $var\[%d];\n", length($data) + 1);
}
}
exit 0;
printf(OUTPUT "%#02x, ", unpack("C", $data));

40
apps/webclient/makestrings Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/perl
sub stringify {
my $name = shift(@_);
open(OUTPUTC, "> $name.c");
open(OUTPUTH, "> $name.h");
open(FILE, "$name");
while(<FILE>) {
if(/(.+) "(.+)"/) {
$var = $1;
$data = $2;
$datan = $data;
$datan =~ s/\\r/\r/g;
$datan =~ s/\\n/\n/g;
$datan =~ s/\\01/\01/g;
$datan =~ s/\\0/\0/g;
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
printf(OUTPUTC "/* \"$data\" */\n");
printf(OUTPUTC "{");
for($j = 0; $j < length($datan); $j++) {
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
}
printf(OUTPUTC "0 };\n");
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
}
}
close(OUTPUTC);
close(OUTPUTH);
}
stringify("webclient-strings");
exit 0;

View File

@@ -0,0 +1,31 @@
http_http "http://"
http_200 "200 "
http_301 "301 "
http_302 "302 "
http_get "GET "
http_10 "HTTP/1.0"
http_11 "HTTP/1.1"
http_content_type "content-type: "
http_texthtml "text/html"
http_location "location: "
http_host "host: "
http_crnl "\r\n"
http_index_html "/index.html"
http_404_html "/404.html"
http_content_type_html "Content-type: text/html\r\n\r\n"
http_content_type_css "Content-type: text/css\r\n\r\n"
http_content_type_text "Content-type: text/text\r\n\r\n"
http_content_type_png "Content-type: image/png\r\n\r\n"
http_content_type_gif "Content-type: image/gif\r\n\r\n"
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
http_html ".html"
http_shtml ".shtml"
http_htm ".htm"
http_css ".css"
http_png ".png"
http_gif ".gif"
http_jpg ".jpg"
http_text ".text"
http_txt ".txt"
http_user_agent_fields "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n"

View File

@@ -0,0 +1,93 @@
const char http_http[8] =
/* "http://" */
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0 };
const char http_200[5] =
/* "200 " */
{0x32, 0x30, 0x30, 0x20, 0 };
const char http_301[5] =
/* "301 " */
{0x33, 0x30, 0x31, 0x20, 0 };
const char http_302[5] =
/* "302 " */
{0x33, 0x30, 0x32, 0x20, 0 };
const char http_get[5] =
/* "GET " */
{0x47, 0x45, 0x54, 0x20, 0 };
const char http_10[9] =
/* "HTTP/1.0" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0 };
const char http_11[9] =
/* "HTTP/1.1" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0 };
const char http_content_type[15] =
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0 };
const char http_texthtml[10] =
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_location[11] =
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0 };
const char http_host[7] =
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0 };
const char http_crnl[3] =
/* "\r\n" */
{0xd, 0xa, 0 };
const char http_index_html[12] =
/* "/index.html" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_404_html[10] =
/* "/404.html" */
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_content_type_html[28] =
/* "Content-type: text/html\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_css [27] =
/* "Content-type: text/css\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_text[28] =
/* "Content-type: text/text\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_png [28] =
/* "Content-type: image/png\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_gif [28] =
/* "Content-type: image/gif\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_jpg [29] =
/* "Content-type: image/jpeg\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_content_type_binary[43] =
/* "Content-type: application/octet-stream\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, 0 };
const char http_html[6] =
/* ".html" */
{0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_shtml[7] =
/* ".shtml" */
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0 };
const char http_htm[5] =
/* ".htm" */
{0x2e, 0x68, 0x74, 0x6d, 0 };
const char http_css[5] =
/* ".css" */
{0x2e, 0x63, 0x73, 0x73, 0 };
const char http_png[5] =
/* ".png" */
{0x2e, 0x70, 0x6e, 0x67, 0 };
const char http_gif[5] =
/* ".gif" */
{0x2e, 0x67, 0x69, 0x66, 0 };
const char http_jpg[5] =
/* ".jpg" */
{0x2e, 0x6a, 0x70, 0x67, 0 };
const char http_text[6] =
/* ".text" */
{0x2e, 0x74, 0x65, 0x78, 0x74, 0 };
const char http_txt[5] =
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, 0 };
const char http_user_agent_fields[77] =
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, 0 };

View File

@@ -0,0 +1,31 @@
extern const char http_http[8];
extern const char http_200[5];
extern const char http_301[5];
extern const char http_302[5];
extern const char http_get[5];
extern const char http_10[9];
extern const char http_11[9];
extern const char http_content_type[15];
extern const char http_texthtml[10];
extern const char http_location[11];
extern const char http_host[7];
extern const char http_crnl[3];
extern const char http_index_html[12];
extern const char http_404_html[10];
extern const char http_content_type_html[28];
extern const char http_content_type_css [27];
extern const char http_content_type_text[28];
extern const char http_content_type_png [28];
extern const char http_content_type_gif [28];
extern const char http_content_type_jpg [29];
extern const char http_content_type_binary[43];
extern const char http_html[6];
extern const char http_shtml[7];
extern const char http_htm[5];
extern const char http_css[5];
extern const char http_png[5];
extern const char http_gif[5];
extern const char http_jpg[5];
extern const char http_text[6];
extern const char http_txt[5];
extern const char http_user_agent_fields[77];

View File

@@ -1,5 +1,5 @@
/**
* \addtogroup exampleapps
* \addtogroup apps
* @{
*/
@@ -22,20 +22,20 @@
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -47,15 +47,16 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the "contiki" web browser.
* This file is part of the uIP TCP/IP stack.
*
* $Id: webclient.c,v 1.1.2.5 2003/10/06 22:56:45 adam Exp $
* $Id: webclient.c,v 1.2 2006/06/11 21:46:37 adam Exp $
*
*/
#include "uip.h"
#include "uiplib.h"
#include "webclient.h"
#include "resolv.h"
@@ -78,22 +79,6 @@
#define ISO_cr 0x0d
#define ISO_space 0x20
struct webclient_state {
u8_t timer;
u8_t state;
u8_t httpflag;
u16_t port;
char host[40];
char file[WWW_CONF_MAX_URLLEN];
u16_t getrequestptr;
u16_t getrequestleft;
char httpheaderline[200];
u16_t httpheaderlineptr;
char mimetype[32];
};
static struct webclient_state s;
@@ -155,13 +140,13 @@ unsigned char
webclient_get(char *host, u16_t port, char *file)
{
struct uip_conn *conn;
u16_t *ipaddr;
static u16_t addr[2];
uip_ipaddr_t *ipaddr;
static uip_ipaddr_t addr;
/* First check if the host is an IP address. */
ipaddr = &addr[0];
if(uip_main_ipaddrconv(host, (unsigned char *)addr) == 0) {
ipaddr = resolv_lookup(host);
ipaddr = &addr;
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
ipaddr = (uip_ipaddr_t *)resolv_lookup(host);
if(ipaddr == NULL) {
return 0;
@@ -182,11 +167,12 @@ webclient_get(char *host, u16_t port, char *file)
return 1;
}
/*-----------------------------------------------------------------------------------*/
static unsigned char * CC_FASTCALL
static unsigned char *
copy_string(unsigned char *dest,
const unsigned char *src, unsigned char len)
{
return strcpy(dest, src) + len;
strncpy(dest, src, len);
return dest + len;
}
/*-----------------------------------------------------------------------------------*/
static void
@@ -218,7 +204,7 @@ senddata(void)
s.getrequestleft;
uip_send(&(getrequest[s.getrequestptr]), len);
}
}
}
/*-----------------------------------------------------------------------------------*/
static void
acked(void)
@@ -240,8 +226,8 @@ parse_statusline(u16_t len)
char *cptr;
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
++uip_appdata;
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
++((char *)uip_appdata);
--len;
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
@@ -308,8 +294,8 @@ parse_headers(u16_t len)
static unsigned char i;
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
s.httpheaderline[s.httpheaderlineptr] = *uip_appdata;
++uip_appdata;
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
++((char *)uip_appdata);
--len;
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
/* We have an entire HTTP header line in s.httpheaderline, so
@@ -323,7 +309,7 @@ parse_headers(u16_t len)
}
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
/* Check for specific HTTP header fields. */
/* Check for specific HTTP header fields. */
if(casecmp(s.httpheaderline, http_content_type,
sizeof(http_content_type) - 1) == 0) {
/* Found Content-type field. */
@@ -339,7 +325,7 @@ parse_headers(u16_t len)
sizeof(http_location) - 1;
if(strncmp(cptr, http_http, 7) == 0) {
cptr += 7;
cptr += 7;
for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
if(*cptr == 0 ||
*cptr == '/' ||
@@ -359,7 +345,7 @@ parse_headers(u16_t len)
/* We're done parsing, so we reset the pointer and start the
next line. */
s.httpheaderlineptr = 0;
s.httpheaderlineptr = 0;
} else {
++s.httpheaderlineptr;
}
@@ -388,7 +374,8 @@ newdata(void)
}
}
/*-----------------------------------------------------------------------------------*/
void webclient_appcall(void)
void
webclient_appcall(void)
{
if(uip_connected()) {
s.timer = 0;
@@ -398,19 +385,11 @@ void webclient_appcall(void)
return;
}
if(state == NULL) {
uip_abort();
return;
}
if(s.state == WEBCLIENT_STATE_CLOSE) {
webclient_closed();
uip_abort();
return;
}
}
if(uip_aborted()) {
webclient_aborted();

View File

@@ -7,24 +7,24 @@
* \file
* Header file for the HTTP client.
* \author Adam Dunkels <adam@dunkels.com>
*/
*/
/*
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -36,22 +36,41 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the "contiki" web browser.
* This file is part of the uIP TCP/IP stack.
*
* $Id: webclient.h,v 1.1.2.5 2003/10/06 22:56:45 adam Exp $
* $Id: webclient.h,v 1.2 2006/06/11 21:46:37 adam Exp $
*
*/
#ifndef __WEBCLIENT_H__
#define __WEBCLIENT_H__
#include "http-strings.h"
#include "http-user-agent-string.h"
#include "webclient-strings.h"
#include "uipopt.h"
#define WEBCLIENT_CONF_MAX_URLLEN 100
struct webclient_state;
struct webclient_state {
u8_t timer;
u8_t state;
u8_t httpflag;
u16_t port;
char host[40];
char file[WEBCLIENT_CONF_MAX_URLLEN];
u16_t getrequestptr;
u16_t getrequestleft;
char httpheaderline[200];
u16_t httpheaderlineptr;
char mimetype[32];
};
typedef struct webclient_state uip_tcp_appstate_t;
#define UIP_APPCALL webclient_appcall
/**
* Callback function that is called from the webclient code when HTTP
@@ -201,7 +220,9 @@ char *webclient_hostname(void);
* \return The port number of the current HTTP data stream, in host byte order.
*/
unsigned short webclient_port(void);
#endif /* __WEBCLIENT_H__ */
/** @} */

View File

@@ -0,0 +1 @@
APP_SOURCES += httpd.c http-strings.c httpd-fs.c httpd-cgi.c

View File

@@ -0,0 +1,35 @@
http_http "http://"
http_200 "200 "
http_301 "301 "
http_302 "302 "
http_get "GET "
http_10 "HTTP/1.0"
http_11 "HTTP/1.1"
http_content_type "content-type: "
http_texthtml "text/html"
http_location "location: "
http_host "host: "
http_crnl "\r\n"
http_index_html "/index.html"
http_404_html "/404.html"
http_referer "Referer:"
http_header_200 "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
http_header_404 "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n"
http_content_type_plain "Content-type: text/plain\r\n\r\n"
http_content_type_html "Content-type: text/html\r\n\r\n"
http_content_type_css "Content-type: text/css\r\n\r\n"
http_content_type_text "Content-type: text/text\r\n\r\n"
http_content_type_png "Content-type: image/png\r\n\r\n"
http_content_type_gif "Content-type: image/gif\r\n\r\n"
http_content_type_jpg "Content-type: image/jpeg\r\n\r\n"
http_content_type_binary "Content-type: application/octet-stream\r\n\r\n"
http_html ".html"
http_shtml ".shtml"
http_htm ".htm"
http_css ".css"
http_png ".png"
http_gif ".gif"
http_jpg ".jpg"
http_text ".txt"
http_txt ".txt"

View File

@@ -0,0 +1,102 @@
const char http_http[8] =
/* "http://" */
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
const char http_200[5] =
/* "200 " */
{0x32, 0x30, 0x30, 0x20, };
const char http_301[5] =
/* "301 " */
{0x33, 0x30, 0x31, 0x20, };
const char http_302[5] =
/* "302 " */
{0x33, 0x30, 0x32, 0x20, };
const char http_get[5] =
/* "GET " */
{0x47, 0x45, 0x54, 0x20, };
const char http_10[9] =
/* "HTTP/1.0" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
const char http_11[9] =
/* "HTTP/1.1" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
const char http_content_type[15] =
/* "content-type: " */
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
const char http_texthtml[10] =
/* "text/html" */
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
const char http_location[11] =
/* "location: " */
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
const char http_host[7] =
/* "host: " */
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
const char http_crnl[3] =
/* "\r\n" */
{0xd, 0xa, };
const char http_index_html[12] =
/* "/index.html" */
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_404_html[10] =
/* "/404.html" */
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_referer[9] =
/* "Referer:" */
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
const char http_header_200[84] =
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
const char http_header_404[91] =
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
const char http_content_type_plain[29] =
/* "Content-type: text/plain\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_html[28] =
/* "Content-type: text/html\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_css [27] =
/* "Content-type: text/css\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_text[28] =
/* "Content-type: text/text\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_png [28] =
/* "Content-type: image/png\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_gif [28] =
/* "Content-type: image/gif\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_jpg [29] =
/* "Content-type: image/jpeg\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
const char http_content_type_binary[43] =
/* "Content-type: application/octet-stream\r\n\r\n" */
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
const char http_html[6] =
/* ".html" */
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
const char http_shtml[7] =
/* ".shtml" */
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
const char http_htm[5] =
/* ".htm" */
{0x2e, 0x68, 0x74, 0x6d, };
const char http_css[5] =
/* ".css" */
{0x2e, 0x63, 0x73, 0x73, };
const char http_png[5] =
/* ".png" */
{0x2e, 0x70, 0x6e, 0x67, };
const char http_gif[5] =
/* ".gif" */
{0x2e, 0x67, 0x69, 0x66, };
const char http_jpg[5] =
/* ".jpg" */
{0x2e, 0x6a, 0x70, 0x67, };
const char http_text[5] =
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, };
const char http_txt[5] =
/* ".txt" */
{0x2e, 0x74, 0x78, 0x74, };

View File

@@ -0,0 +1,34 @@
extern const char http_http[8];
extern const char http_200[5];
extern const char http_301[5];
extern const char http_302[5];
extern const char http_get[5];
extern const char http_10[9];
extern const char http_11[9];
extern const char http_content_type[15];
extern const char http_texthtml[10];
extern const char http_location[11];
extern const char http_host[7];
extern const char http_crnl[3];
extern const char http_index_html[12];
extern const char http_404_html[10];
extern const char http_referer[9];
extern const char http_header_200[84];
extern const char http_header_404[91];
extern const char http_content_type_plain[29];
extern const char http_content_type_html[28];
extern const char http_content_type_css [27];
extern const char http_content_type_text[28];
extern const char http_content_type_png [28];
extern const char http_content_type_gif [28];
extern const char http_content_type_jpg [29];
extern const char http_content_type_binary[43];
extern const char http_html[6];
extern const char http_shtml[7];
extern const char http_htm[5];
extern const char http_css[5];
extern const char http_png[5];
extern const char http_gif[5];
extern const char http_jpg[5];
extern const char http_text[5];
extern const char http_txt[5];

203
apps/webserver/httpd-cgi.c Normal file
View File

@@ -0,0 +1,203 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* Web server script interface
* \author
* Adam Dunkels <adam@sics.se>
*
*/
/*
* Copyright (c) 2001-2006, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.c,v 1.2 2006/06/11 21:46:37 adam Exp $
*
*/
#include "uip.h"
#include "psock.h"
#include "httpd.h"
#include "httpd-cgi.h"
#include "httpd-fs.h"
#include <stdio.h>
#include <string.h>
HTTPD_CGI_CALL(file, "file-stats", file_stats);
HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
HTTPD_CGI_CALL(net, "net-stats", net_stats);
static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL };
/*---------------------------------------------------------------------------*/
static
PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
httpd_cgifunction
httpd_cgi(char *name)
{
const struct httpd_cgi_call **f;
/* Find the matching name in the table, return the function. */
for(f = calls; *f != NULL; ++f) {
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
return (*f)->function;
}
}
return nullfunction;
}
/*---------------------------------------------------------------------------*/
static unsigned short
generate_file_stats(void *arg)
{
char *f = (char *)arg;
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f));
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static const char closed[] = /* "CLOSED",*/
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
static const char syn_rcvd[] = /* "SYN-RCVD",*/
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
0x44, 0};
static const char syn_sent[] = /* "SYN-SENT",*/
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
0x54, 0};
static const char established[] = /* "ESTABLISHED",*/
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
0x45, 0x44, 0};
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x31, 0};
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
0x54, 0x2d, 0x32, 0};
static const char closing[] = /* "CLOSING",*/
{0x43, 0x4c, 0x4f, 0x53, 0x49,
0x4e, 0x47, 0};
static const char time_wait[] = /* "TIME-WAIT,"*/
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
0x49, 0x54, 0};
static const char last_ack[] = /* "LAST-ACK"*/
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
0x4b, 0};
static const char *states[] = {
closed,
syn_rcvd,
syn_sent,
established,
fin_wait_1,
fin_wait_2,
closing,
time_wait,
last_ack};
static unsigned short
generate_tcp_stats(void *arg)
{
struct uip_conn *conn;
struct httpd_state *s = (struct httpd_state *)arg;
conn = &uip_conns[s->count];
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->lport),
htons(conn->ripaddr[0]) >> 8,
htons(conn->ripaddr[0]) & 0xff,
htons(conn->ripaddr[1]) >> 8,
htons(conn->ripaddr[1]) & 0xff,
htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,
(uip_outstanding(conn))? '*':' ',
(uip_stopped(conn))? '!':' ');
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
}
}
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static unsigned short
generate_net_stats(void *arg)
{
struct httpd_state *s = (struct httpd_state *)arg;
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
"%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
}
static
PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
{
PSOCK_BEGIN(&s->sout);
#if UIP_STATISTICS
for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
++s->count) {
PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
}
#endif /* UIP_STATISTICS */
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@@ -0,0 +1,84 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* Web server script interface header file
* \author
* Adam Dunkels <adam@sics.se>
*
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.h,v 1.2 2006/06/11 21:46:38 adam Exp $
*
*/
#ifndef __HTTPD_CGI_H__
#define __HTTPD_CGI_H__
#include "psock.h"
#include "httpd.h"
typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
httpd_cgifunction httpd_cgi(char *name);
struct httpd_cgi_call {
const char *name;
const httpd_cgifunction function;
};
/**
* \brief HTTPD CGI function declaration
* \param name The C variable name of the function
* \param str The string name of the function, used in the script file
* \param function A pointer to the function that implements it
*
* This macro is used for declaring a HTTPD CGI
* function. This function is then added to the list of
* HTTPD CGI functions with the httpd_cgi_add() function.
*
* \hideinitializer
*/
#define HTTPD_CGI_CALL(name, str, function) \
static PT_THREAD(function(struct httpd_state *, char *)); \
static const struct httpd_cgi_call name = {str, function}
void httpd_cgi_init(void);
#endif /* __HTTPD_CGI_H__ */
/** @} */

View File

@@ -1,75 +1,62 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* HTTP server read-only file system code.
* \author Adam Dunkels <adam@dunkels.com>
*
* A simple read-only filesystem.
*/
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: fs.c,v 1.7.2.3 2003/10/07 13:22:27 adam Exp $
* $Id: httpd-fs.c,v 1.1 2006/06/07 09:13:08 adam Exp $
*/
#include "uip.h"
#include "httpd.h"
#include "fs.h"
#include "fsdata.h"
#include "httpd-fs.h"
#include "httpd-fsdata.h"
#define NULL (void *)0
#include "fsdata.c"
#ifndef NULL
#define NULL 0
#endif /* NULL */
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
static u16_t count[FS_NUMFILES];
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#include "httpd-fsdata.c"
#if HTTPD_FS_STATISTICS
static u16_t count[HTTPD_FS_NUMFILES];
#endif /* HTTPD_FS_STATISTICS */
/*-----------------------------------------------------------------------------------*/
static u8_t
fs_strcmp(const char *str1, const char *str2)
httpd_fs_strcmp(const char *str1, const char *str2)
{
u8_t i;
i = 0;
loop:
if(str2[i] == 0 ||
str1[i] == '\r' ||
str1[i] == '\r' ||
str1[i] == '\n') {
return 0;
}
@@ -84,72 +71,62 @@ fs_strcmp(const char *str1, const char *str2)
}
/*-----------------------------------------------------------------------------------*/
int
fs_open(const char *name, struct fs_file *file)
httpd_fs_open(const char *name, struct httpd_fs_file *file)
{
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#if HTTPD_FS_STATISTICS
u16_t i = 0;
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
struct fsdata_file_noconst *f;
#endif /* HTTPD_FS_STATISTICS */
struct httpd_fsdata_file_noconst *f;
for(f = (struct fsdata_file_noconst *)FS_ROOT;
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct fsdata_file_noconst *)f->next) {
f = (struct httpd_fsdata_file_noconst *)f->next) {
if(fs_strcmp(name, f->name) == 0) {
if(httpd_fs_strcmp(name, f->name) == 0) {
file->data = f->data;
file->len = f->len;
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#if HTTPD_FS_STATISTICS
++count[i];
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
return 1;
}
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#if HTTPD_FS_STATISTICS
++i;
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
}
return 0;
}
/*-----------------------------------------------------------------------------------*/
void
fs_init(void)
httpd_fs_init(void)
{
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#if HTTPD_FS_STATISTICS
u16_t i;
for(i = 0; i < FS_NUMFILES; i++) {
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
count[i] = 0;
}
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
}
/*-----------------------------------------------------------------------------------*/
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
u16_t fs_count
#if HTTPD_FS_STATISTICS
u16_t httpd_fs_count
(char *name)
{
struct fsdata_file_noconst *f;
struct httpd_fsdata_file_noconst *f;
u16_t i;
i = 0;
for(f = (struct fsdata_file_noconst *)FS_ROOT;
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
f != NULL;
f = (struct fsdata_file_noconst *)f->next) {
f = (struct httpd_fsdata_file_noconst *)f->next) {
if(fs_strcmp(name, f->name) == 0) {
if(httpd_fs_strcmp(name, f->name) == 0) {
return count[i];
}
++i;
}
return 0;
}
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
/*-----------------------------------------------------------------------------------*/

View File

@@ -1,80 +1,57 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* HTTP server read-only file system header file.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: fs.h,v 1.6.2.3 2003/10/07 13:22:27 adam Exp $
* $Id: httpd-fs.h,v 1.1 2006/06/07 09:13:08 adam Exp $
*/
#ifndef __FS_H__
#define __FS_H__
#ifndef __HTTPD_FS_H__
#define __HTTPD_FS_H__
#include "uip.h"
#define HTTPD_FS_STATISTICS 1
/**
* An open file in the read-only file system.
*/
struct fs_file {
char *data; /**< The actual file data. */
int len; /**< The length of the file data. */
struct httpd_fs_file {
char *data;
int len;
};
/**
* Open a file in the read-only file system.
*
* \param name The name of the file.
*
* \param file The file pointer, which must be allocated by caller and
* will be filled in by the function.
*/
int fs_open(const char *name, struct fs_file *file);
/* file must be allocated by caller and will be filled in
by the function. */
int httpd_fs_open(const char *name, struct httpd_fs_file *file);
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
u16_t fs_count(char *name);
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#ifdef HTTPD_FS_STATISTICS
#if HTTPD_FS_STATISTICS == 1
u16_t httpd_fs_count(char *name);
#endif /* HTTPD_FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
/**
* Initialize the read-only file system.
*/
void fs_init(void);
void httpd_fs_init(void);
#endif /* __FS_H__ */
#endif /* __HTTPD_FS_H__ */

View File

@@ -0,0 +1,8 @@
<html>
<body bgcolor="white">
<center>
<h1>404 - file not found</h1>
<h3>Go <a href="/">here</a> instead.</h3>
</center>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View File

@@ -0,0 +1,35 @@
%!: /header.html
<h1>File statistics</h1>
<center>
<table width="300">
<tr><td><a href="/index.html">/index.html</a></td>
<td>%! file-stats /index.html
</td><td><img src="/fade.png" height=10 width=%! file-stats /index.html
> </td></tr>
<tr><td><a href="/files.shtml">/files.shtml</a></td>
<td>%! file-stats /files.shtml
</td><td><img src="/fade.png" height=10 width=%! file-stats /files.shtml
> </td></tr>
<tr><td><a href="/tcp.shtml">/tcp.shtml</a></td>
<td>%! file-stats /tcp.shtml
</td><td><img src="/fade.png" height=10 width=%! file-stats /tcp.shtml
> </td></tr>
<tr><td><a href="/stats.shtml">/stats.shtml</a></td>
<td>%! file-stats /stats.shtml
</td><td><img src="/fade.png" height=10 width=%! file-stats /stats.shtml
> </td></tr>
<tr><td><a href="/style.css">/style.css</a></td>
<td>%! file-stats /style.css
</td><td><img src="/fade.png" height=10 width=%! file-stats /style.css
> </td></tr>
<tr><td><a href="/404.html">/404.html</a></td>
<td>%! file-stats /404.html
</td><td><img src="/fade.png" height=10 width=%! file-stats /404.html
> </td></tr>
<tr><td><a href="/fade.png">/fade.png</a></td>
<td>%! file-stats /fade.png
</td><td><img src="/fade.png" height=10 width=%! file-stats /fade.png
> </td></tr>
</table>
</center>
%!: /footer.html

View File

@@ -0,0 +1,2 @@
</body>
</html>

View File

@@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome to the uIP web server!</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#fffeec" text="black">
<div class="menu">
<div class="menubox"><a href="/">Front page</a></div>
<div class="menubox"><a href="files.shtml">File statistics</a></div>
<div class="menubox"><a href="stats.shtml">Network statistics</a></div>
<div class="menubox"><a href="tcp.shtml">Network
connections</a></div>
<br>
</div>
<div class="contentblock">

View File

@@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Welcome to the uIP web server!</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#fffeec" text="black">
<div class="menu">
<div class="menubox"><a href="/">Front page</a></div>
<div class="menubox"><a href="files.shtml">File statistics</a></div>
<div class="menubox"><a href="stats.shtml">Network statistics</a></div>
<div class="menubox"><a href="tcp.shtml">Network
connections</a></div>
<br>
</div>
<div class="contentblock">
<p>
These web pages are served by a small web server running on top of
the <a href="http://www.sics.se/~adam/uip/">uIP embedded TCP/IP
stack</a>.
</p>
<p>
Click on the links above for web server statistics.
</p>
</body>
</html>

View File

@@ -0,0 +1,5 @@
%!: /header.html
<h1>System processes</h1><br><table width="100%">
<tr><th>ID</th><th>Name</th><th>Priority</th><th>Poll handler</th><th>Event handler</th><th>Procstate</th></tr>
%! processes
%!: /footer.html

View File

@@ -1,30 +1,31 @@
<html>
<body bgcolor="white">
%!: /header.html
<h1>Network statistics</h1>
<center>
<table width="600" border="0">
<tr><td>
<pre>
IP Packets dropped
Packets received
<table width="300" border="0">
<tr><td><pre>
IP Packets received
Packets sent
Packets dropped
IP errors IP version/header length
IP length, high byte
IP length, low byte
IP fragments
Header checksum
Wrong protocol
ICMP Packets dropped
Packets received
ICMP Packets received
Packets sent
Packets dropped
Type errors
TCP Packets dropped
Packets received
TCP Packets received
Packets sent
Packets dropped
Checksum errors
Data packets without ACKs
Resets
Retransmissions
No connection avaliable
Connection attempts to closed ports
</pre>
</td><td><pre>
</pre></td><td><pre>%! net-stats
</pre></table>
</center>
%!: /footer.html

View File

@@ -0,0 +1,92 @@
h1
{
text-align: center;
font-size:14pt;
font-family:arial,helvetica;
font-weight:bold;
padding:10px;
}
body
{
background-color: #fffeec;
color:black;
font-size:8pt;
font-family:arial,helvetica;
}
.menu
{
margin: 4px;
width:60%;
padding:2px;
border: solid 1px;
background-color: #fffcd2;
text-align:left;
font-size:9pt;
font-family:arial,helvetica;
}
div.menubox
{
width: 25%;
border: 0;
float: left;
text-align: center;
}
.contentblock
{
margin: 4px;
width:60%;
padding:2px;
border: 1px dotted;
background-color: white;
font-size:8pt;
font-family:arial,helvetica;
}
p.intro
{
margin-left:20px;
margin-right:20px;
font-size:10pt;
/* font-weight:bold; */
font-family:arial,helvetica;
}
p.clink
{
font-size:12pt;
font-family:courier,monospace;
text-align:center;
}
p.clink9
{
font-size:9pt;
font-family:courier,monospace;
text-align:center;
}
p
{
padding-left:10px;
}
p.right
{
text-align:right;
}

View File

@@ -0,0 +1,5 @@
%!: /header.html
<h1>Current connections</h1><br><table width="100%">
<tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
%! tcp-connections
%!: /footer.html

View File

@@ -0,0 +1,607 @@
static const unsigned char data_processes_shtml[] = {
/* /processes.shtml */
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72,
0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68,
0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62,
0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72,
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74,
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65,
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74,
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c,
0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f,
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72,
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f,
0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25,
0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f,
0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
static const unsigned char data_404_html[] = {
/* /404.html */
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c,
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e,
0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d,
0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20,
0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e,
0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33,
0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65,
0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65,
0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65,
0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
0};
static const unsigned char data_files_shtml[] = {
/* /files.shtml */
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74,
0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31,
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x3e,
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69,
0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74,
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d,
0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d,
0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67,
0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31,
0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21,
0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74,
0x73, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68,
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73,
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x66,
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa,
0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c,
0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66,
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22,
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22,
0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30,
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20,
0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73,
0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70,
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e,
0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73,
0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68,
0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68,
0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73,
0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e,
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x61,
0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e,
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74,
0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63,
0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e,
0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d,
0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25,
0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61,
0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e,
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79,
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 0x73,
0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 0x2f,
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x79,
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3c, 0x2f, 0x74,
0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67,
0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69,
0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64,
0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65,
0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74,
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3e, 0x20,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34,
0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f,
0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f,
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20,
0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65,
0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67,
0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x66, 0x61,
0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e,
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72,
0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70,
0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d,
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
0x70, 0x6e, 0x67, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x74,
0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65,
0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20,
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74,
0x6d, 0x6c, 0xa, 0};
static const unsigned char data_footer_html[] = {
/* /footer.html */
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa,
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
static const unsigned char data_header_html[] = {
/* /header.html */
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20,
0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73,
0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0};
static const unsigned char data_index_html[] = {
/* /index.html */
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c,
0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d,
0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70,
0x3e, 0xa, 0x20, 0x20, 0x54, 0x68, 0x65, 0x73, 0x65, 0x20,
0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 0x20,
0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64,
0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c,
0x6c, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66,
0xa, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d,
0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x75, 0x49, 0x50,
0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20,
0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, 0x20, 0x20, 0x73,
0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa,
0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c,
0x70, 0x3e, 0xa, 0x20, 0x20, 0x43, 0x6c, 0x69, 0x63, 0x6b,
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69,
0x6e, 0x6b, 0x73, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x20,
0x66, 0x6f, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65,
0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69,
0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c,
0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62,
0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
0x6c, 0x3e, 0xa, 0};
static const unsigned char data_style_css[] = {
/* /style.css */
0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65,
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20,
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20,
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f,
0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a,
0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76,
0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74,
0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70,
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70,
0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64,
0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63,
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f,
0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65,
0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa,
0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a,
0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79,
0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c,
0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa,
0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0xa, 0x7b, 0xa, 0x20,
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34,
0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3a, 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20,
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70,
0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72,
0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64,
0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61,
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63,
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66,
0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78,
0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65,
0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39,
0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74,
0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72,
0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74,
0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa,
0x64, 0x69, 0x76, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
0x78, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3a, 0x20, 0x32, 0x35, 0x25, 0x3b, 0xa, 0x20, 0x20,
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b,
0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20,
0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x74, 0x65, 0x78, 0x74,
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65,
0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x6d,
0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78,
0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a,
0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61,
0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x3b,
0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74,
0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c,
0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b,
0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20,
0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69,
0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68,
0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20,
0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e,
0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61,
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a,
0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61,
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74,
0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20,
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x2f, 0x2a, 0x20, 0x20,
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68,
0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x20, 0x2a, 0x2f,
0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63,
0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66,
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31,
0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63,
0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e,
0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa,
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e,
0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74,
0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66,
0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72,
0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70,
0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74,
0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a,
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa,
0xa, 0xa, 0x70, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61,
0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74,
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa,
0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa,
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20,
0xa, 0x7d, 0xa, 0xa, 0};
static const unsigned char data_tcp_shtml[] = {
/* /tcp.shtml */
0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63,
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c,
0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa,
0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f,
0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74,
0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f,
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61,
0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68,
0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68,
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72,
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46,
0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63,
0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
0};
static const unsigned char data_fade_png[] = {
/* /fade.png */
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0,
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00,
00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 00, 0x4,
00, 00, 00, 0xa, 0x8, 0x2, 00, 00, 00, 0x1c,
0x99, 0x68, 0x59, 00, 00, 00, 0x9, 0x70, 0x48, 0x59,
0x73, 00, 00, 0xb, 0x13, 00, 00, 0xb, 0x13, 0x1,
00, 0x9a, 0x9c, 0x18, 00, 00, 00, 0x7, 0x74, 0x49,
0x4d, 0x45, 0x7, 0xd6, 0x6, 0x8, 0x14, 0x1b, 0x39, 0xaf,
0x5b, 0xc0, 0xe3, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50,
0xef, 0x64, 0x25, 0x6e, 00, 00, 00, 0x3a, 0x49, 0x44,
0x41, 0x54, 0x8, 0xd7, 0x75, 0x8c, 0x31, 0x12, 00, 0x10,
0x10, 0xc4, 0x2e, 0x37, 0x9e, 0x40, 0x65, 0xfd, 0xff, 0x83,
0xf4, 0xa, 0x1c, 0x8d, 0x54, 0x9b, 0xc9, 0xcc, 0x9a, 0x3d,
0x90, 0x73, 0x71, 0x67, 0x91, 0xd4, 0x74, 0x36, 0xa9, 0x55,
0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74,
0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf,
0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0};
static const unsigned char data_stats_shtml[] = {
/* /stats.shtml */
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x73,
0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c,
0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74,
0x65, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65,
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30,
0x30, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d,
0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c,
0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49,
0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
0x73, 0x65, 0x6e, 0x74, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x49, 0x50, 0x20,
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, 0x20, 0x20, 0x20,
0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x6c, 0x65,
0x6e, 0x67, 0x74, 0x68, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50,
0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x68,
0x69, 0x67, 0x68, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74,
0x68, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x79, 0x74,
0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x66, 0x72,
0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0xa, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68,
0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0xa, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x57, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9,
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x73, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65,
0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44,
0x61, 0x74, 0x61, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20,
0x41, 0x43, 0x4b, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
0x73, 0x65, 0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69,
0x6f, 0x6e, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61,
0x62, 0x6c, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x20,
0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x20,
0x70, 0x6f, 0x72, 0x74, 0x73, 0xa, 0x3c, 0x2f, 0x70, 0x72,
0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e,
0x65, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa, 0x3c,
0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62,
0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74,
0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
0xa, 0};
const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
const struct httpd_fsdata_file file_404_html[] = {{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
const struct httpd_fsdata_file file_files_shtml[] = {{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
const struct httpd_fsdata_file file_footer_html[] = {{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
const struct httpd_fsdata_file file_header_html[] = {{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
const struct httpd_fsdata_file file_style_css[] = {{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
const struct httpd_fsdata_file file_tcp_shtml[] = {{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
const struct httpd_fsdata_file file_fade_png[] = {{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}};
const struct httpd_fsdata_file file_stats_shtml[] = {{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}};
#define HTTPD_FS_ROOT file_stats_shtml
#define HTTPD_FS_NUMFILES 10

View File

@@ -1,64 +1,64 @@
/*
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: fsdata.h,v 1.4.2.1 2003/10/04 22:54:06 adam Exp $
* $Id: httpd-fsdata.h,v 1.1 2006/06/07 09:13:08 adam Exp $
*/
#ifndef __FSDATA_H__
#define __FSDATA_H__
#ifndef __HTTPD_FSDATA_H__
#define __HTTPD_FSDATA_H__
#include "uipopt.h"
#include "uip.h"
struct fsdata_file {
const struct fsdata_file *next;
struct httpd_fsdata_file {
const struct httpd_fsdata_file *next;
const char *name;
const char *data;
const int len;
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#ifdef HTTPD_FS_STATISTICS
#if HTTPD_FS_STATISTICS == 1
u16_t count;
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
};
struct fsdata_file_noconst {
struct fsdata_file *next;
struct httpd_fsdata_file_noconst {
struct httpd_fsdata_file *next;
char *name;
char *data;
int len;
#ifdef FS_STATISTICS
#if FS_STATISTICS == 1
#ifdef HTTPD_FS_STATISTICS
#if HTTPD_FS_STATISTICS == 1
u16_t count;
#endif /* FS_STATISTICS */
#endif /* FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
#endif /* HTTPD_FS_STATISTICS */
};
#endif /* __FSDATA_H__ */
#endif /* __HTTPD_FSDATA_H__ */

338
apps/webserver/httpd.c Normal file
View File

@@ -0,0 +1,338 @@
/**
* \addtogroup apps
* @{
*/
/**
* \defgroup httpd Web server
* @{
* The uIP web server is a very simplistic implementation of an HTTP
* server. It can serve web pages and files from a read-only ROM
* filesystem, and provides a very small scripting language.
*/
/**
* \file
* Web server
* \author
* Adam Dunkels <adam@sics.se>
*/
/*
* Copyright (c) 2004, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd.c,v 1.2 2006/06/11 21:46:38 adam Exp $
*/
#include "uip.h"
#include "httpd.h"
#include "httpd-fs.h"
#include "httpd-cgi.h"
#include "http-strings.h"
#include <string.h>
#define STATE_WAITING 0
#define STATE_OUTPUT 1
#define ISO_nl 0x0a
#define ISO_space 0x20
#define ISO_bang 0x21
#define ISO_percent 0x25
#define ISO_period 0x2e
#define ISO_slash 0x2f
#define ISO_colon 0x3a
/*---------------------------------------------------------------------------*/
static unsigned short
generate_part_of_file(void *state)
{
struct httpd_state *s = (struct httpd_state *)state;
if(s->file.len > uip_mss()) {
s->len = uip_mss();
} else {
s->len = s->file.len;
}
memcpy(uip_appdata, s->file.data, s->len);
return s->len;
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
do {
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
s->file.len -= s->len;
s->file.data += s->len;
} while(s->file.len > 0);
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_part_of_file(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sout);
PSOCK_SEND(&s->sout, s->file.data, s->len);
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static void
next_scriptstate(struct httpd_state *s)
{
char *p;
p = strchr(s->scriptptr, ISO_nl) + 1;
s->scriptlen -= (unsigned short)(p - s->scriptptr);
s->scriptptr = p;
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_script(struct httpd_state *s))
{
char *ptr;
PT_BEGIN(&s->scriptpt);
while(s->file.len > 0) {
/* Check if we should start executing a script. */
if(*s->file.data == ISO_percent &&
*(s->file.data + 1) == ISO_bang) {
s->scriptptr = s->file.data + 3;
s->scriptlen = s->file.len - 3;
if(*(s->scriptptr - 1) == ISO_colon) {
httpd_fs_open(s->scriptptr + 1, &s->file);
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
} else {
PT_WAIT_THREAD(&s->scriptpt,
httpd_cgi(s->scriptptr)(s, s->scriptptr));
}
next_scriptstate(s);
/* The script is over, so we reset the pointers and continue
sending the rest of the file. */
s->file.data = s->scriptptr;
s->file.len = s->scriptlen;
} else {
/* See if we find the start of script marker in the block of HTML
to be sent. */
if(s->file.len > uip_mss()) {
s->len = uip_mss();
} else {
s->len = s->file.len;
}
if(*s->file.data == ISO_percent) {
ptr = strchr(s->file.data + 1, ISO_percent);
} else {
ptr = strchr(s->file.data, ISO_percent);
}
if(ptr != NULL &&
ptr != s->file.data) {
s->len = (int)(ptr - s->file.data);
if(s->len >= uip_mss()) {
s->len = uip_mss();
}
}
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
s->file.data += s->len;
s->file.len -= s->len;
}
}
PT_END(&s->scriptpt);
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
{
char *ptr;
PSOCK_BEGIN(&s->sout);
PSOCK_SEND_STR(&s->sout, statushdr);
ptr = strrchr(s->filename, ISO_period);
if(ptr == NULL) {
PSOCK_SEND_STR(&s->sout, http_content_type_binary);
} else if(strncmp(http_html, ptr, 5) == 0 ||
strncmp(http_shtml, ptr, 6) == 0) {
PSOCK_SEND_STR(&s->sout, http_content_type_html);
} else if(strncmp(http_css, ptr, 4) == 0) {
PSOCK_SEND_STR(&s->sout, http_content_type_css);
} else if(strncmp(http_png, ptr, 4) == 0) {
PSOCK_SEND_STR(&s->sout, http_content_type_png);
} else if(strncmp(http_gif, ptr, 4) == 0) {
PSOCK_SEND_STR(&s->sout, http_content_type_gif);
} else if(strncmp(http_jpg, ptr, 4) == 0) {
PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
} else {
PSOCK_SEND_STR(&s->sout, http_content_type_plain);
}
PSOCK_END(&s->sout);
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_output(struct httpd_state *s))
{
char *ptr;
PT_BEGIN(&s->outputpt);
if(!httpd_fs_open(s->filename, &s->file)) {
httpd_fs_open(http_404_html, &s->file);
strcpy(s->filename, http_404_html);
PT_WAIT_THREAD(&s->outputpt,
send_headers(s,
http_header_404));
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
} else {
PT_WAIT_THREAD(&s->outputpt,
send_headers(s,
http_header_200));
ptr = strchr(s->filename, ISO_period);
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
PT_INIT(&s->scriptpt);
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
} else {
PT_WAIT_THREAD(&s->outputpt,
send_file(s));
}
}
PSOCK_CLOSE(&s->sout);
PT_END(&s->outputpt);
}
/*---------------------------------------------------------------------------*/
static
PT_THREAD(handle_input(struct httpd_state *s))
{
PSOCK_BEGIN(&s->sin);
PSOCK_READTO(&s->sin, ISO_space);
if(strncmp(s->inputbuf, http_get, 4) != 0) {
PSOCK_CLOSE_EXIT(&s->sin);
}
PSOCK_READTO(&s->sin, ISO_space);
if(s->inputbuf[0] != ISO_slash) {
PSOCK_CLOSE_EXIT(&s->sin);
}
if(s->inputbuf[1] == ISO_space) {
strncpy(s->filename, http_index_html, sizeof(s->filename));
} else {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
}
/* httpd_log_file(uip_conn->ripaddr, s->filename);*/
s->state = STATE_OUTPUT;
while(1) {
PSOCK_READTO(&s->sin, ISO_nl);
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
/* httpd_log(&s->inputbuf[9]);*/
}
}
PSOCK_END(&s->sin);
}
/*---------------------------------------------------------------------------*/
static void
handle_connection(struct httpd_state *s)
{
handle_input(s);
if(s->state == STATE_OUTPUT) {
handle_output(s);
}
}
/*---------------------------------------------------------------------------*/
void
httpd_appcall(void)
{
struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
if(uip_closed() || uip_aborted() || uip_timedout()) {
} else if(uip_connected()) {
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
PT_INIT(&s->outputpt);
s->state = STATE_WAITING;
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
s->timer = 0;
handle_connection(s);
} else if(s != NULL) {
if(uip_poll()) {
++s->timer;
if(s->timer >= 20) {
uip_abort();
}
} else {
s->timer = 0;
}
handle_connection(s);
} else {
uip_abort();
}
}
/*---------------------------------------------------------------------------*/
/**
* \brief Initialize the web server
*
* This function initializes the web server and should be
* called at system boot-up.
*/
void
httpd_init(void)
{
uip_listen(HTONS(80));
}
/*---------------------------------------------------------------------------*/
/** @} */

View File

@@ -1,29 +1,18 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* HTTP script language header file.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
* Copyright (c) 2001-2005, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -35,23 +24,39 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: cgi.h,v 1.3.2.4 2003/10/07 13:22:27 adam Exp $
* $Id: httpd.h,v 1.2 2006/06/11 21:46:38 adam Exp $
*
*/
#ifndef __CGI_H__
#define __CGI_H__
#ifndef __HTTPD_H__
#define __HTTPD_H__
typedef u8_t (* cgifunction)(u8_t next);
#include "psock.h"
#include "httpd-fs.h"
/**
* A table containing pointers to C functions that can be called from
* a web server script.
*/
extern cgifunction cgitab[];
struct httpd_state {
unsigned char timer;
struct psock sin, sout;
struct pt outputpt, scriptpt;
char inputbuf[50];
char filename[20];
char state;
struct httpd_fs_file file;
int len;
char *scriptptr;
int scriptlen;
unsigned short count;
};
#endif /* __CGI_H__ */
void httpd_init(void);
void httpd_appcall(void);
void httpd_log(char *msg);
void httpd_log_file(u16_t *requester, char *file);
#endif /* __HTTPD_H__ */

78
apps/webserver/makefsdata Executable file
View File

@@ -0,0 +1,78 @@
#!/usr/bin/perl
open(OUTPUT, "> httpd-fsdata.c");
chdir("httpd-fs");
opendir(DIR, ".");
@files = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
closedir(DIR);
foreach $file (@files) {
if(-d $file && $file !~ /^\./) {
print "Processing directory $file\n";
opendir(DIR, $file);
@newfiles = grep { !/^\./ && !/(CVS|~)/ } readdir(DIR);
closedir(DIR);
printf "Adding files @newfiles\n";
@files = (@files, map { $_ = "$file/$_" } @newfiles);
next;
}
}
foreach $file (@files) {
if(-f $file) {
print "Adding file $file\n";
open(FILE, $file) || die "Could not open file $file\n";
$file =~ s-^-/-;
$fvar = $file;
$fvar =~ s-/-_-g;
$fvar =~ s-\.-_-g;
# for AVR, add PROGMEM here
print(OUTPUT "static const unsigned char data".$fvar."[] = {\n");
print(OUTPUT "\t/* $file */\n\t");
for($j = 0; $j < length($file); $j++) {
printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
}
printf(OUTPUT "0,\n");
$i = 0;
while(read(FILE, $data, 1)) {
if($i == 0) {
print(OUTPUT "\t");
}
printf(OUTPUT "%#02x, ", unpack("C", $data));
$i++;
if($i == 10) {
print(OUTPUT "\n");
$i = 0;
}
}
print(OUTPUT "0};\n\n");
close(FILE);
push(@fvars, $fvar);
push(@pfiles, $file);
}
}
for($i = 0; $i < @fvars; $i++) {
$file = $pfiles[$i];
$fvar = $fvars[$i];
if($i == 0) {
$prevfile = "NULL";
} else {
$prevfile = "file" . $fvars[$i - 1];
}
print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
}
print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
print(OUTPUT "#define HTTPD_FS_NUMFILES $i\n");

40
apps/webserver/makestrings Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/perl
sub stringify {
my $name = shift(@_);
open(OUTPUTC, "> $name.c");
open(OUTPUTH, "> $name.h");
open(FILE, "$name");
while(<FILE>) {
if(/(.+) "(.+)"/) {
$var = $1;
$data = $2;
$datan = $data;
$datan =~ s/\\r/\r/g;
$datan =~ s/\\n/\n/g;
$datan =~ s/\\01/\01/g;
$datan =~ s/\\0/\0/g;
printf(OUTPUTC "const char $var\[%d] = \n", length($datan) + 1);
printf(OUTPUTC "/* \"$data\" */\n");
printf(OUTPUTC "{");
for($j = 0; $j < length($datan); $j++) {
printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
}
printf(OUTPUTC "};\n");
printf(OUTPUTH "extern const char $var\[%d];\n", length($datan) + 1);
}
}
close(OUTPUTC);
close(OUTPUTH);
}
stringify("http-strings");
exit 0;

View File

@@ -1,29 +1,19 @@
/**
* \addtogroup httpd
* @{
*/
/**
* \file
* HTTP server header file.
* \author Adam Dunkels <adam@dunkels.com>
*/
/*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -35,20 +25,19 @@
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This file is part of the uIP TCP/IP stack.
* This file is part of the uIP TCP/IP stack
*
* $Id: httpd.h,v 1.4.2.3 2003/10/06 22:56:44 adam Exp $
* $Id: webserver.h,v 1.2 2006/06/11 21:46:38 adam Exp $
*
*/
#ifndef __WEBSERVER_H__
#define __WEBSERVER_H__
#ifndef __HTTPD_H__
#define __HTTPD_H__
void httpd_init(void);
void httpd_appcall(void);
#include "httpd.h"
typedef struct httpd_state uip_tcp_appstate_t;
/* UIP_APPCALL: the name of the application function. This function
must return void and take no arguments (i.e., C type "void
appfunc(void)"). */
@@ -56,22 +45,5 @@ void httpd_appcall(void);
#define UIP_APPCALL httpd_appcall
#endif
struct httpd_state {
u8_t state;
u16_t count;
char *dataptr;
char *script;
};
/* UIP_APPSTATE_SIZE: The size of the application-specific state
stored in the uip_conn structure. */
#ifndef UIP_APPSTATE_SIZE
#define UIP_APPSTATE_SIZE (sizeof(struct httpd_state))
#endif
#define FS_STATISTICS 1
extern struct httpd_state *hs;
#endif /* __HTTPD_H__ */
#endif /* __WEBSERVER_H__ */

View File

@@ -1,52 +1,75 @@
# Doxyfile 1.3.3
# Doxyfile 1.4.6
#---------------------------------------------------------------------------
# General configuration options
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = "uIP 0.9"
PROJECT_NAME = "uIP 1.0"
PROJECT_NUMBER =
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = ../ \
../../
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
STRIP_FROM_INC_PATH =
SHORT_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = YES
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= NO
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SHOW_USED_FILES = NO
SUBGROUPING = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
@@ -54,56 +77,79 @@ QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = uip-doc.txt \
pt-doc.txt \
examples.txt \
uip-code-style.txt \
../uip/uip.h \
../uip/uip.c \
../uip/uip_arch.h \
../uip/uip_arp.h \
../uip/uip_arp.c \
../uip/slipdev.h \
../uip/slipdev.c \
../unix/uipopt.h \
../apps/webclient/webclient.h \
../apps/webclient/webclient.c \
../unix/uip-conf.h \
../uip/uipopt.h \
../uip/uip-split.h \
../uip/uip-split.c \
../uip/uip-neighbor.h \
../uip/uip-neighbor.c \
../uip/pt.h \
../uip/lc.h \
../uip/lc-switch.h \
../uip/lc-addrlabels.h \
../uip/timer.h \
../uip/timer.c \
../uip/clock.h \
../uip/psock.h \
../uip/psock.c \
../lib/memb.c \
../lib/memb.h \
../apps/resolv/resolv.h \
../apps/resolv/resolv.c \
../apps/dhcpc/dhcpc.h \
../apps/dhcpc/dhcpc.c \
../apps/smtp/smtp.h \
../apps/smtp/smtp.c \
../apps/telnetd/telnetd.h \
../apps/telnetd/telnetd.c \
../apps/telnetd/telnetd-shell.c \
../apps/telnetd/memb.h \
../apps/telnetd/memb.c \
../apps/httpd/httpd.h \
../apps/httpd/httpd.c \
../apps/httpd/cgi.h \
../apps/httpd/cgi.c \
../apps/httpd/fs.h \
../apps/httpd/fs.c \
../apps/resolv/resolv.h \
../apps/resolv/resolv.c
../apps/telnetd/shell.h \
../apps/telnetd/shell.c \
../apps/hello-world/hello-world.h \
../apps/hello-world/hello-world.c \
../apps/webclient/webclient.h \
../apps/webclient/webclient.c \
../apps/webserver/httpd.h \
../apps/webserver/httpd-cgi.h \
../apps/webserver/httpd-cgi.c \
../apps/webserver/httpd.c
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATH = . ../apps/hello-world ../apps/smtp \
../apps/telnetd ../apps/resolv ../apps/webclient \
../apps/webserver ../unix ../apps/dhcpc
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
@@ -141,7 +187,7 @@ MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
LATEX_HEADER = header.tex
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = NO
@@ -169,6 +215,7 @@ GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
@@ -193,7 +240,7 @@ PREDEFINED = UIP_UDP
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
@@ -203,32 +250,30 @@ PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT = NO
CLASS_GRAPH = NO
COLLABORATION_GRAPH = YES
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = NO
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 0
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =

View File

@@ -1,5 +1,7 @@
all: htmldoc pdfdoc
htmldoc:
doxygen Doxyfile
pdfdoc: htmldoc
cd latex; make refman.pdf && mv refman.pdf ../uip-refman.pdf
cd latex; make refman.pdf && mv refman.pdf ../uip-refman.pdf

62
doc/doxygen.sty Normal file
View File

@@ -0,0 +1,62 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{doxygen}
\RequirePackage{calc}
\RequirePackage{array}
\pagestyle{fancyplain}
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\lhead[\fancyplain{}{\bfseries\thepage}]
{\fancyplain{}{\bfseries\rightmark}}
\rhead[\fancyplain{}{\bfseries\leftmark}]
{\fancyplain{}{\bfseries\thepage}}
\rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen\lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Wed Jun 7 11:37:14 2006 for uIP 1.0-rc0 by doxygen}}
\cfoot{}
\newenvironment{CompactList}
{\begin{list}{}{
\setlength{\leftmargin}{0.5cm}
\setlength{\itemsep}{0pt}
\setlength{\parsep}{0pt}
\setlength{\topsep}{0pt}
\renewcommand{\makelabel}{}}}
{\end{list}}
\newenvironment{CompactItemize}
{
\begin{itemize}
\setlength{\itemsep}{-3pt}
\setlength{\parsep}{0pt}
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}
}
{\end{itemize}}
\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}
\newlength{\tmplength}
\newenvironment{TabularC}[1]
{
\setlength{\tmplength}
{\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)}
\par\begin{tabular*}{\linewidth}
{*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|}
}
{\end{tabular*}\par}
\newcommand{\entrylabel}[1]{
{\parbox[b]{\labelwidth-4pt}{\makebox[0pt][l]{\textbf{#1}}\\}}}
\newenvironment{Desc}
{\begin{list}{}
{
\settowidth{\labelwidth}{40pt}
\setlength{\leftmargin}{\labelwidth}
\setlength{\parsep}{0pt}
\setlength{\itemsep}{-4pt}
\renewcommand{\makelabel}{\entrylabel}
}
}
{\end{list}}
\newenvironment{Indent}
{\begin{list}{}{\setlength{\leftmargin}{0.5cm}}
\item[]\ignorespaces}
{\unskip\end{list}}
\setlength{\parindent}{0cm}
\setlength{\parskip}{0.2cm}
\addtocounter{secnumdepth}{1}
\sloppy
\usepackage[T1]{fontenc}

View File

@@ -0,0 +1,86 @@
#include "uip.h"
#include "uip_arp.h"
#include "network-device.h"
#include "httpd.h"
#include "timer.h"
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
/*---------------------------------------------------------------------------*/
int
main(void)
{
int i;
uip_ipaddr_t ipaddr;
struct timer periodic_timer, arp_timer;
timer_set(&periodic_timer, CLOCK_SECOND / 2);
timer_set(&arp_timer, CLOCK_SECOND * 10);
network_device_init();
uip_init();
uip_ipaddr(ipaddr, 192,168,0,2);
uip_sethostaddr(ipaddr);
httpd_init();
while(1) {
uip_len = network_device_read();
if(uip_len > 0) {
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
uip_arp_ipin();
uip_input();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
uip_arp_out();
network_device_send();
}
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
uip_arp_arpin();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
network_device_send();
}
}
} else if(timer_expired(&periodic_timer)) {
timer_reset(&periodic_timer);
for(i = 0; i < UIP_CONNS; i++) {
uip_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
uip_arp_out();
network_device_send();
}
}
#if UIP_UDP
for(i = 0; i < UIP_UDP_CONNS; i++) {
uip_udp_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
uip_arp_out();
network_device_send();
}
}
#endif /* UIP_UDP */
/* Call the ARP timer function every 10 seconds. */
if(timer_expired(&arp_timer)) {
timer_reset(&arp_timer);
uip_arp_timer();
}
}
}
return 0;
}
/*---------------------------------------------------------------------------*/

View File

@@ -0,0 +1,62 @@
#include "uip.h"
#include "uip_arp.h"
#include "network-device.h"
#include "httpd.h"
#include "timer.h"
/*---------------------------------------------------------------------------*/
int
main(void)
{
int i;
uip_ipaddr_t ipaddr;
struct timer periodic_timer;
timer_set(&periodic_timer, CLOCK_SECOND / 2);
network_device_init();
uip_init();
uip_ipaddr(ipaddr, 192,168,0,2);
uip_sethostaddr(ipaddr);
httpd_init();
while(1) {
uip_len = network_device_read();
if(uip_len > 0) {
uip_input();
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
network_device_send();
}
} else if(timer_expired(&periodic_timer)) {
timer_reset(&periodic_timer);
for(i = 0; i < UIP_CONNS; i++) {
uip_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
network_device_send();
}
}
#if UIP_UDP
for(i = 0; i < UIP_UDP_CONNS; i++) {
uip_udp_periodic(i);
/* If the above function invocation resulted in data that
should be sent out on the network, the global variable
uip_len is set to a value > 0. */
if(uip_len > 0) {
network_device_send();
}
}
#endif /* UIP_UDP */
}
}
return 0;
}
/*---------------------------------------------------------------------------*/

34
doc/examples.txt Normal file
View File

@@ -0,0 +1,34 @@
/**
\defgroup apps Applications
@{
The uIP distribution contains a number of example applications that
can be either used directory or studied when learning to develop
applications for uIP.
*/
/** \example hello-world.c */
/** \example hello-world.h */
/** \example smtp.c */
/** \example smtp.h */
/** \example webclient.c */
/** \example webclient.h */
/** \example example-mainloop-with-arp.c */
/** \example example-mainloop-without-arp.c */
/** \example telnetd.c */
/** \example telnetd.h */
/** \example resolv.c */
/** \example resolv.h */
/** \example dhcpc.c */
/** \example dhcpc.h */
/** \example uip-conf.h */
/** @} */

53
doc/header.tex Normal file
View File

@@ -0,0 +1,53 @@
\documentclass[a4paper]{book}
\usepackage{a4wide}
\usepackage{makeidx}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{float}
\usepackage{textcomp}
\usepackage{alltt}
\usepackage{times}
\ifx\pdfoutput\undefined
\usepackage[ps2pdf,
pagebackref=true,
colorlinks=true,
linkcolor=blue
]{hyperref}
\usepackage{pspicture}
\else
\usepackage[pdftex,
pagebackref=true,
colorlinks=true,
linkcolor=blue
]{hyperref}
\fi
\usepackage{doxygen}
\makeindex
\setcounter{tocdepth}{1}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\begin{titlepage}
\vspace*{5cm}
\begin{center}
{\Huge The uIP Embedded TCP/IP Stack}\\
\vspace*{1cm}
{\LARGE The uIP 1.0 Reference Manual}\\
\vspace*{3cm}
{\Large June 2006}\\
\vspace*{2cm}
\includegraphics[width=6cm]{../sicslogo.pdf}\\
\vspace*{1cm}
{\Large Adam Dunkels}\\
{\Large \texttt{adam@sics.se}}\\
\vspace*{1cm}
{\LARGE Swedish Institute of Computer Science}\\
\vspace*{0.5cm}
\end{center}
\end{titlepage}
\clearemptydoublepage
\pagenumbering{roman}
\tableofcontents
\clearemptydoublepage
\pagenumbering{arabic}

View File

@@ -1,33 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: fs_file struct Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>fs_file Struct Reference<br>
<small>
[<a class="el" href="a00098.html">Web server</a>]</small>
</h1><code>#include &lt;fs.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
An open file in the read-only file system.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o0" doxytag="fs_file::data"></a>
char *&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00030.html#o0">data</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The actual file data. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o1" doxytag="fs_file::len"></a>
int&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00030.html#o1">len</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The length of the file data. <br><br></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:41 2003 for uIP 0.9 by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
</body>
</html>

View File

@@ -1,24 +1,120 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: telnetd_state struct Reference</title>
<title>uIP 1.0: hello-world.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>telnetd_state Struct Reference<br>
<small>
[<a class="el" href="a00097.html">Telnet server</a>]</small>
</h1><code>#include &lt;telnetd.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A telnet connection structure.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:41 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>hello-world.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup helloworld</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \file</span>
<a name="l00008"></a>00008 <span class="comment"> * An example of how to write uIP applications</span>
<a name="l00009"></a>00009 <span class="comment"> * with protosockets.</span>
<a name="l00010"></a>00010 <span class="comment"> * \author</span>
<a name="l00011"></a>00011 <span class="comment"> * Adam Dunkels &lt;adam@sics.se&gt;</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="comment">/*</span>
<a name="l00015"></a>00015 <span class="comment"> * This is a short example of how to write uIP applications using</span>
<a name="l00016"></a>00016 <span class="comment"> * protosockets.</span>
<a name="l00017"></a>00017 <span class="comment"> */</span>
<a name="l00018"></a>00018
<a name="l00019"></a>00019 <span class="comment">/*</span>
<a name="l00020"></a>00020 <span class="comment"> * We define the application state (struct hello_world_state) in the</span>
<a name="l00021"></a>00021 <span class="comment"> * hello-world.h file, so we need to include it here. We also include</span>
<a name="l00022"></a>00022 <span class="comment"> * uip.h (since this cannot be included in hello-world.h) and</span>
<a name="l00023"></a>00023 <span class="comment"> * &lt;string.h&gt;, since we use the memcpy() function in the code.</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="a00101.html">hello-world.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="comment">/*</span>
<a name="l00030"></a>00030 <span class="comment"> * Declaration of the protosocket function that handles the connection</span>
<a name="l00031"></a>00031 <span class="comment"> * (defined at the end of the code).</span>
<a name="l00032"></a>00032 <span class="comment"> */</span>
<a name="l00033"></a>00033 <span class="keyword">static</span> <span class="keywordtype">int</span> handle_connection(<span class="keyword">struct</span> <a name="_a100"></a><a class="code" href="a00078.html">hello_world_state</a> *s);
<a name="l00034"></a>00034 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00035"></a>00035 <span class="comment">/*</span>
<a name="l00036"></a>00036 <span class="comment"> * The initialization function. We must explicitly call this function</span>
<a name="l00037"></a>00037 <span class="comment"> * from the system initialization code, some time after uip_init() is</span>
<a name="l00038"></a>00038 <span class="comment"> * called.</span>
<a name="l00039"></a>00039 <span class="comment"> */</span>
<a name="l00040"></a>00040 <span class="keywordtype">void</span>
<a name="l00041"></a>00041 <a name="a101"></a><a class="code" href="a00162.html#gb97849f0d3ea858eee790b69591e6427">hello_world_init</a>(<span class="keywordtype">void</span>)
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043 <span class="comment">/* We start to listen for connections on TCP port 1000. */</span>
<a name="l00044"></a>00044 <a name="a102"></a><a class="code" href="a00147.html#gdd1ab3704ecd4900eec61a6897d32dc8">uip_listen</a>(<a name="a103"></a><a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(1000));
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00047"></a>00047 <span class="comment">/*</span>
<a name="l00048"></a>00048 <span class="comment"> * In hello-world.h we have defined the UIP_APPCALL macro to</span>
<a name="l00049"></a>00049 <span class="comment"> * hello_world_appcall so that this funcion is uIP's application</span>
<a name="l00050"></a>00050 <span class="comment"> * function. This function is called whenever an uIP event occurs</span>
<a name="l00051"></a>00051 <span class="comment"> * (e.g. when a new connection is established, new data arrives, sent</span>
<a name="l00052"></a>00052 <span class="comment"> * data is acknowledged, data needs to be retransmitted, etc.).</span>
<a name="l00053"></a>00053 <span class="comment"> */</span>
<a name="l00054"></a>00054 <span class="keywordtype">void</span>
<a name="l00055"></a>00055 <a name="a104"></a><a class="code" href="a00162.html#g03070adbf8faab0f34f87c1270964306">hello_world_appcall</a>(<span class="keywordtype">void</span>)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="comment">/*</span>
<a name="l00058"></a>00058 <span class="comment"> * The uip_conn structure has a field called "appstate" that holds</span>
<a name="l00059"></a>00059 <span class="comment"> * the application state of the connection. We make a pointer to</span>
<a name="l00060"></a>00060 <span class="comment"> * this to access it easier.</span>
<a name="l00061"></a>00061 <span class="comment"> */</span>
<a name="l00062"></a>00062 <span class="keyword">struct </span><a class="code" href="a00078.html">hello_world_state</a> *s = &amp;(<a name="a105"></a><a class="code" href="a00150.html#g788ffac72342f6172343d7f8099cbe1a">uip_conn</a>-&gt;<a name="a106"></a><a class="code" href="a00088.html#97f9e1fda815bfb8b1f4577c355ade20">appstate</a>);
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">/*</span>
<a name="l00065"></a>00065 <span class="comment"> * If a new connection was just established, we should initialize</span>
<a name="l00066"></a>00066 <span class="comment"> * the protosocket in our applications' state structure.</span>
<a name="l00067"></a>00067 <span class="comment"> */</span>
<a name="l00068"></a>00068 <span class="keywordflow">if</span>(<a name="a107"></a><a class="code" href="a00147.html#gdb971fb1525d0c5002f52125b05f3218">uip_connected</a>()) {
<a name="l00069"></a>00069 <a name="a108"></a><a class="code" href="a00158.html#g26ae707402e494f3895a9f012a93ea29">PSOCK_INIT</a>(&amp;s-&gt;<a name="a109"></a><a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>, s-&gt;<a name="a110"></a><a class="code" href="a00078.html#4b1b1436b50ed7638aece35f41421196">inputbuffer</a>, <span class="keyword">sizeof</span>(s-&gt;<a class="code" href="a00078.html#4b1b1436b50ed7638aece35f41421196">inputbuffer</a>));
<a name="l00070"></a>00070 }
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">/*</span>
<a name="l00073"></a>00073 <span class="comment"> * Finally, we run the protosocket function that actually handles</span>
<a name="l00074"></a>00074 <span class="comment"> * the communication. We pass it a pointer to the application state</span>
<a name="l00075"></a>00075 <span class="comment"> * of the current connection.</span>
<a name="l00076"></a>00076 <span class="comment"> */</span>
<a name="l00077"></a>00077 handle_connection(s);
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00080"></a>00080 <span class="comment">/*</span>
<a name="l00081"></a>00081 <span class="comment"> * This is the protosocket function that handles the communication. A</span>
<a name="l00082"></a>00082 <span class="comment"> * protosocket function must always return an int, but must never</span>
<a name="l00083"></a>00083 <span class="comment"> * explicitly return - all return statements are hidden in the PSOCK</span>
<a name="l00084"></a>00084 <span class="comment"> * macros.</span>
<a name="l00085"></a>00085 <span class="comment"> */</span>
<a name="l00086"></a>00086 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00087"></a>00087 handle_connection(<span class="keyword">struct</span> <a class="code" href="a00078.html">hello_world_state</a> *s)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089 <a name="a111"></a><a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>);
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <a name="a112"></a><a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>, <span class="stringliteral">"Hello. What is your name?\n"</span>);
<a name="l00092"></a>00092 <a name="a113"></a><a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>, <span class="charliteral">'\n'</span>);
<a name="l00093"></a>00093 strncpy(s-&gt;<a name="a114"></a><a class="code" href="a00078.html#4da86e9feb5e5835eb15163c2cb61116">name</a>, s-&gt;<a class="code" href="a00078.html#4b1b1436b50ed7638aece35f41421196">inputbuffer</a>, <span class="keyword">sizeof</span>(s-&gt;<a class="code" href="a00078.html#4da86e9feb5e5835eb15163c2cb61116">name</a>));
<a name="l00094"></a>00094 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>, <span class="stringliteral">"Hello "</span>);
<a name="l00095"></a>00095 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>, s-&gt;<a class="code" href="a00078.html#4da86e9feb5e5835eb15163c2cb61116">name</a>);
<a name="l00096"></a>00096 <a name="a115"></a><a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>);
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <a name="a116"></a><a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s-&gt;<a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>);
<a name="l00099"></a>00099 }
<a name="l00100"></a>00100 <span class="comment">/*---------------------------------------------------------------------------*/</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

View File

@@ -1,87 +1,72 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: uip_conn struct Reference</title>
<title>uIP 1.0: hello-world.h</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>uip_conn Struct Reference<br>
<small>
[<a class="el" href="a00075.html">The uIP TCP/IP stack</a>]</small>
</h1><code>#include &lt;uip.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Representation of a uIP TCP connection.
<p>
The uip_conn structure is used for identifying a connection. All but one field in the structure are to be considered read-only by an application. The only exception is the appstate field whos purpose is to let the application store application-specific state (e.g., file pointers) for the connection. The size of this field is configured in the "uipopt.h" header file.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o0" doxytag="uip_conn::ripaddr"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o0">ripaddr</a> [2]</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The IP address of the remote host. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o1" doxytag="uip_conn::lport"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o1">lport</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The local TCP port, in network byte order. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o2" doxytag="uip_conn::rport"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o2">rport</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The local remote TCP port, in network byte order. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o3" doxytag="uip_conn::rcv_nxt"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o3">rcv_nxt</a> [4]</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The sequence number that we expect to receive next. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o4" doxytag="uip_conn::snd_nxt"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o4">snd_nxt</a> [4]</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The sequence number that was last sent by us. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o5" doxytag="uip_conn::len"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o5">len</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Length of the data that was previously sent. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o6" doxytag="uip_conn::mss"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o6">mss</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Current maximum segment size for the connection. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o7" doxytag="uip_conn::initialmss"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o7">initialmss</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initial maximum segment size for the connection. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o8" doxytag="uip_conn::sa"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o8">sa</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retransmission time-out calculation state variable. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o9" doxytag="uip_conn::sv"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o9">sv</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retransmission time-out calculation state variable. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o10" doxytag="uip_conn::rto"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o10">rto</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Retransmission time-out. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o11" doxytag="uip_conn::tcpstateflags"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o11">tcpstateflags</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">TCP state and flags. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o12" doxytag="uip_conn::timer"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o12">timer</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The retransmission timer. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o13" doxytag="uip_conn::nrtx"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o13">nrtx</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The number of retransmissions for the last segment sent. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o14" doxytag="uip_conn::appstate"></a>
<a class="el" href="a00086.html#a0">u8_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00037.html#o14">appstate</a> [UIP_APPSTATE_SIZE]</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The application state. <br><br></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:41 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>hello-world.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup apps</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \defgroup helloworld Hello, world</span>
<a name="l00008"></a>00008 <span class="comment"> * @{</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * A small example showing how to write applications with</span>
<a name="l00011"></a>00011 <span class="comment"> * \ref psock "protosockets".</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment">/**</span>
<a name="l00015"></a>00015 <span class="comment"> * \file</span>
<a name="l00016"></a>00016 <span class="comment"> * Header file for an example of how to write uIP applications</span>
<a name="l00017"></a>00017 <span class="comment"> * with protosockets.</span>
<a name="l00018"></a>00018 <span class="comment"> * \author</span>
<a name="l00019"></a>00019 <span class="comment"> * Adam Dunkels &lt;adam@sics.se&gt;</span>
<a name="l00020"></a>00020 <span class="comment"> */</span>
<a name="l00021"></a>00021
<a name="l00022"></a>00022 <span class="preprocessor">#ifndef __HELLO_WORLD_H__</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define __HELLO_WORLD_H__</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="comment">/* Since this file will be included by uip.h, we cannot include uip.h</span>
<a name="l00026"></a>00026 <span class="comment"> here. But we might need to include uipopt.h if we need the u8_t and</span>
<a name="l00027"></a>00027 <span class="comment"> u16_t datatypes. */</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="a00140.html">uipopt.h</a>"</span>
<a name="l00029"></a>00029
<a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="a00127.html">psock.h</a>"</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="comment">/* Next, we define the uip_tcp_appstate_t datatype. This is the state</span>
<a name="l00033"></a>00033 <span class="comment"> of our application, and the memory required for this state is</span>
<a name="l00034"></a>00034 <span class="comment"> allocated together with each TCP connection. One application state</span>
<a name="l00035"></a>00035 <span class="comment"> for each TCP connection. */</span>
<a name="l00036"></a>00036 <span class="keyword">typedef</span> <span class="keyword">struct </span><a name="_a117"></a><a class="code" href="a00078.html">hello_world_state</a> {
<a name="l00037"></a>00037 <span class="keyword">struct </span><a name="_a118"></a><a class="code" href="a00082.html">psock</a> <a name="a119"></a><a class="code" href="a00078.html#a9825b5977b2d4dec66e6bd09e6ae6ea">p</a>;
<a name="l00038"></a>00038 <span class="keywordtype">char</span> <a name="a120"></a><a class="code" href="a00078.html#4b1b1436b50ed7638aece35f41421196">inputbuffer</a>[10];
<a name="l00039"></a>00039 <span class="keywordtype">char</span> <a name="a121"></a><a class="code" href="a00078.html#4da86e9feb5e5835eb15163c2cb61116">name</a>[40];
<a name="l00040"></a>00040 } <a name="_a122"></a><a class="code" href="a00085.html">uip_tcp_appstate_t</a>;
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="comment">/* Finally we define the application function to be called by uIP. */</span>
<a name="l00043"></a>00043 <span class="keywordtype">void</span> <a name="a123"></a><a class="code" href="a00162.html#g03070adbf8faab0f34f87c1270964306">hello_world_appcall</a>(<span class="keywordtype">void</span>);
<a name="l00044"></a>00044 <span class="preprocessor">#ifndef UIP_APPCALL</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#define UIP_APPCALL hello_world_appcall</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* UIP_APPCALL */</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="keywordtype">void</span> <a name="a124"></a><a class="code" href="a00162.html#gb97849f0d3ea858eee790b69591e6427">hello_world_init</a>(<span class="keywordtype">void</span>);
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#endif </span><span class="comment">/* __HELLO_WORLD_H__ */</span>
<a name="l00051"></a>00051 <span class="comment">/** @} */</span><span class="comment"></span>
<a name="l00052"></a>00052 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

View File

@@ -1,24 +1,282 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: uip_eth_addr struct Reference</title>
<title>uIP 1.0: smtp.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>uip_eth_addr Struct Reference<br>
<small>
[<a class="el" href="a00083.html">uIP Address Resolution Protocol</a>]</small>
</h1><code>#include &lt;uip_arp.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Representation of a 48-bit Ethernet address.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:41 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>smtp.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup apps</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \defgroup smtp SMTP E-mail sender</span>
<a name="l00008"></a>00008 <span class="comment"> * @{</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * The Simple Mail Transfer Protocol (SMTP) as defined by RFC821 is</span>
<a name="l00011"></a>00011 <span class="comment"> * the standard way of sending and transfering e-mail on the</span>
<a name="l00012"></a>00012 <span class="comment"> * Internet. This simple example implementation is intended as an</span>
<a name="l00013"></a>00013 <span class="comment"> * example of how to implement protocols in uIP, and is able to send</span>
<a name="l00014"></a>00014 <span class="comment"> * out e-mail but has not been extensively tested.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 <span class="comment"></span>
<a name="l00017"></a>00017 <span class="comment">/**</span>
<a name="l00018"></a>00018 <span class="comment"> * \file</span>
<a name="l00019"></a>00019 <span class="comment"> * SMTP example implementation</span>
<a name="l00020"></a>00020 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="comment">/*</span>
<a name="l00024"></a>00024 <span class="comment"> * Copyright (c) 2004, Adam Dunkels.</span>
<a name="l00025"></a>00025 <span class="comment"> * All rights reserved.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00028"></a>00028 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00029"></a>00029 <span class="comment"> * are met:</span>
<a name="l00030"></a>00030 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00031"></a>00031 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00032"></a>00032 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00033"></a>00033 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00034"></a>00034 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
<a name="l00035"></a>00035 <span class="comment"> * 3. Neither the name of the Institute nor the names of its contributors</span>
<a name="l00036"></a>00036 <span class="comment"> * may be used to endorse or promote products derived from this software</span>
<a name="l00037"></a>00037 <span class="comment"> * without specific prior written permission.</span>
<a name="l00038"></a>00038 <span class="comment"> *</span>
<a name="l00039"></a>00039 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND</span>
<a name="l00040"></a>00040 <span class="comment"> * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
<a name="l00041"></a>00041 <span class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00042"></a>00042 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE</span>
<a name="l00043"></a>00043 <span class="comment"> * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00044"></a>00044 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS</span>
<a name="l00045"></a>00045 <span class="comment"> * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)</span>
<a name="l00046"></a>00046 <span class="comment"> * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT</span>
<a name="l00047"></a>00047 <span class="comment"> * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY</span>
<a name="l00048"></a>00048 <span class="comment"> * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</span>
<a name="l00049"></a>00049 <span class="comment"> * SUCH DAMAGE.</span>
<a name="l00050"></a>00050 <span class="comment"> *</span>
<a name="l00051"></a>00051 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00052"></a>00052 <span class="comment"> *</span>
<a name="l00053"></a>00053 <span class="comment"> * Author: Adam Dunkels &lt;adam@sics.se&gt;</span>
<a name="l00054"></a>00054 <span class="comment"> *</span>
<a name="l00055"></a>00055 <span class="comment"> * $Id: smtp.c,v 1.4 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00056"></a>00056 <span class="comment"> */</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "<a class="code" href="a00105.html">smtp.h</a>"</span>
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="preprocessor">#include "smtp-strings.h"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="a00127.html">psock.h</a>"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="keyword">static</span> <span class="keyword">struct </span><a name="_a163"></a><a class="code" href="a00085.html">smtp_state</a> s;
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keyword">static</span> <span class="keywordtype">char</span> *localhostname;
<a name="l00068"></a>00068 <span class="keyword">static</span> <a name="a164"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> smtpserver;
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="preprocessor">#define ISO_nl 0x0a</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span><span class="preprocessor">#define ISO_cr 0x0d</span>
<a name="l00072"></a>00072 <span class="preprocessor"></span>
<a name="l00073"></a>00073 <span class="preprocessor">#define ISO_period 0x2e</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span>
<a name="l00075"></a>00075 <span class="preprocessor">#define ISO_2 0x32</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span><span class="preprocessor">#define ISO_3 0x33</span>
<a name="l00077"></a>00077 <span class="preprocessor"></span><span class="preprocessor">#define ISO_4 0x34</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span><span class="preprocessor">#define ISO_5 0x35</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span>
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00082"></a>00082 <span class="keyword">static</span>
<a name="l00083"></a>00083 <a name="a165"></a><a class="code" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(smtp_thread(<span class="keywordtype">void</span>))
<a name="l00084"></a>00084 {
<a name="l00085"></a>00085 <a name="a166"></a><a class="code" href="a00158.html#g84901a5aa60040e96d272a69977edd22">PSOCK_BEGIN</a>(&amp;s.psock);
<a name="l00086"></a>00086
<a name="l00087"></a>00087 <a name="a167"></a><a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a name="a168"></a><a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="keywordflow">if</span>(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
<a name="l00090"></a>00090 <a name="a169"></a><a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00091"></a>00091 <a name="a170"></a><a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(2);
<a name="l00092"></a>00092 <a name="a171"></a><a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <a name="a172"></a><a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_helo);
<a name="l00096"></a>00096 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, localhostname);
<a name="l00097"></a>00097 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00098"></a>00098
<a name="l00099"></a>00099 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a name="a173"></a><a class="code" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>) {
<a name="l00102"></a>00102 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00103"></a>00103 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(3);
<a name="l00104"></a>00104 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_mail_from);
<a name="l00108"></a>00108 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.<a name="a174"></a><a class="code" href="a00085.html#668cab7d54ff0a2fc2a2179ca06b0798">from</a>);
<a name="l00109"></a>00109 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00112"></a>00112
<a name="l00113"></a>00113 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a class="code" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>) {
<a name="l00114"></a>00114 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00115"></a>00115 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(4);
<a name="l00116"></a>00116 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_rcpt_to);
<a name="l00120"></a>00120 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.<a name="a175"></a><a class="code" href="a00085.html#3592a1f5ae100db2ed9c0810b41c7bc7">to</a>);
<a name="l00121"></a>00121 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a class="code" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>) {
<a name="l00126"></a>00126 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00127"></a>00127 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(5);
<a name="l00128"></a>00128 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keywordflow">if</span>(s.cc != 0) {
<a name="l00132"></a>00132 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_rcpt_to);
<a name="l00133"></a>00133 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.cc);
<a name="l00134"></a>00134 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00137"></a>00137
<a name="l00138"></a>00138 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a class="code" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>) {
<a name="l00139"></a>00139 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00140"></a>00140 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(6);
<a name="l00141"></a>00141 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143 }
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_data);
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a name="a176"></a><a class="code" href="a00161.html#g9e97c58fe35f750ad192774be9408ac8">ISO_3</a>) {
<a name="l00150"></a>00150 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00151"></a>00151 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(7);
<a name="l00152"></a>00152 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154
<a name="l00155"></a>00155 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_to);
<a name="l00156"></a>00156 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.<a class="code" href="a00085.html#3592a1f5ae100db2ed9c0810b41c7bc7">to</a>);
<a name="l00157"></a>00157 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00158"></a>00158
<a name="l00159"></a>00159 <span class="keywordflow">if</span>(s.cc != 0) {
<a name="l00160"></a>00160 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_cc);
<a name="l00161"></a>00161 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.cc);
<a name="l00162"></a>00162 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00163"></a>00163 }
<a name="l00164"></a>00164
<a name="l00165"></a>00165 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_from);
<a name="l00166"></a>00166 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.<a class="code" href="a00085.html#668cab7d54ff0a2fc2a2179ca06b0798">from</a>);
<a name="l00167"></a>00167 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_subject);
<a name="l00170"></a>00170 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, s.<a name="a177"></a><a class="code" href="a00085.html#503c2994a4e52300516e2b820f0fc65b">subject</a>);
<a name="l00171"></a>00171 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnl);
<a name="l00172"></a>00172
<a name="l00173"></a>00173 <a name="a178"></a><a class="code" href="a00158.html#g70d236d1cf34b4e21836edda60247b70">PSOCK_SEND</a>(&amp;s.psock, s.<a name="a179"></a><a class="code" href="a00085.html#04833004cec509a41c502429df308e35">msg</a>, s.<a name="a180"></a><a class="code" href="a00085.html#a312da7b5f6441140721ec7e55f345a8">msglen</a>);
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_crnlperiodcrnl);
<a name="l00176"></a>00176
<a name="l00177"></a>00177 <a class="code" href="a00158.html#gb5d9c0becf7cb32d0aaef466839dd92e">PSOCK_READTO</a>(&amp;s.psock, <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>);
<a name="l00178"></a>00178 <span class="keywordflow">if</span>(s.inputbuffer[0] != <a class="code" href="a00161.html#g34b924954ba5707d536df28d71a80d39">ISO_2</a>) {
<a name="l00179"></a>00179 <a class="code" href="a00158.html#g5d56800f82bfc7bbf53bb4a659589812">PSOCK_CLOSE</a>(&amp;s.psock);
<a name="l00180"></a>00180 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(8);
<a name="l00181"></a>00181 <a class="code" href="a00158.html#gfa11b2a1faf395ae2a6626e01c482d5d">PSOCK_EXIT</a>(&amp;s.psock);
<a name="l00182"></a>00182 }
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <a class="code" href="a00158.html#gb0ad55aa96dd1d200cd0fc5a99f6a4f7">PSOCK_SEND_STR</a>(&amp;s.psock, (<span class="keywordtype">char</span> *)smtp_quit);
<a name="l00185"></a>00185 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(<a name="a181"></a><a class="code" href="a00161.html#g029256bc17a12e1e86781887e11c0c7d">SMTP_ERR_OK</a>);
<a name="l00186"></a>00186 <a name="a182"></a><a class="code" href="a00158.html#g4a264bb64ae706d53f572b1d9e4037a2">PSOCK_END</a>(&amp;s.psock);
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00189"></a>00189 <span class="keywordtype">void</span>
<a name="l00190"></a>00190 <a name="a183"></a><a class="code" href="a00161.html#gbc331f73107958428bf1c392ba19b6f4">smtp_appcall</a>(<span class="keywordtype">void</span>)
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192 <span class="keywordflow">if</span>(<a name="a184"></a><a class="code" href="a00147.html#gef6c4140c632b6a406779342cf3b6eb6">uip_closed</a>()) {
<a name="l00193"></a>00193 s.connected = 0;
<a name="l00194"></a>00194 <span class="keywordflow">return</span>;
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 <span class="keywordflow">if</span>(<a name="a185"></a><a class="code" href="a00147.html#gfbd5fc486dfdf6bf6fc9db52b1f418c4">uip_aborted</a>() || <a name="a186"></a><a class="code" href="a00147.html#g7b2ac4b18bd2ac3912fe67b3b17158c3">uip_timedout</a>()) {
<a name="l00197"></a>00197 s.connected = 0;
<a name="l00198"></a>00198 <a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(1);
<a name="l00199"></a>00199 <span class="keywordflow">return</span>;
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201 smtp_thread();
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00204"></a>00204 <span class="comment">/**</span>
<a name="l00205"></a>00205 <span class="comment"> * Specificy an SMTP server and hostname.</span>
<a name="l00206"></a>00206 <span class="comment"> *</span>
<a name="l00207"></a>00207 <span class="comment"> * This function is used to configure the SMTP module with an SMTP</span>
<a name="l00208"></a>00208 <span class="comment"> * server and the hostname of the host.</span>
<a name="l00209"></a>00209 <span class="comment"> *</span>
<a name="l00210"></a>00210 <span class="comment"> * \param lhostname The hostname of the uIP host.</span>
<a name="l00211"></a>00211 <span class="comment"> *</span>
<a name="l00212"></a>00212 <span class="comment"> * \param server A pointer to a 4-byte array representing the IP</span>
<a name="l00213"></a>00213 <span class="comment"> * address of the SMTP server to be configured.</span>
<a name="l00214"></a>00214 <span class="comment"> */</span>
<a name="l00215"></a>00215 <span class="keywordtype">void</span>
<a name="l00216"></a>00216 smtp_configure(<span class="keywordtype">char</span> *lhostname, <span class="keywordtype">void</span> *server)
<a name="l00217"></a>00217 {
<a name="l00218"></a>00218 localhostname = lhostname;
<a name="l00219"></a>00219 <a name="a187"></a><a class="code" href="a00148.html#g769512993b7b27271909d6daa4748b60">uip_ipaddr_copy</a>(smtpserver, server);
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00222"></a>00222 <span class="comment">/**</span>
<a name="l00223"></a>00223 <span class="comment"> * Send an e-mail.</span>
<a name="l00224"></a>00224 <span class="comment"> *</span>
<a name="l00225"></a>00225 <span class="comment"> * \param to The e-mail address of the receiver of the e-mail.</span>
<a name="l00226"></a>00226 <span class="comment"> * \param cc The e-mail address of the CC: receivers of the e-mail.</span>
<a name="l00227"></a>00227 <span class="comment"> * \param from The e-mail address of the sender of the e-mail.</span>
<a name="l00228"></a>00228 <span class="comment"> * \param subject The subject of the e-mail.</span>
<a name="l00229"></a>00229 <span class="comment"> * \param msg The actual e-mail message.</span>
<a name="l00230"></a>00230 <span class="comment"> * \param msglen The length of the e-mail message.</span>
<a name="l00231"></a>00231 <span class="comment"> */</span>
<a name="l00232"></a>00232 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
<a name="l00233"></a>00233 smtp_send(<span class="keywordtype">char</span> *<a class="code" href="a00085.html#3592a1f5ae100db2ed9c0810b41c7bc7">to</a>, <span class="keywordtype">char</span> *cc, <span class="keywordtype">char</span> *<a class="code" href="a00085.html#668cab7d54ff0a2fc2a2179ca06b0798">from</a>,
<a name="l00234"></a>00234 <span class="keywordtype">char</span> *<a class="code" href="a00085.html#503c2994a4e52300516e2b820f0fc65b">subject</a>, <span class="keywordtype">char</span> *<a class="code" href="a00085.html#04833004cec509a41c502429df308e35">msg</a>, <a name="a188"></a><a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <a class="code" href="a00085.html#a312da7b5f6441140721ec7e55f345a8">msglen</a>)
<a name="l00235"></a>00235 {
<a name="l00236"></a>00236 <span class="keyword">struct </span><a name="a189"></a><a class="code" href="a00150.html#g788ffac72342f6172343d7f8099cbe1a">uip_conn</a> *conn;
<a name="l00237"></a>00237
<a name="l00238"></a>00238 conn = <a name="a190"></a><a class="code" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect</a>(smtpserver, <a name="a191"></a><a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(25));
<a name="l00239"></a>00239 <span class="keywordflow">if</span>(conn == <a name="a192"></a><a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00240"></a>00240 <span class="keywordflow">return</span> 0;
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 s.connected = 1;
<a name="l00243"></a>00243 s.<a class="code" href="a00085.html#3592a1f5ae100db2ed9c0810b41c7bc7">to</a> = to;
<a name="l00244"></a>00244 s.cc = cc;
<a name="l00245"></a>00245 s.<a class="code" href="a00085.html#668cab7d54ff0a2fc2a2179ca06b0798">from</a> = from;
<a name="l00246"></a>00246 s.<a class="code" href="a00085.html#503c2994a4e52300516e2b820f0fc65b">subject</a> = subject;
<a name="l00247"></a>00247 s.<a class="code" href="a00085.html#04833004cec509a41c502429df308e35">msg</a> = msg;
<a name="l00248"></a>00248 s.<a class="code" href="a00085.html#a312da7b5f6441140721ec7e55f345a8">msglen</a> = msglen;
<a name="l00249"></a>00249
<a name="l00250"></a>00250 <a name="a193"></a><a class="code" href="a00158.html#g26ae707402e494f3895a9f012a93ea29">PSOCK_INIT</a>(&amp;s.psock, s.inputbuffer, <span class="keyword">sizeof</span>(s.inputbuffer));
<a name="l00251"></a>00251
<a name="l00252"></a>00252 <span class="keywordflow">return</span> 1;
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00255"></a>00255 <span class="keywordtype">void</span>
<a name="l00256"></a>00256 <a name="a194"></a><a class="code" href="a00161.html#g64807ba7c221ddf735572d05021539f2">smtp_init</a>(<span class="keywordtype">void</span>)
<a name="l00257"></a>00257 {
<a name="l00258"></a>00258 s.connected = 0;
<a name="l00259"></a>00259 }
<a name="l00260"></a>00260 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00261"></a>00261 <span class="comment">/** @} */</span><span class="comment"></span>
<a name="l00262"></a>00262 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

View File

@@ -1,28 +1,123 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: uip_eth_hdr struct Reference</title>
<title>uIP 1.0: smtp.h</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>uip_eth_hdr Struct Reference<br>
<small>
[<a class="el" href="a00083.html">uIP Address Resolution Protocol</a>]</small>
</h1><code>#include &lt;uip_arp.h&gt;</code>
<p>
Collaboration diagram for uip_eth_hdr:<p><center><img src="a00137.png" border="0" usemap="#a00138" alt="Collaboration graph"></center>
<map name="a00138">
<area href="a00038.html" shape="rect" coords="7,16,100,37" alt="">
</map>
<center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><hr><a name="_details"></a><h2>Detailed Description</h2>
The Ethernet header.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:42 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>smtp.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment"></span>
<a name="l00002"></a>00002 <span class="comment">/**</span>
<a name="l00003"></a>00003 <span class="comment"> * \addtogroup smtp</span>
<a name="l00004"></a>00004 <span class="comment"> * @{</span>
<a name="l00005"></a>00005 <span class="comment"> */</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="comment"></span>
<a name="l00008"></a>00008 <span class="comment">/**</span>
<a name="l00009"></a>00009 <span class="comment"> * \file</span>
<a name="l00010"></a>00010 <span class="comment"> * SMTP header file</span>
<a name="l00011"></a>00011 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00012"></a>00012 <span class="comment"> */</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="comment">/*</span>
<a name="l00015"></a>00015 <span class="comment"> * Copyright (c) 2002, Adam Dunkels.</span>
<a name="l00016"></a>00016 <span class="comment"> * All rights reserved.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00019"></a>00019 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00020"></a>00020 <span class="comment"> * are met:</span>
<a name="l00021"></a>00021 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00022"></a>00022 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00023"></a>00023 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00024"></a>00024 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00025"></a>00025 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
<a name="l00026"></a>00026 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00027"></a>00027 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00028"></a>00028 <span class="comment"> * written permission.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00031"></a>00031 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00032"></a>00032 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00033"></a>00033 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00034"></a>00034 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00035"></a>00035 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00036"></a>00036 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00037"></a>00037 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00038"></a>00038 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00039"></a>00039 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00040"></a>00040 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00041"></a>00041 <span class="comment"> *</span>
<a name="l00042"></a>00042 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00043"></a>00043 <span class="comment"> *</span>
<a name="l00044"></a>00044 <span class="comment"> * $Id: smtp.h,v 1.4 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00045"></a>00045 <span class="comment"> *</span>
<a name="l00046"></a>00046 <span class="comment"> */</span>
<a name="l00047"></a>00047 <span class="preprocessor">#ifndef __SMTP_H__</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define __SMTP_H__</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "<a class="code" href="a00140.html">uipopt.h</a>"</span>
<a name="l00051"></a>00051 <span class="comment"></span>
<a name="l00052"></a>00052 <span class="comment">/**</span>
<a name="l00053"></a>00053 <span class="comment"> * Error number that signifies a non-error condition.</span>
<a name="l00054"></a>00054 <span class="comment"> */</span>
<a name="l00055"></a>00055 <span class="preprocessor">#define SMTP_ERR_OK 0</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00057"></a>00057 <span class="comment">/**</span>
<a name="l00058"></a>00058 <span class="comment"> * Callback function that is called when an e-mail transmission is</span>
<a name="l00059"></a>00059 <span class="comment"> * done.</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> * This function must be implemented by the module that uses the SMTP</span>
<a name="l00062"></a>00062 <span class="comment"> * module.</span>
<a name="l00063"></a>00063 <span class="comment"> *</span>
<a name="l00064"></a>00064 <span class="comment"> * \param error The number of the error if an error occured, or</span>
<a name="l00065"></a>00065 <span class="comment"> * SMTP_ERR_OK.</span>
<a name="l00066"></a>00066 <span class="comment"> */</span>
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a name="a195"></a><a class="code" href="a00161.html#gb1fc692a2700b7a51517724364683f67">smtp_done</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> error);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="keywordtype">void</span> <a name="a196"></a><a class="code" href="a00161.html#g64807ba7c221ddf735572d05021539f2">smtp_init</a>(<span class="keywordtype">void</span>);
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="comment">/* Functions. */</span>
<a name="l00072"></a>00072 <span class="keywordtype">void</span> smtp_configure(<span class="keywordtype">char</span> *localhostname, <a name="a197"></a><a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> *smtpserver);
<a name="l00073"></a>00073 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> smtp_send(<span class="keywordtype">char</span> *to, <span class="keywordtype">char</span> *from,
<a name="l00074"></a>00074 <span class="keywordtype">char</span> *subject, <span class="keywordtype">char</span> *msg,
<a name="l00075"></a>00075 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> msglen);
<a name="l00076"></a>00076 <span class="preprocessor">#define SMTP_SEND(to, cc, from, subject, msg) \</span>
<a name="l00077"></a>00077 <span class="preprocessor"> smtp_send(to, cc, from, subject, msg, strlen(msg))</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>
<a name="l00079"></a>00079 <span class="keywordtype">void</span> <a name="a198"></a><a class="code" href="a00161.html#gbc331f73107958428bf1c392ba19b6f4">smtp_appcall</a>(<span class="keywordtype">void</span>);
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keyword">struct </span><a name="_a199"></a><a class="code" href="a00085.html">smtp_state</a> {
<a name="l00082"></a>00082 <a name="a200"></a><a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> <a name="a201"></a><a class="code" href="a00085.html#0bb4f34164e7207c2db26b77f23ccfff">state</a>;
<a name="l00083"></a>00083 <span class="keywordtype">char</span> *to;
<a name="l00084"></a>00084 <span class="keywordtype">char</span> *from;
<a name="l00085"></a>00085 <span class="keywordtype">char</span> *subject;
<a name="l00086"></a>00086 <span class="keywordtype">char</span> *msg;
<a name="l00087"></a>00087 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> msglen;
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <a name="a202"></a><a class="code" href="a00085.html#68204df6bde3e3c27271ebde10579a57">sentlen</a>, <a name="a203"></a><a class="code" href="a00085.html#0560495c60c68d62617ff1f3d0c424a4">textlen</a>;
<a name="l00090"></a>00090 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <a name="a204"></a><a class="code" href="a00085.html#5ed2615cec9e633d90ac5968771976eb">sendptr</a>;
<a name="l00091"></a>00091
<a name="l00092"></a>00092 };
<a name="l00093"></a>00093
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="preprocessor">#ifndef UIP_APPCALL</span>
<a name="l00096"></a>00096 <span class="preprocessor"></span><span class="preprocessor">#define UIP_APPCALL smtp_appcall</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="a00085.html">smtp_state</a> <a name="a205"></a><a class="code" href="a00153.html#g69646a81a922033c5281445a71f8ffed">uip_tcp_appstate_t</a>;
<a name="l00099"></a>00099
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="preprocessor">#endif </span><span class="comment">/* __SMTP_H__ */</span>
<a name="l00102"></a>00102 <span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

459
doc/html/a00040.html Normal file
View File

@@ -0,0 +1,459 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: webclient.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>webclient.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup apps</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \defgroup webclient Web client</span>
<a name="l00008"></a>00008 <span class="comment"> * @{</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * This example shows a HTTP client that is able to download web pages</span>
<a name="l00011"></a>00011 <span class="comment"> * and files from web servers. It requires a number of callback</span>
<a name="l00012"></a>00012 <span class="comment"> * functions to be implemented by the module that utilizes the code:</span>
<a name="l00013"></a>00013 <span class="comment"> * webclient_datahandler(), webclient_connected(),</span>
<a name="l00014"></a>00014 <span class="comment"> * webclient_timedout(), webclient_aborted(), webclient_closed().</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 <span class="comment"></span>
<a name="l00017"></a>00017 <span class="comment">/**</span>
<a name="l00018"></a>00018 <span class="comment"> * \file</span>
<a name="l00019"></a>00019 <span class="comment"> * Implementation of the HTTP client.</span>
<a name="l00020"></a>00020 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="comment">/*</span>
<a name="l00024"></a>00024 <span class="comment"> * Copyright (c) 2002, Adam Dunkels.</span>
<a name="l00025"></a>00025 <span class="comment"> * All rights reserved.</span>
<a name="l00026"></a>00026 <span class="comment"> *</span>
<a name="l00027"></a>00027 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00028"></a>00028 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00029"></a>00029 <span class="comment"> * are met:</span>
<a name="l00030"></a>00030 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00031"></a>00031 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00032"></a>00032 <span class="comment"> * 2. Redistributions in binary form must reproduce the above</span>
<a name="l00033"></a>00033 <span class="comment"> * copyright notice, this list of conditions and the following</span>
<a name="l00034"></a>00034 <span class="comment"> * disclaimer in the documentation and/or other materials provided</span>
<a name="l00035"></a>00035 <span class="comment"> * with the distribution.</span>
<a name="l00036"></a>00036 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00037"></a>00037 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00038"></a>00038 <span class="comment"> * written permission.</span>
<a name="l00039"></a>00039 <span class="comment"> *</span>
<a name="l00040"></a>00040 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00041"></a>00041 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00042"></a>00042 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00043"></a>00043 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00044"></a>00044 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00045"></a>00045 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00046"></a>00046 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00047"></a>00047 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00048"></a>00048 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00049"></a>00049 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00050"></a>00050 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00051"></a>00051 <span class="comment"> *</span>
<a name="l00052"></a>00052 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00053"></a>00053 <span class="comment"> *</span>
<a name="l00054"></a>00054 <span class="comment"> * $Id: webclient.c,v 1.2 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00055"></a>00055 <span class="comment"> *</span>
<a name="l00056"></a>00056 <span class="comment"> */</span>
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include "uiplib.h"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="a00111.html">webclient.h</a>"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "<a class="code" href="a00103.html">resolv.h</a>"</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="preprocessor">#define WEBCLIENT_TIMEOUT 100</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>
<a name="l00067"></a>00067 <span class="preprocessor">#define WEBCLIENT_STATE_STATUSLINE 0</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_HEADERS 1</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_DATA 2</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#define WEBCLIENT_STATE_CLOSE 3</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span>
<a name="l00072"></a>00072 <span class="preprocessor">#define HTTPFLAG_NONE 0</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_OK 1</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_MOVED 2</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor">#define HTTPFLAG_ERROR 3</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="preprocessor">#define ISO_nl 0x0a</span>
<a name="l00079"></a>00079 <span class="preprocessor"></span><span class="preprocessor">#define ISO_cr 0x0d</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span><span class="preprocessor">#define ISO_space 0x20</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keyword">static</span> <span class="keyword">struct </span><a name="_a251"></a><a class="code" href="a00097.html">webclient_state</a> s;
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00086"></a>00086 <span class="keywordtype">char</span> *
<a name="l00087"></a>00087 <a name="a252"></a><a class="code" href="a00163.html#g4433d3af16ea083a81576d0f18ba57c9">webclient_mimetype</a>(<span class="keywordtype">void</span>)
<a name="l00088"></a>00088 {
<a name="l00089"></a>00089 <span class="keywordflow">return</span> s.<a name="a253"></a><a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>;
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00092"></a>00092 <span class="keywordtype">char</span> *
<a name="l00093"></a>00093 <a name="a254"></a><a class="code" href="a00163.html#g41e616d3fcc17e0aabfe8ab45ef0d30f">webclient_filename</a>(<span class="keywordtype">void</span>)
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 <span class="keywordflow">return</span> s.<a name="a255"></a><a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>;
<a name="l00096"></a>00096 }
<a name="l00097"></a>00097 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00098"></a>00098 <span class="keywordtype">char</span> *
<a name="l00099"></a>00099 <a name="a256"></a><a class="code" href="a00163.html#g0e0ea5f24b77f124ba33bcbc7ede5bfb">webclient_hostname</a>(<span class="keywordtype">void</span>)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <span class="keywordflow">return</span> s.<a name="a257"></a><a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>;
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00104"></a>00104 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>
<a name="l00105"></a>00105 <a name="a258"></a><a class="code" href="a00163.html#g2a939aa4fcffabbce1dc1f784a7e0ad3">webclient_port</a>(<span class="keywordtype">void</span>)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 <span class="keywordflow">return</span> s.<a name="a259"></a><a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>;
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00110"></a>00110 <span class="keywordtype">void</span>
<a name="l00111"></a>00111 <a name="a260"></a><a class="code" href="a00163.html#g3caacabb2fe1c71921e1a471719ccbd2">webclient_init</a>(<span class="keywordtype">void</span>)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00116"></a>00116 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00117"></a>00117 init_connection(<span class="keywordtype">void</span>)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 s.<a name="a261"></a><a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a name="a262"></a><a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 s.<a name="a263"></a><a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> = <span class="keyword">sizeof</span>(http_get) - 1 + 1 +
<a name="l00122"></a>00122 <span class="keyword">sizeof</span>(http_10) - 1 +
<a name="l00123"></a>00123 <span class="keyword">sizeof</span>(http_crnl) - 1 +
<a name="l00124"></a>00124 <span class="keyword">sizeof</span>(http_host) - 1 +
<a name="l00125"></a>00125 <span class="keyword">sizeof</span>(http_crnl) - 1 +
<a name="l00126"></a>00126 strlen(http_user_agent_fields) +
<a name="l00127"></a>00127 strlen(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>) + strlen(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>);
<a name="l00128"></a>00128 s.<a name="a264"></a><a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a> = 0;
<a name="l00129"></a>00129
<a name="l00130"></a>00130 s.<a name="a265"></a><a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00133"></a>00133 <span class="keywordtype">void</span>
<a name="l00134"></a>00134 <a name="a266"></a><a class="code" href="a00163.html#g1d34be506a61db90dd7829117efdf8cf">webclient_close</a>(<span class="keywordtype">void</span>)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a name="a267"></a><a class="code" href="a00163.html#g863c94b0ed4a76997e53a3ccd5d0b6c3">WEBCLIENT_STATE_CLOSE</a>;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00139"></a>00139 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
<a name="l00140"></a>00140 <a name="a268"></a><a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">webclient_get</a>(<span class="keywordtype">char</span> *<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, u16_t <a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>, <span class="keywordtype">char</span> *<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>)
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142 <span class="keyword">struct </span><a name="a269"></a><a class="code" href="a00150.html#g788ffac72342f6172343d7f8099cbe1a">uip_conn</a> *conn;
<a name="l00143"></a>00143 <a name="a270"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> *ipaddr;
<a name="l00144"></a>00144 <span class="keyword">static</span> <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> addr;
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="comment">/* First check if the host is an IP address. */</span>
<a name="l00147"></a>00147 ipaddr = &amp;addr;
<a name="l00148"></a>00148 <span class="keywordflow">if</span>(uiplib_ipaddrconv(host, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *)addr) == 0) {
<a name="l00149"></a>00149 ipaddr = (<a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> *)<a name="a271"></a><a class="code" href="a00160.html#g66d19181ad5fe8b8f7c84d1f1d46a2ec">resolv_lookup</a>(host);
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="keywordflow">if</span>(ipaddr == <a name="a272"></a><a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00152"></a>00152 <span class="keywordflow">return</span> 0;
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155
<a name="l00156"></a>00156 conn = <a name="a273"></a><a class="code" href="a00147.html#g8096b0c4b543dc408f4dd031ddae7240">uip_connect</a>(ipaddr, <a name="a274"></a><a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(port));
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <span class="keywordflow">if</span>(conn == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00159"></a>00159 <span class="keywordflow">return</span> 0;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a>00162 s.<a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a> = port;
<a name="l00163"></a>00163 strncpy(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, file, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00164"></a>00164 strncpy(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, host, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>));
<a name="l00165"></a>00165
<a name="l00166"></a>00166 init_connection();
<a name="l00167"></a>00167 <span class="keywordflow">return</span> 1;
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00170"></a>00170 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *
<a name="l00171"></a>00171 copy_string(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *dest,
<a name="l00172"></a>00172 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *src, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> len)
<a name="l00173"></a>00173 {
<a name="l00174"></a>00174 strncpy(dest, src, len);
<a name="l00175"></a>00175 <span class="keywordflow">return</span> dest + len;
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00178"></a>00178 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00179"></a>00179 senddata(<span class="keywordtype">void</span>)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 u16_t len;
<a name="l00182"></a>00182 <span class="keywordtype">char</span> *getrequest;
<a name="l00183"></a>00183 <span class="keywordtype">char</span> *cptr;
<a name="l00184"></a>00184
<a name="l00185"></a>00185 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; 0) {
<a name="l00186"></a>00186 cptr = getrequest = (<span class="keywordtype">char</span> *)<a name="a275"></a><a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00187"></a>00187
<a name="l00188"></a>00188 cptr = copy_string(cptr, http_get, <span class="keyword">sizeof</span>(http_get) - 1);
<a name="l00189"></a>00189 cptr = copy_string(cptr, s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, strlen(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00190"></a>00190 *cptr++ = <a name="a276"></a><a class="code" href="a00163.html#g71e1b022f7b7fa3a154f19372b239935">ISO_space</a>;
<a name="l00191"></a>00191 cptr = copy_string(cptr, http_10, <span class="keyword">sizeof</span>(http_10) - 1);
<a name="l00192"></a>00192
<a name="l00193"></a>00193 cptr = copy_string(cptr, http_crnl, <span class="keyword">sizeof</span>(http_crnl) - 1);
<a name="l00194"></a>00194
<a name="l00195"></a>00195 cptr = copy_string(cptr, http_host, <span class="keyword">sizeof</span>(http_host) - 1);
<a name="l00196"></a>00196 cptr = copy_string(cptr, s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, strlen(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>));
<a name="l00197"></a>00197 cptr = copy_string(cptr, http_crnl, <span class="keyword">sizeof</span>(http_crnl) - 1);
<a name="l00198"></a>00198
<a name="l00199"></a>00199 cptr = copy_string(cptr, http_user_agent_fields,
<a name="l00200"></a>00200 strlen(http_user_agent_fields));
<a name="l00201"></a>00201
<a name="l00202"></a>00202 len = s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; <a name="a277"></a><a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>()?
<a name="l00203"></a>00203 <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>():
<a name="l00204"></a>00204 s.getrequestleft;
<a name="l00205"></a>00205 <a name="a278"></a><a class="code" href="a00147.html#g04b053a623aac7cd4195157d470661b3">uip_send</a>(&amp;(getrequest[s.<a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a>]), len);
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207 }
<a name="l00208"></a>00208 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00209"></a>00209 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00210"></a>00210 acked(<span class="keywordtype">void</span>)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212 u16_t len;
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; 0) {
<a name="l00215"></a>00215 len = s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> &gt; <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>()?
<a name="l00216"></a>00216 <a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>():
<a name="l00217"></a>00217 s.getrequestleft;
<a name="l00218"></a>00218 s.<a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a> -= len;
<a name="l00219"></a>00219 s.<a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a> += len;
<a name="l00220"></a>00220 }
<a name="l00221"></a>00221 }
<a name="l00222"></a>00222 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00223"></a>00223 <span class="keyword">static</span> u16_t
<a name="l00224"></a>00224 parse_statusline(u16_t len)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 <span class="keywordtype">char</span> *cptr;
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="keywordflow">while</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> &lt; <span class="keyword">sizeof</span>(s.<a name="a279"></a><a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>)) {
<a name="l00229"></a>00229 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] = *(<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00230"></a>00230 ++((<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>);
<a name="l00231"></a>00231 --len;
<a name="l00232"></a>00232 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] == <a name="a280"></a><a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>) {
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <span class="keywordflow">if</span>((strncmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_10,
<a name="l00235"></a>00235 <span class="keyword">sizeof</span>(http_10) - 1) == 0) ||
<a name="l00236"></a>00236 (strncmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_11,
<a name="l00237"></a>00237 <span class="keyword">sizeof</span>(http_11) - 1) == 0)) {
<a name="l00238"></a>00238 cptr = &amp;(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[9]);
<a name="l00239"></a>00239 s.<a name="a281"></a><a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a name="a282"></a><a class="code" href="a00163.html#g40fb1fb2d990ce04ae9bbee275627c03">HTTPFLAG_NONE</a>;
<a name="l00240"></a>00240 <span class="keywordflow">if</span>(strncmp(cptr, http_200, <span class="keyword">sizeof</span>(http_200) - 1) == 0) {
<a name="l00241"></a>00241 <span class="comment">/* 200 OK */</span>
<a name="l00242"></a>00242 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a name="a283"></a><a class="code" href="a00163.html#gda99954e0f6905091885934e86c278cc">HTTPFLAG_OK</a>;
<a name="l00243"></a>00243 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(strncmp(cptr, http_301, <span class="keyword">sizeof</span>(http_301) - 1) == 0 ||
<a name="l00244"></a>00244 strncmp(cptr, http_302, <span class="keyword">sizeof</span>(http_302) - 1) == 0) {
<a name="l00245"></a>00245 <span class="comment">/* 301 Moved permanently or 302 Found. Location: header line</span>
<a name="l00246"></a>00246 <span class="comment"> will contain thw new location. */</span>
<a name="l00247"></a>00247 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> = <a name="a284"></a><a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>;
<a name="l00248"></a>00248 } <span class="keywordflow">else</span> {
<a name="l00249"></a>00249 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 1] = 0;
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 } <span class="keywordflow">else</span> {
<a name="l00252"></a>00252 <a name="a285"></a><a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00253"></a>00253 <a name="a286"></a><a class="code" href="a00163.html#gf11d9915ec12a8cdd9fdcbb5e8fcd5c7">webclient_aborted</a>();
<a name="l00254"></a>00254 <span class="keywordflow">return</span> 0;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="comment">/* We're done parsing the status line, so we reset the pointer</span>
<a name="l00258"></a>00258 <span class="comment"> and start parsing the HTTP headers.*/</span>
<a name="l00259"></a>00259 s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00260"></a>00260 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a name="a287"></a><a class="code" href="a00163.html#gc4357cec23abca29d2bb885803625a6a">WEBCLIENT_STATE_HEADERS</a>;
<a name="l00261"></a>00261 <span class="keywordflow">break</span>;
<a name="l00262"></a>00262 } <span class="keywordflow">else</span> {
<a name="l00263"></a>00263 ++s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>;
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 }
<a name="l00266"></a>00266 <span class="keywordflow">return</span> len;
<a name="l00267"></a>00267 }
<a name="l00268"></a>00268 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00269"></a>00269 <span class="keyword">static</span> <span class="keywordtype">char</span>
<a name="l00270"></a>00270 casecmp(<span class="keywordtype">char</span> *str1, <span class="keyword">const</span> <span class="keywordtype">char</span> *str2, <span class="keywordtype">char</span> len)
<a name="l00271"></a>00271 {
<a name="l00272"></a>00272 <span class="keyword">static</span> <span class="keywordtype">char</span> c;
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keywordflow">while</span>(len &gt; 0) {
<a name="l00275"></a>00275 c = *str1;
<a name="l00276"></a>00276 <span class="comment">/* Force lower-case characters. */</span>
<a name="l00277"></a>00277 <span class="keywordflow">if</span>(c &amp; 0x40) {
<a name="l00278"></a>00278 c |= 0x20;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 <span class="keywordflow">if</span>(*str2 != c) {
<a name="l00281"></a>00281 <span class="keywordflow">return</span> 1;
<a name="l00282"></a>00282 }
<a name="l00283"></a>00283 ++str1;
<a name="l00284"></a>00284 ++str2;
<a name="l00285"></a>00285 --len;
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287 <span class="keywordflow">return</span> 0;
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00290"></a>00290 <span class="keyword">static</span> u16_t
<a name="l00291"></a>00291 parse_headers(u16_t len)
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293 <span class="keywordtype">char</span> *cptr;
<a name="l00294"></a>00294 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> i;
<a name="l00295"></a>00295
<a name="l00296"></a>00296 <span class="keywordflow">while</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> &lt; <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>)) {
<a name="l00297"></a>00297 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] = *(<span class="keywordtype">char</span> *)uip_appdata;
<a name="l00298"></a>00298 ++((<span class="keywordtype">char</span> *)uip_appdata);
<a name="l00299"></a>00299 --len;
<a name="l00300"></a>00300 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>] == <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>) {
<a name="l00301"></a>00301 <span class="comment">/* We have an entire HTTP header line in s.httpheaderline, so</span>
<a name="l00302"></a>00302 <span class="comment"> we parse it. */</span>
<a name="l00303"></a>00303 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[0] == <a name="a288"></a><a class="code" href="a00161.html#g6cda47c85ce1b58b501b44ac9cccc50e">ISO_cr</a>) {
<a name="l00304"></a>00304 <span class="comment">/* This was the last header line (i.e., and empty "\r\n"), so</span>
<a name="l00305"></a>00305 <span class="comment"> we are done with the headers and proceed with the actual</span>
<a name="l00306"></a>00306 <span class="comment"> data. */</span>
<a name="l00307"></a>00307 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a name="a289"></a><a class="code" href="a00163.html#g4d457c50e6f2cef57167c3804ce8bf7c">WEBCLIENT_STATE_DATA</a>;
<a name="l00308"></a>00308 <span class="keywordflow">return</span> len;
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310
<a name="l00311"></a>00311 s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 1] = 0;
<a name="l00312"></a>00312 <span class="comment">/* Check for specific HTTP header fields. */</span>
<a name="l00313"></a>00313 <span class="keywordflow">if</span>(casecmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_content_type,
<a name="l00314"></a>00314 <span class="keyword">sizeof</span>(http_content_type) - 1) == 0) {
<a name="l00315"></a>00315 <span class="comment">/* Found Content-type field. */</span>
<a name="l00316"></a>00316 cptr = strchr(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, <span class="charliteral">';'</span>);
<a name="l00317"></a>00317 <span class="keywordflow">if</span>(cptr != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00318"></a>00318 *cptr = 0;
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 strncpy(s.<a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>, s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a> +
<a name="l00321"></a>00321 <span class="keyword">sizeof</span>(http_content_type) - 1, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>));
<a name="l00322"></a>00322 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(casecmp(s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>, http_location,
<a name="l00323"></a>00323 <span class="keyword">sizeof</span>(http_location) - 1) == 0) {
<a name="l00324"></a>00324 cptr = s.<a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a> +
<a name="l00325"></a>00325 <span class="keyword">sizeof</span>(http_location) - 1;
<a name="l00326"></a>00326
<a name="l00327"></a>00327 <span class="keywordflow">if</span>(strncmp(cptr, http_http, 7) == 0) {
<a name="l00328"></a>00328 cptr += 7;
<a name="l00329"></a>00329 <span class="keywordflow">for</span>(i = 0; i &lt; s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> - 7; ++i) {
<a name="l00330"></a>00330 <span class="keywordflow">if</span>(*cptr == 0 ||
<a name="l00331"></a>00331 *cptr == <span class="charliteral">'/'</span> ||
<a name="l00332"></a>00332 *cptr == <span class="charliteral">' '</span> ||
<a name="l00333"></a>00333 *cptr == <span class="charliteral">':'</span>) {
<a name="l00334"></a>00334 s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>[i] = 0;
<a name="l00335"></a>00335 <span class="keywordflow">break</span>;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>[i] = *cptr;
<a name="l00338"></a>00338 ++cptr;
<a name="l00339"></a>00339 }
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341 strncpy(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>, cptr, <span class="keyword">sizeof</span>(s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>));
<a name="l00342"></a>00342 <span class="comment">/* s.file[s.httpheaderlineptr - i] = 0;*/</span>
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344
<a name="l00345"></a>00345
<a name="l00346"></a>00346 <span class="comment">/* We're done parsing, so we reset the pointer and start the</span>
<a name="l00347"></a>00347 <span class="comment"> next line. */</span>
<a name="l00348"></a>00348 s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a> = 0;
<a name="l00349"></a>00349 } <span class="keywordflow">else</span> {
<a name="l00350"></a>00350 ++s.<a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 <span class="keywordflow">return</span> len;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00356"></a>00356 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00357"></a>00357 newdata(<span class="keywordtype">void</span>)
<a name="l00358"></a>00358 {
<a name="l00359"></a>00359 u16_t len;
<a name="l00360"></a>00360
<a name="l00361"></a>00361 len = <a name="a290"></a><a class="code" href="a00147.html#g1a1bc437c09ddef238abab41d77c3177">uip_datalen</a>();
<a name="l00362"></a>00362
<a name="l00363"></a>00363 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>) {
<a name="l00364"></a>00364 len = parse_statusline(len);
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#gc4357cec23abca29d2bb885803625a6a">WEBCLIENT_STATE_HEADERS</a> &amp;&amp; len &gt; 0) {
<a name="l00368"></a>00368 len = parse_headers(len);
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370
<a name="l00371"></a>00371 <span class="keywordflow">if</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g4d457c50e6f2cef57167c3804ce8bf7c">WEBCLIENT_STATE_DATA</a> &amp;&amp;
<a name="l00372"></a>00372 s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> != <a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>) {
<a name="l00373"></a>00373 <a name="a291"></a><a class="code" href="a00163.html#gc4b119801e50cc1824498a1cdf9adc37">webclient_datahandler</a>((<span class="keywordtype">char</span> *)uip_appdata, len);
<a name="l00374"></a>00374 }
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00377"></a>00377 <span class="keywordtype">void</span>
<a name="l00378"></a>00378 <a name="a292"></a><a class="code" href="a00163.html#g9e6d2864f390a4ba1ac60dc65e2b9815">webclient_appcall</a>(<span class="keywordtype">void</span>)
<a name="l00379"></a>00379 {
<a name="l00380"></a>00380 <span class="keywordflow">if</span>(<a name="a293"></a><a class="code" href="a00147.html#gdb971fb1525d0c5002f52125b05f3218">uip_connected</a>()) {
<a name="l00381"></a>00381 s.<a name="a294"></a><a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00382"></a>00382 s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> = <a class="code" href="a00163.html#g8714af98a550f10dc814db92b08d1b0d">WEBCLIENT_STATE_STATUSLINE</a>;
<a name="l00383"></a>00383 senddata();
<a name="l00384"></a>00384 <a name="a295"></a><a class="code" href="a00163.html#g6b942c1ef22f8cd1a726ef3364c9fbea">webclient_connected</a>();
<a name="l00385"></a>00385 <span class="keywordflow">return</span>;
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a> == <a class="code" href="a00163.html#g863c94b0ed4a76997e53a3ccd5d0b6c3">WEBCLIENT_STATE_CLOSE</a>) {
<a name="l00389"></a>00389 <a name="a296"></a><a class="code" href="a00163.html#gf8f12c820cc08da32aa62898bfc02db3">webclient_closed</a>();
<a name="l00390"></a>00390 <a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00391"></a>00391 <span class="keywordflow">return</span>;
<a name="l00392"></a>00392 }
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <span class="keywordflow">if</span>(<a name="a297"></a><a class="code" href="a00147.html#gfbd5fc486dfdf6bf6fc9db52b1f418c4">uip_aborted</a>()) {
<a name="l00395"></a>00395 <a class="code" href="a00163.html#gf11d9915ec12a8cdd9fdcbb5e8fcd5c7">webclient_aborted</a>();
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397 <span class="keywordflow">if</span>(<a name="a298"></a><a class="code" href="a00147.html#g7b2ac4b18bd2ac3912fe67b3b17158c3">uip_timedout</a>()) {
<a name="l00398"></a>00398 <a name="a299"></a><a class="code" href="a00163.html#g23705efb9077187881f094fc9be13bde">webclient_timedout</a>();
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400
<a name="l00401"></a>00401
<a name="l00402"></a>00402 <span class="keywordflow">if</span>(<a name="a300"></a><a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>()) {
<a name="l00403"></a>00403 s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00404"></a>00404 acked();
<a name="l00405"></a>00405 }
<a name="l00406"></a>00406 <span class="keywordflow">if</span>(<a name="a301"></a><a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>()) {
<a name="l00407"></a>00407 s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> = 0;
<a name="l00408"></a>00408 newdata();
<a name="l00409"></a>00409 }
<a name="l00410"></a>00410 <span class="keywordflow">if</span>(<a name="a302"></a><a class="code" href="a00147.html#ga8933ad15a2e2947dae4a5cff50e6007">uip_rexmit</a>() ||
<a name="l00411"></a>00411 <a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>() ||
<a name="l00412"></a>00412 <a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>()) {
<a name="l00413"></a>00413 senddata();
<a name="l00414"></a>00414 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a name="a303"></a><a class="code" href="a00147.html#g58bb90796c1cdad3aac2ecf44d87b20e">uip_poll</a>()) {
<a name="l00415"></a>00415 ++s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a>;
<a name="l00416"></a>00416 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#5960d82e7aca2986b8509a0d87d6cbc8">timer</a> == <a name="a304"></a><a class="code" href="a00163.html#g31be289fd8ec3fe09b0088165d13976d">WEBCLIENT_TIMEOUT</a>) {
<a name="l00417"></a>00417 <a class="code" href="a00163.html#g23705efb9077187881f094fc9be13bde">webclient_timedout</a>();
<a name="l00418"></a>00418 <a class="code" href="a00147.html#g88d2ccf7cd821f89d9a8df7e3948b56c">uip_abort</a>();
<a name="l00419"></a>00419 <span class="keywordflow">return</span>;
<a name="l00420"></a>00420 }
<a name="l00421"></a>00421 <span class="comment">/* senddata();*/</span>
<a name="l00422"></a>00422 }
<a name="l00423"></a>00423
<a name="l00424"></a>00424 <span class="keywordflow">if</span>(<a name="a305"></a><a class="code" href="a00147.html#gef6c4140c632b6a406779342cf3b6eb6">uip_closed</a>()) {
<a name="l00425"></a>00425 <span class="keywordflow">if</span>(s.<a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a> != <a class="code" href="a00163.html#gd895686859ae7d178d31be04eb0a1a97">HTTPFLAG_MOVED</a>) {
<a name="l00426"></a>00426 <span class="comment">/* Send NULL data to signal EOF. */</span>
<a name="l00427"></a>00427 <a class="code" href="a00163.html#gc4b119801e50cc1824498a1cdf9adc37">webclient_datahandler</a>(<a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>, 0);
<a name="l00428"></a>00428 } <span class="keywordflow">else</span> {
<a name="l00429"></a>00429 <span class="keywordflow">if</span>(<a class="code" href="a00160.html#g66d19181ad5fe8b8f7c84d1f1d46a2ec">resolv_lookup</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>) == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00430"></a>00430 <a name="a306"></a><a class="code" href="a00160.html#ge4dcbbe6c641d2e3b8537b479df5fc99">resolv_query</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>);
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 <a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">webclient_get</a>(s.<a class="code" href="a00097.html#a6487b9c1c773b32656065d0e19bf142">host</a>, s.<a class="code" href="a00097.html#7092781c50dcad50f473888585c85b83">port</a>, s.<a class="code" href="a00097.html#e87913860c6b05c6e6b060639b950098">file</a>);
<a name="l00433"></a>00433 }
<a name="l00434"></a>00434 }
<a name="l00435"></a>00435 }
<a name="l00436"></a>00436 <span class="comment">/*-----------------------------------------------------------------------------------*/</span>
<a name="l00437"></a>00437 <span class="comment"></span>
<a name="l00438"></a>00438 <span class="comment">/** @} */</span><span class="comment"></span>
<a name="l00439"></a>00439 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

View File

@@ -1,448 +1,248 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: uip_stats struct Reference</title>
<title>uIP 1.0: webclient.h</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>uip_stats Struct Reference<br>
<small>
[<a class="el" href="a00075.html">The uIP TCP/IP stack</a>]</small>
</h1><code>#include &lt;uip.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The structure holding the TCP/IP statistics that are gathered if UIP_STATISTICS is set to 1.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap><a name="o9" doxytag="uip_stats::ip"></a>
struct {</td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o0">drop</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o1">recv</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o2">sent</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o3">vhlerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o4">hblenerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o5">lblenerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o6">fragerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o7">chkerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o8">protoerr</a></td></tr>
<tr><td class="memItemLeft" nowrap valign=top>}&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00041.html#o9">ip</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">IP statistics. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap><a name="o11" doxytag="uip_stats::icmp"></a>
struct {</td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o0">drop</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o1">recv</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o2">sent</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o10">typeerr</a></td></tr>
<tr><td class="memItemLeft" nowrap valign=top>}&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00041.html#o11">icmp</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">ICMP statistics. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap><a name="o17" doxytag="uip_stats::tcp"></a>
struct {</td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o0">drop</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o1">recv</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o2">sent</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o7">chkerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o12">ackerr</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o13">rst</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o14">rexmit</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o15">syndrop</a></td></tr>
<tr><td class="memItemLeft" nowrap>&nbsp;&nbsp;&nbsp;<a class="el" href="a00086.html#a2">uip_stats_t</a>&nbsp;&nbsp;&nbsp;<a class="el" href="a00041.html#o16">synrst</a></td></tr>
<tr><td class="memItemLeft" nowrap valign=top>}&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00041.html#o17">tcp</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">TCP statistics. <br><br></td></tr>
</table>
<hr><h2>Field Documentation</h2>
<a name="o12" doxytag="uip_stats::ackerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o12">uip_stats::ackerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of TCP segments with a bad ACK number.
<p>
</td>
</tr>
</table>
<a name="o7" doxytag="uip_stats::chkerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o7">uip_stats::chkerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of TCP segments with a bad checksum.
<p>
</td>
</tr>
</table>
<a name="o0" doxytag="uip_stats::drop"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o0">uip_stats::drop</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of dropped TCP segments.
<p>
</td>
</tr>
</table>
<a name="o6" doxytag="uip_stats::fragerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o6">uip_stats::fragerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of packets dropped since they were IP fragments.
<p>
</td>
</tr>
</table>
<a name="o4" doxytag="uip_stats::hblenerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o4">uip_stats::hblenerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of packets dropped due to wrong IP length, high byte.
<p>
</td>
</tr>
</table>
<a name="o5" doxytag="uip_stats::lblenerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o5">uip_stats::lblenerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of packets dropped due to wrong IP length, low byte.
<p>
</td>
</tr>
</table>
<a name="o8" doxytag="uip_stats::protoerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o8">uip_stats::protoerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of packets dropped since they were neither ICMP, UDP nor TCP.
<p>
</td>
</tr>
</table>
<a name="o1" doxytag="uip_stats::recv"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o1">uip_stats::recv</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of recived TCP segments.
<p>
</td>
</tr>
</table>
<a name="o14" doxytag="uip_stats::rexmit"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o14">uip_stats::rexmit</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of retransmitted TCP segments.
<p>
</td>
</tr>
</table>
<a name="o13" doxytag="uip_stats::rst"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o13">uip_stats::rst</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of recevied TCP RST (reset) segments.
<p>
</td>
</tr>
</table>
<a name="o2" doxytag="uip_stats::sent"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o2">uip_stats::sent</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of sent TCP segments.
<p>
</td>
</tr>
</table>
<a name="o15" doxytag="uip_stats::syndrop"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o15">uip_stats::syndrop</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of dropped SYNs due to too few connections was avaliable.
<p>
</td>
</tr>
</table>
<a name="o16" doxytag="uip_stats::synrst"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o16">uip_stats::synrst</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of SYNs for closed ports, triggering a RST.
<p>
</td>
</tr>
</table>
<a name="o10" doxytag="uip_stats::typeerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o10">uip_stats::typeerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of ICMP packets with a wrong type.
<p>
</td>
</tr>
</table>
<a name="o3" doxytag="uip_stats::vhlerr"></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top"> <a class="el" href="a00086.html#a2">uip_stats_t</a> <a class="el" href="a00041.html#o3">uip_stats::vhlerr</a>
</table>
</td>
</tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
<tr>
<td>
&nbsp;
</td>
<td>
<p>
Number of packets dropped due to wrong IP version or header length.
<p>
</td>
</tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:43 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>webclient.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup webclient</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \file</span>
<a name="l00008"></a>00008 <span class="comment"> * Header file for the HTTP client.</span>
<a name="l00009"></a>00009 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00010"></a>00010 <span class="comment"> */</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="comment">/*</span>
<a name="l00013"></a>00013 <span class="comment"> * Copyright (c) 2002, Adam Dunkels.</span>
<a name="l00014"></a>00014 <span class="comment"> * All rights reserved.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00017"></a>00017 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00018"></a>00018 <span class="comment"> * are met:</span>
<a name="l00019"></a>00019 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00020"></a>00020 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00021"></a>00021 <span class="comment"> * 2. Redistributions in binary form must reproduce the above</span>
<a name="l00022"></a>00022 <span class="comment"> * copyright notice, this list of conditions and the following</span>
<a name="l00023"></a>00023 <span class="comment"> * disclaimer in the documentation and/or other materials provided</span>
<a name="l00024"></a>00024 <span class="comment"> * with the distribution.</span>
<a name="l00025"></a>00025 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00026"></a>00026 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00027"></a>00027 <span class="comment"> * written permission.</span>
<a name="l00028"></a>00028 <span class="comment"> *</span>
<a name="l00029"></a>00029 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00030"></a>00030 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00031"></a>00031 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00032"></a>00032 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00033"></a>00033 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00034"></a>00034 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00035"></a>00035 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00036"></a>00036 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00037"></a>00037 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00038"></a>00038 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00039"></a>00039 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00040"></a>00040 <span class="comment"> *</span>
<a name="l00041"></a>00041 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00042"></a>00042 <span class="comment"> *</span>
<a name="l00043"></a>00043 <span class="comment"> * $Id: webclient.h,v 1.2 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00044"></a>00044 <span class="comment"> *</span>
<a name="l00045"></a>00045 <span class="comment"> */</span>
<a name="l00046"></a>00046 <span class="preprocessor">#ifndef __WEBCLIENT_H__</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#define __WEBCLIENT_H__</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "webclient-strings.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "<a class="code" href="a00140.html">uipopt.h</a>"</span>
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="preprocessor">#define WEBCLIENT_CONF_MAX_URLLEN 100</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span>
<a name="l00055"></a>00055 <span class="keyword">struct </span><a name="_a307"></a><a class="code" href="a00097.html">webclient_state</a> {
<a name="l00056"></a>00056 u8_t <a name="_a308"></a><a class="code" href="a00087.html">timer</a>;
<a name="l00057"></a>00057 u8_t <a name="a309"></a><a class="code" href="a00097.html#8ae6395641b7752dce47881e20cee970">state</a>;
<a name="l00058"></a>00058 u8_t <a name="a310"></a><a class="code" href="a00097.html#6925d46b2819adb474a5f0036f02dd7d">httpflag</a>;
<a name="l00059"></a>00059
<a name="l00060"></a>00060 u16_t port;
<a name="l00061"></a>00061 <span class="keywordtype">char</span> host[40];
<a name="l00062"></a>00062 <span class="keywordtype">char</span> file[<a name="a311"></a><a class="code" href="a00163.html#g5a5bfd7e9060903893481db90645187b">WEBCLIENT_CONF_MAX_URLLEN</a>];
<a name="l00063"></a>00063 u16_t <a name="a312"></a><a class="code" href="a00097.html#134ec55c3d5abaebfed4ff8edfedf1ea">getrequestptr</a>;
<a name="l00064"></a>00064 u16_t <a name="a313"></a><a class="code" href="a00097.html#5a3116623c6a7da7c82db6c301ae0da3">getrequestleft</a>;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keywordtype">char</span> <a name="a314"></a><a class="code" href="a00097.html#606d2729bf411ade69044828403a72af">httpheaderline</a>[200];
<a name="l00067"></a>00067 u16_t <a name="a315"></a><a class="code" href="a00097.html#2fca02673894f222b01ad2d3a4d7dd79">httpheaderlineptr</a>;
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="keywordtype">char</span> <a name="a316"></a><a class="code" href="a00097.html#fb60f42593d305ea36d9b4303722696e">mimetype</a>[32];
<a name="l00070"></a>00070 };
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="a00097.html">webclient_state</a> <a name="a317"></a><a class="code" href="a00153.html#g69646a81a922033c5281445a71f8ffed">uip_tcp_appstate_t</a>;
<a name="l00073"></a>00073 <span class="preprocessor">#define UIP_APPCALL webclient_appcall</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">/**</span>
<a name="l00076"></a>00076 <span class="comment"> * Callback function that is called from the webclient code when HTTP</span>
<a name="l00077"></a>00077 <span class="comment"> * data has been received.</span>
<a name="l00078"></a>00078 <span class="comment"> *</span>
<a name="l00079"></a>00079 <span class="comment"> * This function must be implemented by the module that uses the</span>
<a name="l00080"></a>00080 <span class="comment"> * webclient code. The function is called from the webclient module</span>
<a name="l00081"></a>00081 <span class="comment"> * when HTTP data has been received. The function is not called when</span>
<a name="l00082"></a>00082 <span class="comment"> * HTTP headers are received, only for the actual data.</span>
<a name="l00083"></a>00083 <span class="comment"> *</span>
<a name="l00084"></a>00084 <span class="comment"> * \note This function is called many times, repetedly, when data is</span>
<a name="l00085"></a>00085 <span class="comment"> * being received, and not once when all data has been received.</span>
<a name="l00086"></a>00086 <span class="comment"> *</span>
<a name="l00087"></a>00087 <span class="comment"> * \param data A pointer to the data that has been received.</span>
<a name="l00088"></a>00088 <span class="comment"> * \param len The length of the data that has been received.</span>
<a name="l00089"></a>00089 <span class="comment"> */</span>
<a name="l00090"></a>00090 <span class="keywordtype">void</span> <a name="a318"></a><a class="code" href="a00163.html#gc4b119801e50cc1824498a1cdf9adc37">webclient_datahandler</a>(<span class="keywordtype">char</span> *data, u16_t len);
<a name="l00091"></a>00091 <span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">/**</span>
<a name="l00093"></a>00093 <span class="comment"> * Callback function that is called from the webclient code when the</span>
<a name="l00094"></a>00094 <span class="comment"> * HTTP connection has been connected to the web server.</span>
<a name="l00095"></a>00095 <span class="comment"> *</span>
<a name="l00096"></a>00096 <span class="comment"> * This function must be implemented by the module that uses the</span>
<a name="l00097"></a>00097 <span class="comment"> * webclient code.</span>
<a name="l00098"></a>00098 <span class="comment"> */</span>
<a name="l00099"></a>00099 <span class="keywordtype">void</span> <a name="a319"></a><a class="code" href="a00163.html#g6b942c1ef22f8cd1a726ef3364c9fbea">webclient_connected</a>(<span class="keywordtype">void</span>);
<a name="l00100"></a>00100 <span class="comment"></span>
<a name="l00101"></a>00101 <span class="comment">/**</span>
<a name="l00102"></a>00102 <span class="comment"> * Callback function that is called from the webclient code if the</span>
<a name="l00103"></a>00103 <span class="comment"> * HTTP connection to the web server has timed out.</span>
<a name="l00104"></a>00104 <span class="comment"> *</span>
<a name="l00105"></a>00105 <span class="comment"> * This function must be implemented by the module that uses the</span>
<a name="l00106"></a>00106 <span class="comment"> * webclient code.</span>
<a name="l00107"></a>00107 <span class="comment"> */</span>
<a name="l00108"></a>00108 <span class="keywordtype">void</span> <a name="a320"></a><a class="code" href="a00163.html#g23705efb9077187881f094fc9be13bde">webclient_timedout</a>(<span class="keywordtype">void</span>);
<a name="l00109"></a>00109 <span class="comment"></span>
<a name="l00110"></a>00110 <span class="comment">/**</span>
<a name="l00111"></a>00111 <span class="comment"> * Callback function that is called from the webclient code if the</span>
<a name="l00112"></a>00112 <span class="comment"> * HTTP connection to the web server has been aborted by the web</span>
<a name="l00113"></a>00113 <span class="comment"> * server.</span>
<a name="l00114"></a>00114 <span class="comment"> *</span>
<a name="l00115"></a>00115 <span class="comment"> * This function must be implemented by the module that uses the</span>
<a name="l00116"></a>00116 <span class="comment"> * webclient code.</span>
<a name="l00117"></a>00117 <span class="comment"> */</span>
<a name="l00118"></a>00118 <span class="keywordtype">void</span> <a name="a321"></a><a class="code" href="a00163.html#gf11d9915ec12a8cdd9fdcbb5e8fcd5c7">webclient_aborted</a>(<span class="keywordtype">void</span>);
<a name="l00119"></a>00119 <span class="comment"></span>
<a name="l00120"></a>00120 <span class="comment">/**</span>
<a name="l00121"></a>00121 <span class="comment"> * Callback function that is called from the webclient code when the</span>
<a name="l00122"></a>00122 <span class="comment"> * HTTP connection to the web server has been closed.</span>
<a name="l00123"></a>00123 <span class="comment"> *</span>
<a name="l00124"></a>00124 <span class="comment"> * This function must be implemented by the module that uses the</span>
<a name="l00125"></a>00125 <span class="comment"> * webclient code.</span>
<a name="l00126"></a>00126 <span class="comment"> */</span>
<a name="l00127"></a>00127 <span class="keywordtype">void</span> <a name="a322"></a><a class="code" href="a00163.html#gf8f12c820cc08da32aa62898bfc02db3">webclient_closed</a>(<span class="keywordtype">void</span>);
<a name="l00128"></a>00128
<a name="l00129"></a>00129
<a name="l00130"></a>00130 <span class="comment"></span>
<a name="l00131"></a>00131 <span class="comment">/**</span>
<a name="l00132"></a>00132 <span class="comment"> * Initialize the webclient module.</span>
<a name="l00133"></a>00133 <span class="comment"> */</span>
<a name="l00134"></a>00134 <span class="keywordtype">void</span> <a name="a323"></a><a class="code" href="a00163.html#g3caacabb2fe1c71921e1a471719ccbd2">webclient_init</a>(<span class="keywordtype">void</span>);
<a name="l00135"></a>00135 <span class="comment"></span>
<a name="l00136"></a>00136 <span class="comment">/**</span>
<a name="l00137"></a>00137 <span class="comment"> * Open an HTTP connection to a web server and ask for a file using</span>
<a name="l00138"></a>00138 <span class="comment"> * the GET method.</span>
<a name="l00139"></a>00139 <span class="comment"> *</span>
<a name="l00140"></a>00140 <span class="comment"> * This function opens an HTTP connection to the specified web server</span>
<a name="l00141"></a>00141 <span class="comment"> * and requests the specified file using the GET method. When the HTTP</span>
<a name="l00142"></a>00142 <span class="comment"> * connection has been connected, the webclient_connected() callback</span>
<a name="l00143"></a>00143 <span class="comment"> * function is called and when the HTTP data arrives the</span>
<a name="l00144"></a>00144 <span class="comment"> * webclient_datahandler() callback function is called.</span>
<a name="l00145"></a>00145 <span class="comment"> *</span>
<a name="l00146"></a>00146 <span class="comment"> * The callback function webclient_timedout() is called if the web</span>
<a name="l00147"></a>00147 <span class="comment"> * server could not be contacted, and the webclient_aborted() callback</span>
<a name="l00148"></a>00148 <span class="comment"> * function is called if the HTTP connection is aborted by the web</span>
<a name="l00149"></a>00149 <span class="comment"> * server.</span>
<a name="l00150"></a>00150 <span class="comment"> *</span>
<a name="l00151"></a>00151 <span class="comment"> * When the HTTP request has been completed and the HTTP connection is</span>
<a name="l00152"></a>00152 <span class="comment"> * closed, the webclient_closed() callback function will be called.</span>
<a name="l00153"></a>00153 <span class="comment"> *</span>
<a name="l00154"></a>00154 <span class="comment"> * \note If the function is passed a host name, it must already be in</span>
<a name="l00155"></a>00155 <span class="comment"> * the resolver cache in order for the function to connect to the web</span>
<a name="l00156"></a>00156 <span class="comment"> * server. It is therefore up to the calling module to implement the</span>
<a name="l00157"></a>00157 <span class="comment"> * resolver calls and the signal handler used for reporting a resolv</span>
<a name="l00158"></a>00158 <span class="comment"> * query answer.</span>
<a name="l00159"></a>00159 <span class="comment"> *</span>
<a name="l00160"></a>00160 <span class="comment"> * \param host A pointer to a string containing either a host name or</span>
<a name="l00161"></a>00161 <span class="comment"> * a numerical IP address in dotted decimal notation (e.g., 192.168.23.1).</span>
<a name="l00162"></a>00162 <span class="comment"> *</span>
<a name="l00163"></a>00163 <span class="comment"> * \param port The port number to which to connect, in host byte order.</span>
<a name="l00164"></a>00164 <span class="comment"> *</span>
<a name="l00165"></a>00165 <span class="comment"> * \param file A pointer to the name of the file to get.</span>
<a name="l00166"></a>00166 <span class="comment"> *</span>
<a name="l00167"></a>00167 <span class="comment"> * \retval 0 if the host name could not be found in the cache, or</span>
<a name="l00168"></a>00168 <span class="comment"> * if a TCP connection could not be created.</span>
<a name="l00169"></a>00169 <span class="comment"> *</span>
<a name="l00170"></a>00170 <span class="comment"> * \retval 1 if the connection was initiated.</span>
<a name="l00171"></a>00171 <span class="comment"> */</span>
<a name="l00172"></a>00172 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a name="a324"></a><a class="code" href="a00163.html#gf9385ef9ecc74c7d53ff2f15e62bfde3">webclient_get</a>(<span class="keywordtype">char</span> *host, u16_t port, <span class="keywordtype">char</span> *file);
<a name="l00173"></a>00173 <span class="comment"></span>
<a name="l00174"></a>00174 <span class="comment">/**</span>
<a name="l00175"></a>00175 <span class="comment"> * Close the currently open HTTP connection.</span>
<a name="l00176"></a>00176 <span class="comment"> */</span>
<a name="l00177"></a>00177 <span class="keywordtype">void</span> <a name="a325"></a><a class="code" href="a00163.html#g1d34be506a61db90dd7829117efdf8cf">webclient_close</a>(<span class="keywordtype">void</span>);
<a name="l00178"></a>00178 <span class="keywordtype">void</span> <a name="a326"></a><a class="code" href="a00163.html#g9e6d2864f390a4ba1ac60dc65e2b9815">webclient_appcall</a>(<span class="keywordtype">void</span>);
<a name="l00179"></a>00179 <span class="comment"></span>
<a name="l00180"></a>00180 <span class="comment">/**</span>
<a name="l00181"></a>00181 <span class="comment"> * Obtain the MIME type of the current HTTP data stream.</span>
<a name="l00182"></a>00182 <span class="comment"> *</span>
<a name="l00183"></a>00183 <span class="comment"> * \return A pointer to a string contaning the MIME type. The string</span>
<a name="l00184"></a>00184 <span class="comment"> * may be empty if no MIME type was reported by the web server.</span>
<a name="l00185"></a>00185 <span class="comment"> */</span>
<a name="l00186"></a>00186 <span class="keywordtype">char</span> *<a name="a327"></a><a class="code" href="a00163.html#g4433d3af16ea083a81576d0f18ba57c9">webclient_mimetype</a>(<span class="keywordtype">void</span>);
<a name="l00187"></a>00187 <span class="comment"></span>
<a name="l00188"></a>00188 <span class="comment">/**</span>
<a name="l00189"></a>00189 <span class="comment"> * Obtain the filename of the current HTTP data stream.</span>
<a name="l00190"></a>00190 <span class="comment"> *</span>
<a name="l00191"></a>00191 <span class="comment"> * The filename of an HTTP request may be changed by the web server,</span>
<a name="l00192"></a>00192 <span class="comment"> * and may therefore not be the same as when the original GET request</span>
<a name="l00193"></a>00193 <span class="comment"> * was made with webclient_get(). This function is used for obtaining</span>
<a name="l00194"></a>00194 <span class="comment"> * the current filename.</span>
<a name="l00195"></a>00195 <span class="comment"> *</span>
<a name="l00196"></a>00196 <span class="comment"> * \return A pointer to the current filename.</span>
<a name="l00197"></a>00197 <span class="comment"> */</span>
<a name="l00198"></a>00198 <span class="keywordtype">char</span> *<a name="a328"></a><a class="code" href="a00163.html#g41e616d3fcc17e0aabfe8ab45ef0d30f">webclient_filename</a>(<span class="keywordtype">void</span>);
<a name="l00199"></a>00199 <span class="comment"></span>
<a name="l00200"></a>00200 <span class="comment">/**</span>
<a name="l00201"></a>00201 <span class="comment"> * Obtain the hostname of the current HTTP data stream.</span>
<a name="l00202"></a>00202 <span class="comment"> *</span>
<a name="l00203"></a>00203 <span class="comment"> * The hostname of the web server of an HTTP request may be changed</span>
<a name="l00204"></a>00204 <span class="comment"> * by the web server, and may therefore not be the same as when the</span>
<a name="l00205"></a>00205 <span class="comment"> * original GET request was made with webclient_get(). This function</span>
<a name="l00206"></a>00206 <span class="comment"> * is used for obtaining the current hostname.</span>
<a name="l00207"></a>00207 <span class="comment"> *</span>
<a name="l00208"></a>00208 <span class="comment"> * \return A pointer to the current hostname.</span>
<a name="l00209"></a>00209 <span class="comment"> */</span>
<a name="l00210"></a>00210 <span class="keywordtype">char</span> *<a name="a329"></a><a class="code" href="a00163.html#g0e0ea5f24b77f124ba33bcbc7ede5bfb">webclient_hostname</a>(<span class="keywordtype">void</span>);
<a name="l00211"></a>00211 <span class="comment"></span>
<a name="l00212"></a>00212 <span class="comment">/**</span>
<a name="l00213"></a>00213 <span class="comment"> * Obtain the port number of the current HTTP data stream.</span>
<a name="l00214"></a>00214 <span class="comment"> *</span>
<a name="l00215"></a>00215 <span class="comment"> * The port number of an HTTP request may be changed by the web</span>
<a name="l00216"></a>00216 <span class="comment"> * server, and may therefore not be the same as when the original GET</span>
<a name="l00217"></a>00217 <span class="comment"> * request was made with webclient_get(). This function is used for</span>
<a name="l00218"></a>00218 <span class="comment"> * obtaining the current port number.</span>
<a name="l00219"></a>00219 <span class="comment"> *</span>
<a name="l00220"></a>00220 <span class="comment"> * \return The port number of the current HTTP data stream, in host byte order.</span>
<a name="l00221"></a>00221 <span class="comment"> */</span>
<a name="l00222"></a>00222 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a name="a330"></a><a class="code" href="a00163.html#g2a939aa4fcffabbce1dc1f784a7e0ad3">webclient_port</a>(<span class="keywordtype">void</span>);
<a name="l00223"></a>00223
<a name="l00224"></a>00224
<a name="l00225"></a>00225
<a name="l00226"></a>00226 <span class="preprocessor">#endif </span><span class="comment">/* __WEBCLIENT_H__ */</span>
<a name="l00227"></a>00227 <span class="comment"></span>
<a name="l00228"></a>00228 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

106
doc/html/a00042.html Normal file
View File

@@ -0,0 +1,106 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: example-mainloop-with-arp.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>example-mainloop-with-arp.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include "<a class="code" href="a00139.html">uip_arp.h</a>"</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include "network-device.h"</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "httpd.h"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="a00130.html">timer.h</a>"</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="preprocessor">#define BUF ((struct uip_eth_hdr *)&amp;uip_buf[0])</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span>
<a name="l00009"></a>00009 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00010"></a>00010 <span class="keywordtype">int</span>
<a name="l00011"></a>00011 main(<span class="keywordtype">void</span>)
<a name="l00012"></a>00012 {
<a name="l00013"></a>00013 <span class="keywordtype">int</span> i;
<a name="l00014"></a>00014 <a name="a60"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a name="l00015"></a>00015 <span class="keyword">struct </span><a name="_a61"></a><a class="code" href="a00087.html">timer</a> periodic_timer, arp_timer;
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <a name="a62"></a><a class="code" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a>(&amp;periodic_timer, <a name="a63"></a><a class="code" href="a00157.html#ge3ced0551b26c9b99cb45a86f34d100a">CLOCK_SECOND</a> / 2);
<a name="l00018"></a>00018 <a class="code" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a>(&amp;arp_timer, <a class="code" href="a00157.html#ge3ced0551b26c9b99cb45a86f34d100a">CLOCK_SECOND</a> * 10);
<a name="l00019"></a>00019
<a name="l00020"></a>00020 network_device_init();
<a name="l00021"></a>00021 <a name="a64"></a><a class="code" href="a00145.html#gc48ed5f0d27721ef62a3ed02a5ad8d2e">uip_init</a>();
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <a name="a65"></a><a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(ipaddr, 192,168,0,2);
<a name="l00024"></a>00024 <a name="a66"></a><a class="code" href="a00144.html#g12b467f314489259dd718228d0827a51">uip_sethostaddr</a>(ipaddr);
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <a name="a67"></a><a class="code" href="a00164.html#gc364305cee969a0be43c071722b136e6">httpd_init</a>();
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="keywordflow">while</span>(1) {
<a name="l00029"></a>00029 <a name="a68"></a><a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = network_device_read();
<a name="l00030"></a>00030 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00031"></a>00031 <span class="keywordflow">if</span>(<a name="a69"></a><a class="code" href="a00150.html#g24f52ac52d6e714cb04a5aa01be3bdd0">BUF</a>-&gt;type == <a name="a70"></a><a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(<a name="a71"></a><a class="code" href="a00152.html#g03d140db75de3d3cdfbbab1c4fed8d8d">UIP_ETHTYPE_IP</a>)) {
<a name="l00032"></a>00032 <a name="a72"></a><a class="code" href="a00152.html#g737337d6a51e31b236c8233d024138a8">uip_arp_ipin</a>();
<a name="l00033"></a>00033 <a name="a73"></a><a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>();
<a name="l00034"></a>00034 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00035"></a>00035 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00036"></a>00036 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00037"></a>00037 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00038"></a>00038 <a name="a74"></a><a class="code" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a>();
<a name="l00039"></a>00039 network_device_send();
<a name="l00040"></a>00040 }
<a name="l00041"></a>00041 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="a00150.html#g24f52ac52d6e714cb04a5aa01be3bdd0">BUF</a>-&gt;type == <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(<a name="a75"></a><a class="code" href="a00152.html#g3e1562e8a6de32268e5df92a52152f91">UIP_ETHTYPE_ARP</a>)) {
<a name="l00042"></a>00042 <a name="a76"></a><a class="code" href="a00152.html#g902c4a360134096224bc2655f623aa5f">uip_arp_arpin</a>();
<a name="l00043"></a>00043 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00044"></a>00044 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00045"></a>00045 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00046"></a>00046 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00047"></a>00047 network_device_send();
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a name="a77"></a><a class="code" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a>(&amp;periodic_timer)) {
<a name="l00052"></a>00052 <a name="a78"></a><a class="code" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a>(&amp;periodic_timer);
<a name="l00053"></a>00053 <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a79"></a><a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; i++) {
<a name="l00054"></a>00054 <a name="a80"></a><a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i);
<a name="l00055"></a>00055 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00056"></a>00056 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00057"></a>00057 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00058"></a>00058 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00059"></a>00059 <a class="code" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a>();
<a name="l00060"></a>00060 network_device_send();
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="preprocessor">#if UIP_UDP</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span> <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a81"></a><a class="code" href="a00153.html#g196379ceb1219a99f4495e41ccc9bbfb">UIP_UDP_CONNS</a>; i++) {
<a name="l00066"></a>00066 <a name="a82"></a><a class="code" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">uip_udp_periodic</a>(i);
<a name="l00067"></a>00067 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00068"></a>00068 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00069"></a>00069 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00070"></a>00070 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00071"></a>00071 <a class="code" href="a00152.html#g54b27e45df15e10a0eb1a3e3a91417d2">uip_arp_out</a>();
<a name="l00072"></a>00072 network_device_send();
<a name="l00073"></a>00073 }
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="comment">/* Call the ARP timer function every 10 seconds. */</span>
<a name="l00078"></a>00078 <span class="keywordflow">if</span>(<a class="code" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a>(&amp;arp_timer)) {
<a name="l00079"></a>00079 <a class="code" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a>(&amp;arp_timer);
<a name="l00080"></a>00080 <a name="a83"></a><a class="code" href="a00152.html#g058a8e6025f67b021862281f1911fcef">uip_arp_timer</a>();
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 <span class="keywordflow">return</span> 0;
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 <span class="comment">/*---------------------------------------------------------------------------*/</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

82
doc/html/a00043.html Normal file
View File

@@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: example-mainloop-without-arp.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>example-mainloop-without-arp.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include "<a class="code" href="a00139.html">uip_arp.h</a>"</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include "network-device.h"</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "httpd.h"</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include "<a class="code" href="a00130.html">timer.h</a>"</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00008"></a>00008 <span class="keywordtype">int</span>
<a name="l00009"></a>00009 main(<span class="keywordtype">void</span>)
<a name="l00010"></a>00010 {
<a name="l00011"></a>00011 <span class="keywordtype">int</span> i;
<a name="l00012"></a>00012 <a name="a84"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a name="l00013"></a>00013 <span class="keyword">struct </span><a name="_a85"></a><a class="code" href="a00087.html">timer</a> periodic_timer;
<a name="l00014"></a>00014
<a name="l00015"></a>00015 <a name="a86"></a><a class="code" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a>(&amp;periodic_timer, <a name="a87"></a><a class="code" href="a00157.html#ge3ced0551b26c9b99cb45a86f34d100a">CLOCK_SECOND</a> / 2);
<a name="l00016"></a>00016
<a name="l00017"></a>00017 network_device_init();
<a name="l00018"></a>00018 <a name="a88"></a><a class="code" href="a00145.html#gc48ed5f0d27721ef62a3ed02a5ad8d2e">uip_init</a>();
<a name="l00019"></a>00019
<a name="l00020"></a>00020 <a name="a89"></a><a class="code" href="a00148.html#g87f0b54ade0d159fba495089128a4932">uip_ipaddr</a>(ipaddr, 192,168,0,2);
<a name="l00021"></a>00021 <a name="a90"></a><a class="code" href="a00144.html#g12b467f314489259dd718228d0827a51">uip_sethostaddr</a>(ipaddr);
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <a name="a91"></a><a class="code" href="a00164.html#gc364305cee969a0be43c071722b136e6">httpd_init</a>();
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="keywordflow">while</span>(1) {
<a name="l00026"></a>00026 <a name="a92"></a><a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> = network_device_read();
<a name="l00027"></a>00027 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00028"></a>00028 <a name="a93"></a><a class="code" href="a00146.html#ga4360412ee9350fba725f98a137169fe">uip_input</a>();
<a name="l00029"></a>00029 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00030"></a>00030 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00031"></a>00031 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00032"></a>00032 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00033"></a>00033 network_device_send();
<a name="l00034"></a>00034 }
<a name="l00035"></a>00035 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a name="a94"></a><a class="code" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a>(&amp;periodic_timer)) {
<a name="l00036"></a>00036 <a name="a95"></a><a class="code" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a>(&amp;periodic_timer);
<a name="l00037"></a>00037 <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a96"></a><a class="code" href="a00153.html#gf5fe83be78b78b9e7d9e7f1e34ab1cc5">UIP_CONNS</a>; i++) {
<a name="l00038"></a>00038 <a name="a97"></a><a class="code" href="a00146.html#g1024f8a5fa65e82bf848b2e6590d9628">uip_periodic</a>(i);
<a name="l00039"></a>00039 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00040"></a>00040 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00041"></a>00041 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00042"></a>00042 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00043"></a>00043 network_device_send();
<a name="l00044"></a>00044 }
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#if UIP_UDP</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span> <span class="keywordflow">for</span>(i = 0; i &lt; <a name="a98"></a><a class="code" href="a00153.html#g196379ceb1219a99f4495e41ccc9bbfb">UIP_UDP_CONNS</a>; i++) {
<a name="l00049"></a>00049 <a name="a99"></a><a class="code" href="a00146.html#g2c64c8c36bc84f9336f6a2184ea51883">uip_udp_periodic</a>(i);
<a name="l00050"></a>00050 <span class="comment">/* If the above function invocation resulted in data that</span>
<a name="l00051"></a>00051 <span class="comment"> should be sent out on the network, the global variable</span>
<a name="l00052"></a>00052 <span class="comment"> uip_len is set to a value &gt; 0. */</span>
<a name="l00053"></a>00053 <span class="keywordflow">if</span>(<a class="code" href="a00149.html#g12a33f0c09711167bdf3dd7d7cf8c5a1">uip_len</a> &gt; 0) {
<a name="l00054"></a>00054 network_device_send();
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 <span class="preprocessor">#endif </span><span class="comment">/* UIP_UDP */</span>
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 <span class="keywordflow">return</span> 0;
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 <span class="comment">/*---------------------------------------------------------------------------*/</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

370
doc/html/a00044.html Normal file
View File

@@ -0,0 +1,370 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: telnetd.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>telnetd.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2003, Adam Dunkels.</span>
<a name="l00003"></a>00003 <span class="comment"> * All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00006"></a>00006 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00007"></a>00007 <span class="comment"> * are met:</span>
<a name="l00008"></a>00008 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00009"></a>00009 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00010"></a>00010 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00011"></a>00011 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00012"></a>00012 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
<a name="l00013"></a>00013 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00014"></a>00014 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00015"></a>00015 <span class="comment"> * written permission.</span>
<a name="l00016"></a>00016 <span class="comment"> *</span>
<a name="l00017"></a>00017 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00018"></a>00018 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00019"></a>00019 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00020"></a>00020 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00021"></a>00021 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00022"></a>00022 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00023"></a>00023 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00024"></a>00024 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00025"></a>00025 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00026"></a>00026 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00027"></a>00027 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00028"></a>00028 <span class="comment"> *</span>
<a name="l00029"></a>00029 <span class="comment"> * This file is part of the uIP TCP/IP stack</span>
<a name="l00030"></a>00030 <span class="comment"> *</span>
<a name="l00031"></a>00031 <span class="comment"> * $Id: telnetd.c,v 1.2 2006/06/07 09:43:54 adam Exp $</span>
<a name="l00032"></a>00032 <span class="comment"> *</span>
<a name="l00033"></a>00033 <span class="comment"> */</span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "telnetd.h"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="a00121.html">memb.h</a>"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="a00107.html">shell.h</a>"</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="preprocessor">#define ISO_nl 0x0a</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define ISO_cr 0x0d</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 <span class="keyword">struct </span>telnetd_line {
<a name="l00046"></a>00046 <span class="keywordtype">char</span> line[TELNETD_CONF_LINELEN];
<a name="l00047"></a>00047 };
<a name="l00048"></a>00048 <a name="a206"></a><a class="code" href="a00159.html#gf31774d02a69fd3f1c2b282454438cba">MEMB</a>(linemem, <span class="keyword">struct</span> telnetd_line, TELNETD_CONF_NUMLINES);
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#define STATE_NORMAL 0</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#define STATE_IAC 1</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#define STATE_WILL 2</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#define STATE_WONT 3</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#define STATE_DO 4</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span><span class="preprocessor">#define STATE_DONT 5</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor">#define STATE_CLOSE 6</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058 <span class="keyword">static</span> <span class="keyword">struct </span><a name="_a207"></a><a class="code" href="a00086.html">telnetd_state</a> s;
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="preprocessor">#define TELNET_IAC 255</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span><span class="preprocessor">#define TELNET_WILL 251</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#define TELNET_WONT 252</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span><span class="preprocessor">#define TELNET_DO 253</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span><span class="preprocessor">#define TELNET_DONT 254</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span><span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keywordtype">char</span> *
<a name="l00067"></a>00067 alloc_line(<span class="keywordtype">void</span>)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069 <span class="keywordflow">return</span> <a name="a208"></a><a class="code" href="a00159.html#gfe5e93119035e14cc485760a176249ba">memb_alloc</a>(&amp;linemem);
<a name="l00070"></a>00070 }
<a name="l00071"></a>00071 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00073"></a>00073 dealloc_line(<span class="keywordtype">char</span> *line)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 <a name="a209"></a><a class="code" href="a00159.html#gceb952d27de8125d5146ac0bee325b8f">memb_free</a>(&amp;linemem, line);
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00078"></a>00078 <span class="keywordtype">void</span>
<a name="l00079"></a>00079 <a name="a210"></a>shell_quit(<span class="keywordtype">char</span> *str)
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081 s.<a name="a211"></a><a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_CLOSE;
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00084"></a>00084 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00085"></a>00085 sendline(<span class="keywordtype">char</span> *line)
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="keywordflow">for</span>(i = 0; i &lt; TELNETD_CONF_NUMLINES; ++i) {
<a name="l00090"></a>00090 <span class="keywordflow">if</span>(s.<a name="a212"></a><a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i] == <a name="a213"></a><a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00091"></a>00091 s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i] = line;
<a name="l00092"></a>00092 <span class="keywordflow">break</span>;
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 <span class="keywordflow">if</span>(i == TELNETD_CONF_NUMLINES) {
<a name="l00096"></a>00096 dealloc_line(line);
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00100"></a>00100 <span class="keywordtype">void</span>
<a name="l00101"></a>00101 <a name="a214"></a>shell_prompt(<span class="keywordtype">char</span> *str)
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103 <span class="keywordtype">char</span> *line;
<a name="l00104"></a>00104 line = alloc_line();
<a name="l00105"></a>00105 <span class="keywordflow">if</span>(line != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00106"></a>00106 strncpy(line, str, TELNETD_CONF_LINELEN);
<a name="l00107"></a>00107 <span class="comment">/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/</span>
<a name="l00108"></a>00108 sendline(line);
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00112"></a>00112 <span class="keywordtype">void</span>
<a name="l00113"></a>00113 <a name="a215"></a>shell_output(<span class="keywordtype">char</span> *str1, <span class="keywordtype">char</span> *str2)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> len;
<a name="l00116"></a>00116 <span class="keywordtype">char</span> *line;
<a name="l00117"></a>00117
<a name="l00118"></a>00118 line = alloc_line();
<a name="l00119"></a>00119 <span class="keywordflow">if</span>(line != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00120"></a>00120 len = strlen(str1);
<a name="l00121"></a>00121 strncpy(line, str1, TELNETD_CONF_LINELEN);
<a name="l00122"></a>00122 <span class="keywordflow">if</span>(len &lt; TELNETD_CONF_LINELEN) {
<a name="l00123"></a>00123 strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125 len = strlen(line);
<a name="l00126"></a>00126 <span class="keywordflow">if</span>(len &lt; TELNETD_CONF_LINELEN - 2) {
<a name="l00127"></a>00127 line[len] = <a name="a216"></a><a class="code" href="a00161.html#g6cda47c85ce1b58b501b44ac9cccc50e">ISO_cr</a>;
<a name="l00128"></a>00128 line[len+1] = <a name="a217"></a><a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a>;
<a name="l00129"></a>00129 line[len+2] = 0;
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131 <span class="comment">/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/</span>
<a name="l00132"></a>00132 sendline(line);
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00136"></a>00136 <span class="keywordtype">void</span>
<a name="l00137"></a>00137 telnetd_init(<span class="keywordtype">void</span>)
<a name="l00138"></a>00138 {
<a name="l00139"></a>00139 <a name="a218"></a><a class="code" href="a00147.html#gdd1ab3704ecd4900eec61a6897d32dc8">uip_listen</a>(<a name="a219"></a><a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(23));
<a name="l00140"></a>00140 <a name="a220"></a><a class="code" href="a00159.html#gd58a6c7e62ae59bf7a016ded12ca2910">memb_init</a>(&amp;linemem);
<a name="l00141"></a>00141 <a name="a221"></a><a class="code" href="a00107.html#69b075ef7e4d7bcf5a903d3d75baac02">shell_init</a>();
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00144"></a>00144 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00145"></a>00145 acked(<span class="keywordtype">void</span>)
<a name="l00146"></a>00146 {
<a name="l00147"></a>00147 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <span class="keywordflow">while</span>(s.<a name="a222"></a><a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a> &gt; 0) {
<a name="l00150"></a>00150 dealloc_line(s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[0]);
<a name="l00151"></a>00151 <span class="keywordflow">for</span>(i = 1; i &lt; TELNETD_CONF_NUMLINES; ++i) {
<a name="l00152"></a>00152 s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i - 1] = s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i];
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154 s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[TELNETD_CONF_NUMLINES - 1] = <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00155"></a>00155 --s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a>;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 }
<a name="l00158"></a>00158 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00159"></a>00159 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00160"></a>00160 senddata(<span class="keywordtype">void</span>)
<a name="l00161"></a>00161 {
<a name="l00162"></a>00162 <span class="keyword">static</span> <span class="keywordtype">char</span> *<a name="a223"></a><a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a>, *lineptr;
<a name="l00163"></a>00163 <span class="keyword">static</span> <span class="keywordtype">int</span> buflen, linelen;
<a name="l00164"></a>00164
<a name="l00165"></a>00165 bufptr = <a name="a224"></a><a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00166"></a>00166 buflen = 0;
<a name="l00167"></a>00167 <span class="keywordflow">for</span>(s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a> = 0; s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a> &lt; TELNETD_CONF_NUMLINES &amp;&amp;
<a name="l00168"></a>00168 s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a>] != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> ; ++s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a>) {
<a name="l00169"></a>00169 lineptr = s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[s.<a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a>];
<a name="l00170"></a>00170 linelen = strlen(lineptr);
<a name="l00171"></a>00171 <span class="keywordflow">if</span>(linelen &gt; TELNETD_CONF_LINELEN) {
<a name="l00172"></a>00172 linelen = TELNETD_CONF_LINELEN;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 <span class="keywordflow">if</span>(buflen + linelen &lt; <a name="a225"></a><a class="code" href="a00147.html#gb5fecbc62edd128012cea0f47b57ab9f">uip_mss</a>()) {
<a name="l00175"></a>00175 memcpy(bufptr, lineptr, linelen);
<a name="l00176"></a>00176 bufptr += linelen;
<a name="l00177"></a>00177 buflen += linelen;
<a name="l00178"></a>00178 } <span class="keywordflow">else</span> {
<a name="l00179"></a>00179 <span class="keywordflow">break</span>;
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 }
<a name="l00182"></a>00182 <a name="a226"></a><a class="code" href="a00147.html#g04b053a623aac7cd4195157d470661b3">uip_send</a>(<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>, buflen);
<a name="l00183"></a>00183 }
<a name="l00184"></a>00184 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00185"></a>00185 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00186"></a>00186 closed(<span class="keywordtype">void</span>)
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordflow">for</span>(i = 0; i &lt; TELNETD_CONF_NUMLINES; ++i) {
<a name="l00191"></a>00191 <span class="keywordflow">if</span>(s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i] != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00192"></a>00192 dealloc_line(s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i]);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 }
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00197"></a>00197 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00198"></a>00198 get_char(<a name="a227"></a><a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> c)
<a name="l00199"></a>00199 {
<a name="l00200"></a>00200 <span class="keywordflow">if</span>(c == <a class="code" href="a00161.html#g6cda47c85ce1b58b501b44ac9cccc50e">ISO_cr</a>) {
<a name="l00201"></a>00201 <span class="keywordflow">return</span>;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203
<a name="l00204"></a>00204 s.<a name="a228"></a><a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>[(int)s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a>] = c;
<a name="l00205"></a>00205 <span class="keywordflow">if</span>(s.<a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>[(<span class="keywordtype">int</span>)s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a>] == <a class="code" href="a00161.html#g3212e70c55244608ac16316888c354f0">ISO_nl</a> ||
<a name="l00206"></a>00206 s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a> == <span class="keyword">sizeof</span>(s.<a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>) - 1) {
<a name="l00207"></a>00207 <span class="keywordflow">if</span>(s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a> &gt; 0) {
<a name="l00208"></a>00208 s.<a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>[(int)s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a>] = 0;
<a name="l00209"></a>00209 <span class="comment">/* petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);*/</span>
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 <a name="a229"></a><a class="code" href="a00107.html#86beee1f69d05b16022dfb430470e9ce">shell_input</a>(s.<a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>);
<a name="l00212"></a>00212 s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a> = 0;
<a name="l00213"></a>00213 } <span class="keywordflow">else</span> {
<a name="l00214"></a>00214 ++s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a>;
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216 }
<a name="l00217"></a>00217 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00218"></a>00218 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00219"></a>00219 sendopt(<a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> option, <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> value)
<a name="l00220"></a>00220 {
<a name="l00221"></a>00221 <span class="keywordtype">char</span> *line;
<a name="l00222"></a>00222 line = alloc_line();
<a name="l00223"></a>00223 <span class="keywordflow">if</span>(line != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00224"></a>00224 line[0] = TELNET_IAC;
<a name="l00225"></a>00225 line[1] = option;
<a name="l00226"></a>00226 line[2] = value;
<a name="l00227"></a>00227 line[3] = 0;
<a name="l00228"></a>00228 sendline(line);
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 }
<a name="l00231"></a>00231 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00232"></a>00232 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00233"></a>00233 newdata(<span class="keywordtype">void</span>)
<a name="l00234"></a>00234 {
<a name="l00235"></a>00235 <a name="a230"></a><a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len;
<a name="l00236"></a>00236 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> c;
<a name="l00237"></a>00237 <span class="keywordtype">char</span> *dataptr;
<a name="l00238"></a>00238
<a name="l00239"></a>00239
<a name="l00240"></a>00240 len = <a name="a231"></a><a class="code" href="a00147.html#g1a1bc437c09ddef238abab41d77c3177">uip_datalen</a>();
<a name="l00241"></a>00241 dataptr = (<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00242"></a>00242
<a name="l00243"></a>00243 <span class="keywordflow">while</span>(len &gt; 0 &amp;&amp; s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a> &lt; <span class="keyword">sizeof</span>(s.<a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>)) {
<a name="l00244"></a>00244 c = *dataptr;
<a name="l00245"></a>00245 ++dataptr;
<a name="l00246"></a>00246 --len;
<a name="l00247"></a>00247 <span class="keywordflow">switch</span>(s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a>) {
<a name="l00248"></a>00248 <span class="keywordflow">case</span> STATE_IAC:
<a name="l00249"></a>00249 <span class="keywordflow">if</span>(c == TELNET_IAC) {
<a name="l00250"></a>00250 get_char(c);
<a name="l00251"></a>00251 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00252"></a>00252 } <span class="keywordflow">else</span> {
<a name="l00253"></a>00253 <span class="keywordflow">switch</span>(c) {
<a name="l00254"></a>00254 <span class="keywordflow">case</span> TELNET_WILL:
<a name="l00255"></a>00255 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_WILL;
<a name="l00256"></a>00256 <span class="keywordflow">break</span>;
<a name="l00257"></a>00257 <span class="keywordflow">case</span> TELNET_WONT:
<a name="l00258"></a>00258 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_WONT;
<a name="l00259"></a>00259 <span class="keywordflow">break</span>;
<a name="l00260"></a>00260 <span class="keywordflow">case</span> TELNET_DO:
<a name="l00261"></a>00261 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_DO;
<a name="l00262"></a>00262 <span class="keywordflow">break</span>;
<a name="l00263"></a>00263 <span class="keywordflow">case</span> TELNET_DONT:
<a name="l00264"></a>00264 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_DONT;
<a name="l00265"></a>00265 <span class="keywordflow">break</span>;
<a name="l00266"></a>00266 <span class="keywordflow">default</span>:
<a name="l00267"></a>00267 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00268"></a>00268 <span class="keywordflow">break</span>;
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271 <span class="keywordflow">break</span>;
<a name="l00272"></a>00272 <span class="keywordflow">case</span> STATE_WILL:
<a name="l00273"></a>00273 <span class="comment">/* Reply with a DONT */</span>
<a name="l00274"></a>00274 sendopt(TELNET_DONT, c);
<a name="l00275"></a>00275 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00276"></a>00276 <span class="keywordflow">break</span>;
<a name="l00277"></a>00277
<a name="l00278"></a>00278 <span class="keywordflow">case</span> STATE_WONT:
<a name="l00279"></a>00279 <span class="comment">/* Reply with a DONT */</span>
<a name="l00280"></a>00280 sendopt(TELNET_DONT, c);
<a name="l00281"></a>00281 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00282"></a>00282 <span class="keywordflow">break</span>;
<a name="l00283"></a>00283 <span class="keywordflow">case</span> STATE_DO:
<a name="l00284"></a>00284 <span class="comment">/* Reply with a WONT */</span>
<a name="l00285"></a>00285 sendopt(TELNET_WONT, c);
<a name="l00286"></a>00286 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00287"></a>00287 <span class="keywordflow">break</span>;
<a name="l00288"></a>00288 <span class="keywordflow">case</span> STATE_DONT:
<a name="l00289"></a>00289 <span class="comment">/* Reply with a WONT */</span>
<a name="l00290"></a>00290 sendopt(TELNET_WONT, c);
<a name="l00291"></a>00291 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00292"></a>00292 <span class="keywordflow">break</span>;
<a name="l00293"></a>00293 <span class="keywordflow">case</span> STATE_NORMAL:
<a name="l00294"></a>00294 <span class="keywordflow">if</span>(c == TELNET_IAC) {
<a name="l00295"></a>00295 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_IAC;
<a name="l00296"></a>00296 } <span class="keywordflow">else</span> {
<a name="l00297"></a>00297 get_char(c);
<a name="l00298"></a>00298 }
<a name="l00299"></a>00299 <span class="keywordflow">break</span>;
<a name="l00300"></a>00300 }
<a name="l00301"></a>00301
<a name="l00302"></a>00302
<a name="l00303"></a>00303 }
<a name="l00304"></a>00304
<a name="l00305"></a>00305 }
<a name="l00306"></a>00306 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00307"></a>00307 <span class="keywordtype">void</span>
<a name="l00308"></a>00308 telnetd_appcall(<span class="keywordtype">void</span>)
<a name="l00309"></a>00309 {
<a name="l00310"></a>00310 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
<a name="l00311"></a>00311 <span class="keywordflow">if</span>(<a name="a232"></a><a class="code" href="a00147.html#gdb971fb1525d0c5002f52125b05f3218">uip_connected</a>()) {
<a name="l00312"></a>00312 <span class="comment">/* tcp_markconn(uip_conn, &amp;s);*/</span>
<a name="l00313"></a>00313 <span class="keywordflow">for</span>(i = 0; i &lt; TELNETD_CONF_NUMLINES; ++i) {
<a name="l00314"></a>00314 s.<a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[i] = <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00315"></a>00315 }
<a name="l00316"></a>00316 s.<a class="code" href="a00086.html#5eced097547fd3fac4ba2a255493d921">bufptr</a> = 0;
<a name="l00317"></a>00317 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00318"></a>00318
<a name="l00319"></a>00319 <a name="a233"></a><a class="code" href="a00107.html#d1f18f739da7703628c3663209463a0d">shell_start</a>();
<a name="l00320"></a>00320 }
<a name="l00321"></a>00321
<a name="l00322"></a>00322 <span class="keywordflow">if</span>(s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> == STATE_CLOSE) {
<a name="l00323"></a>00323 s.<a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a> = STATE_NORMAL;
<a name="l00324"></a>00324 <a name="a234"></a><a class="code" href="a00147.html#g61db1dcb7c760e4dd5d60bf4e5576dca">uip_close</a>();
<a name="l00325"></a>00325 <span class="keywordflow">return</span>;
<a name="l00326"></a>00326 }
<a name="l00327"></a>00327
<a name="l00328"></a>00328 <span class="keywordflow">if</span>(<a name="a235"></a><a class="code" href="a00147.html#gef6c4140c632b6a406779342cf3b6eb6">uip_closed</a>() ||
<a name="l00329"></a>00329 <a name="a236"></a><a class="code" href="a00147.html#gfbd5fc486dfdf6bf6fc9db52b1f418c4">uip_aborted</a>() ||
<a name="l00330"></a>00330 <a name="a237"></a><a class="code" href="a00147.html#g7b2ac4b18bd2ac3912fe67b3b17158c3">uip_timedout</a>()) {
<a name="l00331"></a>00331 closed();
<a name="l00332"></a>00332 }
<a name="l00333"></a>00333
<a name="l00334"></a>00334 <span class="keywordflow">if</span>(<a name="a238"></a><a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>()) {
<a name="l00335"></a>00335 acked();
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337
<a name="l00338"></a>00338 <span class="keywordflow">if</span>(<a name="a239"></a><a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>()) {
<a name="l00339"></a>00339 newdata();
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="keywordflow">if</span>(<a name="a240"></a><a class="code" href="a00147.html#ga8933ad15a2e2947dae4a5cff50e6007">uip_rexmit</a>() ||
<a name="l00343"></a>00343 <a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>() ||
<a name="l00344"></a>00344 <a class="code" href="a00147.html#gde6634974418e3240c212b9b16864368">uip_acked</a>() ||
<a name="l00345"></a>00345 <a class="code" href="a00147.html#gdb971fb1525d0c5002f52125b05f3218">uip_connected</a>() ||
<a name="l00346"></a>00346 <a name="a241"></a><a class="code" href="a00147.html#g58bb90796c1cdad3aac2ecf44d87b20e">uip_poll</a>()) {
<a name="l00347"></a>00347 senddata();
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350 <span class="comment">/*---------------------------------------------------------------------------*/</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

83
doc/html/a00045.html Normal file
View File

@@ -0,0 +1,83 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 1.0: telnetd.h</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>telnetd.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2003, Adam Dunkels.</span>
<a name="l00003"></a>00003 <span class="comment"> * All rights reserved.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00006"></a>00006 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00007"></a>00007 <span class="comment"> * are met:</span>
<a name="l00008"></a>00008 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00009"></a>00009 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00010"></a>00010 <span class="comment"> * 2. Redistributions in binary form must reproduce the above</span>
<a name="l00011"></a>00011 <span class="comment"> * copyright notice, this list of conditions and the following</span>
<a name="l00012"></a>00012 <span class="comment"> * disclaimer in the documentation and/or other materials provided</span>
<a name="l00013"></a>00013 <span class="comment"> * with the distribution.</span>
<a name="l00014"></a>00014 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00015"></a>00015 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00016"></a>00016 <span class="comment"> * written permission.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00019"></a>00019 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00020"></a>00020 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00021"></a>00021 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00022"></a>00022 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00023"></a>00023 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00024"></a>00024 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00025"></a>00025 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00026"></a>00026 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00027"></a>00027 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00028"></a>00028 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This file is part of the uIP TCP/IP stack</span>
<a name="l00031"></a>00031 <span class="comment"> *</span>
<a name="l00032"></a>00032 <span class="comment"> * $Id: telnetd.h,v 1.2 2006/06/07 09:43:54 adam Exp $</span>
<a name="l00033"></a>00033 <span class="comment"> *</span>
<a name="l00034"></a>00034 <span class="comment"> */</span>
<a name="l00035"></a>00035 <span class="preprocessor">#ifndef __TELNETD_H__</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define __TELNETD_H__</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="a00140.html">uipopt.h</a>"</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="keywordtype">void</span> telnetd_appcall(<span class="keywordtype">void</span>);
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="preprocessor">#ifndef TELNETD_CONF_LINELEN</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define TELNETD_CONF_LINELEN 40</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#ifndef TELNETD_CONF_NUMLINES</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span><span class="preprocessor">#define TELNETD_CONF_NUMLINES 16</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="keyword">struct </span><a name="_a242"></a><a class="code" href="a00086.html">telnetd_state</a> {
<a name="l00050"></a>00050 <span class="keywordtype">char</span> *<a name="a243"></a><a class="code" href="a00086.html#cca775e46d4405b7775b328f7694f7e7">lines</a>[TELNETD_CONF_NUMLINES];
<a name="l00051"></a>00051 <span class="keywordtype">char</span> <a name="a244"></a><a class="code" href="a00086.html#54a466311575a727830a92a6c3621cb2">buf</a>[TELNETD_CONF_LINELEN];
<a name="l00052"></a>00052 <span class="keywordtype">char</span> bufptr;
<a name="l00053"></a>00053 <a name="a245"></a><a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> <a name="a246"></a><a class="code" href="a00086.html#d85fc90c30d1fc37c63c4844be5fe09d">numsent</a>;
<a name="l00054"></a>00054 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> <a name="a247"></a><a class="code" href="a00086.html#41bf109b6a45328d5744c0a76563fb6c">state</a>;
<a name="l00055"></a>00055 };
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="a00086.html">telnetd_state</a> <a name="a248"></a><a class="code" href="a00153.html#g69646a81a922033c5281445a71f8ffed">uip_tcp_appstate_t</a>;
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="preprocessor">#ifndef UIP_APPCALL</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span><span class="preprocessor">#define UIP_APPCALL telnetd_appcall</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>
<a name="l00063"></a>00063 <span class="preprocessor">#endif </span><span class="comment">/* __TELNETD_H__ */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

View File

@@ -1,37 +1,484 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>uIP 0.9: uip_udp_conn struct Reference</title>
<title>uIP 1.0: resolv.c</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.3 -->
<div class="qindex"><a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a></div>
<h1>uip_udp_conn Struct Reference<br>
<small>
[<a class="el" href="a00075.html">The uIP TCP/IP stack</a>]</small>
</h1><code>#include &lt;uip.h&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Representation of a uIP UDP connection.
<p>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o0" doxytag="uip_udp_conn::ripaddr"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00046.html#o0">ripaddr</a> [2]</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The IP address of the remote peer. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o1" doxytag="uip_udp_conn::lport"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00046.html#o1">lport</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The local port number in network byte order. <br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a name="o2" doxytag="uip_udp_conn::rport"></a>
<a class="el" href="a00086.html#a1">u16_t</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a00046.html#o2">rport</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The remote port number in network byte order. <br><br></td></tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Oct 7 15:51:43 2003 for uIP 0.9 by
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<h1>resolv.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**</span>
<a name="l00002"></a>00002 <span class="comment"> * \addtogroup apps</span>
<a name="l00003"></a>00003 <span class="comment"> * @{</span>
<a name="l00004"></a>00004 <span class="comment"> */</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">/**</span>
<a name="l00007"></a>00007 <span class="comment"> * \defgroup resolv DNS resolver</span>
<a name="l00008"></a>00008 <span class="comment"> * @{</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * The uIP DNS resolver functions are used to lookup a hostname and</span>
<a name="l00011"></a>00011 <span class="comment"> * map it to a numerical IP address. It maintains a list of resolved</span>
<a name="l00012"></a>00012 <span class="comment"> * hostnames that can be queried with the resolv_lookup()</span>
<a name="l00013"></a>00013 <span class="comment"> * function. New hostnames can be resolved using the resolv_query()</span>
<a name="l00014"></a>00014 <span class="comment"> * function.</span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * When a hostname has been resolved (or found to be non-existant),</span>
<a name="l00017"></a>00017 <span class="comment"> * the resolver code calls a callback function called resolv_found()</span>
<a name="l00018"></a>00018 <span class="comment"> * that must be implemented by the module that uses the resolver.</span>
<a name="l00019"></a>00019 <span class="comment"> */</span>
<a name="l00020"></a>00020 <span class="comment"></span>
<a name="l00021"></a>00021 <span class="comment">/**</span>
<a name="l00022"></a>00022 <span class="comment"> * \file</span>
<a name="l00023"></a>00023 <span class="comment"> * DNS host name to IP address resolver.</span>
<a name="l00024"></a>00024 <span class="comment"> * \author Adam Dunkels &lt;adam@dunkels.com&gt;</span>
<a name="l00025"></a>00025 <span class="comment"> *</span>
<a name="l00026"></a>00026 <span class="comment"> * This file implements a DNS host name to IP address resolver.</span>
<a name="l00027"></a>00027 <span class="comment"> */</span>
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="comment">/*</span>
<a name="l00030"></a>00030 <span class="comment"> * Copyright (c) 2002-2003, Adam Dunkels.</span>
<a name="l00031"></a>00031 <span class="comment"> * All rights reserved.</span>
<a name="l00032"></a>00032 <span class="comment"> *</span>
<a name="l00033"></a>00033 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00034"></a>00034 <span class="comment"> * modification, are permitted provided that the following conditions</span>
<a name="l00035"></a>00035 <span class="comment"> * are met:</span>
<a name="l00036"></a>00036 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span>
<a name="l00037"></a>00037 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span>
<a name="l00038"></a>00038 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00039"></a>00039 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00040"></a>00040 <span class="comment"> * documentation and/or other materials provided with the distribution.</span>
<a name="l00041"></a>00041 <span class="comment"> * 3. The name of the author may not be used to endorse or promote</span>
<a name="l00042"></a>00042 <span class="comment"> * products derived from this software without specific prior</span>
<a name="l00043"></a>00043 <span class="comment"> * written permission.</span>
<a name="l00044"></a>00044 <span class="comment"> *</span>
<a name="l00045"></a>00045 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS</span>
<a name="l00046"></a>00046 <span class="comment"> * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED</span>
<a name="l00047"></a>00047 <span class="comment"> * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00048"></a>00048 <span class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY</span>
<a name="l00049"></a>00049 <span class="comment"> * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL</span>
<a name="l00050"></a>00050 <span class="comment"> * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE</span>
<a name="l00051"></a>00051 <span class="comment"> * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00052"></a>00052 <span class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,</span>
<a name="l00053"></a>00053 <span class="comment"> * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00054"></a>00054 <span class="comment"> * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00055"></a>00055 <span class="comment"> * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00056"></a>00056 <span class="comment"> *</span>
<a name="l00057"></a>00057 <span class="comment"> * This file is part of the uIP TCP/IP stack.</span>
<a name="l00058"></a>00058 <span class="comment"> *</span>
<a name="l00059"></a>00059 <span class="comment"> * $Id: resolv.c,v 1.5 2006/06/11 21:46:37 adam Exp $</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> */</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="preprocessor">#include "<a class="code" href="a00103.html">resolv.h</a>"</span>
<a name="l00064"></a>00064 <span class="preprocessor">#include "<a class="code" href="a00136.html">uip.h</a>"</span>
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="preprocessor">#ifndef NULL</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#define NULL (void *)0</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* NULL */</span>
<a name="l00071"></a>00071 <span class="comment"></span>
<a name="l00072"></a>00072 <span class="comment">/** \internal The maximum number of retries when asking for a name. */</span>
<a name="l00073"></a>00073 <span class="preprocessor">#define MAX_RETRIES 8</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">/** \internal The DNS message header. */</span>
<a name="l00076"></a>00076 <span class="keyword">struct </span>dns_hdr {
<a name="l00077"></a>00077 <a name="a125"></a><a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> id;
<a name="l00078"></a>00078 <a name="a126"></a><a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> flags1, flags2;
<a name="l00079"></a>00079 <span class="preprocessor">#define DNS_FLAG1_RESPONSE 0x80</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_OPCODE_STATUS 0x10</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_OPCODE_INVERSE 0x08</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_OPCODE_STANDARD 0x00</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_AUTHORATIVE 0x04</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_TRUNC 0x02</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG1_RD 0x01</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG2_RA 0x80</span>
<a name="l00087"></a>00087 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG2_ERR_MASK 0x0f</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG2_ERR_NONE 0x00</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span><span class="preprocessor">#define DNS_FLAG2_ERR_NAME 0x03</span>
<a name="l00090"></a>00090 <span class="preprocessor"></span> <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> numquestions;
<a name="l00091"></a>00091 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> numanswers;
<a name="l00092"></a>00092 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> numauthrr;
<a name="l00093"></a>00093 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> numextrarr;
<a name="l00094"></a>00094 };
<a name="l00095"></a>00095 <span class="comment"></span>
<a name="l00096"></a>00096 <span class="comment">/** \internal The DNS answer message structure. */</span>
<a name="l00097"></a>00097 <span class="keyword">struct </span>dns_answer {
<a name="l00098"></a>00098 <span class="comment">/* DNS answer record starts with either a domain name or a pointer</span>
<a name="l00099"></a>00099 <span class="comment"> to a name already present somewhere in the packet. */</span>
<a name="l00100"></a>00100 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> type;
<a name="l00101"></a>00101 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> <span class="keyword">class</span>;
<a name="l00102"></a>00102 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> ttl[2];
<a name="l00103"></a>00103 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> len;
<a name="l00104"></a>00104 <a name="a127"></a><a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a name="l00105"></a>00105 };
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keyword">struct </span>namemap {
<a name="l00108"></a>00108 <span class="preprocessor">#define STATE_UNUSED 0</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">#define STATE_NEW 1</span>
<a name="l00110"></a>00110 <span class="preprocessor"></span><span class="preprocessor">#define STATE_ASKING 2</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="preprocessor">#define STATE_DONE 3</span>
<a name="l00112"></a>00112 <span class="preprocessor"></span><span class="preprocessor">#define STATE_ERROR 4</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> state;
<a name="l00114"></a>00114 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> tmr;
<a name="l00115"></a>00115 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> retries;
<a name="l00116"></a>00116 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> seqno;
<a name="l00117"></a>00117 <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> err;
<a name="l00118"></a>00118 <span class="keywordtype">char</span> name[32];
<a name="l00119"></a>00119 <a class="code" href="a00150.html#g1ef35301f43a5bbb9f89f07b5a36b9a0">uip_ipaddr_t</a> ipaddr;
<a name="l00120"></a>00120 };
<a name="l00121"></a>00121
<a name="l00122"></a>00122 <span class="preprocessor">#ifndef UIP_CONF_RESOLV_ENTRIES</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span><span class="preprocessor">#define RESOLV_ENTRIES 4</span>
<a name="l00124"></a>00124 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* UIP_CONF_RESOLV_ENTRIES */</span>
<a name="l00125"></a>00125 <span class="preprocessor">#define RESOLV_ENTRIES UIP_CONF_RESOLV_ENTRIES</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* UIP_CONF_RESOLV_ENTRIES */</span>
<a name="l00127"></a>00127
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="keyword">static</span> <span class="keyword">struct </span>namemap names[<a name="a128"></a><a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>];
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> seqno;
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="keyword">static</span> <span class="keyword">struct </span><a name="_a129"></a><a class="code" href="a00095.html">uip_udp_conn</a> *resolv_conn = <a name="a130"></a><a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00134"></a>00134
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00137"></a>00137 <span class="comment">/** \internal</span>
<a name="l00138"></a>00138 <span class="comment"> * Walk through a compact encoded DNS name and return the end of it.</span>
<a name="l00139"></a>00139 <span class="comment"> *</span>
<a name="l00140"></a>00140 <span class="comment"> * \return The end of the name.</span>
<a name="l00141"></a>00141 <span class="comment"> */</span>
<a name="l00142"></a>00142 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00143"></a>00143 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *
<a name="l00144"></a>00144 parse_name(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *query)
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> n;
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <span class="keywordflow">do</span> {
<a name="l00149"></a>00149 n = *query++;
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="keywordflow">while</span>(n &gt; 0) {
<a name="l00152"></a>00152 <span class="comment">/* printf("%c", *query);*/</span>
<a name="l00153"></a>00153 ++query;
<a name="l00154"></a>00154 --n;
<a name="l00155"></a>00155 };
<a name="l00156"></a>00156 <span class="comment">/* printf(".");*/</span>
<a name="l00157"></a>00157 } <span class="keywordflow">while</span>(*query != 0);
<a name="l00158"></a>00158 <span class="comment">/* printf("\n");*/</span>
<a name="l00159"></a>00159 <span class="keywordflow">return</span> query + 1;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00162"></a>00162 <span class="comment">/** \internal</span>
<a name="l00163"></a>00163 <span class="comment"> * Runs through the list of names to see if there are any that have</span>
<a name="l00164"></a>00164 <span class="comment"> * not yet been queried and, if so, sends out a query.</span>
<a name="l00165"></a>00165 <span class="comment"> */</span>
<a name="l00166"></a>00166 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00167"></a>00167 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00168"></a>00168 check_entries(<span class="keywordtype">void</span>)
<a name="l00169"></a>00169 {
<a name="l00170"></a>00170 <span class="keyword">register</span> <span class="keyword">struct </span>dns_hdr *hdr;
<a name="l00171"></a>00171 <span class="keywordtype">char</span> *query, *nptr, *nameptr;
<a name="l00172"></a>00172 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> i;
<a name="l00173"></a>00173 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> n;
<a name="l00174"></a>00174 <span class="keyword">register</span> <span class="keyword">struct </span>namemap *namemapptr;
<a name="l00175"></a>00175
<a name="l00176"></a>00176 <span class="keywordflow">for</span>(i = 0; i &lt; <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>; ++i) {
<a name="l00177"></a>00177 namemapptr = &amp;names[i];
<a name="l00178"></a>00178 <span class="keywordflow">if</span>(namemapptr-&gt;state == <a name="a131"></a><a class="code" href="a00102.html#bf4401501f1389872141a78b63f325a3">STATE_NEW</a> ||
<a name="l00179"></a>00179 namemapptr-&gt;state == <a name="a132"></a><a class="code" href="a00102.html#55735650f879293d9b7b5fda6753d147">STATE_ASKING</a>) {
<a name="l00180"></a>00180 <span class="keywordflow">if</span>(namemapptr-&gt;state == <a class="code" href="a00102.html#55735650f879293d9b7b5fda6753d147">STATE_ASKING</a>) {
<a name="l00181"></a>00181 <span class="keywordflow">if</span>(--namemapptr-&gt;tmr == 0) {
<a name="l00182"></a>00182 <span class="keywordflow">if</span>(++namemapptr-&gt;retries == <a name="a133"></a><a class="code" href="a00160.html#gecf13b8dc783db2202ca5c34fe117fc3">MAX_RETRIES</a>) {
<a name="l00183"></a>00183 namemapptr-&gt;state = <a name="a134"></a><a class="code" href="a00102.html#7bf0c086c7c41c12cc63324327932d91">STATE_ERROR</a>;
<a name="l00184"></a>00184 <a name="a135"></a><a class="code" href="a00160.html#g6d9751d534453425c7a5a215d1d4414c">resolv_found</a>(namemapptr-&gt;name, <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00185"></a>00185 <span class="keywordflow">continue</span>;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 namemapptr-&gt;tmr = namemapptr-&gt;retries;
<a name="l00188"></a>00188 } <span class="keywordflow">else</span> {
<a name="l00189"></a>00189 <span class="comment">/* printf("Timer %d\n", namemapptr-&gt;tmr);*/</span>
<a name="l00190"></a>00190 <span class="comment">/* Its timer has not run out, so we move on to next</span>
<a name="l00191"></a>00191 <span class="comment"> entry. */</span>
<a name="l00192"></a>00192 <span class="keywordflow">continue</span>;
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 } <span class="keywordflow">else</span> {
<a name="l00195"></a>00195 namemapptr-&gt;state = <a class="code" href="a00102.html#55735650f879293d9b7b5fda6753d147">STATE_ASKING</a>;
<a name="l00196"></a>00196 namemapptr-&gt;tmr = 1;
<a name="l00197"></a>00197 namemapptr-&gt;retries = 0;
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 hdr = (<span class="keyword">struct </span>dns_hdr *)<a name="a136"></a><a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00200"></a>00200 memset(hdr, 0, <span class="keyword">sizeof</span>(<span class="keyword">struct</span> dns_hdr));
<a name="l00201"></a>00201 hdr-&gt;id = <a name="a137"></a><a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(i);
<a name="l00202"></a>00202 hdr-&gt;flags1 = <a name="a138"></a><a class="code" href="a00102.html#72d99b1623afa14bd58c667b748c2ddc">DNS_FLAG1_RD</a>;
<a name="l00203"></a>00203 hdr-&gt;numquestions = <a name="a139"></a><a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(1);
<a name="l00204"></a>00204 query = (<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a> + 12;
<a name="l00205"></a>00205 nameptr = namemapptr-&gt;name;
<a name="l00206"></a>00206 --nameptr;
<a name="l00207"></a>00207 <span class="comment">/* Convert hostname into suitable query format. */</span>
<a name="l00208"></a>00208 <span class="keywordflow">do</span> {
<a name="l00209"></a>00209 ++nameptr;
<a name="l00210"></a>00210 nptr = query;
<a name="l00211"></a>00211 ++query;
<a name="l00212"></a>00212 <span class="keywordflow">for</span>(n = 0; *nameptr != <span class="charliteral">'.'</span> &amp;&amp; *nameptr != 0; ++nameptr) {
<a name="l00213"></a>00213 *query = *nameptr;
<a name="l00214"></a>00214 ++query;
<a name="l00215"></a>00215 ++n;
<a name="l00216"></a>00216 }
<a name="l00217"></a>00217 *nptr = n;
<a name="l00218"></a>00218 } <span class="keywordflow">while</span>(*nameptr != 0);
<a name="l00219"></a>00219 {
<a name="l00220"></a>00220 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> endquery[] =
<a name="l00221"></a>00221 {0,0,1,0,1};
<a name="l00222"></a>00222 memcpy(query, endquery, 5);
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 <a name="a140"></a><a class="code" href="a00147.html#ge5ab69d40013e6cf86ef1763c95d920e">uip_udp_send</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>)(query + 5 - (<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>));
<a name="l00225"></a>00225 <span class="keywordflow">break</span>;
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 }
<a name="l00229"></a>00229 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00230"></a>00230 <span class="comment">/** \internal</span>
<a name="l00231"></a>00231 <span class="comment"> * Called when new UDP data arrives.</span>
<a name="l00232"></a>00232 <span class="comment"> */</span>
<a name="l00233"></a>00233 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00234"></a>00234 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00235"></a>00235 newdata(<span class="keywordtype">void</span>)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237 <span class="keywordtype">char</span> *nameptr;
<a name="l00238"></a>00238 <span class="keyword">struct </span>dns_answer *ans;
<a name="l00239"></a>00239 <span class="keyword">struct </span>dns_hdr *hdr;
<a name="l00240"></a>00240 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> nquestions, nanswers;
<a name="l00241"></a>00241 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> i;
<a name="l00242"></a>00242 <span class="keyword">register</span> <span class="keyword">struct </span>namemap *namemapptr;
<a name="l00243"></a>00243
<a name="l00244"></a>00244 hdr = (<span class="keyword">struct </span>dns_hdr *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a>;
<a name="l00245"></a>00245 <span class="comment">/* printf("ID %d\n", htons(hdr-&gt;id));</span>
<a name="l00246"></a>00246 <span class="comment"> printf("Query %d\n", hdr-&gt;flags1 &amp; DNS_FLAG1_RESPONSE);</span>
<a name="l00247"></a>00247 <span class="comment"> printf("Error %d\n", hdr-&gt;flags2 &amp; DNS_FLAG2_ERR_MASK);</span>
<a name="l00248"></a>00248 <span class="comment"> printf("Num questions %d, answers %d, authrr %d, extrarr %d\n",</span>
<a name="l00249"></a>00249 <span class="comment"> htons(hdr-&gt;numquestions),</span>
<a name="l00250"></a>00250 <span class="comment"> htons(hdr-&gt;numanswers),</span>
<a name="l00251"></a>00251 <span class="comment"> htons(hdr-&gt;numauthrr),</span>
<a name="l00252"></a>00252 <span class="comment"> htons(hdr-&gt;numextrarr));</span>
<a name="l00253"></a>00253 <span class="comment"> */</span>
<a name="l00254"></a>00254
<a name="l00255"></a>00255 <span class="comment">/* The ID in the DNS header should be our entry into the name</span>
<a name="l00256"></a>00256 <span class="comment"> table. */</span>
<a name="l00257"></a>00257 i = <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(hdr-&gt;id);
<a name="l00258"></a>00258 namemapptr = &amp;names[i];
<a name="l00259"></a>00259 <span class="keywordflow">if</span>(i &lt; <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a> &amp;&amp;
<a name="l00260"></a>00260 namemapptr-&gt;state == <a class="code" href="a00102.html#55735650f879293d9b7b5fda6753d147">STATE_ASKING</a>) {
<a name="l00261"></a>00261
<a name="l00262"></a>00262 <span class="comment">/* This entry is now finished. */</span>
<a name="l00263"></a>00263 namemapptr-&gt;state = <a name="a141"></a><a class="code" href="a00102.html#876c82c946543cd70c141e41417138e0">STATE_DONE</a>;
<a name="l00264"></a>00264 namemapptr-&gt;err = hdr-&gt;flags2 &amp; <a name="a142"></a><a class="code" href="a00102.html#9f6c329c04baba17fe0f5b2a6597d713">DNS_FLAG2_ERR_MASK</a>;
<a name="l00265"></a>00265
<a name="l00266"></a>00266 <span class="comment">/* Check for error. If so, call callback to inform. */</span>
<a name="l00267"></a>00267 <span class="keywordflow">if</span>(namemapptr-&gt;err != 0) {
<a name="l00268"></a>00268 namemapptr-&gt;state = <a class="code" href="a00102.html#7bf0c086c7c41c12cc63324327932d91">STATE_ERROR</a>;
<a name="l00269"></a>00269 <a class="code" href="a00160.html#g6d9751d534453425c7a5a215d1d4414c">resolv_found</a>(namemapptr-&gt;name, <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);
<a name="l00270"></a>00270 <span class="keywordflow">return</span>;
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272
<a name="l00273"></a>00273 <span class="comment">/* We only care about the question(s) and the answers. The authrr</span>
<a name="l00274"></a>00274 <span class="comment"> and the extrarr are simply discarded. */</span>
<a name="l00275"></a>00275 nquestions = <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(hdr-&gt;numquestions);
<a name="l00276"></a>00276 nanswers = <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(hdr-&gt;numanswers);
<a name="l00277"></a>00277
<a name="l00278"></a>00278 <span class="comment">/* Skip the name in the question. XXX: This should really be</span>
<a name="l00279"></a>00279 <span class="comment"> checked agains the name in the question, to be sure that they</span>
<a name="l00280"></a>00280 <span class="comment"> match. */</span>
<a name="l00281"></a>00281 nameptr = parse_name((<span class="keywordtype">char</span> *)<a class="code" href="a00150.html#g561b8eda32e059d4e7397f776268cc63">uip_appdata</a> + 12) + 4;
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keywordflow">while</span>(nanswers &gt; 0) {
<a name="l00284"></a>00284 <span class="comment">/* The first byte in the answer resource record determines if it</span>
<a name="l00285"></a>00285 <span class="comment"> is a compressed record or a normal one. */</span>
<a name="l00286"></a>00286 <span class="keywordflow">if</span>(*nameptr &amp; 0xc0) {
<a name="l00287"></a>00287 <span class="comment">/* Compressed name. */</span>
<a name="l00288"></a>00288 nameptr +=2;
<a name="l00289"></a>00289 <span class="comment">/* printf("Compressed anwser\n");*/</span>
<a name="l00290"></a>00290 } <span class="keywordflow">else</span> {
<a name="l00291"></a>00291 <span class="comment">/* Not compressed name. */</span>
<a name="l00292"></a>00292 nameptr = parse_name((<span class="keywordtype">char</span> *)nameptr);
<a name="l00293"></a>00293 }
<a name="l00294"></a>00294
<a name="l00295"></a>00295 ans = (<span class="keyword">struct </span>dns_answer *)nameptr;
<a name="l00296"></a>00296 <span class="comment">/* printf("Answer: type %x, class %x, ttl %x, length %x\n",</span>
<a name="l00297"></a>00297 <span class="comment"> htons(ans-&gt;type), htons(ans-&gt;class), (htons(ans-&gt;ttl[0])</span>
<a name="l00298"></a>00298 <span class="comment"> &lt;&lt; 16) | htons(ans-&gt;ttl[1]), htons(ans-&gt;len));*/</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300 <span class="comment">/* Check for IP address type and Internet class. Others are</span>
<a name="l00301"></a>00301 <span class="comment"> discarded. */</span>
<a name="l00302"></a>00302 <span class="keywordflow">if</span>(ans-&gt;type == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(1) &amp;&amp;
<a name="l00303"></a>00303 ans-&gt;class == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(1) &amp;&amp;
<a name="l00304"></a>00304 ans-&gt;len == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(4)) {
<a name="l00305"></a>00305 <span class="comment">/* printf("IP address %d.%d.%d.%d\n",</span>
<a name="l00306"></a>00306 <span class="comment"> htons(ans-&gt;ipaddr[0]) &gt;&gt; 8,</span>
<a name="l00307"></a>00307 <span class="comment"> htons(ans-&gt;ipaddr[0]) &amp; 0xff,</span>
<a name="l00308"></a>00308 <span class="comment"> htons(ans-&gt;ipaddr[1]) &gt;&gt; 8,</span>
<a name="l00309"></a>00309 <span class="comment"> htons(ans-&gt;ipaddr[1]) &amp; 0xff);*/</span>
<a name="l00310"></a>00310 <span class="comment">/* XXX: we should really check that this IP address is the one</span>
<a name="l00311"></a>00311 <span class="comment"> we want. */</span>
<a name="l00312"></a>00312 namemapptr-&gt;ipaddr[0] = ans-&gt;ipaddr[0];
<a name="l00313"></a>00313 namemapptr-&gt;ipaddr[1] = ans-&gt;ipaddr[1];
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <a class="code" href="a00160.html#g6d9751d534453425c7a5a215d1d4414c">resolv_found</a>(namemapptr-&gt;name, namemapptr-&gt;ipaddr);
<a name="l00316"></a>00316 <span class="keywordflow">return</span>;
<a name="l00317"></a>00317 } <span class="keywordflow">else</span> {
<a name="l00318"></a>00318 nameptr = nameptr + 10 + <a class="code" href="a00148.html#ga22b04cac8cf283ca12f028578bebc06">htons</a>(ans-&gt;len);
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320 --nanswers;
<a name="l00321"></a>00321 }
<a name="l00322"></a>00322 }
<a name="l00323"></a>00323
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00326"></a>00326 <span class="comment">/** \internal</span>
<a name="l00327"></a>00327 <span class="comment"> * The main UDP function.</span>
<a name="l00328"></a>00328 <span class="comment"> */</span>
<a name="l00329"></a>00329 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00330"></a>00330 <span class="keywordtype">void</span>
<a name="l00331"></a>00331 <a name="a143"></a><a class="code" href="a00160.html#g7c5359305008e9183b18d6ab75f568bf">resolv_appcall</a>(<span class="keywordtype">void</span>)
<a name="l00332"></a>00332 {
<a name="l00333"></a>00333 <span class="keywordflow">if</span>(<a class="code" href="a00095.html">uip_udp_conn</a>-&gt;rport == <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(53)) {
<a name="l00334"></a>00334 <span class="keywordflow">if</span>(<a name="a144"></a><a class="code" href="a00147.html#g58bb90796c1cdad3aac2ecf44d87b20e">uip_poll</a>()) {
<a name="l00335"></a>00335 check_entries();
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 <span class="keywordflow">if</span>(<a name="a145"></a><a class="code" href="a00147.html#g26a14b8dae3f861830af9e7cf1e03725">uip_newdata</a>()) {
<a name="l00338"></a>00338 newdata();
<a name="l00339"></a>00339 }
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00343"></a>00343 <span class="comment">/**</span>
<a name="l00344"></a>00344 <span class="comment"> * Queues a name so that a question for the name will be sent out.</span>
<a name="l00345"></a>00345 <span class="comment"> *</span>
<a name="l00346"></a>00346 <span class="comment"> * \param name The hostname that is to be queried.</span>
<a name="l00347"></a>00347 <span class="comment"> */</span>
<a name="l00348"></a>00348 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00349"></a>00349 <span class="keywordtype">void</span>
<a name="l00350"></a>00350 <a name="a146"></a><a class="code" href="a00160.html#ge4dcbbe6c641d2e3b8537b479df5fc99">resolv_query</a>(<span class="keywordtype">char</span> *name)
<a name="l00351"></a>00351 {
<a name="l00352"></a>00352 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> i;
<a name="l00353"></a>00353 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> lseq, lseqi;
<a name="l00354"></a>00354 <span class="keyword">register</span> <span class="keyword">struct </span>namemap *nameptr;
<a name="l00355"></a>00355
<a name="l00356"></a>00356 lseq = lseqi = 0;
<a name="l00357"></a>00357
<a name="l00358"></a>00358 <span class="keywordflow">for</span>(i = 0; i &lt; <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>; ++i) {
<a name="l00359"></a>00359 nameptr = &amp;names[i];
<a name="l00360"></a>00360 <span class="keywordflow">if</span>(nameptr-&gt;state == <a name="a147"></a><a class="code" href="a00102.html#ee60b8757bacab269b0ccd7c240bf01d">STATE_UNUSED</a>) {
<a name="l00361"></a>00361 <span class="keywordflow">break</span>;
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363 <span class="keywordflow">if</span>(seqno - nameptr-&gt;seqno &gt; lseq) {
<a name="l00364"></a>00364 lseq = seqno - nameptr-&gt;seqno;
<a name="l00365"></a>00365 lseqi = i;
<a name="l00366"></a>00366 }
<a name="l00367"></a>00367 }
<a name="l00368"></a>00368
<a name="l00369"></a>00369 <span class="keywordflow">if</span>(i == <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>) {
<a name="l00370"></a>00370 i = lseqi;
<a name="l00371"></a>00371 nameptr = &amp;names[i];
<a name="l00372"></a>00372 }
<a name="l00373"></a>00373
<a name="l00374"></a>00374 <span class="comment">/* printf("Using entry %d\n", i);*/</span>
<a name="l00375"></a>00375
<a name="l00376"></a>00376 strcpy(nameptr-&gt;name, name);
<a name="l00377"></a>00377 nameptr-&gt;state = <a class="code" href="a00102.html#bf4401501f1389872141a78b63f325a3">STATE_NEW</a>;
<a name="l00378"></a>00378 nameptr-&gt;seqno = seqno;
<a name="l00379"></a>00379 ++seqno;
<a name="l00380"></a>00380 }
<a name="l00381"></a>00381 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00382"></a>00382 <span class="comment">/**</span>
<a name="l00383"></a>00383 <span class="comment"> * Look up a hostname in the array of known hostnames.</span>
<a name="l00384"></a>00384 <span class="comment"> *</span>
<a name="l00385"></a>00385 <span class="comment"> * \note This function only looks in the internal array of known</span>
<a name="l00386"></a>00386 <span class="comment"> * hostnames, it does not send out a query for the hostname if none</span>
<a name="l00387"></a>00387 <span class="comment"> * was found. The function resolv_query() can be used to send a query</span>
<a name="l00388"></a>00388 <span class="comment"> * for a hostname.</span>
<a name="l00389"></a>00389 <span class="comment"> *</span>
<a name="l00390"></a>00390 <span class="comment"> * \return A pointer to a 4-byte representation of the hostname's IP</span>
<a name="l00391"></a>00391 <span class="comment"> * address, or NULL if the hostname was not found in the array of</span>
<a name="l00392"></a>00392 <span class="comment"> * hostnames.</span>
<a name="l00393"></a>00393 <span class="comment"> */</span>
<a name="l00394"></a>00394 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00395"></a>00395 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> *
<a name="l00396"></a>00396 <a name="a148"></a><a class="code" href="a00160.html#g66d19181ad5fe8b8f7c84d1f1d46a2ec">resolv_lookup</a>(<span class="keywordtype">char</span> *name)
<a name="l00397"></a>00397 {
<a name="l00398"></a>00398 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> i;
<a name="l00399"></a>00399 <span class="keyword">struct </span>namemap *nameptr;
<a name="l00400"></a>00400
<a name="l00401"></a>00401 <span class="comment">/* Walk through the list to see if the name is in there. If it is</span>
<a name="l00402"></a>00402 <span class="comment"> not, we return NULL. */</span>
<a name="l00403"></a>00403 <span class="keywordflow">for</span>(i = 0; i &lt; <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>; ++i) {
<a name="l00404"></a>00404 nameptr = &amp;names[i];
<a name="l00405"></a>00405 <span class="keywordflow">if</span>(nameptr-&gt;state == <a class="code" href="a00102.html#876c82c946543cd70c141e41417138e0">STATE_DONE</a> &amp;&amp;
<a name="l00406"></a>00406 strcmp(name, nameptr-&gt;name) == 0) {
<a name="l00407"></a>00407 <span class="keywordflow">return</span> nameptr-&gt;ipaddr;
<a name="l00408"></a>00408 }
<a name="l00409"></a>00409 }
<a name="l00410"></a>00410 <span class="keywordflow">return</span> <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00413"></a>00413 <span class="comment">/**</span>
<a name="l00414"></a>00414 <span class="comment"> * Obtain the currently configured DNS server.</span>
<a name="l00415"></a>00415 <span class="comment"> *</span>
<a name="l00416"></a>00416 <span class="comment"> * \return A pointer to a 4-byte representation of the IP address of</span>
<a name="l00417"></a>00417 <span class="comment"> * the currently configured DNS server or NULL if no DNS server has</span>
<a name="l00418"></a>00418 <span class="comment"> * been configured.</span>
<a name="l00419"></a>00419 <span class="comment"> */</span>
<a name="l00420"></a>00420 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00421"></a>00421 <a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> *
<a name="l00422"></a>00422 <a name="a149"></a><a class="code" href="a00160.html#g3191066cf8f76bd00b6843b77c37068f">resolv_getserver</a>(<span class="keywordtype">void</span>)
<a name="l00423"></a>00423 {
<a name="l00424"></a>00424 <span class="keywordflow">if</span>(resolv_conn == <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00425"></a>00425 <span class="keywordflow">return</span> <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00426"></a>00426 }
<a name="l00427"></a>00427 <span class="keywordflow">return</span> resolv_conn-&gt;<a name="a150"></a><a class="code" href="a00095.html#8a661a2d544100b82d0d14a1985083d5">ripaddr</a>;
<a name="l00428"></a>00428 }
<a name="l00429"></a>00429 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00430"></a>00430 <span class="comment">/**</span>
<a name="l00431"></a>00431 <span class="comment"> * Configure which DNS server to use for queries.</span>
<a name="l00432"></a>00432 <span class="comment"> *</span>
<a name="l00433"></a>00433 <span class="comment"> * \param dnsserver A pointer to a 4-byte representation of the IP</span>
<a name="l00434"></a>00434 <span class="comment"> * address of the DNS server to be configured.</span>
<a name="l00435"></a>00435 <span class="comment"> */</span>
<a name="l00436"></a>00436 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00437"></a>00437 <span class="keywordtype">void</span>
<a name="l00438"></a>00438 <a name="a151"></a><a class="code" href="a00160.html#gdf916e0c752f5cda70d0bddb2be422ba">resolv_conf</a>(<a class="code" href="a00153.html#g77570ac4fcab86864fa1916e55676da2">u16_t</a> *dnsserver)
<a name="l00439"></a>00439 {
<a name="l00440"></a>00440 <span class="keywordflow">if</span>(resolv_conn != <a class="code" href="a00160.html#g070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>) {
<a name="l00441"></a>00441 <a name="a152"></a><a class="code" href="a00147.html#gf2dbaceb10c67783a115075b5b6d66df">uip_udp_remove</a>(resolv_conn);
<a name="l00442"></a>00442 }
<a name="l00443"></a>00443
<a name="l00444"></a>00444 resolv_conn = <a name="a153"></a><a class="code" href="a00147.html#g79c4110211247df3fb30b8cf1c4c02af">uip_udp_new</a>(dnsserver, <a class="code" href="a00148.html#g69a7a4951ff21b302267532c21ee78fc">HTONS</a>(53));
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446 <span class="comment">/*---------------------------------------------------------------------------*/</span><span class="comment"></span>
<a name="l00447"></a>00447 <span class="comment">/**</span>
<a name="l00448"></a>00448 <span class="comment"> * Initalize the resolver.</span>
<a name="l00449"></a>00449 <span class="comment"> */</span>
<a name="l00450"></a>00450 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00451"></a>00451 <span class="keywordtype">void</span>
<a name="l00452"></a>00452 <a name="a154"></a><a class="code" href="a00160.html#gb50f78bbf36d912d69f6c1685d0b40e3">resolv_init</a>(<span class="keywordtype">void</span>)
<a name="l00453"></a>00453 {
<a name="l00454"></a>00454 <span class="keyword">static</span> <a class="code" href="a00153.html#g4caecabca98b43919dd11be1c0d4cd8e">u8_t</a> i;
<a name="l00455"></a>00455
<a name="l00456"></a>00456 <span class="keywordflow">for</span>(i = 0; i &lt; <a class="code" href="a00160.html#g221d37ccde7e3fd0dd2c2eb0a6b15493">RESOLV_ENTRIES</a>; ++i) {
<a name="l00457"></a>00457 names[i].state = <a class="code" href="a00102.html#876c82c946543cd70c141e41417138e0">STATE_DONE</a>;
<a name="l00458"></a>00458 }
<a name="l00459"></a>00459
<a name="l00460"></a>00460 }
<a name="l00461"></a>00461 <span class="comment">/*---------------------------------------------------------------------------*/</span>
<a name="l00462"></a>00462 <span class="comment"></span>
<a name="l00463"></a>00463 <span class="comment">/** @} */</span><span class="comment"></span>
<a name="l00464"></a>00464 <span class="comment">/** @} */</span>
</pre></div> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:01 2006 for uIP 1.0 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 >
</a>1.3.3 </small></address>
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More