X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fexit%2Fgnunet-helper-exit.c;h=573bb7a502ebb5a8c49b41fbf87ebc887defd2d4;hb=82c4c89493dcbfc6ee7fd1232a9088d02e2cd0a2;hp=db1401e89944a838b8fa207dc6c2e4739642898a;hpb=f46035b9126e0bfe6521f2f3e7b66fa6e0bc93d3;p=oweals%2Fgnunet.git diff --git a/src/exit/gnunet-helper-exit.c b/src/exit/gnunet-helper-exit.c index db1401e89..573bb7a50 100644 --- a/src/exit/gnunet-helper-exit.c +++ b/src/exit/gnunet-helper-exit.c @@ -54,6 +54,12 @@ */ #include "gnunet_protocols.h" +/** + * Should we print (interesting|debug) messages that can happen during + * normal operation? + */ +#define DEBUG GNUNET_NO + /** * Maximum size of a GNUnet message (GNUNET_SERVER_MAX_MESSAGE_SIZE) */ @@ -77,8 +83,8 @@ static const char *sbin_iptables; struct in6_ifreq { struct in6_addr ifr6_addr; - uint32_t ifr6_prefixlen; - unsigned int ifr6_ifindex; + __u32 ifr6_prefixlen; + int ifr6_ifindex; }; #endif @@ -202,16 +208,16 @@ static void set_address6 (const char *dev, const char *address, unsigned long prefix_len) { struct ifreq ifr; - struct in6_ifreq ifr6; struct sockaddr_in6 sa6; int fd; + struct in6_ifreq ifr6; /* * parse the new address */ memset (&sa6, 0, sizeof (struct sockaddr_in6)); sa6.sin6_family = AF_INET6; - if (1 != inet_pton (AF_INET6, address, sa6.sin6_addr.s6_addr)) + if (1 != inet_pton (AF_INET6, address, &sa6.sin6_addr)) { fprintf (stderr, "Failed to parse address `%s': %s\n", address, strerror (errno)); @@ -220,7 +226,7 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len) if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) { - fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); + fprintf (stderr, "Error creating socket: %s\n", strerror (errno)); exit (1); } @@ -476,7 +482,9 @@ run (int fd_tun) } else if (0 == buftun_size) { +#if DEBUG fprintf (stderr, "EOF on tun\n"); +#endif shutdown (fd_tun, SHUT_RD); shutdown (1, SHUT_WR); read_open = 0; @@ -498,7 +506,10 @@ run (int fd_tun) if (-1 == written) { - fprintf (stderr, "write-error to stdout: %s\n", strerror (errno)); +#if !DEBUG + if (errno != EPIPE) +#endif + fprintf (stderr, "write-error to stdout: %s\n", strerror (errno)); shutdown (fd_tun, SHUT_RD); shutdown (1, SHUT_WR); read_open = 0; @@ -529,7 +540,9 @@ run (int fd_tun) } else if (0 == bufin_size) { +#if DEBUG fprintf (stderr, "EOF on stdin\n"); +#endif shutdown (0, SHUT_RD); shutdown (fd_tun, SHUT_WR); write_open = 0; @@ -649,7 +662,13 @@ main (int argc, char **argv) if (-1 == (fd_tun = init_tun (dev))) { - fprintf (stderr, "Fatal: could not initialize tun-interface\n"); + fprintf (stderr, + "Fatal: could not initialize tun-interface `%s' with IPv6 %s/%s and IPv4 %s/%s\n", + dev, + argv[3], + argv[4], + argv[5], + argv[6]); return 1; }