Fixes typo and UDP network byte order.
This commit is contained in:
parent
505b5ec2cd
commit
7853247523
2 changed files with 22 additions and 21 deletions
17
src/net.c
17
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)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue