diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-12-17 09:08:53 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-12-17 09:08:53 +0100 |
commit | 6c60f595b5bd12945dfcb19141129e8842a09e24 (patch) | |
tree | 36393b3b6c6844a09bb03920f87ed2e7005a45f3 /src/nat/gnunet-service-nat.c | |
parent | 714a98ab0c0d29e9d2a4226a41fa4cf7d45291bd (diff) | |
download | gnunet-6c60f595b5bd12945dfcb19141129e8842a09e24.tar.gz gnunet-6c60f595b5bd12945dfcb19141129e8842a09e24.zip |
finish external-ip client notification, but not yet tested
Diffstat (limited to 'src/nat/gnunet-service-nat.c')
-rw-r--r-- | src/nat/gnunet-service-nat.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index bf82ce7eb..215c4218f 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -769,23 +769,41 @@ check_notify_client_external_ipv4_change (const struct in_addr *v4, | |||
769 | int add) | 769 | int add) |
770 | { | 770 | { |
771 | struct sockaddr_in sa; | 771 | struct sockaddr_in sa; |
772 | uint16_t port; | ||
773 | uint16_t bport; | ||
772 | 774 | ||
773 | // FIXME: (1) check if client cares; | 775 | /* (1) check if client cares. */ |
774 | GNUNET_break (0); // FIXME: implement! | 776 | if (! ch->natted_address) |
777 | return; | ||
778 | if (0 == (GNUNET_NAT_RF_ADDRESSES & ch->flags)) | ||
779 | return; | ||
780 | bport = 0; | ||
781 | for (unsigned int i=0;i<ch->num_addrs;i++) | ||
782 | { | ||
783 | const struct sockaddr *sa = ch->addrs[i]; | ||
784 | |||
785 | if (AF_INET != sa->sa_family) | ||
786 | continue; | ||
787 | bport = ntohs (((const struct sockaddr_in *) sa)->sin_port); | ||
788 | } | ||
789 | if (0 == bport) | ||
790 | return; /* IPv6-only */ | ||
775 | 791 | ||
776 | /* (2) figure out external port, build sockaddr */ | 792 | /* (2) figure out external port, build sockaddr */ |
793 | port = ch->adv_port; | ||
794 | if (0 == port) | ||
795 | port = bport; | ||
777 | memset (&sa, | 796 | memset (&sa, |
778 | 0, | 797 | 0, |
779 | sizeof (sa)); | 798 | sizeof (sa)); |
780 | sa.sin_family = AF_INET; | 799 | sa.sin_family = AF_INET; |
781 | sa.sin_addr = *v4; | 800 | sa.sin_addr = *v4; |
782 | sa.sin_port = 42; // FIXME | 801 | sa.sin_port = htons (port); |
783 | 802 | ||
784 | /* (3) notify client of change */ | 803 | /* (3) notify client of change */ |
785 | 804 | notify_client (is_nat_v4 (v4) | |
786 | // FIXME: handle case where 'v4' is still in the NAT range | 805 | ? GNUNET_NAT_AC_LAN_PRIVATE |
787 | // (in case of double-NAT!) | 806 | : GNUNET_NAT_AC_GLOBAL_EXTERN, |
788 | notify_client (GNUNET_NAT_AC_GLOBAL_EXTERN, | ||
789 | ch, | 807 | ch, |
790 | add, | 808 | add, |
791 | &sa, | 809 | &sa, |