]> git.meshlink.io Git - meshlink/commitdiff
Push data from the application to the library and print to screen this data in route...
authorSaverio Proto <zioproto@gmail.com>
Wed, 9 Apr 2014 17:55:23 +0000 (19:55 +0200)
committerSaverio Proto <zioproto@gmail.com>
Wed, 9 Apr 2014 17:55:23 +0000 (19:55 +0200)
meshlink-sample/meshlinkapp.c
src/libmeshlink.c
src/libmeshlink.h
src/route.c

index d5f489e99505f9cecfc3e4b350b416f592625363..7dd7f501c715f3f362b1d8c51eb33c5ec202017f 100644 (file)
@@ -9,6 +9,7 @@ tinc_setup(confbase, name);
 tinc_start(confbase);
 while(1) {
 sleep(10); //give time to this thread to finish before we exit
+tinc_send_packet(NULL,"datafgsdfsd",10);
 }
 return 0;
 }
index f4932cc38aebd6b539ea88da4143381dcdb7dd86..80f18a22e341187a192125ba7f8a32a072d8c518 100644 (file)
@@ -549,7 +549,19 @@ end:
 bool tinc_stop();
 
 // can be called from any thread
-bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len);
+bool tinc_send_packet(tincremotehost *receiver, const char* buf, unsigned int len) {
+
+       vpn_packet_t packet;
+
+       packet.priority = 0;
+       memcpy(packet.data,buf,len);
+
+        myself->in_packets++;
+        myself->in_bytes += packet.len;
+        route(myself, &packet);
+
+return true;
+}
 
 // handler runs in tinc thread and should return immediately
 bool tinc_set_packet_receive_handler(void (*handler)(const char* sender, const char* buf, unsigned int len));
index 2541b5f2888ea2242c863769aa2a4b3851971bcf..df1fc8d764be6df525b1b644d24d1a5ebfe6c178 100644 (file)
@@ -23,6 +23,7 @@
 //#include "tincctl.h"
 #include "xalloc.h"
 #include "logger.h"
+#include "route.h"
 
 extern char *hosts_dir;
 extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms);
@@ -40,8 +41,23 @@ bool tinc_start(const char* path);
 
 bool tinc_stop();
 
+typedef struct tincpackethdr {
+  /* Use a standard Type-Length-Value (TLV) element */
+  u_int8_t type;
+  u_int8_t len;
+  u_int16_t reserved;                  /* Always 0 */
+  u_int32_t destination;
+  u_int32_t source;
+} __attribute__ ((__packed__)) tincpackethdr;
+
+typedef struct tincremotehost {
+  char *name;
+  char *publickey;
+
+} tincremotehost;
+
 // can be called from any thread
-bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len);
+bool tinc_send_packet(tincremotehost *receiver, const char* buf, unsigned int len);
 
 // handler runs in tinc thread and should return immediately
 bool tinc_set_packet_receive_handler(void (*handler)(const char* sender, const char* buf, unsigned int len));
index 00ba4c05b19a7a33f5ed978270ed3b24f99b8a7a..83b9029327aa2bb3918d2e60a2d0a643a81cb16c 100644 (file)
@@ -946,6 +946,12 @@ static bool do_decrement_ttl(node_t *source, vpn_packet_t *packet) {
 }
 
 void route(node_t *source, vpn_packet_t *packet) {
+
+       if (/*libmeshlink*/ 1) {
+       printf("%s\n",packet->data);
+       return;
+       }
+
        if(pcap)
                send_pcap(packet);