aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2013-06-03 10:53:49 +0000
committerFlorian Dold <florian.dold@gmail.com>2013-06-03 10:53:49 +0000
commit68403fa780bf94ace2ebc13c2c09463cbbc0b57c (patch)
tree3442e4f25de90eab67c4f9813cb6e433c50b7482 /src/include
parentfae7f583f2e11cac15fefcbefef64287ab6915d3 (diff)
downloadgnunet-68403fa780bf94ace2ebc13c2c09463cbbc0b57c.tar.gz
gnunet-68403fa780bf94ace2ebc13c2c09463cbbc0b57c.zip
- conclude for SET
- consensus with SET
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_consensus_service.h27
-rw-r--r--src/include/gnunet_mq_lib.h89
-rw-r--r--src/include/gnunet_protocols.h34
-rw-r--r--src/include/gnunet_set_service.h27
4 files changed, 79 insertions, 98 deletions
diff --git a/src/include/gnunet_consensus_service.h b/src/include/gnunet_consensus_service.h
index 66d48e0e2..db7509976 100644
--- a/src/include/gnunet_consensus_service.h
+++ b/src/include/gnunet_consensus_service.h
@@ -39,28 +39,7 @@ extern "C"
39#include "gnunet_common.h" 39#include "gnunet_common.h"
40#include "gnunet_time_lib.h" 40#include "gnunet_time_lib.h"
41#include "gnunet_configuration_lib.h" 41#include "gnunet_configuration_lib.h"
42 42#include "gnunet_set_service.h"
43
44/**
45 * An element of the consensus set.
46 */
47struct GNUNET_CONSENSUS_Element
48{
49 /**
50 * The actual data of the element.
51 */
52 const void *data;
53
54 /**
55 * Size of the element's data.
56 */
57 uint16_t size;
58
59 /**
60 * Application specific element type
61 */
62 uint16_t type;
63};
64 43
65 44
66/** 45/**
@@ -73,7 +52,7 @@ struct GNUNET_CONSENSUS_Element
73 * @param element new element, NULL on error 52 * @param element new element, NULL on error
74 */ 53 */
75typedef void (*GNUNET_CONSENSUS_ElementCallback) (void *cls, 54typedef void (*GNUNET_CONSENSUS_ElementCallback) (void *cls,
76 const struct GNUNET_CONSENSUS_Element *element); 55 const struct GNUNET_SET_Element *element);
77 56
78 57
79 58
@@ -138,7 +117,7 @@ typedef void (*GNUNET_CONSENSUS_InsertDoneCallback) (void *cls,
138 */ 117 */
139void 118void
140GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus, 119GNUNET_CONSENSUS_insert (struct GNUNET_CONSENSUS_Handle *consensus,
141 const struct GNUNET_CONSENSUS_Element *element, 120 const struct GNUNET_SET_Element *element,
142 GNUNET_CONSENSUS_InsertDoneCallback idc, 121 GNUNET_CONSENSUS_InsertDoneCallback idc,
143 void *idc_cls); 122 void *idc_cls);
144 123
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index 59b692cf0..54ea806a5 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -53,36 +53,6 @@
53 */ 53 */
54#define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra(mvar, 0, type) 54#define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra(mvar, 0, type)
55 55
56/**
57 * Append data to the end of an existing MQ message.
58 * If the operation is successful, mqm is changed to point to the new MQ message,
59 * and GNUNET_OK is returned.
60 * On failure, GNUNET_SYSERR is returned, and the pointer mqm is not changed,
61 * the user of this API must take care of disposing the already allocated message
62 * (either by sending it, or by using GNUNET_MQ_discard)
63 *
64 * @param mqm MQ message to augment with additional data
65 * @param src source buffer for the additional data
66 * @param len length of the additional data
67 * @return GNUNET_SYSERR if nesting the message failed,
68 * GNUNET_OK on success
69 */
70#define GNUNET_MQ_nest(mqm, src, len) GNUNET_MQ_nest_ (&mqm, src, len)
71
72
73/**
74 * Append a message to the end of an existing MQ message.
75 * If the operation is successful, mqm is changed to point to the new MQ message,
76 * and GNUNET_OK is returned.
77 * On failure, GNUNET_SYSERR is returned, and the pointer mqm is not changed,
78 * the user of this API must take care of disposing the already allocated message
79 * (either by sending it, or by using GNUNET_MQ_discard)
80 *
81 * @param mqm MQ message to augment with additional data
82 * @param mh the message to append, must be of type 'struct GNUNET_MessageHeader *'
83 */
84#define GNUNET_MQ_nest_mh(mqm, mh) ((NULL == mh) ? (GNUNET_OK) : GNUNET_MQ_nest((mqm), (mh), ntohs ((mh)->size)))
85
86 56
87/** 57/**
88 * Allocate a GNUNET_MQ_Message, where the message only consists of a header. 58 * Allocate a GNUNET_MQ_Message, where the message only consists of a header.
@@ -105,6 +75,40 @@
105 75
106 76
107/** 77/**
78 * Allocate a GNUNET_MQ_Message, and append a payload message after the given
79 * message struct.
80 *
81 * @param mvar pointer to a message struct, will be changed to point at the newly allocated message,
82 * whose size is 'sizeof(*mvar) + ntohs (mh->size)'
83 * @param type message type of the allocated message, has no effect on the nested message
84 * @param mh message to nest
85 * @return a newly allocated 'struct GNUNET_MQ_Message *'
86 */
87#define GNUNET_MQ_msg_nested_mh(mvar, type, mh) GNUNET_MQ_msg_nested_mh_((((void)(mvar)->header), (struct GNUNET_MessageHeader**) &(mvar)), sizeof (*(mvar)), (type), mh)
88
89
90/**
91 * Return a pointer to the message at the end of the given message.
92 *
93 * @param var pointer to a message struct, the type of the expression determines the base size,
94 * the space after the base size is the nested message
95 * @return a 'struct GNUNET_MessageHeader *' that points at the nested message of the given message,
96 * or NULL if the given message in 'var' does not have any space after the message struct
97 */
98#define GNUNET_MQ_extract_nested_mh(var) GNUNET_MQ_extract_nested_mh_ ((struct GNUNET_MessageHeader *) (var), sizeof (*(var)))
99
100
101struct GNUNET_MessageHeader *
102GNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh, uint16_t base_size);
103
104
105struct GNUNET_MQ_Message *
106GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, uint16_t base_size, uint16_t type,
107 const struct GNUNET_MessageHeader *nested_mh);
108
109
110
111/**
108 * End-marker for the handlers array 112 * End-marker for the handlers array
109 */ 113 */
110#define GNUNET_MQ_HANDLERS_END {NULL, 0, 0} 114#define GNUNET_MQ_HANDLERS_END {NULL, 0, 0}
@@ -128,7 +132,8 @@ enum GNUNET_MQ_Error
128 * @param cls closure 132 * @param cls closure
129 * @param msg the received message 133 * @param msg the received message
130 */ 134 */
131typedef void (*GNUNET_MQ_MessageCallback) (void *cls, const struct GNUNET_MessageHeader *msg); 135typedef void
136(*GNUNET_MQ_MessageCallback) (void *cls, const struct GNUNET_MessageHeader *msg);
132 137
133 138
134/** 139/**
@@ -151,10 +156,12 @@ typedef void
151 * 156 *
152 * @param cls closure 157 * @param cls closure
153 */ 158 */
154typedef void (*GNUNET_MQ_NotifyCallback) (void *cls); 159typedef void
160(*GNUNET_MQ_NotifyCallback) (void *cls);
155 161
156 162
157typedef void (*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error); 163typedef void
164(*GNUNET_MQ_ErrorHandler) (void *cls, enum GNUNET_MQ_Error error);
158 165
159 166
160struct GNUNET_MQ_Message 167struct GNUNET_MQ_Message
@@ -287,6 +294,7 @@ struct GNUNET_MQ_Handler
287}; 294};
288 295
289 296
297
290/** 298/**
291 * Create a new message for MQ. 299 * Create a new message for MQ.
292 * 300 *
@@ -300,21 +308,6 @@ GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type)
300 308
301 309
302/** 310/**
303 * Resize the the mq message pointed to by mqmp,
304 * and append the given data to it.
305 *
306 * @param mqmp pointer to a mq message pointer
307 * @param src source of the data to append
308 * @param len length of the data to append
309 * @return GNUNET_OK on success,
310 * GNUNET_SYSERR on error (e.g. if len is too large)
311 */
312int
313GNUNET_MQ_nest_ (struct GNUNET_MQ_Message **mqmp,
314 const void *src, uint16_t len);
315
316
317/**
318 * Discard the message queue message, free all 311 * Discard the message queue message, free all
319 * allocated resources. Must be called in the event 312 * allocated resources. Must be called in the event
320 * that a message is created but should not actually be sent. 313 * that a message is created but should not actually be sent.
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 15bbae2e8..85c643f7d 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1754,11 +1754,18 @@ extern "C"
1754 */ 1754 */
1755#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ABORT 548 1755#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ABORT 548
1756 1756
1757/**
1758 * Abort a round, don't send requested elements anymore
1759 */
1760#define GNUNET_MESSAGE_TYPE_CONSENSUS_P2P_ROUND_CONTEXT 547
1761
1757 1762
1758/******************************************************************************* 1763/*******************************************************************************
1759 * SET message types 1764 * SET message types
1760 ******************************************************************************/ 1765 ******************************************************************************/
1761 1766
1767#define GNUNET_MESSAGE_TYPE_SET_REJECT 569
1768
1762/** 1769/**
1763 * Cancel a set operation 1770 * Cancel a set operation
1764 */ 1771 */
@@ -1800,44 +1807,49 @@ extern "C"
1800#define GNUNET_MESSAGE_TYPE_SET_EVALUATE 577 1807#define GNUNET_MESSAGE_TYPE_SET_EVALUATE 577
1801 1808
1802/** 1809/**
1803 * Evaluate a set operation 1810 * Start a set operation with the given set
1811 */
1812#define GNUNET_MESSAGE_TYPE_SET_CONCLUDE 578
1813
1814/**
1815 * Notify the client of a request from a remote peer
1804 */ 1816 */
1805#define GNUNET_MESSAGE_TYPE_SET_REQUEST 578 1817#define GNUNET_MESSAGE_TYPE_SET_REQUEST 579
1806 1818
1807/** 1819/**
1808 * Evaluate a set operation. 1820 * Create a new local set
1809 */ 1821 */
1810#define GNUNET_MESSAGE_TYPE_SET_CREATE 579 1822#define GNUNET_MESSAGE_TYPE_SET_CREATE 580
1811 1823
1812/** 1824/**
1813 * Evaluate a set operation. 1825 * Request a set operation from a remote peer.
1814 */ 1826 */
1815#define GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 580 1827#define GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST 581
1816 1828
1817/** 1829/**
1818 * Strata estimator. 1830 * Strata estimator.
1819 */ 1831 */
1820#define GNUNET_MESSAGE_TYPE_SET_P2P_SE 581 1832#define GNUNET_MESSAGE_TYPE_SET_P2P_SE 582
1821 1833
1822/** 1834/**
1823 * Invertible bloom filter. 1835 * Invertible bloom filter.
1824 */ 1836 */
1825#define GNUNET_MESSAGE_TYPE_SET_P2P_IBF 582 1837#define GNUNET_MESSAGE_TYPE_SET_P2P_IBF 583
1826 1838
1827/** 1839/**
1828 * Actual set elements. 1840 * Actual set elements.
1829 */ 1841 */
1830#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS 583 1842#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS 584
1831 1843
1832/** 1844/**
1833 * Requests for the elements with the given hashes. 1845 * Requests for the elements with the given hashes.
1834 */ 1846 */
1835#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS 584 1847#define GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS 585
1836 1848
1837/** 1849/**
1838 * Operation is done. 1850 * Operation is done.
1839 */ 1851 */
1840#define GNUNET_MESSAGE_TYPE_SET_P2P_DONE 585 1852#define GNUNET_MESSAGE_TYPE_SET_P2P_DONE 586
1841 1853
1842 1854
1843 1855
diff --git a/src/include/gnunet_set_service.h b/src/include/gnunet_set_service.h
index ce413c0de..2684df00a 100644
--- a/src/include/gnunet_set_service.h
+++ b/src/include/gnunet_set_service.h
@@ -257,11 +257,10 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set);
257 257
258 258
259/** 259/**
260 * Evaluate a set operation with our set and the set of another peer. 260 * Create a set operation for evaluation with another peer.
261 * The evaluation will not start until the client provides
262 * a local set with GNUNET_SET_conclude.
261 * 263 *
262 * @param set set to use -- FIXME: remove
263 * this argument, use GNUNET_SET_conclude instead!
264 * @param salt salt for HKDF (explain more here)
265 * @param other_peer peer with the other set 264 * @param other_peer peer with the other set
266 * @param app_id hash for the application using the set 265 * @param app_id hash for the application using the set
267 * @param context_msg additional information for the request 266 * @param context_msg additional information for the request
@@ -275,8 +274,7 @@ GNUNET_SET_destroy (struct GNUNET_SET_Handle *set);
275 * @return a handle to cancel the operation 274 * @return a handle to cancel the operation
276 */ 275 */
277struct GNUNET_SET_OperationHandle * 276struct GNUNET_SET_OperationHandle *
278GNUNET_SET_evaluate (struct GNUNET_SET_Handle *set, 277GNUNET_SET_evaluate (const struct GNUNET_PeerIdentity *other_peer,
279 const struct GNUNET_PeerIdentity *other_peer,
280 const struct GNUNET_HashCode *app_id, 278 const struct GNUNET_HashCode *app_id,
281 const struct GNUNET_MessageHeader *context_msg, 279 const struct GNUNET_MessageHeader *context_msg,
282 uint16_t salt, 280 uint16_t salt,
@@ -315,13 +313,13 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh);
315 313
316 314
317/** 315/**
318 * Accept a request we got via GNUNET_SET_listen. Must be called 316 * Accept a request we got via GNUNET_SET_listen. Must be called during
319 * during GNUNET_SET_listen, as the 'struct GNUNET_SET_Request' 317 * GNUNET_SET_listen, as the 'struct GNUNET_SET_Request' becomes invalid
320 * becomes invalid afterwards. 318 * afterwards.
319 * Call GNUNET_SET_conclude to provide the local set to use for the operation,
320 * and to begin the exchange with the remote peer.
321 * 321 *
322 * @param request request to accept 322 * @param request request to accept
323 * @param set set used for the requested operation -- FIXME: remove
324 * this argument, use GNUNET_SET_conclude instead!
325 * @param result_mode specified how results will be returned, 323 * @param result_mode specified how results will be returned,
326 * see 'GNUNET_SET_ResultMode'. 324 * see 'GNUNET_SET_ResultMode'.
327 * @param result_cb callback for the results 325 * @param result_cb callback for the results
@@ -330,7 +328,6 @@ GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh);
330 */ 328 */
331struct GNUNET_SET_OperationHandle * 329struct GNUNET_SET_OperationHandle *
332GNUNET_SET_accept (struct GNUNET_SET_Request *request, 330GNUNET_SET_accept (struct GNUNET_SET_Request *request,
333 struct GNUNET_SET_Handle *set,
334 enum GNUNET_SET_ResultMode result_mode, 331 enum GNUNET_SET_ResultMode result_mode,
335 GNUNET_SET_ResultIterator result_cb, 332 GNUNET_SET_ResultIterator result_cb,
336 void *cls); 333 void *cls);
@@ -353,9 +350,9 @@ GNUNET_SET_conclude (struct GNUNET_SET_OperationHandle *oh,
353 350
354 351
355/** 352/**
356 * Cancel the given set operation. FIXME: do clients have 353 * Cancel the given set operation.
357 * to cancel the operatino if the GNUNET_SET_ResultIterator 354 * May not be called after the operation's GNUNET_SET_ResultIterator has been
358 * has been called with timeout/error/done? 355 * called with a status that indicates error, timeout or done.
359 * 356 *
360 * @param oh set operation to cancel 357 * @param oh set operation to cancel
361 */ 358 */