Httpd server.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/tcp.h"
#include "lwipopts.h"
#include "httpd.h"
#include "fs.h"
Data Structures | |
struct | http_state |
Functions | |
static err_t | http_accept (void *arg, struct tcp_pcb *pcb, err_t err) |
Accept incoming HTTP connection requests. More... | |
static void | http_close_conn (struct tcp_pcb *pcb, struct http_state *hs) |
Close HTTP connection. More... | |
static void | http_conn_err (void *arg, err_t err) |
Callback called on connection error. More... | |
static err_t | http_poll (void *arg, struct tcp_pcb *pcb) |
Poll for HTTP data. More... | |
static err_t | http_recv (void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) |
Core HTTP server receive function. More... | |
static void | http_send_data (struct tcp_pcb *pcb, struct http_state *hs) |
Send HTTP data. More... | |
static err_t | http_sent (void *arg, struct tcp_pcb *pcb, u16_t len) |
Callback to handle data transfer. More... | |
void | httpd_init (void) |
HTTP server init. More... | |
Accept incoming HTTP connection requests.
arg | Pointer to structure representing the HTTP state. |
pcb | Pointer to a TCP connection structure. |
err | Connection status. |
References ERR_MEM, ERR_OK, http_state::file, http_conn_err(), http_poll(), http_recv(), http_state::left, LWIP_UNUSED_ARG, mem_malloc(), NULL, and http_state::retries.
Referenced by httpd_init().
|
static |
Close HTTP connection.
pcb | Pointer to a TCP connection structure. |
hs | Pointer to structure representing the HTTP state. |
References mem_free(), and NULL.
Referenced by http_recv(), and http_sent().
|
static |
Callback called on connection error.
arg | Pointer to structure representing the HTTP state. |
err | Error code. |
References LWIP_UNUSED_ARG, and mem_free().
Referenced by http_accept().
|
static |
Poll for HTTP data.
arg | Pointer to structure representing the HTTP state. |
pcb | Pointer to a TCP connection structure. |
References ERR_ABRT, ERR_OK, http_state::file, http_send_data(), NULL, and http_state::retries.
Referenced by http_accept().
Core HTTP server receive function.
Handle the request and process it.
arg | Pointer to structure representing the HTTP state. |
pcb | Pointer to a TCP connection structure. |
p | Incoming request. |
err | Connection status. |
References fs_file::data, ERR_OK, http_state::file, fs_open(), http_close_conn(), http_send_data(), http_sent(), http_state::left, fs_file::len, NULL, pbuf::payload, pbuf_free(), and pbuf::tot_len.
Referenced by http_accept().
|
static |
Send HTTP data.
pcb | Pointer to a TCP connection structure. |
hs | Pointer to structure representing the HTTP state. |
References ERR_MEM, ERR_OK, http_state::file, and http_state::left.
Referenced by http_poll(), http_recv(), and http_sent().
Callback to handle data transfer.
arg | Pointer to structure representing the HTTP state. |
pcb | Pointer to a TCP connection structure. |
len | Unused. |
References ERR_OK, http_close_conn(), http_send_data(), http_state::left, LWIP_UNUSED_ARG, and http_state::retries.
Referenced by http_recv().
void httpd_init | ( | void | ) |