diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:28:30 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-11-06 23:28:30 +0000 |
commit | 17bca33cca3c06668aa07c2750000a40a229c4a3 (patch) | |
tree | 70a1ad9c2506b4ca50b19fa0b387b46ab0b9b2e5 /src/transport | |
parent | bfe1f56580a066da971887c9beea44c890d26dd6 (diff) | |
download | gnunet-17bca33cca3c06668aa07c2750000a40a229c4a3.tar.gz gnunet-17bca33cca3c06668aa07c2750000a40a229c4a3.zip |
-removing last uses of TRANSPORT_try_connect API
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 5 | ||||
-rw-r--r-- | src/transport/test_transport_api_restart_1peer.c | 134 | ||||
-rw-r--r-- | src/transport/test_transport_api_restart_2peers.c | 337 | ||||
-rw-r--r-- | src/transport/test_transport_testing_restart.c | 9 | ||||
-rw-r--r-- | src/transport/transport-testing.c | 250 | ||||
-rw-r--r-- | src/transport/transport-testing.h | 13 |
6 files changed, 448 insertions, 300 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 7cd4596df..c4ce03bee 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -154,6 +154,7 @@ libgnunettransporttesting_la_SOURCES = \ | |||
154 | libgnunettransporttesting_la_LIBADD = \ | 154 | libgnunettransporttesting_la_LIBADD = \ |
155 | libgnunettransport.la \ | 155 | libgnunettransport.la \ |
156 | $(top_builddir)/src/hello/libgnunethello.la \ | 156 | $(top_builddir)/src/hello/libgnunethello.la \ |
157 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
157 | $(top_builddir)/src/util/libgnunetutil.la \ | 158 | $(top_builddir)/src/util/libgnunetutil.la \ |
158 | $(top_builddir)/src/testing/libgnunettesting.la \ | 159 | $(top_builddir)/src/testing/libgnunettesting.la \ |
159 | $(GN_LIBINTL) | 160 | $(GN_LIBINTL) |
@@ -791,6 +792,7 @@ test_transport_api_restart_1peer_SOURCES = \ | |||
791 | test_transport_api_restart_1peer_LDADD = \ | 792 | test_transport_api_restart_1peer_LDADD = \ |
792 | libgnunettransport.la \ | 793 | libgnunettransport.la \ |
793 | $(top_builddir)/src/hello/libgnunethello.la \ | 794 | $(top_builddir)/src/hello/libgnunethello.la \ |
795 | $(top_builddir)/src/ats/libgnunetats.la \ | ||
794 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 796 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
795 | $(top_builddir)/src/util/libgnunetutil.la \ | 797 | $(top_builddir)/src/util/libgnunetutil.la \ |
796 | libgnunettransporttesting.la | 798 | libgnunettransporttesting.la |
@@ -800,7 +802,8 @@ test_transport_api_restart_2peers_SOURCES = \ | |||
800 | test_transport_api_restart_2peers_LDADD = \ | 802 | test_transport_api_restart_2peers_LDADD = \ |
801 | libgnunettransport.la \ | 803 | libgnunettransport.la \ |
802 | $(top_builddir)/src/hello/libgnunethello.la \ | 804 | $(top_builddir)/src/hello/libgnunethello.la \ |
803 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 805 | $(top_builddir)/src/ats/libgnunetats.la \ |
806 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
804 | $(top_builddir)/src/util/libgnunetutil.la \ | 807 | $(top_builddir)/src/util/libgnunetutil.la \ |
805 | libgnunettransporttesting.la | 808 | libgnunettransporttesting.la |
806 | 809 | ||
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c index 0e91fa68f..2c4382e9c 100644 --- a/src/transport/test_transport_api_restart_1peer.c +++ b/src/transport/test_transport_api_restart_1peer.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2009, 2010, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -45,11 +45,11 @@ static char *test_name; | |||
45 | 45 | ||
46 | static int ok; | 46 | static int ok; |
47 | 47 | ||
48 | static struct GNUNET_SCHEDULER_Task * die_task; | 48 | static struct GNUNET_SCHEDULER_Task *die_task; |
49 | 49 | ||
50 | static struct GNUNET_SCHEDULER_Task * send_task; | 50 | static struct GNUNET_SCHEDULER_Task *send_task; |
51 | 51 | ||
52 | static struct GNUNET_SCHEDULER_Task * reconnect_task; | 52 | static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; |
53 | 53 | ||
54 | static struct PeerContext *p1; | 54 | static struct PeerContext *p1; |
55 | 55 | ||
@@ -59,7 +59,7 @@ static struct PeerContext *p2; | |||
59 | 59 | ||
60 | static int p2_connected; | 60 | static int p2_connected; |
61 | 61 | ||
62 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; | 62 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; |
63 | 63 | ||
64 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 64 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
65 | 65 | ||
@@ -75,105 +75,101 @@ static int restarted; | |||
75 | static void | 75 | static void |
76 | end () | 76 | end () |
77 | { | 77 | { |
78 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); | 78 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
79 | "Stopping peers\n"); | ||
79 | 80 | ||
80 | if (send_task != NULL) | 81 | if (NULL != send_task) |
82 | { | ||
81 | GNUNET_SCHEDULER_cancel (send_task); | 83 | GNUNET_SCHEDULER_cancel (send_task); |
82 | send_task = NULL; | 84 | send_task = NULL; |
83 | 85 | } | |
84 | if (reconnect_task != NULL) | 86 | if (NULL != ats_sh) |
85 | GNUNET_SCHEDULER_cancel (reconnect_task); | 87 | { |
86 | reconnect_task = NULL; | 88 | GNUNET_ATS_connectivity_suggest_cancel (ats_sh); |
87 | 89 | ats_sh = NULL; | |
88 | if (die_task != NULL) | 90 | } |
91 | if (NULL != die_task) | ||
92 | { | ||
89 | GNUNET_SCHEDULER_cancel (die_task); | 93 | GNUNET_SCHEDULER_cancel (die_task); |
90 | die_task = NULL; | 94 | die_task = NULL; |
91 | 95 | } | |
92 | if (th != NULL) | 96 | if (NULL != th) |
97 | { | ||
93 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 98 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
94 | th = NULL; | 99 | th = NULL; |
95 | 100 | } | |
96 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 101 | if (NULL != p1) |
97 | p1 = NULL; | 102 | { |
98 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 103 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); |
99 | p2 = NULL; | 104 | p1 = NULL; |
105 | } | ||
106 | if (NULL != p2) | ||
107 | { | ||
108 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
109 | p2 = NULL; | ||
110 | } | ||
100 | } | 111 | } |
101 | 112 | ||
113 | |||
102 | static void | 114 | static void |
103 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 115 | end_badly (void *cls, |
116 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
104 | { | 117 | { |
105 | die_task = NULL; | 118 | die_task = NULL; |
106 | 119 | ||
107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Fail! Stopping peers\n"); | 120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
121 | "Fail! Stopping peers\n"); | ||
108 | 122 | ||
109 | if (restarted == GNUNET_YES) | 123 | if (restarted == GNUNET_YES) |
110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer was restarted\n"); | 124 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
125 | "Peer was restarted\n"); | ||
111 | 126 | ||
112 | if (restarted == GNUNET_NO) | 127 | if (restarted == GNUNET_NO) |
113 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer was NOT restarted\n"); | 128 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
114 | 129 | "Peer was NOT restarted\n"); | |
115 | if (reconnect_task != NULL) | 130 | if (NULL != cc) |
116 | GNUNET_SCHEDULER_cancel (reconnect_task); | ||
117 | reconnect_task = NULL; | ||
118 | |||
119 | if (send_task != NULL) | ||
120 | GNUNET_SCHEDULER_cancel (send_task); | ||
121 | send_task = NULL; | ||
122 | |||
123 | if (cc != NULL) | ||
124 | { | 131 | { |
125 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | 132 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
133 | _("Fail! Could not connect peers\n")); | ||
126 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 134 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
127 | cc = NULL; | 135 | cc = NULL; |
128 | } | 136 | } |
129 | 137 | end (); | |
130 | if (th != NULL) | ||
131 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | ||
132 | th = NULL; | ||
133 | |||
134 | if (p1 != NULL) | ||
135 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | ||
136 | if (p2 != NULL) | ||
137 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
138 | |||
139 | ok = GNUNET_SYSERR; | 138 | ok = GNUNET_SYSERR; |
140 | } | 139 | } |
141 | 140 | ||
142 | static void | ||
143 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
144 | { | ||
145 | struct PeerContext *p = cls; | ||
146 | |||
147 | reconnect_task = NULL; | ||
148 | |||
149 | GNUNET_TRANSPORT_try_connect (p->th, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */ | ||
150 | reconnect_task = | ||
151 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p); | ||
152 | } | ||
153 | 141 | ||
154 | static void | 142 | static void |
155 | restart_cb (struct PeerContext *p, void *cls) | 143 | restart_cb (struct PeerContext *p, void *cls) |
156 | { | 144 | { |
157 | |||
158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
159 | "Restarted peer %u (`%4s'), issuing reconnect\n", p->no, | 146 | "Restarted peer %u (`%4s'), issuing reconnect\n", |
147 | p->no, | ||
160 | GNUNET_i2s (&p->id)); | 148 | GNUNET_i2s (&p->id)); |
161 | 149 | ats_sh = GNUNET_ATS_connectivity_suggest (p->ats, | |
162 | reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p); | 150 | &p2->id, |
151 | 1); | ||
163 | } | 152 | } |
164 | 153 | ||
154 | |||
165 | static void | 155 | static void |
166 | restart (struct PeerContext *p, char *cfg_file) | 156 | restart (struct PeerContext *p, |
157 | const char *cfg_file) | ||
167 | { | 158 | { |
168 | GNUNET_assert (p != NULL); | 159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Restarting peer %u (`%4s')\n", p->no, | 160 | "Restarting peer %u (`%4s')\n", |
161 | p->no, | ||
170 | GNUNET_i2s (&p->id)); | 162 | GNUNET_i2s (&p->id)); |
171 | GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p); | 163 | GNUNET_TRANSPORT_TESTING_restart_peer (p, |
172 | return; | 164 | cfg_file, |
165 | &restart_cb, | ||
166 | p); | ||
173 | } | 167 | } |
174 | 168 | ||
169 | |||
175 | static void | 170 | static void |
176 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 171 | notify_receive (void *cls, |
172 | const struct GNUNET_PeerIdentity *peer, | ||
177 | const struct GNUNET_MessageHeader *message) | 173 | const struct GNUNET_MessageHeader *message) |
178 | { | 174 | { |
179 | struct PeerContext *p = cls; | 175 | struct PeerContext *p = cls; |
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c index 5b47ee1d3..8d30ba15d 100644 --- a/src/transport/test_transport_api_restart_2peers.c +++ b/src/transport/test_transport_api_restart_2peers.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009, 2010 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2009, 2010, 2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -44,17 +44,17 @@ static char *test_name; | |||
44 | 44 | ||
45 | static int ok; | 45 | static int ok; |
46 | 46 | ||
47 | static struct GNUNET_SCHEDULER_Task * die_task; | 47 | static struct GNUNET_SCHEDULER_Task *die_task; |
48 | 48 | ||
49 | static struct GNUNET_SCHEDULER_Task * send_task; | 49 | static struct GNUNET_SCHEDULER_Task *send_task; |
50 | 50 | ||
51 | static struct GNUNET_SCHEDULER_Task * reconnect_task; | 51 | static struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; |
52 | 52 | ||
53 | static struct PeerContext *p1; | 53 | static struct PeerContext *p1; |
54 | 54 | ||
55 | static struct PeerContext *p2; | 55 | static struct PeerContext *p2; |
56 | 56 | ||
57 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; | 57 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; |
58 | 58 | ||
59 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 59 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
60 | 60 | ||
@@ -71,80 +71,67 @@ static void | |||
71 | end () | 71 | end () |
72 | { | 72 | { |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); | 73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peers\n"); |
74 | if (send_task != NULL) | 74 | if (NULL != send_task) |
75 | { | ||
75 | GNUNET_SCHEDULER_cancel (send_task); | 76 | GNUNET_SCHEDULER_cancel (send_task); |
76 | send_task = NULL; | 77 | send_task = NULL; |
77 | 78 | } | |
78 | if (reconnect_task != NULL) | 79 | if (NULL != ats_sh) |
79 | GNUNET_SCHEDULER_cancel (reconnect_task); | 80 | { |
80 | reconnect_task = NULL; | 81 | GNUNET_ATS_connectivity_suggest_cancel (ats_sh); |
81 | 82 | ats_sh = NULL; | |
82 | if (die_task != NULL) | 83 | } |
84 | if (NULL != die_task) | ||
85 | { | ||
83 | GNUNET_SCHEDULER_cancel (die_task); | 86 | GNUNET_SCHEDULER_cancel (die_task); |
84 | die_task = NULL; | 87 | die_task = NULL; |
85 | 88 | } | |
86 | if (th != NULL) | 89 | if (NULL != th) |
90 | { | ||
87 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 91 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
88 | th = NULL; | 92 | th = NULL; |
89 | 93 | } | |
90 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 94 | if (NULL != p1) |
91 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 95 | { |
96 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | ||
97 | p1 = NULL; | ||
98 | } | ||
99 | if (NULL != p2) | ||
100 | { | ||
101 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
102 | p2 = NULL; | ||
103 | } | ||
92 | } | 104 | } |
93 | 105 | ||
94 | 106 | ||
95 | static void | 107 | static void |
96 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 108 | end_badly (void *cls, |
109 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
97 | { | 110 | { |
98 | die_task = NULL; | 111 | die_task = NULL; |
99 | 112 | ||
100 | if (restarted == GNUNET_YES) | 113 | if (restarted == GNUNET_YES) |
101 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer was restarted, but communication did not resume\n"); | 114 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
115 | "Peer was restarted, but communication did not resume\n"); | ||
102 | 116 | ||
103 | if (restarted == GNUNET_NO) | 117 | if (restarted == GNUNET_NO) |
104 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer was NOT (even) restarted\n"); | 118 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
105 | 119 | "Peer was NOT (even) restarted\n"); | |
106 | if (reconnect_task != NULL) | ||
107 | GNUNET_SCHEDULER_cancel (reconnect_task); | ||
108 | reconnect_task = NULL; | ||
109 | |||
110 | if (send_task != NULL) | ||
111 | GNUNET_SCHEDULER_cancel (send_task); | ||
112 | send_task = NULL; | ||
113 | |||
114 | if (cc != NULL) | 120 | if (cc != NULL) |
115 | { | 121 | { |
116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | 122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
123 | _("Fail! Could not connect peers\n")); | ||
117 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 124 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); |
118 | cc = NULL; | 125 | cc = NULL; |
119 | } | 126 | } |
120 | 127 | end (); | |
121 | if (th != NULL) | ||
122 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | ||
123 | th = NULL; | ||
124 | |||
125 | if (p1 != NULL) | ||
126 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | ||
127 | if (p2 != NULL) | ||
128 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | ||
129 | |||
130 | ok = GNUNET_SYSERR; | 128 | ok = GNUNET_SYSERR; |
131 | } | 129 | } |
132 | 130 | ||
133 | 131 | ||
134 | static void | 132 | static void |
135 | reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 133 | restart_cb (struct PeerContext *p, |
136 | { | 134 | void *cls) |
137 | struct PeerContext *p = cls; | ||
138 | |||
139 | reconnect_task = NULL; | ||
140 | GNUNET_TRANSPORT_try_connect (p1->th, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */ | ||
141 | reconnect_task = | ||
142 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p); | ||
143 | } | ||
144 | |||
145 | |||
146 | static void | ||
147 | restart_cb (struct PeerContext *p, void *cls) | ||
148 | { | 135 | { |
149 | static int c; | 136 | static int c; |
150 | 137 | ||
@@ -152,26 +139,34 @@ restart_cb (struct PeerContext *p, void *cls) | |||
152 | if (c != 2) | 139 | if (c != 2) |
153 | return; | 140 | return; |
154 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 141 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
155 | "Restarted peer %u (`%4s'), issuing reconnect\n", p->no, | 142 | "Restarted peer %u (`%4s'), issuing reconnect\n", |
143 | p->no, | ||
156 | GNUNET_i2s (&p->id)); | 144 | GNUNET_i2s (&p->id)); |
157 | reconnect_task = GNUNET_SCHEDULER_add_now (&reconnect, p); | 145 | ats_sh = GNUNET_ATS_connectivity_suggest (p->ats, |
146 | &p2->id, | ||
147 | 1); | ||
158 | } | 148 | } |
159 | 149 | ||
160 | 150 | ||
161 | static void | 151 | static void |
162 | restart (struct PeerContext *p, char *cfg_file) | 152 | restart (struct PeerContext *p, |
153 | const char *cfg_file) | ||
163 | { | 154 | { |
164 | GNUNET_assert (p != NULL); | 155 | GNUNET_assert (NULL != p); |
165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
166 | "Restarting peer %u (`%4s')\n", | 157 | "Restarting peer %u (`%4s')\n", |
167 | p->no, | 158 | p->no, |
168 | GNUNET_i2s (&p->id)); | 159 | GNUNET_i2s (&p->id)); |
169 | GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, cfg_file, &restart_cb, p); | 160 | GNUNET_TRANSPORT_TESTING_restart_peer (p, |
161 | cfg_file, | ||
162 | &restart_cb, | ||
163 | p); | ||
170 | } | 164 | } |
171 | 165 | ||
172 | 166 | ||
173 | static void | 167 | static void |
174 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 168 | notify_receive (void *cls, |
169 | const struct GNUNET_PeerIdentity *peer, | ||
175 | const struct GNUNET_MessageHeader *message) | 170 | const struct GNUNET_MessageHeader *message) |
176 | { | 171 | { |
177 | struct PeerContext *p = cls; | 172 | struct PeerContext *p = cls; |
@@ -183,13 +178,19 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
183 | t = p2; | 178 | t = p2; |
184 | GNUNET_assert (t != NULL); | 179 | GNUNET_assert (t != NULL); |
185 | 180 | ||
186 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 181 | { |
187 | 182 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | |
188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 183 | |
189 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
190 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, | 185 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
191 | GNUNET_i2s (&t->id)); | 186 | p->no, |
192 | GNUNET_free (ps); | 187 | ps, |
188 | ntohs (message->type), | ||
189 | ntohs (message->size), | ||
190 | t->no, | ||
191 | GNUNET_i2s (&t->id)); | ||
192 | GNUNET_free (ps); | ||
193 | } | ||
193 | 194 | ||
194 | if ((MTYPE == ntohs (message->type)) && | 195 | if ((MTYPE == ntohs (message->type)) && |
195 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) | 196 | (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size))) |
@@ -221,13 +222,15 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
221 | 222 | ||
222 | 223 | ||
223 | static size_t | 224 | static size_t |
224 | notify_ready (void *cls, size_t size, void *buf) | 225 | notify_ready (void *cls, |
226 | size_t size, | ||
227 | void *buf) | ||
225 | { | 228 | { |
226 | struct PeerContext *p = cls; | 229 | struct PeerContext *p = cls; |
227 | struct GNUNET_MessageHeader *hdr; | 230 | struct GNUNET_MessageHeader *hdr; |
228 | 231 | ||
229 | th = NULL; | 232 | th = NULL; |
230 | if (buf == NULL) | 233 | if (NULL == buf) |
231 | { | 234 | { |
232 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
233 | "Timeout occurred while waiting for transmit_ready\n"); | 236 | "Timeout occurred while waiting for transmit_ready\n"); |
@@ -239,40 +242,54 @@ notify_ready (void *cls, size_t size, void *buf) | |||
239 | } | 242 | } |
240 | 243 | ||
241 | GNUNET_assert (size >= 256); | 244 | GNUNET_assert (size >= 256); |
245 | hdr = buf; | ||
246 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | ||
247 | hdr->type = htons (MTYPE); | ||
242 | 248 | ||
243 | if (buf != NULL) | ||
244 | { | 249 | { |
245 | hdr = buf; | 250 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
246 | hdr->size = htons (sizeof (struct GNUNET_MessageHeader)); | 251 | |
247 | hdr->type = htons (MTYPE); | 252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
253 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
254 | p2->no, | ||
255 | ps, | ||
256 | ntohs (hdr->type), | ||
257 | ntohs (hdr->size), | ||
258 | p->no, | ||
259 | GNUNET_i2s (&p->id)); | ||
260 | GNUNET_free (ps); | ||
248 | } | 261 | } |
249 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
250 | 262 | ||
251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
252 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
253 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
254 | GNUNET_i2s (&p->id)); | ||
255 | GNUNET_free (ps); | ||
256 | return sizeof (struct GNUNET_MessageHeader); | 263 | return sizeof (struct GNUNET_MessageHeader); |
257 | } | 264 | } |
258 | 265 | ||
259 | 266 | ||
260 | static void | 267 | static void |
261 | sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 268 | sendtask (void *cls, |
269 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
262 | { | 270 | { |
263 | send_task = NULL; | 271 | send_task = NULL; |
264 | 272 | ||
265 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 273 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
266 | return; | 274 | return; |
267 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
268 | 275 | ||
269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 276 | { |
270 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | 277 | char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
271 | p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s); | 278 | |
272 | GNUNET_free (receiver_s); | 279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
280 | "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n", | ||
281 | p2->no, | ||
282 | GNUNET_i2s (&p2->id), | ||
283 | p1->no, | ||
284 | receiver_s); | ||
285 | GNUNET_free (receiver_s); | ||
286 | } | ||
273 | 287 | ||
274 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256, | 288 | th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, |
275 | TIMEOUT_TRANSMIT, ¬ify_ready, | 289 | &p1->id, |
290 | 256, | ||
291 | TIMEOUT_TRANSMIT, | ||
292 | ¬ify_ready, | ||
276 | p1); | 293 | p1); |
277 | } | 294 | } |
278 | 295 | ||
@@ -281,64 +298,90 @@ static void | |||
281 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 298 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
282 | { | 299 | { |
283 | static int c; | 300 | static int c; |
284 | |||
285 | c++; | ||
286 | struct PeerContext *p = cls; | 301 | struct PeerContext *p = cls; |
287 | struct PeerContext *t = NULL; | 302 | struct PeerContext *t = NULL; |
288 | 303 | ||
289 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 304 | c++; |
305 | if (0 == memcmp (peer, | ||
306 | &p1->id, | ||
307 | sizeof (struct GNUNET_PeerIdentity))) | ||
290 | t = p1; | 308 | t = p1; |
291 | if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity))) | 309 | if (0 == memcmp (peer, |
310 | &p2->id, | ||
311 | sizeof (struct GNUNET_PeerIdentity))) | ||
292 | t = p2; | 312 | t = p2; |
293 | GNUNET_assert (t != NULL); | 313 | GNUNET_assert (t != NULL); |
294 | 314 | ||
295 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 315 | { |
296 | 316 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | |
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 317 | |
298 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps, | 318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
299 | t->no, GNUNET_i2s (peer)); | 319 | "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", |
300 | GNUNET_free (ps); | 320 | p->no, |
321 | ps, | ||
322 | t->no, | ||
323 | GNUNET_i2s (peer)); | ||
324 | GNUNET_free (ps); | ||
325 | } | ||
301 | 326 | ||
302 | if ((restarted == GNUNET_YES) && (c == 4)) | 327 | if ((restarted == GNUNET_YES) && (c == 4)) |
303 | { | 328 | { |
304 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 329 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, |
330 | NULL); | ||
305 | } | 331 | } |
306 | } | 332 | } |
307 | 333 | ||
308 | 334 | ||
309 | static void | 335 | static void |
310 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 336 | notify_disconnect (void *cls, |
337 | const struct GNUNET_PeerIdentity *peer) | ||
311 | { | 338 | { |
312 | struct PeerContext *p = cls; | 339 | struct PeerContext *p = cls; |
313 | 340 | ||
314 | 341 | { | |
315 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 342 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
316 | 343 | ||
317 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
318 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps, | 345 | "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", |
319 | GNUNET_i2s (peer)); | 346 | p->no, |
320 | GNUNET_free (ps); | 347 | ps, |
348 | GNUNET_i2s (peer)); | ||
349 | GNUNET_free (ps); | ||
350 | } | ||
321 | 351 | ||
322 | if (th != NULL) | 352 | if (th != NULL) |
353 | { | ||
323 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 354 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
324 | th = NULL; | 355 | th = NULL; |
325 | if (NULL != send_task) | 356 | } |
357 | if (NULL != send_task) | ||
358 | { | ||
326 | GNUNET_SCHEDULER_cancel (send_task); | 359 | GNUNET_SCHEDULER_cancel (send_task); |
327 | send_task = NULL; | 360 | send_task = NULL; |
361 | } | ||
328 | } | 362 | } |
329 | 363 | ||
330 | 364 | ||
331 | static void | 365 | static void |
332 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 366 | testing_connect_cb (struct PeerContext *p1, |
367 | struct PeerContext *p2, | ||
368 | void *cls) | ||
333 | { | 369 | { |
334 | cc = NULL; | 370 | cc = NULL; |
335 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | ||
336 | 371 | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u (%s)\n", | 372 | { |
338 | p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id)); | 373 | char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); |
339 | GNUNET_free (p1_c); | 374 | |
340 | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
341 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 376 | "Peers connected: %u (%s) <-> %u (%s)\n", |
377 | p1->no, | ||
378 | p1_c, | ||
379 | p2->no, | ||
380 | GNUNET_i2s (&p2->id)); | ||
381 | GNUNET_free (p1_c); | ||
382 | } | ||
383 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, | ||
384 | NULL); | ||
342 | } | 385 | } |
343 | 386 | ||
344 | 387 | ||
@@ -348,40 +391,58 @@ start_cb (struct PeerContext *p, void *cls) | |||
348 | static int started; | 391 | static int started; |
349 | 392 | ||
350 | started++; | 393 | started++; |
351 | 394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no, | 395 | "Peer %u (`%s') started\n", |
396 | p->no, | ||
353 | GNUNET_i2s (&p->id)); | 397 | GNUNET_i2s (&p->id)); |
354 | |||
355 | if (started != 2) | 398 | if (started != 2) |
356 | return; | 399 | return; |
357 | 400 | ||
358 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | 401 | { |
359 | 402 | char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id)); | |
360 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 403 | |
361 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
362 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | 405 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
363 | GNUNET_free (sender_c); | 406 | p1->no, |
407 | sender_c, | ||
408 | p2->no, | ||
409 | GNUNET_i2s (&p2->id)); | ||
410 | GNUNET_free (sender_c); | ||
411 | } | ||
364 | 412 | ||
365 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 413 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, |
414 | p1, | ||
415 | p2, | ||
416 | &testing_connect_cb, | ||
366 | NULL); | 417 | NULL); |
367 | |||
368 | } | 418 | } |
369 | 419 | ||
370 | 420 | ||
371 | static void | 421 | static void |
372 | run (void *cls, char *const *args, const char *cfgfile, | 422 | run (void *cls, |
423 | char *const *args, | ||
424 | const char *cfgfile, | ||
373 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 425 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
374 | { | 426 | { |
375 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 427 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
376 | 428 | &end_badly, | |
377 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 429 | NULL); |
378 | ¬ify_receive, ¬ify_connect, | 430 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
379 | ¬ify_disconnect, &start_cb, | 431 | cfg_file_p1, |
432 | 1, | ||
433 | ¬ify_receive, | ||
434 | ¬ify_connect, | ||
435 | ¬ify_disconnect, | ||
436 | &start_cb, | ||
380 | NULL); | 437 | NULL); |
381 | 438 | ||
382 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 439 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
383 | ¬ify_receive, ¬ify_connect, | 440 | cfg_file_p2, |
384 | ¬ify_disconnect, &start_cb, | 441 | 2, |
442 | ¬ify_receive, | ||
443 | ¬ify_connect, | ||
444 | ¬ify_disconnect, | ||
445 | &start_cb, | ||
385 | NULL); | 446 | NULL); |
386 | 447 | ||
387 | if ((p1 == NULL) || (p2 == NULL)) | 448 | if ((p1 == NULL) || (p2 == NULL)) |
diff --git a/src/transport/test_transport_testing_restart.c b/src/transport/test_transport_testing_restart.c index d2d0d4c9e..188cc20b5 100644 --- a/src/transport/test_transport_testing_restart.c +++ b/src/transport/test_transport_testing_restart.c | |||
@@ -82,12 +82,17 @@ restart_cb (struct PeerContext *p, void *cls) | |||
82 | static void | 82 | static void |
83 | restart_task () | 83 | restart_task () |
84 | { | 84 | { |
85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') restarting, \n", | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
86 | "Peer %u (`%s') restarting, \n", | ||
86 | p->no, | 87 | p->no, |
87 | GNUNET_i2s (&p->id)); | 88 | GNUNET_i2s (&p->id)); |
88 | GNUNET_TRANSPORT_TESTING_restart_peer (tth, p, NULL, restart_cb, p); | 89 | GNUNET_TRANSPORT_TESTING_restart_peer (p, |
90 | NULL, | ||
91 | &restart_cb, | ||
92 | p); | ||
89 | } | 93 | } |
90 | 94 | ||
95 | |||
91 | static void | 96 | static void |
92 | start_cb (struct PeerContext *p, void *cls) | 97 | start_cb (struct PeerContext *p, void *cls) |
93 | { | 98 | { |
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 86c67a039..a55727539 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c | |||
@@ -34,7 +34,6 @@ static struct PeerContext * | |||
34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 34 | find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
35 | const struct GNUNET_PeerIdentity *peer) | 35 | const struct GNUNET_PeerIdentity *peer) |
36 | { | 36 | { |
37 | GNUNET_assert (tth != NULL); | ||
38 | struct PeerContext *t = tth->p_head; | 37 | struct PeerContext *t = tth->p_head; |
39 | 38 | ||
40 | while (t != NULL) | 39 | while (t != NULL) |
@@ -183,7 +182,8 @@ get_hello (void *cb_cls, | |||
183 | if (NULL != p->start_cb) | 182 | if (NULL != p->start_cb) |
184 | { | 183 | { |
185 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 184 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
186 | "Peer %u (`%s') successfully started\n", p->no, | 185 | "Peer %u (`%s') successfully started\n", |
186 | p->no, | ||
187 | GNUNET_i2s (&p->id)); | 187 | GNUNET_i2s (&p->id)); |
188 | p->start_cb (p, p->cb_cls); | 188 | p->start_cb (p, p->cb_cls); |
189 | p->start_cb = NULL; | 189 | p->start_cb = NULL; |
@@ -191,8 +191,43 @@ get_hello (void *cb_cls, | |||
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | /** | ||
195 | * Offer the current HELLO of P2 to P1. | ||
196 | * | ||
197 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest ` | ||
198 | * @param tc scheduler context | ||
199 | */ | ||
200 | static void | ||
201 | offer_hello (void *cls, | ||
202 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
203 | |||
204 | |||
205 | /** | ||
206 | * Function called after the HELLO was passed to the | ||
207 | * transport service. | ||
208 | */ | ||
209 | static void | ||
210 | hello_offered (void *cls, | ||
211 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
212 | { | ||
213 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | ||
214 | |||
215 | cc->oh = NULL; | ||
216 | cc->tct = | ||
217 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
218 | &offer_hello, | ||
219 | cc); | ||
220 | } | ||
221 | |||
222 | |||
223 | /** | ||
224 | * Offer the current HELLO of P2 to P1. | ||
225 | * | ||
226 | * @param cls our `struct GNUNET_TRANSPORT_TESTING_ConnectRequest ` | ||
227 | * @param tc scheduler context | ||
228 | */ | ||
194 | static void | 229 | static void |
195 | try_connect (void *cls, | 230 | offer_hello (void *cls, |
196 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 231 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
197 | { | 232 | { |
198 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; | 233 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = cls; |
@@ -202,26 +237,26 @@ try_connect (void *cls, | |||
202 | cc->tct = NULL; | 237 | cc->tct = NULL; |
203 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) | 238 | if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) |
204 | return; | 239 | return; |
240 | { | ||
241 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
205 | 242 | ||
206 | GNUNET_assert (cc != NULL); | 243 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
207 | GNUNET_assert (cc->p1 != NULL); | 244 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", |
208 | GNUNET_assert (cc->p2 != NULL); | 245 | p1->no, |
209 | 246 | GNUNET_i2s (&p1->id), | |
210 | char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); | 247 | p2->no, |
211 | 248 | p2_s, | |
212 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 249 | GNUNET_HELLO_size (cc->p2->hello)); |
213 | "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", | 250 | GNUNET_free (p2_s); |
214 | p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, | 251 | } |
215 | GNUNET_HELLO_size (cc->p2->hello)); | ||
216 | GNUNET_free (p2_s); | ||
217 | |||
218 | GNUNET_TRANSPORT_offer_hello (cc->th_p1, | ||
219 | (const struct GNUNET_MessageHeader *) cc-> | ||
220 | p2->hello, NULL, NULL); | ||
221 | GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */ | ||
222 | 252 | ||
223 | cc->tct = | 253 | if (NULL != cc->oh) |
224 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc); | 254 | GNUNET_TRANSPORT_offer_hello_cancel (cc->oh); |
255 | cc->oh = | ||
256 | GNUNET_TRANSPORT_offer_hello (cc->p1->th, | ||
257 | (const struct GNUNET_MessageHeader *) cc->p2->hello, | ||
258 | &hello_offered, | ||
259 | cc); | ||
225 | } | 260 | } |
226 | 261 | ||
227 | 262 | ||
@@ -239,7 +274,8 @@ try_connect (void *cls, | |||
239 | */ | 274 | */ |
240 | struct PeerContext * | 275 | struct PeerContext * |
241 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 276 | GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
242 | const char *cfgname, int peer_id, | 277 | const char *cfgname, |
278 | int peer_id, | ||
243 | GNUNET_TRANSPORT_ReceiveCallback rec, | 279 | GNUNET_TRANSPORT_ReceiveCallback rec, |
244 | GNUNET_TRANSPORT_NotifyConnect nc, | 280 | GNUNET_TRANSPORT_NotifyConnect nc, |
245 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 281 | GNUNET_TRANSPORT_NotifyDisconnect nd, |
@@ -278,7 +314,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
278 | 314 | ||
279 | p->no = peer_id; | 315 | p->no = peer_id; |
280 | /* Configure peer with configuration */ | 316 | /* Configure peer with configuration */ |
281 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); | 317 | p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, |
318 | p->cfg, p->no, NULL, &emsg); | ||
282 | if (NULL == p->peer) | 319 | if (NULL == p->peer) |
283 | { | 320 | { |
284 | LOG (GNUNET_ERROR_TYPE_ERROR, | 321 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -329,41 +366,51 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth | |||
329 | 366 | ||
330 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, | 367 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, |
331 | ¬ify_receive, | 368 | ¬ify_receive, |
332 | ¬ify_connect, ¬ify_disconnect); | 369 | ¬ify_connect, |
370 | ¬ify_disconnect); | ||
333 | if (NULL == p->th) | 371 | if (NULL == p->th) |
334 | { | 372 | { |
335 | LOG (GNUNET_ERROR_TYPE_ERROR, | 373 | LOG (GNUNET_ERROR_TYPE_ERROR, |
336 | "Failed to connect to transport service for peer `%s': `%s'\n", | 374 | "Failed to connect to transport service for peer `%s': `%s'\n", |
337 | cfgname, | 375 | cfgname, |
338 | emsg); | 376 | emsg); |
339 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | 377 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); |
340 | return NULL; | 378 | return NULL; |
341 | } | 379 | } |
342 | 380 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | |
343 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | 381 | if (NULL == p->ats) |
382 | { | ||
383 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
384 | "Failed to connect to ATS service for peer `%s': `%s'\n", | ||
385 | cfgname, | ||
386 | emsg); | ||
387 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); | ||
388 | return NULL; | ||
389 | } | ||
390 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, | ||
391 | &get_hello, | ||
392 | p); | ||
344 | GNUNET_assert (p->ghh != NULL); | 393 | GNUNET_assert (p->ghh != NULL); |
345 | 394 | ||
346 | return p; | 395 | return p; |
347 | } | 396 | } |
348 | 397 | ||
398 | |||
349 | /** | 399 | /** |
350 | * Restart the given peer | 400 | * Restart the given peer |
351 | * @param tth testing handle | 401 | * |
352 | * @param p the peer | 402 | * @param p the peer |
353 | * @param cfgname the cfg file used to restart | 403 | * @param cfgname the cfg file used to restart |
354 | * @param restart_cb callback to call when restarted | 404 | * @param restart_cb callback to call when restarted |
355 | * @param cb_cls callback closure | 405 | * @param cb_cls callback closure |
356 | * @return GNUNET_OK in success otherwise GNUNET_SYSERR | 406 | * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR |
357 | */ | 407 | */ |
358 | int | 408 | int |
359 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | 409 | GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p, |
360 | *tth, struct PeerContext *p, | ||
361 | const char *cfgname, | 410 | const char *cfgname, |
362 | GNUNET_TRANSPORT_TESTING_start_cb | 411 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, |
363 | restart_cb, void *cb_cls) | 412 | void *cb_cls) |
364 | { | 413 | { |
365 | GNUNET_assert (tth != NULL); | ||
366 | GNUNET_assert (p != NULL); | ||
367 | GNUNET_assert (NULL != p->peer); | 414 | GNUNET_assert (NULL != p->peer); |
368 | 415 | ||
369 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 416 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -377,13 +424,22 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
377 | p->no, | 424 | p->no, |
378 | GNUNET_i2s (&p->id)); | 425 | GNUNET_i2s (&p->id)); |
379 | if (NULL != p->ghh) | 426 | if (NULL != p->ghh) |
427 | { | ||
380 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 428 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
381 | p->ghh = NULL; | 429 | p->ghh = NULL; |
382 | 430 | } | |
383 | if (NULL != p->th) | 431 | if (NULL != p->th) |
432 | { | ||
384 | GNUNET_TRANSPORT_disconnect (p->th); | 433 | GNUNET_TRANSPORT_disconnect (p->th); |
434 | p->th = NULL; | ||
435 | } | ||
436 | if (NULL != p->ats) | ||
437 | { | ||
438 | GNUNET_ATS_connectivity_done (p->ats); | ||
439 | p->ats = NULL; | ||
440 | } | ||
385 | 441 | ||
386 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer)) | 442 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop (p->peer)) |
387 | { | 443 | { |
388 | LOG (GNUNET_ERROR_TYPE_ERROR, | 444 | LOG (GNUNET_ERROR_TYPE_ERROR, |
389 | "Failed to stop peer %u (`%s')\n", | 445 | "Failed to stop peer %u (`%s')\n", |
@@ -395,33 +451,38 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle | |||
395 | sleep (5); // YUCK! | 451 | sleep (5); // YUCK! |
396 | 452 | ||
397 | /* restart */ | 453 | /* restart */ |
398 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer)) | 454 | if (GNUNET_SYSERR == GNUNET_TESTING_peer_start (p->peer)) |
399 | { | 455 | { |
400 | LOG (GNUNET_ERROR_TYPE_ERROR, | 456 | LOG (GNUNET_ERROR_TYPE_ERROR, |
401 | "Failed to restart peer %u (`%s')\n", | 457 | "Failed to restart peer %u (`%s')\n", |
402 | p->no, GNUNET_i2s (&p->id)); | 458 | p->no, |
459 | GNUNET_i2s (&p->id)); | ||
403 | return GNUNET_SYSERR; | 460 | return GNUNET_SYSERR; |
404 | } | 461 | } |
405 | 462 | ||
406 | GNUNET_assert (p->th != NULL); | 463 | GNUNET_assert (NULL == p->start_cb); |
407 | GNUNET_assert (p->start_cb == NULL); | ||
408 | p->start_cb = restart_cb; | 464 | p->start_cb = restart_cb; |
409 | p->cb_cls = cb_cls; | 465 | p->cb_cls = cb_cls; |
410 | 466 | ||
411 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, | 467 | p->th = GNUNET_TRANSPORT_connect (p->cfg, |
468 | NULL, | ||
469 | p, | ||
412 | ¬ify_receive, | 470 | ¬ify_receive, |
413 | ¬ify_connect, | 471 | ¬ify_connect, |
414 | ¬ify_disconnect); | 472 | ¬ify_disconnect); |
415 | GNUNET_assert (NULL != p->th); | 473 | GNUNET_assert (NULL != p->th); |
416 | 474 | p->ats = GNUNET_ATS_connectivity_init (p->cfg); | |
417 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); | 475 | p->ghh = GNUNET_TRANSPORT_get_hello (p->th, |
418 | GNUNET_assert (p->ghh != NULL); | 476 | &get_hello, |
477 | p); | ||
478 | GNUNET_assert (NULL != p->ghh); | ||
419 | return GNUNET_OK; | 479 | return GNUNET_OK; |
420 | } | 480 | } |
421 | 481 | ||
422 | 482 | ||
423 | /** | 483 | /** |
424 | * shutdown the given peer | 484 | * Shutdown the given peer |
485 | * | ||
425 | * @param tth testing handle | 486 | * @param tth testing handle |
426 | * @param p the peer | 487 | * @param p the peer |
427 | */ | 488 | */ |
@@ -429,19 +490,17 @@ void | |||
429 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 490 | GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
430 | struct PeerContext *p) | 491 | struct PeerContext *p) |
431 | { | 492 | { |
432 | GNUNET_assert (p != NULL); | 493 | if (NULL != p->ghh) |
433 | if (p->ghh != NULL) | ||
434 | { | 494 | { |
435 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); | 495 | GNUNET_TRANSPORT_get_hello_cancel (p->ghh); |
436 | p->ghh = NULL; | 496 | p->ghh = NULL; |
437 | } | 497 | } |
438 | if (p->th != NULL) | 498 | if (NULL != p->th) |
439 | { | 499 | { |
440 | GNUNET_TRANSPORT_disconnect (p->th); | 500 | GNUNET_TRANSPORT_disconnect (p->th); |
441 | p->th = NULL; | 501 | p->th = NULL; |
442 | } | 502 | } |
443 | 503 | if (NULL != p->peer) | |
444 | if (p->peer != NULL) | ||
445 | { | 504 | { |
446 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) | 505 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) |
447 | { | 506 | { |
@@ -452,20 +511,27 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
452 | GNUNET_TESTING_peer_destroy (p->peer); | 511 | GNUNET_TESTING_peer_destroy (p->peer); |
453 | p->peer = NULL; | 512 | p->peer = NULL; |
454 | } | 513 | } |
455 | 514 | if (NULL != p->ats) | |
456 | if (p->hello != NULL) | 515 | { |
516 | GNUNET_ATS_connectivity_done (p->ats); | ||
517 | p->ats = NULL; | ||
518 | } | ||
519 | if (NULL != p->hello) | ||
457 | { | 520 | { |
458 | GNUNET_free (p->hello); | 521 | GNUNET_free (p->hello); |
459 | p->hello = NULL; | 522 | p->hello = NULL; |
460 | } | 523 | } |
461 | if (p->cfg != NULL) | 524 | if (NULL != p->cfg) |
462 | { | 525 | { |
463 | GNUNET_CONFIGURATION_destroy (p->cfg); | 526 | GNUNET_CONFIGURATION_destroy (p->cfg); |
464 | p->cfg = NULL; | 527 | p->cfg = NULL; |
465 | } | 528 | } |
466 | GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); | 529 | GNUNET_CONTAINER_DLL_remove (tth->p_head, |
530 | tth->p_tail, | ||
531 | p); | ||
467 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 532 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
468 | "Peer %u (`%s') stopped \n", p->no, | 533 | "Peer %u (`%s') stopped \n", |
534 | p->no, | ||
469 | GNUNET_i2s (&p->id)); | 535 | GNUNET_i2s (&p->id)); |
470 | GNUNET_free (p); | 536 | GNUNET_free (p); |
471 | } | 537 | } |
@@ -490,26 +556,25 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * | |||
490 | GNUNET_TRANSPORT_TESTING_connect_cb cb, | 556 | GNUNET_TRANSPORT_TESTING_connect_cb cb, |
491 | void *cls) | 557 | void *cls) |
492 | { | 558 | { |
493 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); | 559 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc; |
494 | 560 | ||
495 | GNUNET_assert (tth != NULL); | 561 | cc = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_ConnectRequest); |
496 | GNUNET_assert (p1 != NULL); | ||
497 | GNUNET_assert (p2 != NULL); | ||
498 | cc->p1 = p1; | 562 | cc->p1 = p1; |
499 | cc->p2 = p2; | 563 | cc->p2 = p2; |
500 | cc->cb = cb; | 564 | cc->cb = cb; |
501 | if (cls != NULL) | 565 | if (NULL != cls) |
502 | cc->cb_cls = cls; | 566 | cc->cb_cls = cls; |
503 | else | 567 | else |
504 | cc->cb_cls = cc; | 568 | cc->cb_cls = cc; |
505 | cc->th_p1 = p1->th; | ||
506 | cc->th_p2 = p2->th; | ||
507 | GNUNET_assert (cc->th_p1 != NULL); | ||
508 | GNUNET_assert (cc->th_p2 != NULL); | ||
509 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, | 569 | GNUNET_CONTAINER_DLL_insert (tth->cc_head, |
510 | tth->cc_tail, | 570 | tth->cc_tail, |
511 | cc); | 571 | cc); |
512 | cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); | 572 | cc->tct = GNUNET_SCHEDULER_add_now (&offer_hello, |
573 | cc); | ||
574 | cc->ats_sh = GNUNET_ATS_connectivity_suggest (cc->p1->ats, | ||
575 | &p2->id, | ||
576 | 1); | ||
577 | |||
513 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 578 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
514 | "New connect request %p\n", | 579 | "New connect request %p\n", |
515 | cc); | 580 | cc); |
@@ -529,17 +594,28 @@ void | |||
529 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 594 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct GNUNET_TRANSPORT_TESTING_handle *tth, |
530 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc) | 595 | struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc) |
531 | { | 596 | { |
532 | GNUNET_assert (tth != NULL); | ||
533 | |||
534 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 597 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
535 | "Canceling connect request %p!\n", | 598 | "Canceling connect request %p!\n", |
536 | cc); | 599 | cc); |
537 | 600 | if (NULL != cc->tct) | |
538 | if (cc->tct != NULL) | 601 | { |
539 | GNUNET_SCHEDULER_cancel (cc->tct); | 602 | GNUNET_SCHEDULER_cancel (cc->tct); |
540 | cc->tct = NULL; | 603 | cc->tct = NULL; |
604 | } | ||
605 | if (NULL != cc->oh) | ||
606 | { | ||
607 | GNUNET_TRANSPORT_offer_hello_cancel (cc->oh); | ||
608 | cc->oh = NULL; | ||
609 | } | ||
610 | if (NULL != cc->ats_sh) | ||
611 | { | ||
612 | GNUNET_ATS_connectivity_suggest_cancel (cc->ats_sh); | ||
613 | cc->ats_sh = NULL; | ||
614 | } | ||
541 | 615 | ||
542 | GNUNET_CONTAINER_DLL_remove (tth->cc_head, tth->cc_tail, cc); | 616 | GNUNET_CONTAINER_DLL_remove (tth->cc_head, |
617 | tth->cc_tail, | ||
618 | cc); | ||
543 | GNUNET_free (cc); | 619 | GNUNET_free (cc); |
544 | } | 620 | } |
545 | 621 | ||
@@ -556,19 +632,18 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
556 | struct PeerContext *p = tth->p_head; | 632 | struct PeerContext *p = tth->p_head; |
557 | struct PeerContext *t = NULL; | 633 | struct PeerContext *t = NULL; |
558 | 634 | ||
559 | GNUNET_assert (tth != NULL); | ||
560 | |||
561 | while (cc != tth->cc_tail) | 635 | while (cc != tth->cc_tail) |
562 | { | 636 | { |
563 | ct = cc->next; | 637 | ct = cc->next; |
564 | LOG (GNUNET_ERROR_TYPE_ERROR, | 638 | LOG (GNUNET_ERROR_TYPE_ERROR, |
565 | "Developer forgot to cancel connect request %p!\n", | 639 | "Developer forgot to cancel connect request %p!\n", |
566 | cc); | 640 | cc); |
567 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 641 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, |
642 | cc); | ||
568 | cc = ct; | 643 | cc = ct; |
569 | } | 644 | } |
570 | 645 | ||
571 | while (p != NULL) | 646 | while (NULL != p) |
572 | { | 647 | { |
573 | t = p->next; | 648 | t = p->next; |
574 | LOG (GNUNET_ERROR_TYPE_ERROR, | 649 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -577,7 +652,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) | |||
577 | p = t; | 652 | p = t; |
578 | } | 653 | } |
579 | 654 | ||
580 | GNUNET_TESTING_system_destroy (tth->tl_system, GNUNET_YES); | 655 | GNUNET_TESTING_system_destroy (tth->tl_system, |
656 | GNUNET_YES); | ||
581 | 657 | ||
582 | GNUNET_free (tth); | 658 | GNUNET_free (tth); |
583 | tth = NULL; | 659 | tth = NULL; |
@@ -619,6 +695,7 @@ GNUNET_TRANSPORT_TESTING_init () | |||
619 | 695 | ||
620 | /** | 696 | /** |
621 | * Removes all directory separators from absolute filename | 697 | * Removes all directory separators from absolute filename |
698 | * | ||
622 | * @param file the absolute file name, e.g. as found in argv[0] | 699 | * @param file the absolute file name, e.g. as found in argv[0] |
623 | * @return extracted file name, has to be freed by caller | 700 | * @return extracted file name, has to be freed by caller |
624 | */ | 701 | */ |
@@ -670,7 +747,9 @@ extract_filename (const char *file) | |||
670 | 747 | ||
671 | 748 | ||
672 | /** | 749 | /** |
673 | * Extracts the test filename from an absolute file name and removes the extension | 750 | * Extracts the test filename from an absolute file name and removes |
751 | * the extension | ||
752 | * | ||
674 | * @param file absolute file name | 753 | * @param file absolute file name |
675 | * @param dest where to store result | 754 | * @param dest where to store result |
676 | */ | 755 | */ |
@@ -709,6 +788,7 @@ suc: | |||
709 | 788 | ||
710 | /** | 789 | /** |
711 | * Extracts the filename from an absolute file name and removes the extension | 790 | * Extracts the filename from an absolute file name and removes the extension |
791 | * | ||
712 | * @param file absolute file name | 792 | * @param file absolute file name |
713 | * @param dest where to store result | 793 | * @param dest where to store result |
714 | */ | 794 | */ |
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h index dcac29185..69da1f99d 100644 --- a/src/transport/transport-testing.h +++ b/src/transport/transport-testing.h | |||
@@ -93,6 +93,11 @@ struct PeerContext | |||
93 | struct GNUNET_TRANSPORT_Handle *th; | 93 | struct GNUNET_TRANSPORT_Handle *th; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Peer's ATS handle. | ||
97 | */ | ||
98 | struct GNUNET_ATS_ConnectivityHandle *ats; | ||
99 | |||
100 | /** | ||
96 | * Peer's transport get hello handle to retrieve peer's HELLO message | 101 | * Peer's transport get hello handle to retrieve peer's HELLO message |
97 | */ | 102 | */ |
98 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 103 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; |
@@ -156,10 +161,10 @@ struct GNUNET_TRANSPORT_TESTING_ConnectRequest | |||
156 | struct PeerContext *p1; | 161 | struct PeerContext *p1; |
157 | struct PeerContext *p2; | 162 | struct PeerContext *p2; |
158 | struct GNUNET_SCHEDULER_Task *tct; | 163 | struct GNUNET_SCHEDULER_Task *tct; |
164 | struct GNUNET_ATS_ConnectivitySuggestHandle *ats_sh; | ||
165 | struct GNUNET_TRANSPORT_OfferHelloHandle *oh; | ||
159 | GNUNET_TRANSPORT_TESTING_connect_cb cb; | 166 | GNUNET_TRANSPORT_TESTING_connect_cb cb; |
160 | void *cb_cls; | 167 | void *cb_cls; |
161 | struct GNUNET_TRANSPORT_Handle *th_p1; | ||
162 | struct GNUNET_TRANSPORT_Handle *th_p2; | ||
163 | int p1_c; | 168 | int p1_c; |
164 | int p2_c; | 169 | int p2_c; |
165 | }; | 170 | }; |
@@ -231,7 +236,6 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
231 | /** | 236 | /** |
232 | * Restart the given peer | 237 | * Restart the given peer |
233 | * | 238 | * |
234 | * @param tth testing handle | ||
235 | * @param p the peer | 239 | * @param p the peer |
236 | * @param cfgname the cfg file used to restart | 240 | * @param cfgname the cfg file used to restart |
237 | * @param restart_cb restart callback | 241 | * @param restart_cb restart callback |
@@ -239,8 +243,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | |||
239 | * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR | 243 | * @return #GNUNET_OK in success otherwise #GNUNET_SYSERR |
240 | */ | 244 | */ |
241 | int | 245 | int |
242 | GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth, | 246 | GNUNET_TRANSPORT_TESTING_restart_peer (struct PeerContext *p, |
243 | struct PeerContext *p, | ||
244 | const char *cfgname, | 247 | const char *cfgname, |
245 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, | 248 | GNUNET_TRANSPORT_TESTING_start_cb restart_cb, |
246 | void *cb_cls); | 249 | void *cb_cls); |