From acbad345d0ae2c197e51ec66c9b9c0e0a1cd991e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 10 Feb 2014 00:05:52 +0000 Subject: improved handling of sequence numbers (only increment if packet is sent) --- src/uanytun.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/uanytun.c b/src/uanytun.c index 674e7bb..5b30b54 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -104,7 +104,7 @@ int init_main_loop(options_t* opt, cipher_t* c, auth_algo_t* aa, key_derivation_ } int process_tun_data(tun_device_t* dev, udp_t* sock, options_t* opt, plain_packet_t* plain_packet, encrypted_packet_t* encrypted_packet, - cipher_t* c, auth_algo_t* aa, key_derivation_t* kd, seq_nr_t seq_nr) + cipher_t* c, auth_algo_t* aa, key_derivation_t* kd, seq_nr_t* seq_nr) { plain_packet_set_payload_length(plain_packet, -1); encrypted_packet_set_length(encrypted_packet, -1); @@ -127,8 +127,8 @@ int process_tun_data(tun_device_t* dev, udp_t* sock, options_t* opt, plain_packe if(!udp_has_remote(sock)) return 0; - cipher_encrypt(c, kd, kd_outbound, plain_packet, encrypted_packet, seq_nr, opt->sender_id_, opt->mux_); - + cipher_encrypt(c, kd, kd_outbound, plain_packet, encrypted_packet, *seq_nr, opt->sender_id_, opt->mux_); + (*seq_nr)++; #ifndef NO_CRYPT auth_algo_generate(aa, kd, kd_outbound, encrypted_packet); #endif @@ -253,8 +253,7 @@ int main_loop(tun_device_t* dev, udp_t* sock, options_t* opt) } if(FD_ISSET(dev->fd_, &readyfds)) { - return_value = process_tun_data(dev, sock, opt, &plain_packet, &encrypted_packet, &c, &aa, &kd, seq_nr); - seq_nr++; + return_value = process_tun_data(dev, sock, opt, &plain_packet, &encrypted_packet, &c, &aa, &kd, &seq_nr); if(return_value) break; } -- cgit v1.2.3