aboutsummaryrefslogtreecommitdiff
path: root/src/multicast
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2016-09-22 11:35:37 +0000
committerGabor X Toth <*@tg-x.net>2016-09-22 11:35:37 +0000
commit2f26cb57675966de7f04606fa83b0f0fc1dae46b (patch)
treec2afd2dbf7d956f6c8d76800961e2edcf9ff311c /src/multicast
parent7aaeecbba083f6e34f181fa3db515cf65736e9f6 (diff)
downloadgnunet-2f26cb57675966de7f04606fa83b0f0fc1dae46b.tar.gz
gnunet-2f26cb57675966de7f04606fa83b0f0fc1dae46b.zip
multicast: towards multipeer test
Diffstat (limited to 'src/multicast')
-rw-r--r--src/multicast/test_multicast_multipeer.c157
1 files changed, 120 insertions, 37 deletions
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c
index e13dc0f93..2e8b9818d 100644
--- a/src/multicast/test_multicast_multipeer.c
+++ b/src/multicast/test_multicast_multipeer.c
@@ -36,11 +36,25 @@
36 36
37#define NUM_PEERS 2 37#define NUM_PEERS 2
38 38
39static struct GNUNET_TESTBED_Operation *multicast_peer0; 39static struct GNUNET_TESTBED_Operation *peer0;
40static struct GNUNET_TESTBED_Operation *multicast_peer1; 40static struct GNUNET_TESTBED_Operation *peer1;
41 41
42static struct GNUNET_SCHEDULER_Task *timeout_tid; 42static struct GNUNET_SCHEDULER_Task *timeout_tid;
43 43
44struct GNUNET_CRYPTO_EddsaPrivateKey *group_key;
45struct GNUNET_CRYPTO_EddsaPublicKey group_pub_key;
46
47struct GNUNET_CRYPTO_EcdsaPrivateKey *member1_key;
48struct GNUNET_CRYPTO_EcdsaPublicKey member1_pub_key;
49
50
51enum
52{
53 TEST_INIT = 0,
54 TEST_ORIGIN_START = 1,
55 TEST_MEMBER_JOIN = 2,
56} test;
57
44 58
45/** 59/**
46 * Global result for testcase. 60 * Global result for testcase.
@@ -55,10 +69,10 @@ static int result;
55static void 69static void
56shutdown_task (void *cls) 70shutdown_task (void *cls)
57{ 71{
58 if (NULL != multicast_peer0) 72 if (NULL != peer0)
59 { 73 {
60 GNUNET_TESTBED_operation_done (multicast_peer0); 74 GNUNET_TESTBED_operation_done (peer0);
61 multicast_peer0 = NULL; 75 peer0 = NULL;
62 } 76 }
63 if (NULL != timeout_tid) 77 if (NULL != timeout_tid)
64 { 78 {
@@ -79,45 +93,115 @@ timeout_task (void *cls)
79} 93}
80 94
81 95
82static void 96static void
97origin_recv_replay_msg (void *cls,
98 const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
99 uint64_t message_id,
100 uint64_t fragment_offset,
101 uint64_t flags,
102 struct GNUNET_MULTICAST_ReplayHandle *rh)
103{
104 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
105 "Test #%u: origin_recv_replay_msg()\n", test);
106 GNUNET_assert (0);
107}
108
109
110static void
111member_recv_replay_msg (void *cls,
112 const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
113 uint64_t message_id,
114 uint64_t fragment_offset,
115 uint64_t flags,
116 struct GNUNET_MULTICAST_ReplayHandle *rh)
117{
118 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
119 "Test #%u: member_recv_replay_msg()\n", test);
120 GNUNET_assert (0);
121}
122
123
124static void
125origin_recv_replay_frag (void *cls,
126 const struct GNUNET_CRYPTO_EcdsaPublicKey *member_key,
127 uint64_t fragment_id,
128 uint64_t flags,
129 struct GNUNET_MULTICAST_ReplayHandle *rh)
130{
131 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
132 "Test #%u: origin_recv_replay_frag()"
133 " - fragment_id=%" PRIu64 " flags=%" PRIu64 "\n",
134 test, fragment_id, flags);
135}
136
137
138/**
139 * Test: origin receives join request
140 */
141static void
142origin_recv_join_request (void *cls,
143 const struct GNUNET_CRYPTO_EcdsaPublicKey *mem_key,
144 const struct GNUNET_MessageHeader *join_msg,
145 struct GNUNET_MULTICAST_JoinHandle *jh)
146{
147 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
148 "Test #%u: origin_recv_join_request()\n", test);
149}
150
151
152static void
153origin_recv_request (void *cls,
154 const struct GNUNET_MULTICAST_RequestHeader *req)
155{
156 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
157 "Test #%u: origin_recv_request()\n",
158 test);
159}
160
161
162static void
163origin_recv_message (void *cls,
164 const struct GNUNET_MULTICAST_MessageHeader *msg)
165{
166 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
167 "Test #%u: origin_recv_message()\n",
168 test);
169}
170
171
172static void
83service_close_peer0 (void *cls, 173service_close_peer0 (void *cls,
84 void *op_result) 174 void *op_result)
85{ 175{
86 struct GNUNET_MULTICAST_Origin *orig = op_result; 176 struct GNUNET_MULTICAST_Origin *orig = op_result;
87 177
88 GNUNET_MULTICAST_origin_stop (orig, 178 GNUNET_MULTICAST_origin_stop (orig, NULL, NULL);
89 NULL,
90 NULL);
91} 179}
92 180
93 181
94/** 182/**
95 * Function run when service multicast has started and is providing us 183 * Function run when service multicast has started and is providing us
96 * with a configuration file. 184 * with a configuration file.
97 */ 185 */
98static void * 186static void *
99service_conf_peer0 (void *cls, 187service_conf_peer0 (void *cls,
100 const struct GNUNET_CONFIGURATION_Handle *cfg) 188 const struct GNUNET_CONFIGURATION_Handle *cfg)
101{ 189{
102 #if 0 190 group_key = GNUNET_CRYPTO_eddsa_key_create ();
103 return GNUNET_MULTICAST_origin_start (cfg, 191 GNUNET_CRYPTO_eddsa_key_get_public (group_key, &group_pub_key);
104 priv_key,
105 42,
106 &join_rcb,
107 &reply_fcb,
108 &reply_mcb,
109 &request_cb,
110 &message_cb,
111 NULL);
112#else
113 return NULL;
114 192
115#endif 193 return GNUNET_MULTICAST_origin_start (cfg, group_key, 0,
194 origin_recv_join_request,
195 origin_recv_replay_frag,
196 origin_recv_replay_msg,
197 origin_recv_request,
198 origin_recv_message,
199 NULL);
116} 200}
117 201
118 202
119/** 203/**
120 * Test logic of peer "0" being origin starts here. 204 * Test logic of peer "0" being origin starts here.
121 * 205 *
122 * @param cls closure, for the example: NULL 206 * @param cls closure, for the example: NULL
123 * @param op should be equal to "dht_op" 207 * @param op should be equal to "dht_op"
@@ -134,7 +218,7 @@ service_connect_peer0 (void *cls,
134{ 218{
135 struct GNUNET_MULTICAST_Origin *orig = ca_result; 219 struct GNUNET_MULTICAST_Origin *orig = ca_result;
136 220
137 /* Connection to service successful. Here we'd usually do something with 221 /* Connection to service successful. Here we'd usually do something with
138 * the service. */ 222 * the service. */
139 result = GNUNET_OK; 223 result = GNUNET_OK;
140 GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */ 224 GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
@@ -147,8 +231,8 @@ service_connect_peer0 (void *cls,
147 * just to the multicast service of peer 0 and 1. 231 * just to the multicast service of peer 0 and 1.
148 * Peer 0 is going to be origin. 232 * Peer 0 is going to be origin.
149 * Peer 1 is going to be one member. 233 * Peer 1 is going to be one member.
150 * Origin will start a multicast group and the member will try to join it. 234 * Origin will start a multicast group and the member will try to join it.
151 * After that we execute some multicast test. 235 * After that we execute some multicast test.
152 * 236 *
153 * @param cls closure 237 * @param cls closure
154 * @param h the run handle 238 * @param h the run handle
@@ -158,18 +242,18 @@ service_connect_peer0 (void *cls,
158 * @param links_failed number of links testbed was unable to establish 242 * @param links_failed number of links testbed was unable to establish
159 */ 243 */
160static void 244static void
161test_master (void *cls, 245run (void *cls,
162 struct GNUNET_TESTBED_RunHandle *h, 246 struct GNUNET_TESTBED_RunHandle *h,
163 unsigned int num_peers, 247 unsigned int num_peers,
164 struct GNUNET_TESTBED_Peer **peers, 248 struct GNUNET_TESTBED_Peer **peers,
165 unsigned int links_succeeded, 249 unsigned int links_succeeded,
166 unsigned int links_failed) 250 unsigned int links_failed)
167{ 251{
168 /* Testbed is ready with peers running and connected in a pre-defined overlay 252 /* Testbed is ready with peers running and connected in a pre-defined overlay
169 topology (FIXME) */ 253 topology (FIXME) */
170 254
171 /* connect to a peers service */ 255 /* connect to a peers service */
172 multicast_peer0 = GNUNET_TESTBED_service_connect 256 peer0 = GNUNET_TESTBED_service_connect
173 (NULL, /* Closure for operation */ 257 (NULL, /* Closure for operation */
174 peers[0], /* The peer whose service to connect to */ 258 peers[0], /* The peer whose service to connect to */
175 "multicast", /* The name of the service */ 259 "multicast", /* The name of the service */
@@ -200,8 +284,7 @@ main (int argc, char *argv[])
200 0LL, /* Event mask - set to 0 for no event notifications */ 284 0LL, /* Event mask - set to 0 for no event notifications */
201 NULL, /* Controller event callback */ 285 NULL, /* Controller event callback */
202 NULL, /* Closure for controller event callback */ 286 NULL, /* Closure for controller event callback */
203 &test_master, /* continuation callback to be called when testbed setup is 287 run, /* continuation callback to be called when testbed setup is complete */
204 complete */
205 NULL); /* Closure for the test_master callback */ 288 NULL); /* Closure for the test_master callback */
206 if ( (GNUNET_OK != ret) || (GNUNET_OK != result) ) 289 if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
207 return 1; 290 return 1;