X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=dc632b608f457defcdde384a6c27b24021233a34;hp=ebcaeb3652f98db1024229ed81692c4ad8b7ad6d;hb=ee96ccabbbf0180d5631d3c22838456f28ee9c15;hpb=aeccaca829842910b4a5c8a5fa61e1738492bea6 diff --git a/src/net.c b/src/net.c index ebcaeb36..dc632b60 100644 --- a/src/net.c +++ b/src/net.c @@ -1,6 +1,6 @@ /* net.c -- most of the network code - Copyright (C) 1998,99 Ivo Timmermans + Copyright (C) 1998,1999,2000 Ivo Timmermans This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -93,12 +93,14 @@ int xsend(conn_list_t *cl, void *packet) real_packet_t rp; cp do_encrypt((vpn_packet_t*)packet, &rp, cl->key); - rp.from = myself->vpn_ip; + rp.from = htonl(myself->vpn_ip); + rp.data.len = htons(rp.data.len); + rp.len = htons(rp.len); if(debug_lvl > 3) - syslog(LOG_ERR, "Sent %d bytes to %lx", rp.len, cl->vpn_ip); + syslog(LOG_ERR, "Sent %d bytes to %lx", ntohs(rp.len), cl->vpn_ip); - if((r = send(cl->socket, (char*)&rp, rp.len, 0)) < 0) + if((r = send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0) { syslog(LOG_ERR, "Error sending data: %m"); return -1; @@ -302,21 +304,6 @@ cp return xsend(cl, packet); } -int send_broadcast(conn_list_t *cl, vpn_packet_t *packet) -{ - conn_list_t *p; -cp - for(p = cl; p != NULL; p = p->next) - if(send_packet(p->real_ip, packet) < 0) - { - syslog(LOG_ERR, "Could not send a broadcast packet to %08lx (%08lx): %m", - p->vpn_ip, p->real_ip); - break; /* FIXME: should retry later, and send a ping over the metaconnection. */ - } -cp - return 0; -} - /* open the local ethertap device */ @@ -771,6 +758,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); @@ -923,7 +915,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)