nick = argv[2];
}
- meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_message);
+ meshlink_set_log_cb(NULL, MESHLINK_INFO, log_message);
meshlink_handle_t *mesh = meshlink_open(confbase, nick, "chat", DEV_CLASS_STATIONARY);
meshlink_set_receive_cb(mesh, receive);
meshlink_set_node_status_cb(mesh, node_status);
- meshlink_set_log_cb(mesh, MESHLINK_DEBUG, log_message);
+ meshlink_set_log_cb(mesh, MESHLINK_INFO, log_message);
if(!meshlink_start(mesh)) {
fprintf(stderr, "Could not start MeshLink: %s\n", meshlink_strerror(meshlink_errno));
}
static void send_mdns_packet(meshlink_handle_t *mesh, const discovery_address_t *addr) {
- char *host = NULL, *port = NULL;
- sockaddr2str(&addr->address, &host, &port);
- fprintf(stderr, "Sending on iface %d %s port %s\n", addr->index, host, port);
- free(host);
- free(port);
-
// Configure the socket to send the packet to the right interface
int fd;
uint8_t data[1024];
if(len == -1) {
if(!sockwouldblock(errno)) {
- fprintf(stderr, "Error reading from discovery socket: %s\n", strerror(errno));
logger(mesh, MESHLINK_ERROR, "Error reading from mDNS discovery socket: %s", strerror(errno));
io_set(loop, io, 0);
}
node_t *n = (node_t *)meshlink_get_node(mesh, values[0]);
if(n) {
- logger(mesh, MESHLINK_INFO, "Node %s is part of the mesh network.\n", n->name);
+ if(n != mesh->self) {
+ logger(mesh, MESHLINK_INFO, "Node %s discovered on the local network.\n", n->name);
+ }
if(!response && n != mesh->self) {
// Send a unicast response back
c->last_ping_time = -3600;
}
}
- } else {
- logger(mesh, MESHLINK_WARNING, "Node %s is not part of the mesh network.\n", values[0]);
}
-
- fprintf(stderr, "Got packet from %s port %u\n%s=%s\n%s=%s\n", name, port, keys[0], values[0], keys[1], values[1]);
}
free(name);
return;
}
- fprintf(stderr, "iface %d up\n", index);
mesh->discovery.ifaces = xrealloc(mesh->discovery.ifaces, ++mesh->discovery.iface_count * sizeof(*p));
mesh->discovery.ifaces[mesh->discovery.iface_count - 1] = index;
qsort(mesh->discovery.ifaces, mesh->discovery.iface_count, sizeof(*p), iface_compare);
};
setsockopt(mesh->discovery.sockets[1].fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6));
- fprintf(stderr, "iface %d down\n", index);
memmove(p, p + 1, (mesh->discovery.ifaces + --mesh->discovery.iface_count - p) * sizeof(*p));
handle_network_change(mesh, mesh->discovery.iface_count);
}
bool up = bsearch(&addr->index, mesh->discovery.ifaces, mesh->discovery.iface_count, sizeof(int), iface_compare);
- char *host = NULL, *port = NULL;
- sockaddr2str(&addr->address, &host, &port);
- fprintf(stderr, "address %d %s port %s up %d\n", addr->index, host, port, up);
- free(host);
- free(port);
mesh->discovery.addresses = xrealloc(mesh->discovery.addresses, ++mesh->discovery.address_count * sizeof(*p));
mesh->discovery.addresses[mesh->discovery.address_count - 1] = *addr;
return;
}
- char *host = NULL, *port = NULL;
- sockaddr2str(&addr->address, &host, &port);
- fprintf(stderr, "address %d %s port %s down\n", addr->index, host, port);
- free(host);
- free(port);
-
memmove(p, p + 1, (mesh->discovery.addresses + --mesh->discovery.address_count - p) * sizeof(*p));
}
send(fd, &msg, msg.nlm.nlmsg_len, 0);
}
-
static void netlink_parse_link(meshlink_handle_t *mesh, const struct nlmsghdr *nlm) {
const struct ifinfomsg *ifi = (const struct ifinfomsg *)(nlm + 1);