X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=meshlink-sample%2Fmeshlinkapp.c;h=aa9b30c5570d0351c16d40af5df7c9a77d8a4338;hb=3c72744cc47f02815bbef5de39ce3740f23be3a0;hp=0ec564e37b6f149b17c457e0706a9bc637420ba9;hpb=b226232d74099ddd92d3b61ee31051b71e678aa9;p=meshlink diff --git a/meshlink-sample/meshlinkapp.c b/meshlink-sample/meshlinkapp.c index 0ec564e3..aa9b30c5 100644 --- a/meshlink-sample/meshlinkapp.c +++ b/meshlink-sample/meshlinkapp.c @@ -1,19 +1,31 @@ #include + +void handle_recv_data(void *data); +void handle_recv_data(void *data) { +printf("Data received is %s\n",data); + +} + 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; -tincremotehost* remotenode = malloc(sizeof(tincremotehost)); -char *remotename = "nameofremotenode"; +node_t* remotenode = new_node(); +char *remotename = argc > 3 ? argv[3] : "bar"; -//TODO: change this, calling a function that returns tincremotehost +//TODO: change this, calling a function that returns node_t +remotenode->name = malloc(16); remotenode->name = remotename; -remotenode->publickey = NULL; 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) {