From: Nathan S. Evans Date: Thu, 18 Mar 2010 16:33:14 +0000 (+0000) Subject: dht related changes to message types and whatnot X-Git-Tag: initial-import-from-subversion-38251~22406 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=558fa8b012469c0ada0c4fac6d05c01a727ef764;p=oweals%2Fgnunet.git dht related changes to message types and whatnot --- diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index be7594e32..9e2e5d163 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h @@ -43,6 +43,12 @@ extern "C" */ struct GNUNET_DHT_Handle; +/** + * Iterator called on each result obtained from a generic route + * operation + */ +typedef void (*GNUNET_DHT_MessageCallback)(void *cls, + int code); /** * Initialize the connection with the DHT service. @@ -87,14 +93,14 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *h); * @param cont_cls closure for cont */ void -GNUNET_DHT_put (struct GNUNET_DHT_Handle *h, +GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key, uint32_t type, uint32_t size, const char *data, struct GNUNET_TIME_Absolute exp, struct GNUNET_TIME_Relative timeout, - GNUNET_SCHEDULER_Task cont, + GNUNET_DHT_MessageCallback cont, void *cont_cls); @@ -105,8 +111,8 @@ struct GNUNET_DHT_GetHandle; /** - * Iterator called on each result obtained for a GET - * operation. + * Iterator called on each result obtained for a DHT + * operation that expects a reply * * @param cls closure * @param exp when will this value expire @@ -115,7 +121,7 @@ struct GNUNET_DHT_GetHandle; * @param size number of bytes in data * @param data pointer to the result data */ -typedef void (*GNUNET_DHT_Iterator)(void *cls, +typedef void (*GNUNET_DHT_GetIterator)(void *cls, struct GNUNET_TIME_Absolute exp, const GNUNET_HashCode * key, uint32_t type, @@ -128,17 +134,20 @@ typedef void (*GNUNET_DHT_Iterator)(void *cls, * Perform an asynchronous GET operation on the DHT identified. * * @param h handle to the DHT service + * @param timeout timeout for this request to be sent to the + * service * @param type expected type of the response object * @param key the key to look up * @param iter function to call on each result * @param iter_cls closure for iter * @return handle to stop the async get, NULL on error */ -struct GNUNET_DHT_GetHandle * +struct GNUNET_DHT_RouteHandle * GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, + struct GNUNET_TIME_Relative timeout, uint32_t type, const GNUNET_HashCode * key, - GNUNET_DHT_Iterator iter, + GNUNET_DHT_GetIterator iter, void *iter_cls); /** @@ -147,22 +156,29 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *h, * @param get_handle GET operation to stop. */ void -GNUNET_DHT_get_stop (struct GNUNET_DHT_GetHandle *get_handle); +GNUNET_DHT_get_stop (struct GNUNET_DHT_RouteHandle *get_handle); /** - * Iterator called on each result obtained from a FIND_PEER + * Iterator called on each result obtained from a find peer * operation * * @param cls closure - * @param peer a peer that was located - * @param reply response generated by the peer (for example, a HELLO); or NULL + * @param reply response */ -typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, +typedef void (*GNUNET_DHT_FindPeerProcessor)(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *reply); +/** + * Iterator called on each result obtained from a generic route + * operation + */ +typedef void (*GNUNET_DHT_ReplyProcessor)(void *cls, + const struct GNUNET_MessageHeader *reply); + + /** * Options for routing. */ @@ -180,6 +196,10 @@ enum GNUNET_DHT_RouteOption GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE = 1 }; +/** + * Handle to control a route operation. + */ +struct GNUNET_DHT_RouteHandle; /** * Perform an asynchronous FIND_PEER operation on the DHT. @@ -195,13 +215,12 @@ enum GNUNET_DHT_RouteOption * @param iter_cls closure for iter * @param timeout when to abort with an error if we fail to get * a confirmation for the PUT from the local DHT service - * @param cont continuation to call when done; - * reason will be TIMEOUT on error, - * reason will be PREREQ_DONE on success + * @param cont continuation to call when done, GNUNET_SYSERR if failed + * GNUNET_OK otherwise * @param cont_cls closure for cont * @return handle to stop the request */ -struct GNUNET_DHT_FindPeerHandle * +struct GNUNET_DHT_RouteHandle * GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode *key, unsigned int desired_replication_level, @@ -210,11 +229,11 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, struct GNUNET_TIME_Relative timeout, GNUNET_DHT_ReplyProcessor iter, void *iter_cls, - GNUNET_SCHEDULER_Task cont, + GNUNET_DHT_MessageCallback cont, void *cont_cls); void -GNUNET_DHT_route_stop (struct GNUNET_DHT_FindPeerHandle *fph); +GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *fph); #if 0 /* keep Emacsens' auto-indent happy */ diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index f5ce449ce..564ad8182 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -489,40 +489,49 @@ extern "C" */ /** - * Local DHT Get message, from API to service + * Local and P2P generic DHT message start type */ -#define GNUNET_MESSAGE_TYPE_DHT_GET 143 +#define GNUNET_MESSAGE_TYPE_DHT 142 /** - * Local DHT Get stop message, from API to service + * Local and P2P generic DHT message stop type */ -#define GNUNET_MESSAGE_TYPE_DHT_GET_STOP 144 +#define GNUNET_MESSAGE_TYPE_DHT_STOP 143 + +/** + * Local and message acknowledgment + */ +#define GNUNET_MESSAGE_TYPE_DHT_ACK 145 /** * Local DHT Get message, from API to service */ -#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER 145 +#define GNUNET_MESSAGE_TYPE_DHT_GET 146 /** * Local DHT Get stop message, from API to service */ -#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_STOP 146 +#define GNUNET_MESSAGE_TYPE_DHT_GET_STOP 147 /** - * Local DHT Put message, from API to service + * Local DHT Get message, from API to service */ -#define GNUNET_MESSAGE_TYPE_DHT_PUT 147 +#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER 148 /** - * Local DHT Get result message, from service to API + * Local DHT Get stop message, from API to service */ -#define GNUNET_MESSAGE_TYPE_DHT_GET_RESULT 149 +#define GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_STOP 149 /** - * Local DHT Put result message, from service to API + * Local DHT Put message, from API to service */ -#define GNUNET_MESSAGE_TYPE_DHT_PUT_RESULT 151 +#define GNUNET_MESSAGE_TYPE_DHT_PUT 150 +/** + * Local DHT Get result message, from service to API + */ +#define GNUNET_MESSAGE_TYPE_DHT_GET_RESULT 151 /**