aboutsummaryrefslogtreecommitdiff
path: root/src/nat/gnunet-helper-nat-server.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/nat/gnunet-helper-nat-server.c
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/nat/gnunet-helper-nat-server.c')
-rw-r--r--src/nat/gnunet-helper-nat-server.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c
index 636ae6003..684fa9706 100644
--- a/src/nat/gnunet-helper-nat-server.c
+++ b/src/nat/gnunet-helper-nat-server.c
@@ -252,8 +252,8 @@ send_icmp_echo (const struct in_addr *my_ip)
252 ip_pkt.checksum = 0; 252 ip_pkt.checksum = 0;
253 ip_pkt.src_ip = my_ip->s_addr; 253 ip_pkt.src_ip = my_ip->s_addr;
254 ip_pkt.dst_ip = dummy.s_addr; 254 ip_pkt.dst_ip = dummy.s_addr;
255 ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, 255 ip_pkt.checksum =
256 sizeof (struct ip_header))); 256 htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header)));
257 memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); 257 memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header));
258 off += sizeof (struct ip_header); 258 off += sizeof (struct ip_header);
259 259
@@ -261,8 +261,9 @@ send_icmp_echo (const struct in_addr *my_ip)
261 icmp_echo.code = 0; 261 icmp_echo.code = 0;
262 icmp_echo.checksum = 0; 262 icmp_echo.checksum = 0;
263 icmp_echo.reserved = 0; 263 icmp_echo.reserved = 0;
264 icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, 264 icmp_echo.checksum =
265 sizeof (struct icmp_echo_header))); 265 htons (calc_checksum
266 ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header)));
266 memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); 267 memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header));
267 off += sizeof (struct icmp_echo_header); 268 off += sizeof (struct icmp_echo_header);
268 269
@@ -272,8 +273,8 @@ send_icmp_echo (const struct in_addr *my_ip)
272 dst.sin_len = sizeof (struct sockaddr_in); 273 dst.sin_len = sizeof (struct sockaddr_in);
273#endif 274#endif
274 dst.sin_addr = dummy; 275 dst.sin_addr = dummy;
275 err = sendto (rawsock, 276 err =
276 packet, off, 0, (struct sockaddr *) &dst, sizeof (dst)); 277 sendto (rawsock, packet, off, 0, (struct sockaddr *) &dst, sizeof (dst));
277 if (err < 0) 278 if (err < 0)
278 { 279 {
279#if VERBOSE 280#if VERBOSE
@@ -368,9 +369,10 @@ process_icmp_response ()
368 switch (ip_pkt.proto) 369 switch (ip_pkt.proto)
369 { 370 {
370 case IPPROTO_ICMP: 371 case IPPROTO_ICMP:
371 if (have != (sizeof (struct ip_header) * 2 + 372 if (have !=
372 sizeof (struct icmp_ttl_exceeded_header) + 373 (sizeof (struct ip_header) * 2 +
373 sizeof (struct icmp_echo_header))) 374 sizeof (struct icmp_ttl_exceeded_header) +
375 sizeof (struct icmp_echo_header)))
374 { 376 {
375 /* malformed */ 377 /* malformed */
376 return; 378 return;
@@ -380,9 +382,9 @@ process_icmp_response ()
380 port = (uint16_t) ntohl (icmp_echo.reserved); 382 port = (uint16_t) ntohl (icmp_echo.reserved);
381 break; 383 break;
382 case IPPROTO_UDP: 384 case IPPROTO_UDP:
383 if (have != (sizeof (struct ip_header) * 2 + 385 if (have !=
384 sizeof (struct icmp_ttl_exceeded_header) + 386 (sizeof (struct ip_header) * 2 +
385 sizeof (struct udp_header))) 387 sizeof (struct icmp_ttl_exceeded_header) + sizeof (struct udp_header)))
386 { 388 {
387 /* malformed */ 389 /* malformed */
388 return; 390 return;
@@ -397,13 +399,12 @@ process_icmp_response ()
397 } 399 }
398 400
399 if (port == 0) 401 if (port == 0)
400 fprintf (stdout, 402 fprintf (stdout, "%s\n",
401 "%s\n", inet_ntop (AF_INET, &source_ip, buf, sizeof (buf))); 403 inet_ntop (AF_INET, &source_ip, buf, sizeof (buf)));
402 else 404 else
403 fprintf (stdout, 405 fprintf (stdout, "%s:%u\n",
404 "%s:%u\n", 406 inet_ntop (AF_INET, &source_ip, buf, sizeof (buf)),
405 inet_ntop (AF_INET, 407 (unsigned int) port);
406 &source_ip, buf, sizeof (buf)), (unsigned int) port);
407 fflush (stdout); 408 fflush (stdout);
408} 409}
409 410
@@ -426,9 +427,8 @@ make_icmp_socket ()
426 } 427 }
427 if (ret >= FD_SETSIZE) 428 if (ret >= FD_SETSIZE)
428 { 429 {
429 fprintf (stderr, 430 fprintf (stderr, "Socket number too large (%d > %u)\n", ret,
430 "Socket number too large (%d > %u)\n", 431 (unsigned int) FD_SETSIZE);
431 ret, (unsigned int) FD_SETSIZE);
432 close (ret); 432 close (ret);
433 return -1; 433 return -1;
434 } 434 }
@@ -453,15 +453,15 @@ make_raw_socket ()
453 fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno)); 453 fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno));
454 return -1; 454 return -1;
455 } 455 }
456 if (-1 == setsockopt (ret, 456 if (-1 ==
457 SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one))) 457 setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one)))
458 { 458 {
459 fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); 459 fprintf (stderr, "setsockopt failed: %s\n", strerror (errno));
460 close (ret); 460 close (ret);
461 return -1; 461 return -1;
462 } 462 }
463 if (-1 == setsockopt (ret, 463 if (-1 ==
464 IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one))) 464 setsockopt (ret, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one)))
465 { 465 {
466 fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); 466 fprintf (stderr, "setsockopt failed: %s\n", strerror (errno));
467 close (ret); 467 close (ret);
@@ -499,9 +499,8 @@ make_udp_socket (const struct in_addr *my_ip)
499 499
500 if (0 != bind (ret, &addr, sizeof (addr))) 500 if (0 != bind (ret, &addr, sizeof (addr)))
501 { 501 {
502 fprintf (stderr, 502 fprintf (stderr, "Error binding UDP socket to port %u: %s\n", NAT_TRAV_PORT,
503 "Error binding UDP socket to port %u: %s\n", 503 strerror (errno));
504 NAT_TRAV_PORT, strerror (errno));
505 /* likely problematic, but not certain, try to continue */ 504 /* likely problematic, but not certain, try to continue */
506 } 505 }
507 return ret; 506 return ret;