Tizen RT Libs&Environment  v1.0 D5
webclient.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
30 #ifndef __APPS_INCLUDE_NETUTILS_WEBCLIENT_H
31 #define __APPS_INCLUDE_NETUTILS_WEBCLIENT_H
32 
33 /****************************************************************************
34  * Included Files
35  ****************************************************************************/
36 
37 #include <tinyara/config.h>
38 #include <sys/types.h>
39 
40 #ifdef CONFIG_NET_SECURITY_TLS
41 #include "tls/config.h"
42 #include "tls/entropy.h"
43 #include "tls/ctr_drbg.h"
44 #include "tls/certs.h"
45 #include "tls/x509.h"
46 #include "tls/ssl.h"
47 #include "tls/net.h"
48 #include "tls/error.h"
49 #include "tls/debug.h"
50 #include "tls/ssl_cache.h"
51 #endif
52 
53 #include <apps/netutils/webserver/http_keyvalue_list.h>
54 
55 /****************************************************************************
56  * Pre-processor Definitions
57  ****************************************************************************/
58 
59 #define WGET_MODE_GET 0
60 #define WGET_MODE_POST 1
61 #define WGET_MODE_PUT 2
62 #define WGET_MODE_DELETE 3
63 
64 #define CONTENT_LENGTH 0
65 #define CHUNKED_ENCODING 1
66 
67 #define WEBCLIENT_CONF_MAX_URL_SIZE 50
68 #define WEBCLIENT_CONF_MAX_ENTITY_SIZE 2048
69 #define WEBCLIENT_CONF_MAX_PHRASE_SIZE 50
70 #define WEBCLIENT_CONF_MAX_MESSAGE_SIZE 2100
71 
72 #define WEBCLIENT_CONF_TIMEOUT_MSEC 5000
73 #define WEBCLIENT_CONF_MIN_TLS_MEMORY 100000
74 
75 /****************************************************************************
76  * Public types
77  ****************************************************************************/
78 
80 typedef void (*wget_callback_t)(httprsp);
81 
82 #ifdef CONFIG_NET_SECURITY_TLS
83 
87  int client_fd;
88  mbedtls_ssl_context tls_ssl;
89  mbedtls_net_context tls_client_fd;
90 
91  int tls_init;
92  mbedtls_ssl_config tls_conf;
93  mbedtls_entropy_context tls_entropy;
94  mbedtls_ctr_drbg_context tls_ctr_drbg;
95  mbedtls_x509_crt tls_clicert;
96  mbedtls_pk_context tls_pkey;
97  mbedtls_ssl_session tls_session;
98 };
99 
104 #ifdef CONFIG_HW_RSA_SIGN
105  unsigned int ca_key_index;
106  unsigned int dev_key_index;
107  unsigned int ca_cert_index;
108  unsigned int dev_cert_index;
109 #else
110  char *root_ca;
111  char *dev_cert;
112  char *private_key;
113  unsigned int root_ca_len;
114  unsigned int dev_cert_len;
115  unsigned int private_key_len;
116 #endif /* CONFIG_HW_RSA_SIGN */
117 };
118 
119 #endif
120 
125  int method;
126  char *url;
127  int buflen;
128  int encoding;
129  char *entity;
132 #ifdef CONFIG_NET_SECURITY_TLS
133  struct http_client_ssl_config_t ssl_config;
134 #endif
135 };
136 
141  int method;
142  char *url;
143  int status;
144  char *phrase;
146  char *message;
147  char *entity;
148  unsigned int entity_len;
149 };
150 
151 /****************************************************************************
152  * Public Function Prototypes
153  ****************************************************************************/
154 
155 #ifdef __cplusplus
156 #define EXTERN extern "C"
157 extern "C" {
158 #else
159 #define EXTERN extern
160 #endif
161 
174 int http_client_send_request(struct http_client_request_t *request, struct http_client_ssl_config_t *ssl_config, struct http_client_response_t *response);
175 
189 
200 
210 
211 #undef EXTERN
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif /* __APPS_INCLUDE_NETUTILS_WEBCLIENT_H */
217 
void http_client_response_release(struct http_client_response_t *response)
http_client_response_release() releases the response structure.
mbedtls_pk_context tls_pkey
Definition: webclient.h:96
mbedtls_ssl_config tls_conf
Definition: webclient.h:92
mbedtls_ctr_drbg_context tls_ctr_drbg
Definition: webclient.h:94
HTTP request structure.
Definition: webclient.h:124
mbedtls_x509_crt tls_clicert
Definition: webclient.h:95
unsigned int private_key_len
Definition: webclient.h:115
mbedtls_ssl_session tls_session
Definition: webclient.h:97
struct http_keyvalue_list_t * headers
Definition: webclient.h:145
mbedtls_net_context tls_client_fd
Definition: webclient.h:89
struct http_keyvalue_list_t * headers
Definition: webclient.h:131
SSL configure structure.
Definition: webclient.h:103
int http_client_response_init(struct http_client_response_t *response)
http_client_response_init() initializes the response structure.
unsigned int root_ca_len
Definition: webclient.h:113
mbedtls_entropy_context tls_entropy
Definition: webclient.h:93
HTTP client TLS structure.
Definition: webclient.h:86
struct http_client_response_t * httprsp
Definition: webclient.h:79
HTTP response structure.
Definition: webclient.h:140
mbedtls_ssl_context tls_ssl
Definition: webclient.h:88
wget_callback_t callback
Definition: webclient.h:130
HTTP keyvalue linked list structure.
int http_client_send_request_async(struct http_client_request_t *request, struct http_client_ssl_config_t *ssl_config, wget_callback_t cb)
http_client_send_request_async() sends the HTTP request to HTTP server with asynchronous function...
unsigned int entity_len
Definition: webclient.h:148
int http_client_send_request(struct http_client_request_t *request, struct http_client_ssl_config_t *ssl_config, struct http_client_response_t *response)
http_client_send_request() sends the HTTP request to HTTP server with synchronous function...
unsigned int dev_cert_len
Definition: webclient.h:114
void(* wget_callback_t)(httprsp)
Definition: webclient.h:80