X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet_packet.c;h=7e567e99c058c24dd01ae31bcca8eb93005ebeaa;hb=f5843e7d649f4a7f72cb3fd356bc935457aa492f;hp=ded80a2fb94272bb98eaf5a9bdcad34dce739007;hpb=ffa3a443b9f01d3ea0fcb3c4fc6928a5c695cf4a;p=tinc diff --git a/src/net_packet.c b/src/net_packet.c index ded80a2f..7e567e99 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -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); + } }