#include <libmeshlink.h>
+
+void handle_recv_data(void *data);
+void handle_recv_data(void *data) {
+printf("do nothing for now\n");
+
+}
+
int main(int argc , char **argv){
char *confbase = argc > 1 ? argv[1] : "/tmp/meshlink/";
tinc_setup(confbase, name);
tinc_start(confbase);
+
+//Register callback function for incoming data
+recvdata_register_cb(handle_recv_data);
+
sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
while(1) {
#include "protocol.h"
char *hosts_dir = NULL;
+recvdata_cb_t recv_callback;
static char *name = NULL;
char *tinc_conf = NULL;
static bool tty = false;
void *tinc_main_thread(void * in) {
static bool status = false;
-
/* If nonzero, write log entries to a separate file. */
bool use_logfile = false;
*/
bool tinc_blacklist(node_t *host);
-
+void recvdata_register_cb(recvdata_cb_t cb) {
+recv_callback = cb;
+};
#include "logger.h"
#include "route.h"
+typedef void (*recvdata_cb_t)(void *data);
+void recvdata_register_cb(recvdata_cb_t cb);
+
+extern recvdata_cb_t recv_callback;
+
extern char *hosts_dir;
extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms);
if (owner == myself ) {
//TODO: implement sending received data from meshlink library to the application
logger(DEBUG_TRAFFIC, LOG_WARNING, "I received a packet for me with payload: %s \n", packet->data + 46);
+ (recv_callback)(NULL);
return;
}