Prusa MINI Firmware overview
|
Internal connection structure which is used in LwIP tcp_ callbacks as arg.
More...
#include <connection.hpp>
Internal connection structure which is used in LwIP tcp_ callbacks as arg.
◆ State
Enumerator |
---|
FIRST | |
WAIT_FOR_EOH | |
PAYLOAD | |
◆ Context()
Context::Context |
( |
struct tcp_pcb * |
pcb | ) |
|
60 ,
message({
nullptr,
nullptr,
nullptr, 0 })
65 , request_buffer(
nullptr)
66 , request_buffer_size(0) {
◆ ~Context()
73 tcp_arg(this->
pcb,
nullptr);
◆ operator new()
static void* Context::operator new |
( |
size_t |
size | ) |
|
|
staticnoexcept |
40 if (Context::instances == Context::MAX) {
◆ operator delete()
static void Context::operator delete |
( |
void * |
ptr | ) |
|
|
static |
◆ fill_request_buffer()
Append pbuf to request_buffer.
18 if (request_buffer ==
nullptr) {
23 if (request_buffer ==
nullptr) {
27 for (
auto it = p; it !=
nullptr; it = it->next) {
28 uint16_t
len = it->len;
32 std::strncpy(request_buffer + request_buffer_size,
33 reinterpret_cast<char *>(it->payload),
len);
34 request_buffer_size +=
len;
◆ find_eoh()
size_t Context::find_eoh |
( |
const void * |
data = nullptr , |
|
|
size_t |
length = 0 |
|
) |
| |
Try to find End Of Header (\r
\r
) in buffer.
- Returns
- position in data of \r
\r
. Return value can't be less then MINIMAL_REQUEST_LENGTH. If EOH sequence is not found, zero is returned.
40 if (
data ==
nullptr) {
41 data = request_buffer;
42 length = request_buffer_size;
◆ parse_request()
err_t Context::parse_request |
( |
const void * |
data = nullptr , |
|
|
size_t |
length = 0 |
|
) |
| |
parste the request header (request line + request headers)
Parse and set request method and uri from input buffer.
111 if (request_buffer !=
nullptr) {
112 data = request_buffer;
113 length = request_buffer_size;
129 while (
end !=
nullptr) {
◆ prepare_response()
err_t Context::prepare_response |
( |
| ) |
|
Process message.response to internal buffer.
◆ prepare_header()
err_t Context::prepare_header |
( |
| ) |
|
Process message.headers to internal buffer.
185 if (header->
next ==
nullptr) {
◆ free_buffer()
void Context::free_buffer |
( |
| ) |
|
◆ pcb
struct tcp_pcb* Context::pcb |
◆ retries
◆ state
◆ env
Request WSAPI environment
◆ message
Last message returned from application
◆ buffer
Buffer for internal output data
◆ m_position
size_t Context::m_position |
Position of data in last message which is write not yet.
◆ end_of_header
size_t Context::end_of_header |
◆ response
Response object with generator function.
u16_t len
Definition: pbuf.h:159
const char * response
Definition: lwsapi_app.hpp:212
State state
Definition: connection.hpp:30
Message_t message
Definition: connection.hpp:32
Definition: connection.hpp:24
#define MAX_HTTP_REQUEST
LwIP WSAPI C/C++ implementation.
Definition: lwsapi_app.hpp:33
start
Definition: g29_auto.py:150
uint8_t data[8]
Definition: masstorage.h:49
Definition: connection.hpp:23
uint8_t i
Definition: screen_test_graph.c:72
#define lwsapi_error
Definition: lwsapi_app.hpp:42
#define CRLF
Definition: connection.hpp:7
#define memlen(start, end)
return lenght of data from start to end
Definition: connection.hpp:16
void * mem_calloc(mem_size_t count, mem_size_t size)
Definition: mem.c:765
end
Definition: createSpeedLookupTable.py:33
uint8_t retries
Definition: connection.hpp:29
#define chrshift(ptr, size)
Definition: connection.hpp:12
struct tcp_pcb * pcb
Definition: connection.hpp:28
IResponse::unique_ptr_t response
Definition: connection.hpp:37
Definition: connection.hpp:25
size_t end_of_header
Definition: connection.hpp:36
#define MINIMAL_REQUEST_LENGTH
Definition: connection.hpp:8
#define lwsapi_free(arg)
Definition: lwsapi_app.hpp:44
size_t m_position
Definition: connection.hpp:34
void * mem_malloc(mem_size_t size)
Definition: mem.c:603
static const char * HTTP_10
Definition: connection.cpp:8
png_uint_32 length
Definition: png.c:2247
void mem_free(void *rmem)
Definition: mem.c:419
#define memshift(ptr, size)
Definition: connection.hpp:10
const IHeader * headers
Definition: lwsapi_app.hpp:213
static png_bytep size_t size
Definition: pngwrite.c:2170
char * buffer
Definition: connection.hpp:33