aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api.c')
-rw-r--r--src/transport/transport_api.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index a6d2fa0ba..bbfe1e63d 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -150,18 +150,23 @@ struct Neighbour
150/** 150/**
151 * Linked list of functions to call whenever our HELLO is updated. 151 * Linked list of functions to call whenever our HELLO is updated.
152 */ 152 */
153struct HelloWaitList 153struct GNUNET_TRANSPORT_GetHelloHandle
154{ 154{
155 155
156 /** 156 /**
157 * This is a doubly linked list. 157 * This is a doubly linked list.
158 */ 158 */
159 struct HelloWaitList *next; 159 struct GNUNET_TRANSPORT_GetHelloHandle *next;
160 160
161 /** 161 /**
162 * This is a doubly linked list. 162 * This is a doubly linked list.
163 */ 163 */
164 struct HelloWaitList *prev; 164 struct GNUNET_TRANSPORT_GetHelloHandle *prev;
165
166 /**
167 * Transport handle.
168 */
169 struct GNUNET_TRANSPORT_Handle *handle;
165 170
166 /** 171 /**
167 * Callback to call once we got our HELLO. 172 * Callback to call once we got our HELLO.
@@ -232,12 +237,12 @@ struct GNUNET_TRANSPORT_Handle
232 /** 237 /**
233 * Linked list of pending requests for our HELLO. 238 * Linked list of pending requests for our HELLO.
234 */ 239 */
235 struct HelloWaitList *hwl_head; 240 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_head;
236 241
237 /** 242 /**
238 * Linked list of pending requests for our HELLO. 243 * Linked list of pending requests for our HELLO.
239 */ 244 */
240 struct HelloWaitList *hwl_tail; 245 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
241 246
242 /** 247 /**
243 * My configuration. 248 * My configuration.
@@ -397,8 +402,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
397 const struct InboundMessage *im; 402 const struct InboundMessage *im;
398 const struct GNUNET_MessageHeader *imm; 403 const struct GNUNET_MessageHeader *imm;
399 const struct SendOkMessage *okm; 404 const struct SendOkMessage *okm;
400 struct HelloWaitList *hwl; 405 struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
401 struct HelloWaitList *next_hwl; 406 struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
402 struct Neighbour *n; 407 struct Neighbour *n;
403 struct GNUNET_PeerIdentity me; 408 struct GNUNET_PeerIdentity me;
404 uint16_t size; 409 uint16_t size;
@@ -1189,50 +1194,39 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1189 * (handshake with transport service pending/failed). 1194 * (handshake with transport service pending/failed).
1190 * cost estimate will be 0. 1195 * cost estimate will be 0.
1191 * @param rec_cls closure for rec 1196 * @param rec_cls closure for rec
1197 * @return handle to cancel the operation, NULL on error
1192 */ 1198 */
1193void 1199struct GNUNET_TRANSPORT_GetHelloHandle *
1194GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, 1200GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
1195 GNUNET_TRANSPORT_HelloUpdateCallback rec, 1201 GNUNET_TRANSPORT_HelloUpdateCallback rec,
1196 void *rec_cls) 1202 void *rec_cls)
1197{ 1203{
1198 struct HelloWaitList *hwl; 1204 struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
1199 1205
1200 hwl = GNUNET_malloc (sizeof (struct HelloWaitList)); 1206 if (handle->my_hello == NULL)
1207 return NULL;
1208 hwl = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_GetHelloHandle));
1201 hwl->rec = rec; 1209 hwl->rec = rec;
1202 hwl->rec_cls = rec_cls; 1210 hwl->rec_cls = rec_cls;
1211 hwl->handle = handle;
1203 GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl); 1212 GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
1204 if (handle->my_hello == NULL)
1205 return;
1206 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello); 1213 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
1214 return hwl;
1207} 1215}
1208 1216
1209 1217
1210/** 1218/**
1211 * Stop receiving updates about changes to our HELLO message. 1219 * Stop receiving updates about changes to our HELLO message.
1212 * 1220 *
1213 * @param handle connection to transport service 1221 * @param ghh handle to cancel
1214 * @param rec function previously registered to be called with the HELLOs
1215 * @param rec_cls closure for rec
1216 */ 1222 */
1217void 1223void
1218GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle, 1224GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
1219 GNUNET_TRANSPORT_HelloUpdateCallback rec,
1220 void *rec_cls)
1221{ 1225{
1222 struct HelloWaitList *pos; 1226 struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
1223 1227
1224 pos = handle->hwl_head; 1228 GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
1225 while (pos != NULL) 1229 GNUNET_free (ghh);
1226 {
1227 if ((pos->rec == rec) && (pos->rec_cls == rec_cls))
1228 break;
1229 pos = pos->next;
1230 }
1231 GNUNET_break (pos != NULL);
1232 if (pos == NULL)
1233 return;
1234 GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, pos);
1235 GNUNET_free (pos);
1236} 1230}
1237 1231
1238 1232