GNUnet 0.21.1
testbed_test.c File Reference
#include "platform.h"
#include <unistd.h>
#include <gnunet/platform.h>
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_testbed_service.h>
#include <gnunet/gnunet_dht_service.h>
Include dependency graph for testbed_test.c:

Go to the source code of this file.

Data Structures

struct  MyContext
 

Macros

#define NUM_PEERS   20
 

Functions

static void shutdown_task (void *cls)
 
static void service_connect_comp (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
 
static void * dht_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
 
static void dht_da (void *cls, void *op_result)
 
static void test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
 
int main (int argc, char **argv)
 

Variables

static struct GNUNET_TESTBED_Operation * dht_op
 
static struct GNUNET_DHT_Handledht_handle
 
struct MyContext ctxt
 
static int result
 

Macro Definition Documentation

◆ NUM_PEERS

#define NUM_PEERS   20

Definition at line 8 of file testbed_test.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Definition at line 25 of file testbed_test.c.

26{
27 if (NULL != dht_op)
28 {
29 GNUNET_TESTBED_operation_done (dht_op);
30 dht_op = NULL;
31 dht_handle = NULL;
32 }
34}
@ GNUNET_OK
static struct GNUNET_DHT_Handle * dht_handle
Definition: testbed_test.c:12
static int result
Definition: testbed_test.c:21
static struct GNUNET_TESTBED_Operation * dht_op
Definition: testbed_test.c:10

References dht_handle, dht_op, GNUNET_OK, and result.

Referenced by test_master().

Here is the caller graph for this function:

◆ service_connect_comp()

static void service_connect_comp ( void *  cls,
struct GNUNET_TESTBED_Operation *  op,
void *  ca_result,
const char *  emsg 
)
static

Definition at line 38 of file testbed_test.c.

42{
44 dht_handle = ca_result;
45 // Do work here...
47}
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:144
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567

References dht_handle, dht_op, GNUNET_assert, GNUNET_SCHEDULER_shutdown(), and op.

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_ca()

static void * dht_ca ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Definition at line 51 of file testbed_test.c.

52{
53 struct MyContext *ctxt = cls;
54
56 return dht_handle;
57}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:109
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:1037
struct MyContext ctxt

References cfg, ctxt, dht_handle, GNUNET_DHT_connect(), and MyContext::ht_len.

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dht_da()

static void dht_da ( void *  cls,
void *  op_result 
)
static

Definition at line 61 of file testbed_test.c.

62{
63 struct MyContext *ctxt = cls;
64
66 dht_handle = NULL;
67}
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:1060
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Definition: op.c:246
Connection to the DHT service.
Definition: dht_api.c:235

References ctxt, dht_handle, GNUNET_DHT_disconnect(), and op_result().

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_master()

static void test_master ( void *  cls,
struct GNUNET_TESTBED_RunHandle *  h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Definition at line 71 of file testbed_test.c.

77{
78 ctxt.ht_len = 10;
79 dht_op = GNUNET_TESTBED_service_connect
80 (NULL, peers[0], "dht",
82 &dht_ca, &dht_da, &ctxt);
84}
struct GNUNET_CONTAINER_MultiPeerMap * peers
Map from PIDs to struct CadetPeer entries.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1340
static void shutdown_task(void *cls)
Definition: testbed_test.c:25
static void dht_da(void *cls, void *op_result)
Definition: testbed_test.c:61
static void * dht_ca(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Definition: testbed_test.c:51
static void service_connect_comp(void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg)
Definition: testbed_test.c:38

References ctxt, dht_ca(), dht_da(), dht_op, GNUNET_SCHEDULER_add_shutdown(), MyContext::ht_len, peers, service_connect_comp(), and shutdown_task().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 88 of file testbed_test.c.

89{
90 int ret;
91
93 ret = GNUNET_TESTBED_test_run
94 ("awesome-test", "template.conf",
95 NUM_PEERS, 0LL,
96 NULL, NULL, &test_master, NULL);
97 if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
98 return 1;
99 return 0;
100}
static int ret
Final status code.
Definition: gnunet-arm.c:94
@ GNUNET_SYSERR
#define NUM_PEERS
Definition: testbed_test.c:8
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Definition: testbed_test.c:71

References GNUNET_OK, GNUNET_SYSERR, NUM_PEERS, result, ret, and test_master().

Here is the call graph for this function:

Variable Documentation

◆ dht_op

struct GNUNET_TESTBED_Operation* dht_op
static

Definition at line 10 of file testbed_test.c.

Referenced by service_connect_comp(), shutdown_task(), and test_master().

◆ dht_handle

struct GNUNET_DHT_Handle* dht_handle
static

Definition at line 12 of file testbed_test.c.

Referenced by dht_ca(), dht_da(), service_connect_comp(), and shutdown_task().

◆ ctxt

struct MyContext ctxt

Referenced by dht_ca(), dht_da(), and test_master().

◆ result

int result
static

Definition at line 21 of file testbed_test.c.

Referenced by main(), and shutdown_task().