GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
gnunet-service-testbed.h File Reference

data structures shared amongst components of TESTBED service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "gnunet_transport_service.h"
#include "gnunet_core_service.h"
#include "testbed.h"
#include "testbed_api.h"
#include "testbed_api_operations.h"
#include "testbed_api_hosts.h"
#include "gnunet_testing_lib.h"
#include "gnunet-service-testbed_links.h"
Include dependency graph for gnunet-service-testbed.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Route
 A routing entry. More...
 
struct  ForwardedOperationContext
 Context information for operations forwarded to subcontrollers. More...
 
struct  HostRegistration
 A DLL of host registrations to be made. More...
 
struct  LinkControllersContext
 Context information used while linking controllers. More...
 
struct  Peer
 Information about preferences and sessions we track per peer. More...
 
struct  Context
 Context to hold data of peer. More...
 
struct  SharedService
 The structure for identifying a shared service. More...
 
struct  ForwardedOverlayConnectContext
 Context information to used during operations which forward the overlay connect message. More...
 
struct  RegisteredHostContext
 This context information will be created for each host that is registered at slave controllers during overlay connects. More...
 
struct  HandlerContext_ShutdownPeers
 Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler. More...
 

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging. More...
 
#define LOG_DEBUG(...)   LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 Debug logging. More...
 
#define LIST_GROW_STEP   10
 By how much should the arrays lists grow. More...
 
#define VALID_HOST_ID(id)   ( ((id) < GST_host_list_size) && (NULL != GST_host_list[id]) )
 Condition to check if host id is valid. More...
 
#define VALID_PEER_ID(id)   ( ((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]) )
 Condition to check if peer id is valid. More...
 
#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 it only once. More...
 

Functions

void GST_destroy_peer (struct Peer *peer)
 Function to destroy a peer. More...
 
void GST_destroy_peers (void)
 Stops and destroys all peers. More...
 
struct RouteGST_find_dest_route (uint32_t host_id)
 Finds the route with directly connected host as destination through which the destination host can be reached. More...
 
void handle_overlay_connect (void *cls, const struct GNUNET_TESTBED_OverlayConnectMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages. More...
 
void GST_queue_host_registration (struct Slave *slave, GNUNET_TESTBED_HostRegistrationCompletion cb, void *cb_cls, struct GNUNET_TESTBED_Host *host)
 Adds a host registration's request to a slave's registration queue. More...
 
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. More...
 
void GST_forwarded_operation_timeout (void *cls)
 Task to free resources when forwarded operation has been timedout. More...
 
void GST_clear_fopcq (void)
 Clears the forwarded operations queue. More...
 
void GST_send_operation_fail_msg (struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
 Send operation failure message to client. More...
 
void GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client)
 Notify OC subsystem that client disconnected. More...
 
void GST_notify_client_disconnect_peers (struct GNUNET_SERVICE_Client *client)
 Notify peers subsystem that client disconnected. More...
 
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. More...
 
int check_remote_overlay_connect (void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages. More...
 
void handle_remote_overlay_connect (void *cls, const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages. More...
 
int check_peer_create (void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
 Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages. More...
 
void handle_peer_create (void *cls, const struct GNUNET_TESTBED_PeerCreateMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages. More...
 
void handle_peer_destroy (void *cls, const struct GNUNET_TESTBED_PeerDestroyMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages. More...
 
void handle_peer_start (void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages. More...
 
void handle_peer_stop (void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
 Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages. More...
 
void handle_peer_get_config (void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages. More...
 
void handle_shutdown_peers (void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages. More...
 
int check_manage_peer_service (void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message. More...
 
void handle_manage_peer_service (void *cls, const struct GNUNET_TESTBED_ManagePeerServiceMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message. More...
 
int check_peer_reconfigure (void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
 Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages. More...
 
void handle_peer_reconfigure (void *cls, const struct GNUNET_TESTBED_PeerReconfigureMessage *msg)
 Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages. More...
 
void GST_free_mctxq (void)
 Frees the ManageServiceContext queue. More...
 
void GST_free_lcf (void)
 Cleans up the queue used for forwarding link controllers requests. More...
 
void GST_route_list_clear (void)
 Cleans up the route list. More...
 
void GST_process_next_focc (struct RegisteredHostContext *rhc)
 Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext. More...
 
void GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc)
 Cleans up ForwardedOverlayConnectContext. More...
 
void GST_free_occq (void)
 Clears all pending overlay connect contexts in queue. More...
 
void GST_free_roccq (void)
 Clears all pending remote overlay connect contexts in queue. More...
 
void GST_free_prcq (void)
 Cleans up the Peer reconfigure context list. More...
 
void GST_cache_init (unsigned int size)
 Initializes the cache. More...
 
void GST_cache_clear (void)
 Clear cache. More...
 
const struct GNUNET_MessageHeaderGST_cache_lookup_hello (const unsigned int peer_id)
 Looks up in the hello cache and returns the HELLO of the given peer. More...
 
void GST_cache_add_hello (const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
 Caches the HELLO of the given peer. More...
 
void GST_stats_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize logging CPU and IO statisticfs. More...
 
void GST_stats_destroy (void)
 Shutdown the status calls module. More...
 

Variables

struct GNUNET_CONFIGURATION_HandleGST_config
 Our configuration. More...
 
struct ContextGST_context
 The master context; generated with the first INIT message. More...
 
struct ForwardedOperationContextfopcq_head
 DLL head for forwarded operation contexts. More...
 
struct ForwardedOperationContextfopcq_tail
 DLL tail for forwarded operation contexts. More...
 
struct Peer ** GST_peer_list
 A list of peers we know about. More...
 
struct GNUNET_TESTBED_Host ** GST_host_list
 Array of hosts. More...
 
struct OperationQueueGST_opq_openfds
 Operation queue for open file descriptors. More...
 
const struct GNUNET_TIME_Relative GST_timeout
 Timeout for operations which may take some time. More...
 
unsigned int GST_peer_list_size
 The size of the peer list. More...
 
unsigned int GST_num_local_peers
 The current number of peers running locally under this controller. More...
 
unsigned int GST_host_list_size
 The size of the host list. More...
 
char * GST_stats_dir
 The directory where to store load statistics data. More...
 

Detailed Description

data structures shared amongst components of TESTBED service

Author
Sree Harsha Totakura

Definition in file gnunet-service-testbed.h.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log (kind, __VA_ARGS__)

Generic logging.

Definition at line 44 of file gnunet-service-testbed.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   ...)    LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)

Debug logging.

Definition at line 50 of file gnunet-service-testbed.h.

◆ LIST_GROW_STEP

#define LIST_GROW_STEP   10

By how much should the arrays lists grow.

Definition at line 56 of file gnunet-service-testbed.h.

Referenced by peer_list_remove().

◆ VALID_HOST_ID

#define VALID_HOST_ID (   id)    ( ((id) < GST_host_list_size) && (NULL != GST_host_list[id]) )

Condition to check if host id is valid.

Definition at line 482 of file gnunet-service-testbed.h.

Referenced by forward_overlay_connect(), and handle_overlay_connect().

◆ VALID_PEER_ID

#define VALID_PEER_ID (   id)    ( ((id) < GST_peer_list_size) && (NULL != GST_peer_list[id]) )

◆ GST_array_grow_large_enough

#define GST_array_grow_large_enough (   ptr,
  size,
  accommodate_size 
)
Value:
do \
{ \
unsigned int growth_size; \
GNUNET_assert (size <= accommodate_size); \
growth_size = size; \
while (growth_size <= accommodate_size) \
growth_size += LIST_GROW_STEP; \
GNUNET_array_grow (ptr, size, growth_size); \
GNUNET_assert (size > accommodate_size); \
} while (0)
#define LIST_GROW_STEP
By how much should the arrays lists grow.
static unsigned int size
Size of the "table".
Definition: peer.c:67

Similar to GNUNET_array_grow(); however instead of calling GNUNET_array_grow() several times we call it only once.

The array is also made to grow in steps of LIST_GROW_STEP.

Parameters
ptrthe array pointer to grow
sizethe size of array
accommodate_sizethe size which the array has to accommdate; after this call the array will be big enough to accommdate sizes upto accommodate_size

Definition at line 503 of file gnunet-service-testbed.h.

Referenced by host_list_add(), neighbour_list_add(), peer_list_add(), route_list_add(), and slave_list_add().

Function Documentation

◆ GST_destroy_peer()

void GST_destroy_peer ( struct Peer peer)

Function to destroy a peer.

Parameters
peerthe peer structure to destroy

Definition at line 260 of file gnunet-service-testbed_peers.c.

References Peer::details, GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_NO, GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_stop(), GNUNET_YES, Peer::is_remote, Peer::local, peer_list_remove(), and Peer::reference_cnt.

Referenced by cleanup_mctx(), cleanup_occ(), cleanup_rocc(), handle_peer_destroy(), and peer_destroy_success_cb().

261 {
262  GNUNET_break (0 == peer->reference_cnt);
263  if (GNUNET_YES == peer->is_remote)
264  {
265  peer_list_remove (peer);
266  GNUNET_free (peer);
267  return;
268  }
269  if (GNUNET_YES == peer->details.local.is_running)
270  {
272  peer->details.local.is_running = GNUNET_NO;
273  }
276  peer_list_remove (peer);
277  GNUNET_free (peer);
278 }
int is_remote
Is this peer locally created?
#define GNUNET_NO
Definition: gnunet_common.h:81
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1418
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct Peer::@69::@70 local
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
static void peer_list_remove(struct Peer *peer)
Removes a the give peer from the peer array.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
union Peer::@69 details
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1511
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_destroy_peers()

void GST_destroy_peers ( void  )

Stops and destroys all peers.

Definition at line 1409 of file gnunet-service-testbed_peers.c.

References Peer::destroy_flag, Peer::details, GNUNET_break, GNUNET_CONFIGURATION_destroy(), GNUNET_free, GNUNET_free_non_null, GNUNET_NO, GNUNET_TESTING_peer_destroy(), GNUNET_TESTING_peer_kill(), GNUNET_TESTING_peer_wait(), GNUNET_YES, GST_peer_list_size, id, Peer::is_remote, Peer::local, ManageServiceContext::peer, and Peer::reference_cnt.

Referenced by handle_shutdown_peers(), and shutdown_task().

1410 {
1411  struct Peer *peer;
1412  unsigned int id;
1413 
1414  if (NULL == GST_peer_list)
1415  return;
1416  for (id = 0; id < GST_peer_list_size; id++)
1417  {
1418  peer = GST_peer_list[id];
1419  if (NULL == peer)
1420  continue;
1421  /* If destroy flag is set it means that this peer should have been
1422  * destroyed by a context which we destroy before */
1423  GNUNET_break (GNUNET_NO == peer->destroy_flag);
1424  /* counter should be zero as we free all contexts before */
1425  GNUNET_break (0 == peer->reference_cnt);
1426  if ((GNUNET_NO == peer->is_remote) &&
1427  (GNUNET_YES == peer->details.local.is_running))
1428  GNUNET_TESTING_peer_kill (peer->details.local.peer);
1429  }
1430  for (id = 0; id < GST_peer_list_size; id++)
1431  {
1432  peer = GST_peer_list[id];
1433  if (NULL == peer)
1434  continue;
1435  if (GNUNET_NO == peer->is_remote)
1436  {
1437  if (GNUNET_YES == peer->details.local.is_running)
1438  GNUNET_TESTING_peer_wait (peer->details.local.peer);
1441  }
1442  GNUNET_free (peer);
1443  }
1445  GST_peer_list = NULL;
1446  GST_peer_list_size = 0;
1447 }
int is_remote
Is this peer locally created?
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
unsigned int GST_peer_list_size
The size of the peer list.
#define GNUNET_NO
Definition: gnunet_common.h:81
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer&#39;s main process.
Definition: testing.c:1363
struct Peer::@69::@70 local
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct Peer ** GST_peer_list
A list of peers we know about.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
union Peer::@69 details
Information about preferences and sessions we track per peer.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1511
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1395
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_find_dest_route()

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 reached.

Parameters
host_idthe id of the destination host
Returns
the route with directly connected destination host; NULL if no route is found

Definition at line 525 of file gnunet-service-testbed_links.c.

References GST_context, Context::host_id, route_list_size, and Route::thru.

Referenced by forward_overlay_connect(), handle_link_controllers(), and handle_peer_create().

526 {
527  struct Route *route;
528 
529  if (route_list_size <= host_id)
530  return NULL;
531  while (NULL != (route = route_list[host_id]))
532  {
533  if (route->thru == GST_context->host_id)
534  break;
535  host_id = route->thru;
536  }
537  return route;
538 }
uint32_t thru
The destination host is reachable thru.
uint32_t host_id
Our host id according to this context.
A routing entry.
struct Context * GST_context
The master context; generated with the first INIT message.
Here is the caller graph for this function:

◆ handle_overlay_connect()

void handle_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_OverlayConnectMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1522 of file gnunet-service-testbed_oc.c.

References OverlayConnectContext::cgh_ch, OverlayConnectContext::client, Peer::details, OverlayConnectContext::emsg, forward_overlay_connect(), GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_CORE, GST_create_neighbour(), GST_get_neighbour(), GST_host_list, GST_neighbour_get_connection(), GST_peer_list, GST_timeout, Peer::id, Peer::is_remote, Peer::local, LOG, LOG_DEBUG, RemotePeer2Context::ncn, occ_cache_get_handle_core_cb(), OCC_TYPE_LOCAL, OCC_TYPE_REMOTE_LATERAL, OCC_TYPE_REMOTE_SLAVE, OverlayConnectContext::op_id, GNUNET_TESTBED_OverlayConnectMessage::operation_id, OverlayConnectContext::other_peer_id, OverlayConnectContext::other_peer_identity, overlay_connect_notify(), p2_controller_connect_cb(), RemotePeer2Context::p2c, OverlayConnectContext::p2ctx, RemotePeer2Context::p2n, peer, OverlayConnectContext::peer, GNUNET_TESTBED_OverlayConnectMessage::peer1, GNUNET_TESTBED_OverlayConnectMessage::peer2, GNUNET_TESTBED_OverlayConnectMessage::peer2_host_id, Peer::reference_cnt, Peer::remote, OverlayConnectContext::remote, timeout_overlay_connect(), OverlayConnectContext::timeout_task, OverlayConnectContext::type, VALID_HOST_ID, and VALID_PEER_ID.

1524 {
1525  struct GNUNET_SERVICE_Client *client = cls;
1526  struct Peer *peer;
1527  struct Peer *peer2;
1528  struct OverlayConnectContext *occ;
1529  struct Neighbour *p2n;
1530  uint64_t operation_id;
1531  uint32_t p1;
1532  uint32_t p2;
1533  uint32_t peer2_host_id;
1534 
1535  p1 = ntohl (msg->peer1);
1536  p2 = ntohl (msg->peer2);
1537  if (! VALID_PEER_ID (p1))
1538  {
1539  GNUNET_break (0);
1540  GNUNET_SERVICE_client_drop (client);
1541  return;
1542  }
1543  peer = GST_peer_list[p1];
1544  operation_id = GNUNET_ntohll (msg->operation_id);
1545  LOG_DEBUG
1546  ("Received overlay connect for peers %u and %u with op id: 0x%llx\n",
1547  p1,
1548  p2,
1549  operation_id);
1550  peer2_host_id = ntohl (msg->peer2_host_id);
1551  if (GNUNET_YES == peer->is_remote)
1552  {
1553  if (! VALID_HOST_ID (peer2_host_id))
1554  {
1555  GNUNET_break (0);
1556  GNUNET_SERVICE_client_drop (client);
1557  return;
1558  }
1559  forward_overlay_connect (msg, client);
1561  return;
1562  }
1563  p2n = NULL;
1564  occ = GNUNET_new (struct OverlayConnectContext);
1565  occ->type = OCC_TYPE_LOCAL;
1566  if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */
1567  {
1568  if (NULL == (p2n = GST_get_neighbour (peer2_host_id)))
1569  {
1570  if (! VALID_HOST_ID (peer2_host_id))
1571  {
1572  GNUNET_break (0);
1574  "0x%llx: Peer %u's host not in our neighbours list\n",
1575  operation_id, p2);
1576  GNUNET_SERVICE_client_drop (client);
1577  GNUNET_free (occ);
1578  return;
1579  }
1580  p2n = GST_create_neighbour (GST_host_list[peer2_host_id]);
1581  }
1583  occ->p2ctx.remote.p2n = p2n;
1584  }
1585  else if (GNUNET_YES == GST_peer_list[p2]->is_remote)
1586  {
1587  occ->type = OCC_TYPE_REMOTE_SLAVE;
1588  occ->p2ctx.remote.p2c = GST_peer_list[p2]->details.remote.slave->controller;
1589  }
1591  occq_tail,
1592  occ);
1593  occ->client = client;
1594  occ->other_peer_id = p2;
1596  occ->peer = GST_peer_list[p1];
1597  occ->op_id = operation_id;
1598  GNUNET_assert (NULL == occ->timeout_task);
1599  occ->timeout_task =
1602  occ);
1603  switch (occ->type)
1604  {
1606  GNUNET_asprintf (&occ->emsg,
1607  "0x%llx: Timeout while acquiring connection to peer %u's "
1608  "host: %u\n",
1609  occ->op_id,
1610  occ->other_peer_id,
1611  peer2_host_id);
1612  occ->p2ctx.remote.ncn
1615  occ);
1616  break;
1617  case OCC_TYPE_REMOTE_SLAVE:
1619  occ->p2ctx.remote.p2c);
1620  break;
1621  case OCC_TYPE_LOCAL:
1622  peer2 = GST_peer_list[occ->other_peer_id];
1623  peer2->reference_cnt++;
1625  &occ->other_peer_identity);
1626  GNUNET_asprintf (&occ->emsg,
1627  "0x%llx: Timeout while connecting to CORE of peer with "
1628  "id: %u",
1629  occ->op_id,
1630  occ->peer->id);
1631  occ->cgh_ch =
1633  occ->peer->details.local.cfg,
1636  &occ->other_peer_identity,
1637  &overlay_connect_notify, occ);
1638  break;
1639  }
1641 }
A connected controller which is not our child.
static void occ_cache_get_handle_core_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *my_identity, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed CORE handle set.
int is_remote
Is this peer locally created?
struct NeighbourConnectNotification * ncn
Notification handle acquire to connect to a remote controller.
uint64_t op_id
The id of the operation responsible for creating this context.
struct Peer::@69::@71 remote
Type to be used when the first peer is local and the other peer is on a controller which is not start...
struct GST_ConnectionPool_GetHandle * cgh_ch
The GST_ConnectionPool_GetHandle for registering callback to notify CORE level peer connects and to g...
struct GNUNET_SCHEDULER_Task * timeout_task
The id of the overlay connect timeout task.
Context information for connecting 2 peers in overlay.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct Peer ** GST_peer_list
A list of peers we know about.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:412
#define LOG(kind,...)
Redefine LOG with a changed log component string.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct RemotePeer2Context remote
Context information to be used if the second peer is remote.
char * emsg
The error message we send if this overlay connect operation has timed out.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void timeout_overlay_connect(void *cls)
Task which will be run when overlay connect request has been timed out.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
Handle to a client that is connected to a service.
Definition: service.c:249
static void overlay_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_TESTBED_Controller * p2c
Controller of peer 2; If OCC_TYPE_REMOTE_LATERAL is the type of overlay connection then this can be N...
static struct OverlayConnectContext * occq_tail
DLL tail for OverlayConnectContext DLL.
uint32_t peer2
Unique ID for the second peer.
Definition: testbed.h:417
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
Definition: scheduler.c:1246
struct Peer::@69::@70 local
struct Peer * peer
the first peer which is to expect an overlay connection from the second peer.
uint32_t peer1
Unique ID for the first peer.
Definition: testbed.h:407
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
uint32_t peer2_host_id
The ID of the host which runs peer2.
Definition: testbed.h:422
enum OverlayConnectContextType type
The type of this context information.
struct Neighbour * p2n
The neighbour handle.
struct GNUNET_PeerIdentity other_peer_identity
The peer identity of the other peer.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
This type is used if the overlay connection is local i.e.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
Type to be used when the first peer is local and the other peer is on a slave controller started by u...
#define VALID_HOST_ID(id)
Condition to check if host id is valid.
uint32_t other_peer_id
The id of the second peer which has to connect to the first peer.
static void forward_overlay_connect(const struct GNUNET_TESTBED_OverlayConnectMessage *msg, struct GNUNET_SERVICE_Client *client)
Forwards the overlay connect request to a slave controller.
union Peer::@69 details
union OverlayConnectContext::@72 p2ctx
Context information for operations on the second peer.
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
static void p2_controller_connect_cb(void *cls, struct GNUNET_TESTBED_Controller *c)
Callback called when a connection to the controller of peer2 has been established.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GST_queue_host_registration()

void GST_queue_host_registration ( struct Slave slave,
GNUNET_TESTBED_HostRegistrationCompletion  cb,
void *  cb_cls,
struct GNUNET_TESTBED_Host host 
)

Adds a host registration's request to a slave's registration queue.

Parameters
slavethe slave controller at which the given host has to be registered
cbthe host registration completion callback
cb_clsthe closure for the host registration completion callback
hostthe host which has to be registered

Definition at line 246 of file gnunet-service-testbed.c.

References HostRegistration::cb, HostRegistration::cb_cls, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_new, GNUNET_NO, GNUNET_TESTBED_host_get_id_(), GNUNET_YES, host, HostRegistration::host, Slave::host_id, Slave::hr_dll_head, Slave::hr_dll_tail, LOG, and register_next_host().

Referenced by lcf_proc_task(), and register_host().

250 {
251  struct HostRegistration *hr;
252  int call_register;
253 
255  "Queueing host registration for host %u at %u\n",
258  hr = GNUNET_new (struct HostRegistration);
259  hr->cb = cb;
260  hr->cb_cls = cb_cls;
261  hr->host = host;
262  call_register = (NULL == slave->hr_dll_head) ? GNUNET_YES : GNUNET_NO;
264  slave->hr_dll_tail,
265  hr);
266  if (GNUNET_YES == call_register)
267  register_next_host (slave);
268 }
#define LOG(kind,...)
Definition: arm_api.c:33
static void register_next_host(struct Slave *slave)
Attempts to register the next host in the host registration queue.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
GNUNET_TESTBED_HostRegistrationCompletion cb
The callback to call after this registration&#39;s status is available.
struct GNUNET_TESTBED_Host ** GST_host_list
Array of hosts.
A DLL of host registrations to be made.
uint32_t GNUNET_TESTBED_host_get_id_(const struct GNUNET_TESTBED_Host *host)
Obtain the host&#39;s unique global ID.
struct HostRegistration * hr_dll_tail
Tail of the host registration DLL.
struct HostRegistration * hr_dll_head
Head of the host registration DLL.
GUID host
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_TESTBED_Host * host
The host that has to be registered.
uint32_t host_id
The id of the host this controller is running on.
#define GNUNET_YES
Definition: gnunet_common.h:80
void * cb_cls
The closure for the above callback.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_forwarded_operation_reply_relay()

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.

Parameters
clsForwardedOperationContext
msgthe message to relay

Definition at line 278 of file gnunet-service-testbed.c.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_get_mq(), LOG_DEBUG, GNUNET_MessageHeader::size, ForwardedOperationContext::timeout_task, and GNUNET_MessageHeader::type.

Referenced by forward_overlay_connect(), forwarded_overlay_connect_listener(), handle_manage_peer_service(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), peer_create_success_cb(), and peer_destroy_success_cb().

280 {
281  struct ForwardedOperationContext *fopc = cls;
282  struct GNUNET_MQ_Envelope *env;
283 
284  LOG_DEBUG ("Relaying message with type: %u, size: %u\n",
285  ntohs (msg->type),
286  ntohs (msg->size));
287  env = GNUNET_MQ_msg_copy (msg);
289  env);
292  fopcq_tail,
293  fopc);
294  GNUNET_free (fopc);
295 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
void * cls
Closure pointer.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_forwarded_operation_timeout()

void GST_forwarded_operation_timeout ( void *  cls)

Task to free resources when forwarded operation has been timedout.

Parameters
clsthe ForwardedOperationContext
tcthe task context from scheduler

Task to free resources when forwarded operation has been timedout.

Parameters
clsthe ForwardedOperationContext

Definition at line 304 of file gnunet-service-testbed.c.

References ForwardedOperationContext::client, ForwardedOperationContext::cls, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_TESTBED_forward_operation_msg_cancel_(), GST_send_operation_fail_msg(), LOG, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, and ForwardedOperationContext::timeout_task.

Referenced by client_disconnect_cb(), forward_overlay_connect(), forwarded_overlay_connect_timeout(), GST_notify_client_disconnect_oc(), GST_notify_client_disconnect_peers(), handle_manage_peer_service(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), and peer_create_forward_timeout().

305 {
306  struct ForwardedOperationContext *fopc = cls;
307 
308  fopc->timeout_task = NULL;
311  "A forwarded operation has timed out\n");
313  fopc->operation_id,
314  "A forwarded operation has timed out");
316  fopcq_tail,
317  fopc);
318  GNUNET_free (fopc);
319 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
#define LOG(kind,...)
Definition: arm_api.c:33
struct OperationContext * opc
The generated operation context.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1410
void * cls
Closure pointer.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
uint64_t operation_id
The id of the operation that has been forwarded.
Context information for operations forwarded to subcontrollers.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_clear_fopcq()

void GST_clear_fopcq ( void  )

Clears the forwarded operations queue.

Definition at line 675 of file gnunet-service-testbed.c.

References ForwardedOperationContext::cls, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_forward_operation_msg_cancel_(), HandlerContext_ShutdownPeers::nslaves, OP_FORWARDED, OP_GET_SLAVE_CONFIG, OP_LINK_CONTROLLERS, OP_MANAGE_SERVICE, OP_OVERLAY_CONNECT, OP_PEER_CREATE, OP_PEER_DESTROY, OP_PEER_INFO, OP_PEER_RECONFIGURE, OP_PEER_START, OP_PEER_STOP, OP_SHUTDOWN_PEERS, ForwardedOperationContext::opc, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

Referenced by handle_shutdown_peers(), and shutdown_task().

676 {
677  struct ForwardedOperationContext *fopc;
678 
679  while (NULL != (fopc = fopcq_head))
680  {
682  fopcq_tail,
683  fopc);
685  if (NULL != fopc->timeout_task)
687  switch (fopc->type)
688  {
689  case OP_PEER_CREATE:
690  GNUNET_free (fopc->cls);
691  break;
692  case OP_SHUTDOWN_PEERS:
693  {
694  struct HandlerContext_ShutdownPeers *hc = fopc->cls;
695 
696  GNUNET_assert (0 < hc->nslaves);
697  hc->nslaves--;
698  if (0 == hc->nslaves)
699  GNUNET_free (hc);
700  }
701  break;
702  case OP_PEER_START:
703  case OP_PEER_STOP:
704  case OP_PEER_DESTROY:
705  case OP_PEER_INFO:
706  case OP_OVERLAY_CONNECT:
707  case OP_LINK_CONTROLLERS:
708  case OP_GET_SLAVE_CONFIG:
709  case OP_MANAGE_SERVICE:
710  case OP_PEER_RECONFIGURE:
711  break;
712  case OP_FORWARDED:
713  GNUNET_assert (0);
714  };
715  GNUNET_free (fopc);
716  }
717 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct OperationContext * opc
The generated operation context.
Stop and destroy all peers.
Definition: testbed_api.h:99
Reconfigure a peer.
Definition: testbed_api.h:74
Link controllers operation.
Definition: testbed_api.h:89
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
void GNUNET_TESTBED_forward_operation_msg_cancel_(struct OperationContext *opc)
Function to cancel an operation created by simply forwarding an operation message.
Definition: testbed_api.c:1410
enum OperationType type
The type of the operation which is forwarded.
Peer destroy operation.
Definition: testbed_api.h:64
Peer start operation.
Definition: testbed_api.h:54
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
void * cls
Closure pointer.
Overlay connection operation.
Definition: testbed_api.h:79
Forwarded operation.
Definition: testbed_api.h:84
Peer stop operation.
Definition: testbed_api.h:59
Get slave config operation.
Definition: testbed_api.h:94
Start/stop service at a peer.
Definition: testbed_api.h:104
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
Peer create operation.
Definition: testbed_api.h:49
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
Context information for operations forwarded to subcontrollers.
Get peer information operation.
Definition: testbed_api.h:69
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_send_operation_fail_msg()

void GST_send_operation_fail_msg ( struct GNUNET_SERVICE_Client client,
uint64_t  operation_id,
const char *  emsg 
)

Send operation failure message to client.

Parameters
clientthe client to which the failure message has to be sent to
operation_idthe id of the failed operation
emsgthe error message; can be NULL

Definition at line 124 of file gnunet-service-testbed.c.

References env, GNUNET_TESTBED_OperationFailureEventMessage::event_type, GNUNET_htonll(), GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, msg, and GNUNET_TESTBED_OperationFailureEventMessage::operation_id.

Referenced by GST_forwarded_operation_timeout(), handle_manage_peer_service(), handle_peer_create(), handle_peer_destroy(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_slave_get_config(), prc_stop_cb(), service_manage_result_cb(), shutdown_peers_reply_cb(), and timeout_overlay_connect().

127 {
128  struct GNUNET_MQ_Envelope *env;
130  uint16_t emsg_len;
131 
132  emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1;
133  env = GNUNET_MQ_msg_extra (msg,
134  emsg_len,
138  GNUNET_memcpy (&msg[1],
139  emsg,
140  emsg_len);
142  env);
143 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
Event notification from a controller to a client.
Definition: testbed.h:536
int32_t event_type
&#39;enum GNUNET_TESTBED_EventType&#39; (in NBO); GNUNET_TESTBED_ET_OPERATION_FINISHED.
Definition: testbed.h:548
#define GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
Message for operation events.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
#define GNUNET_memcpy(dst, src, n)
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:553
A requested testbed operation has been completed.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_notify_client_disconnect_oc()

void GST_notify_client_disconnect_oc ( struct GNUNET_SERVICE_Client client)

Notify OC subsystem that client disconnected.

Parameters
clientthe client that disconnected

Definition at line 623 of file gnunet-service-testbed_oc.c.

References cleanup_occ(), ForwardedOperationContext::client, OverlayConnectContext::client, fopcq_head, GNUNET_SCHEDULER_cancel(), GST_forwarded_operation_timeout(), ForwardedOperationContext::next, OverlayConnectContext::next, and ForwardedOperationContext::timeout_task.

Referenced by client_disconnect_cb().

624 {
625  struct ForwardedOperationContext *fopc;
626  struct ForwardedOperationContext *fopcn;
627  struct OverlayConnectContext *occ;
628  struct OverlayConnectContext *occn;
629 
630  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
631  {
632  fopcn = fopc->next;
633  if (fopc->client == client)
634  {
637  }
638  }
639  for (occ = occq_head; NULL != occ; occ = occn)
640  {
641  occn = occ->next;
642  if (occ->client == client)
643  cleanup_occ (occ);
644  }
645  // FIXME: implement clean up for client_keep replacements!
646 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
Context information for connecting 2 peers in overlay.
struct OverlayConnectContext * next
The next pointer for maintaining a DLL of all OverlayConnectContexts.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
struct GNUNET_SERVICE_Client * client
The client which has requested for overlay connection.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct ForwardedOperationContext * next
The next pointer for DLL.
Context information for operations forwarded to subcontrollers.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_notify_client_disconnect_peers()

void GST_notify_client_disconnect_peers ( struct GNUNET_SERVICE_Client client)

Notify peers subsystem that client disconnected.

Parameters
clientthe client that disconnected

Definition at line 355 of file gnunet-service-testbed_peers.c.

References cleanup_mctx(), cleanup_prc(), ManageServiceContext::client, ForwardedOperationContext::client, PeerReconfigureContext::client, ForwardedOperationContext::cls, fopcq_head, GNUNET_free, GNUNET_SCHEDULER_cancel(), GST_forwarded_operation_timeout(), ManageServiceContext::next, ForwardedOperationContext::next, PeerReconfigureContext::next, OP_PEER_CREATE, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

Referenced by client_disconnect_cb().

356 {
357  struct ForwardedOperationContext *fopc;
358  struct ForwardedOperationContext *fopcn;
359  struct ManageServiceContext *mctx;
360  struct ManageServiceContext *mctxn;
361  struct PeerReconfigureContext *prc;
362  struct PeerReconfigureContext *prcn;
363 
364  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
365  {
366  fopcn = fopc->next;
367  if (client == fopc->client)
368  {
369  if (OP_PEER_CREATE == fopc->type)
370  GNUNET_free (fopc->cls);
373  }
374  }
375  for (mctx = mctx_head; NULL != mctx; mctx = mctxn)
376  {
377  mctxn = mctx->next;
378  if (client == mctx->client)
379  cleanup_mctx (mctx);
380  }
381  for (prc = prc_head; NULL != prc; prc = prcn)
382  {
383  prcn = prc->next;
384  if (client == prc->client)
385  cleanup_prc (prc);
386  }
387 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ManageServiceContext * next
DLL next ptr.
Context information for peer re-configure operations.
Context information to manage peers&#39; services.
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
enum OperationType type
The type of the operation which is forwarded.
void * cls
Closure pointer.
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer&#39;s service.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
Peer create operation.
Definition: testbed_api.h:49
struct ForwardedOperationContext * next
The next pointer for DLL.
struct PeerReconfigureContext * next
DLL next for inclusoin in peer reconfigure operations list.
Context information for operations forwarded to subcontrollers.
#define GNUNET_free(ptr)
Wrapper around free.
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer&#39;s service.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_send_operation_success_msg()

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.

Parameters
clientthe client to send the message to
operation_idthe id of the operation which was successful

Definition at line 153 of file gnunet-service-testbed.c.

References env, GNUNET_TESTBED_GenericOperationSuccessEventMessage::event_type, GNUNET_htonll(), GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_OPERATION_FINISHED, hr_completion(), msg, and GNUNET_TESTBED_GenericOperationSuccessEventMessage::operation_id.

Referenced by handle_peer_destroy(), handle_peer_reconfigure(), handle_shutdown_peers(), prc_stop_cb(), service_manage_result_cb(), and shutdown_peers_reply_cb().

155 {
156  struct GNUNET_MQ_Envelope *env;
158 
159  env = GNUNET_MQ_msg (msg,
164  env);
165 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:606
A requested testbed operation has been completed.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Event notification from a controller to a client for a generic operational success where the operatio...
Definition: testbed.h:589
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
int32_t event_type
&#39;enum GNUNET_TESTBED_EventType&#39; (in NBO); GNUNET_TESTBED_ET_OPERATION_FINISHED.
Definition: testbed.h:601
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_remote_overlay_connect()

int check_remote_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_RemoteOverlayConnectMessage msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if msg is well-formed

Definition at line 1842 of file gnunet-service-testbed_oc.c.

References GNUNET_break, GNUNET_break_op, GNUNET_MESSAGE_TYPE_HELLO, GNUNET_OK, GNUNET_SYSERR, GST_peer_list, GST_peer_list_size, GNUNET_TESTBED_RemoteOverlayConnectMessage::header, GNUNET_TESTBED_RemoteOverlayConnectMessage::hello, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer, peer_id, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

1844 {
1845  uint32_t peer_id;
1846  uint16_t msize;
1847  uint16_t hsize;
1848 
1849  msize = ntohs (msg->header.size);
1850  if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type))
1851  {
1852  GNUNET_break (0);
1853  return GNUNET_SYSERR;
1854  }
1855  hsize = ntohs (msg->hello->size);
1856  if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize)
1857  {
1858  GNUNET_break (0);
1859  return GNUNET_SYSERR;
1860  }
1861  peer_id = ntohl (msg->peer);
1862  if ((peer_id >= GST_peer_list_size) ||
1863  (NULL == GST_peer_list[peer_id]))
1864  {
1865  GNUNET_break_op (0);
1866  return GNUNET_SYSERR;
1867  }
1868  return GNUNET_OK;
1869 }
Message sent from host controller of a peer(A) to the host controller of another peer(B) to request B...
Definition: testbed.h:431
struct Peer ** GST_peer_list
A list of peers we know about.
unsigned int GST_peer_list_size
The size of the peer list.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:456
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint32_t peer
The Unique ID of B.
Definition: testbed.h:441
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_MESSAGE_TYPE_HELLO
HELLO message with friend only flag used for communicating peer addresses.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:436

◆ handle_remote_overlay_connect()

void handle_remote_overlay_connect ( void *  cls,
const struct GNUNET_TESTBED_RemoteOverlayConnectMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1879 of file gnunet-service-testbed_oc.c.

References RemoteOverlayConnectCtx::a_id, cache_transport_peer_connect_notify(), ConnectivitySuggestContext::cgh_p2_th, Peer::details, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_copy_message(), GNUNET_i2s(), GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_strlcpy(), GNUNET_TESTBED_queue_message_(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_connection_pool_get_handle(), GST_CONNECTIONPOOL_SERVICE_TRANSPORT, GST_peer_list, GST_timeout, GNUNET_TESTBED_RemoteOverlayConnectMessage::header, RemoteOverlayConnectCtx::hello, GNUNET_TESTBED_RemoteOverlayConnectMessage::hello, Peer::is_remote, Peer::local, LOG_DEBUG, RemoteOverlayConnectCtx::op_id, GNUNET_TESTBED_RemoteOverlayConnectMessage::operation_id, peer, RemoteOverlayConnectCtx::peer, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer, peer_id, GNUNET_TESTBED_RemoteOverlayConnectMessage::peer_identity, Peer::reference_cnt, Peer::remote, rocc_cache_get_handle_transport_cb(), GNUNET_MessageHeader::size, RemoteOverlayConnectCtx::tcc, timeout_rocc_task(), and RemoteOverlayConnectCtx::timeout_rocc_task_id.

1881 {
1882  struct GNUNET_SERVICE_Client *client = cls;
1883  struct RemoteOverlayConnectCtx *rocc;
1884  struct Peer *peer;
1885  struct GNUNET_PeerIdentity pid;
1886  static char pid_str[16];
1887  uint32_t peer_id;
1888  uint16_t hsize;
1889 
1890  hsize = ntohs (msg->hello->size);
1891  peer_id = ntohl (msg->peer);
1892  peer = GST_peer_list[peer_id];
1893  if (GNUNET_YES == peer->is_remote)
1894  {
1895  struct GNUNET_MessageHeader *msg2;
1896 
1897  msg2 = GNUNET_copy_message (&msg->header);
1898  GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller,
1899  msg2);
1901  return;
1902  }
1903  rocc = GNUNET_new (struct RemoteOverlayConnectCtx);
1904  rocc->op_id = GNUNET_ntohll (msg->operation_id);
1906  roccq_tail,
1907  rocc);
1908  rocc->a_id = msg->peer_identity;
1910  &pid);
1911  (void) GNUNET_strlcpy (pid_str,
1912  GNUNET_i2s (&pid),
1913  sizeof (pid_str));
1914  LOG_DEBUG ("0x%llx: Remote overlay connect %s to peer %s with hello size: %u\n",
1915  rocc->op_id,
1916  pid_str,
1917  GNUNET_i2s (&rocc->a_id),
1918  hsize);
1919  rocc->peer = peer;
1920  rocc->peer->reference_cnt++;
1921  rocc->hello = GNUNET_malloc (hsize);
1922  GNUNET_memcpy (rocc->hello,
1923  msg->hello,
1924  hsize);
1925  rocc->tcc.cgh_p2_th =
1927  rocc->peer->details.local.cfg,
1930  rocc,
1931  &rocc->a_id,
1933  rocc);
1934  rocc->timeout_rocc_task_id =
1937  rocc);
1939 }
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
int is_remote
Is this peer locally created?
struct GNUNET_PeerIdentity a_id
The peer identity of peer A.
struct Peer::@69::@71 remote
struct ConnectivitySuggestContext tcc
The transport try connect context.
struct Peer ** GST_peer_list
A list of peers we know about.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
struct GNUNET_MessageHeader hello[0]
To be followed by the HELLO message of A.
Definition: testbed.h:456
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity peer_identity
Identity of A.
Definition: testbed.h:451
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
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.
Definition: scheduler.c:1246
struct Peer::@69::@70 local
#define GNUNET_memcpy(dst, src, n)
uint32_t peer
The Unique ID of B.
Definition: testbed.h:441
struct GNUNET_SCHEDULER_Task * timeout_rocc_task_id
Task to timeout RequestOverlayConnect.
static struct RemoteOverlayConnectCtx * roccq_tail
DLL tail for RequectOverlayConnectContext DLL.
uint64_t operation_id
The Operation ID that is used to identify this operation.
Definition: testbed.h:446
uint64_t op_id
The id of the operation responsible for creating this context.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
static void rocc_cache_get_handle_transport_cb(void *cls, struct GNUNET_CORE_Handle *ch, struct GNUNET_TRANSPORT_CoreHandle *th, struct GNUNET_ATS_ConnectivityHandle *ac, const struct GNUNET_PeerIdentity *ignore_, const struct GNUNET_CONFIGURATION_Handle *cfg)
Callback from cache with needed handles set.
Context information for remote overlay connect operations.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
The identity of the host (wraps the signing key of the peer).
union Peer::@69 details
Information about preferences and sessions we track per peer.
struct GST_ConnectionPool_GetHandle * GST_connection_pool_get_handle(unsigned int peer_id, const struct GNUNET_CONFIGURATION_Handle *cfg, enum GST_ConnectionPool_Service service, GST_connection_pool_connection_ready_cb cb, void *cb_cls, const struct GNUNET_PeerIdentity *target, GST_connection_pool_peer_connect_notify connect_notify_cb, void *connect_notify_cb_cls)
Get a connection handle to service.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
struct GNUNET_MessageHeader * hello
Peer A&#39;s HELLO.
Header for all communications.
struct GST_ConnectionPool_GetHandle * cgh_p2_th
The GetCacheHandle for the peer2&#39;s transport handle (used to offer the HELLO to the peer)...
#define GNUNET_YES
Definition: gnunet_common.h:80
static void cache_transport_peer_connect_notify(void *cls, const struct GNUNET_PeerIdentity *new_peer)
Function called to notify transport users that another peer connected to us.
#define LOG_DEBUG(msg)
static void timeout_rocc_task(void *cls)
Task to timeout rocc and cleanit up.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
struct Peer * peer
The peer handle of peer B.
#define GNUNET_malloc(size)
Wrapper around malloc.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT.
Definition: testbed.h:436
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:

◆ check_peer_create()

int check_peer_create ( void *  cls,
const struct GNUNET_TESTBED_PeerCreateMessage msg 
)

Check #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if msg is well-formed

Definition at line 425 of file gnunet-service-testbed_peers.c.

References GNUNET_OK.

427 {
428  return GNUNET_OK; /* checked later */
429 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_peer_create()

void handle_peer_create ( void *  cls,
const struct GNUNET_TESTBED_PeerCreateMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER messages.

Parameters
clsidentification of the client
messagethe actual message
clsidentification of the client
msgthe actual message

Definition at line 439 of file gnunet-service-testbed_peers.c.

References cfg, ManageServiceContext::client, ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, Route::dest, Peer::details, env, fopcq_head, fopcq_tail, GNUNET_asprintf(), GNUNET_break, GNUNET_CONFIGURATION_set_value_number(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_configure(), GNUNET_YES, GST_context, GST_find_dest_route(), GST_send_operation_fail_msg(), GST_slave_list, GST_timeout, GNUNET_TESTBED_PeerCreateMessage::header, GNUNET_TESTBED_PeerCreateMessage::host_id, Context::host_id, Peer::id, Peer::is_remote, Peer::local, LOG, LOG_DEBUG, OP_PEER_CREATE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerCreateMessage::operation_id, GNUNET_TESTBED_PeerCreateSuccessEventMessage::operation_id, ManageServiceContext::peer, peer_create_forward_timeout(), peer_create_success_cb(), peer_id, GNUNET_TESTBED_PeerCreateMessage::peer_id, GNUNET_TESTBED_PeerCreateSuccessEventMessage::peer_id, peer_list_add(), Peer::remote, Context::system, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

441 {
442  struct GNUNET_SERVICE_Client *client = cls;
443  struct GNUNET_MQ_Envelope *env;
446  struct ForwardedOperationContext *fo_ctxt;
447  struct Route *route;
448  struct Peer *peer;
449  char *emsg;
450  uint32_t host_id;
451  uint32_t peer_id;
452 
453  host_id = ntohl (msg->host_id);
454  peer_id = ntohl (msg->peer_id);
455  if (VALID_PEER_ID (peer_id))
456  {
457  (void) GNUNET_asprintf (&emsg,
458  "Peer with ID %u already exists",
459  peer_id);
462  emsg);
463  GNUNET_free (emsg);
465  return;
466  }
467  if (UINT32_MAX == peer_id)
468  {
471  "Cannot create peer with given ID");
473  return;
474  }
475  if (host_id == GST_context->host_id)
476  {
477  /* We are responsible for this peer */
479  if (NULL == cfg)
480  {
481  GNUNET_break (0);
483  return;
484  }
486  "TESTBED",
487  "PEERID",
488  (unsigned long long) peer_id);
489 
491  "PATHS",
492  "PEERID",
493  (unsigned long long) peer_id);
494  peer = GNUNET_new (struct Peer);
495  peer->is_remote = GNUNET_NO;
496  peer->details.local.cfg = cfg;
497  peer->id = peer_id;
498  LOG_DEBUG ("Creating peer with id: %u\n",
499  (unsigned int) peer->id);
500  peer->details.local.peer =
502  peer->details.local.cfg, peer->id,
503  NULL /* Peer id */ ,
504  &emsg);
505  if (NULL == peer->details.local.peer)
506  {
508  "Configuring peer failed: %s\n",
509  emsg);
510  GNUNET_free (emsg);
511  GNUNET_free (peer);
512  GNUNET_break (0);
514  return;
515  }
516  peer->details.local.is_running = GNUNET_NO;
517  peer_list_add (peer);
518  env = GNUNET_MQ_msg (reply,
520  reply->peer_id = msg->peer_id;
521  reply->operation_id = msg->operation_id;
523  env);
525  return;
526  }
527 
528  /* Forward peer create request */
529  route = GST_find_dest_route (host_id);
530  if (NULL == route)
531  {
532  GNUNET_break (0);
533  GNUNET_SERVICE_client_continue (client); // ?
534  return;
535  }
536  peer = GNUNET_new (struct Peer);
537  peer->is_remote = GNUNET_YES;
538  peer->id = peer_id;
539  peer->details.remote.slave = GST_slave_list[route->dest];
540  peer->details.remote.remote_host_id = host_id;
541  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
542  fo_ctxt->client = client;
543  fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
544  fo_ctxt->cls = peer;
545  fo_ctxt->type = OP_PEER_CREATE;
546  fo_ctxt->opc =
548  [route->dest]->controller,
549  fo_ctxt->operation_id,
550  &msg->header,
552  fo_ctxt);
553  fo_ctxt->timeout_task =
556  fo_ctxt);
558  fopcq_tail,
559  fo_ctxt);
561 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
Event notification from a controller to a client.
Definition: testbed.h:563
int is_remote
Is this peer locally created?
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
struct Peer::@69::@71 remote
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
#define LOG(kind,...)
Definition: arm_api.c:33
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:219
uint32_t id
Our local reference id for this peer.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
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_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t peer_id
Peer identity of the peer that was created.
Definition: testbed.h:574
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2068
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successfull.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static void peer_create_forward_timeout(void *cls)
The task to be executed if the forwarded peer create operation has been timed out.
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.
Definition: testing.c:1134
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
Definition: scheduler.c:1246
struct Peer::@69::@70 local
uint32_t host_id
Our host id according to this context.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
enum OperationType type
The type of the operation which is forwarded.
A routing entry.
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...
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
uint64_t operation_id
Unique operation id.
Definition: testbed.h:229
void * cls
Closure pointer.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:579
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.
Definition: testbed_api.c:1368
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
configuration data
Definition: configuration.c:85
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct Context * GST_context
The master context; generated with the first INIT message.
uint32_t host_id
On which host should the peer be started?
Definition: testbed.h:224
Peer create operation.
Definition: testbed_api.h:49
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define LOG_DEBUG(msg)
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:234
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint32_t dest
destination host
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_peer_destroy()

void handle_peer_destroy ( void *  cls,
const struct GNUNET_TESTBED_PeerDestroyMessage msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 571 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::client, ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, Peer::destroy_flag, Peer::details, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_destroy_peer(), GST_forwarded_operation_timeout(), GST_send_operation_fail_msg(), GST_send_operation_success_msg(), GST_timeout, GNUNET_TESTBED_PeerDestroyMessage::header, Peer::is_remote, LOG, LOG_DEBUG, OP_PEER_DESTROY, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerDestroyMessage::operation_id, ManageServiceContext::peer, peer_destroy_success_cb(), peer_id, GNUNET_TESTBED_PeerDestroyMessage::peer_id, Peer::reference_cnt, Peer::remote, Peer::slave, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

573 {
574  struct GNUNET_SERVICE_Client *client = cls;
575  struct ForwardedOperationContext *fopc;
576  struct Peer *peer;
577  uint32_t peer_id;
578 
579  peer_id = ntohl (msg->peer_id);
580  LOG_DEBUG ("Received peer destory on peer: %u and operation id: %llu\n",
581  (unsigned int) peer_id,
582  (unsigned long long) GNUNET_ntohll (msg->operation_id));
583  if (!VALID_PEER_ID (peer_id))
584  {
586  "Asked to destroy a non existent peer with id: %u\n", peer_id);
589  "Peer doesn't exist");
591  return;
592  }
593  peer = GST_peer_list[peer_id];
594  if (GNUNET_YES == peer->is_remote)
595  {
596  /* Forward the destory message to sub controller */
597  fopc = GNUNET_new (struct ForwardedOperationContext);
598  fopc->client = client;
599  fopc->cls = peer;
600  fopc->type = OP_PEER_DESTROY;
601  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
602  fopc->opc =
604  slave->controller,
605  fopc->operation_id,
606  &msg->header,
608  fopc);
609  fopc->timeout_task =
612  fopc);
614  fopcq_tail,
615  fopc);
617  return;
618  }
619  peer->destroy_flag = GNUNET_YES;
620  if (0 == peer->reference_cnt)
621  GST_destroy_peer (peer);
622  else
624  "Delaying peer destroy as peer is currently in use\n");
626  GNUNET_ntohll (msg->operation_id));
628 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
int is_remote
Is this peer locally created?
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct Peer::@69::@71 remote
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
#define LOG(kind,...)
Definition: arm_api.c:33
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
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.
Definition: scheduler.c:1246
struct Slave * slave
The slave this peer is started through.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:345
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
enum OperationType type
The type of the operation which is forwarded.
Peer destroy operation.
Definition: testbed_api.h:64
struct Peer ** GST_peer_list
A list of peers we know about.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
void * cls
Closure pointer.
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER.
Definition: testbed.h:340
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
static void peer_destroy_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer destroy operation is successfull.
#define GNUNET_YES
Definition: gnunet_common.h:80
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.
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:350
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Here is the call graph for this function:

◆ handle_peer_start()

void handle_peer_start ( void *  cls,
const struct GNUNET_TESTBED_PeerStartMessage msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 655 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::client, ForwardedOperationContext::client, Slave::controller, Peer::details, env, GNUNET_TESTBED_PeerEventMessage::event_type, fopcq_head, fopcq_tail, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_PEER_START, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_context, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_send_operation_fail_msg(), GST_timeout, GNUNET_TESTBED_PeerStartMessage::header, Context::host_id, GNUNET_TESTBED_PeerEventMessage::host_id, Peer::is_remote, LOG, OP_PEER_START, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerStartMessage::operation_id, GNUNET_TESTBED_PeerEventMessage::operation_id, ManageServiceContext::peer, peer_id, GNUNET_TESTBED_PeerStartMessage::peer_id, GNUNET_TESTBED_PeerEventMessage::peer_id, Peer::remote, Peer::slave, start_peer(), ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

657 {
658  struct GNUNET_SERVICE_Client *client = cls;
659  struct GNUNET_MQ_Envelope *env;
660  struct GNUNET_TESTBED_PeerEventMessage *reply;
661  struct ForwardedOperationContext *fopc;
662  struct Peer *peer;
663  uint32_t peer_id;
664 
665  peer_id = ntohl (msg->peer_id);
666  if (! VALID_PEER_ID (peer_id))
667  {
668  GNUNET_break (0);
670  "Asked to start a non existent peer with id: %u\n",
671  peer_id);
673  return;
674  }
675  peer = GST_peer_list[peer_id];
676  if (GNUNET_YES == peer->is_remote)
677  {
678  fopc = GNUNET_new (struct ForwardedOperationContext);
679  fopc->client = client;
680  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
681  fopc->type = OP_PEER_START;
682  fopc->opc =
684  slave->controller,
685  fopc->operation_id, &msg->header,
687  fopc);
688  fopc->timeout_task =
691  fopc);
693  fopcq_tail,
694  fopc);
696  return;
697  }
698  if (GNUNET_OK != start_peer (peer))
699  {
701  "Failed to start");
703  return;
704  }
705  env = GNUNET_MQ_msg (reply,
707  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_START);
708  reply->host_id = htonl (GST_context->host_id);
709  reply->peer_id = msg->peer_id;
710  reply->operation_id = msg->operation_id;
712  env);
714 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:493
int is_remote
Is this peer locally created?
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct Peer::@69::@71 remote
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:300
#define LOG(kind,...)
Definition: arm_api.c:33
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
Event notification from a controller to a client.
Definition: testbed.h:466
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:488
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:478
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.
Definition: scheduler.c:1246
struct Slave * slave
The slave this peer is started through.
uint32_t host_id
Our host id according to this context.
uint32_t host_id
Host where the peer is running.
Definition: testbed.h:483
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
enum OperationType type
The type of the operation which is forwarded.
Peer start operation.
Definition: testbed_api.h:54
struct Peer ** GST_peer_list
A list of peers we know about.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_START_PEER.
Definition: testbed.h:290
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct Context * GST_context
The master context; generated with the first INIT message.
static int start_peer(struct Peer *peer)
Stats a peer.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:295
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Here is the call graph for this function:

◆ handle_peer_stop()

void handle_peer_stop ( void *  cls,
const struct GNUNET_TESTBED_PeerStopMessage msg 
)

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
messagethe actual message

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 724 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::client, ForwardedOperationContext::client, Slave::controller, Peer::details, env, GNUNET_TESTBED_PeerEventMessage::event_type, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_ET_PEER_STOP, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_wait(), GNUNET_YES, GST_context, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_send_operation_fail_msg(), GST_timeout, GNUNET_TESTBED_PeerStopMessage::header, Context::host_id, GNUNET_TESTBED_PeerEventMessage::host_id, Peer::is_remote, Peer::local, LOG, OP_PEER_STOP, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerStopMessage::operation_id, GNUNET_TESTBED_PeerEventMessage::operation_id, ManageServiceContext::peer, peer_id, GNUNET_TESTBED_PeerStopMessage::peer_id, GNUNET_TESTBED_PeerEventMessage::peer_id, Peer::remote, Peer::slave, stop_peer(), ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

726 {
727  struct GNUNET_SERVICE_Client *client = cls;
728  struct GNUNET_MQ_Envelope *env;
729  struct GNUNET_TESTBED_PeerEventMessage *reply;
730  struct ForwardedOperationContext *fopc;
731  struct Peer *peer;
732  uint32_t peer_id;
733 
734  peer_id = ntohl (msg->peer_id);
736  "Received PEER_STOP for peer %u\n",
737  (unsigned int) peer_id);
738  if (! VALID_PEER_ID (peer_id))
739  {
742  "Peer not found");
744  return;
745  }
746  peer = GST_peer_list[peer_id];
747  if (GNUNET_YES == peer->is_remote)
748  {
750  "Forwarding PEER_STOP for peer %u\n",
751  (unsigned int) peer_id);
752  fopc = GNUNET_new (struct ForwardedOperationContext);
753  fopc->client = client;
754  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
755  fopc->type = OP_PEER_STOP;
756  fopc->opc =
758  slave->controller,
759  fopc->operation_id,
760  &msg->header,
762  fopc);
763  fopc->timeout_task =
766  fopc);
768  fopcq_tail,
769  fopc);
771  return;
772  }
773  if (GNUNET_OK != stop_peer (peer))
774  {
776  "Stopping peer %u failed\n",
777  (unsigned int) peer_id);
780  "Peer not running");
782  return;
783  }
785  "Peer %u successfully stopped\n",
786  (unsigned int) peer_id);
787  env = GNUNET_MQ_msg (reply,
789  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
790  reply->host_id = htonl (GST_context->host_id);
791  reply->peer_id = msg->peer_id;
792  reply->operation_id = msg->operation_id;
794  env);
797 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:493
int is_remote
Is this peer locally created?
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct Peer::@69::@71 remote
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
static int stop_peer(struct Peer *peer)
Stops a peer.
#define LOG(kind,...)
Definition: arm_api.c:33
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
Event notification from a controller to a client.
Definition: testbed.h:466
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer_id
Peer that was started or stopped.
Definition: testbed.h:488
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:478
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.
Definition: scheduler.c:1246
struct Peer::@69::@70 local
struct Slave * slave
The slave this peer is started through.
uint32_t host_id
Our host id according to this context.
uint32_t host_id
Host where the peer is running.
Definition: testbed.h:483
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
Message for peer events.
enum OperationType type
The type of the operation which is forwarded.
struct Peer ** GST_peer_list
A list of peers we know about.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
Peer stop operation.
Definition: testbed_api.h:59
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER.
Definition: testbed.h:315
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:320
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
A peer has been stopped.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:325
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
int GNUNET_TESTING_peer_wait(struct GNUNET_TESTING_Peer *peer)
Waits for a peer to terminate.
Definition: testing.c:1395
Here is the call graph for this function:

◆ handle_peer_get_config()

void handle_peer_get_config ( void *  cls,
const struct GNUNET_TESTBED_PeerGetConfigurationMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 807 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::client, ForwardedOperationContext::client, config, GNUNET_TESTBED_PeerConfigurationInformationMessage::config_size, Slave::controller, Peer::details, env, fopcq_head, fopcq_tail, GNUNET_CONFIGURATION_serialize(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_new, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_compress_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_get_identity(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_send_operation_fail_msg(), GST_timeout, GNUNET_TESTBED_PeerGetConfigurationMessage::header, Peer::is_remote, LOG_DEBUG, OP_PEER_INFO, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerGetConfigurationMessage::operation_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::operation_id, ManageServiceContext::peer, peer_id, GNUNET_TESTBED_PeerGetConfigurationMessage::peer_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_id, GNUNET_TESTBED_PeerConfigurationInformationMessage::peer_identity, Peer::remote, Peer::slave, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

809 {
810  struct GNUNET_SERVICE_Client *client = cls;
811  struct GNUNET_MQ_Envelope *env;
813  struct ForwardedOperationContext *fopc;
814  struct Peer *peer;
815  char *config;
816  char *xconfig;
817  size_t c_size;
818  size_t xc_size;
819  uint32_t peer_id;
820 
821  peer_id = ntohl (msg->peer_id);
822  LOG_DEBUG ("Received GET_CONFIG for peer %u\n",
823  (unsigned int) peer_id);
824  if (!VALID_PEER_ID (peer_id))
825  {
828  "Peer not found");
830  return;
831  }
832  peer = GST_peer_list[peer_id];
833  if (GNUNET_YES == peer->is_remote)
834  {
835  LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n",
836  (unsigned int) peer_id);
837  fopc = GNUNET_new (struct ForwardedOperationContext);
838  fopc->client = client;
839  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
840  fopc->type = OP_PEER_INFO;
841  fopc->opc =
843  slave->controller,
844  fopc->operation_id,
845  &msg->header,
847  fopc);
848  fopc->timeout_task =
851  fopc);
853  fopcq_tail,
854  fopc);
856  return;
857  }
858  LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n",
859  peer_id);
860  config =
862  &c_size);
863  xc_size = GNUNET_TESTBED_compress_config_ (config,
864  c_size,
865  &xconfig);
866  GNUNET_free (config);
867  env = GNUNET_MQ_msg_extra (reply,
868  xc_size,
870  reply->peer_id = msg->peer_id;
871  reply->operation_id = msg->operation_id;
873  &reply->peer_identity);
874  reply->config_size = htons ((uint16_t) c_size);
875  GNUNET_memcpy (&reply[1],
876  xconfig,
877  xc_size);
878  GNUNET_free (xconfig);
880  env);
882 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
int is_remote
Is this peer locally created?
uint32_t peer_id
The id of the peer relevant to this information.
Definition: testbed.h:650
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct Peer::@69::@71 remote
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
Peer configuration and identity reply from controller to a client.
Definition: testbed.h:639
struct OperationContext * opc
The generated operation context.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:626
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:655
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_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:665
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
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.
Definition: scheduler.c:1246
struct Slave * slave
The slave this peer is started through.
#define GNUNET_memcpy(dst, src, n)
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:631
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:621
enum OperationType type
The type of the operation which is forwarded.
static const struct GNUNET_CONFIGURATION_Handle * config
#define GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
Message containing the peer&#39;s information.
struct GNUNET_PeerIdentity peer_identity
Identity of the peer.
Definition: testbed.h:660
struct Peer ** GST_peer_list
A list of peers we know about.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1761
char * GNUNET_CONFIGURATION_serialize(const struct GNUNET_CONFIGURATION_Handle *cfg, size_t *size)
Serializes the given configuration.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
void GNUNET_TESTING_peer_get_identity(struct GNUNET_TESTING_Peer *peer, struct GNUNET_PeerIdentity *id)
Obtain the peer identity from a peer handle.
Definition: testing.c:1292
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
Get peer information operation.
Definition: testbed_api.h:69
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ handle_shutdown_peers()

void handle_shutdown_peers ( void *  cls,
const struct GNUNET_TESTBED_ShutdownPeersMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 1497 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::client, ForwardedOperationContext::client, ForwardedOperationContext::cls, Slave::controller, Slave::controller_proc, fopcq_head, fopcq_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_new, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_forward_operation_msg_(), GST_clear_fopcq(), GST_destroy_peers(), GST_free_mctxq(), GST_free_occq(), GST_free_roccq(), GST_send_operation_success_msg(), GST_slave_list, GST_slave_list_size, GNUNET_TESTBED_ShutdownPeersMessage::header, LOG_DEBUG, HandlerContext_ShutdownPeers::nslaves, ManageServiceContext::op_id, OP_SHUTDOWN_PEERS, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_ShutdownPeersMessage::operation_id, shutdown_peers_reply_cb(), and ForwardedOperationContext::type.

1499 {
1500  struct GNUNET_SERVICE_Client *client = cls;
1501  struct HandlerContext_ShutdownPeers *hc;
1502  struct Slave *slave;
1503  struct ForwardedOperationContext *fo_ctxt;
1504  uint64_t op_id;
1505  unsigned int cnt;
1506 
1507  LOG_DEBUG ("Received SHUTDOWN_PEERS\n");
1508  /* Stop and destroy all peers */
1509  GST_free_mctxq ();
1510  GST_free_occq ();
1511  GST_free_roccq ();
1512  GST_clear_fopcq ();
1513  /* Forward to all slaves which we have started */
1514  op_id = GNUNET_ntohll (msg->operation_id);
1516  /* FIXME: have a better implementation where we track which slaves are
1517  started by this controller */
1518  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1519  {
1520  slave = GST_slave_list[cnt];
1521  if (NULL == slave)
1522  continue;
1523  if (NULL == slave->controller_proc) /* We didn't start the slave */
1524  continue;
1525  LOG_DEBUG ("Forwarding SHUTDOWN_PEERS\n");
1526  hc->nslaves++;
1527  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
1528  fo_ctxt->client = client;
1529  fo_ctxt->operation_id = op_id;
1530  fo_ctxt->cls = hc;
1531  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1532  fo_ctxt->opc =
1534  fo_ctxt->operation_id,
1535  &msg->header,
1537  fo_ctxt);
1539  fopcq_tail,
1540  fo_ctxt);
1541  }
1542  LOG_DEBUG ("Shutting down peers\n");
1543  GST_destroy_peers ();
1544  if (0 == hc->nslaves)
1545  {
1547  op_id);
1548  GNUNET_free (hc);
1549  }
1551 }
void GST_free_mctxq()
Frees the ManageServiceContext queue.
void GST_clear_fopcq()
Clears the forwarded operations queue.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:733
struct OperationContext * opc
The generated operation context.
Stop and destroy all peers.
Definition: testbed_api.h:99
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
uint64_t operation_id
Operation ID.
Definition: testbed.h:738
Handle to a client that is connected to a service.
Definition: service.c:249
void GST_destroy_peers()
Stops and destroys all peers.
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
enum OperationType type
The type of the operation which is forwarded.
unsigned int nslaves
The number of slave we expect to hear from since we forwarded the GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOW...
void * cls
Closure pointer.
struct GNUNET_TESTBED_ControllerProc * controller_proc
The controller process handle if we had started the controller.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
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.
#define LOG_DEBUG(msg)
void GST_free_occq(void)
Clears all pending overlay connect contexts in queue.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
static void shutdown_peers_reply_cb(void *cls, const struct GNUNET_MessageHeader *msg)
The reply msg handler forwarded SHUTDOWN_PEERS operation.
void GST_free_roccq(void)
Clears all pending remote overlay connect contexts in queue.
Here is the call graph for this function:

◆ check_manage_peer_service()

int check_manage_peer_service ( void *  cls,
const struct GNUNET_TESTBED_ManagePeerServiceMessage msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.

Parameters
clsidentification of client
msgthe actual message
Returns
GNUNET_OK if msg is well-formed

Definition at line 1265 of file gnunet-service-testbed_peers.c.

References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_ManagePeerServiceMessage::header, ManageServiceContext::service, GNUNET_MessageHeader::size, and GNUNET_TESTBED_ManagePeerServiceMessage::start.

1267 {
1268  uint16_t msize;
1269  const char* service;
1270 
1271  msize = ntohs (msg->header.size);
1272  service = (const char *) &msg[1];
1273  if ('\0' != service[msize - sizeof
1275  {
1276  GNUNET_break_op (0);
1277  return GNUNET_SYSERR;
1278  }
1279  if (1 < msg->start)
1280  {
1281  GNUNET_break_op (0);
1282  return GNUNET_SYSERR;
1283  }
1284  return GNUNET_OK;
1285 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:765
Message to start/stop services of a peer.
Definition: testbed.h:745
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:750

◆ handle_manage_peer_service()

void handle_manage_peer_service ( void *  cls,
const struct GNUNET_TESTBED_ManagePeerServiceMessage msg 
)

Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.

Parameters
clsidentification of client
msgthe actual message

Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.

Parameters
clsidentification of client
msgthe actual message

Definition at line 1295 of file gnunet-service-testbed_peers.c.

References ManageServiceContext::ah, ManageServiceContext::client, ForwardedOperationContext::client, ForwardedOperationContext::cls, Peer::details, fopcq_head, fopcq_tail, GNUNET_ARM_connect(), GNUNET_ARM_request_service_start(), GNUNET_ARM_request_service_stop(), GNUNET_asprintf(), GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_OS_INHERIT_STD_ERR, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_peer_list_size, GST_send_operation_fail_msg(), GST_timeout, GNUNET_TESTBED_ManagePeerServiceMessage::header, Peer::is_remote, Peer::local, LOG, LOG_DEBUG, ManageServiceContext::op_id, OP_MANAGE_SERVICE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_ManagePeerServiceMessage::operation_id, ManageServiceContext::peer, peer_id, GNUNET_TESTBED_ManagePeerServiceMessage::peer_id, Peer::reference_cnt, Peer::remote, ManageServiceContext::service, service_manage_result_cb(), ManageServiceContext::start, GNUNET_TESTBED_ManagePeerServiceMessage::start, ForwardedOperationContext::timeout_task, and ForwardedOperationContext::type.

1297 {
1298  struct GNUNET_SERVICE_Client *client = cls;
1299  const char* service;
1300  struct Peer *peer;
1301  char *emsg;
1302  struct GNUNET_ARM_Handle *ah;
1303  struct ManageServiceContext *mctx;
1304  struct ForwardedOperationContext *fopc;
1305  uint64_t op_id;
1306  uint32_t peer_id;
1307 
1308  service = (const char *) &msg[1];
1309  peer_id = ntohl (msg->peer_id);
1310  op_id = GNUNET_ntohll (msg->operation_id);
1311  LOG_DEBUG ("Received request to manage service %s on peer %u\n",
1312  service, (unsigned int) peer_id);
1313  if ((GST_peer_list_size <= peer_id)
1314  || (NULL == (peer = GST_peer_list[peer_id])))
1315  {
1316  GNUNET_asprintf (&emsg, "Asked to manage service of a non existent peer "
1317  "with id: %u", peer_id);
1318  goto err_ret;
1319  }
1320  if (0 == strcasecmp ("arm", service))
1321  {
1322  emsg = GNUNET_strdup ("Cannot start/stop peer's ARM service. "
1323  "Use peer start/stop for that");
1324  goto err_ret;
1325  }
1326  if (GNUNET_YES == peer->is_remote)
1327  {
1328  /* Forward the destory message to sub controller */
1329  fopc = GNUNET_new (struct ForwardedOperationContext);
1330  fopc->client = client;
1331  fopc->cls = peer;
1332  fopc->type = OP_MANAGE_SERVICE;
1333  fopc->operation_id = op_id;
1334  fopc->opc =
1336  slave->controller,
1337  fopc->operation_id,
1338  &msg->header,
1340  fopc);
1341  fopc->timeout_task =
1344  fopc);
1346  fopcq_tail,
1347  fopc);
1349  return;
1350  }
1351  if (GNUNET_NO == peer->details.local.is_running)
1352  {
1353  emsg = GNUNET_strdup ("Peer not running\n");
1354  goto err_ret;
1355  }
1356  if ((0 != peer->reference_cnt)
1357  && ( (0 == strcasecmp ("core", service))
1358  || (0 == strcasecmp ("transport", service)) ) )
1359  {
1360  GNUNET_asprintf (&emsg, "Cannot stop %s service of peer with id: %u "
1361  "since it is required by existing operations",
1362  service, peer_id);
1363  goto err_ret;
1364  }
1365  ah = GNUNET_ARM_connect (peer->details.local.cfg, NULL, NULL);
1366  if (NULL == ah)
1367  {
1368  GNUNET_asprintf (&emsg,
1369  "Cannot connect to ARM service of peer with id: %u",
1370  peer_id);
1371  goto err_ret;
1372  }
1373  mctx = GNUNET_new (struct ManageServiceContext);
1374  mctx->peer = peer;
1375  peer->reference_cnt++;
1376  mctx->op_id = op_id;
1377  mctx->ah = ah;
1378  mctx->client = client;
1379  mctx->start = msg->start;
1380  mctx->service = GNUNET_strdup (service);
1382  mctx_tail,
1383  mctx);
1384  if (1 == mctx->start)
1386  service,
1389  mctx);
1390  else
1391  GNUNET_ARM_request_service_stop (mctx->ah, service,
1393  mctx);
1395  return;
1396 
1397  err_ret:
1398  LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1399  GST_send_operation_fail_msg (client, op_id, emsg);
1400  GNUNET_free (emsg);
1402 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
int is_remote
Is this peer locally created?
When this flag is set, the child process will inherit stderr of the parent.
Definition: gnunet_os_lib.h:92
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
struct Peer::@69::@71 remote
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.
#define LOG(kind,...)
Definition: arm_api.c:33
struct OperationContext * opc
The generated operation context.
unsigned int GST_peer_list_size
The size of the peer list.
Handle for interacting with ARM.
Definition: arm_api.c:97
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Context information to manage peers&#39; services.
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
struct Peer * peer
peer whose service has to be managed
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
Definition: scheduler.c:1246
uint64_t operation_id
Operation ID.
Definition: testbed.h:760
struct Peer::@69::@70 local
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.
Definition: arm_api.c:864
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
enum OperationType type
The type of the operation which is forwarded.
char * service
Name of the service.
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...
Definition: arm_api.c:482
struct Peer ** GST_peer_list
A list of peers we know about.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
void * cls
Closure pointer.
uint64_t op_id
The operation id of the associated request.
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.
Definition: arm_api.c:789
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:765
Start/stop service at a peer.
Definition: testbed_api.h:104
static struct GNUNET_NAT_AUTO_AutoHandle * ah
Handle to ongoing autoconfiguration.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:755
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer&#39;s service.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:750
Context information for operations forwarded to subcontrollers.
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ check_peer_reconfigure()

int check_peer_reconfigure ( void *  cls,
const struct GNUNET_TESTBED_PeerReconfigureMessage msg 
)

Check #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.

Parameters
clsidentification of the client
msgthe actual message
Returns
GNUNET_OK if msg is well-formed

Definition at line 977 of file gnunet-service-testbed_peers.c.

References GNUNET_OK.

979 {
980  return GNUNET_OK; /* checked later */
981 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_peer_reconfigure()

void handle_peer_reconfigure ( void *  cls,
const struct GNUNET_TESTBED_PeerReconfigureMessage msg 
)

Handler for #GNUNET_MESSAGE_TYPDE_TESTBED_RECONFIGURE_PEER type messages.

Should stop the peer asyncronously, destroy it and create it again with the new configuration.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 993 of file gnunet-service-testbed_peers.c.

References cfg, PeerReconfigureContext::cfg, ManageServiceContext::client, ForwardedOperationContext::client, PeerReconfigureContext::client, Peer::destroy_flag, Peer::details, fopcq_head, fopcq_tail, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_free_non_null, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_TESTBED_extract_config_(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_TESTING_peer_stop_async(), GNUNET_YES, GST_forwarded_operation_reply_relay(), GST_forwarded_operation_timeout(), GST_send_operation_fail_msg(), GST_send_operation_success_msg(), GST_timeout, GNUNET_TESTBED_PeerReconfigureMessage::header, Peer::is_remote, Peer::local, LOG, LOG_DEBUG, ManageServiceContext::op_id, PeerReconfigureContext::op_id, OP_PEER_RECONFIGURE, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, GNUNET_TESTBED_PeerReconfigureMessage::operation_id, ManageServiceContext::peer, peer_id, PeerReconfigureContext::peer_id, GNUNET_TESTBED_PeerReconfigureMessage::peer_id, prc_stop_cb(), Peer::reference_cnt, Peer::remote, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, update_peer_config(), and VALID_PEER_ID.

995 {
996  struct GNUNET_SERVICE_Client *client = cls;
997  struct Peer *peer;
999  struct ForwardedOperationContext *fopc;
1000  struct PeerReconfigureContext *prc;
1001  char *emsg;
1002  uint64_t op_id;
1003  uint32_t peer_id;
1004 
1005  peer_id = ntohl (msg->peer_id);
1006  op_id = GNUNET_ntohll (msg->operation_id);
1007  if (! VALID_PEER_ID (peer_id))
1008  {
1009  GNUNET_break (0);
1011  op_id,
1012  "Peer not found");
1014  return;
1015  }
1016  peer = GST_peer_list[peer_id];
1017  if (GNUNET_YES == peer->is_remote)
1018  {
1019  LOG_DEBUG ("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1020  fopc = GNUNET_new (struct ForwardedOperationContext);
1021  fopc->client = client;
1022  fopc->operation_id = op_id;
1023  fopc->type = OP_PEER_RECONFIGURE;
1024  fopc->opc =
1026  slave->controller,
1027  fopc->operation_id,
1028  &msg->header,
1030  fopc);
1031  fopc->timeout_task =
1034  fopc);
1036  fopcq_tail,
1037  fopc);
1039  return;
1040  }
1041  LOG_DEBUG ("Received PEER_RECONFIGURE for peer %u\n",
1042  (unsigned int) peer_id);
1043  if (0 < peer->reference_cnt)
1044  {
1045  GNUNET_break (0);
1047  op_id,
1048  "Peer in use");
1050  return;
1051  }
1052  if (GNUNET_YES == peer->destroy_flag)
1053  {
1054  GNUNET_break (0);
1056  op_id,
1057  "Peer is being destroyed");
1059  return;
1060  }
1061  cfg = GNUNET_TESTBED_extract_config_ (&msg->header);
1062  if (NULL == cfg)
1063  {
1064  GNUNET_break (0);
1066  op_id,
1067  "Compression error");
1069  return;
1070  }
1071  if (GNUNET_NO == peer->details.local.is_running)
1072  {
1073  emsg = update_peer_config (peer,
1074  cfg);
1075  if (NULL != emsg)
1077  op_id,
1078  emsg);
1080  op_id);
1082  GNUNET_free_non_null (emsg);
1083  return;
1084  }
1085  prc = GNUNET_new (struct PeerReconfigureContext);
1086  if (GNUNET_OK !=
1088  &prc_stop_cb,
1089  prc))
1090  {
1091  GNUNET_assert (0 < GNUNET_asprintf (&emsg,
1092  "Error trying to stop peer %u asynchronously\n",
1093  peer_id));
1095  "%s\n",
1096  emsg);
1098  op_id,
1099  emsg);
1101  GNUNET_free (prc);
1102  GNUNET_free (emsg);
1103  return;
1104  }
1105  prc->cfg = cfg;
1106  prc->peer_id = peer_id;
1107  prc->op_id = op_id;
1108  prc->client = client;
1110  prc_tail,
1111  prc);
1113 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
int is_remote
Is this peer locally created?
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.
Definition: testing.c:1470
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
struct Peer::@69::@71 remote
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:257
uint32_t destroy_flag
While destroying a peer, due to the fact that there could be references to this peer, we delay the peer destroy to a further time.
#define LOG(kind,...)
Definition: arm_api.c:33
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:81
Context information for peer re-configure operations.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONFIGURATION_Handle * GNUNET_TESTBED_extract_config_(const struct GNUNET_MessageHeader *msg)
Generates configuration by uncompressing configuration in given message.
Definition: testbed_api.c:2068
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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.
uint32_t peer_id
The id of the peer which has to be reconfigured.
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:262
Reconfigure a peer.
Definition: testbed_api.h:74
Handle to a client that is connected to a service.
Definition: service.c:249
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
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.
Definition: scheduler.c:1246
struct Peer::@69::@70 local
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:267
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
uint64_t op_id
The id of the operation.
enum OperationType type
The type of the operation which is forwarded.
struct Peer ** GST_peer_list
A list of peers we know about.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static char * update_peer_config(struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
Update peer configuration.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
static void prc_stop_cb(void *cls, struct GNUNET_TESTING_Peer *p, int success)
Callback to inform whether the peer is running or stopped.
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
union Peer::@69 details
configuration data
Definition: configuration.c:85
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
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.
#define LOG_DEBUG(msg)
Context information for operations forwarded to subcontrollers.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GST_free_mctxq()

void GST_free_mctxq ( void  )

Frees the ManageServiceContext queue.

Definition at line 1120 of file gnunet-service-testbed_peers.c.

References cleanup_mctx().

Referenced by handle_shutdown_peers(), and shutdown_task().

1121 {
1122  while (NULL != mctx_head)
1124 }
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
static void cleanup_mctx(struct ManageServiceContext *mctx)
Cleanup the context information created for managing a peer&#39;s service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_free_lcf()

void GST_free_lcf ( void  )

Cleans up the queue used for forwarding link controllers requests.

Definition at line 1437 of file gnunet-service-testbed_links.c.

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), lcf_head, LCFContext::op, and LCFContext::timeout_task.

Referenced by shutdown_task(), and slave_status_cb().

1438 {
1439  struct LCFContext *lcf;
1440 
1441  if (NULL != lcf_head)
1442  {
1443  if (NULL != lcf_proc_task_id)
1444  {
1446  lcf_proc_task_id = NULL;
1447  }
1448  }
1449  GNUNET_assert (NULL == lcf_proc_task_id);
1450  for (lcf = lcf_head; NULL != lcf; lcf = lcf_head)
1451  {
1452  if (NULL != lcf->op)
1454  if (NULL != lcf->timeout_task)
1457  lcf_tail,
1458  lcf);
1459  GNUNET_free (lcf);
1460  }
1461 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Link controllers request forwarding context.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_TESTBED_Operation * op
Handle for operations which are forwarded while linking controllers.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
Definition: testbed_api.c:2046
struct GNUNET_SCHEDULER_Task * timeout_task
The timeout task.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_route_list_clear()

void GST_route_list_clear ( void  )

Cleans up the route list.

Definition at line 397 of file gnunet-service-testbed_links.c.

References GNUNET_free, GNUNET_free_non_null, id, and route_list_size.

Referenced by shutdown_task().

398 {
399  unsigned int id;
400 
401  for (id = 0; id < route_list_size; id++)
402  if (NULL != route_list[id])
403  GNUNET_free (route_list[id]);
405  route_list = NULL;
406 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GST_process_next_focc()

void GST_process_next_focc ( struct RegisteredHostContext rhc)

Processes a forwarded overlay connect context in the queue of the given RegisteredHostContext.

Parameters
rhcthe RegisteredHostContext

Definition at line 427 of file gnunet-service-testbed_oc.c.

References ForwardedOperationContext::client, ForwardedOverlayConnectContext::client, ForwardedOperationContext::cls, Slave::controller, Peer::details, RegisteredHostContext::focc_dll_head, fopcq_head, fopcq_tail, forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_free, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_TESTBED_forward_operation_msg_(), GNUNET_YES, GST_peer_list, GST_timeout, Peer::is_remote, OP_OVERLAY_CONNECT, ForwardedOperationContext::opc, ForwardedOperationContext::operation_id, ForwardedOverlayConnectContext::operation_id, ForwardedOverlayConnectContext::orig_msg, peer, ForwardedOverlayConnectContext::peer1, Peer::remote, RegisteredHostContext::state, ForwardedOperationContext::timeout_task, ForwardedOperationContext::type, and VALID_PEER_ID.

Referenced by forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), and host_registration_comp().

428 {
429  struct ForwardedOperationContext *fopc;
430  struct ForwardedOverlayConnectContext *focc;
431  struct Peer *peer;
432  struct Slave *slave;
433 
434  focc = rhc->focc_dll_head;
435  GNUNET_assert (NULL != focc);
436  GNUNET_assert (RHC_DONE == rhc->state);
438  peer = GST_peer_list[focc->peer1];
440  GNUNET_assert (NULL != (slave = peer->details.remote.slave));
441  fopc = GNUNET_new (struct ForwardedOperationContext);
442  fopc->client = focc->client;
443  fopc->operation_id = focc->operation_id;
444  fopc->cls = rhc;
445  fopc->type = OP_OVERLAY_CONNECT;
446  fopc->opc =
448  focc->operation_id,
449  focc->orig_msg,
451  fopc);
452  GNUNET_free (focc->orig_msg);
453  focc->orig_msg = NULL;
456  fopc);
458  fopcq_tail,
459  fopc);
460 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
static void forwarded_overlay_connect_listener(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded overlay connection operation has a reply from the sub-controller...
int is_remote
Is this peer locally created?
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
struct Peer::@69::@71 remote
static void forwarded_overlay_connect_timeout(void *cls)
Timeout task for cancelling a forwarded overlay connect connect.
struct GNUNET_SERVICE_Client * client
The client handle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
struct OperationContext * opc
The generated operation context.
struct Peer ** GST_peer_list
A list of peers we know about.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
const struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
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.
Definition: scheduler.c:1246
struct ForwardedOperationContext * fopcq_head
DLL head for forwarded operation contexts.
uint64_t operation_id
The id of the operation which created this context information.
enum OperationType type
The type of the operation which is forwarded.
Context information to used during operations which forward the overlay connect message.
enum RegisteredHostContext::RHCState state
void * cls
Closure pointer.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Overlay connection operation.
Definition: testbed_api.h:79
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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.
Definition: testbed_api.c:1368
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
union Peer::@69 details
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
Information about preferences and sessions we track per peer.
struct GNUNET_TESTBED_Controller * controller
The controller handle.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:80
Context information for operations forwarded to subcontrollers.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_cleanup_focc()

void GST_cleanup_focc ( struct ForwardedOverlayConnectContext focc)

Cleans up ForwardedOverlayConnectContext.

Parameters
foccthe ForwardedOverlayConnectContext to cleanup

Definition at line 359 of file gnunet-service-testbed_oc.c.

References RegisteredHostContext::focc_dll_head, RegisteredHostContext::focc_dll_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_free_non_null, ForwardedOverlayConnectContext::orig_msg, and ForwardedOverlayConnectContext::rhc.

Referenced by drop_client_entries(), forwarded_overlay_connect_listener(), forwarded_overlay_connect_timeout(), and reghost_free_iterator().

360 {
361  struct RegisteredHostContext *rhc = focc->rhc;
362 
364  rhc->focc_dll_tail,
365  focc);
367  GNUNET_free (focc);
368 }
struct ForwardedOverlayConnectContext * focc_dll_head
Head of the ForwardedOverlayConnectContext DLL.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
This context information will be created for each host that is registered at slave controllers during...
struct GNUNET_MessageHeader * orig_msg
A copy of the original overlay connect message.
struct ForwardedOverlayConnectContext * focc_dll_tail
Tail of the ForwardedOverlayConnectContext DLL.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
struct RegisteredHostContext * rhc
Which host does this FOCC belong to?
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GST_free_occq()

void GST_free_occq ( void  )

Clears all pending overlay connect contexts in queue.

Definition at line 1946 of file gnunet-service-testbed_oc.c.

References cleanup_occ().

Referenced by handle_shutdown_peers(), and shutdown_task().

1947 {
1948  struct OverlayConnectContext *occ;
1949 
1950  while (NULL != (occ = occq_head))
1951  cleanup_occ (occ);
1952 }
Context information for connecting 2 peers in overlay.
static void cleanup_occ(struct OverlayConnectContext *occ)
Cleanup overlay connect context structure.
static struct OverlayConnectContext * occq_head
DLL head for OverlayConnectContext DLL - to be used to clean up during shutdown.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_free_roccq()

void GST_free_roccq ( void  )

Clears all pending remote overlay connect contexts in queue.

Definition at line 1959 of file gnunet-service-testbed_oc.c.

References cleanup_rocc().

Referenced by handle_shutdown_peers(), and shutdown_task().

1960 {
1961  struct RemoteOverlayConnectCtx *rocc;
1962 
1963  while (NULL != (rocc = roccq_head))
1964  cleanup_rocc (rocc);
1965 }
static struct RemoteOverlayConnectCtx * roccq_head
DLL head for RequectOverlayConnectContext DLL - to be used to clean up during shutdown.
static void cleanup_rocc(struct RemoteOverlayConnectCtx *rocc)
Function to cleanup RemoteOverlayConnectCtx and any associated tasks with it.
Context information for remote overlay connect operations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_free_prcq()

void GST_free_prcq ( void  )

Cleans up the Peer reconfigure context list.

Definition at line 889 of file gnunet-service-testbed_peers.c.

References cleanup_prc().

Referenced by shutdown_task().

890 {
891  while (NULL != prc_head)
893 }
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_cache_init()

void GST_cache_init ( unsigned int  size)

Initializes the cache.

Parameters
sizethe size of the cache

Definition at line 210 of file gnunet-service-testbed_cache.c.

References cache_size, GNUNET_CONTAINER_multihashmap32_create(), and size.

Referenced by testbed_run().

211 {
212  if (0 == size)
213  return;
214  cache_size = size;
216 }
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
static unsigned int size
Size of the "table".
Definition: peer.c:67
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
static unsigned int cache_size
Maximum number of elements to cache.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_cache_clear()

void GST_cache_clear ( void  )

Clear cache.

Definition at line 189 of file gnunet-service-testbed_cache.c.

References cache_clear_iterator(), cache_size, GNUNET_assert, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), and GNUNET_CONTAINER_multihashmap32_size().

Referenced by shutdown_task().

190 {
191  if (NULL != cache)
192  {
196  cache = NULL;
197  }
198  cache_size = 0;
199  cache_head = NULL;
200  cache_tail = NULL;
201 }
static struct CacheEntry * cache_head
DLL head for least recently used cache entries; least recently used cache items are at the head...
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
static int cache_clear_iterator(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
static struct CacheEntry * cache_tail
DLL tail for least recently used cache entries; recently used cache items are at the tail...
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_HashMapIterator32 it, void *it_cls)
Iterate over all entries in the map.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
static unsigned int cache_size
Maximum number of elements to cache.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_cache_lookup_hello()

const struct GNUNET_MessageHeader* GST_cache_lookup_hello ( const unsigned int  peer_id)

Looks up in the hello cache and returns the HELLO of the given peer.

Parameters
peer_idthe index of the peer whose HELLO has to be looked up
Returns
the HELLO message; NULL if not found

Definition at line 226 of file gnunet-service-testbed_cache.c.

References cache_lookup(), CacheEntry::hello, and LOG_DEBUG.

Referenced by occ_cache_get_handle_core_cb().

227 {
228  struct CacheEntry *entry;
229 
230  LOG_DEBUG ("Looking up HELLO for peer %u\n", peer_id);
231  if (NULL == cache)
232  {
233  LOG_DEBUG ("Caching disabled\n");
234  return NULL;
235  }
236  entry = cache_lookup (peer_id);
237  if (NULL == entry)
238  return NULL;
239  if (NULL != entry->hello)
240  LOG_DEBUG ("HELLO found for peer %u\n", peer_id);
241  return entry->hello;
242 }
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
struct GNUNET_MessageHeader * hello
The HELLO message.
static struct CacheEntry * cache_lookup(unsigned int peer_id)
Looks up in the cache and returns the entry.
#define LOG_DEBUG(msg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_cache_add_hello()

void GST_cache_add_hello ( const unsigned int  peer_id,
const struct GNUNET_MessageHeader hello 
)

Caches the HELLO of the given peer.

Updates the HELLO if it was already cached before

Parameters
peer_idthe peer identity of the peer whose HELLO has to be cached
hellothe HELLO message

Definition at line 253 of file gnunet-service-testbed_cache.c.

References add_entry(), cache_lookup(), GNUNET_copy_message(), GNUNET_free_non_null, and CacheEntry::hello.

Referenced by hello_update_cb().

255 {
256  struct CacheEntry *entry;
257 
258  if (NULL == cache)
259  return;
260  entry = cache_lookup (peer_id);
261  if (NULL == entry)
262  entry = add_entry (peer_id);
263  GNUNET_free_non_null (entry->hello);
264  entry->hello = GNUNET_copy_message (hello);
265 }
static struct CacheEntry * add_entry(unsigned int peer_id)
Creates a new cache entry and then puts it into the cache&#39;s hashtable.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
struct GNUNET_MessageHeader * hello
The HELLO message.
static struct CacheEntry * cache_lookup(unsigned int peer_id)
Looks up in the cache and returns the entry.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_stats_init()

void GST_stats_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize logging CPU and IO statisticfs.

Checks the configuration for "STATS_DIR" and logs to a file in that directory. The file is name is generated from the hostname and the process's PID.

Definition at line 694 of file gnunet-service-testbed_cpustatus.c.

References _, fn, GNUNET_asprintf(), GNUNET_BIO_write_open(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror, GNUNET_log_strerror_file, GNUNET_malloc, GNUNET_OK, GNUNET_OS_get_hostname_max_length, GNUNET_SCHEDULER_add_now(), hostname, len, sample_load_task(), and updateUsage().

Referenced by testbed_run().

695 {
696  char *hostname;
697  char *stats_dir;
698  char *fn;
699  size_t len;
700 
701 #if MINGW
703  "Load statistics logging now available for windows\n");
704  return; /* No logging on windows for now :( */
705 #endif
706 
707  if (GNUNET_OK !=
709  "STATS_DIR", &stats_dir))
710  return;
712  hostname = GNUNET_malloc (len);
713  if (0 != gethostname (hostname, len))
714  {
716  GNUNET_free (stats_dir);
717  GNUNET_free (hostname);
718  return;
719  }
720  fn = NULL;
721  (void) GNUNET_asprintf (&fn, "%s/%.*s-%jd.dat", stats_dir, len,
722  hostname, (intmax_t) getpid());
723  GNUNET_free (stats_dir);
724  GNUNET_free (hostname);
725  if (NULL == (bw = GNUNET_BIO_write_open (fn)))
726  {
728  _("Cannot open %s for writing load statistics. "
729  "Not logging load statistics\n"), fn);
730  GNUNET_free (fn);
731  return;
732  }
733  GNUNET_free (fn);
735 #ifdef LINUX
736  proc_stat = fopen ("/proc/stat", "r");
737  if (NULL == proc_stat)
739  "fopen", "/proc/stat");
740 #elif OSX
741  initMachCpuStats ();
742 #endif
743  updateUsage (); /* initialize */
744 
745 }
static void sample_load_task(void *cls)
struct GNUNET_BIO_WriteHandle * bw
hanlde to the file to write the load statistics to
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_OS_get_hostname_max_length()
Get maximum string length returned by gethostname()
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1273
struct GNUNET_SCHEDULER_Task * sample_load_task_id
static char * hostname
Our hostname; we give this to all the peers we start.
struct GNUNET_BIO_WriteHandle * GNUNET_BIO_write_open(const char *fn)
Open a file for writing.
Definition: bio.c:430
#define GNUNET_log(kind,...)
int GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
static int updateUsage()
Update the currentCPU and currentIO load (and on Linux, memory) values.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_stats_destroy()

void GST_stats_destroy ( void  )

Shutdown the status calls module.

Definition at line 752 of file gnunet-service-testbed_cpustatus.c.

References GNUNET_BIO_write_close(), GNUNET_break, GNUNET_free_non_null, GNUNET_OK, and GNUNET_SCHEDULER_cancel().

Referenced by shutdown_task().

753 {
754 #if MINGW
755  return;
756 #endif
757  if (NULL == bw)
758  return;
759 #ifdef LINUX
760  if (proc_stat != NULL)
761  {
762  fclose (proc_stat);
763  proc_stat = NULL;
764  }
765 #elif OSX
766  GNUNET_free_non_null (prev_cpu_load);
767 #endif
768  if (NULL != sample_load_task_id)
769  {
771  sample_load_task_id = NULL;
772  }
774  bw = NULL;
775 }
struct GNUNET_BIO_WriteHandle * bw
hanlde to the file to write the load statistics to
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_BIO_write_close(struct GNUNET_BIO_WriteHandle *h)
Close an open file for writing.
Definition: bio.c:457
struct GNUNET_SCHEDULER_Task * sample_load_task_id
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GST_config

struct GNUNET_CONFIGURATION_Handle* GST_config

Our configuration.

Definition at line 38 of file gnunet-service-testbed.c.

◆ GST_context

struct Context* GST_context

◆ fopcq_head

struct ForwardedOperationContext* fopcq_head

◆ fopcq_tail

struct ForwardedOperationContext* fopcq_tail

◆ GST_peer_list

struct Peer** GST_peer_list

◆ GST_host_list

struct GNUNET_TESTBED_Host** GST_host_list

◆ GST_opq_openfds

struct OperationQueue* GST_opq_openfds

Operation queue for open file descriptors.

Definition at line 63 of file gnunet-service-testbed.c.

Referenced by GST_connection_pool_get_handle(), and GST_neighbour_get_connection().

◆ GST_timeout

const struct GNUNET_TIME_Relative GST_timeout

◆ GST_peer_list_size

unsigned int GST_peer_list_size

◆ GST_num_local_peers

unsigned int GST_num_local_peers

The current number of peers running locally under this controller.

Definition at line 41 of file gnunet-service-testbed_peers.c.

Referenced by peer_list_add(), and peer_list_remove().

◆ GST_host_list_size

unsigned int GST_host_list_size

The size of the host list.

Definition at line 73 of file gnunet-service-testbed.c.

Referenced by handle_link_controllers(), host_list_add(), and shutdown_task().

◆ GST_stats_dir

char* GST_stats_dir

The directory where to store load statistics data.