Using both GCC 8 and Clang 7.
AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
AS_IF([test "x$enable_hardening" != "xno"],
- [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
+ [CPPFLAGS="$CPPFLAGS -W -pedantic"
+ AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"],
[AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])]
)
#define CHAT_PORT 531
static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
- const char *levelstr[] = {
+ (void) mesh;
+
+ static const char *levelstr[] = {
[MESHLINK_DEBUG] = "\x1b[34mDEBUG",
[MESHLINK_INFO] = "\x1b[32mINFO",
[MESHLINK_WARNING] = "\x1b[33mWARNING",
}
static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)data;
+ (void)len;
+
// Only accept connections to the chat port
if(port != CHAT_PORT) {
fprintf(stderr, "Rejected incoming channel from '%s' to port %u\n", channel->node->name, port);
}
static void channel_poll(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)len;
+
fprintf(stderr, "Channel to '%s' connected\n", channel->node->name);
meshlink_set_channel_poll_cb(mesh, channel, NULL);
}
static void node_status(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
printf("%s joined.\n", node->name);
} else {
} else {
printf("%zu known nodes:", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
printf(" %s", nodes[i]->name);
}
// Commands start with '/'
if(*buf == '/') {
- return parse_command(mesh, buf + 1);
+ parse_command(mesh, buf + 1);
+ return;
}
// Lines in the form "name: message..." set the destination node.
#include "../src/meshlink.h"
static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
- const char *levelstr[] = {
+ (void)mesh;
+
+ static const char *levelstr[] = {
[MESHLINK_DEBUG] = "\x1b[34mDEBUG",
[MESHLINK_INFO] = "\x1b[32mINFO",
[MESHLINK_WARNING] = "\x1b[33mWARNING",
[MESHLINK_ERROR] = "\x1b[31mERROR",
[MESHLINK_CRITICAL] = "\x1b[31mCRITICAL",
};
+
fprintf(stderr, "%s:\x1b[0m %s\n", levelstr[level], text);
}
static void receive(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) {
+ (void)mesh;
+
const char *msg = data;
if(!len || msg[len - 1]) {
}
static void node_status(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(reachable) {
printf("%s joined.\n", node->name);
} else {
} else {
printf("%zu known nodes:", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
printf(" %s", nodes[i]->name);
}
// Commands start with '/'
if(*buf == '/') {
- return parse_command(mesh, buf + 1);
+ parse_command(mesh, buf + 1);
+ return;
}
// Lines in the form "name: message..." set the destination node.
} else {
printf("%zu known nodes:\n", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
//printf(" %s\n", nodes[i]->name);
if(!meshlink_send(mesh[nindex], nodes[i], "magic", strlen("magic") + 1)) {
fprintf(stderr, "Could not send message to '%s': %s\n", nodes[i]->name, meshlink_strerror(meshlink_errno));
void exportmeshgraph_timer(int signum) {
+ (void)signum;
+
struct timeval ts;
gettimeofday(&ts, NULL);
#ifndef _WIN32
static bool exportmeshgraph_started = false;
-static bool exportmeshgraph_end(const char *none) {
+static bool exportmeshgraph_end(void) {
if(!exportmeshgraph_started) {
return false;
}
- struct itimerval zero_timer = { 0 };
+ struct itimerval zero_timer;
setitimer(ITIMER_REAL, &zero_timer, NULL);
}
if(exportmeshgraph_started) {
- if(!exportmeshgraph_end(NULL)) {
+ if(!exportmeshgraph_end()) {
return false;
}
}
return true;
}
#else
-static bool exportmeshgraph_end(const char *none) {
+static bool exportmeshgraph_end(void) {
return false;
}
} else {
printf("%zu known nodes:", nnodes);
- for(int i = 0; i < nnodes; i++) {
+ for(size_t i = 0; i < nnodes; i++) {
printf(" %s", nodes[i]->name);
}
} else if(!strcasecmp(buf, "egb")) {
exportmeshgraph_begin(arg);
} else if(!strcasecmp(buf, "ege")) {
- exportmeshgraph_end(NULL);
+ exportmeshgraph_end();
} else if(!strcasecmp(buf, "test")) {
testmesh();
} else if(!strcasecmp(buf, "select")) {
// Commands start with '/'
if(*buf == '/') {
- return parse_command(buf + 1);
+ parse_command(buf + 1);
+ return;
}
// Lines in the form "name: message..." set the destination node.
parse_input(buf);
}
- exportmeshgraph_end(NULL);
+ exportmeshgraph_end();
printf("Nodes stopping.\n");
#include "../src/meshlink.h"
void handle_recv_data(meshlink_handle_t *mesh, meshlink_node_t *source, void *data, size_t len) {
+ (void)mesh;
+
printf("Received %zu bytes from %s: %s\n", len, source->name, (char *)data);
}
bool chacha_poly1305_set_key(chacha_poly1305_ctx_t *ctx, const void *key)
{
chacha_keysetup(&ctx->main_ctx, key, 256);
- chacha_keysetup(&ctx->header_ctx, key + 32, 256);
+ chacha_keysetup(&ctx->header_ctx, (uint8_t *)key + 32, 256);
return true;
}
chacha_ivsetup(&ctx->main_ctx, seqbuf, one);
chacha_encrypt_bytes(&ctx->main_ctx, indata, outdata, inlen);
- poly1305_auth(outdata + inlen, outdata, inlen, poly_key);
+ poly1305_auth((uint8_t *)outdata + inlen, outdata, inlen, poly_key);
if (outlen)
*outlen = inlen + POLY1305_TAGLEN;
/* Check tag before anything else */
inlen -= POLY1305_TAGLEN;
- const uint8_t *tag = indata + inlen;
+ const uint8_t *tag = (const uint8_t *)indata + inlen;
poly1305_auth(expected_tag, indata, inlen, poly_key);
if (memcmp(expected_tag, tag, POLY1305_TAGLEN))
char tmpname[PATH_MAX];
bool error = false;
- snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
- snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename);
+ if (snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name) >= PATH_MAX) {
+ logger(mesh, MESHLINK_ERROR, "Filename too long: %s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ return false;
+ }
+
+ if (snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename) >= PATH_MAX) {
+ logger(mesh, MESHLINK_ERROR, "Filename too long: %s.tmp", filename);
+ return false;
+ }
FILE *fr = fopen(filename, "r");
}
void randomize(void *out, size_t outlen) {
+ char *ptr = out;
+
while(outlen) {
- size_t len = read(random_fd, out, outlen);
+ size_t len = read(random_fd, ptr, outlen);
if(len <= 0) {
if(errno == EAGAIN || errno == EINTR) {
abort();
}
- out += len;
+ ptr += len;
outlen -= len;
}
}
void sc_reduce(unsigned char *s);
void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c);
-#endif
\ No newline at end of file
+#endif
*/
/// This function is called whenever another node sends data to the local node.
- virtual void receive(node *source, const void *data, size_t length) { /* do nothing */ }
+ virtual void receive(node *source, const void *data, size_t length) { /* do nothing */ (void)source; (void)data; (void) length; }
/// This functions is called whenever another node's status changed.
- virtual void node_status(node *peer, bool reachable) { /* do nothing */ }
+ virtual void node_status(node *peer, bool reachable) { /* do nothing */ (void)peer; (void)reachable; }
/// This functions is called whenever MeshLink has some information to log.
- virtual void log(log_level_t level, const char *message) { /* do nothing */ }
+ virtual void log(log_level_t level, const char *message) { /* do nothing */ (void)level; (void)message; }
/// This functions is called whenever another node attemps to open a channel to the local node.
/**
*/
virtual bool channel_accept(channel *channel, uint16_t port, const void *data, size_t len) {
/* by default reject all channels */
+ (void)channel; (void)port; (void)data; (void)len;
return false;
}
* @param data A pointer to a buffer containing data sent by the source.
* @param len The length of the data.
*/
- virtual void channel_receive(channel *channel, const void *data, size_t len) { /* do nothing */ }
+ virtual void channel_receive(channel *channel, const void *data, size_t len) { /* do nothing */ (void)channel; (void)data; (void)len; }
/// This function is called by Meshlink when data can be send on a channel.
/**
* @param channel A handle for the channel.
* @param len The maximum length of data that is guaranteed to be accepted by a call to channel_send().
*/
- virtual void channel_poll(channel *channel, size_t len) { /* do nothing */ }
+ virtual void channel_poll(channel *channel, size_t len) { /* do nothing */ (void)channel; (void)len; }
/// Start MeshLink.
/** This function causes MeshLink to open network sockets, make outgoing connections, and
static bool invitation_send(void *handle, uint8_t type, const void *data, size_t len) {
(void)type;
meshlink_handle_t *mesh = handle;
+ const char *ptr = data;
while(len) {
- int result = send(mesh->sock, data, len, 0);
+ int result = send(mesh->sock, ptr, len, 0);
if(result == -1 && errno == EINTR) {
continue;
return false;
}
- data += result;
+ ptr += result;
len -= result;
}
logger(mesh, MESHLINK_DEBUG, "Done.\n");
}
- snprintf(privname, sizeof(privname), "%s" SLASH "ecdsa_key.priv", mesh->confbase);
+ if (snprintf(privname, sizeof(privname), "%s" SLASH "ecdsa_key.priv", mesh->confbase) >= PATH_MAX) {
+ logger(mesh, MESHLINK_DEBUG, "Filename too long: %s" SLASH "ecdsa_key.priv\n", mesh->confbase);
+ meshlink_errno = MESHLINK_ESTORAGE;
+ return false;
+ }
+
f = fopen(privname, "wb");
if(!f) {
char invname[PATH_MAX];
struct stat st;
- snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name);
+ if (snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name) >= PATH_MAX) {
+ logger(mesh, MESHLINK_DEBUG, "Filename too long: %s" SLASH "%s", filename, ent->d_name);
+ continue;
+ }
if(!stat(invname, &st)) {
if(mesh->invitation_key && deadline < st.st_mtime) {
return;
}
- return send_sptps_packet(mesh, n, origpkt);
+ send_sptps_packet(mesh, n, origpkt);
}
bool send_sptps_data(void *handle, uint8_t type, const void *data, size_t len) {
listen_socket_t *ls = data;
vpn_packet_t pkt;
char *hostname;
- sockaddr_t from = {};
+ sockaddr_t from;
socklen_t fromlen = sizeof(from);
node_t *n;
int len;
}
}
- struct addrinfo *ai, hint = {};
-
- hint.ai_family = addressfamily;
-
- hint.ai_socktype = SOCK_STREAM;
-
- hint.ai_protocol = IPPROTO_TCP;
-
- hint.ai_flags = AI_PASSIVE;
+ struct addrinfo *ai;
+ struct addrinfo hint = {
+ .ai_family = addressfamily,
+ .ai_socktype = SOCK_STREAM,
+ .ai_protocol = IPPROTO_TCP,
+ .ai_flags = AI_PASSIVE,
+ };
int err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai);
Return NULL on failure.
*/
struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) {
- struct addrinfo *ai, hint = {};
+ struct addrinfo *ai;
int err;
- hint.ai_family = addressfamily;
- hint.ai_socktype = socktype;
+ struct addrinfo hint = {
+ .ai_family = addressfamily,
+ .ai_socktype = socktype,
+ };
err = getaddrinfo(address, service, &hint, &ai);
}
sockaddr_t str2sockaddr(const char *address, const char *port) {
- struct addrinfo *ai, hint = {};
- sockaddr_t result = {};
+ struct addrinfo *ai;
+ sockaddr_t result;
int err;
- hint.ai_family = AF_UNSPEC;
- hint.ai_flags = AI_NUMERICHOST;
- hint.ai_socktype = SOCK_STREAM;
+ struct addrinfo hint = {
+ .ai_family = AF_UNSPEC,
+ .ai_flags = AI_NUMERICHOST,
+ .ai_socktype = SOCK_STREAM,
+ };
err = getaddrinfo(address, port, &hint, &ai);
}
}
-static const size_t mdlen = 64;
+#define mdlen 64
// TODO: separate key setup from hmac_sha512
}
bool seen_request(meshlink_handle_t *mesh, const char *request) {
- past_request_t *new, p = {};
-
- p.request = request;
+ past_request_t *new, p = {.request = request};
if(splay_search(mesh->past_request_tree, &p)) {
logger(mesh, MESHLINK_DEBUG, "Already seen request");
/* Splay operation */
static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *result) {
- splay_node_t left = {}, right = {};
+ splay_node_t left = {NULL}, right = {NULL};
splay_node_t *leftbottom = &left, *rightbottom = &right, *child, *grandchild;
splay_node_t *root = tree->root;
int c;
char buffer[len];
size_t outlen;
- return chacha_poly1305_decrypt(s->incipher, seqno, data + 4, len - 4, buffer, &outlen);
+ return chacha_poly1305_decrypt(s->incipher, seqno, (const char *)data + 4, len - 4, buffer, &outlen);
}
// Receive incoming data, datagram version.
return sptps_receive_data_datagram(s, data, len);
}
+ const char *ptr = data;
+
while(len) {
// First read the 2 length bytes.
if(s->buflen < 2) {
toread = len;
}
- memcpy(s->inbuf + s->buflen, data, toread);
+ memcpy(s->inbuf + s->buflen, ptr, toread);
s->buflen += toread;
len -= toread;
- data += toread;
+ ptr += toread;
// Exit early if we don't have the full length.
if(s->buflen < 2) {
toread = len;
}
- memcpy(s->inbuf + s->buflen, data, toread);
+ memcpy(s->inbuf + s->buflen, ptr, toread);
s->buflen += toread;
len -= toread;
- data += toread;
+ ptr += toread;
// If we don't have a whole record, exit.
if(s->buflen < s->reclen + (s->instate ? 19UL : 3UL)) {
-Subproject commit 850542e9585f716985c25d5995ba5bcb2cc6ba87
+Subproject commit d0c4523ccd8998a70262fb11e015ea807d4aaba7
#include "meshlink.h"
-int main(int argc, char *argv[]) {
+int main() {
// Open a new meshlink instance.
meshlink_handle_t *mesh = meshlink_open("basic_conf", "foo", "basic", DEV_CLASS_BACKBONE);
using namespace std;
-int main(int argc, char *argv[]) {
+int main() {
// Open a new meshlink instance.
meshlink::mesh mesh;
}
void a_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+
if(len == 5 && !memcmp(data, "Hello", 5)) {
b_responded = true;
} else if(len == 0) {
}
bool reject_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)port;
+ (void)data;
+ (void)len;
+
return false;
}
bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)port;
+
meshlink_set_channel_accept_cb(mesh, NULL);
meshlink_set_channel_receive_cb(mesh, channel, b_receive_cb);
}
void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)len;
+
meshlink_set_channel_poll_cb(mesh, channel, NULL);
- set_sync_flag(channel->priv);
+ set_sync_flag(channel->priv, true);
}
void poll_cb2(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)mesh;
+ (void)channel;
+
if(len) {
a_nonzero_poll_cb = true;
}
}
-int main(int argc, char *argv[]) {
+int main() {
meshlink_handle_t *a, *b;
open_meshlink_pair(&a, &b, "channels-cornercases");
//meshlink_set_log_cb(a, MESHLINK_DEBUG, log_cb);
meshlink_node_t *nb = meshlink_get_node(a, "b");
assert(nb);
- struct sync_flag channel_opened = {};
+ struct sync_flag channel_opened = {.flag = false};
pthread_mutex_lock(&channel_opened.mutex);
meshlink_channel_t *channel = meshlink_channel_open(a, nb, 7, a_receive_cb, NULL, 0);
}
void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar")) {
bar_reachable = reachable;
}
}
void foo_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)len;
+
if(len == 5 && !memcmp(data, "Hello", 5)) {
bar_responded = true;
}
}
bool reject_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)port;
+ (void)data;
+ (void)len;
+
return false;
}
}
void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)len;
+
meshlink_set_channel_poll_cb(mesh, channel, NULL);
if(meshlink_channel_send(mesh, channel, "Hello", 5) != 5) {
}
-int main(int argc, char *argv[]) {
+int main() {
int fda[2], fdb[2];
pipe2(fda, 0);
}
void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
printf("status_cb: %s %sreachable\n", node->name, reachable ? "" : "un");
if(!strcmp(node->name, "bar")) {
}
void foo_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+
printf("foo_receive_cb %zu: ", len);
fwrite(data, 1, len, stdout);
printf("\n");
}
bool reject_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)port;
+ (void)data;
+ (void)len;
+
return false;
}
}
void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)len;
+
meshlink_set_channel_poll_cb(mesh, channel, NULL);
if(meshlink_channel_send(mesh, channel, "Hello", 5) != 5) {
}
}
-int main(int argc, char *argv[]) {
+int main() {
meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
// Open two new meshlink instance.
}
void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar")) {
bar_reachable = reachable;
} else if(!strcmp(node->name, "foo"))
}
void foo_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)data;
+ (void)len;
+
// One way only.
}
void bar_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+
if(!len) {
fprintf(stderr, "Connection closed by foo\n");
foo_closed = true;
}
bool reject_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) {
+ (void)mesh;
+ (void)channel;
+ (void)port;
+ (void)data;
+ (void)len;
+
return false;
}
}
void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) {
+ (void)len;
+
meshlink_set_channel_poll_cb(mesh, channel, NULL);
bar_responded = true;
}
}
-int main(int argc, char *argv[]) {
+int main() {
debug_level = getenv("DEBUG") ? MESHLINK_DEBUG : MESHLINK_ERROR;
// Initialize and exchange configuration.
volatile bool bar_reachable = false;
void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "bar")) {
bar_reachable = reachable;
}
}
-int main(int argc, char *argv[]) {
+int main() {
// Open two new meshlink instance.
meshlink_handle_t *mesh1 = meshlink_open("import_export_conf.1", "foo", "import-export", DEV_CLASS_BACKBONE);
volatile bool baz_reachable = false;
void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
+ (void)mesh;
+
if(!strcmp(node->name, "baz")) {
baz_reachable = reachable;
}
}
-int main(int argc, char *argv[]) {
+int main() {
// Open two new meshlink instance.
meshlink_handle_t *mesh1 = meshlink_open("invite_join_conf.1", "foo", "invite-join", DEV_CLASS_BACKBONE);
#include "meshlink.h"
-int main(int argc, char *argv[]) {
+int main() {
// Open two new meshlink instance.
meshlink_handle_t *mesh1 = meshlink_open("sign_verify_conf.1", "foo", "sign-verify", DEV_CLASS_BACKBONE);
#include "utils.h"
static void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
+ (void)mesh;
+
static struct timeval tv0;
struct timeval tv;
static bool received = false;
static void receive_cb(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) {
+ (void)mesh;
+ (void)source;
+
fprintf(stderr, "RECEIVED SOMETHING\n");
if(len == 5 && !memcmp(data, "Hello", 5)) {
}
}
-int main(int argc, char *argv[]) {
+int main() {
// Create three instances.
const char *name[3] = {"foo", "bar", "baz"};
#include "utils.h"
-void set_sync_flag(struct sync_flag *s) {
+void set_sync_flag(struct sync_flag *s, bool value) {
pthread_mutex_lock(&s->mutex);
- s->flag = true;
+ s->flag = value;
pthread_cond_broadcast(&s->cond);
pthread_mutex_unlock(&s->mutex);
}
// Don't poll in the application thread, use a condition variable to signal when the peer is online.
static void pair_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) {
- set_sync_flag(mesh->priv);
+ (void)node;
+
+ set_sync_flag(mesh->priv, reachable);
}
void start_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b) {
- struct sync_flag pair_status = {};
+ struct sync_flag pair_status = {.flag = false};
a->priv = &pair_status;
meshlink_set_node_status_cb(a, pair_status_cb);
bool flag;
};
-extern void set_sync_flag(struct sync_flag *s);
+extern void set_sync_flag(struct sync_flag *s, bool value);
extern bool wait_sync_flag(struct sync_flag *s, int seconds);
/// Create a pair of meshlink instances that are already joined together.