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-windows.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/nat/gnunet-helper-nat-client-windows.c')
-rw-r--r-- | src/nat/gnunet-helper-nat-client-windows.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/src/nat/gnunet-helper-nat-client-windows.c b/src/nat/gnunet-helper-nat-client-windows.c index 0fa62ff7c..864c911b0 100644 --- a/src/nat/gnunet-helper-nat-client-windows.c +++ b/src/nat/gnunet-helper-nat-client-windows.c | |||
@@ -258,8 +258,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
258 | ip_pkt.checksum = 0; | 258 | ip_pkt.checksum = 0; |
259 | ip_pkt.src_ip = my_ip->s_addr; | 259 | ip_pkt.src_ip = my_ip->s_addr; |
260 | ip_pkt.dst_ip = other->s_addr; | 260 | ip_pkt.dst_ip = other->s_addr; |
261 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 261 | ip_pkt.checksum = |
262 | sizeof (struct ip_header))); | 262 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
263 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 263 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
264 | off += sizeof (struct ip_header); | 264 | off += sizeof (struct ip_header); |
265 | 265 | ||
@@ -273,8 +273,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
273 | /* ip header of the presumably 'lost' udp packet */ | 273 | /* ip header of the presumably 'lost' udp packet */ |
274 | ip_pkt.vers_ihl = 0x45; | 274 | ip_pkt.vers_ihl = 0x45; |
275 | ip_pkt.tos = 0; | 275 | ip_pkt.tos = 0; |
276 | ip_pkt.pkt_len = htons (sizeof (struct ip_header) + | 276 | ip_pkt.pkt_len = |
277 | sizeof (struct udp_header)); | 277 | htons (sizeof (struct ip_header) + sizeof (struct udp_header)); |
278 | ip_pkt.id = htons (0); | 278 | ip_pkt.id = htons (0); |
279 | ip_pkt.flags_frag_offset = 0; | 279 | ip_pkt.flags_frag_offset = 0; |
280 | ip_pkt.ttl = 128; | 280 | ip_pkt.ttl = 128; |
@@ -282,8 +282,8 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
282 | ip_pkt.checksum = 0; | 282 | ip_pkt.checksum = 0; |
283 | ip_pkt.src_ip = other->s_addr; | 283 | ip_pkt.src_ip = other->s_addr; |
284 | ip_pkt.dst_ip = dummy.s_addr; | 284 | ip_pkt.dst_ip = dummy.s_addr; |
285 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 285 | ip_pkt.checksum = |
286 | sizeof (struct ip_header))); | 286 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
287 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 287 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
288 | off += sizeof (struct ip_header); | 288 | off += sizeof (struct ip_header); |
289 | 289 | ||
@@ -296,20 +296,20 @@ send_icmp_udp (const struct in_addr *my_ip, const struct in_addr *other) | |||
296 | off += sizeof (struct udp_header); | 296 | off += sizeof (struct udp_header); |
297 | 297 | ||
298 | /* no go back to calculate ICMP packet checksum */ | 298 | /* no go back to calculate ICMP packet checksum */ |
299 | icmp_pkt.checksum = htons (calc_checksum ((uint16_t *) & packet[off], | 299 | icmp_pkt.checksum = |
300 | sizeof (struct | 300 | htons (calc_checksum |
301 | icmp_ttl_exceeded_header) + | 301 | ((uint16_t *) & packet[off], |
302 | sizeof (struct ip_header) + | 302 | sizeof (struct icmp_ttl_exceeded_header) + |
303 | sizeof (struct udp_header))); | 303 | sizeof (struct ip_header) + sizeof (struct udp_header))); |
304 | memcpy (&packet[sizeof (struct ip_header)], &icmp_pkt, | 304 | memcpy (&packet[sizeof (struct ip_header)], &icmp_pkt, |
305 | sizeof (struct icmp_ttl_exceeded_header)); | 305 | sizeof (struct icmp_ttl_exceeded_header)); |
306 | 306 | ||
307 | memset (&dst, 0, sizeof (dst)); | 307 | memset (&dst, 0, sizeof (dst)); |
308 | dst.sin_family = AF_INET; | 308 | dst.sin_family = AF_INET; |
309 | dst.sin_addr = *other; | 309 | dst.sin_addr = *other; |
310 | err = sendto (rawsock, | 310 | err = |
311 | packet, | 311 | sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, |
312 | sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); | 312 | sizeof (dst)); |
313 | if (err < 0) | 313 | if (err < 0) |
314 | { | 314 | { |
315 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); | 315 | fprintf (stderr, "sendto failed: %s\n", strerror (errno)); |
@@ -352,8 +352,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
352 | ip_pkt.checksum = 0; | 352 | ip_pkt.checksum = 0; |
353 | ip_pkt.src_ip = my_ip->s_addr; | 353 | ip_pkt.src_ip = my_ip->s_addr; |
354 | ip_pkt.dst_ip = other->s_addr; | 354 | ip_pkt.dst_ip = other->s_addr; |
355 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 355 | ip_pkt.checksum = |
356 | sizeof (struct ip_header))); | 356 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
357 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 357 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
358 | off += sizeof (ip_pkt); | 358 | off += sizeof (ip_pkt); |
359 | 359 | ||
@@ -377,8 +377,8 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
377 | ip_pkt.src_ip = other->s_addr; | 377 | ip_pkt.src_ip = other->s_addr; |
378 | ip_pkt.dst_ip = dummy.s_addr; | 378 | ip_pkt.dst_ip = dummy.s_addr; |
379 | ip_pkt.checksum = 0; | 379 | ip_pkt.checksum = 0; |
380 | ip_pkt.checksum = htons (calc_checksum ((uint16_t *) & ip_pkt, | 380 | ip_pkt.checksum = |
381 | sizeof (struct ip_header))); | 381 | htons (calc_checksum ((uint16_t *) & ip_pkt, sizeof (struct ip_header))); |
382 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); | 382 | memcpy (&packet[off], &ip_pkt, sizeof (struct ip_header)); |
383 | off += sizeof (struct ip_header); | 383 | off += sizeof (struct ip_header); |
384 | 384 | ||
@@ -386,26 +386,27 @@ send_icmp (const struct in_addr *my_ip, const struct in_addr *other) | |||
386 | icmp_echo.code = 0; | 386 | icmp_echo.code = 0; |
387 | icmp_echo.reserved = htonl (port); | 387 | icmp_echo.reserved = htonl (port); |
388 | icmp_echo.checksum = 0; | 388 | icmp_echo.checksum = 0; |
389 | icmp_echo.checksum = htons (calc_checksum ((uint16_t *) & icmp_echo, | 389 | icmp_echo.checksum = |
390 | sizeof (struct icmp_echo_header))); | 390 | htons (calc_checksum |
391 | ((uint16_t *) & icmp_echo, sizeof (struct icmp_echo_header))); | ||
391 | memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); | 392 | memcpy (&packet[off], &icmp_echo, sizeof (struct icmp_echo_header)); |
392 | 393 | ||
393 | /* no go back to calculate ICMP packet checksum */ | 394 | /* no go back to calculate ICMP packet checksum */ |
394 | off = sizeof (struct ip_header); | 395 | off = sizeof (struct ip_header); |
395 | icmp_ttl.checksum = htons (calc_checksum ((uint16_t *) & packet[off], | 396 | icmp_ttl.checksum = |
396 | sizeof (struct | 397 | htons (calc_checksum |
397 | icmp_ttl_exceeded_header) + | 398 | ((uint16_t *) & packet[off], |
398 | sizeof (struct ip_header) + | 399 | sizeof (struct icmp_ttl_exceeded_header) + |
399 | sizeof (struct icmp_echo_header))); | 400 | sizeof (struct ip_header) + sizeof (struct icmp_echo_header))); |
400 | memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); | 401 | memcpy (&packet[off], &icmp_ttl, sizeof (struct icmp_ttl_exceeded_header)); |
401 | 402 | ||
402 | memset (&dst, 0, sizeof (dst)); | 403 | memset (&dst, 0, sizeof (dst)); |
403 | dst.sin_family = AF_INET; | 404 | dst.sin_family = AF_INET; |
404 | dst.sin_addr = *other; | 405 | dst.sin_addr = *other; |
405 | 406 | ||
406 | err = sendto (rawsock, | 407 | err = |
407 | packet, | 408 | sendto (rawsock, packet, sizeof (packet), 0, (struct sockaddr *) &dst, |
408 | sizeof (packet), 0, (struct sockaddr *) &dst, sizeof (dst)); | 409 | sizeof (dst)); |
409 | 410 | ||
410 | if (err < 0) | 411 | if (err < 0) |
411 | { | 412 | { |
@@ -439,8 +440,8 @@ make_raw_socket () | |||
439 | if (0 != | 440 | if (0 != |
440 | setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen)) | 441 | setsockopt (ret, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen)) |
441 | { | 442 | { |
442 | fprintf (stderr, | 443 | fprintf (stderr, "Error setting SO_BROADCAST to ON: %s\n", |
443 | "Error setting SO_BROADCAST to ON: %s\n", strerror (errno)); | 444 | strerror (errno)); |
444 | closesocket (rawsock); | 445 | closesocket (rawsock); |
445 | return INVALID_SOCKET; | 446 | return INVALID_SOCKET; |
446 | } | 447 | } |