]> git.meshlink.io Git - meshlink/blob - meshlink-sample/meshlinkapp.c
647e6b77630c66b05b2d14e664ae3d1a4899ebbf
[meshlink] / meshlink-sample / meshlinkapp.c
1 #include <libmeshlink.h>
2
3 int main(int argc , char **argv){
4
5 char *confbase = "/tmp/meshlink/";
6 char *name = "test";
7
8 node_t* remotenode = new_node();
9 char *remotename = "nameofremotenode";
10
11 //TODO: change this, calling a function that returns node_t
12 remotenode->name = malloc(16);
13 remotenode->name = remotename;
14
15 tinc_setup(confbase, name);
16 tinc_start(confbase);
17 sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
18 while(1) {
19
20 //sample data to send out
21 char mydata[200];
22 memset(mydata,0,200);
23 strcpy(mydata,"Hello World!");
24
25 //send out data
26 tinc_send_packet(remotenode,mydata,sizeof(mydata));
27 sleep(10); //give time to this thread to finish before we exit
28 }
29 free(remotenode);
30 return 0;
31 }
32