aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_disconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_disconnect.c')
-rw-r--r--src/transport/test_transport_api_disconnect.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 8522a3a88..47e52b67e 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20/** 20/**
21 * @file transport/test_transport_api_disconnect.c 21 * @file transport/test_transport_api_disconnect.c
22 * @brief base test case for transport implementations 22 * @brief base test case for transport implementations
@@ -32,7 +32,7 @@
32/** 32/**
33 * How long until we give up on transmitting the message? 33 * How long until we give up on transmitting the message?
34 */ 34 */
35#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 35#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 120)
36 36
37 37
38static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc; 38static struct GNUNET_TRANSPORT_TESTING_ConnectCheckContext *ccc;
@@ -41,69 +41,69 @@ static int shutdown_;
41 41
42 42
43static void 43static void
44notify_disconnect (void *cls, 44notify_disconnect(void *cls,
45 struct GNUNET_TRANSPORT_TESTING_PeerContext *me, 45 struct GNUNET_TRANSPORT_TESTING_PeerContext *me,
46 const struct GNUNET_PeerIdentity *other) 46 const struct GNUNET_PeerIdentity *other)
47{ 47{
48 if (me != ccc->p[0]) 48 if (me != ccc->p[0])
49 return; 49 return;
50 GNUNET_TRANSPORT_TESTING_log_disconnect (cls, 50 GNUNET_TRANSPORT_TESTING_log_disconnect(cls,
51 me, 51 me,
52 other); 52 other);
53 if (GNUNET_YES == shutdown_) 53 if (GNUNET_YES == shutdown_)
54 { 54 {
55 ccc->global_ret = GNUNET_OK; 55 ccc->global_ret = GNUNET_OK;
56 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 56 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
57 "Test good, shutting down...\n"); 57 "Test good, shutting down...\n");
58 GNUNET_SCHEDULER_shutdown (); 58 GNUNET_SCHEDULER_shutdown();
59 } 59 }
60} 60}
61 61
62 62
63static void 63static void
64stop_peer (void *cls) 64stop_peer(void *cls)
65{ 65{
66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 66 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
67 "Shutting down peer %u (`%s')\n", 67 "Shutting down peer %u (`%s')\n",
68 ccc->p[1]->no, 68 ccc->p[1]->no,
69 GNUNET_i2s (&ccc->p[1]->id)); 69 GNUNET_i2s(&ccc->p[1]->id));
70 shutdown_ = GNUNET_YES; 70 shutdown_ = GNUNET_YES;
71 GNUNET_TRANSPORT_TESTING_stop_peer (ccc->p[1]); 71 GNUNET_TRANSPORT_TESTING_stop_peer(ccc->p[1]);
72 ccc->p[1] = NULL; 72 ccc->p[1] = NULL;
73} 73}
74 74
75 75
76static void 76static void
77notify_receive (void *cls, 77notify_receive(void *cls,
78 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver, 78 struct GNUNET_TRANSPORT_TESTING_PeerContext *receiver,
79 const struct GNUNET_PeerIdentity *sender, 79 const struct GNUNET_PeerIdentity *sender,
80 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) 80 const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
81{ 81{
82 { 82 {
83 char *ps = GNUNET_strdup (GNUNET_i2s (&receiver->id)); 83 char *ps = GNUNET_strdup(GNUNET_i2s(&receiver->id));
84 84
85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 85 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
86 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n", 86 "Peer %u (`%s') received message of type %d and size %u size from peer %s!\n",
87 receiver->no, 87 receiver->no,
88 ps, 88 ps,
89 ntohs (message->header.type), 89 ntohs(message->header.type),
90 ntohs (message->header.size), 90 ntohs(message->header.size),
91 GNUNET_i2s (sender)); 91 GNUNET_i2s(sender));
92 GNUNET_free (ps); 92 GNUNET_free(ps);
93 }
94 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs (message->header.type)) &&
95 (sizeof (struct GNUNET_TRANSPORT_TESTING_TestMessage) == ntohs (message->header.size)))
96 {
97 GNUNET_SCHEDULER_add_now (&stop_peer,
98 NULL);
99 return;
100 } 93 }
94 if ((GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE == ntohs(message->header.type)) &&
95 (sizeof(struct GNUNET_TRANSPORT_TESTING_TestMessage) == ntohs(message->header.size)))
96 {
97 GNUNET_SCHEDULER_add_now(&stop_peer,
98 NULL);
99 return;
100 }
101} 101}
102 102
103 103
104int 104int
105main (int argc, 105main(int argc,
106 char *argv[]) 106 char *argv[])
107{ 107{
108 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = { 108 struct GNUNET_TRANSPORT_TESTING_SendClosure sc = {
109 .num_messages = 1 109 .num_messages = 1
@@ -118,13 +118,13 @@ main (int argc,
118 .timeout = TIMEOUT, 118 .timeout = TIMEOUT,
119 .global_ret = GNUNET_SYSERR 119 .global_ret = GNUNET_SYSERR
120 }; 120 };
121 121
122 ccc = &my_ccc; 122 ccc = &my_ccc;
123 sc.ccc = ccc; 123 sc.ccc = ccc;
124 if (GNUNET_OK != 124 if (GNUNET_OK !=
125 GNUNET_TRANSPORT_TESTING_main (2, 125 GNUNET_TRANSPORT_TESTING_main(2,
126 &GNUNET_TRANSPORT_TESTING_connect_check, 126 &GNUNET_TRANSPORT_TESTING_connect_check,
127 ccc)) 127 ccc))
128 return 1; 128 return 1;
129 return 0; 129 return 0;
130} 130}