From 4c819a6e3a59da17142bc7bafd0455ca4bf049ac Mon Sep 17 00:00:00 2001 From: Saverio Proto Date: Thu, 10 Apr 2014 15:59:42 +0200 Subject: [PATCH] Started the implementation of route_meshlink that at the moment routes packets based on instance names. --- src/libmeshlink.c | 29 ++++++++++++++++++++++++++++- src/route.c | 6 ------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/libmeshlink.c b/src/libmeshlink.c index ca03b791..bd6a3d28 100644 --- a/src/libmeshlink.c +++ b/src/libmeshlink.c @@ -548,6 +548,33 @@ end: bool tinc_stop(); +bool route_meshlink(node_t *source,vpn_packet_t *packet) { + + printf("data %s\n",packet->data); + printf("data 11%s\n",packet->data+11); + printf("data 32%s\n",packet->data+32); + node_t* owner = NULL; + + tincpackethdr* hdr = (tincpackethdr*)packet->data; + owner = lookup_node(hdr->destination); + + if (owner == NULL) { + //Lookup failed + printf("NULL\n"); + return false; + } + printf("lookupnode %s\n",owner->name); + + if(!owner->status.reachable) { + //Do some here + return false; + } + + //TODO: I skipped here a lot of checks ! + + send_packet(owner,packet); + +} // can be called from any thread bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len) { @@ -570,7 +597,7 @@ bool tinc_send_packet(node_t *receiver, const char* buf, unsigned int len) { myself->in_packets++; myself->in_bytes += packet.len; - route(myself, &packet); + route_meshlink(myself, &packet); return true; } diff --git a/src/route.c b/src/route.c index 83b90293..00ba4c05 100644 --- a/src/route.c +++ b/src/route.c @@ -946,12 +946,6 @@ 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); -- 2.39.2