GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-service-testbed_peers.c File Reference

implementation of TESTBED service that deals with peer management More...

#include "gnunet-service-testbed.h"
#include "gnunet_arm_service.h"
#include <zlib.h>
Include dependency graph for gnunet-service-testbed_peers.c:

Go to the source code of this file.

Data Structures

struct  ManageServiceContext
 Context information to manage peers' services. More...
 
struct  PeerReconfigureContext
 Context information for peer re-configure operations. More...
 

Functions

static void peer_list_add (struct Peer *peer)
 Adds a peer to the peer array. More...
 
static void peer_list_remove (struct Peer *peer)
 Removes a the give peer from the peer array. More...
 
static void peer_create_forward_timeout (void *cls)
 The task to be executed if the forwarded peer create operation has been timed out. More...
 
static void peer_create_success_cb (void *cls, const struct GNUNET_MessageHeader *msg)
 Callback to be called when forwarded peer create operation is successfull. More...
 
void GST_destroy_peer (struct Peer *peer)
 Function to destroy a peer. More...
 
static void cleanup_mctx (struct ManageServiceContext *mctx)
 Cleanup the context information created for managing a peer's service. More...
 
static int stop_peer (struct Peer *peer)
 Stops a peer. More...
 
static void cleanup_prc (struct PeerReconfigureContext *prc)
 Cleans up the given PeerReconfigureContext. More...
 
void GST_notify_client_disconnect_peers (struct GNUNET_SERVICE_Client *client)
 Notify peers subsystem that client disconnected. More...
 
static void peer_destroy_success_cb (void *cls, const struct GNUNET_MessageHeader *msg)
 Callback to be called when forwarded peer destroy operation is successfull. 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...
 
static int start_peer (struct Peer *peer)
 Stats a peer. More...
 
void handle_peer_start (void *cls, const struct GNUNET_TESTBED_PeerStartMessage *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_START_PEER messages. More...
 
void handle_peer_stop (void *cls, const struct GNUNET_TESTBED_PeerStopMessage *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER messages. More...
 
void handle_peer_get_config (void *cls, const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION messages. More...
 
void GST_free_prcq ()
 Cleans up the Peer reconfigure context list. More...
 
static char * update_peer_config (struct Peer *peer, struct GNUNET_CONFIGURATION_Handle *cfg)
 Update peer configuration. More...
 
static void prc_stop_cb (void *cls, struct GNUNET_TESTING_Peer *p, int success)
 Callback to inform whether the peer is running or stopped. 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 ()
 Frees the ManageServiceContext queue. More...
 
static const char * arm_req_string (enum GNUNET_ARM_RequestStatus rs)
 Returns a string interpretation of rs. More...
 
static const char * arm_ret_string (enum GNUNET_ARM_Result result)
 Returns a string interpretation of the result. More...
 
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. 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 messages. More...
 
void GST_destroy_peers ()
 Stops and destroys all peers. More...
 
static void shutdown_peers_reply_cb (void *cls, const struct GNUNET_MessageHeader *msg)
 The reply msg handler forwarded SHUTDOWN_PEERS operation. More...
 
void handle_shutdown_peers (void *cls, const struct GNUNET_TESTBED_ShutdownPeersMessage *msg)
 Handler for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS messages. More...
 

Variables

struct Peer ** GST_peer_list
 A list of peers we know about. More...
 
unsigned int GST_num_local_peers
 The current number of peers running locally under this controller. More...
 
static struct PeerReconfigureContextprc_head
 The DLL head for the peer reconfigure list. More...
 
static struct PeerReconfigureContextprc_tail
 The DLL tail for the peer reconfigure list. More...
 
static struct ManageServiceContextmctx_head
 DLL head for queue of manage service requests. More...
 
static struct ManageServiceContextmctx_tail
 DLL tail for queue of manage service requests. More...
 

Detailed Description

implementation of TESTBED service that deals with peer management

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file gnunet-service-testbed_peers.c.

Function Documentation

◆ peer_list_add()

static void peer_list_add ( struct Peer peer)
static

Adds a peer to the peer array.

Parameters
peerthe peer to add

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

References GNUNET_assert, GNUNET_NO, GST_array_grow_large_enough, GST_num_local_peers, GST_peer_list_size, Peer::id, Peer::is_remote, and ManageServiceContext::peer.

Referenced by handle_peer_create(), and peer_create_success_cb().

169 {
170  if (peer->id >= GST_peer_list_size)
172  GNUNET_assert (NULL == GST_peer_list[peer->id]);
173  GST_peer_list[peer->id] = peer;
174  if (GNUNET_NO == peer->is_remote)
176 }
int is_remote
Is this peer locally created?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
uint32_t id
Our local reference id for this peer.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
unsigned int GST_peer_list_size
The size of the peer list.
#define GNUNET_NO
Definition: gnunet_common.h:78
#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 ...
struct Peer ** GST_peer_list
A list of peers we know about.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Here is the caller graph for this function:

◆ peer_list_remove()

static void peer_list_remove ( struct Peer peer)
static

Removes a the give peer from the peer array.

Parameters
peerthe peer to be removed

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

References GNUNET_NO, GNUNET_realloc, GST_num_local_peers, GST_peer_list_size, id, Peer::id, Peer::is_remote, and LIST_GROW_STEP.

Referenced by GST_destroy_peer().

186 {
187  unsigned int orig_size;
188  uint32_t id;
189 
190  if (GNUNET_NO == peer->is_remote)
192  GST_peer_list[peer->id] = NULL;
193  orig_size = GST_peer_list_size;
195  {
196  for (id = GST_peer_list_size - 1;
197  (id >= GST_peer_list_size - LIST_GROW_STEP) && (id != UINT32_MAX);
198  id--)
199  if (NULL != GST_peer_list[id])
200  break;
201  if (id != ((GST_peer_list_size - LIST_GROW_STEP) - 1))
202  break;
204  }
205  if (orig_size == GST_peer_list_size)
206  return;
207  GST_peer_list =
209  sizeof(struct Peer *) * GST_peer_list_size);
210 }
int is_remote
Is this peer locally created?
uint32_t id
Our local reference id for this peer.
unsigned int GST_num_local_peers
The current number of peers running locally under this controller.
unsigned int GST_peer_list_size
The size of the peer list.
#define GNUNET_NO
Definition: gnunet_common.h:78
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
struct Peer ** GST_peer_list
A list of peers we know about.
#define LIST_GROW_STEP
By how much should the arrays lists grow.
Here is the caller graph for this function:

◆ peer_create_forward_timeout()

static void peer_create_forward_timeout ( void *  cls)
static

The task to be executed if the forwarded peer create operation has been timed out.

Parameters
clsthe FowardedOperationContext

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

References ForwardedOperationContext::cls, GNUNET_free, and GST_forwarded_operation_timeout().

Referenced by handle_peer_create().

221 {
222  struct ForwardedOperationContext *fopc = cls;
223 
224  GNUNET_free (fopc->cls);
226 }
void GST_forwarded_operation_timeout(void *cls)
Task to free resources when forwarded operation has been timed out.
void * cls
Closure pointer.
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:

◆ peer_create_success_cb()

static void peer_create_success_cb ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Callback to be called when forwarded peer create operation is successfull.

We have to relay the reply msg back to the client

Parameters
clsForwardedOperationContext
msgthe peer create success message

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

References ForwardedOperationContext::cls, GNUNET_assert, GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS, GST_forwarded_operation_reply_relay(), peer_list_add(), and GNUNET_MessageHeader::type.

Referenced by handle_peer_create().

238 {
239  struct ForwardedOperationContext *fopc = cls;
240  struct Peer *remote_peer;
241 
243  {
244  GNUNET_assert (NULL != fopc->cls);
245  remote_peer = fopc->cls;
246  peer_list_add (remote_peer);
247  }
249  msg);
250 }
#define GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
Message to signal successful peer creation.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void peer_list_add(struct Peer *peer)
Adds a peer to the peer array.
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.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
void * cls
Closure pointer.
Context information for operations forwarded to subcontrollers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_destroy_peer()

void GST_destroy_peer ( struct Peer peer)

Function to destroy a peer.

Parameters
peerthe peer structure to destroy

Definition at line 259 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().

260 {
261  GNUNET_break (0 == peer->reference_cnt);
262  if (GNUNET_YES == peer->is_remote)
263  {
264  peer_list_remove (peer);
265  GNUNET_free (peer);
266  return;
267  }
268  if (GNUNET_YES == peer->details.local.is_running)
269  {
271  peer->details.local.is_running = GNUNET_NO;
272  }
275  peer_list_remove (peer);
276  GNUNET_free (peer);
277 }
int is_remote
Is this peer locally created?
#define GNUNET_NO
Definition: gnunet_common.h:78
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1464
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
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.
union Peer::@66 details
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
struct Peer::@66::@67 local
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1556
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_mctx()

static void cleanup_mctx ( struct ManageServiceContext mctx)
static

Cleanup the context information created for managing a peer's service.

Parameters
mctxthe ManageServiceContext

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

References ManageServiceContext::ah, Peer::destroy_flag, ManageServiceContext::expired, GNUNET_ARM_disconnect(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_YES, GST_destroy_peer(), ManageServiceContext::peer, Peer::reference_cnt, and ManageServiceContext::service.

Referenced by GST_free_mctxq(), GST_notify_client_disconnect_peers(), and service_manage_result_cb().

287 {
288  mctx->expired = GNUNET_YES;
290  mctx_tail,
291  mctx);
292  GNUNET_ARM_disconnect (mctx->ah);
293  GNUNET_assert (0 < mctx->peer->reference_cnt);
294  mctx->peer->reference_cnt--;
295  if ((GNUNET_YES == mctx->peer->destroy_flag) &&
296  (0 == mctx->peer->reference_cnt))
297  GST_destroy_peer (mctx->peer);
298  GNUNET_free (mctx->service);
299  GNUNET_free (mctx);
300 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
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 GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_ARM_disconnect(struct GNUNET_ARM_Handle *h)
Disconnect from the ARM service (if connected) and destroy the context.
Definition: arm_api.c:604
struct GNUNET_ARM_Handle * ah
The ARM handle of the peer.
struct Peer * peer
peer whose service has to be managed
char * service
Name of the service.
uint32_t reference_cnt
References to peers are using in forwarded overlay contexts and remote overlay connect contexts...
void GST_destroy_peer(struct Peer *peer)
Function to destroy a peer.
static struct ManageServiceContext * mctx_head
DLL head for queue of manage service requests.
#define GNUNET_YES
Definition: gnunet_common.h:77
static struct ManageServiceContext * mctx_tail
DLL tail for queue of manage service requests.
uint8_t expired
Is this context expired? Do not work on this context if it is set to GNUNET_YES.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop_peer()

static int stop_peer ( struct Peer peer)
static

Stops a peer.

Parameters
peerthe peer to stop
Returns
GNUNET_OK upon success; GNUNET_SYSERR upon failure

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

References Peer::details, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_peer_kill(), Peer::is_remote, and Peer::local.

Referenced by cleanup_prc(), and handle_peer_stop().

311 {
312  GNUNET_assert (GNUNET_NO == peer->is_remote);
313  if (GNUNET_OK != GNUNET_TESTING_peer_kill (peer->details.local.peer))
314  return GNUNET_SYSERR;
315  peer->details.local.is_running = GNUNET_NO;
316  return GNUNET_OK;
317 }
int is_remote
Is this peer locally created?
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
int GNUNET_TESTING_peer_kill(struct GNUNET_TESTING_Peer *peer)
Sends SIGTERM to the peer&#39;s main process.
Definition: testing.c:1409
union Peer::@66 details
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct Peer::@66::@67 local
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_prc()

static void cleanup_prc ( struct PeerReconfigureContext prc)
static

Cleans up the given PeerReconfigureContext.

Parameters
prcthe PeerReconfigureContext

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

References PeerReconfigureContext::cfg, Peer::details, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_TESTING_peer_stop_async_cancel(), Peer::local, ManageServiceContext::peer, PeerReconfigureContext::peer_id, stop_peer(), PeerReconfigureContext::stopped, and VALID_PEER_ID.

Referenced by GST_free_prcq(), GST_notify_client_disconnect_peers(), and prc_stop_cb().

327 {
328  struct Peer *peer;
329 
330  if (VALID_PEER_ID (prc->peer_id))
331  {
332  peer = GST_peer_list [prc->peer_id];
333  if (1 != prc->stopped)
334  {
336  stop_peer (peer); /* Stop the peer synchronously */
337  }
338  }
339  if (NULL != prc->cfg)
342  prc_tail,
343  prc);
344  GNUNET_free (prc);
345 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static int stop_peer(struct Peer *peer)
Stops a peer.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
uint32_t peer_id
The id of the peer which has to be reconfigured.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
union Peer::@66 details
struct Peer ** GST_peer_list
A list of peers we know about.
static struct PeerReconfigureContext * prc_tail
The DLL tail for the peer reconfigure list.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct Peer::@66::@67 local
void GNUNET_TESTING_peer_stop_async_cancel(struct GNUNET_TESTING_Peer *peer)
Cancel a previous asynchronous peer stop request.
Definition: testing.c:1540
static struct PeerReconfigureContext * prc_head
The DLL head for the peer reconfigure list.
uint8_t stopped
The the peer stopped? Used while cleaning up this context to decide whether the asynchronous stop req...
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
#define GNUNET_free(ptr)
Wrapper around free.
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 354 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().

355 {
356  struct ForwardedOperationContext *fopc;
357  struct ForwardedOperationContext *fopcn;
358  struct ManageServiceContext *mctx;
359  struct ManageServiceContext *mctxn;
360  struct PeerReconfigureContext *prc;
361  struct PeerReconfigureContext *prcn;
362 
363  for (fopc = fopcq_head; NULL != fopc; fopc = fopcn)
364  {
365  fopcn = fopc->next;
366  if (client == fopc->client)
367  {
368  if (OP_PEER_CREATE == fopc->type)
369  GNUNET_free (fopc->cls);
372  }
373  }
374  for (mctx = mctx_head; NULL != mctx; mctx = mctxn)
375  {
376  mctxn = mctx->next;
377  if (client == mctx->client)
378  cleanup_mctx (mctx);
379  }
380  for (prc = prc_head; NULL != prc; prc = prcn)
381  {
382  prcn = prc->next;
383  if (client == prc->client)
384  cleanup_prc (prc);
385  }
386 }
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:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_destroy_success_cb()

static void peer_destroy_success_cb ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

Callback to be called when forwarded peer destroy operation is successfull.

We have to relay the reply msg back to the client

Parameters
clsForwardedOperationContext
msgthe peer create success message

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

References ForwardedOperationContext::cls, Peer::destroy_flag, GNUNET_assert, GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_YES, GST_destroy_peer(), GST_forwarded_operation_reply_relay(), Peer::reference_cnt, and GNUNET_MessageHeader::type.

Referenced by handle_peer_destroy().

398 {
399  struct ForwardedOperationContext *fopc = cls;
400  struct Peer *remote_peer;
401 
403  ntohs (msg->type))
404  {
405  remote_peer = fopc->cls;
406  GNUNET_assert (NULL != remote_peer);
407  remote_peer->destroy_flag = GNUNET_YES;
408  if (0 == remote_peer->reference_cnt)
409  GST_destroy_peer (remote_peer);
410  }
412  msg);
413 }
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 GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
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.
#define GNUNET_YES
Definition: gnunet_common.h:77
Context information for operations forwarded to subcontrollers.
Here is the call graph for this function:
Here is the caller 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 424 of file gnunet-service-testbed_peers.c.

References GNUNET_OK.

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

◆ 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
msgthe actual message

Definition at line 438 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.

440 {
441  struct GNUNET_SERVICE_Client *client = cls;
442  struct GNUNET_MQ_Envelope *env;
445  struct ForwardedOperationContext *fo_ctxt;
446  struct Route *route;
447  struct Peer *peer;
448  char *emsg;
449  uint32_t host_id;
450  uint32_t peer_id;
451 
452  host_id = ntohl (msg->host_id);
453  peer_id = ntohl (msg->peer_id);
454  if (VALID_PEER_ID (peer_id))
455  {
456  (void) GNUNET_asprintf (&emsg,
457  "Peer with ID %u already exists",
458  peer_id);
461  emsg);
462  GNUNET_free (emsg);
464  return;
465  }
466  if (UINT32_MAX == peer_id)
467  {
470  "Cannot create peer with given ID");
472  return;
473  }
474  if (host_id == GST_context->host_id)
475  {
476  /* We are responsible for this peer */
478  if (NULL == cfg)
479  {
480  GNUNET_break (0);
482  return;
483  }
485  "TESTBED",
486  "PEERID",
487  (unsigned long long) peer_id);
488 
490  "PATHS",
491  "PEERID",
492  (unsigned long long) peer_id);
493  peer = GNUNET_new (struct Peer);
494  peer->is_remote = GNUNET_NO;
495  peer->details.local.cfg = cfg;
496  peer->id = peer_id;
497  LOG_DEBUG ("Creating peer with id: %u\n",
498  (unsigned int) peer->id);
499  peer->details.local.peer =
501  peer->details.local.cfg, peer->id,
502  NULL /* Peer id */,
503  &emsg);
504  if (NULL == peer->details.local.peer)
505  {
507  "Configuring peer failed: %s\n",
508  emsg);
509  GNUNET_free (emsg);
510  GNUNET_free (peer);
511  GNUNET_break (0);
513  return;
514  }
515  peer->details.local.is_running = GNUNET_NO;
516  peer_list_add (peer);
517  env = GNUNET_MQ_msg (reply,
519  reply->peer_id = msg->peer_id;
520  reply->operation_id = msg->operation_id;
522  env);
524  return;
525  }
526 
527  /* Forward peer create request */
528  route = GST_find_dest_route (host_id);
529  if (NULL == route)
530  {
531  GNUNET_break (0);
532  GNUNET_SERVICE_client_continue (client); // ?
533  return;
534  }
535  peer = GNUNET_new (struct Peer);
536  peer->is_remote = GNUNET_YES;
537  peer->id = peer_id;
538  peer->details.remote.slave = GST_slave_list[route->dest];
539  peer->details.remote.remote_host_id = host_id;
540  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
541  fo_ctxt->client = client;
542  fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
543  fo_ctxt->cls = peer;
544  fo_ctxt->type = OP_PEER_CREATE;
545  fo_ctxt->opc =
547  [route->dest]->controller,
548  fo_ctxt->operation_id,
549  &msg->header,
551  fo_ctxt);
552  fo_ctxt->timeout_task =
555  fo_ctxt);
557  fopcq_tail,
558  fo_ctxt);
560 }
struct GNUNET_SCHEDULER_Task * timeout_task
Task ID for the timeout task.
Event notification from a controller to a client.
Definition: testbed.h:533
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.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER.
Definition: testbed.h:209
#define LOG(kind,...)
Definition: abd_api.c:38
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:78
#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:543
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:2066
static void peer_create_success_cb(void *cls, const struct GNUNET_MessageHeader *msg)
Callback to be called when forwarded peer create operation is successfull.
struct Peer::@66::@68 remote
#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:1166
Handle to a client that is connected to a service.
Definition: service.c:250
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:1253
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.
union Peer::@66 details
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:2324
uint64_t operation_id
Unique operation id.
Definition: testbed.h:219
void * cls
Closure pointer.
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 Peer::@66::@67 local
uint64_t operation_id
Operation ID of the operation that created this event.
Definition: testbed.h:548
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:1369
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
configuration data
Definition: configuration.c:85
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:214
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:77
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
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:224
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:2243
uint32_t dest
destination host
#define LOG_DEBUG(...)
Debug logging shorthand.
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 570 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.

572 {
573  struct GNUNET_SERVICE_Client *client = cls;
574  struct ForwardedOperationContext *fopc;
575  struct Peer *peer;
576  uint32_t peer_id;
577 
578  peer_id = ntohl (msg->peer_id);
579  LOG_DEBUG ("Received peer destory on peer: %u and operation id: %llu\n",
580  (unsigned int) peer_id,
581  (unsigned long long) GNUNET_ntohll (msg->operation_id));
582  if (! VALID_PEER_ID (peer_id))
583  {
585  "Asked to destroy a non existent peer with id: %u\n", peer_id);
588  "Peer doesn't exist");
590  return;
591  }
592  peer = GST_peer_list[peer_id];
593  if (GNUNET_YES == peer->is_remote)
594  {
595  /* Forward the destory message to sub controller */
596  fopc = GNUNET_new (struct ForwardedOperationContext);
597  fopc->client = client;
598  fopc->cls = peer;
599  fopc->type = OP_PEER_DESTROY;
600  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
601  fopc->opc =
603  slave->controller,
604  fopc->operation_id,
605  &msg->header,
607  fopc);
608  fopc->timeout_task =
611  fopc);
613  fopcq_tail,
614  fopc);
616  return;
617  }
618  peer->destroy_flag = GNUNET_YES;
619  if (0 == peer->reference_cnt)
620  GST_destroy_peer (peer);
621  else
623  "Delaying peer destroy as peer is currently in use\n");
625  GNUNET_ntohll (msg->operation_id));
627 }
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.
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: abd_api.c:38
#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.
struct Peer::@66::@68 remote
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:250
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:1253
struct Slave * slave
The slave this peer is started through.
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:327
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
union Peer::@66 details
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:1369
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER.
Definition: testbed.h:322
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:77
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.
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:2243
#define LOG_DEBUG(...)
Debug logging shorthand.
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:332
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:

◆ start_peer()

static int start_peer ( struct Peer peer)
static

Stats a peer.

Parameters
peerthe peer to start
Returns
GNUNET_OK upon success; GNUNET_SYSERR upon failure

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

References Peer::details, GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTING_peer_start(), GNUNET_YES, Peer::is_remote, and Peer::local.

Referenced by handle_peer_start(), and prc_stop_cb().

638 {
639  GNUNET_assert (GNUNET_NO == peer->is_remote);
640  if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer))
641  return GNUNET_SYSERR;
642  peer->details.local.is_running = GNUNET_YES;
643  return GNUNET_OK;
644 }
int is_remote
Is this peer locally created?
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1359
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
union Peer::@66 details
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct Peer::@66::@67 local
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller 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_START_PEER messages.

Message handler for #GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 654 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.

656 {
657  struct GNUNET_SERVICE_Client *client = cls;
658  struct GNUNET_MQ_Envelope *env;
659  struct GNUNET_TESTBED_PeerEventMessage *reply;
660  struct ForwardedOperationContext *fopc;
661  struct Peer *peer;
662  uint32_t peer_id;
663 
664  peer_id = ntohl (msg->peer_id);
665  if (! VALID_PEER_ID (peer_id))
666  {
667  GNUNET_break (0);
669  "Asked to start a non existent peer with id: %u\n",
670  peer_id);
672  return;
673  }
674  peer = GST_peer_list[peer_id];
675  if (GNUNET_YES == peer->is_remote)
676  {
677  fopc = GNUNET_new (struct ForwardedOperationContext);
678  fopc->client = client;
679  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
680  fopc->type = OP_PEER_START;
681  fopc->opc =
683  slave->controller,
684  fopc->operation_id, &msg->header,
685  &
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:468
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 GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:286
#define LOG(kind,...)
Definition: abd_api.c:38
#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:442
#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:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct Peer::@66::@68 remote
#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:463
Handle to a client that is connected to a service.
Definition: service.c:250
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:453
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:1253
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:458
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
union Peer::@66 details
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:1369
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_START_PEER.
Definition: testbed.h:276
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:77
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:2243
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:281
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_STOP_PEER messages.

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,
761  &
763  fopc);
764  fopc->timeout_task =
767  fopc);
769  fopcq_tail,
770  fopc);
772  return;
773  }
774  if (GNUNET_OK != stop_peer (peer))
775  {
777  "Stopping peer %u failed\n",
778  (unsigned int) peer_id);
781  "Peer not running");
783  return;
784  }
786  "Peer %u successfully stopped\n",
787  (unsigned int) peer_id);
788  env = GNUNET_MQ_msg (reply,
790  reply->event_type = htonl (GNUNET_TESTBED_ET_PEER_STOP);
791  reply->host_id = htonl (GST_context->host_id);
792  reply->peer_id = msg->peer_id;
793  reply->operation_id = msg->operation_id;
795  env);
798 }
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:468
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 GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
static int stop_peer(struct Peer *peer)
Stops a peer.
#define LOG(kind,...)
Definition: abd_api.c:38
#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:442
#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:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct Peer::@66::@68 remote
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:463
Handle to a client that is connected to a service.
Definition: service.c:250
int32_t event_type
enum GNUNET_TESTBED_EventType (in NBO); either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER...
Definition: testbed.h:453
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:1253
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:458
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.
union Peer::@66 details
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 Peer::@66::@67 local
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:1369
Peer stop operation.
Definition: testbed_api.h:59
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER.
Definition: testbed.h:299
struct ForwardedOperationContext * fopcq_tail
DLL tail for forwarded operation contexts.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:304
#define GNUNET_YES
Definition: gnunet_common.h:77
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:309
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:2243
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:1441
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_GET_PEER_INFORMATION messages.

Handler for #GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG messages.

Parameters
clsidentification of the client
msgthe actual message

Definition at line 808 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.

811 {
812  struct GNUNET_SERVICE_Client *client = cls;
813  struct GNUNET_MQ_Envelope *env;
815  struct ForwardedOperationContext *fopc;
816  struct Peer *peer;
817  char *config;
818  char *xconfig;
819  size_t c_size;
820  size_t xc_size;
821  uint32_t peer_id;
822 
823  peer_id = ntohl (msg->peer_id);
824  LOG_DEBUG ("Received GET_CONFIG for peer %u\n",
825  (unsigned int) peer_id);
826  if (! VALID_PEER_ID (peer_id))
827  {
830  "Peer not found");
832  return;
833  }
834  peer = GST_peer_list[peer_id];
835  if (GNUNET_YES == peer->is_remote)
836  {
837  LOG_DEBUG ("Forwarding PEER_GET_CONFIG for peer: %u\n",
838  (unsigned int) peer_id);
839  fopc = GNUNET_new (struct ForwardedOperationContext);
840  fopc->client = client;
841  fopc->operation_id = GNUNET_ntohll (msg->operation_id);
842  fopc->type = OP_PEER_INFO;
843  fopc->opc =
845  slave->controller,
846  fopc->operation_id,
847  &msg->header,
848  &
850  fopc);
851  fopc->timeout_task =
854  fopc);
856  fopcq_tail,
857  fopc);
859  return;
860  }
861  LOG_DEBUG ("Received PEER_GET_CONFIG for peer: %u\n",
862  peer_id);
863  config =
865  &c_size);
866  xc_size = GNUNET_TESTBED_compress_config_ (config,
867  c_size,
868  &xconfig);
869  GNUNET_free (config);
870  env = GNUNET_MQ_msg_extra (reply,
871  xc_size,
873  reply->peer_id = msg->peer_id;
874  reply->operation_id = msg->operation_id;
876  &reply->peer_identity);
877  reply->config_size = htons ((uint16_t) c_size);
878  GNUNET_memcpy (&reply[1],
879  xconfig,
880  xc_size);
881  GNUNET_free (xconfig);
883  env);
885 }
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:613
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 GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
#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:603
struct OperationContext * opc
The generated operation context.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
uint32_t peer_id
Unique ID for the peer.
Definition: testbed.h:591
#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:618
struct Peer::@66::@68 remote
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:250
uint16_t config_size
The size of configuration when uncompressed.
Definition: testbed.h:628
#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:1253
struct Slave * slave
The slave this peer is started through.
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:596
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION.
Definition: testbed.h:586
enum OperationType type
The type of the operation which is forwarded.
static const struct GNUNET_CONFIGURATION_Handle * config
union Peer::@66 details
#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:623
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:1369
size_t GNUNET_TESTBED_compress_config_(const char *config, size_t size, char **xconfig)
Compresses given configuration using zlib compress.
Definition: testbed_api.c:1757
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.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:1337
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:77
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:2243
Get peer information operation.
Definition: testbed_api.h:69
#define LOG_DEBUG(...)
Debug logging shorthand.
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_prcq()

void GST_free_prcq ( void  )

Cleans up the Peer reconfigure context list.

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

References cleanup_prc().

Referenced by shutdown_task().

893 {
894  while (NULL != prc_head)
896 }
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:

◆ update_peer_config()

static char* update_peer_config ( struct Peer peer,
struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Update peer configuration.

Parameters
peerthe peer to update
cfgthe new configuration
Returns
error message (freshly allocated); NULL upon success

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

References cfg, Peer::details, GNUNET_CONFIGURATION_destroy(), GNUNET_TESTING_peer_configure(), GNUNET_TESTING_peer_destroy(), GST_context, Peer::id, Peer::local, and Context::system.

Referenced by handle_peer_reconfigure(), and prc_stop_cb().

909 {
910  char *emsg;
911 
914  peer->details.local.cfg = cfg;
915  emsg = NULL;
916  peer->details.local.peer
918  peer->details.local.cfg,
919  peer->id,
920  NULL /* Peer id */,
921  &emsg);
922  return emsg;
923 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
uint32_t id
Our local reference id for this peer.
struct GNUNET_TESTING_System * system
The TESTING system handle for starting peers locally.
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:1166
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
union Peer::@66 details
struct Peer::@66::@67 local
struct Context * GST_context
The master context; generated with the first INIT message.
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1556
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prc_stop_cb()

static void prc_stop_cb ( void *  cls,
struct GNUNET_TESTING_Peer p,
int  success 
)
static

Callback to inform whether the peer is running or stopped.

Parameters
clsthe closure given to GNUNET_TESTING_peer_stop_async()
pthe respective peer whose status is being reported
successGNUNET_YES if the peer is stopped; GNUNET_SYSERR upon any error

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

References PeerReconfigureContext::cfg, cleanup(), cleanup_prc(), PeerReconfigureContext::client, GNUNET_assert, GNUNET_NO, GNUNET_OK, GST_send_operation_fail_msg(), GST_send_operation_success_msg(), Peer::is_remote, PeerReconfigureContext::op_id, ManageServiceContext::peer, PeerReconfigureContext::peer_id, start_peer(), PeerReconfigureContext::stopped, update_peer_config(), and VALID_PEER_ID.

Referenced by handle_peer_reconfigure().

938 {
939  struct PeerReconfigureContext *prc = cls;
940  struct Peer *peer;
941  char *emsg;
942 
944  peer = GST_peer_list [prc->peer_id];
945  GNUNET_assert (GNUNET_NO == peer->is_remote);
946  emsg = update_peer_config (peer, prc->cfg);
947  prc->cfg = NULL;
948  prc->stopped = 1;
949  if (NULL != emsg)
950  {
952  prc->op_id,
953  emsg);
954  goto cleanup;
955  }
956  if (GNUNET_OK != start_peer (peer))
957  {
959  prc->op_id,
960  "Failed to start reconfigured peer");
961  goto cleanup;
962  }
964  prc->op_id);
965 
966 cleanup:
967  cleanup_prc (prc);
968  return;
969 }
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_assert(cond)
Use this for fatal errors that cannot be handled.
#define VALID_PEER_ID(id)
Condition to check if peer id is valid.
#define GNUNET_NO
Definition: gnunet_common.h:78
Context information for peer re-configure operations.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static void cleanup_prc(struct PeerReconfigureContext *prc)
Cleans up the given PeerReconfigureContext.
uint32_t peer_id
The id of the peer which has to be reconfigured.
uint64_t op_id
The id of the operation.
static void cleanup(void *cls)
Function scheduled as very last function, cleans up after us.
struct Peer ** GST_peer_list
A list of peers we know about.
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.
struct GNUNET_SERVICE_Client * client
The client which gave this operation to us.
static int start_peer(struct Peer *peer)
Stats a peer.
uint8_t stopped
The the peer stopped? Used while cleaning up this context to decide whether the asynchronous stop req...
struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle to use as the new template.
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.
Here is the call graph for this function:
Here is the caller 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 980 of file gnunet-service-testbed_peers.c.

References GNUNET_OK.

982 {
983  return GNUNET_OK; /* checked later */
984 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75

◆ 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 996 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.

999 {
1000  struct GNUNET_SERVICE_Client *client = cls;
1001  struct Peer *peer;
1003  struct ForwardedOperationContext *fopc;
1004  struct PeerReconfigureContext *prc;
1005  char *emsg;
1006  uint64_t op_id;
1007  uint32_t peer_id;
1008 
1009  peer_id = ntohl (msg->peer_id);
1010  op_id = GNUNET_ntohll (msg->operation_id);
1011  if (! VALID_PEER_ID (peer_id))
1012  {
1013  GNUNET_break (0);
1015  op_id,
1016  "Peer not found");
1018  return;
1019  }
1020  peer = GST_peer_list[peer_id];
1021  if (GNUNET_YES == peer->is_remote)
1022  {
1023  LOG_DEBUG ("Forwarding PEER_RECONFIGURE for peer: %u\n", peer_id);
1024  fopc = GNUNET_new (struct ForwardedOperationContext);
1025  fopc->client = client;
1026  fopc->operation_id = op_id;
1027  fopc->type = OP_PEER_RECONFIGURE;
1028  fopc->opc =
1030  slave->controller,
1031  fopc->operation_id,
1032  &msg->header,
1033  &
1035  fopc);
1036  fopc->timeout_task =
1039  fopc);
1041  fopcq_tail,
1042  fopc);
1044  return;
1045  }
1046  LOG_DEBUG ("Received PEER_RECONFIGURE for peer %u\n",
1047  (unsigned int) peer_id);
1048  if (0 < peer->reference_cnt)
1049  {
1050  GNUNET_break (0);
1052  op_id,
1053  "Peer in use");
1055  return;
1056  }
1057  if (GNUNET_YES == peer->destroy_flag)
1058  {
1059  GNUNET_break (0);
1061  op_id,
1062  "Peer is being destroyed");
1064  return;
1065  }
1066  cfg = GNUNET_TESTBED_extract_config_ (&msg->header);
1067  if (NULL == cfg)
1068  {
1069  GNUNET_break (0);
1071  op_id,
1072  "Compression error");
1074  return;
1075  }
1076  if (GNUNET_NO == peer->details.local.is_running)
1077  {
1078  emsg = update_peer_config (peer,
1079  cfg);
1080  if (NULL != emsg)
1082  op_id,
1083  emsg);
1085  op_id);
1087  GNUNET_free_non_null (emsg);
1088  return;
1089  }
1090  prc = GNUNET_new (struct PeerReconfigureContext);
1091  if (GNUNET_OK !=
1093  &prc_stop_cb,
1094  prc))
1095  {
1096  GNUNET_assert (0 < GNUNET_asprintf (&emsg,
1097  "Error trying to stop peer %u asynchronously\n",
1098  peer_id));
1100  "%s\n",
1101  emsg);
1103  op_id,
1104  emsg);
1106  GNUNET_free (prc);
1107  GNUNET_free (emsg);
1108  return;
1109  }
1110  prc->cfg = cfg;
1111  prc->peer_id = peer_id;
1112  prc->op_id = op_id;
1113  prc->client = client;
1115  prc_tail,
1116  prc);
1118 }
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:1515
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 const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER.
Definition: testbed.h:245
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: abd_api.c:38
#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:78
Context information for peer re-configure operations.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#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:2066
struct Peer::@66::@68 remote
#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:250
Reconfigure a peer.
Definition: testbed_api.h:74
Handle to a client that is connected to a service.
Definition: service.c:250
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:1253
uint64_t operation_id
Operation ID that is used to identify this operation.
Definition: testbed.h:255
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.
union Peer::@66 details
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 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 Peer::@66::@67 local
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:1369
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.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
configuration data
Definition: configuration.c:85
struct GNUNET_SERVICE_Client * client
The client to which we have to reply.
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:77
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.
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:2243
#define LOG_DEBUG(...)
Debug logging shorthand.
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 1125 of file gnunet-service-testbed_peers.c.

References cleanup_mctx().

Referenced by handle_shutdown_peers(), and shutdown_task().

1126 {
1127  while (NULL != mctx_head)
1129 }
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:

◆ arm_req_string()

static const char* arm_req_string ( enum GNUNET_ARM_RequestStatus  rs)
static

Returns a string interpretation of rs.

Parameters
rsthe request status from ARM
Returns
a string interpretation of the request status

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

References _, GNUNET_ARM_REQUEST_DISCONNECTED, and GNUNET_ARM_REQUEST_SENT_OK.

Referenced by service_manage_result_cb().

1140 {
1141  switch (rs)
1142  {
1144  return _ ("Message was sent successfully");
1145 
1147  return _ ("We disconnected from ARM before we could send a request");
1148  }
1149  return _ ("Unknown request status");
1150 }
We disconnected from ARM, and request was not sent.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Message was sent successfully.
Here is the caller graph for this function:

◆ arm_ret_string()

static const char* arm_ret_string ( enum GNUNET_ARM_Result  result)
static

Returns a string interpretation of the result.

Parameters
resultthe arm result
Returns
a string interpretation

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

References _, GNUNET_ARM_RESULT_IN_SHUTDOWN, GNUNET_ARM_RESULT_IS_NOT_KNOWN, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ARM_RESULT_IS_STARTING_ALREADY, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_IS_STOPPING_ALREADY, GNUNET_ARM_RESULT_START_FAILED, GNUNET_ARM_RESULT_STARTING, GNUNET_ARM_RESULT_STOPPED, and GNUNET_ARM_RESULT_STOPPING.

Referenced by service_manage_result_cb().

1161 {
1162  switch (result)
1163  {
1165  return _ ("%s is stopped");
1166 
1168  return _ ("%s is starting");
1169 
1171  return _ ("%s is stopping");
1172 
1174  return _ ("%s is starting already");
1175 
1177  return _ ("%s is stopping already");
1178 
1180  return _ ("%s is started already");
1181 
1183  return _ ("%s is stopped already");
1184 
1186  return _ ("%s service is not known to ARM");
1187 
1189  return _ ("%s service failed to start");
1190 
1192  return _ ("%s service can't be started because ARM is shutting down");
1193  }
1194  return _ ("%.s Unknown result code.");
1195 }
ARM stopping was initiated (there&#39;s no "stopped" for ARM itself).
Asked to stop it, but it&#39;s already stopping.
Asked to start it, but it&#39;s already started.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Tried to start a service, but that failed for some reason.
Service starting was initiated.
Asked to start it, but it&#39;s already starting.
static int result
Global testing status.
Asked to start something, but ARM is shutting down and can&#39;t comply.
Asked to stop it, but it&#39;s already stopped.
Asked to start or stop a service, but it&#39;s not known.
Service was stopped (never sent for ARM itself).
Here is the caller graph for this function:

◆ service_manage_result_cb()

static void service_manage_result_cb ( void *  cls,
enum GNUNET_ARM_RequestStatus  rs,
enum GNUNET_ARM_Result  result 
)
static

Function called in response to a start/stop request.

Will be called when request was not sent successfully, or when a reply comes. If the request was not sent successfully, rs will indicate that, and result will be undefined.

Parameters
clsManageServiceContext
rsstatus of the request
resultresult of the operation

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

References arm_req_string(), arm_ret_string(), cleanup_mctx(), ManageServiceContext::client, ManageServiceContext::expired, GNUNET_ARM_REQUEST_SENT_OK, GNUNET_ARM_RESULT_IS_STARTED_ALREADY, GNUNET_ARM_RESULT_IS_STARTING_ALREADY, GNUNET_ARM_RESULT_IS_STOPPED_ALREADY, GNUNET_ARM_RESULT_IS_STOPPING_ALREADY, GNUNET_ARM_RESULT_STARTING, GNUNET_ARM_RESULT_STOPPED, GNUNET_ARM_RESULT_STOPPING, GNUNET_asprintf(), GNUNET_free_non_null, GNUNET_YES, GST_send_operation_fail_msg(), GST_send_operation_success_msg(), Peer::id, LOG_DEBUG, ManageServiceContext::op_id, ManageServiceContext::peer, ret, ManageServiceContext::service, and ManageServiceContext::start.

Referenced by handle_manage_peer_service().

1212 {
1213  struct ManageServiceContext *mctx = cls;
1214  char *emsg;
1215 
1216  emsg = NULL;
1217  if (GNUNET_YES == mctx->expired)
1218  return;
1219  if (GNUNET_ARM_REQUEST_SENT_OK != rs)
1220  {
1221  GNUNET_asprintf (&emsg,
1222  "Error communicating with Peer %u's ARM: %s",
1223  mctx->peer->id,
1224  arm_req_string (rs));
1225  goto ret;
1226  }
1227  if (1 == mctx->start)
1228  goto service_start_check;
1229  if (! ((GNUNET_ARM_RESULT_STOPPED == result)
1233  {
1234  /* stopping a service failed */
1235  GNUNET_asprintf (&emsg,
1237  mctx->service);
1238  goto ret;
1239  }
1240  /* service stopped successfully */
1241  goto ret;
1242 
1243 service_start_check:
1247  {
1248  /* starting a service failed */
1249  GNUNET_asprintf (&emsg,
1251  mctx->service);
1252  goto ret;
1253  }
1254  /* service started successfully */
1255 
1256 ret:
1257  if (NULL != emsg)
1258  {
1259  LOG_DEBUG ("%s\n", emsg);
1261  mctx->op_id,
1262  emsg);
1263  }
1264  else
1266  mctx->op_id);
1267  GNUNET_free_non_null (emsg);
1268  cleanup_mctx (mctx);
1269 }
ARM stopping was initiated (there&#39;s no "stopped" for ARM itself).
void GST_send_operation_fail_msg(struct GNUNET_SERVICE_Client *client, uint64_t operation_id, const char *emsg)
Send operation failure message to client.
Asked to stop it, but it&#39;s already stopping.
uint32_t id
Our local reference id for this peer.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Context information to manage peers&#39; services.
Asked to start it, but it&#39;s already started.
uint8_t start
1 if the service at the peer has to be started; 0 if it has to be stopped
struct Peer * peer
peer whose service has to be managed
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Service starting was initiated.
Asked to start it, but it&#39;s already starting.
char * service
Name of the service.
static int result
Global testing status.
uint64_t op_id
The operation id of the associated request.
static const char * arm_ret_string(enum GNUNET_ARM_Result result)
Returns a string interpretation of the result.
Asked to stop it, but it&#39;s already stopped.
Message was sent successfully.
struct GNUNET_SERVICE_Client * client
The client which requested to manage the peer&#39;s service.
#define GNUNET_YES
Definition: gnunet_common.h:77
static const char * arm_req_string(enum GNUNET_ARM_RequestStatus rs)
Returns a string interpretation of rs.
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.
Service was stopped (never sent for ARM itself).
#define LOG_DEBUG(...)
Debug logging shorthand.
uint8_t expired
Is this context expired? Do not work on this context if it is set to GNUNET_YES.
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:

◆ 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 1280 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.

1283 {
1284  uint16_t msize;
1285  const char*service;
1286 
1287  msize = ntohs (msg->header.size);
1288  service = (const char *) &msg[1];
1289  if ('\0' != service[msize - sizeof
1291  {
1292  GNUNET_break_op (0);
1293  return GNUNET_SYSERR;
1294  }
1295  if (1 < msg->start)
1296  {
1297  GNUNET_break_op (0);
1298  return GNUNET_SYSERR;
1299  }
1300  return GNUNET_OK;
1301 }
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:76
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:725
Message to start/stop services of a peer.
Definition: testbed.h:705
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:710

◆ 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 messages.

Handler for GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE message.

Parameters
clsidentification of client
msgthe actual message

Definition at line 1311 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.

1314 {
1315  struct GNUNET_SERVICE_Client *client = cls;
1316  const char*service;
1317  struct Peer *peer;
1318  char *emsg;
1319  struct GNUNET_ARM_Handle *ah;
1320  struct ManageServiceContext *mctx;
1321  struct ForwardedOperationContext *fopc;
1322  uint64_t op_id;
1323  uint32_t peer_id;
1324 
1325  service = (const char *) &msg[1];
1326  peer_id = ntohl (msg->peer_id);
1327  op_id = GNUNET_ntohll (msg->operation_id);
1328  LOG_DEBUG ("Received request to manage service %s on peer %u\n",
1329  service, (unsigned int) peer_id);
1330  if ((GST_peer_list_size <= peer_id)
1331  || (NULL == (peer = GST_peer_list[peer_id])))
1332  {
1333  GNUNET_asprintf (&emsg, "Asked to manage service of a non existent peer "
1334  "with id: %u", peer_id);
1335  goto err_ret;
1336  }
1337  if (0 == strcasecmp ("arm", service))
1338  {
1339  emsg = GNUNET_strdup ("Cannot start/stop peer's ARM service. "
1340  "Use peer start/stop for that");
1341  goto err_ret;
1342  }
1343  if (GNUNET_YES == peer->is_remote)
1344  {
1345  /* Forward the destory message to sub controller */
1346  fopc = GNUNET_new (struct ForwardedOperationContext);
1347  fopc->client = client;
1348  fopc->cls = peer;
1349  fopc->type = OP_MANAGE_SERVICE;
1350  fopc->operation_id = op_id;
1351  fopc->opc =
1353  slave->controller,
1354  fopc->operation_id,
1355  &msg->header,
1356  &
1358  fopc);
1359  fopc->timeout_task =
1362  fopc);
1364  fopcq_tail,
1365  fopc);
1367  return;
1368  }
1369  if (GNUNET_NO == peer->details.local.is_running)
1370  {
1371  emsg = GNUNET_strdup ("Peer not running\n");
1372  goto err_ret;
1373  }
1374  if ((0 != peer->reference_cnt)
1375  && ((0 == strcasecmp ("core", service))
1376  || (0 == strcasecmp ("transport", service))))
1377  {
1378  GNUNET_asprintf (&emsg, "Cannot stop %s service of peer with id: %u "
1379  "since it is required by existing operations",
1380  service, peer_id);
1381  goto err_ret;
1382  }
1383  ah = GNUNET_ARM_connect (peer->details.local.cfg, NULL, NULL);
1384  if (NULL == ah)
1385  {
1386  GNUNET_asprintf (&emsg,
1387  "Cannot connect to ARM service of peer with id: %u",
1388  peer_id);
1389  goto err_ret;
1390  }
1391  mctx = GNUNET_new (struct ManageServiceContext);
1392  mctx->peer = peer;
1393  peer->reference_cnt++;
1394  mctx->op_id = op_id;
1395  mctx->ah = ah;
1396  mctx->client = client;
1397  mctx->start = msg->start;
1398  mctx->service = GNUNET_strdup (service);
1400  mctx_tail,
1401  mctx);
1402  if (1 == mctx->start)
1404  service,
1407  mctx);
1408  else
1409  GNUNET_ARM_request_service_stop (mctx->ah, service,
1411  mctx);
1413  return;
1414 
1415 err_ret:
1416  LOG (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1417  GST_send_operation_fail_msg (client, op_id, emsg);
1418  GNUNET_free (emsg);
1420 }
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:91
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.
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: abd_api.c:38
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:102
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
#define GNUNET_NO
Definition: gnunet_common.h:78
#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_.
struct Peer::@66::@68 remote
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:250
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:1253
uint64_t operation_id
Operation ID.
Definition: testbed.h:720
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:1039
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.
union Peer::@66 details
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:579
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:930
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 Peer::@66::@67 local
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:1369
uint8_t start
set this to 1 to start the service; 0 to stop the service
Definition: testbed.h:725
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.
struct GNUNET_TIME_Relative GST_timeout
Timeout for operations which may take some time.
uint32_t peer_id
Unique ID of the peer whose service has to be managed.
Definition: testbed.h:715
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.
uint64_t operation_id
The id of the operation that has been forwarded.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS.
Definition: testbed.h:710
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:2243
#define LOG_DEBUG(...)
Debug logging shorthand.
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_destroy_peers()

void GST_destroy_peers ( void  )

Stops and destroys all peers.

Definition at line 1427 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().

1428 {
1429  struct Peer *peer;
1430  unsigned int id;
1431 
1432  if (NULL == GST_peer_list)
1433  return;
1434  for (id = 0; id < GST_peer_list_size; id++)
1435  {
1436  peer = GST_peer_list[id];
1437  if (NULL == peer)
1438  continue;
1439  /* If destroy flag is set it means that this peer should have been
1440  * destroyed by a context which we destroy before */
1441  GNUNET_break (GNUNET_NO == peer->destroy_flag);
1442  /* counter should be zero as we free all contexts before */
1443  GNUNET_break (0 == peer->reference_cnt);
1444  if ((GNUNET_NO == peer->is_remote) &&
1445  (GNUNET_YES == peer->details.local.is_running))
1446  GNUNET_TESTING_peer_kill (peer->details.local.peer);
1447  }
1448  for (id = 0; id < GST_peer_list_size; id++)
1449  {
1450  peer = GST_peer_list[id];
1451  if (NULL == peer)
1452  continue;
1453  if (GNUNET_NO == peer->is_remote)
1454  {
1455  if (GNUNET_YES == peer->details.local.is_running)
1456  GNUNET_TESTING_peer_wait (peer->details.local.peer);
1459  }
1460  GNUNET_free (peer);
1461  }
1463  GST_peer_list = NULL;
1464  GST_peer_list_size = 0;
1465 }
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:78
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:1409
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
union Peer::@66 details
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.
struct Peer::@66::@67 local
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1556
#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:1441
Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown_peers_reply_cb()

static void shutdown_peers_reply_cb ( void *  cls,
const struct GNUNET_MessageHeader msg 
)
static

The reply msg handler forwarded SHUTDOWN_PEERS operation.

Checks if a success reply is received from all clients and then sends the success message to the client

Parameters
clsForwardedOperationContext
msgthe message to relay

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

References ForwardedOperationContext::client, ForwardedOperationContext::cls, fopcq_head, fopcq_tail, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS, GNUNET_YES, GST_send_operation_fail_msg(), GST_send_operation_success_msg(), HandlerContext_ShutdownPeers::nslaves, ForwardedOperationContext::operation_id, HandlerContext_ShutdownPeers::timeout, and GNUNET_MessageHeader::type.

Referenced by handle_shutdown_peers().

1479 {
1480  struct ForwardedOperationContext *fo_ctxt = cls;
1481  struct HandlerContext_ShutdownPeers *hc;
1482 
1483  hc = fo_ctxt->cls;
1484  GNUNET_assert (0 < hc->nslaves);
1485  hc->nslaves--;
1487  ntohs (msg->type))
1488  hc->timeout = GNUNET_YES;
1489  if (0 == hc->nslaves)
1490  {
1491  if (GNUNET_YES == hc->timeout)
1493  fo_ctxt->operation_id,
1494  "Timeout at a slave controller");
1495  else
1497  fo_ctxt->operation_id);
1498  GNUNET_free (hc);
1499  hc = NULL;
1500  }
1502  fopcq_tail,
1503  fo_ctxt);
1504  GNUNET_free (fo_ctxt);
1505 }
#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.
int timeout
Did we observe a timeout with respect to this operation at any of the slaves.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
Message to signal a generic operation has been successful.
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.
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 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.
#define GNUNET_YES
Definition: gnunet_common.h:77
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.
Context data for GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS handler.
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:

◆ 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 1515 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.

1517 {
1518  struct GNUNET_SERVICE_Client *client = cls;
1519  struct HandlerContext_ShutdownPeers *hc;
1520  struct Slave *slave;
1521  struct ForwardedOperationContext *fo_ctxt;
1522  uint64_t op_id;
1523  unsigned int cnt;
1524 
1525  LOG_DEBUG ("Received SHUTDOWN_PEERS\n");
1526  /* Stop and destroy all peers */
1527  GST_free_mctxq ();
1528  GST_free_occq ();
1529  GST_free_roccq ();
1530  GST_clear_fopcq ();
1531  /* Forward to all slaves which we have started */
1532  op_id = GNUNET_ntohll (msg->operation_id);
1534  /* FIXME: have a better implementation where we track which slaves are
1535  started by this controller */
1536  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
1537  {
1538  slave = GST_slave_list[cnt];
1539  if (NULL == slave)
1540  continue;
1541  if (NULL == slave->controller_proc) /* We didn't start the slave */
1542  continue;
1543  LOG_DEBUG ("Forwarding SHUTDOWN_PEERS\n");
1544  hc->nslaves++;
1545  fo_ctxt = GNUNET_new (struct ForwardedOperationContext);
1546  fo_ctxt->client = client;
1547  fo_ctxt->operation_id = op_id;
1548  fo_ctxt->cls = hc;
1549  fo_ctxt->type = OP_SHUTDOWN_PEERS;
1550  fo_ctxt->opc =
1552  fo_ctxt->operation_id,
1553  &msg->header,
1555  fo_ctxt);
1557  fopcq_tail,
1558  fo_ctxt);
1559  }
1560  LOG_DEBUG ("Shutting down peers\n");
1561  GST_destroy_peers ();
1562  if (0 == hc->nslaves)
1563  {
1565  op_id);
1566  GNUNET_free (hc);
1567  }
1569 }
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:693
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:698
Handle to a client that is connected to a service.
Definition: service.c:250
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:1369
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.
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:2243
#define LOG_DEBUG(...)
Debug logging shorthand.
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:

Variable Documentation

◆ GST_peer_list

struct Peer** GST_peer_list

◆ 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().

◆ prc_head

struct PeerReconfigureContext* prc_head
static

The DLL head for the peer reconfigure list.

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

◆ prc_tail

struct PeerReconfigureContext* prc_tail
static

The DLL tail for the peer reconfigure list.

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

◆ mctx_head

struct ManageServiceContext* mctx_head
static

DLL head for queue of manage service requests.

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

◆ mctx_tail

struct ManageServiceContext* mctx_tail
static

DLL tail for queue of manage service requests.

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