Skip to content

Commit 4ab8291

Browse files
committed
Fix libwebsockets build
1 parent 78afc47 commit 4ab8291

9 files changed

+37
-4
lines changed

lib/mosquitto_internal.h

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct mosquitto__client_msg;
6363
#endif
6464

6565
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
66+
# include <libwebsockets.h>
6667
# define WS_PACKET_OFFSET LWS_PRE
6768
#else
6869
# define WS_PACKET_OFFSET 16

lib/net_mosq.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int net__socket_close(struct mosquitto *mosq)
203203

204204
assert(mosq);
205205
#ifdef WITH_TLS
206-
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
206+
#if defined(WITH_BROKER) && defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
207207
if(!mosq->wsi)
208208
#endif
209209
{
@@ -217,7 +217,7 @@ int net__socket_close(struct mosquitto *mosq)
217217
}
218218
#endif
219219

220-
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
220+
#if defined(WITH_BROKER) && defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
221221
if(mosq->wsi)
222222
{
223223
if(mosq->state != mosq_cs_disconnecting){

src/conf.c

+8
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,10 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
16061606
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: $CONTROL support not available (enable_control_api).");
16071607
#endif
16081608
}else if(!strcmp(token, "enable_proxy_protocol")){
1609+
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
1610+
log__printf(NULL, MOSQ_LOG_ERR, "Error: PROXY support not available with libwebsockets.");
1611+
return MOSQ_ERR_INVAL;
1612+
#endif
16091613
REQUIRE_LISTENER(token);
16101614
if(conf__parse_int(&token, "enable_proxy_protocol", &cur_listener->enable_proxy_protocol, &saveptr)) return MOSQ_ERR_INVAL;
16111615
if(cur_listener->enable_proxy_protocol < 1 || cur_listener->enable_proxy_protocol > 2){
@@ -2148,6 +2152,10 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
21482152
return MOSQ_ERR_INVAL;
21492153
}
21502154
}else if(!strcmp(token, "proxy_protocol_v2_require_tls")){
2155+
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
2156+
log__printf(NULL, MOSQ_LOG_ERR, "Error: PROXY support not available with libwebsockets.");
2157+
return MOSQ_ERR_INVAL;
2158+
#endif
21512159
REQUIRE_LISTENER(token);
21522160
if(conf__parse_bool(&token, "proxy_protocol_v2_require_tls", &cur_listener->proxy_protocol_v2_require_tls, &saveptr)) return MOSQ_ERR_INVAL;
21532161
}else if(!strcmp(token, "psk_file")){

src/mux_epoll.c

+6
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,15 @@ static void loop_handle_reads_writes(struct mosquitto *context, uint32_t events)
262262
rc = http__write(context);
263263
break;
264264
#endif
265+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
266+
/* Not supported with LWS */
265267
case mosq_t_proxy_v2:
266268
rc = packet__write(context);
267269
break;
268270
case mosq_t_proxy_v1:
269271
rc = packet__write(context);
270272
break;
273+
#endif
271274
default:
272275
rc = MOSQ_ERR_INVAL;
273276
break;
@@ -295,12 +298,15 @@ static void loop_handle_reads_writes(struct mosquitto *context, uint32_t events)
295298
rc = http__read(context);
296299
break;
297300
#endif
301+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
302+
/* Not supported with LWS */
298303
case mosq_t_proxy_v2:
299304
rc = proxy_v2__read(context);
300305
break;
301306
case mosq_t_proxy_v1:
302307
rc = proxy_v1__read(context);
303308
break;
309+
#endif
304310
default:
305311
rc = MOSQ_ERR_INVAL;
306312
break;

src/mux_kqueue.c

+6
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,15 @@ static void loop_handle_reads_writes(struct mosquitto *context, short event)
265265
rc = http__write(context);
266266
break;
267267
#endif
268+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
269+
/* Not supported with LWS */
268270
case mosq_t_proxy_v2:
269271
rc = packet__write(context);
270272
break;
271273
case mosq_t_proxy_v1:
272274
rc = packet__write(context);
273275
break;
276+
#endif
274277
default:
275278
rc = MOSQ_ERR_INVAL;
276279
break;
@@ -298,12 +301,15 @@ static void loop_handle_reads_writes(struct mosquitto *context, short event)
298301
rc = http__read(context);
299302
break;
300303
#endif
304+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
305+
/* Not supported with LWS */
301306
case mosq_t_proxy_v2:
302307
rc = proxy_v2__read(context);
303308
break;
304309
case mosq_t_proxy_v1:
305310
rc = proxy_v1__read(context);
306311
break;
312+
#endif
307313
default:
308314
rc = MOSQ_ERR_INVAL;
309315
break;

src/mux_poll.c

+6
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,15 @@ static void loop_handle_reads_writes(void)
324324
rc = http__write(context);
325325
break;
326326
#endif
327+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
328+
/* Not supported with LWS */
327329
case mosq_t_proxy_v2:
328330
rc = packet__write(context);
329331
break;
330332
case mosq_t_proxy_v1:
331333
rc = packet__write(context);
332334
break;
335+
#endif
333336
default:
334337
rc = MOSQ_ERR_INVAL;
335338
break;
@@ -369,12 +372,15 @@ static void loop_handle_reads_writes(void)
369372
rc = http__read(context);
370373
break;
371374
#endif
375+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
376+
/* Not supported with LWS */
372377
case mosq_t_proxy_v2:
373378
rc = proxy_v2__read(context);
374379
break;
375380
case mosq_t_proxy_v1:
376381
rc = proxy_v1__read(context);
377382
break;
383+
#endif
378384
default:
379385
rc = MOSQ_ERR_INVAL;
380386
break;

src/proxy_v1.c

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "mosquitto_internal.h"
1010
#include "net_mosq.h"
1111

12+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
13+
1214
#define PROXY_V1_PACKET_LIMIT 108
1315

1416
const uint8_t signature4[11] = {'P', 'R', 'O', 'X', 'Y', ' ', 'T', 'C', 'P', '4', ' '};
@@ -153,3 +155,4 @@ int proxy_v1__read(struct mosquitto *context)
153155

154156
return MOSQ_ERR_SUCCESS;
155157
}
158+
#endif

src/proxy_v2.c

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "mosquitto_internal.h"
99
#include "net_mosq.h"
1010

11+
#if !defined(WITH_WEBSOCKETS) || WITH_WEBSOCKETS == WS_IS_BUILTIN
12+
1113
#define PROXY_CMD_LOCAL 0x00
1214
#define PROXY_CMD_PROXY 0x01
1315

@@ -304,3 +306,4 @@ int proxy_v2__read(struct mosquitto *context)
304306

305307
return MOSQ_ERR_SUCCESS;
306308
}
309+
#endif

src/websockets.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,9 @@ void mosq_websockets_init(struct mosquitto__listener *listener, const struct mos
700700
if(listener->socket_domain == AF_INET){
701701
info.options |= LWS_SERVER_OPTION_DISABLE_IPV6;
702702
}
703-
info.max_http_header_data = conf->websockets_headers_size;
703+
info.max_http_header_data = conf->packet_buffer_size;
704704

705-
user = mosquitto__calloc(1, sizeof(struct libws_mqtt_hack));
705+
user = mosquitto_calloc(1, sizeof(struct libws_mqtt_hack));
706706
if(!user){
707707
mosquitto_FREE(p);
708708
log__printf(NULL, MOSQ_LOG_ERR, "Out of memory.");

0 commit comments

Comments
 (0)