diff options
author | Christian Pointner <equinox@anytun.org> | 2014-02-09 23:12:44 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2014-02-09 23:12:44 +0000 |
commit | 72fa004f63e49103512ba3c29836f2cdeda19423 (patch) | |
tree | d7a9421bf05fe305277d31a3d4a45169da589c9e /src/uanytun.c | |
parent | remote end is now stored at every sock (diff) |
moved remote end handling and active sock to udp.c
Diffstat (limited to 'src/uanytun.c')
-rw-r--r-- | src/uanytun.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/uanytun.c b/src/uanytun.c index 3473b24..674e7bb 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -124,7 +124,7 @@ int process_tun_data(tun_device_t* dev, udp_t* sock, options_t* opt, plain_packe else plain_packet_set_type(plain_packet, PAYLOAD_TYPE_UNKNOWN); - if(!sock->active_sock_ || !sock->active_sock_->remote_end_set_) + if(!udp_has_remote(sock)) return 0; cipher_encrypt(c, kd, kd_outbound, plain_packet, encrypted_packet, seq_nr, opt->sender_id_, opt->mux_); @@ -182,17 +182,7 @@ int process_sock_data(tun_device_t* dev, int fd, udp_t* sock, options_t* opt, pl return -2; } - udp_set_active_sock(sock, fd); - if(sock->active_sock_) { - if(remote.len_ != sock->active_sock_->remote_end_.len_ || - memcmp(&(remote.addr_), &(sock->active_sock_->remote_end_.addr_), remote.len_)) { - memcpy(&(sock->active_sock_->remote_end_.addr_), &(remote.addr_), remote.len_); - sock->active_sock_->remote_end_set_ = 1; - char* addrstring = udp_endpoint_to_string(remote); - log_printf(NOTICE, "autodetected remote host changed %s", addrstring); - free(addrstring); - } - } + udp_update_remote(sock, fd, &remote); if(encrypted_packet_get_payload_length(encrypted_packet) <= plain_packet_get_header_length()) { log_printf(WARNING, "ignoring packet with zero length payload"); |