diff options
author | xrs <xrs@mail36.net> | 2020-06-17 20:08:47 +0200 |
---|---|---|
committer | xrs <xrs@mail36.net> | 2020-06-17 20:08:47 +0200 |
commit | 97f951473b1581eca61c769c12b9d794df98bf6e (patch) | |
tree | 741ecb1d541232bffce515cba511f8aaae02c181 /src | |
parent | cdea4f7ba00100c83b41d4820588e375b1bb996c (diff) | |
download | gnunet-97f951473b1581eca61c769c12b9d794df98bf6e.tar.gz gnunet-97f951473b1581eca61c769c12b9d794df98bf6e.zip |
add logic for sending multiple messages and linklayer manipulation
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/test_cadeT.c | 48 | ||||
-rw-r--r-- | src/cadet/test_cadeT_util.c | 13 |
2 files changed, 38 insertions, 23 deletions
diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index 5e92084a6..97f315167 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c | |||
@@ -45,7 +45,6 @@ | |||
45 | * - GNUNET_TESTBED_underlay_configure_link not implemented | 45 | * - GNUNET_TESTBED_underlay_configure_link not implemented |
46 | * - GNUNET_TESTBED_underlaylinkmodel_set_link not usable | 46 | * - GNUNET_TESTBED_underlaylinkmodel_set_link not usable |
47 | * - GNUNET_TESTBED_peer_stop evokes standard service disconnect | 47 | * - GNUNET_TESTBED_peer_stop evokes standard service disconnect |
48 | * - GNUNET_TESTBED_peer_destroy and GNUNET_TESTBED_peer_create | ||
49 | * - how can we test the sublayers of CADET, e.g. connection, tunnel, channel? | 48 | * - how can we test the sublayers of CADET, e.g. connection, tunnel, channel? |
50 | * | 49 | * |
51 | * Development | 50 | * Development |
@@ -63,29 +62,50 @@ | |||
63 | /****************************** TEST LOGIC ********************************/ | 62 | /****************************** TEST LOGIC ********************************/ |
64 | 63 | ||
65 | static int kx_initiator; | 64 | static int kx_initiator; |
66 | 65 | static struct GNUNET_TESTBED_UnderlayLinkModel *model; | |
67 | void | ||
68 | handle_message (void *cls, | ||
69 | const struct GNUNET_MessageHeader *msg) | ||
70 | { | ||
71 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | ||
72 | } | ||
73 | 66 | ||
74 | static void | 67 | static void |
75 | send_message () | 68 | send_message () |
76 | { | 69 | { |
77 | struct GNUNET_MQ_Envelope *envelope; | 70 | struct GNUNET_MQ_Envelope *envelope; |
78 | struct GNUNET_MessageHeader *msg; | 71 | struct GNUNET_MessageHeader *msg; |
72 | int *data; | ||
79 | 73 | ||
80 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | 74 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); |
81 | 75 | ||
82 | envelope = GNUNET_MQ_msg (msg, | 76 | envelope = GNUNET_MQ_msg_extra (msg, 10000, |
83 | GNUNET_MESSAGE_TYPE_DUMMY); | 77 | GNUNET_MESSAGE_TYPE_DUMMY); |
78 | data = (int *) &msg[1]; | ||
79 | *data = 1000; | ||
84 | 80 | ||
85 | GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), | 81 | GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), |
86 | envelope); | 82 | envelope); |
87 | } | 83 | } |
88 | 84 | ||
85 | int | ||
86 | check_message (void *cls, | ||
87 | const struct GNUNET_MessageHeader *message) | ||
88 | { | ||
89 | return GNUNET_OK; /* all is well-formed */ | ||
90 | } | ||
91 | |||
92 | void | ||
93 | handle_message (void *cls, | ||
94 | const struct GNUNET_MessageHeader *msg) | ||
95 | { | ||
96 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | ||
97 | |||
98 | /* | ||
99 | model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer, | ||
100 | GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST); | ||
101 | GNUNET_TESTBED_underlaylinkmodel_set_link (model, | ||
102 | test_peers[0].testbed_peer, | ||
103 | 0, 100, 0); | ||
104 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: Modified link model.\n", __func__); | ||
105 | */ | ||
106 | send_message(); | ||
107 | } | ||
108 | |||
89 | /** | 109 | /** |
90 | * This function is called after all testbed management is done and the | 110 | * This function is called after all testbed management is done and the |
91 | * testbed peers are ready for the actual test logic. | 111 | * testbed peers are ready for the actual test logic. |
@@ -99,10 +119,12 @@ run_test () | |||
99 | kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0; | 119 | kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0; |
100 | 120 | ||
101 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 121 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
102 | "KX initiator is peer %s\n", | 122 | "KX initiator is peer %s (idx:%i)\n", |
103 | GNUNET_i2s (&test_peers[kx_initiator].id)); | 123 | GNUNET_i2s (&test_peers[kx_initiator].id), |
124 | kx_initiator); | ||
104 | 125 | ||
105 | send_message(); | 126 | for (int i=0; i<10; i++) |
127 | send_message(); | ||
106 | } | 128 | } |
107 | 129 | ||
108 | 130 | ||
diff --git a/src/cadet/test_cadeT_util.c b/src/cadet/test_cadeT_util.c index bc66adbdc..f2082a006 100644 --- a/src/cadet/test_cadeT_util.c +++ b/src/cadet/test_cadeT_util.c | |||
@@ -41,11 +41,6 @@ static struct GNUNET_TESTBED_Operation *testbed_info_req[REQUESTED_PEERS]; | |||
41 | static struct GNUNET_HashCode hashed_portname; | 41 | static struct GNUNET_HashCode hashed_portname; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Port handle. | ||
45 | */ | ||
46 | struct GNUNET_CADET_Port *port; | ||
47 | |||
48 | /** | ||
49 | * Result of the test. | 44 | * Result of the test. |
50 | */ | 45 | */ |
51 | int test_result = 0; | 46 | int test_result = 0; |
@@ -83,9 +78,6 @@ disconnect_from_peer (void *cls, | |||
83 | 78 | ||
84 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); | 79 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); |
85 | 80 | ||
86 | if (0 == strncmp ("listening_peer", cls, sizeof (cls))) | ||
87 | GNUNET_CADET_close_port (port); | ||
88 | |||
89 | GNUNET_CADET_disconnect (cadet); | 81 | GNUNET_CADET_disconnect (cadet); |
90 | } | 82 | } |
91 | 83 | ||
@@ -142,6 +134,7 @@ setup_listening_peer (void *cls, | |||
142 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 134 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
143 | { | 135 | { |
144 | struct GNUNET_CADET_Handle *cadet; | 136 | struct GNUNET_CADET_Handle *cadet; |
137 | struct GNUNET_CADET_Port *port; | ||
145 | struct GNUNET_MQ_MessageHandler msg_handlers[] = { | 138 | struct GNUNET_MQ_MessageHandler msg_handlers[] = { |
146 | GNUNET_MQ_hd_fixed_size (message, | 139 | GNUNET_MQ_hd_fixed_size (message, |
147 | GNUNET_MESSAGE_TYPE_DUMMY, | 140 | GNUNET_MESSAGE_TYPE_DUMMY, |
@@ -205,13 +198,13 @@ connect_to_service (void *cb_cls, | |||
205 | "cadet", | 198 | "cadet", |
206 | &check_test_readyness, NULL, | 199 | &check_test_readyness, NULL, |
207 | &setup_listening_peer, | 200 | &setup_listening_peer, |
208 | &disconnect_from_peer, "listening_peer"); | 201 | &disconnect_from_peer, NULL); |
209 | testbed_to_svc[0] = | 202 | testbed_to_svc[0] = |
210 | GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, | 203 | GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, |
211 | "cadet", | 204 | "cadet", |
212 | &check_test_readyness, NULL, | 205 | &check_test_readyness, NULL, |
213 | &setup_initiating_peer, | 206 | &setup_initiating_peer, |
214 | &disconnect_from_peer, "initiating_peer"); | 207 | &disconnect_from_peer, NULL); |
215 | } | 208 | } |
216 | } | 209 | } |
217 | 210 | ||