more code cleanup
authorChristian Grothoff <christian@grothoff.org>
Fri, 20 Aug 2010 14:03:17 +0000 (14:03 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 20 Aug 2010 14:03:17 +0000 (14:03 +0000)
src/transport/gnunet-nat-client-windows.c
src/transport/gnunet-nat-client.c
src/transport/gnunet-nat-server-windows.c
src/transport/gnunet-nat-server.c

index 26cf72f6aade6645d2735717e0078bde6e3aa9fc..febcfc7172e7d561de204595df47934bb423b290 100644 (file)
@@ -249,7 +249,6 @@ send_icmp_udp (const struct in_addr *my_ip,
 
   /* ip header: send to (known) ip address */
   off = 0;
-  memset(&ip_pkt, 0, sizeof(ip_pkt));
   ip_pkt.vers_ihl = 0x45;
   ip_pkt.tos = 0;
   ip_pkt.pkt_len = htons(sizeof (packet));
index ddb59bc8457aac514fa4a82b9d623908e191bb65..2fc2a51a099138e4f645f55e8444c385676cbb56 100644 (file)
  * - Christian Grothoff
  * - Nathan Evans
  */
-#define _GNU_SOURCE
 #if HAVE_CONFIG_H
 /* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */
 #include "gnunet_config.h"
+#else
+#define _GNU_SOURCE
 #endif
 #include <sys/types.h> 
 #include <sys/socket.h>
@@ -375,7 +376,7 @@ send_icmp (const struct in_addr *my_ip,
 
   /* no go back to calculate ICMP packet checksum */
   off = sizeof (ip_pkt);
-  icmp_pkt.checksum = htons(calc_checksum(&packet[off],
+  icmp_pkt.checksum = htons(calc_checksum((uint16_t*) &packet[off],
                                          sizeof (struct icmp_packet) + sizeof(struct ip_packet) + sizeof(struct icmp_echo_packet)));
   memcpy (&packet[off],
          &icmp_pkt,
index ceff3fb8d9b5c2b0ffd894406a506eaa0342ebe6..12aa5b138fe98a4583dbd25b39efef3c5c21e502 100644 (file)
@@ -255,7 +255,7 @@ send_icmp_echo (const struct in_addr *my_ip)
   ip_pkt.src_ip = my_ip->s_addr;
   ip_pkt.dst_ip = dummy.s_addr;
   ip_pkt.checksum = htons(calc_checksum((uint16_t*)&ip_pkt, sizeof (ip_pkt)));
-  memcpy (packet, &ip_pkt, sizeof (ip_pkt));
+  memcpy (&packet[off], &ip_pkt, sizeof (ip_pkt));
   off += sizeof (ip_pkt);
 
   icmp_echo.type = ICMP_ECHO;
index fb88874d3ad51133b0fdad22553a2486afb99e61..e9cbee47cbde454874b357305ce6cfc06fb0fe4b 100644 (file)
  * - Christian Grothoff
  * - Nathan Evans
  */
-#define _GNU_SOURCE
 #if HAVE_CONFIG_H
 /* Just needed for HAVE_SOCKADDR_IN_SIN_LEN test macro! */
 #include "gnunet_config.h"
+#else
+#define _GNU_SOURCE
 #endif
 #include <sys/types.h> 
 #include <sys/socket.h>
@@ -237,9 +238,6 @@ send_icmp_echo (const struct in_addr *my_ip)
   icmp_echo.checksum = 0;
   icmp_echo.checksum = htons(calc_checksum((uint16_t*)&icmp_echo, 
                                           sizeof (struct icmp_packet)));
-
-  make_echo (my_ip, &icmp_echo);
-
   memcpy (&packet[off], &icmp_echo, sizeof (icmp_echo));
   off += sizeof (icmp_echo);