X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=1805cf7eca3c760df73b08bf78f462bd6b9aae68;hb=d772289f6d6adfb8932658b533349d43f08ec326;hp=ded80a2fb94272bb98eaf5a9bdcad34dce739007;hpb=ce8775000ab38229a78ecf3dc26bab008ca0f332;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index ded80a2f..1805cf7e 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -56,7 +56,7 @@ #include "xalloc.h" int keylifetime = 0; -int keyexpires = 0; +static 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 +150,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]) { @@ -236,6 +236,9 @@ static void receive_packet(node_t *n, vpn_packet_t *packet) { ifdebug(TRAFFIC) logger(LOG_DEBUG, "Received packet of %d bytes from %s (%s)", packet->len, n->name, n->hostname); + n->in_packets++; + n->in_bytes += packet->len; + route(n, packet); } @@ -502,12 +505,14 @@ end: /* send a packet to the given vpn ip. */ -void send_packet(const node_t *n, vpn_packet_t *packet) { +void send_packet(node_t *n, vpn_packet_t *packet) { node_t *via; if(n == myself) { if(overwrite_mac) memcpy(packet->data, mymac.x, ETH_ALEN); + n->out_packets++; + n->out_bytes += packet->len; write_packet(packet); return; } @@ -521,6 +526,9 @@ void send_packet(const node_t *n, vpn_packet_t *packet) { return; } + n->out_packets++; + n->out_bytes += packet->len; + via = (packet->priority == -1 || n->via == myself) ? n->nexthop : n->via; if(via != n) @@ -640,6 +648,9 @@ 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; - if(read_packet(&packet)) + if(read_packet(&packet)) { + myself->in_packets++; + myself->in_bytes += packet.len; route(myself, &packet); + } }