aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_api.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-08-07 06:34:19 +0000
committerBart Polot <bart@net.in.tum.de>2011-08-07 06:34:19 +0000
commit4a7ea21113603575b97c37eea5c4ee93d1c376bc (patch)
tree8dcb8b08d48a87097634e83a89f33ccdf5f18019 /src/mesh/test_mesh_api.c
parent5133e679d1c77f276ea7a23f2c054f61fa61ac08 (diff)
downloadgnunet-4a7ea21113603575b97c37eea5c4ee93d1c376bc.tar.gz
gnunet-4a7ea21113603575b97c37eea5c4ee93d1c376bc.zip
Greetings from San Francisco.
Connect_by_type registration and search Local data delivery Fixes Tests
Diffstat (limited to 'src/mesh/test_mesh_api.c')
-rw-r--r--src/mesh/test_mesh_api.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c
index 08a3b1c3c..c85f2e738 100644
--- a/src/mesh/test_mesh_api.c
+++ b/src/mesh/test_mesh_api.c
@@ -32,13 +32,40 @@
32#define VERBOSE 1 32#define VERBOSE 1
33#define VERBOSE_ARM 0 33#define VERBOSE_ARM 0
34 34
35static struct GNUNET_MESH_MessageHandler handlers[] = {{NULL, 0, 0}};
36static struct GNUNET_OS_Process *arm_pid; 35static struct GNUNET_OS_Process *arm_pid;
37static struct GNUNET_MESH_Handle *mesh; 36static struct GNUNET_MESH_Handle *mesh;
38static int result; 37static int result;
39GNUNET_SCHEDULER_TaskIdentifier abort_task; 38GNUNET_SCHEDULER_TaskIdentifier abort_task;
40GNUNET_SCHEDULER_TaskIdentifier test_task; 39GNUNET_SCHEDULER_TaskIdentifier test_task;
41 40
41/**
42 * Function is called whenever a message is received.
43 *
44 * @param cls closure (set from GNUNET_MESH_connect)
45 * @param tunnel connection to the other end
46 * @param tunnel_ctx place to store local state associated with the tunnel
47 * @param sender who sent the message
48 * @param message the actual message
49 * @param atsi performance data for the connection
50 * @return GNUNET_OK to keep the connection open,
51 * GNUNET_SYSERR to close it (signal serious error)
52 */
53static int
54callback(void *cls,
55 struct GNUNET_MESH_Tunnel *tunnel,
56 void **tunnel_ctx,
57 const struct GNUNET_PeerIdentity *sender,
58 const struct GNUNET_MessageHeader *message,
59 const struct GNUNET_TRANSPORT_ATS_Information
60 *atsi)
61{
62 return 0;
63}
64
65static struct GNUNET_MESH_MessageHandler handlers[] = {{&callback, 1, 0},
66 {NULL, 0, 0}};
67
68
42static void 69static void
43do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 70do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
44{ 71{
@@ -70,10 +97,12 @@ static void
70test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 97test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
71{ 98{
72 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 99 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
73 GNUNET_MESH_ApplicationType app; 100 GNUNET_MESH_ApplicationType app[3];
74 101
75 test_task = (GNUNET_SCHEDULER_TaskIdentifier) 0; 102 test_task = (GNUNET_SCHEDULER_TaskIdentifier) 0;
76 app = (GNUNET_MESH_ApplicationType) 0; 103 app[0] = (GNUNET_MESH_ApplicationType) 1;
104 app[1] = (GNUNET_MESH_ApplicationType) 2;
105 app[2] = (GNUNET_MESH_ApplicationType) 0;
77 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, &app); 106 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, &app);
78 if(NULL == mesh) { 107 if(NULL == mesh) {
79 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to mesh :(\n"); 108 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to mesh :(\n");
@@ -104,7 +133,7 @@ run (void *cls,
104 NULL); 133 NULL);
105 134
106 abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( 135 abort_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
107 GNUNET_TIME_UNIT_SECONDS, 5), 136 GNUNET_TIME_UNIT_SECONDS, 20),
108 &do_abort, 137 &do_abort,
109 NULL); 138 NULL);
110 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( 139 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(