188 unsigned int orig_size;
241 struct Peer *remote_peer;
246 remote_peer = fopc->
cls;
340 if (NULL != prc->
cfg)
364 for (fopc =
fopcq_head; NULL != fopc; fopc = fopcn)
375 for (mctx =
mctx_head; NULL != mctx; mctx = mctxn)
381 for (prc =
prc_head; NULL != prc; prc = prcn)
401 struct Peer *remote_peer;
406 remote_peer = fopc->
cls;
447 host_id = ntohl (
msg->host_id);
452 "Peer with ID %u already exists",
465 "Cannot create peer with given ID");
492 LOG_DEBUG (
"Creating peer with id: %u\n",
493 (
unsigned int)
peer->id);
494 peer->details.local.peer =
499 if (NULL ==
peer->details.local.peer)
502 "Configuring peer failed: %s\n",
534 peer->details.remote.remote_host_id = host_id;
574 LOG_DEBUG (
"Received peer destroy on peer: %u and operation id: %llu\n",
580 "Asked to destroy a non existent peer with id: %u\n",
peer_id);
583 "Peer doesn't exist");
614 if (0 ==
peer->reference_cnt)
618 "Delaying peer destroy as peer is currently in use\n");
658 "Asked to start a non existent peer with id: %u\n",
725 "Received PEER_STOP for peer %u\n",
739 "Forwarding PEER_STOP for peer %u\n",
766 "Stopping peer %u failed\n",
775 "Peer %u successfully stopped\n",
813 LOG_DEBUG (
"Received GET_CONFIG for peer %u\n",
826 LOG_DEBUG (
"Forwarding PEER_GET_CONFIG for peer: %u\n",
850 LOG_DEBUG (
"Received PEER_GET_CONFIG for peer: %u\n",
905 peer->details.local.peer
907 peer->details.local.cfg,
949 "Failed to start reconfigured peer");
1035 LOG_DEBUG (
"Received PEER_RECONFIGURE for peer %u\n",
1037 if (0 <
peer->reference_cnt)
1051 "Peer is being destroyed");
1061 "Compression error");
1086 "Error trying to stop peer %u asynchronously\n",
1133 return _ (
"Message was sent successfully");
1136 return _ (
"We disconnected from ARM before we could send a request");
1138 return _ (
"Unknown request status");
1154 return _ (
"%s is stopped");
1157 return _ (
"%s is starting");
1160 return _ (
"%s is stopping");
1163 return _ (
"%s is starting already");
1166 return _ (
"%s is stopping already");
1169 return _ (
"%s is started already");
1172 return _ (
"%s is stopped already");
1175 return _ (
"%s service is not known to ARM");
1178 return _ (
"%s service failed to start");
1181 return _ (
"%s service can't be started because ARM is shutting down");
1183 return _ (
"%.s Unknown result code.");
1211 "Error communicating with Peer %u's ARM: %s",
1216 if (1 == mctx->
start)
1217 goto service_start_check;
1232 service_start_check:
1276 msize = ntohs (
msg->header.
size);
1278 if (
'\0' !=
service[msize -
sizeof
1311 LOG_DEBUG (
"Received request to manage service %s on peer %u\n",
1316 GNUNET_asprintf (&emsg,
"Asked to manage service of a non existent peer "
1320 if (0 == strcasecmp (
"arm",
service))
1322 emsg =
GNUNET_strdup (
"Cannot start/stop peer's ARM service. "
1323 "Use peer start/stop for that");
1357 if ((0 !=
peer->reference_cnt)
1358 && ((0 == strcasecmp (
"core",
service))
1359 || (0 == strcasecmp (
"transport",
service))))
1362 "since it is required by existing operations",
1370 "Cannot connect to ARM service of peer with id: %u",
1376 peer->reference_cnt++;
1377 mctx->
op_id = op_id;
1385 if (1 == mctx->
start)
1477 "Timeout at a slave controller");
1503 struct Slave *slave;
1508 LOG_DEBUG (
"Received SHUTDOWN_PEERS\n");
1526 LOG_DEBUG (
"Forwarding SHUTDOWN_PEERS\n");
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static char * peer_id
Option –peer.
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
#define LOG_DEBUG(...)
Debug logging shorthand.
static int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
void GST_forwarded_operation_reply_relay(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to relay the reply msg of a forwarded operation back to the client.
void GST_clear_fopcq()
Clears the forwarded operations queue.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
unsigned int GST_peer_list_size
The size of the peer list.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
void GST_send_operation_success_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id)
Function to send generic operation success message to given client.
data structures shared amongst components of TESTBED service
#define GST_array_grow_large_enough(ptr, size, accommodate_size)
Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call ...
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct Route * GST_find_dest_route(uint32_t host_id)
Finds the route with directly connected host as destination through which the destination host can be...
#define LIST_GROW_STEP
By how much should the arrays lists grow.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
unsigned int GST_slave_list_size
The size of directly linked neighbours list.
struct Slave ** GST_slave_list
A list of directly linked neighbours.
static void service_manage_result_cb(void *cls, enum GNUNET_ARM_RequestStatus rs, enum GNUNET_ARM_Result result)
Function called in response to a start/stop request.
static int start_peer(struct Peer *peer)
Stats a peer.
static char * update_peer_config(struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
Update peer configuration.
int check_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
void GST_free_prcq()
Cleans up the Peer reconfigure context list.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
void handle_peer_destroy(void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
static void shutdown_peers_reply_cb(void *cls, const struct GNUNET_MessageHeader *msg)
The reply msg handler forwarded SHUTDOWN_PEERS operation.
void GST_notify_client_disconnect_peers(struct GNUNET_SERVICE_Client *client)
Notify peers subsystem that client disconnected.
static void peer_list_remove(struct Peer *peer)
Removes a the give peer from the peer array.
static const char * arm_req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
static const char * arm_ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
static void prc_stop_cb(void *cls, struct GNUNET_TESTING_Peer *p, int success)
Callback to inform whether the peer is running or stopped.
void handle_shutdown_peers(void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successful.
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
void GST_free_mctxq()
Frees the ManageServiceContext queue.
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer's service.
static int stop_peer(struct Peer *peer)
Stops a peer.
void handle_peer_get_config(void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION messages.
void handle_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE messages.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
void handle_peer_start(void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
void handle_peer_stop(void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
Message handler for GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER messages.
void GST_destroy_peers()
Stops and destroys all peers.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
static void peer_destroy_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer destroy operation is successful.
void handle_peer_reconfigure(void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.
int check_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
struct Peer ** GST_peer_list
A list of peers we know about.
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
void handle_peer_create(void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.
static void peer_create_forward_timeout(void *cls)
The task to be executed if the forwarded peer create operation has been timed out.
int check_manage_peer_service(void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.
static const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_OS_Process * p
Helper process we started.
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_start(struct GNUNET_ARM_Handle *h, const char *service_name, enum GNUNET_OS_InheritStdioFlags std_inheritance, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request for a service to be started.
struct GNUNET_ARM_Handle * GNUNET_ARM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ARM_ConnectionStatusCallback conn_status, void *conn_status_cls)
Set up a context for communicating with ARM, then start connecting to the ARM service using that cont...
struct GNUNET_ARM_Operation * GNUNET_ARM_request_service_stop(struct GNUNET_ARM_Handle *h, const char *service_name, GNUNET_ARM_ResultCallback cont, void *cont_cls)
Request a service to be stopped.
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
GNUNET_ARM_Result
Replies to ARM requests.
GNUNET_ARM_RequestStatus
Statuses of the requests that client can send to ARM.
@ GNUNET_ARM_RESULT_IS_NOT_KNOWN
Asked to start or stop a service, but it's not known.
@ GNUNET_ARM_RESULT_IS_STARTING_ALREADY
Asked to start it, but it's already starting.
@ GNUNET_ARM_RESULT_IS_STOPPED_ALREADY
Asked to stop it, but it's already stopped.
@ GNUNET_ARM_RESULT_STARTING
Service starting was initiated.
@ GNUNET_ARM_RESULT_IS_STARTED_ALREADY
Asked to start it, but it's already started.
@ GNUNET_ARM_RESULT_STOPPING
ARM stopping was initiated (there's no "stopped" for ARM itself).
@ GNUNET_ARM_RESULT_IS_STOPPING_ALREADY
Asked to stop it, but it's already stopping.
@ GNUNET_ARM_RESULT_STOPPED
Service was stopped (never sent for ARM itself).
@ GNUNET_ARM_RESULT_START_FAILED
Tried to start a service, but that failed for some reason.
@ GNUNET_ARM_RESULT_IN_SHUTDOWN
Asked to start something, but ARM is shutting down and can't comply.
@ GNUNET_ARM_REQUEST_DISCONNECTED
We disconnected from ARM, and request was not sent.
@ GNUNET_ARM_REQUEST_SENT_OK
Message was sent successfully.
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
void GNUNET_CONFIGURATION_set_value_number(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long number)
Set a configuration value that should be a number.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
@ GNUNET_OS_INHERIT_STD_ERR
When this flag is set, the child process will inherit stderr of the parent.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer's information.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ GNUNET_TESTBED_ET_PEER_START
A peer has been started.
@ GNUNET_TESTBED_ET_PEER_STOP
A peer has been stopped.
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
struct GNUNET_TESTING_Peer * GNUNET_TESTING_peer_configure(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t key_number, struct GNUNET_PeerIdentity *id, char **emsg)
Configure a GNUnet peer.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
int GNUNET_TESTING_peer_stop_async(struct GNUNET_TESTING_Peer *peer, GNUNET_TESTING_PeerStopCallback cb, void *cb_cls)
Stop a peer asynchronously using ARM API.
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer's main process.
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
uint32_t host_id
Our host id according to this context.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
Context information for operations forwarded to subcontrollers.
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
void * cls
Closure pointer.
enum OperationType type
The type of the operation which is forwarded.
struct OperationContext * opc
The generated operation context.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct ForwardedOperationContext * next
The next pointer for DLL.
uint64_t operation_id
The id of the operation that has been forwarded.
Handle for interacting with ARM.
Handle to a client that is connected to a service.
Message to start/stop services of a peer.
Message sent from client to testing service to create (configure, but not start) a peer.
Event notification from a controller to a client.
uint32_t peer_id
Peer identity of the peer that was created.
uint64_t operation_id
Operation ID of the operation that created this event.
Message sent from client to testing service to destroy a (stopped) peer.
Event notification from a controller to a client.
uint32_t peer_id
Peer that was started or stopped.
uint64_t operation_id
Operation ID that is used to identify this operation.
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
uint32_t host_id
Host where the peer is running.
Message sent from client to testing service to obtain the configuration of a peer.
Message sent from client to testing service to start a peer.
Message sent from client to testing service to stop a peer.
struct GNUNET_TESTBED_Controller * controller
Our controller context (not necessarily the controller that is responsible for starting/running the p...
Handle for a GNUnet peer controlled by testing.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
int timeout
Did we observe a timeout with respect to this operation at any of the slaves.
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
Context information to manage peers' services.
uint64_t op_id
The operation id of the associated request.
struct ManageServiceContext * next
DLL next ptr.
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer's service.
char * service
Name of the service.
struct ManageServiceContext * prev
DLL prev ptr.
struct Peer * peer
peer whose service has to be managed
uint8_t expired
Is this context expired? Do not work on this context if it is set to GNUNET_YES.
Context information for peer re-configure operations.
uint8_t stopped
The the peer stopped? Used while cleaning up this context to decide whether the asynchronous stop req...
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
uint64_t op_id
The id of the operation.
struct PeerReconfigureContext * prev
DLL prev.
uint32_t peer_id
The id of the peer which has to be reconfigured.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
struct Slave * slave
The slave this peer is started through.
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer,...
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts.
uint32_t id
Our local reference id for this peer.
uint32_t dest
destination host
Structure representing a connected(directly-linked) controller.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
struct OperationContext * GNUNET_TESTBED_forward_operation_msg_(struct GNUNET_TESTBED_Controller *controller, uint64_t operation_id, const struct GNUNET_MessageHeader *msg, GNUNET_MQ_MessageCallback cc, void *cc_cls)
Sends the given message as an operation.
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
@ OP_PEER_RECONFIGURE
Reconfigure a peer.
@ OP_PEER_START
Peer start operation.
@ OP_PEER_INFO
Get peer information operation.
@ OP_SHUTDOWN_PEERS
Stop and destroy all peers.
@ OP_MANAGE_SERVICE
Start/stop service at a peer.
@ OP_PEER_DESTROY
Peer destroy operation.
@ OP_PEER_STOP
Peer stop operation.
@ OP_PEER_CREATE
Peer create operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.