]> git.meshlink.io Git - meshlink/blobdiff - meshlink-sample/meshlinkapp.c
Initial callback support for data received from the VPN to the Application
[meshlink] / meshlink-sample / meshlinkapp.c
index 0b494599f4c6c635d4ad0503909b2cbdbd614d6b..25949b161203d6519d793a99e591b23a7e289c52 100644 (file)
@@ -1,13 +1,20 @@
 #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 = "/tmp/meshlink/";
-char *name = "test";
+char *confbase = argc > 1 ? argv[1] : "/tmp/meshlink/";
+char *name = argc > 2 ? argv[2] : "foo";
 debug_level = 5;
 
 node_t* remotenode = new_node();
-char *remotename = "ml";
+char *remotename = argc > 3 ? argv[3] : "bar";
 
 //TODO: change this, calling a function that returns node_t
 remotenode->name = malloc(16);
@@ -15,6 +22,10 @@ remotenode->name = remotename;
 
 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) {