diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/nat/gnunet-helper-nat-client.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/nat/gnunet-helper-nat-client.c')
-rw-r--r-- | src/nat/gnunet-helper-nat-client.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/nat/gnunet-helper-nat-client.c b/src/nat/gnunet-helper-nat-client.c index 76f405bf1..fbebdbc0f 100644 --- a/src/nat/gnunet-helper-nat-client.c +++ b/src/nat/gnunet-helper-nat-client.c | |||
@@ -235,8 +235,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
235 | ip_pkt.checksum = 0; | 235 | ip_pkt.checksum = 0; |
236 | ip_pkt.src_ip = my_ip->s_addr; | 236 | ip_pkt.src_ip = my_ip->s_addr; |
237 | ip_pkt.dst_ip = other->s_addr; | 237 | ip_pkt.dst_ip = other->s_addr; |
238 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 238 | ip_pkt.checksum = |
239 | sizeof (struct ip_header))); | 239 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
240 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 240 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
241 | off += sizeof (struct ip_header); | 241 | off += sizeof (struct ip_header); |
242 | 242 | ||
@@ -250,8 +250,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
250 | /* ip header of the presumably 'lost' udp packet */ | 250 | /* ip header of the presumably 'lost' udp packet */ |
251 | ip_pkt.vers_ihl = 0x45; | 251 | ip_pkt.vers_ihl = 0x45; |
252 | ip_pkt.tos = 0; | 252 | ip_pkt.tos = 0; |
253 | ip_pkt.pkt_len = htons (sizeof (struct ip_header) + | 253 | ip_pkt.pkt_len = |
254 | sizeof (struct udp_header)); | 254 | htons (sizeof (struct ip_header) + sizeof (struct udp_header)); |
255 | ip_pkt.id = htons (0); | 255 | ip_pkt.id = htons (0); |
256 | ip_pkt.flags_frag_offset = 0; | 256 | ip_pkt.flags_frag_offset = 0; |
257 | ip_pkt.ttl = 128; | 257 | ip_pkt.ttl = 128; |
@@ -259,8 +259,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
259 | ip_pkt.checksum = 0; | 259 | ip_pkt.checksum = 0; |
260 | ip_pkt.src_ip = other->s_addr; | 260 | ip_pkt.src_ip = other->s_addr; |
261 | ip_pkt.dst_ip = dummy.s_addr; | 261 | ip_pkt.dst_ip = dummy.s_addr; |
262 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 262 | ip_pkt.checksum = |
263 | sizeof (struct ip_header))); | 263 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
264 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 264 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
265 | off += sizeof (struct ip_header); | 265 | off += sizeof (struct ip_header); |
266 | 266 | ||
@@ -287,9 +287,9 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
287 | dst.sin_len = sizeof (struct sockaddr_in); | 287 | dst.sin_len = sizeof (struct sockaddr_in); |
288 | #endif | 288 | #endif |
289 | dst.sin_addr = *other; | 289 | dst.sin_addr = *other; |
290 | err = sendto (rawsock, | 290 | err = |
291 | packet, | 291 | sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, |
292 | sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); | 292 | sizeof (dst)); |
293 | if (err < 0) | 293 | if (err < 0) |
294 | { | 294 | { |
295 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); | 295 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); |
@@ -332,8 +332,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
332 | ip_pkt.checksum = 0; | 332 | ip_pkt.checksum = 0; |
333 | ip_pkt.src_ip = my_ip->s_addr; | 333 | ip_pkt.src_ip = my_ip->s_addr; |
334 | ip_pkt.dst_ip = other->s_addr; | 334 | ip_pkt.dst_ip = other->s_addr; |
335 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 335 | ip_pkt.checksum = |
336 | sizeof (struct ip_header))); | 336 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
337 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 337 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
338 | off = sizeof (ip_pkt); | 338 | off = sizeof (ip_pkt); |
339 | 339 | ||
@@ -357,8 +357,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
357 | ip_pkt.src_ip = other->s_addr; | 357 | ip_pkt.src_ip = other->s_addr; |
358 | ip_pkt.dst_ip = dummy.s_addr; | 358 | ip_pkt.dst_ip = dummy.s_addr; |
359 | ip_pkt.checksum = 0; | 359 | ip_pkt.checksum = 0; |
360 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 360 | ip_pkt.checksum = |
361 | sizeof (struct ip_header))); | 361 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
362 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 362 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
363 | off += sizeof (struct ip_header); | 363 | off += sizeof (struct ip_header); |
364 | 364 | ||
@@ -366,17 +366,18 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
366 | icmp_echo.code = 0; | 366 | icmp_echo.code = 0; |
367 | icmp_echo.reserved = htonl (port); | 367 | icmp_echo.reserved = htonl (port); |
368 | icmp_echo.checksum = 0; | 368 | icmp_echo.checksum = 0; |
369 | icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, | 369 | icmp_echo.checksum = |
370 | sizeof (struct icmp_echo_header))); | 370 | htons (calc_checksum |
371 | ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); | ||
371 | memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); | 372 | memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); |
372 | 373 | ||
373 | /* no go back to calculate ICMP packet checksum */ | 374 | /* no go back to calculate ICMP packet checksum */ |
374 | off = sizeof (struct ip_header); | 375 | off = sizeof (struct ip_header); |
375 | icmp_ttl.checksum = htons (calc_checksum ((uint16_t *) & packet[off], | 376 | icmp_ttl.checksum = |
376 | sizeof (struct | 377 | htons (calc_checksum |
377 | icmp_ttl_exceeded_header) + | 378 | ((uint16_t *) & packet[off], |
378 | sizeof (struct ip_header) + | 379 | sizeof (struct icmp_ttl_exceeded_header) + |
379 | sizeof (struct icmp_echo_header))); | 380 | sizeof (struct ip_header) + sizeof (struct icmp_echo_header))); |
380 | memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); | 381 | memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); |
381 | 382 | ||
382 | /* prepare for transmission */ | 383 | /* prepare for transmission */ |
@@ -386,9 +387,9 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
386 | dst.sin_len = sizeof (struct sockaddr_in); | 387 | dst.sin_len = sizeof (struct sockaddr_in); |
387 | #endif | 388 | #endif |
388 | dst.sin_addr = *other; | 389 | dst.sin_addr = *other; |
389 | err = sendto (rawsock, | 390 | err = |
390 | packet, | 391 | sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, |
391 | sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); | 392 | sizeof (dst)); |
392 | if (err < 0) | 393 | if (err < 0) |
393 | { | 394 | { |
394 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); | 395 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); |
@@ -417,15 +418,15 @@ make_raw_socket () | |||
417 | fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno)); | 418 | fprintf (stderr, "Error opening RAW socket: %s\n", strerror (errno)); |
418 | return -1; | 419 | return -1; |
419 | } | 420 | } |
420 | if (0 != setsockopt (ret, SOL_SOCKET, SO_BROADCAST, | 421 | if (0 != |
421 | (char *) &one, sizeof (one))) | 422 | setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof (one))) |
422 | { | 423 | { |
423 | fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); | 424 | fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); |
424 | close (ret); | 425 | close (ret); |
425 | return -1; | 426 | return -1; |
426 | } | 427 | } |
427 | if (0 != setsockopt (ret, IPPROTO_IP, IP_HDRINCL, | 428 | if (0 != |
428 | (char *) &one, sizeof (one))) | 429 | setsockopt (ret, IPPROTO_IP, IP_HDRINCL, (char *) &one, sizeof (one))) |
429 | { | 430 | { |
430 | fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); | 431 | fprintf (stderr, "setsockopt failed: %s\n", strerror (errno)); |
431 | close (ret); | 432 | close (ret); |