/*
This file is part of GNUnet
- (C) 2008--2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2008--2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
{
struct ExpireOperationEntry *entry;
- entry = GNUNET_malloc (sizeof (struct ExpireOperationEntry));
+ entry = GNUNET_new (struct ExpireOperationEntry);
entry->op = op;
GNUNET_CONTAINER_DLL_insert_tail (exop_head, exop_tail, entry);
}
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS message from
* controller (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS message from
* controller (testbed service)
*
* @param c the controller handle
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT message from
* controller (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT message from
* controller (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION message from
* controller (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
peer = data->peer;
GNUNET_assert (NULL != peer);
GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id);
- pinfo = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerInformation));
+ pinfo = GNUNET_new (struct GNUNET_TESTBED_PeerInformation);
pinfo->pit = data->pit;
cb = data->cb;
cb_cls = data->cb_cls;
switch (pinfo->pit)
{
case GNUNET_TESTBED_PIT_IDENTITY:
- pinfo->result.id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity));
+ pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity);
(void) memcpy (pinfo->result.id, &msg->peer_identity,
sizeof (struct GNUNET_PeerIdentity));
break;
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONFAILEVENT message from
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT message from
* controller (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION message from controller
* (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
/**
- * Handler for GNUNET_MESSAGE_TYPE_TESTBED_SLAVECONFIG message from controller
+ * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT message from controller
* (testbed service)
*
* @param c the controller handler
* @param msg message received
- * @return GNUNET_YES if we can continue receiving from service; GNUNET_NO if
+ * @return #GNUNET_YES if we can continue receiving from service; #GNUNET_NO if
* not
*/
static int
size = ntohs (msg->size);
GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) &&
(GNUNET_MESSAGE_TYPE_TESTBED_MAX > type));
- mq_entry = GNUNET_malloc (sizeof (struct MessageQueue));
+ mq_entry = GNUNET_new (struct MessageQueue);
mq_entry->msg = msg;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Queueing message of type %u, size %u for sending\n", type,
struct GNUNET_MessageHeader *dup_msg;
uint16_t msize;
- data = GNUNET_malloc (sizeof (struct ForwardedOperationData));
+ data = GNUNET_new (struct ForwardedOperationData);
data->cc = cc;
data->cc_cls = cc_cls;
- opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc = GNUNET_new (struct OperationContext);
opc->c = controller;
opc->type = OP_FORWARDED;
opc->data = data;
GNUNET_break (0);
return NULL;
}
- controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
+ controller = GNUNET_new (struct GNUNET_TESTBED_Controller);
controller->cc = cc;
controller->cc_cls = cc_cls;
controller->event_mask = event_mask;
* @param c handle to controller to stop
*/
void
-GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller
- *c)
+GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *c)
{
struct MessageQueue *mq_entry;
msg->delegated_host_id = htonl (delegated_host_id);
msg->slave_host_id = htonl (slave_host_id);
msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0;
- data = GNUNET_malloc (sizeof (struct ControllerLinkData));
+ data = GNUNET_new (struct ControllerLinkData);
data->msg = msg;
data->host_id = delegated_host_id;
- opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc = GNUNET_new (struct OperationContext);
opc->c = master;
opc->data = data;
opc->type = OP_LINK_CONTROLLERS;
struct OperationContext *opc;
struct GetSlaveConfigData *data;
- data = GNUNET_malloc (sizeof (struct GetSlaveConfigData));
+ data = GNUNET_new (struct GetSlaveConfigData);
data->slave_id = slave_host_id;
- opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc = GNUNET_new (struct OperationContext);
opc->state = OPC_STATE_INIT;
opc->c = master;
opc->id = GNUNET_TESTBED_get_next_op_id (master);
/**
* Generates configuration by uncompressing configuration in given message. The
* given message should be of the following types:
- * GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION,
- * GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
- * GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST,
- * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS,
- * GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
+ * #GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION,
+ * #GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION,
+ * #GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST,
+ * #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS,
+ * #GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT,
*
* @param msg the message containing compressed configuration
* @return handle to the parsed configuration; NULL upon error while parsing the message
struct GNUNET_TESTBED_ShutdownPeersMessage *msg;
opc->state = OPC_STATE_STARTED;
- msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ShutdownPeersMessage));
+ msg = GNUNET_new (struct GNUNET_TESTBED_ShutdownPeersMessage);
msg->header.size =
htons (sizeof (struct GNUNET_TESTBED_ShutdownPeersMessage));
msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
if (0 != GNUNET_CONTAINER_multihashmap32_size (c->opc_map))
return NULL;
- data = GNUNET_malloc (sizeof (struct ShutdownPeersData));
+ data = GNUNET_new (struct ShutdownPeersData);
data->cb = cb;
data->cb_cls = cb_cls;
- opc = GNUNET_malloc (sizeof (struct OperationContext));
+ opc = GNUNET_new (struct OperationContext);
opc->c = c;
opc->op_cls = op_cls;
opc->data = data;
}
+/**
+ * Return the index of the peer inside of the total peer array,
+ * aka. the peer's "unique ID".
+ *
+ * @param peer Peer handle.
+ *
+ * @return The peer's unique ID.
+ */
+uint32_t
+GNUNET_TESTBED_get_index (const struct GNUNET_TESTBED_Peer *peer)
+{
+ return peer->unique_id;
+}
+
/* end of testbed_api.c */