2 This file is part of GNUnet
3 (C) 2008--2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file testbed/testbed_api.c
23 * @brief API for accessing the GNUnet testing service.
24 * This library is supposed to make it easier to write
25 * testcases and script large-scale benchmarks.
26 * @author Christian Grothoff
27 * @author Sree Harsha Totakura
32 #include "gnunet_testbed_service.h"
33 #include "gnunet_core_service.h"
34 #include "gnunet_constants.h"
35 #include "gnunet_transport_service.h"
36 #include "gnunet_hello_lib.h"
40 #include "testbed_api.h"
41 #include "testbed_api_hosts.h"
42 #include "testbed_api_peers.h"
45 * Generic logging shorthand
47 #define LOG(kind, ...) \
48 GNUNET_log_from (kind, "testbed-api", __VA_ARGS__);
53 #define LOG_DEBUG(...) \
54 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__);
57 * Relative time seconds shorthand
59 #define TIME_REL_SECS(sec) \
60 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
64 * Default server message sending retry timeout
66 #define TIMEOUT_REL TIME_REL_SECS(1)
70 * The message queue for sending messages to the controller service
75 * The message to be sent
77 struct GNUNET_MessageHeader *msg;
80 * next pointer for DLL
82 struct MessageQueue *next;
85 * prev pointer for DLL
87 struct MessageQueue *prev;
92 * Structure for a controller link
97 * The next ptr for DLL
99 struct ControllerLink *next;
102 * The prev ptr for DLL
104 struct ControllerLink *prev;
107 * The host which will be referred in the peer start request. This is the
108 * host where the peer should be started
110 struct GNUNET_TESTBED_Host *delegated_host;
113 * The host which will contacted to delegate the peer start request
115 struct GNUNET_TESTBED_Host *slave_host;
118 * The configuration to be used to connect to slave host
120 const struct GNUNET_CONFIGURATION_Handle *slave_cfg;
123 * GNUNET_YES if the slave should be started (and stopped) by us; GNUNET_NO
124 * if we are just allowed to use the slave via TCP/IP
131 * Handle to interact with a GNUnet testbed controller. Each
132 * controller has at least one master handle which is created when the
133 * controller is created; this master handle interacts with the
134 * controller process, destroying it destroys the controller (by
135 * closing stdin of the controller process). Additionally,
136 * controllers can interact with each other (in a P2P fashion); those
137 * links are established via TCP/IP on the controller's service port.
139 struct GNUNET_TESTBED_Controller
143 * The host where the controller is running
145 struct GNUNET_TESTBED_Host *host;
148 * The controller callback
150 GNUNET_TESTBED_ControllerCallback cc;
153 * The closure for controller callback
158 * The configuration to use while connecting to controller
160 struct GNUNET_CONFIGURATION_Handle *cfg;
163 * The client connection handle to the controller service
165 struct GNUNET_CLIENT_Connection *client;
168 * The head of the message queue
170 struct MessageQueue *mq_head;
173 * The tail of the message queue
175 struct MessageQueue *mq_tail;
178 * The head of the ControllerLink list
180 struct ControllerLink *cl_head;
183 * The tail of the ControllerLink list
185 struct ControllerLink *cl_tail;
188 * The client transmit handle
190 struct GNUNET_CLIENT_TransmitHandle *th;
193 * The host registration handle; NULL if no current registration requests are
196 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
199 * The controller event mask
204 * Did we start the receive loop yet?
209 * Did we create the host for this?
216 * handle for host registration
218 struct GNUNET_TESTBED_HostRegistrationHandle
221 * The host being registered
223 struct GNUNET_TESTBED_Host *host;
226 * The controller at which this host is being registered
228 struct GNUNET_TESTBED_Controller *c;
231 * The Registartion completion callback
233 GNUNET_TESTBED_HostRegistrationCompletion cc;
236 * The closure for above callback
243 * The global operation id counter
245 uint64_t GNUNET_TESTBED_operation_id;
248 * The head of the operation queue
250 struct GNUNET_TESTBED_Operation *op_head;
253 * The tail of the operation queue
255 struct GNUNET_TESTBED_Operation *op_tail;
259 * Adds an operation to the queue of operations
261 * @param op the operation to add
264 GNUNET_TESTBED_operation_add (struct GNUNET_TESTBED_Operation *op)
266 GNUNET_CONTAINER_DLL_insert_tail (op_head, op_tail, op);
271 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
272 * controller (testbed service)
274 * @param c the controller handler
275 * @param msg message received
276 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
280 handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c,
281 const struct GNUNET_TESTBED_HostConfirmedMessage *msg)
283 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
292 if (GNUNET_TESTBED_host_get_id_ (rh->host) != ntohl (msg->host_id))
294 LOG_DEBUG ("Mismatch in host id's %u, %u of host confirm msg\n",
295 GNUNET_TESTBED_host_get_id_ (rh->host), ntohl (msg->host_id));
299 msg_size = ntohs (msg->header.size);
300 if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size)
302 LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id));
303 GNUNET_TESTBED_mark_host_registered_at_ (rh->host, c);
304 rh->cc (rh->cc_cls, NULL);
308 /* We have an error message */
309 emsg = (char *) &msg[1];
310 if ('\0' != emsg[msg_size -
311 sizeof (struct GNUNET_TESTBED_HostConfirmedMessage)])
317 LOG (GNUNET_ERROR_TYPE_ERROR, _("Adding host %u failed with error: %s\n"),
318 ntohl (msg->host_id), emsg);
319 rh->cc (rh->cc_cls, emsg);
326 * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
327 * controller (testbed service)
329 * @param c the controller handler
330 * @param msg message received
331 * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
335 handle_opsuccess (struct GNUNET_TESTBED_Controller *c,
337 GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg)
339 struct GNUNET_TESTBED_Operation *op;
340 struct GNUNET_TESTBED_EventInformation *event;
343 op_id = GNUNET_ntohll (msg->operation_id);
344 LOG_DEBUG ("Operation %ul successful\n", op_id);
345 for (op = op_head; NULL != op; op = op->next)
347 if (op->operation_id == op_id)
352 LOG_DEBUG ("Operation not found\n");
356 if (0 != (c->event_mask & (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED)))
357 event = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_EventInformation));
359 event->type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
362 case OP_PEER_DESTROY:
364 struct PeerDestroyData *data;
368 event->details.operation_finished.operation = op;
369 event->details.operation_finished.op_cls = NULL;
370 event->details.operation_finished.emsg = NULL;
371 event->details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC;
372 event->details.operation_finished.op_result.generic = NULL;
374 data = (struct PeerDestroyData *) op->data;
375 if (NULL != data->peer->details)
377 if (NULL != data->peer->details->cfg)
378 GNUNET_CONFIGURATION_destroy (data->peer->details->cfg);
381 GNUNET_free (data->peer);
392 c->cc (c->cc_cls, event);
394 GNUNET_CONTAINER_DLL_remove (op_head, op_tail, op);
401 * Handler for messages from controller (testbed service)
403 * @param cls the controller handler
404 * @param msg message received, NULL on timeout or fatal error
407 message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
409 struct GNUNET_TESTBED_Controller *c = cls;
412 c->in_receive = GNUNET_NO;
413 /* FIXME: Add checks for message integrity */
416 LOG_DEBUG ("Receive timed out or connection to service dropped\n");
420 switch (ntohs (msg->type))
422 case GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM:
424 handle_addhostconfirm (c, (const struct
425 GNUNET_TESTBED_HostConfirmedMessage *) msg);
427 case GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS:
429 handle_opsuccess (c, (const struct
430 GNUNET_TESTBED_GenericOperationSuccessEventMessage
435 if ((GNUNET_OK == status) && (GNUNET_NO == c->in_receive))
437 c->in_receive = GNUNET_YES;
438 GNUNET_CLIENT_receive (c->client, &message_handler, c,
439 GNUNET_TIME_UNIT_FOREVER_REL);
444 * Function called to notify a client about the connection begin ready to queue
445 * more data. "buf" will be NULL and "size" zero if the connection was closed
446 * for writing in the meantime.
449 * @param size number of bytes available in buf
450 * @param buf where the callee should write the message
451 * @return number of bytes written to buf
454 transmit_ready_notify (void *cls, size_t size, void *buf)
456 struct GNUNET_TESTBED_Controller *c = cls;
457 struct MessageQueue *mq_entry;
460 mq_entry = c->mq_head;
461 GNUNET_assert (NULL != mq_entry);
462 if ((0 == size) && (NULL == buf)) /* Timeout */
464 LOG_DEBUG ("Message sending timed out -- retrying\n");
466 GNUNET_CLIENT_notify_transmit_ready (c->client,
467 ntohs (mq_entry->msg->size),
469 GNUNET_YES, &transmit_ready_notify,
473 GNUNET_assert (ntohs (mq_entry->msg->size) <= size);
474 size = ntohs (mq_entry->msg->size);
475 memcpy (buf, mq_entry->msg, size);
476 LOG_DEBUG ("Message of type: %u and size: %u sent\n",
477 ntohs (mq_entry->msg->type), size);
478 GNUNET_free (mq_entry->msg);
479 GNUNET_CONTAINER_DLL_remove (c->mq_head, c->mq_tail, mq_entry);
480 GNUNET_free (mq_entry);
481 mq_entry = c->mq_head;
482 if (NULL != mq_entry)
484 GNUNET_CLIENT_notify_transmit_ready (c->client,
485 ntohs (mq_entry->msg->size),
487 GNUNET_YES, &transmit_ready_notify,
489 if (GNUNET_NO == c->in_receive)
491 c->in_receive = GNUNET_YES;
492 GNUNET_CLIENT_receive (c->client, &message_handler, c,
493 GNUNET_TIME_UNIT_FOREVER_REL);
500 * Queues a message in send queue for sending to the service
502 * @param controller the handle to the controller
503 * @param msg the message to queue
506 GNUNET_TESTBED_queue_message (struct GNUNET_TESTBED_Controller *controller,
507 struct GNUNET_MessageHeader *msg)
509 struct MessageQueue *mq_entry;
513 type = ntohs (msg->type);
514 size = ntohs (msg->size);
515 GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) &&
516 (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type));
517 mq_entry = GNUNET_malloc (sizeof (struct MessageQueue));
519 LOG (GNUNET_ERROR_TYPE_DEBUG,
520 "Queueing message of type %u, size %u for sending\n", type,
522 GNUNET_CONTAINER_DLL_insert_tail (controller->mq_head, controller->mq_tail,
524 if (NULL == controller->th)
526 GNUNET_CLIENT_notify_transmit_ready (controller->client, size,
528 GNUNET_YES, &transmit_ready_notify,
534 * Handle for controller process
536 struct GNUNET_TESTBED_ControllerProc
541 struct GNUNET_TESTBED_HelperHandle *helper;
547 * Starts a controller process at the host
549 * @param host the host where the controller has to be started; NULL for localhost
550 * @return the controller process handle
552 struct GNUNET_TESTBED_ControllerProc *
553 GNUNET_TESTBED_controller_start (struct GNUNET_TESTBED_Host *host)
555 struct GNUNET_TESTBED_ControllerProc *cproc;
556 char * const binary_argv[] = {
557 "gnunet-service-testbed",
558 "gnunet-service-testbed",
562 cproc = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc));
563 cproc->helper = GNUNET_TESTBED_host_run_ (host, binary_argv);
564 if (NULL == cproc->helper)
574 * Stop the controller process (also will terminate all peers and controllers
575 * dependent on this controller). This function blocks until the testbed has
576 * been fully terminated (!).
578 * @param cproc the controller process handle
581 GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc)
583 GNUNET_TESTBED_host_stop_ (cproc->helper);
589 * Start a controller process using the given configuration at the
592 * @param cfg configuration to use
593 * @param host host to run the controller on; This should be the same host if
594 * the controller was previously started with
595 * GNUNET_TESTBED_controller_start; NULL for localhost
596 * @param event_mask bit mask with set of events to call 'cc' for;
597 * or-ed values of "1LL" shifted by the
598 * respective 'enum GNUNET_TESTBED_EventType'
599 * (i.e. "(1LL << GNUNET_TESTBED_ET_CONNECT) | ...")
600 * @param cc controller callback to invoke on events
601 * @param cc_cls closure for cc
602 * @return handle to the controller
604 struct GNUNET_TESTBED_Controller *
605 GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
606 struct GNUNET_TESTBED_Host *host,
608 GNUNET_TESTBED_ControllerCallback cc,
611 struct GNUNET_TESTBED_Controller *controller;
612 struct GNUNET_TESTBED_InitMessage *msg;
614 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
616 controller->cc_cls = cc_cls;
617 controller->event_mask = event_mask;
618 controller->cfg = GNUNET_CONFIGURATION_dup (cfg);
619 controller->client = GNUNET_CLIENT_connect ("testbed", controller->cfg);
620 if (NULL == controller->client)
622 GNUNET_TESTBED_controller_disconnect (controller);
627 host = GNUNET_TESTBED_host_create_by_id_ (0);
630 LOG (GNUNET_ERROR_TYPE_WARNING,
631 "Treating NULL host as localhost. Multiple references to localhost. "
632 " May break when localhost freed before calling disconnect \n");
633 host = GNUNET_TESTBED_host_lookup_by_id_ (0);
637 controller->aux_host = GNUNET_YES;
640 GNUNET_assert (NULL != host);
641 msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage));
642 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT);
643 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_InitMessage));
644 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
645 msg->event_mask = GNUNET_htonll (controller->event_mask);
646 GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) msg);
652 * Configure shared services at a controller. Using this function,
653 * you can specify that certain services (such as "resolver")
654 * should not be run for each peer but instead be shared
655 * across N peers on the specified host. This function
656 * must be called before any peers are created at the host.
658 * @param controller controller to configure
659 * @param service_name name of the service to share
660 * @param num_peers number of peers that should share one instance
661 * of the specified service (1 for no sharing is the default),
662 * use 0 to disable the service
665 GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller,
666 const char *service_name,
669 struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg;
670 uint16_t service_name_size;
673 service_name_size = strlen (service_name) + 1;
674 msg_size = sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage)
676 msg = GNUNET_malloc (msg_size);
677 msg->header.size = htons (msg_size);
678 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE);
679 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (controller->host));
680 msg->num_peers = htonl (num_peers);
681 memcpy (&msg[1], service_name, service_name_size);
682 GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) msg);
687 * disconnects from the controller.
689 * @param controller handle to controller to stop
692 GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controller)
694 struct MessageQueue *mq_entry;
696 if (NULL != controller->th)
697 GNUNET_CLIENT_notify_transmit_ready_cancel (controller->th);
698 /* Clear the message queue */
699 while (NULL != (mq_entry = controller->mq_head))
701 GNUNET_CONTAINER_DLL_remove (controller->mq_head,
704 GNUNET_free (mq_entry->msg);
705 GNUNET_free (mq_entry);
707 if (NULL != controller->client)
708 GNUNET_CLIENT_disconnect (controller->client);
709 GNUNET_CONFIGURATION_destroy (controller->cfg);
710 if (GNUNET_YES == controller->aux_host)
711 GNUNET_TESTBED_host_destroy (controller->host);
712 GNUNET_free (controller);
717 * Register a host with the controller
719 * @param controller the controller handle
720 * @param host the host to register
721 * @param cc the completion callback to call to inform the status of
722 * registration. After calling this callback the registration handle
723 * will be invalid. Cannot be NULL.
724 * @param cc_cls the closure for the cc
725 * @return handle to the host registration which can be used to cancel the
728 struct GNUNET_TESTBED_HostRegistrationHandle *
729 GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller,
730 struct GNUNET_TESTBED_Host *host,
731 GNUNET_TESTBED_HostRegistrationCompletion cc,
734 struct GNUNET_TESTBED_HostRegistrationHandle *rh;
735 struct GNUNET_TESTBED_AddHostMessage *msg;
736 const char *username;
737 const char *hostname;
739 uint16_t user_name_length;
741 if (NULL != controller->rh)
743 hostname = GNUNET_TESTBED_host_get_hostname_ (host);
744 if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller))
746 LOG (GNUNET_ERROR_TYPE_WARNING,
747 "Host hostname: %s already registered\n",
748 (NULL == hostname) ? "localhost" : hostname);
751 rh = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostRegistrationHandle));
754 GNUNET_assert (NULL != cc);
758 username = GNUNET_TESTBED_host_get_username_ (host);
759 msg_size = (sizeof (struct GNUNET_TESTBED_AddHostMessage));
760 user_name_length = 0;
761 if (NULL != username)
763 user_name_length = strlen (username) + 1;
764 msg_size += user_name_length;
766 /* FIXME: what happens when hostname is NULL? localhost */
767 GNUNET_assert (NULL != hostname);
768 msg_size += strlen (hostname) + 1;
769 msg = GNUNET_malloc (msg_size);
770 msg->header.size = htons (msg_size);
771 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST);
772 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
773 msg->ssh_port = htons (GNUNET_TESTBED_host_get_ssh_port_ (host));
774 msg->user_name_length = htons (user_name_length);
775 if (NULL != username)
776 memcpy (&msg[1], username, user_name_length);
777 strcpy (((void *) &msg[1]) + user_name_length, hostname);
778 GNUNET_TESTBED_queue_message (controller, (struct GNUNET_MessageHeader *) msg);
784 * Cancel the pending registration. Note that if the registration message is
785 * already sent to the service the cancellation has only the effect that the
786 * registration completion callback for the registration is never called.
788 * @param handle the registration handle to cancel
791 GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle
794 if (handle != handle->c->rh)
799 handle->c->rh = NULL;
800 GNUNET_free (handle);
805 * Same as the GNUNET_TESTBED_controller_link, however expects configuration in
806 * serialized and compressed
808 * @param master handle to the master controller who creates the association
809 * @param delegated_host requests to which host should be delegated; cannot be NULL
810 * @param slave_host which host is used to run the slave controller; use NULL to
811 * make the master controller connect to the delegated host
812 * @param sxcfg serialized and compressed configuration
813 * @param sxcfg_size the size scfg
814 * @param scfg_size the size of uncompressed serialized configuration
815 * @param is_subordinate GNUNET_YES if the controller at delegated_host should
816 * be started by the master controller; GNUNET_NO if we are just
817 * allowed to use the slave via TCP/IP
820 GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master,
821 struct GNUNET_TESTBED_Host *delegated_host,
822 struct GNUNET_TESTBED_Host *slave_host,
828 struct GNUNET_TESTBED_ControllerLinkMessage *msg;
831 GNUNET_assert (GNUNET_YES ==
832 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
833 if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host)))
834 GNUNET_assert (GNUNET_YES ==
835 GNUNET_TESTBED_is_host_registered_ (slave_host, master));
836 msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkMessage);
837 msg = GNUNET_malloc (msg_size);
838 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS);
839 msg->header.size = htons (msg_size);
840 msg->delegated_host_id = htonl (GNUNET_TESTBED_host_get_id_ (delegated_host));
841 msg->slave_host_id = htonl (GNUNET_TESTBED_host_get_id_
842 ((NULL != slave_host) ? slave_host : master->host));
843 msg->config_size = htons ((uint16_t) scfg_size);
844 msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
845 memcpy (&msg[1], sxcfg, sxcfg_size);
846 GNUNET_TESTBED_queue_message (master, (struct GNUNET_MessageHeader *) msg);
851 * Compresses given configuration using zlib compress
853 * @param config the serialized configuration
854 * @param size the size of config
855 * @param xconfig will be set to the compressed configuration (memory is fresly
857 * @return the size of the xconfig
860 GNUNET_TESTBED_compress_config (const char *config, size_t size,
865 xsize = compressBound ((uLong) size);
866 *xconfig = GNUNET_malloc (xsize);
867 GNUNET_assert (Z_OK ==
868 compress2 ((Bytef *)* xconfig, (uLongf *) &xsize,
869 (const Bytef *) config, (uLongf) size,
876 * Create a link from slave controller to delegated controller. Whenever the
877 * master controller is asked to start a peer at the delegated controller the
878 * request will be routed towards slave controller (if a route exists). The
879 * slave controller will then route it to the delegated controller. The
880 * configuration of the slave controller is given and to be used to either
881 * create the slave controller or to connect to an existing slave controller
882 * process. 'is_subordinate' specifies if the given slave controller should be
883 * started and managed by the master controller, or if the slave already has a
884 * master and this is just a secondary master that is also allowed to use the
887 * @param master handle to the master controller who creates the association
888 * @param delegated_host requests to which host should be delegated
889 * @param slave_host which host is used to run the slave controller
890 * @param slave_cfg configuration to use for the slave controller
891 * @param is_subordinate GNUNET_YES if the slave should be started (and stopped)
892 * by the master controller; GNUNET_NO if we are just
893 * allowed to use the slave via TCP/IP
896 GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master,
897 struct GNUNET_TESTBED_Host *delegated_host,
898 struct GNUNET_TESTBED_Host *slave_host,
899 const struct GNUNET_CONFIGURATION_Handle *slave_cfg,
907 GNUNET_assert (GNUNET_YES ==
908 GNUNET_TESTBED_is_host_registered_ (delegated_host, master));
909 if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host)))
910 GNUNET_assert (GNUNET_YES ==
911 GNUNET_TESTBED_is_host_registered_ (slave_host, master));
912 config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size);
913 cc_size = GNUNET_TESTBED_compress_config (config, config_size, &cconfig);
914 GNUNET_free (config);
915 GNUNET_assert ((UINT16_MAX -
916 sizeof (struct GNUNET_TESTBED_ControllerLinkMessage))
917 >= cc_size); /* Configuration doesn't fit in 1 message */
918 GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host,
919 (const char *) cconfig,
920 cc_size, config_size, is_subordinate);
921 GNUNET_free (cconfig);
926 * Ask the testbed controller to write the current overlay topology to
927 * a file. Naturally, the file will only contain a snapshot as the
928 * topology may evolve all the time.
930 * @param controller overlay controller to inspect
931 * @param filename name of the file the topology should
935 GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller,
936 const char *filename)
943 /* end of testbed_api.c */