35 #ifndef __http_server_h__ 36 #define __http_server_h__ 46 #include <netinet/in.h> 48 #ifdef CONFIG_NETUTILS_WEBSOCKET 49 #include <apps/netutils/websocket.h> 52 #ifdef CONFIG_NET_SECURITY_TLS 53 #include "tls/config.h" 54 #include "tls/entropy.h" 55 #include "tls/ctr_drbg.h" 56 #include "tls/certs.h" 60 #include "tls/error.h" 61 #include "tls/debug.h" 62 #include "tls/ssl_cache.h" 69 #define HTTP_METHOD_UNKNOWN -1 70 #define HTTP_METHOD_GET 0 71 #define HTTP_METHOD_PUT 1 72 #define HTTP_METHOD_POST 2 73 #define HTTP_METHOD_DELETE 3 75 #define HTTP_HTTP_VERSION_UNKNOWN 0 76 #define HTTP_HTTP_VERSION_09 9 77 #define HTTP_HTTP_VERSION_10 10 78 #define HTTP_HTTP_VERSION_11 11 80 #define HTTP_CONTENT_LENGTH 0 81 #define HTTP_CHUNKED_ENCODING 1 83 #define HTTP_CONF_MAX_CLIENT 16 84 #define HTTP_CONF_CLIENT_STACKSIZE 8192 85 #define HTTP_CONF_MIN_TLS_MEMORY 80000 86 #define HTTP_CONF_SOCKET_TIMEOUT_MSEC 5000 87 #define HTTP_CONF_MAX_CLIENT_HANDLE 2 88 #define HTTP_CONF_SERVER_MQ_MAX_MSG 10 89 #define HTTP_CONF_SERVER_MQ_PRIO 50 90 #define HTTP_CONF_SERVER_SIGWAKEUP 18 92 #define HTTP_CONF_MAX_REQUEST_LENGTH 2048 93 #define HTTP_CONF_MAX_REQUEST_LINE_LENGTH 256 94 #define HTTP_CONF_MAX_REQUEST_HEADER_URL_LENGTH 128 95 #define HTTP_CONF_MAX_URL_QUERY_LENGTH 64 96 #define HTTP_CONF_MAX_URL_PARAMS_LENGTH 256 97 #define HTTP_CONF_MAX_KEY_LENGTH 32 98 #define HTTP_CONF_MAX_VALUE_LENGTH 256 99 #define HTTP_CONF_MAX_DIVIDED_PATH_LENGTH 32 100 #define HTTP_CONF_MAX_SLASH_COUNT 32 101 #define HTTP_CONF_MAX_QUERY_HANDLER_COUNT 64 102 #define HTTP_CONF_MAX_ENTITY_LENGTH 2048 104 #define HTTP_ERROR_400 "Bad Request" 105 #define HTTP_ERROR_404 "Not Found" 106 #define HTTP_ERROR_500 "Internal Server Error" 112 struct http_client_t;
120 #ifdef CONFIG_HW_RSA_SIGN 121 unsigned int ca_key_index;
122 unsigned int dev_key_index;
123 unsigned int ca_cert_index;
124 unsigned int dev_cert_index;
175 #ifdef CONFIG_NET_SECURITY_TLS 186 struct sockaddr_in servaddr;
188 struct http_query_handler_t
190 #ifdef CONFIG_NETUTILS_WEBSOCKET 287 #ifdef CONFIG_NET_SECURITY_TLS
mbedtls_x509_crt tls_srvcert
void(* http_cb_t)(struct http_client_t *client, struct http_req_message *msg)
typedef for callback function.
int http_server_stop(struct http_server_t *server)
http_server_stop() stops the webserver. Both HTTP server and HTTPS server are stoped by this function...
int http_server_deregister_cb(struct http_server_t *server, int method, const char *url_format)
http_server_deregister_cb() deregisters the cb function to each method on webserver.
struct http_keyvalue_list_t * headers
FAR struct mq_des * mqd_t
mbedtls_pk_context tls_pkey
mbedtls_net_context tls_ctx
mbedtls_ctr_drbg_context tls_ctr_drbg
unsigned int private_key_len
#define HTTP_CONF_MAX_QUERY_HANDLER_COUNT
int http_server_register_cb(struct http_server_t *server, int method, const char *url_format, http_cb_t func)
http_server_register_cb() registers the cb function to each method on webserver.
mbedtls_ssl_cache_context tls_cache
synchronous I/O multiplexing APIs
int http_server_start(struct http_server_t *server)
http_server_start() starts the webserver.
unsigned int dev_cert_len
mbedtls_entropy_context tls_entropy
Standard Input / Output APIs.
http_server_state_t state
int http_tls_init(struct http_server_t *server, struct ssl_config_t *ssl_config)
http_tls_init() initializes the TLS configuere for webserver.
Structure of generic semaphore.
int http_send_response(struct http_client_t *client, int status, const char *body, struct http_keyvalue_list_t *headers)
http_send_response() sends the response. If receive request, you must send a response by this functio...
mbedtls_ssl_config tls_conf
struct http_server_t * http_server_init(int port)
http_server_init() initializes the webserver.
http server ssl config structure.
#define HTTP_CONF_MAX_CLIENT_HANDLE
HTTP keyvalue linked list structure.
#define websocket_cb_t
Websocket structure wrapper to carry call back pointers.
void http_server_release(struct http_server_t **server)
http_server_release() releases the struct http_server_t.