diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-08-21 22:34:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-08-21 22:34:17 +0000 |
commit | 1355ed0acd88356beccc25dfc710ef0d458b5b96 (patch) | |
tree | 9f9b038f4313c39cc7360d9d7a73ca824da0bc83 /src/transport/gnunet-nat-client.c | |
parent | 59303b47a266fa1b40da6725f2cac5f29f358cbe (diff) | |
download | gnunet-1355ed0acd88356beccc25dfc710ef0d458b5b96.tar.gz gnunet-1355ed0acd88356beccc25dfc710ef0d458b5b96.zip |
cleaning
Diffstat (limited to 'src/transport/gnunet-nat-client.c')
-rw-r--r-- | src/transport/gnunet-nat-client.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/transport/gnunet-nat-client.c b/src/transport/gnunet-nat-client.c index 0ab29dff8..bff86cc93 100644 --- a/src/transport/gnunet-nat-client.c +++ b/src/transport/gnunet-nat-client.c | |||
@@ -228,7 +228,7 @@ send_icmp_udp (const struct in_addr *my_ip, | |||
228 | off = 0; | 228 | off = 0; |
229 | ip_pkt.vers_ihl = 0x45; | 229 | ip_pkt.vers_ihl = 0x45; |
230 | ip_pkt.tos = 0; | 230 | ip_pkt.tos = 0; |
231 | ip_pkt.pkt_len = htons(sizeof (packet)); | 231 | ip_pkt.pkt_len = htons (sizeof (packet)); |
232 | ip_pkt.id = htons(256); | 232 | ip_pkt.id = htons(256); |
233 | ip_pkt.flags_frag_offset = 0; | 233 | ip_pkt.flags_frag_offset = 0; |
234 | ip_pkt.ttl = 128; | 234 | ip_pkt.ttl = 128; |
@@ -256,7 +256,7 @@ send_icmp_udp (const struct in_addr *my_ip, | |||
256 | ip_pkt.vers_ihl = 0x45; | 256 | ip_pkt.vers_ihl = 0x45; |
257 | ip_pkt.tos = 0; | 257 | ip_pkt.tos = 0; |
258 | ip_pkt.pkt_len = htons(sizeof (struct ip_header) + | 258 | ip_pkt.pkt_len = htons(sizeof (struct ip_header) + |
259 | sizeof(struct udp_header)); | 259 | sizeof (struct udp_header)); |
260 | ip_pkt.id = htons(0); | 260 | ip_pkt.id = htons(0); |
261 | ip_pkt.flags_frag_offset = 0; | 261 | ip_pkt.flags_frag_offset = 0; |
262 | ip_pkt.ttl = 128; | 262 | ip_pkt.ttl = 128; |
@@ -289,6 +289,7 @@ send_icmp_udp (const struct in_addr *my_ip, | |||
289 | memcpy (&packet[sizeof(struct ip_header)], | 289 | memcpy (&packet[sizeof(struct ip_header)], |
290 | &icmp_pkt, | 290 | &icmp_pkt, |
291 | sizeof (struct icmp_ttl_exceeded_header)); | 291 | sizeof (struct icmp_ttl_exceeded_header)); |
292 | |||
292 | memset (&dst, 0, sizeof (dst)); | 293 | memset (&dst, 0, sizeof (dst)); |
293 | dst.sin_family = AF_INET; | 294 | dst.sin_family = AF_INET; |
294 | #if HAVE_SOCKADDR_IN_SIN_LEN | 295 | #if HAVE_SOCKADDR_IN_SIN_LEN |
@@ -297,7 +298,7 @@ send_icmp_udp (const struct in_addr *my_ip, | |||
297 | dst.sin_addr = *other; | 298 | dst.sin_addr = *other; |
298 | err = sendto(rawsock, | 299 | err = sendto(rawsock, |
299 | packet, | 300 | packet, |
300 | off, 0, | 301 | sizeof (packet), 0, |
301 | (struct sockaddr*)&dst, | 302 | (struct sockaddr*)&dst, |
302 | sizeof(dst)); | 303 | sizeof(dst)); |
303 | if (err < 0) | 304 | if (err < 0) |
@@ -305,7 +306,7 @@ send_icmp_udp (const struct in_addr *my_ip, | |||
305 | fprintf(stderr, | 306 | fprintf(stderr, |
306 | "sendto failed: %s\n", strerror(errno)); | 307 | "sendto failed: %s\n", strerror(errno)); |
307 | } | 308 | } |
308 | else if (off != (size_t) err) | 309 | else if (sizeof (packet) != (size_t) err) |
309 | { | 310 | { |
310 | fprintf(stderr, | 311 | fprintf(stderr, |
311 | "Error: partial send of ICMP message\n"); | 312 | "Error: partial send of ICMP message\n"); |
@@ -337,8 +338,8 @@ send_icmp (const struct in_addr *my_ip, | |||
337 | off = 0; | 338 | off = 0; |
338 | ip_pkt.vers_ihl = 0x45; | 339 | ip_pkt.vers_ihl = 0x45; |
339 | ip_pkt.tos = 0; | 340 | ip_pkt.tos = 0; |
340 | ip_pkt.pkt_len = sizeof (packet); | 341 | ip_pkt.pkt_len = htons (sizeof (packet)); |
341 | ip_pkt.id = 1; | 342 | ip_pkt.id = htons (256); |
342 | ip_pkt.flags_frag_offset = 0; | 343 | ip_pkt.flags_frag_offset = 0; |
343 | ip_pkt.ttl = IPDEFTTL; | 344 | ip_pkt.ttl = IPDEFTTL; |
344 | ip_pkt.proto = IPPROTO_ICMP; | 345 | ip_pkt.proto = IPPROTO_ICMP; |
@@ -365,8 +366,8 @@ send_icmp (const struct in_addr *my_ip, | |||
365 | /* ip header of the presumably 'lost' udp packet */ | 366 | /* ip header of the presumably 'lost' udp packet */ |
366 | ip_pkt.vers_ihl = 0x45; | 367 | ip_pkt.vers_ihl = 0x45; |
367 | ip_pkt.tos = 0; | 368 | ip_pkt.tos = 0; |
368 | ip_pkt.pkt_len = (sizeof (struct ip_header) + sizeof (struct icmp_echo_header)); | 369 | ip_pkt.pkt_len = htons (sizeof (struct ip_header) + sizeof (struct icmp_echo_header)); |
369 | ip_pkt.id = 1; | 370 | ip_pkt.id = htons (256); |
370 | ip_pkt.flags_frag_offset = 0; | 371 | ip_pkt.flags_frag_offset = 0; |
371 | ip_pkt.ttl = 1; /* real TTL would be 1 on a time exceeded packet */ | 372 | ip_pkt.ttl = 1; /* real TTL would be 1 on a time exceeded packet */ |
372 | ip_pkt.proto = IPPROTO_ICMP; | 373 | ip_pkt.proto = IPPROTO_ICMP; |
@@ -394,8 +395,8 @@ send_icmp (const struct in_addr *my_ip, | |||
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 = htons(calc_checksum((uint16_t*) &packet[off], |
396 | sizeof (struct icmp_ttl_exceeded_header) + | 397 | sizeof (struct icmp_ttl_exceeded_header) + |
397 | sizeof(struct ip_header) + | 398 | sizeof (struct ip_header) + |
398 | sizeof(struct icmp_echo_header))); | 399 | sizeof (struct icmp_echo_header))); |
399 | memcpy (&packet[off], | 400 | memcpy (&packet[off], |
400 | &icmp_ttl, | 401 | &icmp_ttl, |
401 | sizeof (struct icmp_ttl_exceeded_header)); | 402 | sizeof (struct icmp_ttl_exceeded_header)); |
@@ -411,7 +412,7 @@ send_icmp (const struct in_addr *my_ip, | |||
411 | packet, | 412 | packet, |
412 | sizeof (packet), 0, | 413 | sizeof (packet), 0, |
413 | (struct sockaddr*)&dst, | 414 | (struct sockaddr*)&dst, |
414 | sizeof(struct sockaddr_in)); | 415 | sizeof(dst)); |
415 | if (err < 0) | 416 | if (err < 0) |
416 | { | 417 | { |
417 | fprintf(stderr, | 418 | fprintf(stderr, |
@@ -444,8 +445,8 @@ make_raw_socket () | |||
444 | strerror (errno)); | 445 | strerror (errno)); |
445 | return -1; | 446 | return -1; |
446 | } | 447 | } |
447 | if (-1 == setsockopt(ret, SOL_SOCKET, SO_BROADCAST, | 448 | if (0 != setsockopt(ret, SOL_SOCKET, SO_BROADCAST, |
448 | (char *)&one, sizeof(one))) | 449 | (char *)&one, sizeof(one))) |
449 | { | 450 | { |
450 | fprintf(stderr, | 451 | fprintf(stderr, |
451 | "setsockopt failed: %s\n", | 452 | "setsockopt failed: %s\n", |
@@ -453,8 +454,8 @@ make_raw_socket () | |||
453 | close (ret); | 454 | close (ret); |
454 | return -1; | 455 | return -1; |
455 | } | 456 | } |
456 | if (-1 == setsockopt(ret, IPPROTO_IP, IP_HDRINCL, | 457 | if (0 != setsockopt(ret, IPPROTO_IP, IP_HDRINCL, |
457 | (char *)&one, sizeof(one))) | 458 | (char *)&one, sizeof(one))) |
458 | { | 459 | { |
459 | fprintf(stderr, | 460 | fprintf(stderr, |
460 | "setsockopt failed: %s\n", | 461 | "setsockopt failed: %s\n", |