]> git.meshlink.io Git - meshlink/blob - meshlink-sample/meshlinkapp.c
Improved sample application
[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 tincremotehost* remotenode = malloc(sizeof(tincremotehost));
9 char *remotename = "nameofremotenode";
10
11 //TODO: change this, calling a function that returns tincremotehost
12 remotenode->name = remotename;
13 remotenode->publickey = NULL;
14
15 tinc_setup(confbase, name);
16 tinc_start(confbase);
17 while(1) {
18
19 //sample data to send out
20 char mydata[200];
21 memset(mydata,0,200);
22 strcpy(mydata,"Hello World!");
23
24 //send out data
25 tinc_send_packet(remotenode,mydata,sizeof(mydata));
26 sleep(10); //give time to this thread to finish before we exit
27 }
28 free(remotenode);
29 return 0;
30 }
31