@@ -68,6 +68,8 @@ struct http_resource_desc {
68
68
struct http_service_runtime_data {
69
69
int num_clients ;
70
70
};
71
+
72
+ typedef int (* http_socket_create_fn )(const struct http_service_desc * svc , int af , int proto );
71
73
72
74
struct http_service_desc {
73
75
const char * host ;
@@ -84,6 +86,7 @@ struct http_service_desc {
84
86
const sec_tag_t * sec_tag_list ;
85
87
size_t sec_tag_list_size ;
86
88
#endif
89
+ http_socket_create_fn socket_create ;
87
90
};
88
91
89
92
#define __z_http_service_define (_name , _host , _port , _concurrent , _backlog , _detail , \
@@ -110,6 +113,7 @@ struct http_service_desc {
110
113
COND_CODE_1(CONFIG_NET_SOCKETS_SOCKOPT_TLS, \
111
114
(.sec_tag_list_size = COND_CODE_0(NUM_VA_ARGS_LESS_1(__VA_ARGS__), (0),\
112
115
(GET_ARG_N(1, GET_ARGS_LESS_N(1, __VA_ARGS__))))), ())\
116
+ .socket_create = GET_ARG_N(3, __VA_ARGS__, NULL, NULL, NULL), \
113
117
}
114
118
115
119
/** @endcond */
@@ -135,9 +139,9 @@ struct http_service_desc {
135
139
* @param _res_fallback Fallback resource to be served if no other resource matches path
136
140
*/
137
141
#define HTTP_SERVICE_DEFINE_EMPTY (_name , _host , _port , _concurrent , _backlog , _detail , \
138
- _res_fallback ) \
142
+ _res_fallback , ... ) \
139
143
__z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
140
- _res_fallback, NULL, NULL)
144
+ _res_fallback, NULL, NULL, __VA_ARGS__ )
141
145
142
146
/**
143
147
* @brief Define an HTTPS service without static resources.
@@ -162,10 +166,10 @@ struct http_service_desc {
162
166
* @param _sec_tag_list_size TLS security tag list size used to setup a HTTPS socket.
163
167
*/
164
168
#define HTTPS_SERVICE_DEFINE_EMPTY (_name , _host , _port , _concurrent , _backlog , _detail , \
165
- _res_fallback , _sec_tag_list , _sec_tag_list_size ) \
169
+ _res_fallback , _sec_tag_list , _sec_tag_list_size , ... ) \
166
170
__z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
167
171
_res_fallback, NULL, NULL, \
168
- _sec_tag_list, _sec_tag_list_size); \
172
+ _sec_tag_list, _sec_tag_list_size, __VA_ARGS__ ); \
169
173
BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
170
174
"TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
171
175
@@ -189,13 +193,13 @@ struct http_service_desc {
189
193
* @param _detail User-defined detail associated with the service.
190
194
* @param _res_fallback Fallback resource to be served if no other resource matches path
191
195
*/
192
- #define HTTP_SERVICE_DEFINE (_name , _host , _port , _concurrent , _backlog , _detail , _res_fallback ) \
196
+ #define HTTP_SERVICE_DEFINE (_name , _host , _port , _concurrent , _backlog , _detail , _res_fallback , ... ) \
193
197
extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
194
198
extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
195
199
__z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
196
200
_res_fallback, \
197
201
&_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
198
- &_CONCAT(_http_resource_desc_##_name, _list_end)[0]);
202
+ &_CONCAT(_http_resource_desc_##_name, _list_end)[0], __VA_ARGS__)
199
203
200
204
/**
201
205
* @brief Define an HTTPS service with static resources.
@@ -220,14 +224,14 @@ struct http_service_desc {
220
224
* @param _sec_tag_list_size TLS security tag list size used to setup a HTTPS socket.
221
225
*/
222
226
#define HTTPS_SERVICE_DEFINE (_name , _host , _port , _concurrent , _backlog , _detail , \
223
- _res_fallback , _sec_tag_list , _sec_tag_list_size ) \
227
+ _res_fallback , _sec_tag_list , _sec_tag_list_size , ... ) \
224
228
extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_start)[]; \
225
229
extern struct http_resource_desc _CONCAT(_http_resource_desc_##_name, _list_end)[]; \
226
230
__z_http_service_define(_name, _host, _port, _concurrent, _backlog, _detail, \
227
231
_res_fallback, \
228
232
&_CONCAT(_http_resource_desc_##_name, _list_start)[0], \
229
233
&_CONCAT(_http_resource_desc_##_name, _list_end)[0], \
230
- _sec_tag_list, _sec_tag_list_size); \
234
+ _sec_tag_list, _sec_tag_list_size, __VA_ARGS__ ); \
231
235
BUILD_ASSERT(IS_ENABLED(CONFIG_NET_SOCKETS_SOCKOPT_TLS), \
232
236
"TLS is required for HTTP secure (CONFIG_NET_SOCKETS_SOCKOPT_TLS)")
233
237
0 commit comments