diff options
Diffstat (limited to 'src/testbed')
-rw-r--r-- | src/testbed/gnunet-helper-testbed.c | 30 | ||||
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 10 | ||||
-rw-r--r-- | src/testbed/test_gnunet_helper_testbed.c | 2 | ||||
-rw-r--r-- | src/testbed/testbed_api.c | 17 | ||||
-rw-r--r-- | src/testbed/testbed_api.h | 2 | ||||
-rw-r--r-- | src/testbed/testbed_helper.h | 13 |
6 files changed, 65 insertions, 9 deletions
diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index bc7f223af..0e70645c7 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c | |||
@@ -226,14 +226,18 @@ tokenizer_cb (void *cls, void *client, | |||
226 | struct GNUNET_CONFIGURATION_Handle *cfg; | 226 | struct GNUNET_CONFIGURATION_Handle *cfg; |
227 | struct WriteContext *wc; | 227 | struct WriteContext *wc; |
228 | char *controller; | 228 | char *controller; |
229 | char *hostname; | ||
229 | char *config; | 230 | char *config; |
230 | char *xconfig; | 231 | char *xconfig; |
231 | size_t config_size; | 232 | size_t config_size; |
232 | uLongf ul_config_size; | 233 | uLongf ul_config_size; |
233 | size_t xconfig_size; | 234 | size_t xconfig_size; |
234 | uint16_t cname_size; | 235 | uint16_t cname_size; |
235 | 236 | uint16_t hostname_size; | |
236 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) || | 237 | uint16_t msize; |
238 | |||
239 | msize = ntohs (message->size); | ||
240 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= msize) || | ||
237 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) | 241 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) |
238 | { | 242 | { |
239 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 243 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
@@ -248,6 +252,14 @@ tokenizer_cb (void *cls, void *client, | |||
248 | "Controller name cannot be empty -- exiting\n"); | 252 | "Controller name cannot be empty -- exiting\n"); |
249 | goto error; | 253 | goto error; |
250 | } | 254 | } |
255 | hostname_size = ntohs (msg->hostname_size); | ||
256 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) + cname_size + 1 + | ||
257 | hostname_size) >= msize) | ||
258 | { | ||
259 | GNUNET_break (0); | ||
260 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | ||
261 | goto error; | ||
262 | } | ||
251 | ul_config_size = (uLongf) ntohs (msg->config_size); | 263 | ul_config_size = (uLongf) ntohs (msg->config_size); |
252 | config = GNUNET_malloc (ul_config_size); | 264 | config = GNUNET_malloc (ul_config_size); |
253 | xconfig_size = | 265 | xconfig_size = |
@@ -255,7 +267,7 @@ tokenizer_cb (void *cls, void *client, | |||
255 | sizeof (struct GNUNET_TESTBED_HelperInit)); | 267 | sizeof (struct GNUNET_TESTBED_HelperInit)); |
256 | if (Z_OK != | 268 | if (Z_OK != |
257 | uncompress ((Bytef *) config, &ul_config_size, | 269 | uncompress ((Bytef *) config, &ul_config_size, |
258 | (const Bytef *) (controller + cname_size + 1), | 270 | (const Bytef *) (controller + cname_size + 1 + hostname_size), |
259 | (uLongf) xconfig_size)) | 271 | (uLongf) xconfig_size)) |
260 | { | 272 | { |
261 | LOG (GNUNET_ERROR_TYPE_WARNING, | 273 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -273,7 +285,17 @@ tokenizer_cb (void *cls, void *client, | |||
273 | goto error; | 285 | goto error; |
274 | } | 286 | } |
275 | GNUNET_free (config); | 287 | GNUNET_free (config); |
276 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller); | 288 | hostname = NULL; |
289 | if (0 != hostname_size) | ||
290 | { | ||
291 | hostname = GNUNET_malloc (hostname_size + 1); | ||
292 | (void) strncpy (hostname, ((char *) &msg[1]) + cname_size + 1, hostname_size); | ||
293 | hostname[hostname_size] = '\0'; | ||
294 | } | ||
295 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller, | ||
296 | hostname); | ||
297 | GNUNET_free_non_null (hostname); | ||
298 | hostname = NULL; | ||
277 | GNUNET_assert (NULL != test_system); | 299 | GNUNET_assert (NULL != test_system); |
278 | GNUNET_assert (GNUNET_OK == | 300 | GNUNET_assert (GNUNET_OK == |
279 | GNUNET_TESTING_configuration_create (test_system, cfg)); | 301 | GNUNET_TESTING_configuration_create (test_system, cfg)); |
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index c4a30f12c..0736f5997 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -538,6 +538,11 @@ struct LinkControllersContext | |||
538 | */ | 538 | */ |
539 | static struct Context *master_context; | 539 | static struct Context *master_context; |
540 | 540 | ||
541 | /** | ||
542 | * Our hostname; we give this to all the peers we start | ||
543 | */ | ||
544 | static char *hostname; | ||
545 | |||
541 | /***********/ | 546 | /***********/ |
542 | /* Handles */ | 547 | /* Handles */ |
543 | /***********/ | 548 | /***********/ |
@@ -1237,7 +1242,7 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client, | |||
1237 | master_context->master_ip = GNUNET_strdup (controller_hostname); | 1242 | master_context->master_ip = GNUNET_strdup (controller_hostname); |
1238 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); | 1243 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); |
1239 | master_context->system = | 1244 | master_context->system = |
1240 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); | 1245 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip, hostname); |
1241 | host = | 1246 | host = |
1242 | GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, | 1247 | GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, |
1243 | 0); | 1248 | 0); |
@@ -2832,6 +2837,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2832 | GNUNET_free (master_context); | 2837 | GNUNET_free (master_context); |
2833 | master_context = NULL; | 2838 | master_context = NULL; |
2834 | } | 2839 | } |
2840 | GNUNET_free_non_null (hostname); | ||
2835 | } | 2841 | } |
2836 | 2842 | ||
2837 | 2843 | ||
@@ -2896,6 +2902,8 @@ testbed_run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
2896 | {NULL} | 2902 | {NULL} |
2897 | }; | 2903 | }; |
2898 | 2904 | ||
2905 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string | ||
2906 | (cfg, "testbed", "HOSTNAME", &hostname)); | ||
2899 | GNUNET_SERVER_add_handlers (server, message_handlers); | 2907 | GNUNET_SERVER_add_handlers (server, message_handlers); |
2900 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); | 2908 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); |
2901 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); | 2909 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); |
diff --git a/src/testbed/test_gnunet_helper_testbed.c b/src/testbed/test_gnunet_helper_testbed.c index 7fce9a5d8..db889c1ec 100644 --- a/src/testbed/test_gnunet_helper_testbed.c +++ b/src/testbed/test_gnunet_helper_testbed.c | |||
@@ -212,7 +212,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
212 | &mst_cb, &exp_cb, NULL); | 212 | &mst_cb, &exp_cb, NULL); |
213 | GNUNET_assert (NULL != helper); | 213 | GNUNET_assert (NULL != helper); |
214 | cfg = GNUNET_CONFIGURATION_dup (cfg2); | 214 | cfg = GNUNET_CONFIGURATION_dup (cfg2); |
215 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg); | 215 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, NULL, cfg); |
216 | shandle = | 216 | shandle = |
217 | GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL); | 217 | GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL); |
218 | GNUNET_assert (NULL != shandle); | 218 | GNUNET_assert (NULL != shandle); |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 953488af1..1d99c7e3f 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -1338,10 +1338,12 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1338 | { | 1338 | { |
1339 | struct GNUNET_TESTBED_ControllerProc *cp; | 1339 | struct GNUNET_TESTBED_ControllerProc *cp; |
1340 | struct GNUNET_TESTBED_HelperInit *msg; | 1340 | struct GNUNET_TESTBED_HelperInit *msg; |
1341 | const char *hostname; | ||
1341 | static char *const binary_argv[] = { | 1342 | static char *const binary_argv[] = { |
1342 | HELPER_TESTBED_BINARY, NULL | 1343 | HELPER_TESTBED_BINARY, NULL |
1343 | }; | 1344 | }; |
1344 | 1345 | ||
1346 | hostname = NULL; | ||
1345 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); | 1347 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); |
1346 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) | 1348 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) |
1347 | cp->helper = | 1349 | cp->helper = |
@@ -1352,7 +1354,6 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1352 | char *remote_args[8]; | 1354 | char *remote_args[8]; |
1353 | unsigned int argp; | 1355 | unsigned int argp; |
1354 | const char *username; | 1356 | const char *username; |
1355 | const char *hostname; | ||
1356 | 1357 | ||
1357 | username = GNUNET_TESTBED_host_get_username_ (host); | 1358 | username = GNUNET_TESTBED_host_get_username_ (host); |
1358 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); | 1359 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); |
@@ -1386,7 +1387,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1386 | cp->host = host; | 1387 | cp->host = host; |
1387 | cp->cb = cb; | 1388 | cp->cb = cb; |
1388 | cp->cls = cls; | 1389 | cp->cls = cls; |
1389 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); | 1390 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, hostname, cfg); |
1390 | cp->msg = &msg->header; | 1391 | cp->msg = &msg->header; |
1391 | cp->shandle = | 1392 | cp->shandle = |
1392 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); | 1393 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); |
@@ -1915,12 +1916,14 @@ GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller | |||
1915 | * want to use this in testing | 1916 | * want to use this in testing |
1916 | * | 1917 | * |
1917 | * @param cname the ip address of the controlling host | 1918 | * @param cname the ip address of the controlling host |
1919 | * @param hostname the hostname of the destination this message is intended for | ||
1918 | * @param cfg the configuration that has to used to start the testbed service | 1920 | * @param cfg the configuration that has to used to start the testbed service |
1919 | * thru helper | 1921 | * thru helper |
1920 | * @return the initialization message | 1922 | * @return the initialization message |
1921 | */ | 1923 | */ |
1922 | struct GNUNET_TESTBED_HelperInit * | 1924 | struct GNUNET_TESTBED_HelperInit * |
1923 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 1925 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
1926 | const char *hostname, | ||
1924 | const struct GNUNET_CONFIGURATION_Handle | 1927 | const struct GNUNET_CONFIGURATION_Handle |
1925 | *cfg) | 1928 | *cfg) |
1926 | { | 1929 | { |
@@ -1930,6 +1933,7 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1930 | size_t config_size; | 1933 | size_t config_size; |
1931 | size_t xconfig_size; | 1934 | size_t xconfig_size; |
1932 | uint16_t cname_len; | 1935 | uint16_t cname_len; |
1936 | uint16_t hostname_len; | ||
1933 | uint16_t msg_size; | 1937 | uint16_t msg_size; |
1934 | 1938 | ||
1935 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); | 1939 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); |
@@ -1938,15 +1942,22 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1938 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); | 1942 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); |
1939 | GNUNET_free (config); | 1943 | GNUNET_free (config); |
1940 | cname_len = strlen (cname); | 1944 | cname_len = strlen (cname); |
1945 | hostname_len = (NULL == hostname) ? 0 : strlen (hostname); | ||
1941 | msg_size = | 1946 | msg_size = |
1942 | xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); | 1947 | xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); |
1948 | msg_size += hostname_len; | ||
1943 | msg = GNUNET_realloc (xconfig, msg_size); | 1949 | msg = GNUNET_realloc (xconfig, msg_size); |
1944 | (void) memmove (((void *) &msg[1]) + cname_len + 1, msg, xconfig_size); | 1950 | (void) memmove (((void *) &msg[1]) + cname_len + 1 + hostname_len, |
1951 | msg, | ||
1952 | xconfig_size); | ||
1945 | msg->header.size = htons (msg_size); | 1953 | msg->header.size = htons (msg_size); |
1946 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); | 1954 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); |
1947 | msg->cname_size = htons (cname_len); | 1955 | msg->cname_size = htons (cname_len); |
1956 | msg->hostname_size = htons (hostname_len); | ||
1948 | msg->config_size = htons (config_size); | 1957 | msg->config_size = htons (config_size); |
1949 | (void) strcpy ((char *) &msg[1], cname); | 1958 | (void) strcpy ((char *) &msg[1], cname); |
1959 | if (0 != hostname_len) | ||
1960 | (void) strncpy (((char *) &msg[1]) + cname_len + 1, hostname, hostname_len); | ||
1950 | return msg; | 1961 | return msg; |
1951 | } | 1962 | } |
1952 | 1963 | ||
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index c464b0ad5..020d951a2 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -356,12 +356,14 @@ GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op); | |||
356 | * Creates a helper initialization message. Only for testing. | 356 | * Creates a helper initialization message. Only for testing. |
357 | * | 357 | * |
358 | * @param cname the ip address of the controlling host | 358 | * @param cname the ip address of the controlling host |
359 | * @param hostname the hostname of the destination this message is intended for | ||
359 | * @param cfg the configuration that has to used to start the testbed service | 360 | * @param cfg the configuration that has to used to start the testbed service |
360 | * thru helper | 361 | * thru helper |
361 | * @return the initialization message | 362 | * @return the initialization message |
362 | */ | 363 | */ |
363 | struct GNUNET_TESTBED_HelperInit * | 364 | struct GNUNET_TESTBED_HelperInit * |
364 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 365 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
366 | const char *hostname, | ||
365 | const struct GNUNET_CONFIGURATION_Handle | 367 | const struct GNUNET_CONFIGURATION_Handle |
366 | *cfg); | 368 | *cfg); |
367 | 369 | ||
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h index aee2c5b47..8a3ea55e0 100644 --- a/src/testbed/testbed_helper.h +++ b/src/testbed/testbed_helper.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #ifndef TESTBED_HELPER_H | 28 | #ifndef TESTBED_HELPER_H |
29 | #define TESTBED_HELPER_H | 29 | #define TESTBED_HELPER_H |
30 | 30 | ||
31 | GNUNET_NETWORK_STRUCT_BEGIN | ||
32 | |||
31 | /** | 33 | /** |
32 | * Initialization message for gnunet-helper-testbed to start testbed service | 34 | * Initialization message for gnunet-helper-testbed to start testbed service |
33 | */ | 35 | */ |
@@ -45,12 +47,21 @@ struct GNUNET_TESTBED_HelperInit | |||
45 | uint16_t cname_size GNUNET_PACKED; | 47 | uint16_t cname_size GNUNET_PACKED; |
46 | 48 | ||
47 | /** | 49 | /** |
50 | * The hostname size excluding the NULL termination character - strlen | ||
51 | * (hostname); cannot be zero | ||
52 | */ | ||
53 | uint16_t hostname_size GNUNET_PACKED; | ||
54 | |||
55 | /** | ||
48 | * The size of the uncompressed configuration | 56 | * The size of the uncompressed configuration |
49 | */ | 57 | */ |
50 | uint16_t config_size GNUNET_PACKED; | 58 | uint16_t config_size GNUNET_PACKED; |
51 | 59 | ||
52 | /* Followed by NULL terminated controller hostname */ | 60 | /* Followed by NULL terminated controller hostname */ |
53 | 61 | ||
62 | /* Followed by hostname of the machine on which helper runs. This is not NULL | ||
63 | terminated */ | ||
64 | |||
54 | /* Followed by serialized and compressed configuration which should be | 65 | /* Followed by serialized and compressed configuration which should be |
55 | * config_size long when un-compressed */ | 66 | * config_size long when un-compressed */ |
56 | }; | 67 | }; |
@@ -74,6 +85,8 @@ struct GNUNET_TESTBED_HelperReply | |||
74 | * un-compressed */ | 85 | * un-compressed */ |
75 | }; | 86 | }; |
76 | 87 | ||
88 | GNUNET_NETWORK_STRUCT_END | ||
89 | |||
77 | #endif | 90 | #endif |
78 | 91 | ||
79 | /* end of testbed_helper.h */ | 92 | /* end of testbed_helper.h */ |