WE310F5  39.00.000
m2mb_httpd.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
16 /*-----------------------------------------------------------------------------------------------*/
17 
18 #ifndef M2MB_HTTPD_API_H
19 #define M2MB_HTTPD_API_H
20 
30 /*-----------------------------------------------------------------------------------------------*/
31 
32 
37 /*-----------------------------------------------------------------------------------------------*/
38 /* Global declarations ==========================================================================*/
39 
40 #define M2MB_HTTPD_PATH_MAX 31
41 #define M2MB_HTTPD_SRVR_NAME_MAX 512
43 #define HTTP_OK 200
44 #define HTTP_CREATED 201
45 #define HTTP_ACCEPTED 202
46 #define HTTP_NO_CONTENT 204
47 #define HTTP_RESET_CONTENT 205
48 
49 /* http redirect codes: 3xx */
50 #define HTTP_REDIRECT_MULTI 300
51 #define HTTP_REDIRECT_PERM 301
52 #define HTTP_REDIRECT_TEMP 302
53 #define HTTP_REDIRECT_OTHER 303
54 #define HTTP_REDIRECT_NOMOD 304
55 #define HTTP_REDIRECT_PROXY 305
56 
57 /* Client errors: 4xx */
58 #define HTTP_ERROR_BADREQ 400
59 #define HTTP_ERROR_AUTHFAIL 401
60 #define HTTP_ERROR_PAYMENT 402
61 #define HTTP_ERROR_FORBID 403
62 #define HTTP_ERROR_NOFILE 404
63 #define HTTP_ERROR_METHOD 405
64 #define HTTP_ERROR_UNACCEPT 406
65 #define HTTP_ERROR_PROXYAUT 407
66 #define HTTP_ERROR_REQTMO 408
67 #define HTTP_ERROR_CONFLICT 409
68 #define HTTP_ERROR_RESGONE 410
69 #define HTTP_ERROR_LENGTH 411
70 #define HTTP_ERROR_PREFAIL 412
71 #define HTTP_ERROR_TOOBIG 413
72 #define HTTP_ERROR_URIBIG 414
73 #define HTTP_ERROR_BADMEDIA 415
74 
75 /* Server errors: 5xx */
76 #define HTTP_ERROR_SERVER 500
77 #define HTTP_ERROR_NOTIMPLEMENTED 501
78 #define HTTP_ERROR_BADGATEWAY 502
79 #define HTTP_ERROR_OVERLOAD 503
80 #define HTTP_ERROR_GATEAWYTMO 504
81 #define HTTP_ERROR_HTTPVER 505
82 
83 /* Global typedefs ==============================================================================*/
84 
90 typedef enum
91 {
92  FP_ERR = 0x110,
93  FP_OK = 0x120,
94  FP_FILE = 0x140,
95  FP_DONE = 0x200,
97 
104 typedef enum
105 {
110 
116 typedef enum
117 {
128 
134 typedef enum M2MB_URI_AUTH_FLAG
135 {
140 
147 {
167 
169 
176 typedef struct M2MB_HTTPD_CONFIG_S
177 {
231 
237 typedef struct M2MB_HTTPD_URI_CTX
238 {
242 
249 typedef struct M2MB_HTTPD_URI_REQ_INFO{
251  VOID *hp;
261 
271 
282 
356 typedef INT32 (*M2MB_HTTPD_URI_HANDLER_T)( VOID* conn_handle, VOID* usr_ctx, INT32 event );
357 
358 typedef struct M2MB_URI_CFG_S
359 {
360  UINT8 name[128];
362 
364 
366  void *appCtx; /* User context */
369 
370 
378 typedef enum M2MB_HTTPD_CONF_ID
379 {
380  //SET CONF IDs
385  //GET CONF IDs
394 
403  {
407 
416  {
423 
432  {
437 
446 {
450 
459 {
463 
472 {
476 
485  {
489 
498  {
502 
510 typedef struct M2MB_HTTPD_USER_INFO
511  {
516 
524 typedef union
525 {
537 
538 
539 /* External variables ===========================================================================*/
540 
541 /* External functions ===========================================================================*/
542 
543 /* Global functions =============================================================================*/
544 
545 /*-----------------------------------------------------------------------------------------------*/
590 /*-----------------------------------------------------------------------------------------------*/
592 
642 /*-----------------------------------------------------------------------------------------------*/
644 
697 /*-----------------------------------------------------------------------------------------------*/
699 
761 /*-----------------------------------------------------------------------------------------------*/
763 
764 /*-----------------------------------------------------------------------------------------------*/
857 /*-----------------------------------------------------------------------------------------------*/
859  UINT8 *content_type,
860  INT32 content_length,
861  INT32 status_code,
862  UINT8 *status_text,
863  UINT8 *user_headers );
864 
865 /*-----------------------------------------------------------------------------------------------*/
950 /*-----------------------------------------------------------------------------------------------*/
951 M2MB_STATUS_T m2mb_httpd_send_data( VOID *conn_handle, const INT8 *data, UINT32 length );
952 
953 
954 /*---------------------------------------------------------------------------*/
1088 /*---------------------------------------------------------------------------*/
1090 
1091 
1092 /*---------------------------------------------------------------------------*/
1227 /*---------------------------------------------------------------------------*/
1229 
1230 /*-----------------------------------------------------------------------------------------------*/
1296 /*-----------------------------------------------------------------------------------------------*/
1298 
1302 /*-----------------------------------------------------------------------------------------------*/
1303 
1304 
1305 #endif
M2MB_HTTPD_URI_REQ_CGI_FORM_DATA_T * cgi_form_data
Definition: m2mb_httpd.h:487
struct M2MB_HTTPD_GET_MSG_INFO M2MB_HTTPD_GET_MSG_INFO_T
The structure is used to GET the HEAD/BODY information.
CHAR root_Path[M2MB_HTTPD_PATH_MAX]
Definition: m2mb_httpd.h:195
M2MB_HTTPD_URI_CONFIG_PARAMS_T * uri_cfg_params
Definition: m2mb_httpd.h:527
M2MB_HTTPD_MODE_E
HTTP server operational mode enumeration.
Definition: m2mb_httpd.h:104
unsigned char UINT8
Definition: m2mb_types.h:86
M2MB_HTTPD_URI_USER_EVENT
HTTP server URI user event enumeration.
Definition: m2mb_httpd.h:146
M2MB_HTTPD_URI_REQ_CGI_KEY_PAIR_T nameval[1]
Definition: m2mb_httpd.h:280
CHAR interface_Name[8]
Definition: m2mb_httpd.h:178
M2MB_HTTPD_URI_HANDLER_T h
Definition: m2mb_httpd.h:363
CHAR cert_File[M2MB_HTTPD_PATH_MAX]
Definition: m2mb_httpd.h:199
struct M2MB_HTTPD_GET_REQUEST_TYPE M2MB_HTTPD_GET_REQUEST_TYPE_T
The structure is used to GET the request type on the connection handler.
CHAR root_Index_Page[M2MB_HTTPD_PATH_MAX]
Definition: m2mb_httpd.h:191
struct M2MB_HTTPD_USER_INFO M2MB_HTTPD_USER_INFO_T
The structure is used to GET/SET the user information on the HTTPD module.
M2MB_HTTPD_USER_INFO_T * user_info
Definition: m2mb_httpd.h:535
HTTP server URI Request structure.
Definition: m2mb_httpd.h:249
struct M2MB_HTTPD_GET_BODY_LOC M2MB_HTTPD_GET_BODY_LOC_T
The structure is used to GET the pointer to the body locaiton on the request.
INT32 M2MB_STATUS_T
Definition: m2mb_status.h:97
M2MB_SSL_CTXT_HANDLE ssl_handle
Definition: m2mb_httpd.h:405
M2MB_HTTPD_GET_CONTENT_LEN_T * get_content_len
Definition: m2mb_httpd.h:530
enum M2MB_HTTPD_CONF_ID M2MB_HTTPD_CONF_ID_E
HTTP server GET/SET Configuration enumeration.
struct M2MB_HTTPD_INIT_PARAMS M2MB_HTTPD_INIT_PARAMS_T
HTTPD initialization parameters.
M2MB_STATUS_T m2mb_httpd_get_cfg(HANDLE handle, M2MB_HTTPD_CONF_ID_E conf_id, M2MB_HTTPD_CONF_PARAMS_T *conf_params)
GET the HTTPD configuration parameters.
unsigned short UINT16
Definition: m2mb_types.h:87
enum M2MB_URI_AUTH_FLAG M2MB_URI_AUTH_FLAG_T
HTTP server URI user authentication enumeration.
This structure is used to set HTTPD URI configuration parameters.
Definition: m2mb_httpd.h:415
struct M2MB_HTTPD_CONFIG_S M2MB_HTTPD_CONFIG_T
HTTP server configuration structure.
struct M2MB_HTTPD_URI_REQ_CGI_FORM_DATA M2MB_HTTPD_URI_REQ_CGI_FORM_DATA_T
HTTP server CGI form data structure.
struct M2MB_HTTPD_URI_REQ_CGI_KEY_PAIR M2MB_HTTPD_URI_REQ_CGI_KEY_PAIR_T
HTTP server CGI parameter pair structure.
M2MB_URI_CFG_T * m2mb_httpd_get_uri_cfg_from_index(INT32 index)
Gets the URI configuration.
#define M2MB_HTTPD_PATH_MAX
Definition: m2mb_httpd.h:40
M2MB_HTTPD_CONF_ID
HTTP server GET/SET Configuration enumeration.
Definition: m2mb_httpd.h:378
M2MB_STATUS_T m2mb_httpd_start(HANDLE handle)
Start HTTP server.
The structure is used to GET the CGI form data with the URI request.
Definition: m2mb_httpd.h:484
char CHAR
Definition: m2mb_types.h:76
M2MB_HTTPD_CGI_RETURN_E
Return values enumeration.
Definition: m2mb_httpd.h:90
M2MB_HTTPD_MODE_E mode
Definition: m2mb_httpd.h:182
M2MB_HTTPD_GET_REQUEST_TYPE_T * get_request_type
Definition: m2mb_httpd.h:532
struct M2MB_HTTPD_URICTXT_FROM_INDEX M2MB_HTTPD_URICTXT_FROM_INDEX_T
The structure is used to GET the applicaiton context of the registered URI.
HTTP server CGI form data structure.
Definition: m2mb_httpd.h:277
struct M2MB_URI_CFG_S M2MB_URI_CFG_T
signed char INT8
Definition: m2mb_types.h:80
HTTP server URI context structure.
Definition: m2mb_httpd.h:237
M2MB_STATUS_T m2mb_httpd_stop(HANDLE handle)
Stop HTTP server.
void VOID
Definition: m2mb_types.h:74
M2MB_STATUS_T m2mb_httpd_init(HANDLE *handle, M2MB_HTTPD_INIT_PARAMS_T *init_params)
HTTP server deinitialization.
M2MB_URI_AUTH_FLAG
HTTP server URI user authentication enumeration.
Definition: m2mb_httpd.h:134
M2MB_STATUS_T m2mb_httpd_deinit(HANDLE handle)
HTTP server deinitialization.
struct M2MB_HTTPD_URI_CTX M2MB_HTTPD_URICTX_T
HTTP server URI context structure.
M2MB_HTTPD_GET_MSG_INFO_T * get_msg_info
Definition: m2mb_httpd.h:529
The structure is used to GET the content length of the request.
Definition: m2mb_httpd.h:445
M2MB_STATUS_T m2mb_httpd_set_cfg(HANDLE handle, M2MB_HTTPD_CONF_ID_E conf_id, M2MB_HTTPD_CONF_PARAMS_T *conf_params)
SET the HTTPD configuration parameters.
HTTPD initialization parameters.
Definition: m2mb_httpd.h:402
HTTP server CGI parameter pair structure.
Definition: m2mb_httpd.h:267
INT32(* M2MB_HTTPD_URI_HANDLER_T)(VOID *conn_handle, VOID *usr_ctx, INT32 event)
HTTP server URI Request user call back prototype.
Definition: m2mb_httpd.h:356
M2MB_STATUS_T m2mb_httpd_send_data(VOID *conn_handle, const INT8 *data, UINT32 length)
Send HTTP data.
M2MB_HTTPD_GET_REQ_URI_CGI_FORM_DATA_T * get_uri_cgi_form_data
Definition: m2mb_httpd.h:533
HTTP server configuration structure.
Definition: m2mb_httpd.h:176
M2MB_HTTPD_URICTXT_FROM_INDEX_T * get_uri_ctxt
Definition: m2mb_httpd.h:534
The structure is used to GET/SET the user information on the HTTPD module.
Definition: m2mb_httpd.h:510
unsigned long int UINT32
Definition: m2mb_types.h:88
The structure is used to GET the request type on the connection handler.
Definition: m2mb_httpd.h:471
struct M2MB_HTTPD_GET_CONTENT_LEN M2MB_HTTPD_GET_CONTENT_LEN_T
The structure is used to GET the content length of the request.
M2MB_HTTPD_METHOD_E
HTTP server request method enumeration.
Definition: m2mb_httpd.h:116
UINT8 name[128]
Definition: m2mb_httpd.h:360
signed int INT32
Definition: m2mb_types.h:82
The structure is used to GET the HEAD/BODY information.
Definition: m2mb_httpd.h:431
HANDLE M2MB_SSL_CTXT_HANDLE
SSL context handle. This is obtained from m2mb_ssl_open API and then used in subsequent SSL APIs...
Definition: m2mb_ssl.h:165
M2MB_HTTPD_URI_HANDLER_T fn_cb
Definition: m2mb_httpd.h:420
struct M2MB_HTTPD_URI_CONFIG_PARAMS M2MB_HTTPD_URI_CONFIG_PARAMS_T
This structure is used to set HTTPD URI configuration parameters.
void * HANDLE
Definition: m2mb_types.h:98
VOID(* webfiles_Setup)(void)
Definition: m2mb_httpd.h:208
M2MB_HTTPD_CONFIG_T * cfg
Definition: m2mb_httpd.h:404
M2MB_STATUS_T m2mb_httpd_send_headers(VOID *conn_handle, UINT8 *content_type, INT32 content_length, INT32 status_code, UINT8 *status_text, UINT8 *user_headers)
Send HTTP headers.
M2MB_HTTPD_GET_BODY_LOC_T * get_body_loc
Definition: m2mb_httpd.h:531
M2MB_URI_AUTH_FLAG_T flag
Definition: m2mb_httpd.h:419
The structure is used to GET the applicaiton context of the registered URI.
Definition: m2mb_httpd.h:497
The structure is used to GET the pointer to the body locaiton on the request.
Definition: m2mb_httpd.h:458
Structure is used by SET/GET configuration paramters of CONF IDs mentioned in enum M2MB_HTTPD_CONF_ID...
Definition: m2mb_httpd.h:524
struct M2MB_HTTPD_GET_REQ_URI_CGI_FORM_DATA M2MB_HTTPD_GET_REQ_URI_CGI_FORM_DATA_T
The structure is used to GET the CGI form data with the URI request.
enum M2MB_HTTPD_URI_USER_EVENT M2MB_HTTPD_URI_USER_EVENT_E
HTTP server URI user event enumeration.
struct M2MB_HTTPD_URI_REQ_INFO M2MB_HTTPD_URI_REQ_INFO_T
HTTP server URI Request structure.