X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=src%2Futcp-test.c;h=564bfba8618472fdcffe646d9dcb54efeb937ce4;hb=refs%2Fheads%2Ffeature%2Fmetaconnection-address;hp=992e6f0f9b1952673705a5015601e866ceb12bda;hpb=8d4b96efb7955eaa96174af4804597f92e124041;p=meshlink diff --git a/src/utcp-test.c b/src/utcp-test.c index 992e6f0f..564bfba8 100644 --- a/src/utcp-test.c +++ b/src/utcp-test.c @@ -1,16 +1,25 @@ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* + utcp-test.c -- Test application for UTCP + Copyright (C) 2014-2020 Guus Sliepen + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" #include - +#include #include "utcp.h" @@ -148,11 +157,17 @@ static ssize_t do_send(struct utcp *utcp, const void *data, size_t len) { } static void set_mtu(struct utcp *u, int s) { +#ifdef IP_MTU + if(!mtu) { socklen_t optlen = sizeof(mtu); getsockopt(s, IPPROTO_IP, IP_MTU, &mtu, &optlen); } +#else + (void)s; +#endif + if(!mtu || mtu == 65535) { mtu = 1500; } @@ -255,6 +270,11 @@ int main(int argc, char *argv[]) { return 1; } } else { +#ifdef SO_NOSIGPIPE + int nosigpipe = 1; + setsockopt(s, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe)); +#endif + if(connect(s, ai->ai_addr, ai->ai_addrlen)) { debug("Could not connect: %s\n", strerror(errno)); return 1;