7#ifndef ZEPHYR_INCLUDE_NET_HTTP_SERVICE_H_
8#define ZEPHYR_INCLUDE_NET_HTTP_SERVICE_H_
58#define HTTP_RESOURCE_DEFINE(_name, _service, _resource, _detail) \
59 const STRUCT_SECTION_ITERABLE_ALTERNATE(http_resource_desc_##_service, http_resource_desc, \
61 .resource = _resource, \
62 .detail = (void *)(_detail), \
67struct http_service_desc {
75#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
77 size_t sec_tag_list_size;
81#define __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, _res_begin, \
83 const STRUCT_SECTION_ITERABLE(http_service_desc, _name) = { \
85 .port = (uint16_t *)(_port), \
86 .detail = (void *)(_detail), \
87 .concurrent = (_concurrent), \
88 .backlog = (_backlog), \
89 .res_begin = (_res_begin), \
90 .res_end = (_res_end), \
91 COND_CODE_1(CONFIG_NET_SOCKETS_SOCKOPT_TLS, \
92 (.sec_tag_list = COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), (NULL), \
93 (GET_ARG_N(1, __VA_ARGS__))),), ()) \
94 COND_CODE_1(CONFIG_NET_SOCKETS_SOCKOPT_TLS, \
95 (.sec_tag_list_size = COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), (0),\
96 (GET_ARG_N(1, GET_ARGS_LESS_N(1, __VA_ARGS__))))), ())\
120#define HTTP_SERVICE_DEFINE_EMPTY(_name, _host, _port, _concurrent, _backlog, _detail) \
121 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, NULL, NULL)
144#define HTTPS_SERVICE_DEFINE_EMPTY(_name, _host, _port, _concurrent, _backlog, _detail, \
145 _sec_tag_list, _sec_tag_list_size) \
146 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, NULL, NULL, \
147 _sec_tag_list, _sec_tag_list_size); \
148 BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
149 "TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
170#define HTTP_SERVICE_DEFINE(_name, _host, _port, _concurrent, _backlog, _detail) \
171 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
172 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
173 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
174 &_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
175 &_CONCAT(_http_resource_desc_##_name, _list_end)[0])
198#define HTTPS_SERVICE_DEFINE(_name, _host, _port, _concurrent, _backlog, _detail, \
199 _sec_tag_list, _sec_tag_list_size) \
200 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
201 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
202 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
203 &_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
204 &_CONCAT(_http_resource_desc_##_name, _list_end)[0], \
205 _sec_tag_list, _sec_tag_list_size); \
206 BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
207 "TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
214#define HTTP_SERVICE_COUNT(_dst) STRUCT_SECTION_COUNT(http_service_desc, _dst)
221#define HTTP_SERVICE_RESOURCE_COUNT(_service) ((_service)->res_end - (_service)->res_begin)
228#define HTTP_SERVICE_FOREACH(_it) STRUCT_SECTION_FOREACH(http_service_desc, _it)
238#define HTTP_RESOURCE_FOREACH(_service, _it) \
239 STRUCT_SECTION_FOREACH_ALTERNATE(http_resource_desc_##_service, http_resource_desc, _it)
250#define HTTP_SERVICE_FOREACH_RESOURCE(_service, _it) \
251 for (struct http_resource_desc *_it = (_service)->res_begin; ({ \
252 __ASSERT(_it <= (_service)->res_end, "unexpected list end location"); \
253 _it < (_service)->res_end; \
int sec_tag_t
Secure tag, a reference to TLS credential.
Definition tls_credentials.h:74
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
HTTP resource description.
Definition service.h:34
const char * resource
Resource name.
Definition service.h:36
void * detail
Detail associated with this resource.
Definition service.h:38
TLS credentials management.