7#ifndef ZEPHYR_INCLUDE_NET_HTTP_SERVICE_H_
8#define ZEPHYR_INCLUDE_NET_HTTP_SERVICE_H_
56#define HTTP_RESOURCE_DEFINE(_name, _service, _resource, _detail) \
57 const STRUCT_SECTION_ITERABLE_ALTERNATE(http_resource_desc_##_service, http_resource_desc, \
59 .resource = _resource, \
60 .detail = (void *)(_detail), \
65struct http_service_desc {
73#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
75 size_t sec_tag_list_size;
79#define __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, _res_begin, \
81 static const STRUCT_SECTION_ITERABLE(http_service_desc, _name) = { \
83 .port = (uint16_t *)(_port), \
84 .detail = (void *)(_detail), \
85 .concurrent = (_concurrent), \
86 .backlog = (_backlog), \
87 .res_begin = (_res_begin), \
88 .res_end = (_res_end), \
89 COND_CODE_1(CONFIG_NET_SOCKETS_SOCKOPT_TLS, \
90 (.sec_tag_list = COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), (NULL), \
91 (GET_ARG_N(1, __VA_ARGS__))),), ()) \
92 COND_CODE_1(CONFIG_NET_SOCKETS_SOCKOPT_TLS, \
93 (.sec_tag_list_size = COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), (0),\
94 (GET_ARG_N(1, GET_ARGS_LESS_N(1, __VA_ARGS__))))), ())\
117#define HTTP_SERVICE_DEFINE_EMPTY(_name, _host, _port, _concurrent, _backlog, _detail) \
118 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, NULL, NULL)
140#define HTTPS_SERVICE_DEFINE_EMPTY(_name, _host, _port, _concurrent, _backlog, _detail, \
141 _sec_tag_list, _sec_tag_list_size) \
142 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, NULL, NULL, \
143 _sec_tag_list, _sec_tag_list_size); \
144 BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
145 "TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
165#define HTTP_SERVICE_DEFINE(_name, _host, _port, _concurrent, _backlog, _detail) \
166 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
167 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
168 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
169 &_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
170 &_CONCAT(_http_resource_desc_##_name, _list_end)[0])
192#define HTTPS_SERVICE_DEFINE(_name, _host, _port, _concurrent, _backlog, _detail, \
193 _sec_tag_list, _sec_tag_list_size) \
194 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
195 extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
196 __z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
197 &_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
198 &_CONCAT(_http_resource_desc_##_name, _list_end)[0], \
199 _sec_tag_list, _sec_tag_list_size); \
200 BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
201 "TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
208#define HTTP_SERVICE_COUNT(_dst) STRUCT_SECTION_COUNT(http_service_desc, _dst)
215#define HTTP_SERVICE_RESOURCE_COUNT(_service) ((_service)->res_end - (_service)->res_begin)
222#define HTTP_SERVICE_FOREACH(_it) STRUCT_SECTION_FOREACH(http_service_desc, _it)
232#define HTTP_RESOURCE_FOREACH(_service, _it) \
233 STRUCT_SECTION_FOREACH_ALTERNATE(http_resource_desc_##_service, http_resource_desc, _it)
244#define HTTP_SERVICE_FOREACH_RESOURCE(_service, _it) \
245 for (struct http_resource_desc *_it = (_service)->res_begin; ({ \
246 __ASSERT(_it <= (_service)->res_end, "unexpected list end location"); \
247 _it < (_service)->res_end; \
int sec_tag_t
Secure tag, a reference to TLS credential.
Definition: tls_credentials.h:72
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
HTTP resource description.
Definition: service.h:32
const char * resource
Resource name.
Definition: service.h:34
void * detail
Detail associated with this resource.
Definition: service.h:36
TLS credentials management.