44#include "contiki-net.h"
46#ifndef WEBSERVER_CONF_CFS_PATHLEN
47#define HTTPD_PATHLEN 80
49#define HTTPD_PATHLEN WEBSERVER_CONF_CFS_PATHLEN
52#ifndef WEBSERVER_CONF_INBUF_SIZE
53#define HTTPD_INBUF_SIZE (HTTPD_PATHLEN + 90)
55#define HTTPD_INBUF_SIZE WEBSERVER_CONF_INBUF_SIZE
58#if HTTPD_INBUF_SIZE < UIP_TCP_MSS || HTTPD_INBUF_SIZE < UIP_RECEIVE_WINDOW
59#error HTTPD_INBUF_SIZE is too small. Must be at least a TCP window in size.
62#ifndef WEBSERVER_CONF_OUTBUF_SIZE
63#define HTTPD_OUTBUF_SIZE (UIP_TCP_MSS + 20)
65#define HTTPD_OUTBUF_SIZE WEBSERVER_CONF_OUTBUF_SIZE
69typedef char (* httpd_ws_script_t)(
struct httpd_ws_state *s);
70typedef int (* httpd_ws_output_headers_t)(
struct httpd_ws_state *s,
71 char *buffer,
int buf_size,
75#define HTTPD_WS_POST 2
77#define HTTPD_WS_RESPONSE 4
79#define HTTPD_WS_STATE_UNUSED 0
80#define HTTPD_WS_STATE_INPUT 1
81#define HTTPD_WS_STATE_OUTPUT 2
82#define HTTPD_WS_STATE_REQUEST_OUTPUT 3
83#define HTTPD_WS_STATE_REQUEST_INPUT 4
85struct httpd_ws_state {
87 struct psock sin, sout;
89 char inputbuf[HTTPD_INBUF_SIZE];
90 char filename[HTTPD_PATHLEN];
91 const char *content_type;
93 char outbuf[HTTPD_OUTBUF_SIZE];
99 httpd_ws_output_headers_t output_extra_headers;
100 httpd_ws_script_t script;
102#ifdef HTTPD_WS_CONF_USER_STATE
103 HTTPD_WS_CONF_USER_STATE;
107void httpd_ws_init(
void);
108void httpd_ws_appcall(
void *state);
110struct httpd_ws_state *httpd_ws_request(
char request_type,
112 const char *host_hdr,
115 const char *content_type,
116 uint16_t content_len,
117 httpd_ws_script_t generator);
119#define SEND_STRING(s, str, len) PSOCK_SEND((s), (uint8_t *)(str), (len))
121httpd_ws_script_t httpd_ws_get_script(
struct httpd_ws_state *s);
#define PROCESS_NAME(name)
Declare the name of a process.
The representation of a protosocket.