X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=b3474c371b8bf85cf37d37948a9b6eba1cc6e6bf;hp=83824df72dceafae5f09ce6b8236b93ecd222bd3;hb=78532475238b23eb52ac88d905fbf966d97a79d2;hpb=505b5ec2cd9d6cf3dc655284a8c4041ce8527a07 diff --git a/src/net.c b/src/net.c index 83824df7..b3474c37 100644 --- a/src/net.c +++ b/src/net.c @@ -94,8 +94,8 @@ int xsend(conn_list_t *cl, void *packet) cp do_encrypt((vpn_packet_t*)packet, &rp, cl->key); rp.from = htonl(myself->vpn_ip); - rp.data->len = htons(rp.data->len); - rp.len = htons(rp.data->len); + rp.data.len = htons(rp.data.len); + rp.len = htons(rp.len); if(debug_lvl > 3) syslog(LOG_ERR, "Sent %d bytes to %lx", ntohs(rp.len), cl->vpn_ip); @@ -111,15 +111,11 @@ cp return 0; } -int xrecv(conn_list_t *cl, void *packet) +int xrecv(conn_list_t *cl, real_packet_t *packet) { vpn_packet_t vp; int lenin; cp - packet->data->len = ntohs(packet->data->len); - packet->len = ntohs(packet->len); - packet->from = ntohl(packet->from); - do_decrypt((real_packet_t*)packet, &vp, cl->key); add_mac_addresses(&vp); @@ -777,6 +773,11 @@ cp return -1; } total_socket_in += lenin; + + rp.data.len = ntohs(rp.data.len); + rp.len = ntohs(rp.len); + rp.from = ntohl(rp.from); + if(rp.len >= 0) { f = lookup_conn(rp.from); @@ -929,7 +930,7 @@ cp int handle_incoming_meta_data(conn_list_t *cl) { int x, l = sizeof(x); - int request, oldlen, p, i; + int request, oldlen, i; int lenin = 0; cp if(getsockopt(cl->meta_socket, SOL_SOCKET, SO_ERROR, &x, &l) < 0)