diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-23 10:46:03 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-01-23 10:46:03 +0000 |
commit | 121e91bff9459e1ee0615b3b0c1b14c25809f5b9 (patch) | |
tree | b62cbc54514367322e006f796c68316cdd4cc31a /src | |
parent | 27ebda5ab80f37b3c619ae71c07e74205ad577d3 (diff) | |
download | gnunet-121e91bff9459e1ee0615b3b0c1b14c25809f5b9.tar.gz gnunet-121e91bff9459e1ee0615b3b0c1b14c25809f5b9.zip |
use all IP addresses of master controller as trusted ip
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 42bc4d606..194d54a58 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -142,6 +142,11 @@ struct RunContext | |||
142 | void *cc_cls; | 142 | void *cc_cls; |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * The trusted IP string | ||
146 | */ | ||
147 | char *trusted_ip; | ||
148 | |||
149 | /** | ||
145 | * TestMaster callback to call when testbed initialization is done | 150 | * TestMaster callback to call when testbed initialization is done |
146 | */ | 151 | */ |
147 | GNUNET_TESTBED_TestMaster test_master; | 152 | GNUNET_TESTBED_TestMaster test_master; |
@@ -365,6 +370,7 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
365 | if (NULL != rc->cfg) | 370 | if (NULL != rc->cfg) |
366 | GNUNET_CONFIGURATION_destroy (rc->cfg); | 371 | GNUNET_CONFIGURATION_destroy (rc->cfg); |
367 | GNUNET_free_non_null (rc->topo_file); | 372 | GNUNET_free_non_null (rc->topo_file); |
373 | GNUNET_free_non_null (rc->trusted_ip); | ||
368 | GNUNET_free (rc); | 374 | GNUNET_free (rc); |
369 | } | 375 | } |
370 | 376 | ||
@@ -846,6 +852,48 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
846 | 852 | ||
847 | 853 | ||
848 | /** | 854 | /** |
855 | * Callback function invoked for each interface found. | ||
856 | * | ||
857 | * @param cls closure | ||
858 | * @param name name of the interface (can be NULL for unknown) | ||
859 | * @param isDefault is this presumably the default interface | ||
860 | * @param addr address of this interface (can be NULL for unknown or unassigned) | ||
861 | * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned) | ||
862 | * @param netmask the network mask (can be NULL for unknown or unassigned)) | ||
863 | * @param addrlen length of the address | ||
864 | * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort | ||
865 | */ | ||
866 | static int | ||
867 | netint_proc (void *cls, const char *name, | ||
868 | int isDefault, | ||
869 | const struct sockaddr *addr, | ||
870 | const struct sockaddr *broadcast_addr, | ||
871 | const struct sockaddr *netmask, | ||
872 | socklen_t addrlen) | ||
873 | { | ||
874 | struct RunContext *rc = cls; | ||
875 | char hostip[NI_MAXHOST]; | ||
876 | char *buf; | ||
877 | |||
878 | if (sizeof (struct sockaddr_in) != addrlen) | ||
879 | return GNUNET_OK; /* Only consider IPv4 for now */ | ||
880 | if (0 != getnameinfo(addr, addrlen, | ||
881 | hostip, NI_MAXHOST, | ||
882 | NULL, 0, NI_NUMERICHOST)) | ||
883 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "getnameinfo"); | ||
884 | if (NULL == rc->trusted_ip) | ||
885 | { | ||
886 | rc->trusted_ip = GNUNET_strdup (hostip); | ||
887 | return GNUNET_YES; | ||
888 | } | ||
889 | (void) GNUNET_asprintf (&buf, "%s; %s", rc->trusted_ip, hostip); | ||
890 | GNUNET_free (rc->trusted_ip); | ||
891 | rc->trusted_ip = buf; | ||
892 | return GNUNET_YES; | ||
893 | } | ||
894 | |||
895 | |||
896 | /** | ||
849 | * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to | 897 | * Callbacks of this type are called by GNUNET_TESTBED_is_host_habitable to |
850 | * inform whether the given host is habitable or not. The Handle returned by | 898 | * inform whether the given host is habitable or not. The Handle returned by |
851 | * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called | 899 | * GNUNET_TESTBED_is_host_habitable() is invalid after this callback is called |
@@ -892,11 +940,14 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, int status | |||
892 | GNUNET_free (rc->hosts); | 940 | GNUNET_free (rc->hosts); |
893 | rc->hosts = NULL; | 941 | rc->hosts = NULL; |
894 | } | 942 | } |
895 | /* FIXME: If we are starting controller on different host 127.0.0.1 may not ab | 943 | GNUNET_OS_network_interfaces_list (netint_proc, rc); |
896 | correct */ | 944 | if (NULL == rc->trusted_ip) |
945 | rc->trusted_ip = GNUNET_strdup ("127.0.0.1"); | ||
897 | rc->cproc = | 946 | rc->cproc = |
898 | GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, rc->cfg, | 947 | GNUNET_TESTBED_controller_start (rc->trusted_ip, rc->h, rc->cfg, |
899 | &controller_status_cb, rc); | 948 | &controller_status_cb, rc); |
949 | GNUNET_free (rc->trusted_ip); | ||
950 | rc->trusted_ip = NULL; | ||
900 | if (NULL == rc->cproc) | 951 | if (NULL == rc->cproc) |
901 | { | 952 | { |
902 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot start the master controller")); | 953 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot start the master controller")); |