GNUnet  0.10.x
Functions
gnunet-service-testbed_barriers.h File Reference

Interface for the barrier initialisation handler routine. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void GST_barriers_init (struct GNUNET_CONFIGURATION_Handle *cfg)
 Function to initialise barrriers component. More...
 
void GST_barriers_destroy (void)
 Function to stop the barrier service. More...
 
int check_barrier_init (void *cls, const struct GNUNET_TESTBED_BarrierInit *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages. More...
 
void handle_barrier_init (void *cls, const struct GNUNET_TESTBED_BarrierInit *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages. More...
 
int check_barrier_cancel (void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages. More...
 
void handle_barrier_cancel (void *cls, const struct GNUNET_TESTBED_BarrierCancel *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages. More...
 
int check_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages. More...
 
void handle_barrier_status (void *cls, const struct GNUNET_TESTBED_BarrierStatusMsg *msg)
 Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages. More...
 

Detailed Description

Interface for the barrier initialisation handler routine.

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_barriers.h.

Function Documentation

◆ GST_barriers_init()

void GST_barriers_init ( struct GNUNET_CONFIGURATION_Handle cfg)

Function to initialise barrriers component.

Parameters
cfgthe configuration to use for initialisation

Definition at line 468 of file gnunet-service-testbed_barriers.c.

References connect_cb(), disconnect_cb(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_SERVICE_start(), GNUNET_YES, and LOG_DEBUG.

Referenced by testbed_run().

469 {
470  struct GNUNET_MQ_MessageHandler message_handlers[] = {
471  GNUNET_MQ_hd_var_size (barrier_wait,
474  NULL),
476  };
477 
478  LOG_DEBUG ("Launching testbed-barrier service\n");
480  GNUNET_YES);
481  ctx = GNUNET_SERVICE_start ("testbed-barrier",
482  cfg,
483  &connect_cb,
484  &disconnect_cb,
485  NULL,
486  message_handlers);
487 }
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
#define GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT
Message sent by a peer when it has reached a barrier and is waiting for it to be crossed.
struct GNUNET_SERVICE_Handle * GNUNET_SERVICE_start(const char *service_name, const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_SERVICE_ConnectHandler connect_cb, GNUNET_SERVICE_DisconnectHandler disconnect_cb, void *cls, const struct GNUNET_MQ_MessageHandler *handlers)
Low-level function to start a service if the scheduler is already running.
Definition: service.c:2157
Message sent from peers to the testbed-barrier service to indicate that they have reached a barrier a...
Definition: testbed.h:891
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
static struct GNUNET_SERVICE_Handle * ctx
Service context.
static void disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Functions with this signature are called whenever a client is disconnected on the network level...
Message handler for a specific message type.
static void * connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Function called when a client connects to the testbed-barrier service.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_YES
Definition: gnunet_common.h:80
#define LOG_DEBUG(msg)
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GST_barriers_destroy()

void GST_barriers_destroy ( void  )

Function to stop the barrier service.

Definition at line 518 of file gnunet-service-testbed_barriers.c.

References barrier_destroy_iterator(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_SERVICE_stop(), and GNUNET_SYSERR.

Referenced by shutdown_task().

519 {
520  GNUNET_assert (NULL != barrier_map);
524  NULL));
526  GNUNET_assert (NULL != ctx);
528 }
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static struct GNUNET_SERVICE_Handle * ctx
Service context.
void GNUNET_SERVICE_stop(struct GNUNET_SERVICE_Handle *srv)
Stops a service that was started with GNUNET_SERVICE_start().
Definition: service.c:2193
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static int barrier_destroy_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_barrier_init()

int check_barrier_init ( void *  cls,
const struct GNUNET_TESTBED_BarrierInit msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.

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

Definition at line 627 of file gnunet-service-testbed_barriers.c.

References GNUNET_OK.

629 {
630  return GNUNET_OK; /* always well-formed */
631 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_barrier_init()

void handle_barrier_init ( void *  cls,
const struct GNUNET_TESTBED_BarrierInit msg 
)

Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT messages.

This message should always come from a parent controller or the testbed API if we are the root controller.

This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller

Parameters
clsidentification of the client
msgthe actual message

Definition at line 646 of file gnunet-service-testbed_barriers.c.

References ClientCtx::barrier, WBarrier::barrier, ClientCtx::client, Context::client, Slave::controller, WBarrier::controller, fwd_tout_barrier_init(), GNUNET_assert, GNUNET_break, GNUNET_break_op, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TESTBED_barrier_init_(), GNUNET_TESTBED_BARRIERSTATUS_ERROR, GNUNET_TESTBED_BARRIERSTATUS_INITIALISED, GNUNET_YES, GST_context, GST_slave_list, GST_slave_list_size, Barrier::hash, WBarrier::hbarrier, GNUNET_TESTBED_BarrierInit::header, LOG_DEBUG, Barrier::mc, MESSAGE_SEND_TIMEOUT, Barrier::name, name, GNUNET_TESTBED_BarrierInit::name, Barrier::num_wbarriers, Barrier::quorum, GNUNET_TESTBED_BarrierInit::quorum, send_barrier_status_msg(), send_client_status_msg(), GNUNET_MessageHeader::size, Barrier::status, Barrier::tout_task, wbarrier_status_cb(), Barrier::whead, and Barrier::wtail.

648 {
649  struct GNUNET_SERVICE_Client *client = cls;
650  char *name;
651  struct Barrier *barrier;
652  struct Slave *slave;
653  struct WBarrier *wrapper;
654  struct GNUNET_HashCode hash;
655  size_t name_len;
656  unsigned int cnt;
657  uint16_t msize;
658 
659  if (NULL == GST_context)
660  {
661  GNUNET_break_op (0);
663  return;
664  }
665  if (client != GST_context->client)
666  {
667  GNUNET_break_op (0);
669  return;
670  }
671  msize = ntohs (msg->header.size);
672  name_len = (size_t) msize - sizeof (struct GNUNET_TESTBED_BarrierInit);
673  name = GNUNET_malloc (name_len + 1);
674  GNUNET_memcpy (name, msg->name, name_len);
675  GNUNET_CRYPTO_hash (name, name_len, &hash);
676  LOG_DEBUG ("Received BARRIER_INIT for barrier `%s'\n",
677  name);
678  if (GNUNET_YES ==
680  &hash))
681  {
682  send_client_status_msg (client,
683  name,
685  "A barrier with the same name already exists");
686  GNUNET_free (name);
688  return;
689  }
690  barrier = GNUNET_new (struct Barrier);
691  barrier->hash = hash;
692  barrier->quorum = msg->quorum;
693  barrier->name = name;
694  barrier->mc = client;
697  &barrier->hash,
698  barrier,
701  /* Propagate barrier init to subcontrollers */
702  for (cnt = 0; cnt < GST_slave_list_size; cnt++)
703  {
704  if (NULL == (slave = GST_slave_list[cnt]))
705  continue;
706  if (NULL == slave->controller)
707  {
708  GNUNET_break (0);/* May happen when we are connecting to the controller */
709  continue;
710  }
711  wrapper = GNUNET_new (struct WBarrier);
712  wrapper->barrier = barrier;
713  wrapper->controller = slave->controller;
715  barrier->wtail,
716  wrapper);
717  barrier->num_wbarriers++;
718  wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (wrapper->controller,
719  barrier->name,
720  barrier->quorum,
722  wrapper,
723  GNUNET_NO);
724  }
725  if (NULL == barrier->whead) /* No further propagation */
726  {
728  LOG_DEBUG ("Sending GNUNET_TESTBED_BARRIERSTATUS_INITIALISED for barrier `%s'\n",
729  barrier->name);
730  send_barrier_status_msg (barrier, NULL);
731  }else
734  barrier);
735 }
struct WBarrier * wtail
DLL tail for the list of barrier handles.
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Structure representing a connected(directly-linked) controller.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
static void send_barrier_status_msg(struct Barrier *barrier, const char *emsg)
Sends a barrier failed message.
struct GNUNET_TESTBED_Barrier * hbarrier
The barrier handle from API.
enum GNUNET_TESTBED_BarrierStatus status
The status of this barrier.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
unsigned int num_wbarriers
Number of barriers wrapped in the above DLL.
Handle to a client that is connected to a service.
Definition: service.c:249
#define MESSAGE_SEND_TIMEOUT(s)
timeout for outgoing message transmissions in seconds
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1246
#define GNUNET_memcpy(dst, src, n)
, &#39; bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
struct WBarrier * whead
DLL head for the list of barrier handles.
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
struct GNUNET_TESTBED_Controller * controller
Handle to the slave controller where this wrapper creates a barrier.
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
struct GNUNET_HashCode hash
The hashcode of the barrier name.
struct GNUNET_TESTBED_Barrier * GNUNET_TESTBED_barrier_init_(struct GNUNET_TESTBED_Controller *controller, const char *name, unsigned int quorum, GNUNET_TESTBED_barrier_status_cb cb, void *cls, int echo)
Initialise a barrier and call the given callback when the required percentage of peers (quorum) reach...
Definition: testbed_api.c:2375
struct GNUNET_SERVICE_Client * mc
The client handle to the master controller.
const char * name
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT.
Definition: testbed.h:828
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static void wbarrier_status_cb(void *cls, const char *name, struct GNUNET_TESTBED_Barrier *b_, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg)
Functions of this type are to be given as callback argument to GNUNET_TESTBED_barrier_init().
char * name
The name of the barrier.
uint8_t quorum
Quorum percentage to be reached.
struct Context * GST_context
The master context; generated with the first INIT message.
struct GNUNET_SCHEDULER_Task * tout_task
Identifier for the timeout task.
Wrapper around Barrier handle.
uint8_t quorum
The quorum percentage needed for crossing the barrier.
Definition: testbed.h:833
static void fwd_tout_barrier_init(void *cls)
Function called upon timeout while waiting for a response from the subcontrollers to barrier init mes...
struct GNUNET_TESTBED_Controller * controller
The controller handle.
Barrier initialised successfully.
#define GNUNET_YES
Definition: gnunet_common.h:80
char name[0]
name of the barrier.
Definition: testbed.h:838
#define LOG_DEBUG(msg)
Message to initialise a barrier.
Definition: testbed.h:823
struct Barrier * barrier
The local barrier associated with the creation of this wrapper.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
static void send_client_status_msg(struct GNUNET_SERVICE_Client *client, const char *name, enum GNUNET_TESTBED_BarrierStatus status, const char *emsg)
Send a status message about a barrier to the given client.
Here is the call graph for this function:

◆ check_barrier_cancel()

int check_barrier_cancel ( void *  cls,
const struct GNUNET_TESTBED_BarrierCancel msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.

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

Definition at line 746 of file gnunet-service-testbed_barriers.c.

References GNUNET_OK.

748 {
749  return GNUNET_OK; /* all are well-formed */
750 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78

◆ handle_barrier_cancel()

void handle_barrier_cancel ( void *  cls,
const struct GNUNET_TESTBED_BarrierCancel msg 
)

Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL messages.

This message should always come from a parent controller or the testbed API if we are the root controller.

This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller

Parameters
clsidentification of the client
msgthe actual message

Definition at line 765 of file gnunet-service-testbed_barriers.c.

References ClientCtx::barrier, cancel_wrappers(), ClientCtx::client, Context::client, GNUNET_assert, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GST_context, GNUNET_TESTBED_BarrierCancel::header, LOG_DEBUG, name, GNUNET_TESTBED_BarrierCancel::name, remove_barrier(), and GNUNET_MessageHeader::size.

767 {
768  struct GNUNET_SERVICE_Client *client = cls;
769  char *name;
770  struct Barrier *barrier;
771  struct GNUNET_HashCode hash;
772  size_t name_len;
773  uint16_t msize;
774 
775  if (NULL == GST_context)
776  {
777  GNUNET_break_op (0);
779  return;
780  }
781  if (client != GST_context->client)
782  {
783  GNUNET_break_op (0);
785  return;
786  }
787  msize = ntohs (msg->header.size);
788  name_len = msize - sizeof (struct GNUNET_TESTBED_BarrierCancel);
789  name = GNUNET_malloc (name_len + 1);
790  GNUNET_memcpy (name,
791  msg->name,
792  name_len);
793  LOG_DEBUG ("Received BARRIER_CANCEL for barrier `%s'\n",
794  name);
795  GNUNET_CRYPTO_hash (name,
796  name_len,
797  &hash);
798  if (GNUNET_NO ==
800  &hash))
801  {
802  GNUNET_break_op (0);
804  return;
805  }
807  &hash);
808  GNUNET_assert (NULL != barrier);
809  cancel_wrappers (barrier);
810  remove_barrier (barrier);
812 }
Message to cancel a barrier.
Definition: testbed.h:845
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:81
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL.
Definition: testbed.h:850
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
Handle to a client that is connected to a service.
Definition: service.c:249
#define GNUNET_memcpy(dst, src, n)
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
static void cancel_wrappers(struct Barrier *barrier)
Cancels all subcontroller barrier handles.
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
char name[0]
The barrier name.
Definition: testbed.h:855
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
const char * name
struct Context * GST_context
The master context; generated with the first INIT message.
#define LOG_DEBUG(msg)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
static void remove_barrier(struct Barrier *barrier)
Function to remove a barrier from the barrier map and cleanup resources occupied by a barrier...
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:

◆ check_barrier_status()

int check_barrier_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)

Check GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.

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

Definition at line 823 of file gnunet-service-testbed_barriers.c.

References GNUNET_TESTBED_BarrierStatusMsg::data, GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TESTBED_BARRIERSTATUS_CROSSED, GNUNET_TESTBED_BarrierStatusMsg::header, name, GNUNET_TESTBED_BarrierStatusMsg::name_len, GNUNET_MessageHeader::size, status, and GNUNET_TESTBED_BarrierStatusMsg::status.

825 {
826  uint16_t msize;
827  uint16_t name_len;
828  const char *name;
830 
831  msize = ntohs (msg->header.size) - sizeof (*msg);
832  status = ntohs (msg->status);
834  {
835  GNUNET_break_op (0); /* current we only expect BARRIER_CROSSED
836  status message this way */
837  return GNUNET_SYSERR;
838  }
839  name = msg->data;
840  name_len = ntohs (msg->name_len);
841  if ((name_len + 1) != msize)
842  {
843  GNUNET_break_op (0);
844  return GNUNET_SYSERR;
845  }
846  if ('\0' != name[name_len])
847  {
848  GNUNET_break_op (0);
849  return GNUNET_SYSERR;
850  }
851  return GNUNET_OK;
852 }
uint16_t name_len
strlen of the barrier name
Definition: testbed.h:877
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS.
Definition: testbed.h:867
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
GNUNET_TESTBED_BarrierStatus
Status of a barrier.
uint16_t status
status.
Definition: testbed.h:872
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
uint16_t status
See PRISM_STATUS_*-constants.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
char data[0]
the barrier name (0-terminated) concatenated with an error message (0-terminated) if the status were ...
Definition: testbed.h:883
const char * name

◆ handle_barrier_status()

void handle_barrier_status ( void *  cls,
const struct GNUNET_TESTBED_BarrierStatusMsg msg 
)

Message handler for GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS messages.

This handler is queued in the main service and will handle the messages sent either from the testbed driver or from a high level controller

Parameters
clsidentification of the client
msgthe actual message

The wrapper barriers do not echo the barrier status, so we have to do it here

Definition at line 864 of file gnunet-service-testbed_barriers.c.

References ClientCtx::barrier, ClientCtx::client, Context::client, WBarrier::controller, GNUNET_TESTBED_BarrierStatusMsg::data, env, GNUNET_break_op, GNUNET_CONTAINER_multihashmap_get(), GNUNET_copy_message(), GNUNET_CRYPTO_hash(), GNUNET_MQ_msg_copy(), GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_get_mq(), GNUNET_TESTBED_queue_message_(), GST_context, Barrier::head, GNUNET_TESTBED_BarrierStatusMsg::header, LOG_DEBUG, name, GNUNET_TESTBED_BarrierStatusMsg::name_len, ClientCtx::next, WBarrier::next, and Barrier::whead.

866 {
867  struct GNUNET_SERVICE_Client *client = cls;
868  struct Barrier *barrier;
869  struct ClientCtx *client_ctx;
870  struct WBarrier *wrapper;
871  const char *name;
872  struct GNUNET_HashCode key;
873  uint16_t name_len;
874  struct GNUNET_MQ_Envelope *env;
875 
876  if (NULL == GST_context)
877  {
878  GNUNET_break_op (0);
880  return;
881  }
882  if (client != GST_context->client)
883  {
884  GNUNET_break_op (0);
886  return;
887  }
888  name = msg->data;
889  name_len = ntohs (msg->name_len);
890  LOG_DEBUG ("Received BARRIER_STATUS for barrier `%s'\n",
891  name);
892  GNUNET_CRYPTO_hash (name,
893  name_len,
894  &key);
896  &key);
897  if (NULL == barrier)
898  {
899  GNUNET_break_op (0);
901  return;
902  }
904  for(client_ctx = barrier->head; NULL != client_ctx; client_ctx = client_ctx->next) /* Notify peers */
905  {
906  env = GNUNET_MQ_msg_copy (&msg->header);
908  env);
909  }
914  for (wrapper = barrier->whead; NULL != wrapper; wrapper = wrapper->next)
915  {
917  GNUNET_copy_message (&msg->header));
918  }
919 }
struct GNUNET_MQ_Envelope * GNUNET_MQ_msg_copy(const struct GNUNET_MessageHeader *hdr)
Create a new envelope by copying an existing message.
Definition: mq.c:653
struct WBarrier * next
DLL next pointer.
Context to be associated with each client.
static struct GNUNET_CONTAINER_MultiHashMap * barrier_map
Hashtable handle for storing initialised barriers.
uint16_t name_len
strlen of the barrier name
Definition: testbed.h:877
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS.
Definition: testbed.h:867
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
Handle to a client that is connected to a service.
Definition: service.c:249
struct ClientCtx * next
DLL next ptr.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
struct WBarrier * whead
DLL head for the list of barrier handles.
struct GNUNET_SERVICE_Client * client
The client handle associated with this context.
struct GNUNET_TESTBED_Controller * controller
Handle to the slave controller where this wrapper creates a barrier.
A 512-bit hashcode.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2618
struct GNUNET_HashCode key
The key used in the DHT.
char data[0]
the barrier name (0-terminated) concatenated with an error message (0-terminated) if the status were ...
Definition: testbed.h:883
void GNUNET_TESTBED_queue_message_(struct GNUNET_TESTBED_Controller *controller, struct GNUNET_MessageHeader *msg)
Queues a message in send queue for sending to the service.
Definition: testbed_api.c:1331
const char * name
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_SERVICE_Client * client
The client handle.
struct Context * GST_context
The master context; generated with the first INIT message.
struct ClientCtx * head
DLL head for the list of clients waiting for this barrier.
Wrapper around Barrier handle.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
#define LOG_DEBUG(msg)
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2533
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
Here is the call graph for this function: