aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-29 14:29:41 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-29 14:29:41 +0000
commitab500ec36e087619e7e58693dc744c3f67a9d200 (patch)
tree315c79c1c9e4b609df8cd2fde627410b1dec3eb8 /src/dht/dht_api.c
parentc7d9b8245a19e203a3a11658038f8e603dad31a3 (diff)
downloadgnunet-ab500ec36e087619e7e58693dc744c3f67a9d200.tar.gz
gnunet-ab500ec36e087619e7e58693dc744c3f67a9d200.zip
-minor code/doxygen clean up
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r--src/dht/dht_api.c135
1 files changed, 71 insertions, 64 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 96ca6abfb..0af2d0d63 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -318,7 +318,7 @@ struct GNUNET_DHT_Handle
318 318
319 /** 319 /**
320 * Hash map containing the current outstanding unique GET requests 320 * Hash map containing the current outstanding unique GET requests
321 * (values are of type 'struct GNUNET_DHT_GetHandle'). 321 * (values are of type `struct GNUNET_DHT_GetHandle`).
322 */ 322 */
323 struct GNUNET_CONTAINER_MultiHashMap *active_requests; 323 struct GNUNET_CONTAINER_MultiHashMap *active_requests;
324 324
@@ -349,18 +349,19 @@ struct GNUNET_DHT_Handle
349 * Handler for messages received from the DHT service 349 * Handler for messages received from the DHT service
350 * a demultiplexer which handles numerous message types 350 * a demultiplexer which handles numerous message types
351 * 351 *
352 * @param cls the 'struct GNUNET_DHT_Handle' 352 * @param cls the `struct GNUNET_DHT_Handle`
353 * @param msg the incoming message 353 * @param msg the incoming message
354 */ 354 */
355static void 355static void
356service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg); 356service_message_handler (void *cls,
357 const struct GNUNET_MessageHeader *msg);
357 358
358 359
359/** 360/**
360 * Try to (re)connect to the DHT service. 361 * Try to (re)connect to the DHT service.
361 * 362 *
362 * @param handle DHT handle to reconnect 363 * @param handle DHT handle to reconnect
363 * @return GNUNET_YES on success, GNUNET_NO on failure. 364 * @return #GNUNET_YES on success, #GNUNET_NO on failure.
364 */ 365 */
365static int 366static int
366try_connect (struct GNUNET_DHT_Handle *handle) 367try_connect (struct GNUNET_DHT_Handle *handle)
@@ -427,13 +428,15 @@ queue_filter_messages (struct GNUNET_DHT_GetHandle *get_handle)
427 * Add the request corresponding to the given route handle 428 * Add the request corresponding to the given route handle
428 * to the pending queue (if it is not already in there). 429 * to the pending queue (if it is not already in there).
429 * 430 *
430 * @param cls the 'struct GNUNET_DHT_Handle*' 431 * @param cls the `struct GNUNET_DHT_Handle *`
431 * @param key key for the request (not used) 432 * @param key key for the request (not used)
432 * @param value the 'struct GNUNET_DHT_GetHandle*' 433 * @param value the `struct GNUNET_DHT_GetHandle *`
433 * @return GNUNET_YES (always) 434 * @return #GNUNET_YES (always)
434 */ 435 */
435static int 436static int
436add_request_to_pending (void *cls, const struct GNUNET_HashCode * key, void *value) 437add_request_to_pending (void *cls,
438 const struct GNUNET_HashCode *key,
439 void *value)
437{ 440{
438 struct GNUNET_DHT_Handle *handle = cls; 441 struct GNUNET_DHT_Handle *handle = cls;
439 struct GNUNET_DHT_GetHandle *get_handle = value; 442 struct GNUNET_DHT_GetHandle *get_handle = value;
@@ -465,11 +468,12 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle);
465/** 468/**
466 * Try reconnecting to the dht service. 469 * Try reconnecting to the dht service.
467 * 470 *
468 * @param cls GNUNET_DHT_Handle 471 * @param cls a `struct GNUNET_DHT_Handle`
469 * @param tc scheduler context 472 * @param tc scheduler context
470 */ 473 */
471static void 474static void
472try_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 475try_reconnect (void *cls,
476 const struct GNUNET_SCHEDULER_TaskContext *tc)
473{ 477{
474 struct GNUNET_DHT_Handle *handle = cls; 478 struct GNUNET_DHT_Handle *handle = cls;
475 479
@@ -533,12 +537,14 @@ do_disconnect (struct GNUNET_DHT_Handle *handle)
533 * Transmit the next pending message, called by notify_transmit_ready 537 * Transmit the next pending message, called by notify_transmit_ready
534 * 538 *
535 * @param cls the DHT handle 539 * @param cls the DHT handle
536 * @param size number of bytes available in 'buf' for transmission 540 * @param size number of bytes available in @a buf for transmission
537 * @param buf where to copy messages for the service 541 * @param buf where to copy messages for the service
538 * @return number of bytes written to 'buf' 542 * @return number of bytes written to @a buf
539 */ 543 */
540static size_t 544static size_t
541transmit_pending (void *cls, size_t size, void *buf); 545transmit_pending (void *cls,
546 size_t size,
547 void *buf);
542 548
543 549
544/** 550/**
@@ -580,12 +586,14 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle)
580 * Transmit the next pending message, called by notify_transmit_ready 586 * Transmit the next pending message, called by notify_transmit_ready
581 * 587 *
582 * @param cls the DHT handle 588 * @param cls the DHT handle
583 * @param size number of bytes available in 'buf' for transmission 589 * @param size number of bytes available in @a buf for transmission
584 * @param buf where to copy messages for the service 590 * @param buf where to copy messages for the service
585 * @return number of bytes written to 'buf' 591 * @return number of bytes written to @a buf
586 */ 592 */
587static size_t 593static size_t
588transmit_pending (void *cls, size_t size, void *buf) 594transmit_pending (void *cls,
595 size_t size,
596 void *buf)
589{ 597{
590 struct GNUNET_DHT_Handle *handle = cls; 598 struct GNUNET_DHT_Handle *handle = cls;
591 struct PendingMessage *head; 599 struct PendingMessage *head;
@@ -638,14 +646,16 @@ transmit_pending (void *cls, size_t size, void *buf)
638 * Process a given reply that might match the given 646 * Process a given reply that might match the given
639 * request. 647 * request.
640 * 648 *
641 * @param cls the 'struct GNUNET_DHT_ClientResultMessage' 649 * @param cls the `struct GNUNET_DHT_ClientResultMessage`
642 * @param key query of the request 650 * @param key query of the request
643 * @param value the 'struct GNUNET_DHT_RouteHandle' of a request matching the same key 651 * @param value the `struct GNUNET_DHT_RouteHandle` of a request matching the same key
644 * @return GNUNET_YES to continue to iterate over all results, 652 * @return #GNUNET_YES to continue to iterate over all results,
645 * GNUNET_NO if the reply is malformed or we found a matching request 653 * #GNUNET_NO if the reply is malformed or we found a matching request
646 */ 654 */
647static int 655static int
648process_reply (void *cls, const struct GNUNET_HashCode * key, void *value) 656process_reply (void *cls,
657 const struct GNUNET_HashCode *key,
658 void *value)
649{ 659{
650 const struct GNUNET_DHT_ClientResultMessage *dht_msg = cls; 660 const struct GNUNET_DHT_ClientResultMessage *dht_msg = cls;
651 struct GNUNET_DHT_GetHandle *get_handle = value; 661 struct GNUNET_DHT_GetHandle *get_handle = value;
@@ -697,8 +707,7 @@ process_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
697 GNUNET_assert (get_handle->seen_results_end == get_handle->seen_results_transmission_offset); 707 GNUNET_assert (get_handle->seen_results_end == get_handle->seen_results_transmission_offset);
698 get_handle->seen_results[get_handle->seen_results_end++] = hc; 708 get_handle->seen_results[get_handle->seen_results_end++] = hc;
699 /* no need to block it explicitly, service already knows about it! */ 709 /* no need to block it explicitly, service already knows about it! */
700 get_handle->seen_results_transmission_offset++; 710 get_handle->seen_results_transmission_offset++;
701
702 get_handle->iter (get_handle->iter_cls, 711 get_handle->iter (get_handle->iter_cls,
703 GNUNET_TIME_absolute_ntoh (dht_msg->expiration), key, 712 GNUNET_TIME_absolute_ntoh (dht_msg->expiration), key,
704 get_path, get_path_length, put_path, put_path_length, 713 get_path, get_path_length, put_path, put_path_length,
@@ -706,14 +715,14 @@ process_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
706 return GNUNET_NO; 715 return GNUNET_NO;
707} 716}
708 717
718
709/** 719/**
710 * Process a get monitor message from the service. 720 * Process a get monitor message from the service.
711 * 721 *
712 * @param handle The DHT handle. 722 * @param handle The DHT handle.
713 * @param msg Monitor get message from the service. 723 * @param msg Monitor get message from the service.
714 * 724 * @return #GNUNET_OK if everything went fine,
715 * @return GNUNET_OK if everything went fine, 725 * #GNUNET_SYSERR if the message is malformed.
716 * GNUNET_SYSERR if the message is malformed.
717 */ 726 */
718static int 727static int
719process_monitor_get_message (struct GNUNET_DHT_Handle *handle, 728process_monitor_get_message (struct GNUNET_DHT_Handle *handle,
@@ -748,13 +757,12 @@ process_monitor_get_message (struct GNUNET_DHT_Handle *handle,
748 * 757 *
749 * @param handle The DHT handle. 758 * @param handle The DHT handle.
750 * @param msg monitor get response message from the service 759 * @param msg monitor get response message from the service
751 * @return GNUNET_OK if everything went fine, 760 * @return #GNUNET_OK if everything went fine,
752 * GNUNET_SYSERR if the message is malformed. 761 * #GNUNET_SYSERR if the message is malformed.
753 */ 762 */
754static int 763static int
755process_monitor_get_resp_message (struct GNUNET_DHT_Handle *handle, 764process_monitor_get_resp_message (struct GNUNET_DHT_Handle *handle,
756 const struct GNUNET_DHT_MonitorGetRespMessage 765 const struct GNUNET_DHT_MonitorGetRespMessage *msg)
757 *msg)
758{ 766{
759 struct GNUNET_DHT_MonitorHandle *h; 767 struct GNUNET_DHT_MonitorHandle *h;
760 struct GNUNET_PeerIdentity *path; 768 struct GNUNET_PeerIdentity *path;
@@ -801,9 +809,8 @@ process_monitor_get_resp_message (struct GNUNET_DHT_Handle *handle,
801 * 809 *
802 * @param handle The DHT handle. 810 * @param handle The DHT handle.
803 * @param msg Monitor put message from the service. 811 * @param msg Monitor put message from the service.
804 * 812 * @return #GNUNET_OK if everything went fine,
805 * @return GNUNET_OK if everything went fine, 813 * #GNUNET_SYSERR if the message is malformed.
806 * GNUNET_SYSERR if the message is malformed.
807 */ 814 */
808static int 815static int
809process_monitor_put_message (struct GNUNET_DHT_Handle *handle, 816process_monitor_put_message (struct GNUNET_DHT_Handle *handle,
@@ -853,8 +860,8 @@ process_monitor_put_message (struct GNUNET_DHT_Handle *handle,
853 * 860 *
854 * @param handle The DHT handle. 861 * @param handle The DHT handle.
855 * @param msg confirmation message from the service. 862 * @param msg confirmation message from the service.
856 * @return GNUNET_OK if everything went fine, 863 * @return #GNUNET_OK if everything went fine,
857 * GNUNET_SYSERR if the message is malformed. 864 * #GNUNET_SYSERR if the message is malformed.
858 */ 865 */
859static int 866static int
860process_put_confirmation_message (struct GNUNET_DHT_Handle *handle, 867process_put_confirmation_message (struct GNUNET_DHT_Handle *handle,
@@ -882,7 +889,7 @@ process_put_confirmation_message (struct GNUNET_DHT_Handle *handle,
882 * Handler for messages received from the DHT service 889 * Handler for messages received from the DHT service
883 * a demultiplexer which handles numerous message types 890 * a demultiplexer which handles numerous message types
884 * 891 *
885 * @param cls the 'struct GNUNET_DHT_Handle' 892 * @param cls the `struct GNUNET_DHT_Handle`
886 * @param msg the incoming message 893 * @param msg the incoming message
887 */ 894 */
888static void 895static void
@@ -948,9 +955,9 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
948 "Received reply for `%s' from DHT service %p\n", 955 "Received reply for `%s' from DHT service %p\n",
949 GNUNET_h2s (&dht_msg->key), handle); 956 GNUNET_h2s (&dht_msg->key), handle);
950 GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, 957 GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests,
951 &dht_msg->key, 958 &dht_msg->key,
952 &process_reply, 959 &process_reply,
953 (void *) dht_msg); 960 (void *) dht_msg);
954 ret = GNUNET_OK; 961 ret = GNUNET_OK;
955 break; 962 break;
956 case GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK: 963 case GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK:
@@ -984,7 +991,6 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
984 * @param cfg configuration to use 991 * @param cfg configuration to use
985 * @param ht_len size of the internal hash table to use for 992 * @param ht_len size of the internal hash table to use for
986 * processing multiple GET/FIND requests in parallel 993 * processing multiple GET/FIND requests in parallel
987 *
988 * @return handle to the DHT service, or NULL on error 994 * @return handle to the DHT service, or NULL on error
989 */ 995 */
990struct GNUNET_DHT_Handle * 996struct GNUNET_DHT_Handle *
@@ -993,7 +999,7 @@ GNUNET_DHT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
993{ 999{
994 struct GNUNET_DHT_Handle *handle; 1000 struct GNUNET_DHT_Handle *handle;
995 1001
996 handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_Handle)); 1002 handle = GNUNET_new (struct GNUNET_DHT_Handle);
997 handle->cfg = cfg; 1003 handle->cfg = cfg;
998 handle->uid_gen = 1004 handle->uid_gen =
999 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX); 1005 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
@@ -1060,11 +1066,12 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle)
1060/** 1066/**
1061 * Timeout for the transmission of a fire&forget-request. Clean it up. 1067 * Timeout for the transmission of a fire&forget-request. Clean it up.
1062 * 1068 *
1063 * @param cls the 'struct PendingMessage' 1069 * @param cls the `struct GNUNET_DHT_PutHandle *`
1064 * @param tc scheduler context 1070 * @param tc scheduler context
1065 */ 1071 */
1066static void 1072static void
1067timeout_put_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1073timeout_put_request (void *cls,
1074 const struct GNUNET_SCHEDULER_TaskContext *tc)
1068{ 1075{
1069 struct GNUNET_DHT_PutHandle *ph = cls; 1076 struct GNUNET_DHT_PutHandle *ph = cls;
1070 struct GNUNET_DHT_Handle *handle = ph->dht_handle; 1077 struct GNUNET_DHT_Handle *handle = ph->dht_handle;
@@ -1090,7 +1097,7 @@ timeout_put_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1090 * Function called whenever the PUT message leaves the queue. Sets 1097 * Function called whenever the PUT message leaves the queue. Sets
1091 * the message pointer in the put handle to NULL. 1098 * the message pointer in the put handle to NULL.
1092 * 1099 *
1093 * @param cls the 'struct GNUNET_DHT_PutHandle' 1100 * @param cls the `struct GNUNET_DHT_PutHandle`
1094 * @param tc unused 1101 * @param tc unused
1095 */ 1102 */
1096static void 1103static void
@@ -1121,16 +1128,19 @@ mark_put_message_gone (void *cls,
1121 * @param exp desired expiration time for the value 1128 * @param exp desired expiration time for the value
1122 * @param timeout how long to wait for transmission of this request 1129 * @param timeout how long to wait for transmission of this request
1123 * @param cont continuation to call when done (transmitting request to service) 1130 * @param cont continuation to call when done (transmitting request to service)
1124 * You must not call GNUNET_DHT_DISCONNECT in this continuation 1131 * You must not call #GNUNET_DHT_disconnect in this continuation
1125 * @param cont_cls closure for cont 1132 * @param cont_cls closure for @a cont
1126 */ 1133 */
1127struct GNUNET_DHT_PutHandle * 1134struct GNUNET_DHT_PutHandle *
1128GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode * key, 1135GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle,
1136 const struct GNUNET_HashCode * key,
1129 uint32_t desired_replication_level, 1137 uint32_t desired_replication_level,
1130 enum GNUNET_DHT_RouteOption options, 1138 enum GNUNET_DHT_RouteOption options,
1131 enum GNUNET_BLOCK_Type type, size_t size, const void *data, 1139 enum GNUNET_BLOCK_Type type, size_t size,
1140 const void *data,
1132 struct GNUNET_TIME_Absolute exp, 1141 struct GNUNET_TIME_Absolute exp,
1133 struct GNUNET_TIME_Relative timeout, GNUNET_DHT_PutContinuation cont, 1142 struct GNUNET_TIME_Relative timeout,
1143 GNUNET_DHT_PutContinuation cont,
1134 void *cont_cls) 1144 void *cont_cls)
1135{ 1145{
1136 struct GNUNET_DHT_ClientPutMessage *put_msg; 1146 struct GNUNET_DHT_ClientPutMessage *put_msg;
@@ -1145,7 +1155,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *
1145 GNUNET_break (0); 1155 GNUNET_break (0);
1146 return NULL; 1156 return NULL;
1147 } 1157 }
1148 ph = GNUNET_malloc (sizeof (struct GNUNET_DHT_PutHandle)); 1158 ph = GNUNET_new (struct GNUNET_DHT_PutHandle);
1149 ph->dht_handle = handle; 1159 ph->dht_handle = handle;
1150 ph->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_put_request, ph); 1160 ph->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_put_request, ph);
1151 ph->cont = cont; 1161 ph->cont = cont;
@@ -1185,7 +1195,7 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *
1185 * has not yet been sent to the service, cancelling the PUT will stop 1195 * has not yet been sent to the service, cancelling the PUT will stop
1186 * this from happening (but there is no way for the user of this API 1196 * this from happening (but there is no way for the user of this API
1187 * to tell if that is the case). The only use for this API is to 1197 * to tell if that is the case). The only use for this API is to
1188 * prevent a later call to 'cont' from "GNUNET_DHT_put" (i.e. because 1198 * prevent a later call to 'cont' from #GNUNET_DHT_put (i.e. because
1189 * the system is shutting down). 1199 * the system is shutting down).
1190 * 1200 *
1191 * @param ph put operation to cancel ('cont' will no longer be called) 1201 * @param ph put operation to cancel ('cont' will no longer be called)
@@ -1217,7 +1227,7 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph)
1217 1227
1218/** 1228/**
1219 * Perform an asynchronous GET operation on the DHT identified. See 1229 * Perform an asynchronous GET operation on the DHT identified. See
1220 * also "GNUNET_BLOCK_evaluate". 1230 * also #GNUNET_BLOCK_evaluate.
1221 * 1231 *
1222 * @param handle handle to the DHT service 1232 * @param handle handle to the DHT service
1223 * @param type expected type of the response object 1233 * @param type expected type of the response object
@@ -1226,7 +1236,7 @@ GNUNET_DHT_put_cancel (struct GNUNET_DHT_PutHandle *ph)
1226 nearest peers this request should reach 1236 nearest peers this request should reach
1227 * @param options routing options for this message 1237 * @param options routing options for this message
1228 * @param xquery extended query data (can be NULL, depending on type) 1238 * @param xquery extended query data (can be NULL, depending on type)
1229 * @param xquery_size number of bytes in xquery 1239 * @param xquery_size number of bytes in @a xquery
1230 * @param iter function to call on each result 1240 * @param iter function to call on each result
1231 * @param iter_cls closure for iter 1241 * @param iter_cls closure for iter
1232 * @return handle to stop the async get 1242 * @return handle to stop the async get
@@ -1269,7 +1279,7 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
1269 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, 1279 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
1270 pending); 1280 pending);
1271 pending->in_pending_queue = GNUNET_YES; 1281 pending->in_pending_queue = GNUNET_YES;
1272 get_handle = GNUNET_malloc (sizeof (struct GNUNET_DHT_GetHandle)); 1282 get_handle = GNUNET_new (struct GNUNET_DHT_GetHandle);
1273 get_handle->dht_handle = handle; 1283 get_handle->dht_handle = handle;
1274 get_handle->iter = iter; 1284 get_handle->iter = iter;
1275 get_handle->iter_cls = iter_cls; 1285 get_handle->iter_cls = iter_cls;
@@ -1282,14 +1292,13 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle,
1282} 1292}
1283 1293
1284 1294
1285
1286/** 1295/**
1287 * Tell the DHT not to return any of the following known results 1296 * Tell the DHT not to return any of the following known results
1288 * to this client. 1297 * to this client.
1289 * 1298 *
1290 * @param get_handle get operation for which results should be filtered 1299 * @param get_handle get operation for which results should be filtered
1291 * @param num_results number of results to be blocked that are 1300 * @param num_results number of results to be blocked that are
1292 * provided in this call (size of the 'results' array) 1301 * provided in this call (size of the @a results array)
1293 * @param results array of hash codes over the 'data' of the results 1302 * @param results array of hash codes over the 'data' of the results
1294 * to be blocked 1303 * to be blocked
1295 */ 1304 */
@@ -1330,7 +1339,8 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle)
1330 handle = get_handle->message->handle; 1339 handle = get_handle->message->handle;
1331 get_msg = 1340 get_msg =
1332 (const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg; 1341 (const struct GNUNET_DHT_ClientGetMessage *) get_handle->message->msg;
1333 LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending STOP for %s to DHT via %p\n", 1342 LOG (GNUNET_ERROR_TYPE_DEBUG,
1343 "Sending STOP for %s to DHT via %p\n",
1334 GNUNET_h2s (&get_msg->key), handle); 1344 GNUNET_h2s (&get_msg->key), handle);
1335 /* generate STOP */ 1345 /* generate STOP */
1336 pending = 1346 pending =
@@ -1379,8 +1389,7 @@ GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle)
1379 * @param get_cb Callback to process monitored get messages. 1389 * @param get_cb Callback to process monitored get messages.
1380 * @param get_resp_cb Callback to process monitored get response messages. 1390 * @param get_resp_cb Callback to process monitored get response messages.
1381 * @param put_cb Callback to process monitored put messages. 1391 * @param put_cb Callback to process monitored put messages.
1382 * @param cb_cls Closure for cb. 1392 * @param cb_cls Closure for callbacks.
1383 *
1384 * @return Handle to stop monitoring. 1393 * @return Handle to stop monitoring.
1385 */ 1394 */
1386struct GNUNET_DHT_MonitorHandle * 1395struct GNUNET_DHT_MonitorHandle *
@@ -1396,7 +1405,7 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
1396 struct GNUNET_DHT_MonitorStartStopMessage *m; 1405 struct GNUNET_DHT_MonitorStartStopMessage *m;
1397 struct PendingMessage *pending; 1406 struct PendingMessage *pending;
1398 1407
1399 h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle)); 1408 h = GNUNET_new (struct GNUNET_DHT_MonitorHandle);
1400 GNUNET_CONTAINER_DLL_insert(handle->monitor_head, handle->monitor_tail, h); 1409 GNUNET_CONTAINER_DLL_insert(handle->monitor_head, handle->monitor_tail, h);
1401 1410
1402 h->get_cb = get_cb; 1411 h->get_cb = get_cb;
@@ -1407,8 +1416,8 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
1407 h->dht_handle = handle; 1416 h->dht_handle = handle;
1408 if (NULL != key) 1417 if (NULL != key)
1409 { 1418 {
1410 h->key = GNUNET_malloc (sizeof(struct GNUNET_HashCode)); 1419 h->key = GNUNET_new(struct GNUNET_HashCode);
1411 memcpy (h->key, key, sizeof(struct GNUNET_HashCode)); 1420 h->key = *key;
1412 } 1421 }
1413 1422
1414 pending = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorStartStopMessage) + 1423 pending = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorStartStopMessage) +
@@ -1479,6 +1488,4 @@ GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle)
1479 GNUNET_free (handle); 1488 GNUNET_free (handle);
1480} 1489}
1481 1490
1482
1483
1484/* end of dht_api.c */ 1491/* end of dht_api.c */