MeterLogger
|
#include <esp8266.h>
#include <lwip/ip.h>
#include <lwip/udp.h>
#include <lwip/tcp_impl.h>
#include <netif/etharp.h>
#include <lwip/netif.h>
#include <lwip/lwip_napt.h>
#include <lwip/dns.h>
#include <lwip/app/dhcpserver.h>
#include <lwip/opt.h>
#include <espconn.h>
#include "httpd.h"
#include "espfs.h"
#include "debug.h"
#include "tinyprintf.h"
Go to the source code of this file.
Data Structures | |
struct | HttpdPriv |
struct | MimeMap |
Macros | |
#define | MAX_HEAD_LEN 1024 |
#define | MAX_CONN 4 |
#define | MAX_POST 1024 |
#define | MAX_SENDBUFF_LEN 2048 |
Variables | |
static HttpdBuiltInUrl * | builtInUrls |
static HttpdPriv * | connPrivData |
static HttpdConnData | connData [MAX_CONN] |
static struct espconn | httpdConn = (struct espconn){ 0 } |
static esp_tcp | httpdTcp |
static const MimeMap | mimeTypes [] |
static os_timer_t | httpdDisconnectTimer |
static const char * | httpNotFoundHeader ="HTTP/1.0 404 Not Found\r\nServer: esp8266-httpd/0.1\r\nContent-Type: text/plain\r\n\r\nNot Found.\r\n" |
#define MAX_CONN 4 |
Definition at line 41 of file httpd.c.
Referenced by httpdConnectCb(), httpdDisconCb(), httpdFindConnData(), and httpdInit().
#define MAX_HEAD_LEN 1024 |
Definition at line 39 of file httpd.c.
Referenced by httpdRecvCb().
#define MAX_POST 1024 |
Definition at line 43 of file httpd.c.
Referenced by httpdParseHeader().
#define MAX_SENDBUFF_LEN 2048 |
Definition at line 45 of file httpd.c.
Referenced by httpdRecvCb(), httpdSend(), and httpdSentCb().
ICACHE_FLASH_ATTR int cgiRedirect | ( | HttpdConnData * | connData | ) |
Definition at line 256 of file httpd.c.
References HttpdConnData::cgiArg, HttpdConnData::conn, HTTPD_CGI_DONE, httpdRedirect(), ICACHE_FLASH_ATTR, and NULL.
|
static |
Definition at line 483 of file httpd.c.
References conn, HttpdConnData::conn, espconn_disconnect(), espconn_regist_disconcb(), espconn_regist_reconcb(), espconn_regist_recvcb(), espconn_regist_sentcb(), HttpdPriv::headPos, httpdDisconCb(), httpdReconCb(), httpdRecvCb(), httpdSentCb(), ICACHE_FLASH_ATTR, INFO, MAX_CONN, NULL, HttpdConnData::postBuff, HttpdConnData::postLen, HttpdPriv::postPos, and HttpdConnData::priv.
Referenced by httpdInit().
|
static |
Definition at line 454 of file httpd.c.
References HttpdConnData::cgi, conn, HttpdConnData::conn, ESPCONN_CLOSE, ESPCONN_NONE, httpdFindConnData(), httpdRetireConn(), ICACHE_FLASH_ATTR, INFO, MAX_CONN, NULL, and espconn::state.
Referenced by httpdConnectCb().
|
static |
Definition at line 529 of file httpd.c.
References httpdStop(), and ICACHE_FLASH_ATTR.
Referenced by httpdStop().
ICACHE_FLASH_ATTR void httpdEndHeaders | ( | HttpdConnData * | conn | ) |
Definition at line 240 of file httpd.c.
References httpdSend(), and ICACHE_FLASH_ATTR.
Referenced by authBasic(), cgiEspFsHook(), cgiEspFsTemplate(), and cgiWiFiScan().
ICACHE_FLASH_ATTR int httpdFindArg | ( | char * | line, |
char * | arg, | ||
char * | buff, | ||
int | buffLen | ||
) |
Definition at line 167 of file httpd.c.
References httpdUrlDecode(), ICACHE_FLASH_ATTR, INFO, NULL, os_strlen, os_strncmp, os_strstr, and strlen.
Referenced by cgiSetup(), and cgiWifiSetMode().
|
static |
Definition at line 107 of file httpd.c.
References conn, ICACHE_FLASH_ATTR, INFO, MAX_CONN, and NULL.
Referenced by httpdDisconCb(), httpdReconCb(), httpdRecvCb(), and httpdSentCb().
ICACHE_FLASH_ATTR int httpdGetHeader | ( | HttpdConnData * | conn, |
char * | header, | ||
char * | ret, | ||
int | retLen | ||
) |
Definition at line 189 of file httpd.c.
References HttpdPriv::head, HttpdPriv::headPos, ICACHE_FLASH_ATTR, os_strncmp, HttpdConnData::priv, and strlen.
Referenced by authBasic().
ICACHE_FLASH_ATTR const char* httpdGetMimetype | ( | char * | url | ) |
Definition at line 93 of file httpd.c.
References ICACHE_FLASH_ATTR, MimeMap::mimetype, NULL, os_strcmp, and strlen.
Referenced by cgiEspFsHook(), and cgiEspFsTemplate().
ICACHE_FLASH_ATTR void httpdHeader | ( | HttpdConnData * | conn, |
const char * | field, | ||
const char * | val | ||
) |
Definition at line 229 of file httpd.c.
References httpdSend(), ICACHE_FLASH_ATTR, strlen, and tfp_snprintf().
Referenced by authBasic(), cgiEspFsHook(), cgiEspFsTemplate(), and cgiWiFiScan().
|
static |
Definition at line 126 of file httpd.c.
Referenced by httpdUrlDecode().
ICACHE_FLASH_ATTR void httpdInit | ( | HttpdBuiltInUrl * | fixedUrls, |
int | port | ||
) |
Definition at line 509 of file httpd.c.
References HttpdConnData::conn, espconn_accept(), ESPCONN_NONE, espconn_regist_connectcb(), ESPCONN_TCP, httpdConnectCb(), httpdTcp, ICACHE_FLASH_ATTR, INFO, _esp_tcp::local_port, malloc, MAX_CONN, NULL, espconn::proto, espconn::state, espconn::tcp, and espconn::type.
Referenced by httpd_user_init().
|
static |
Definition at line 350 of file httpd.c.
References HttpdConnData::getArgs, ICACHE_FLASH_ATTR, INFO, MAX_POST, NULL, os_malloc, os_strncmp, os_strstr, HttpdConnData::postBuff, HttpdConnData::postLen, HttpdPriv::postPos, HttpdConnData::priv, and HttpdConnData::url.
Referenced by httpdRecvCb().
|
static |
Definition at line 446 of file httpd.c.
References conn, httpdFindConnData(), ICACHE_FLASH_ATTR, INFO, and NULL.
Referenced by httpdConnectCb().
|
static |
Definition at line 394 of file httpd.c.
References conn, HttpdPriv::head, HttpdPriv::headPos, httpdFindConnData(), httpdParseHeader(), httpdSendResp(), ICACHE_FLASH_ATTR, INFO, MAX_HEAD_LEN, MAX_SENDBUFF_LEN, NULL, os_strstr, HttpdConnData::postBuff, HttpdConnData::postLen, HttpdPriv::postPos, HttpdConnData::priv, HttpdPriv::sendBuff, HttpdPriv::sendBuffLen, HttpdConnData::url, and xmitSendBuff().
Referenced by httpdConnectCb().
ICACHE_FLASH_ATTR void httpdRedirect | ( | HttpdConnData * | conn, |
char * | newUrl | ||
) |
Definition at line 246 of file httpd.c.
References httpdSend(), ICACHE_FLASH_ATTR, strlen, and tfp_snprintf().
Referenced by cgiRedirect(), cgiSetup(), and cgiWifiSetMode().
|
static |
Definition at line 118 of file httpd.c.
References HttpdConnData::cgi, HttpdConnData::conn, NULL, os_free, and HttpdConnData::postBuff.
Referenced by httpdDisconCb(), httpdSentCb(), and httpdStop().
ICACHE_FLASH_ATTR int httpdSend | ( | HttpdConnData * | conn, |
const char * | data, | ||
int | len | ||
) |
Definition at line 270 of file httpd.c.
References ICACHE_FLASH_ATTR, MAX_SENDBUFF_LEN, os_memcpy, HttpdConnData::priv, HttpdPriv::sendBuff, HttpdPriv::sendBuffLen, and strlen.
Referenced by authBasic(), cgiEspFsTemplate(), cgiWiFiScan(), httpdEndHeaders(), httpdHeader(), httpdRedirect(), httpdSendResp(), httpdStartResponse(), and tplSetup().
|
static |
Definition at line 319 of file httpd.c.
References HttpdConnData::cgi, HttpdConnData::cgiArg, HttpdBuiltInUrl::cgiArg, HttpdBuiltInUrl::cgiCb, HttpdConnData::cgiData, HTTPD_CGI_DONE, HTTPD_CGI_NOTFOUND, httpdSend(), httpNotFoundHeader, ICACHE_FLASH_ATTR, INFO, NULL, os_strcmp, os_strlen, os_strncmp, HttpdConnData::url, and url.
Referenced by httpdRecvCb().
|
static |
Definition at line 290 of file httpd.c.
References HttpdConnData::cgi, conn, HttpdConnData::conn, espconn_disconnect(), HTTPD_CGI_DONE, httpdFindConnData(), httpdRetireConn(), INFO, MAX_SENDBUFF_LEN, NULL, HttpdConnData::priv, HttpdPriv::sendBuff, HttpdPriv::sendBuffLen, and xmitSendBuff().
Referenced by httpdConnectCb().
ICACHE_FLASH_ATTR void httpdStartResponse | ( | HttpdConnData * | conn, |
int | code | ||
) |
Definition at line 219 of file httpd.c.
References httpdSend(), HTTPDVER, ICACHE_FLASH_ATTR, strlen, and tfp_snprintf().
Referenced by authBasic(), cgiEspFsHook(), cgiEspFsTemplate(), and cgiWiFiScan().
ICACHE_FLASH_ATTR void httpdStop | ( | ) |
Definition at line 534 of file httpd.c.
References espconn_delete(), espconn_disconnect(), ESPCONN_NONE, free, httpdDisconnectTimer, httpdDisconnectTimerFunc(), httpdRetireConn(), INFO, NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, os_timer_setfn, and espconn::state.
Referenced by httpdDisconnectTimerFunc().
int httpdUrlDecode | ( | char * | val, |
int | valLen, | ||
char * | ret, | ||
int | retLen | ||
) |
Definition at line 137 of file httpd.c.
References httpdHexVal(), and ICACHE_FLASH_ATTR.
Referenced by httpdFindArg().
|
static |
Definition at line 280 of file httpd.c.
References HttpdConnData::conn, espconn_sent(), ICACHE_FLASH_ATTR, HttpdConnData::priv, HttpdPriv::sendBuff, and HttpdPriv::sendBuffLen.
Referenced by httpdRecvCb(), and httpdSentCb().
|
static |
|
static |
|
static |
Definition at line 89 of file httpd.c.
Referenced by httpdStop().
|
static |
Definition at line 67 of file httpd.c.
Referenced by httpdInit().
|
static |
Definition at line 314 of file httpd.c.
Referenced by httpdSendResp().
|
static |