Commit d9b7ec18 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot

Add MG_F_ENABLE_BROADCAST option

PUBLISHED_FROM=293a54ab09e6879b6f0c36975a137eeaeff92098
parent ffed9c4d
......@@ -59,6 +59,7 @@ signature: |
#define MG_F_CLOSE_IMMEDIATELY (1 << 11) /* Disconnect */
#define MG_F_WEBSOCKET_NO_DEFRAG (1 << 12) /* Websocket specific */
#define MG_F_DELETE_CHUNK (1 << 13) /* HTTP specific */
#define MG_F_ENABLE_BROADCAST (1 << 14) /* Allow broadcast address usage */
#define MG_F_USER_1 (1 << 20) /* Flags left for application */
#define MG_F_USER_2 (1 << 21)
......
......@@ -1679,7 +1679,7 @@ const char *c_strnstr(const char *s, const char *find, size_t slen) {
/* Which flags can be pre-set by the user at connection creation time. */
#define _MG_ALLOWED_CONNECT_FLAGS_MASK \
(MG_F_USER_1 | MG_F_USER_2 | MG_F_USER_3 | MG_F_USER_4 | MG_F_USER_5 | \
MG_F_USER_6 | MG_F_WEBSOCKET_NO_DEFRAG)
MG_F_USER_6 | MG_F_WEBSOCKET_NO_DEFRAG | MG_F_ENABLE_BROADCAST)
/* Which flags should be modifiable by user's callbacks. */
#define _MG_CALLBACK_MODIFIABLE_FLAGS_MASK \
(MG_F_USER_1 | MG_F_USER_2 | MG_F_USER_3 | MG_F_USER_4 | MG_F_USER_5 | \
......@@ -2789,6 +2789,11 @@ void mg_if_connect_udp(struct mg_connection *nc) {
nc->err = errno ? errno : 1;
return;
}
if (nc->flags & MG_F_ENABLE_BROADCAST) {
int optval = 1;
setsockopt(nc->sock, SOL_SOCKET, SO_BROADCAST, (const char *) &optval,
sizeof(optval));
}
nc->err = 0;
}
......
......@@ -1263,6 +1263,7 @@ struct mg_connection {
#define MG_F_CLOSE_IMMEDIATELY (1 << 11) /* Disconnect */
#define MG_F_WEBSOCKET_NO_DEFRAG (1 << 12) /* Websocket specific */
#define MG_F_DELETE_CHUNK (1 << 13) /* HTTP specific */
#define MG_F_ENABLE_BROADCAST (1 << 14) /* Allow broadcast address usage */
#define MG_F_USER_1 (1 << 20) /* Flags left for application */
#define MG_F_USER_2 (1 << 21)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment