X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=3627f31d317bfcc122269b0a84a9eff6327900d5;hb=365f60f3f8a8ff85a616d5014d555b470740d395;hp=7e567e99c058c24dd01ae31bcca8eb93005ebeaa;hpb=f5843e7d649f4a7f72cb3fd356bc935457aa492f;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index 7e567e99..3627f31d 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -45,7 +45,6 @@ #include "device.h" #include "ethernet.h" #include "graph.h" -#include "list.h" #include "logger.h" #include "net.h" #include "netutl.h" @@ -56,7 +55,6 @@ #include "xalloc.h" int keylifetime = 0; -int keyexpires = 0; #ifdef HAVE_LZO static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; #endif @@ -150,7 +148,7 @@ void send_mtu_probe(node_t *n) { send_mtu_probe_handler(0, 0, n); } -void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { +static void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { ifdebug(TRAFFIC) logger(LOG_INFO, "Got MTU probe length %d from %s (%s)", packet->len, n->name, n->hostname); if(!packet->data[0]) { @@ -255,7 +253,6 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { int nextpkt = 0; vpn_packet_t *outpkt = pkt[0]; size_t outlen; - int i; if(!cipher_active(&n->incipher)) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", @@ -318,7 +315,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { return; } } else { - for(i = n->received_seqno + 1; i < inpkt->seqno; i++) + for(int i = n->received_seqno + 1; i < inpkt->seqno; i++) n->late[(i / 8) % replaywin] |= 1 << i % 8; } } @@ -359,7 +356,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { receive_packet(n, inpkt); } -void receive_tcppacket(connection_t *c, char *buffer, int len) { +void receive_tcppacket(connection_t *c, const char *buffer, int len) { vpn_packet_t outpkt; outpkt.len = len; @@ -378,12 +375,12 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { vpn_packet_t *inpkt = origpkt; int nextpkt = 0; vpn_packet_t *outpkt; - int origlen; + int origlen = origpkt->len; size_t outlen; #if defined(SOL_IP) && defined(IP_TOS) static int priority = 0; + int origpriority = origpkt->priority; #endif - int origpriority; int sock; if(!n->status.reachable) { @@ -400,7 +397,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { "No valid key known yet for %s (%s), forwarding via TCP", n->name, n->hostname); - if(n->last_req_key + 10 < now) { + if(n->last_req_key + 10 <= now) { send_req_key(n); n->last_req_key = now; } @@ -423,9 +420,6 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { return; } - origlen = inpkt->len; - origpriority = inpkt->priority; - /* Compress the packet */ if(n->outcompression) { @@ -648,6 +642,8 @@ void handle_incoming_vpn_data(int sock, short events, void *data) { void handle_device_data(int sock, short events, void *data) { vpn_packet_t packet; + packet.priority = 0; + if(read_packet(&packet)) { myself->in_packets++; myself->in_bytes += packet.len;