CGI request function handlers.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include <lwip/ip.h>
#include <lwip/ip_addr.h>
#include <lwip/netif.h>
#include <lwip/tcpip.h>
#include <lwip/stats.h>
#include <lwip/opt.h>
#include "httpd.h"
#include "cgi.h"
#include "sysclk.h"
#include "conf_eth.h"
#include "lwip/memp_std.h"
Data Structures | |
struct | archnames |
Macros | |
#define | CGI_MATCH_EXT 2 /* Select item in table if the extention match */ |
#define | CGI_MATCH_NAME 3 /* Select item in table if the string is content */ |
#define | CGI_MATCH_NONE 0 |
#define | CGI_MATCH_WORD 1 /* Select item in table only if string match */ |
#define | CHIPID_ARCH |
#define | CHIPID_EPRCOC |
#define | CHIPID_NVPSIZ |
#define | CHIPID_NVTYP |
#define | CHIPID_SRAMSIZ |
#define | FREERTOS_STATS_BUFLEN 512 |
#define | IP_ADDR_TO_INT_TUPLE(addr) |
#define | LWIP_MEMPOOL(name, num, size, desc) desc, |
#define | TX_REQ_BUFLEN 1024 |
Functions | |
static int | cgi_chipInfo (struct netconn *client, const char *name, char *recv_buf, size_t recv_len) |
Send the chip ID information. More... | |
static int | cgi_error (struct netconn *client, const char *name, char *recv_buf, size_t recv_len) |
Used to handle unsupported CGI requests. More... | |
http_handler_t | cgi_search (const char *name, HttpCGI *table) |
CGI request search engine. More... | |
static int | cgi_status (struct netconn *client, const char *name, char *recv_buf, size_t recv_len) |
Send a JSON string representing the board status. More... | |
static const char * | chipid_archnames (unsigned value) |
Return the chip architecture name. More... | |
static const char * | chipid_eproc_name (int idx) |
Return the chip ID name. More... | |
static const char * | chipid_nvpsize (int idx) |
Return the non volatile programmable memory size. More... | |
static const char * | chipid_sramsize (int idx) |
Return the chip SRAM size. More... | |
Variables | |
static const char | _unknown [] = "unknown" |
static sys_sem_t | cgi_sem |
HttpCGI | cgi_table [] |
static struct archnames | chip_id_archnames [] |
static const char *const | chip_id_eproc_names [] |
static const char *const | chip_id_nvpsize [] |
static const char *const | chip_id_sramsize [] |
static int8_t | freertos_stats [FREERTOS_STATS_BUFLEN] |
static uint8_t | tx_buf [TX_REQ_BUFLEN] |
#define CGI_MATCH_EXT 2 /* Select item in table if the extention match */ |
Referenced by cgi_search().
Referenced by cgi_search().
#define CGI_MATCH_NONE 0 |
#define CGI_MATCH_WORD 1 /* Select item in table only if string match */ |
#define CHIPID_ARCH |
Referenced by cgi_chipInfo().
#define CHIPID_EPRCOC |
Referenced by cgi_chipInfo().
#define CHIPID_NVPSIZ |
Referenced by cgi_chipInfo().
#define CHIPID_NVTYP |
#define CHIPID_SRAMSIZ |
Referenced by cgi_chipInfo().
#define FREERTOS_STATS_BUFLEN 512 |
Referenced by cgi_status().
#define IP_ADDR_TO_INT_TUPLE | ( | addr | ) |
#define LWIP_MEMPOOL | ( | name, | |
num, | |||
size, | |||
desc | |||
) | desc, |
#define TX_REQ_BUFLEN 1024 |
|
static |
Send the chip ID information.
name | Not used. |
recv_buf | Receive buffer. |
recv_len | Receive buffer length. |
References CHIPID_ARCH, chipid_archnames(), CHIPID_EPRCOC, chipid_eproc_name(), CHIPID_NVPSIZ, chipid_nvpsize, CHIPID_SRAMSIZ, chipid_sramsize, HTTP_CONTENT_JSON, http_sendOk(), sys_arch_sem_wait(), sys_sem_signal(), and tx_buf.
|
static |
Used to handle unsupported CGI requests.
name | Not used. |
recv_buf | Receive buffer. |
recv_len | Receive buffer length. |
http_handler_t cgi_search | ( | const char * | name, |
HttpCGI * | table | ||
) |
CGI request search engine.
name | CGI request name. |
table | CGI handler table. |
References CGI_MATCH_EXT, CGI_MATCH_NAME, get_ext(), HttpCGI::handler, NULL, sys_sem_new(), and sys_sem_valid().
Referenced by http_request().
|
static |
Send a JSON string representing the board status.
name | Not used. |
recv_buf | Receive buffer. |
recv_len | Receive buffer length. |
References freertos_stats, FREERTOS_STATS_BUFLEN, HTTP_CONTENT_JSON, http_sendOk(), IP_ADDR_TO_INT_TUPLE, MEMP_MAX, status, sys_arch_sem_wait(), sys_sem_signal(), tx_buf, vTaskGetRunTimeStats(), and xTaskGetTickCount().
|
static |
Return the chip architecture name.
idx | Index in the chip_id_archnames table. |
References _unknown, chip_id_archnames, and archnames::name.
Referenced by cgi_chipInfo().
|
static |
Return the chip ID name.
idx | Index in the chip_id_eproc_names table. |
References _unknown, and chip_id_eproc_names.
Referenced by cgi_chipInfo().
|
static |
Return the non volatile programmable memory size.
idx | Index in the chip_id_nvpsize table. |
References _unknown, and chip_id_nvpsize.
|
static |
Return the chip SRAM size.
idx | Index in the chip_id_sramsize table. |
References _unknown, and chip_id_sramsize.
|
static |
Referenced by chipid_archnames(), chipid_eproc_name(), chipid_nvpsize(), and chipid_sramsize().
|
static |
HttpCGI cgi_table[] |
Referenced by http_request().
|
static |
Referenced by chipid_archnames().
|
static |
Referenced by chipid_eproc_name().
|
static |
|
static |
Referenced by chipid_sramsize().
|
static |
Referenced by cgi_status().
|
static |
Referenced by cgi_chipInfo(), and cgi_status().