From 78532475238b23eb52ac88d905fbf966d97a79d2 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 3 May 2000 17:59:07 +0000 Subject: [PATCH] Fixes typo and UDP network byte order. --- src/net.c | 17 +++++++++-------- src/protocol.c | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 21 deletions(-) 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) diff --git a/src/protocol.c b/src/protocol.c index da35a96f..b5305e8f 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -44,7 +44,7 @@ cp if(debug_lvl > 2) syslog(LOG_DEBUG, "Send ACK to %s", cl->hostname); - buflen = snprintf(buffer, MAXBUFLEN, "%d\n", ACK); + buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", ACK); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -64,7 +64,7 @@ cp syslog(LOG_DEBUG, "Send TERMREQ to " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx\n", TERMREQ, myself->vpn_ip); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", TERMREQ, myself->vpn_ip); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -82,7 +82,7 @@ cp syslog(LOG_DEBUG, "Send TIMEOUT to " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx\n", PINGTIMEOUT, myself->vpn_ip); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", PINGTIMEOUT, myself->vpn_ip); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -100,7 +100,7 @@ cp syslog(LOG_DEBUG, "Sending delete host " IP_ADDR_S " to " IP_ADDR_S, IP_ADDR_V(new_host->vpn_ip), IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx\n", DEL_HOST, new_host->vpn_ip); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", DEL_HOST, new_host->vpn_ip); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -117,7 +117,7 @@ cp if(debug_lvl > 3) syslog(LOG_DEBUG, "pinging " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d\n", PING); + buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PING); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -131,7 +131,7 @@ cp int send_pong(conn_list_t *cl) { cp - buflen = snprintf(buffer, MAXBUFLEN, "%d\n", PONG); + buflen = snprintf(buffer, MAXBUFSIZE, "%d\n", PONG); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -149,7 +149,7 @@ cp syslog(LOG_DEBUG, "Sending add host to " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx %lx/%lx:%x\n", ADD_HOST, new_host->real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx/%lx:%x\n", ADD_HOST, new_host->real_ip, new_host->vpn_ip, new_host->vpn_mask, new_host->port); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -167,7 +167,7 @@ cp syslog(LOG_DEBUG, "Sending KEY_CHANGED to " IP_ADDR_S, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx\n", KEY_CHANGED, src->vpn_ip); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx\n", KEY_CHANGED, src->vpn_ip); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -195,7 +195,7 @@ cp syslog(LOG_DEBUG, "Send BASIC_INFO to " IP_ADDR_S, IP_ADDR_V(cl->real_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %d %lx/%lx:%x\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %d %lx/%lx:%x\n", BASIC_INFO, PROT_CURRENT, myself->vpn_ip, myself->vpn_mask, myself->port); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -234,7 +234,7 @@ cp syslog(LOG_DEBUG, "Send PUBLIC_KEY %s to " IP_ADDR_S, my_public_key_base36, IP_ADDR_V(cl->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %s\n", PUBLIC_KEY, my_public_key_base36); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", PUBLIC_KEY, my_public_key_base36); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -248,7 +248,7 @@ cp int send_calculate(conn_list_t *cl, char *k) { cp - buflen = snprintf(buffer, MAXBUFLEN, "%d %s\n", CALCULATE, k); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %s\n", CALCULATE, k); if((write(cl->meta_socket, buffer, buflen)) < 0) { @@ -275,7 +275,7 @@ cp syslog(LOG_DEBUG, "Sending out request for public key to " IP_ADDR_S, IP_ADDR_V(fw->nexthop->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx %lx\n", REQ_KEY, to, myself->vpn_ip); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx\n", REQ_KEY, to, myself->vpn_ip); if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0) { @@ -305,7 +305,7 @@ cp syslog(LOG_DEBUG, "Sending public key to " IP_ADDR_S, IP_ADDR_V(fw->nexthop->vpn_ip)); - buflen = snprintf(buffer, MAXBUFLEN, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36); + buflen = snprintf(buffer, MAXBUFSIZE, "%d %lx %lx %d %s\n", ANS_KEY, to, myself->vpn_ip, my_key_expiry, my_public_key_base36); if((write(fw->nexthop->meta_socket, buffer, buflen)) < 0) { -- 2.39.5