]> git.meshlink.io Git - meshlink/blob - meshlink-sample/meshlinkapp.c
Remove everything GPL that is not copyright Guus Sliepen, update copyright statements.
[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 debug_level = 5;
8
9 node_t* remotenode = new_node();
10 char *remotename = "ml";
11
12 //TODO: change this, calling a function that returns node_t
13 remotenode->name = malloc(16);
14 remotenode->name = remotename;
15
16 tinc_setup(confbase, name);
17 tinc_start(confbase);
18 sleep(2); //there is a race condition here, tinc_start detaches to a thread the needs time to setup stuff
19 while(1) {
20
21 //sample data to send out
22 char mydata[200];
23 memset(mydata,0,200);
24 strcpy(mydata,"Hello World!");
25
26 //send out data
27 tinc_send_packet(remotenode,mydata,sizeof(mydata));
28 sleep(10); //give time to this thread to finish before we exit
29 }
30 free(remotenode);
31 return 0;
32 }
33