diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-04 14:31:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-04 14:31:16 +0000 |
commit | 2ecad0debfa1f03527d7cae26aa18edccc1483b6 (patch) | |
tree | f5c626c9534691c48223b41551a873a79872606a /src | |
parent | 1731b084310f032309e99e2bb35ca906b11f5945 (diff) | |
download | gnunet-2ecad0debfa1f03527d7cae26aa18edccc1483b6.tar.gz gnunet-2ecad0debfa1f03527d7cae26aa18edccc1483b6.zip |
fix
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-nat-client.c | 15 | ||||
-rw-r--r-- | src/transport/gnunet-nat-server.c | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/transport/gnunet-nat-client.c b/src/transport/gnunet-nat-client.c index da0a8064b..80c1c14ad 100644 --- a/src/transport/gnunet-nat-client.c +++ b/src/transport/gnunet-nat-client.c | |||
@@ -329,6 +329,7 @@ process_icmp_response (const struct in_addr *my_ip, | |||
329 | struct in_addr sip; | 329 | struct in_addr sip; |
330 | uint16_t my_magic; | 330 | uint16_t my_magic; |
331 | uint16_t reply_magic; | 331 | uint16_t reply_magic; |
332 | uint16_t local_port; | ||
332 | struct ip_packet ip_pkt; | 333 | struct ip_packet ip_pkt; |
333 | struct icmp_packet icmp_pkt; | 334 | struct icmp_packet icmp_pkt; |
334 | struct udp_packet udp_pkt; | 335 | struct udp_packet udp_pkt; |
@@ -382,6 +383,7 @@ process_icmp_response (const struct in_addr *my_ip, | |||
382 | memcpy(&sip, &ip_pkt.src_ip, sizeof (sip)); | 383 | memcpy(&sip, &ip_pkt.src_ip, sizeof (sip)); |
383 | reply_magic = ntohs (udp_pkt.checksum_aka_my_magic); | 384 | reply_magic = ntohs (udp_pkt.checksum_aka_my_magic); |
384 | my_magic = ntohs (udp_pkt.mlen_aka_reply_port_magic); | 385 | my_magic = ntohs (udp_pkt.mlen_aka_reply_port_magic); |
386 | local_port = ntohs (udp_pkt.source_port); | ||
385 | if (my_magic == 0) | 387 | if (my_magic == 0) |
386 | { | 388 | { |
387 | #if 0 | 389 | #if 0 |
@@ -392,13 +394,14 @@ process_icmp_response (const struct in_addr *my_ip, | |||
392 | return; | 394 | return; |
393 | } | 395 | } |
394 | fprintf (stderr, | 396 | fprintf (stderr, |
395 | "Received ICMP from `%s' with hints %u and %u\n", | 397 | "Received ICMP from `%s' with hints %u and %u to local port %u\n", |
396 | inet_ntop (AF_INET, | 398 | inet_ntop (AF_INET, |
397 | &sip, | 399 | &sip, |
398 | buf, | 400 | buf, |
399 | sizeof (buf)), | 401 | sizeof (buf)), |
400 | my_magic, | 402 | my_magic, |
401 | reply_magic); | 403 | reply_magic, |
404 | local_port); | ||
402 | if (my_magic == 0) | 405 | if (my_magic == 0) |
403 | { | 406 | { |
404 | try_connect (my_ip, &sip, reply_magic); | 407 | try_connect (my_ip, &sip, reply_magic); |
@@ -406,12 +409,14 @@ process_icmp_response (const struct in_addr *my_ip, | |||
406 | else | 409 | else |
407 | { | 410 | { |
408 | send_icmp (my_ip, &target, my_magic, reply_magic); | 411 | send_icmp (my_ip, &target, my_magic, reply_magic); |
409 | printf ("%s:%u\n", | 412 | printf ("%s:%u listen on %u\n", |
410 | inet_ntop (AF_INET, | 413 | inet_ntop (AF_INET, |
411 | &sip, | 414 | &sip, |
412 | buf, | 415 | buf, |
413 | sizeof(buf)), | 416 | sizeof(buf)), |
414 | my_magic); | 417 | my_magic, |
418 | local_port); | ||
419 | /* technically, we're done here! */ | ||
415 | } | 420 | } |
416 | } | 421 | } |
417 | 422 | ||
@@ -549,7 +554,7 @@ main (int argc, char *const *argv) | |||
549 | } | 554 | } |
550 | p = make_port (); | 555 | p = make_port (); |
551 | fprintf (stderr, | 556 | fprintf (stderr, |
552 | "Sending fake ICMP message to %s with port %u\n", | 557 | "Sending fake ICMP message to %s:%u\n", |
553 | argv[1], | 558 | argv[1], |
554 | p); | 559 | p); |
555 | send_icmp (&external, | 560 | send_icmp (&external, |
diff --git a/src/transport/gnunet-nat-server.c b/src/transport/gnunet-nat-server.c index bc1130f9b..ab984d18a 100644 --- a/src/transport/gnunet-nat-server.c +++ b/src/transport/gnunet-nat-server.c | |||
@@ -325,6 +325,7 @@ process_icmp_response (const struct in_addr *my_ip, | |||
325 | struct in_addr sip; | 325 | struct in_addr sip; |
326 | uint16_t my_magic; | 326 | uint16_t my_magic; |
327 | uint16_t reply_magic; | 327 | uint16_t reply_magic; |
328 | uint16_t local_port; | ||
328 | struct ip_packet ip_pkt; | 329 | struct ip_packet ip_pkt; |
329 | struct icmp_packet icmp_pkt; | 330 | struct icmp_packet icmp_pkt; |
330 | struct udp_packet udp_pkt; | 331 | struct udp_packet udp_pkt; |
@@ -378,6 +379,7 @@ process_icmp_response (const struct in_addr *my_ip, | |||
378 | memcpy(&sip, &ip_pkt.src_ip, sizeof (sip)); | 379 | memcpy(&sip, &ip_pkt.src_ip, sizeof (sip)); |
379 | reply_magic = ntohs (udp_pkt.checksum_aka_my_magic); | 380 | reply_magic = ntohs (udp_pkt.checksum_aka_my_magic); |
380 | my_magic = ntohs (udp_pkt.mlen_aka_reply_port_magic); | 381 | my_magic = ntohs (udp_pkt.mlen_aka_reply_port_magic); |
382 | local_port = ntohs (udp_pkt.source_port); | ||
381 | fprintf (stderr, | 383 | fprintf (stderr, |
382 | "Received ICMP from `%s' with hints %u and %u\n", | 384 | "Received ICMP from `%s' with hints %u and %u\n", |
383 | inet_ntop (AF_INET, | 385 | inet_ntop (AF_INET, |
@@ -392,12 +394,14 @@ process_icmp_response (const struct in_addr *my_ip, | |||
392 | } | 394 | } |
393 | else | 395 | else |
394 | { | 396 | { |
395 | printf ("%s:%u\n", | 397 | /* FIXME: should close 'local_port' */ |
398 | printf ("%s:%u listen on %u\n", | ||
396 | inet_ntop (AF_INET, | 399 | inet_ntop (AF_INET, |
397 | &sip, | 400 | &sip, |
398 | buf, | 401 | buf, |
399 | sizeof(buf)), | 402 | sizeof(buf)), |
400 | my_magic); | 403 | my_magic, |
404 | local_port); | ||
401 | } | 405 | } |
402 | } | 406 | } |
403 | 407 | ||