X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet_packet.c;h=36ad02bcf7b19fbfe05d19184b11be8f96e6d20d;hb=cb9cccebb8d74a573a131ac6794542881f9a7d38;hp=7db041b9be15210e5d4566bdf487707510a3b3e9;hpb=dc0e52cb3e42620c3139e713b373d130aa30b698;p=meshlink diff --git a/src/net_packet.c b/src/net_packet.c index 7db041b9..36ad02bc 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -19,10 +19,6 @@ #include "system.h" -#ifdef HAVE_ZLIB -#include -#endif - #include "conf.h" #include "connection.h" #include "crypto.h" @@ -109,7 +105,7 @@ static void send_mtu_probe_handler(event_loop_t *loop, void *data) { timeout = mesh->pingtimeout; } - for(int i = 0; i < 4 + mesh->localdiscovery; i++) { + for(int i = 0; i < 5; i++) { int len; if(i == 0) { @@ -265,11 +261,6 @@ static void send_sptps_packet(meshlink_handle_t *mesh, node_t *n, vpn_packet_t * return; } - if(n->outcompression) { - logger(mesh, MESHLINK_ERROR, "Error while compressing packet to %s", n->name); - return; - } - sptps_send_record(&n->sptps, type, origpkt->data, origpkt->len); return; } @@ -345,22 +336,12 @@ static void choose_broadcast_address(meshlink_handle_t *mesh, const node_t *n, c *sock = rand() % mesh->listen_sockets; if(mesh->listen_socket[*sock].sa.sa.sa_family == AF_INET6) { - if(mesh->localdiscovery_address.sa.sa_family == AF_INET6) { - mesh->localdiscovery_address.in6.sin6_port = n->prevedge->address.in.sin_port; - *sa = &mesh->localdiscovery_address; - } else { - broadcast_ipv6.in6.sin6_port = n->prevedge->address.in.sin_port; - broadcast_ipv6.in6.sin6_scope_id = mesh->listen_socket[*sock].sa.in6.sin6_scope_id; - *sa = &broadcast_ipv6; - } + broadcast_ipv6.in6.sin6_port = n->prevedge->address.in.sin_port; + broadcast_ipv6.in6.sin6_scope_id = mesh->listen_socket[*sock].sa.in6.sin6_scope_id; + *sa = &broadcast_ipv6; } else { - if(mesh->localdiscovery_address.sa.sa_family == AF_INET) { - mesh->localdiscovery_address.in.sin_port = n->prevedge->address.in.sin_port; - *sa = &mesh->localdiscovery_address; - } else { - broadcast_ipv4.in.sin_port = n->prevedge->address.in.sin_port; - *sa = &broadcast_ipv4; - } + broadcast_ipv4.in.sin_port = n->prevedge->address.in.sin_port; + *sa = &broadcast_ipv4; } } @@ -379,17 +360,16 @@ bool send_sptps_data(void *handle, uint8_t type, const void *data, size_t len) { /* Send it via TCP if it is a handshake packet, TCPOnly is in use, or this packet is larger than the MTU. */ - if(type >= SPTPS_HANDSHAKE || ((mesh->self->options | to->options) & OPTION_TCPONLY) || (type != PKT_PROBE && len > to->minmtu)) { + if(type >= SPTPS_HANDSHAKE || (type != PKT_PROBE && len > to->minmtu)) { char buf[len * 4 / 3 + 5]; b64encode(data, buf, len); /* If no valid key is known yet, send the packets using ANS_KEY requests, to ensure we get to learn the reflexive UDP address. */ if(!to->status.validkey) { - to->incompression = mesh->self->incompression; - return send_request(mesh, to->nexthop->connection, "%d %s %s %s -1 -1 -1 %d", ANS_KEY, mesh->self->name, to->name, buf, to->incompression); + return send_request(mesh, to->nexthop->connection, NULL, "%d %s %s %s -1 -1 -1 %d", ANS_KEY, mesh->self->name, to->name, buf, 0); } else { - return send_request(mesh, to->nexthop->connection, "%d %s %s %d %s", REQ_KEY, mesh->self->name, to->name, REQ_SPTPS, buf); + return send_request(mesh, to->nexthop->connection, NULL, "%d %s %s %d %s", REQ_KEY, mesh->self->name, to->name, REQ_SPTPS, buf); } } @@ -428,7 +408,7 @@ bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t if(type == SPTPS_HANDSHAKE) { if(!from->status.validkey) { - logger(mesh, MESHLINK_INFO, "SPTPS key exchange with %s succesful", from->name); + logger(mesh, MESHLINK_INFO, "SPTPS key exchange with %s successful", from->name); from->status.validkey = true; from->status.waitingforkey = false; @@ -560,6 +540,8 @@ void handle_incoming_vpn_data(event_loop_t *loop, void *data, int flags) { node_t *n; int len; + memset(&from, 0, sizeof(from)); + len = recvfrom(ls->udp.fd, pkt.data, MAXSIZE, 0, &from.sa, &fromlen); if(len <= 0 || len > MAXSIZE) {