handling replies continuously from server
[oweals/gnunet.git] / src / exit / gnunet-daemon-exit.c
index 7cd207a50a4a26e773540993d9a21663fe6b004b..e58611cc62b37fd68fc1981b2b9afa3f90281722 100644 (file)
@@ -284,7 +284,7 @@ static struct GNUNET_CONTAINER_Heap *connections_heap;
 /**
  * If there are at least this many connections, old ones will be removed
  */
-static long long unsigned int max_connections;
+static unsigned long long max_connections;
 
 /**
  * This hashmaps saves interesting things about the configured UDP services
@@ -395,8 +395,8 @@ get_redirect_state (int af,
   GNUNET_HashCode key;
   struct TunnelState *state;
 
-  if ( ( (af == AF_INET) && (proto == IPPROTO_ICMP) ) ||
-       ( (af == AF_INET6) && (proto == IPPROTO_ICMPV6) ) )
+  if ( ( (af == AF_INET) && (protocol == IPPROTO_ICMP) ) ||
+       ( (af == AF_INET6) && (protocol == IPPROTO_ICMPV6) ) )
   {
     /* ignore ports */
     destination_port = 0;
@@ -668,8 +668,9 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
        /* could be TCP or UDP, but both have the ports in the right
           place, so that doesn't matter here */
        udp = (const struct GNUNET_TUN_UdpHeader *) &ipv4[1];
-       source_port = ntohs (udp->source_port);
-       destination_port = ntohs (udp->destination_port);
+       /* swap ports, as they are from the original message */
+       destination_port = ntohs (udp->source_port);
+       source_port = ntohs (udp->destination_port);
        /* throw away ICMP payload, won't be useful for the other side anyway */
        pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
        break;
@@ -701,8 +702,9 @@ icmp_from_helper (const struct GNUNET_TUN_IcmpHeader *icmp,
        /* could be TCP or UDP, but both have the ports in the right
           place, so that doesn't matter here */
        udp = (const struct GNUNET_TUN_UdpHeader *) &ipv6[1];
-       source_port = ntohs (udp->source_port);
-       destination_port = ntohs (udp->destination_port);
+       /* swap ports, as they are from the original message */
+       destination_port = ntohs (udp->source_port);
+       source_port = ntohs (udp->destination_port);
        /* throw away ICMP payload, won't be useful for the other side anyway */
        pktlen = sizeof (struct GNUNET_TUN_IcmpHeader);
        break;
@@ -874,7 +876,7 @@ tcp_from_helper (const struct GNUNET_TUN_TcpHeader *tcp,
                 const void *source_ip)
 {
   struct TunnelState *state;
-  char buf[pktlen];
+  char buf[pktlen] GNUNET_ALIGN;
   struct GNUNET_TUN_TcpHeader *mtcp;
   struct GNUNET_EXIT_TcpDataMessage *tdm;
   struct TunnelMessageQueue *tnq;
@@ -1491,7 +1493,7 @@ send_tcp_packet_via_tun (const struct SocketAddress *destination_address,
     return;
   }
   {
-    char buf[len];
+    char buf[len] GNUNET_ALIGN;
     struct GNUNET_MessageHeader *hdr;
     struct GNUNET_TUN_Layer2PacketHeader *tun;
     
@@ -1850,7 +1852,7 @@ send_icmp_packet_via_tun (const struct SocketAddress *destination_address,
     return;
   }
   {
-    char buf[len];
+    char buf[len] GNUNET_ALIGN;
     struct GNUNET_MessageHeader *hdr;
     struct GNUNET_TUN_Layer2PacketHeader *tun;
     
@@ -1983,7 +1985,7 @@ receive_icmp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
   const struct in_addr *v4;
   const struct in6_addr *v6;  
   const void *payload;
-  char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8];
+  char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
   int af;
 
   GNUNET_STATISTICS_update (stats,
@@ -2225,7 +2227,7 @@ receive_icmp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel
   const struct GNUNET_EXIT_IcmpServiceMessage *msg;
   uint16_t pkt_len = ntohs (message->size);
   struct GNUNET_TUN_IcmpHeader icmp;
-  char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8];
+  char buf[sizeof (struct GNUNET_TUN_IPv6Header) + 8] GNUNET_ALIGN;
   const void *payload;
 
   GNUNET_STATISTICS_update (stats,
@@ -2433,7 +2435,7 @@ send_udp_packet_via_tun (const struct SocketAddress *destination_address,
     return;
   }
   {
-    char buf[len];
+    char buf[len] GNUNET_ALIGN;
     struct GNUNET_MessageHeader *hdr;
     struct GNUNET_TUN_Layer2PacketHeader *tun;
     
@@ -3025,9 +3027,9 @@ run (void *cls, char *const *args GNUNET_UNUSED,
   if (GNUNET_YES !=
       GNUNET_OS_check_helper_binary ("gnunet-helper-exit"))
   {
-    fprintf (stderr,
-            "`%s' is not SUID, refusing to run.\n",
-            "gnunet-helper-exit");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               _("`%s' must be installed SUID, refusing to run\n"),
+               "gnunet-helper-exit");
     global_ret = 1;
     return;
   }