From 10b85a807d6328e0eff7d50a0763304b74cf2b1f Mon Sep 17 00:00:00 2001 From: Saverio Proto Date: Thu, 17 Apr 2014 10:19:53 +0200 Subject: [PATCH] Implemented len a loop checks in the route function --- src/route.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/route.c b/src/route.c index e4007b47..317d120f 100644 --- a/src/route.c +++ b/src/route.c @@ -63,8 +63,14 @@ void route(node_t *source,vpn_packet_t *packet) { // TODO: route on name or key node_t* owner = NULL; + node_t* via = NULL; tincpackethdr* hdr = (tincpackethdr*)packet->data; owner = lookup_node(hdr->destination); + + //Check Lenght + if(!checklength(source, packet, (sizeof(tincpackethdr)))) + return; + if (owner == NULL) { //Lookup failed logger(DEBUG_TRAFFIC, LOG_WARNING, "Cant lookup the owner of a packet in the route() function. This should never happen \n"); @@ -84,7 +90,16 @@ void route(node_t *source,vpn_packet_t *packet) { return; } - //TODO: I skipped here a lot of checks ! + via = (owner->via == myself) ? owner->nexthop : owner->via; + if(via == source) { + logger(DEBUG_TRAFFIC, LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); + return; + } + + if (directonly && owner!=via) { + logger(DEBUG_TRAFFIC, LOG_WARNING, "Direct Only is requested. Dropping packet because direct connection not available \n"); + return; + } send_packet(owner,packet); return; -- 2.39.5