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, http_state::retries, tcp_arg(), tcp_err(), tcp_poll(), TCP_PRIO_MIN, tcp_recv(), and tcp_setprio().
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(), NULL, tcp_arg(), tcp_close(), tcp_recv(), and tcp_sent().
Referenced by http_recv(), and http_sent().
Callback called on connection error.
arg | Pointer to structure representing the HTTP state. |
err | Error code. |
References arg, LWIP_UNUSED_ARG, and mem_free().
Referenced by http_accept().
Poll for HTTP data.
arg | Pointer to structure representing the HTTP state. |
pcb | Pointer to a TCP connection structure. |
References arg, ERR_ABRT, ERR_OK, http_state::file, http_send_data(), NULL, http_state::retries, and tcp_abort().
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 arg, 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(), tcp_recved(), tcp_sent(), 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, http_state::left, tcp_sndbuf, tcp_write(), and TCP_WRITE_FLAG_COPY.
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 arg, ERR_OK, http_close_conn(), http_send_data(), http_state::left, LWIP_UNUSED_ARG, and http_state::retries.
Referenced by http_recv().
HTTP server init.
References http_accept(), IP_ADDR_ANY, tcp_accept(), tcp_bind(), tcp_listen, and tcp_new().
Referenced by main().