aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-09 13:33:40 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-09 13:33:40 +0000
commita61fe2107d79336c3da80591c24256b6dbd3d159 (patch)
tree5e28e476165f456ff7b18214ff744402297ad37c /src/transport
parent755b5bb632de94de0e6b0e55212fbcce7b6c719c (diff)
downloadgnunet-a61fe2107d79336c3da80591c24256b6dbd3d159.tar.gz
gnunet-a61fe2107d79336c3da80591c24256b6dbd3d159.zip
changes to transport api
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-transport.c4
-rw-r--r--src/transport/test_transport_api_restart_1peer.c2
-rw-r--r--src/transport/test_transport_api_restart_2peers.c2
-rw-r--r--src/transport/transport-testing.c2
-rw-r--r--src/transport/transport_api.c238
5 files changed, 183 insertions, 65 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 0297b4624..b3a971b96 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -752,7 +752,7 @@ testservice_task (void *cls,
752 ret = 1; 752 ret = 1;
753 return; 753 return;
754 } 754 }
755 GNUNET_TRANSPORT_try_connect (handle, &pid); 755 GNUNET_TRANSPORT_try_connect (handle, &pid, NULL, NULL); /*FIXME TRY_CONNECT change */
756 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, 756 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
757 &operation_timeout, NULL); 757 &operation_timeout, NULL);
758 758
@@ -776,7 +776,7 @@ testservice_task (void *cls,
776 ret = 1; 776 ret = 1;
777 return; 777 return;
778 } 778 }
779 GNUNET_TRANSPORT_try_connect (handle, &pid); 779 GNUNET_TRANSPORT_try_connect (handle, &pid, NULL, NULL); /*FIXME TRY_CONNECT change */
780 start_time = GNUNET_TIME_absolute_get (); 780 start_time = GNUNET_TIME_absolute_get ();
781 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT, 781 op_timeout = GNUNET_SCHEDULER_add_delayed (OP_TIMEOUT,
782 &operation_timeout, NULL); 782 &operation_timeout, NULL);
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c
index 5f8f97b75..9927946de 100644
--- a/src/transport/test_transport_api_restart_1peer.c
+++ b/src/transport/test_transport_api_restart_1peer.c
@@ -146,7 +146,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
146 146
147 reconnect_task = GNUNET_SCHEDULER_NO_TASK; 147 reconnect_task = GNUNET_SCHEDULER_NO_TASK;
148 148
149 GNUNET_TRANSPORT_try_connect (p->th, &p2->id); 149 GNUNET_TRANSPORT_try_connect (p->th, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */
150 reconnect_task = 150 reconnect_task =
151 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p); 151 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
152} 152}
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c
index bdf14744f..6e55f5734 100644
--- a/src/transport/test_transport_api_restart_2peers.c
+++ b/src/transport/test_transport_api_restart_2peers.c
@@ -138,7 +138,7 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
138 struct PeerContext *p = cls; 138 struct PeerContext *p = cls;
139 139
140 reconnect_task = GNUNET_SCHEDULER_NO_TASK; 140 reconnect_task = GNUNET_SCHEDULER_NO_TASK;
141 GNUNET_TRANSPORT_try_connect (p1->th, &p2->id); 141 GNUNET_TRANSPORT_try_connect (p1->th, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */
142 reconnect_task = 142 reconnect_task =
143 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p); 143 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, p);
144} 144}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 0c51ef334..32331d9d9 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -208,7 +208,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
208 GNUNET_TRANSPORT_offer_hello (cc->th_p1, 208 GNUNET_TRANSPORT_offer_hello (cc->th_p1,
209 (const struct GNUNET_MessageHeader *) cc-> 209 (const struct GNUNET_MessageHeader *) cc->
210 p2->hello, NULL, NULL); 210 p2->hello, NULL, NULL);
211 GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id); 211 GNUNET_TRANSPORT_try_connect (cc->th_p1, &p2->id, NULL, NULL); /*FIXME TRY_CONNECT change */
212 212
213 cc->tct = 213 cc->tct =
214 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc); 214 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &try_connect, cc);
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index aa8db1474..768ed36da 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -187,6 +187,41 @@ struct GNUNET_TRANSPORT_GetHelloHandle
187 187
188}; 188};
189 189
190/**
191 * Linked list for all try-connect requests
192 */
193struct GNUNET_TRANSPORT_TryConnectHandle
194{
195 struct GNUNET_TRANSPORT_TryConnectHandle *prev;
196 struct GNUNET_TRANSPORT_TryConnectHandle *next;
197
198 struct GNUNET_PeerIdentity pid;
199
200 struct GNUNET_TRANSPORT_Handle *th;
201 struct GNUNET_TRANSPORT_TransmitHandle *tth;
202 GNUNET_TRANSPORT_TryConnectCallback cb;
203 void *cb_cls;
204};
205
206
207/**
208 * Linked list for all try-connect requests
209 */
210struct GNUNET_TRANSPORT_OfferHelloHandle
211{
212 struct GNUNET_TRANSPORT_OfferHelloHandle *prev;
213 struct GNUNET_TRANSPORT_OfferHelloHandle *next;
214
215 struct GNUNET_TRANSPORT_Handle *th;
216
217 struct GNUNET_TRANSPORT_TransmitHandle *tth;
218 GNUNET_SCHEDULER_Task cont;
219
220 void *cls;
221
222 struct GNUNET_MessageHeader *msg;
223};
224
190 225
191/** 226/**
192 * Handle for the transport service (includes all of the 227 * Handle for the transport service (includes all of the
@@ -252,6 +287,26 @@ struct GNUNET_TRANSPORT_Handle
252 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail; 287 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
253 288
254 /** 289 /**
290 * Linked list of pending try connect requests head
291 */
292 struct GNUNET_TRANSPORT_TryConnectHandle *tc_head;
293
294 /**
295 * Linked list of pending try connect requests tail
296 */
297 struct GNUNET_TRANSPORT_TryConnectHandle *tc_tail;
298
299 /**
300 * Linked list of pending offer HELLO requests head
301 */
302 struct GNUNET_TRANSPORT_OfferHelloHandle *oh_head;
303
304 /**
305 * Linked list of pending offer HELLO requests tail
306 */
307 struct GNUNET_TRANSPORT_OfferHelloHandle *oh_tail;
308
309 /**
255 * My configuration. 310 * My configuration.
256 */ 311 */
257 const struct GNUNET_CONFIGURATION_Handle *cfg; 312 const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -306,6 +361,7 @@ struct GNUNET_TRANSPORT_Handle
306}; 361};
307 362
308 363
364
309/** 365/**
310 * Schedule the task to send one message, either from the control 366 * Schedule the task to send one message, either from the control
311 * list or the peer message queues to the service. 367 * list or the peer message queues to the service.
@@ -830,8 +886,9 @@ schedule_transmission (struct GNUNET_TRANSPORT_Handle *h)
830 * @param size number of bytes to be transmitted 886 * @param size number of bytes to be transmitted
831 * @param notify function to call to get the content 887 * @param notify function to call to get the content
832 * @param notify_cls closure for notify 888 * @param notify_cls closure for notify
889 * @return a GNUNET_TRANSPORT_TransmitHandle
833 */ 890 */
834static void 891static struct GNUNET_TRANSPORT_TransmitHandle *
835schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size, 892schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size,
836 GNUNET_CONNECTION_TransmitReadyNotify notify, 893 GNUNET_CONNECTION_TransmitReadyNotify notify,
837 void *notify_cls) 894 void *notify_cls)
@@ -846,6 +903,7 @@ schedule_control_transmit (struct GNUNET_TRANSPORT_Handle *h, size_t size,
846 th->notify_size = size; 903 th->notify_size = size;
847 GNUNET_CONTAINER_DLL_insert_tail (h->control_head, h->control_tail, th); 904 GNUNET_CONTAINER_DLL_insert_tail (h->control_head, h->control_tail, th);
848 schedule_transmission (h); 905 schedule_transmission (h);
906 return th;
849} 907}
850 908
851 909
@@ -961,6 +1019,26 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
961 1019
962 1020
963/** 1021/**
1022 * Cancel control request for transmission to the transport service.
1023 *
1024 * @param th handle to the transport service
1025 * @param tth transmit handle to cancel
1026 */
1027static void
1028cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th, struct GNUNET_TRANSPORT_TransmitHandle *tth)
1029{
1030 GNUNET_assert (NULL != th);
1031 GNUNET_assert (NULL != tth);
1032
1033 LOG (GNUNET_ERROR_TYPE_DEBUG, "Canceling transmit of contral transmission requested\n");
1034
1035 GNUNET_CONTAINER_DLL_remove (th->control_head, th->control_tail, tth);
1036 GNUNET_free (tth);
1037}
1038
1039
1040
1041/**
964 * Send REQUEST_CONNECT message to the service. 1042 * Send REQUEST_CONNECT message to the service.
965 * 1043 *
966 * @param cls the 'struct GNUNET_PeerIdentity' 1044 * @param cls the 'struct GNUNET_PeerIdentity'
@@ -971,24 +1049,30 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
971static size_t 1049static size_t
972send_try_connect (void *cls, size_t size, void *buf) 1050send_try_connect (void *cls, size_t size, void *buf)
973{ 1051{
974 struct GNUNET_PeerIdentity *pid = cls; 1052 struct GNUNET_TRANSPORT_TryConnectHandle *tch = cls;
975 struct TransportRequestConnectMessage msg; 1053 struct TransportRequestConnectMessage msg;
976 1054
977 if (buf == NULL) 1055 if (buf == NULL)
978 { 1056 {
979 GNUNET_free (pid); 1057 if (NULL != tch->cb)
1058 tch->cb (tch->cb_cls, GNUNET_SYSERR);
1059 GNUNET_CONTAINER_DLL_remove (tch->th->tc_head, tch->th->tc_tail, tch);
1060 GNUNET_free (tch);
980 return 0; 1061 return 0;
981 } 1062 }
982 LOG (GNUNET_ERROR_TYPE_DEBUG, 1063 LOG (GNUNET_ERROR_TYPE_DEBUG,
983 "Transmitting `%s' request with respect to `%4s'.\n", "REQUEST_CONNECT", 1064 "Transmitting `%s' request with respect to `%4s'.\n", "REQUEST_CONNECT",
984 GNUNET_i2s (pid)); 1065 GNUNET_i2s (&tch->pid));
985 GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage)); 1066 GNUNET_assert (size >= sizeof (struct TransportRequestConnectMessage));
986 msg.header.size = htons (sizeof (struct TransportRequestConnectMessage)); 1067 msg.header.size = htons (sizeof (struct TransportRequestConnectMessage));
987 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT); 1068 msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_CONNECT);
988 msg.reserved = htonl (0); 1069 msg.reserved = htonl (0);
989 msg.peer = *pid; 1070 msg.peer = tch->pid;
990 memcpy (buf, &msg, sizeof (msg)); 1071 memcpy (buf, &msg, sizeof (msg));
991 GNUNET_free (pid); 1072 if (NULL != tch->cb)
1073 tch->cb (tch->cb_cls, GNUNET_OK);
1074 GNUNET_CONTAINER_DLL_remove (tch->th->tc_head, tch->th->tc_tail, tch);
1075 GNUNET_free (tch);
992 return sizeof (struct TransportRequestConnectMessage); 1076 return sizeof (struct TransportRequestConnectMessage);
993} 1077}
994 1078
@@ -998,40 +1082,52 @@ send_try_connect (void *cls, size_t size, void *buf)
998 * 1082 *
999 * @param handle connection to transport service 1083 * @param handle connection to transport service
1000 * @param target who we should try to connect to 1084 * @param target who we should try to connect to
1001 * @return GNUNET_OK if request can be scheduled 1085 * @param cb callback to be called when request was transmitted to transport
1002 * GNUNET_NO please retry later because we are reconnecting 1086 * service
1003 * GNUNET_SYSERR on failure 1087 * @return a GNUNET_TRANSPORT_TryConnectHandle handle or
1088 * NULL on failure (cb will not be called)
1004 */ 1089 */
1005int 1090struct GNUNET_TRANSPORT_TryConnectHandle *
1006GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle, 1091GNUNET_TRANSPORT_try_connect (struct GNUNET_TRANSPORT_Handle *handle,
1007 const struct GNUNET_PeerIdentity *target) 1092 const struct GNUNET_PeerIdentity *target,
1093 GNUNET_TRANSPORT_TryConnectCallback cb,
1094 void *cb_cls)
1008{ 1095{
1009 struct GNUNET_PeerIdentity *pid; 1096 struct GNUNET_TRANSPORT_TryConnectHandle *tch = NULL;
1010 if (NULL == handle->client)
1011 {
1012 if (GNUNET_SCHEDULER_NO_TASK == handle->reconnect_task)
1013 return GNUNET_SYSERR; /* this should never happen */
1014 else
1015 return GNUNET_NO; /* please retry */
1016 }
1017 1097
1018 pid = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); 1098 if (NULL == handle->client)
1019 *pid = *target; 1099 return NULL;
1020 schedule_control_transmit (handle, 1100
1101 tch = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TryConnectHandle));
1102 tch->th = handle;
1103 tch->pid = *(target);
1104 tch->cb = cb;
1105 tch->cb_cls = cb_cls;
1106 tch->tth = schedule_control_transmit (handle,
1021 sizeof (struct TransportRequestConnectMessage), 1107 sizeof (struct TransportRequestConnectMessage),
1022 &send_try_connect, pid); 1108 &send_try_connect, tch);
1023 return GNUNET_OK; 1109 GNUNET_CONTAINER_DLL_insert(handle->tc_head, handle->tc_tail, tch);
1110 return tch;
1024} 1111}
1025 1112
1026 1113
1027struct SendHelloContext 1114/**
1115 * Cancel the request to transport to try a connect
1116 * Callback will not be called
1117 *
1118 * @param tch GNUNET_TRANSPORT_TryConnectHandle handle to cancel
1119 */
1120void
1121GNUNET_TRANSPORT_try_connect_cancel (struct GNUNET_TRANSPORT_TryConnectHandle *tch)
1028{ 1122{
1029 GNUNET_SCHEDULER_Task cont; 1123 struct GNUNET_TRANSPORT_Handle *th;
1124 GNUNET_assert (NULL != tch);
1030 1125
1031 void *cls; 1126 th = tch->th;
1032 1127 cancel_control_transmit (th, tch->tth);
1033 struct GNUNET_MessageHeader *msg; 1128 GNUNET_CONTAINER_DLL_remove (th->tc_head, th->tc_tail, tch);
1034}; 1129 GNUNET_free (tch);
1130}
1035 1131
1036/** 1132/**
1037 * Send HELLO message to the service. 1133 * Send HELLO message to the service.
@@ -1044,8 +1140,8 @@ struct SendHelloContext
1044static size_t 1140static size_t
1045send_hello (void *cls, size_t size, void *buf) 1141send_hello (void *cls, size_t size, void *buf)
1046{ 1142{
1047 struct SendHelloContext *shc = cls; 1143 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
1048 struct GNUNET_MessageHeader *msg = shc->msg; 1144 struct GNUNET_MessageHeader *msg = ohh->msg;
1049 uint16_t ssize; 1145 uint16_t ssize;
1050 struct GNUNET_SCHEDULER_TaskContext tc; 1146 struct GNUNET_SCHEDULER_TaskContext tc;
1051 tc.read_ready = NULL; 1147 tc.read_ready = NULL;
@@ -1056,10 +1152,11 @@ send_hello (void *cls, size_t size, void *buf)
1056 { 1152 {
1057 LOG (GNUNET_ERROR_TYPE_DEBUG, 1153 LOG (GNUNET_ERROR_TYPE_DEBUG,
1058 "Timeout while trying to transmit `%s' request.\n", "HELLO"); 1154 "Timeout while trying to transmit `%s' request.\n", "HELLO");
1059 if (NULL != shc->cont) 1155 if (NULL != ohh->cont)
1060 shc->cont (shc->cls, &tc); 1156 ohh->cont (ohh->cls, &tc);
1061 GNUNET_free (msg); 1157 GNUNET_free (msg);
1062 GNUNET_free (shc); 1158 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head, ohh->th->oh_tail, ohh);
1159 GNUNET_free (ohh);
1063 return 0; 1160 return 0;
1064 } 1161 }
1065 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "HELLO"); 1162 LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' request.\n", "HELLO");
@@ -1068,9 +1165,10 @@ send_hello (void *cls, size_t size, void *buf)
1068 memcpy (buf, msg, ssize); 1165 memcpy (buf, msg, ssize);
1069 GNUNET_free (msg); 1166 GNUNET_free (msg);
1070 tc.reason = GNUNET_SCHEDULER_REASON_READ_READY; 1167 tc.reason = GNUNET_SCHEDULER_REASON_READ_READY;
1071 if (NULL != shc->cont) 1168 if (NULL != ohh->cont)
1072 shc->cont (shc->cls, &tc); 1169 ohh->cont (ohh->cls, &tc);
1073 GNUNET_free (shc); 1170 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head, ohh->th->oh_tail, ohh);
1171 GNUNET_free (ohh);
1074 return ssize; 1172 return ssize;
1075} 1173}
1076 1174
@@ -1086,29 +1184,26 @@ send_hello (void *cls, size_t size, void *buf)
1086 * tc reason GNUNET_SCHEDULER_REASON_TIMEOUT for fail 1184 * tc reason GNUNET_SCHEDULER_REASON_TIMEOUT for fail
1087 * tc reasong GNUNET_SCHEDULER_REASON_READ_READY for success 1185 * tc reasong GNUNET_SCHEDULER_REASON_READ_READY for success
1088 * @param cls closure for continuation 1186 * @param cls closure for continuation
1187 * @return a GNUNET_TRANSPORT_OfferHelloHandle handle or NULL on failure,
1188 * in case of failure cont will not be called
1089 * 1189 *
1090 */ 1190 */
1091void 1191struct GNUNET_TRANSPORT_OfferHelloHandle *
1092GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, 1192GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1093 const struct GNUNET_MessageHeader *hello, 1193 const struct GNUNET_MessageHeader *hello,
1094 GNUNET_SCHEDULER_Task cont, void *cls) 1194 GNUNET_SCHEDULER_Task cont, void *cls)
1095{ 1195{
1096 uint16_t size; 1196 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
1097 struct GNUNET_PeerIdentity peer;
1098 struct GNUNET_MessageHeader *msg; 1197 struct GNUNET_MessageHeader *msg;
1099 struct SendHelloContext * shc; 1198 struct GNUNET_PeerIdentity peer;
1100 struct GNUNET_SCHEDULER_TaskContext tc; 1199 uint16_t size;
1101 1200
1102 tc.read_ready = NULL; 1201 GNUNET_assert (NULL != handle);
1103 tc.write_ready = NULL; 1202 GNUNET_assert (NULL != hello);
1104 tc.reason = GNUNET_SCHEDULER_REASON_TIMEOUT;
1105 1203
1106 if (NULL == handle->client) 1204 if (NULL == handle->client)
1107 { 1205 return NULL;
1108 if (NULL != cont) 1206
1109 cont (cls, &tc);
1110 return;
1111 }
1112 GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO); 1207 GNUNET_break (ntohs (hello->type) == GNUNET_MESSAGE_TYPE_HELLO);
1113 size = ntohs (hello->size); 1208 size = ntohs (hello->size);
1114 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader)); 1209 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader));
@@ -1116,25 +1211,46 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1116 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello, &peer)) 1211 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello, &peer))
1117 { 1212 {
1118 GNUNET_break (0); 1213 GNUNET_break (0);
1119 if (NULL != cont) 1214 return NULL;
1120 if (NULL != cont)
1121 cont (cls, &tc);
1122 return;
1123 } 1215 }
1216
1124 msg = GNUNET_malloc (size); 1217 msg = GNUNET_malloc (size);
1125 memcpy (msg, hello, size); 1218 memcpy (msg, hello, size);
1126 LOG (GNUNET_ERROR_TYPE_DEBUG, 1219 LOG (GNUNET_ERROR_TYPE_DEBUG,
1127 "Offering `%s' message of `%4s' to transport for validation.\n", "HELLO", 1220 "Offering `%s' message of `%4s' to transport for validation.\n", "HELLO",
1128 GNUNET_i2s (&peer)); 1221 GNUNET_i2s (&peer));
1129 shc = GNUNET_malloc (sizeof (struct SendHelloContext)); 1222
1130 shc->msg = msg; 1223 ohh = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_OfferHelloHandle));
1131 shc->cont = cont; 1224 ohh->th = handle;
1132 shc->cls = cls; 1225 ohh->cont = cont;
1133 schedule_control_transmit (handle, size, &send_hello, shc); 1226 ohh->cls = cls;
1227 ohh->msg = msg;
1228 ohh->tth = schedule_control_transmit (handle, size, &send_hello, ohh);
1229 GNUNET_CONTAINER_DLL_insert (handle->oh_head, handle->oh_tail, ohh);
1230 return ohh;
1134} 1231}
1135 1232
1136 1233
1137/** 1234/**
1235 * Cancel the request to transport to offer the HELLO message
1236 *
1237 * @param ohh the GNUNET_TRANSPORT_OfferHelloHandle to cancel
1238 */
1239void
1240GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *ohh)
1241{
1242 struct GNUNET_TRANSPORT_Handle *th = ohh->th;
1243 GNUNET_assert (NULL != ohh);
1244
1245 cancel_control_transmit (ohh->th, ohh->tth);
1246 GNUNET_CONTAINER_DLL_remove (th->oh_head, th->oh_tail, ohh);
1247 GNUNET_free (ohh->msg);
1248 GNUNET_free (ohh);
1249}
1250
1251
1252
1253/**
1138 * Obtain the HELLO message for this peer. 1254 * Obtain the HELLO message for this peer.
1139 * 1255 *
1140 * @param handle connection to transport service 1256 * @param handle connection to transport service
@@ -1254,6 +1370,8 @@ GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle)
1254 } 1370 }
1255 GNUNET_free_non_null (handle->my_hello); 1371 GNUNET_free_non_null (handle->my_hello);
1256 handle->my_hello = NULL; 1372 handle->my_hello = NULL;
1373 GNUNET_assert (handle->tc_head == NULL);
1374 GNUNET_assert (handle->tc_tail == NULL);
1257 GNUNET_assert (handle->hwl_head == NULL); 1375 GNUNET_assert (handle->hwl_head == NULL);
1258 GNUNET_assert (handle->hwl_tail == NULL); 1376 GNUNET_assert (handle->hwl_tail == NULL);
1259 GNUNET_CONTAINER_heap_destroy (handle->ready_heap); 1377 GNUNET_CONTAINER_heap_destroy (handle->ready_heap);