5 void handle_recv_data(void *data);
6 void handle_recv_data(void *data) {
7 printf("Data received is %s\n",data);
11 int main(int argc , char **argv){
12 char *confbase = argc > 1 ? argv[1] : "/tmp/meshlink/";
13 char *name = argc > 2 ? argv[2] : "foo";
16 meshlink_node_t* remotenode = new_node();
17 char *remotename = argc > 3 ? argv[3] : "bar";
19 //TODO: change this, calling a function that returns node_t
20 //remotenode->name = malloc(16);
21 //remotenode->name = remotename;
23 meshlink_handle_t* myhandle;
25 meshlink_open(confbase, name);
26 meshlink_start(myhandle);
28 //Register callback function for incoming data
29 meshlink_receive_cb_t(handle_recv_data);
31 sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
34 //sample data to send out
37 strcpy(mydata,"Hello World!");
40 meshlink_send(myhandle,remotenode,mydata,sizeof(mydata));
41 sleep(10); //give time to this thread to finish before we exit