1 // FIXME: copyright, etc.
4 * The operation that a set set supports.
6 enum GNUNET_SET_Operation
9 * Set intersection, only return elements that are in both sets.
11 GNUNET_SET_OPERATION_INTERSECTION,
13 * Set union, return all elements that are in at least one of the sets.
15 GNUNET_SET_OPERATION_UNION
19 * Status for the result callback
21 enum GNUNET_SET_Status
28 * There was a timeout.
30 GNUNET_SET_STATUS_TIMEOUT,
32 * The other peer refused to to the operation with us
34 GNUNET_SET_STATUS_REFUSED
38 struct GNUNET_SET_Element
41 * Number of bytes in the buffer pointed to by data.
45 * Application-specific element type.
49 * Actual data of the element
56 * Create an empty set, supporting the specified operation.
58 * @param op operation supported by the set
59 * Note that the operation has to be specified
60 * beforehand, as certain set operations need to maintain
61 * data structures spefific to the operation
62 * @return a handle to the set
64 struct GNUNET_SET_Handle *
65 GNUNET_SET_create (enum GNUNET_SET_Operation op);
70 GNUNET_SET_add_element (struct GNUNET_SET_Handle *set,
71 const struct GNUNET_SET_Element *element,
72 GNUNET_SET_Continuation cont,
78 GNUNET_SET_remove_element (struct GNUNET_SET_Handle *set,
79 const struct GNUNET_SET_Element *element,
80 GNUNET_SET_Continuation cont,
85 struct GNUNET_SET_Handle *
86 GNUNET_SET_clone (struct GNUNET_SET_Handle *set);
91 GNUNET_SET_destroy (struct GNUNET_SET_Handle *set);
96 * Callback for set operation results. Called for each element
98 // FIXME: might want a way to just get the 'additional/removd' elements
101 * @param element element, or NULL to indicate that all elements
102 * have been passed to the callback
103 * Only valid if (status==GNUNET_SET_STATUS_OK) holds.
104 * @param status see enum GNUNET_SET_Status
107 (*GNUNET_SET_ResultIterator) (void *cls,
108 struct GNUNET_SET_Element *element,
109 enum GNUNET_SET_ResultStatus status);
113 * Evaluate a set operation with our set and the set of another peer.
115 * @param other_peer peer with the other set
116 * @param app_id hash for the application using the set
117 * @param context_msg additional information for the request
118 * @param result_cb called on error or success
119 * @param result_cls closure for result_cb
120 * @return a handle to cancel the operation
122 struct GNUNET_SET_OperationHandle *
123 GNUNET_SET_evaluate (const struct GNUNET_PeerIdentity *other_peer,
124 const struct GNUNET_HashCode *app_id,
125 const struct GNUNET_MessageHeader *context_msg,
126 struct GNUNET_TIME_Relative timeout,
127 GNUNET_SET_ResultIterator result_cb,
132 * Called when another peer wants to do a set operation with the
135 * @param other_peer the other peer
136 * @param context_msg message with application specific information from
138 * @param request request from the other peer, use GNUNET_SET_accept
139 * to accept it, otherwise the request will be refused
140 * Note that we don't use a return value here, as it is also
141 * necessary to specify the set we want to do the operation with,
142 * whith sometimes can be derived from the context message.
143 * Also necessary to specify the timeout.
146 (*GNUNET_SET_ListenCallback) (void *cls,
147 const struct GNUNET_PeerIdentity *other_peer,
148 const struct GNUNET_MessageHeader *context_msg,
149 struct GNUNET_SET_Request *request);
153 * Wait for set operation requests for the given application id
155 * @param operation operation we want to listen for
156 * @param app_id id of the application that handles set operation requests
157 * @param listen_cb called for each incoming request matching the operation
159 * @param listen_cls handle for listen_cb
160 * @return a handle that can be used to cancel the listen operation
162 struct GNUNET_SET_ListenHandle *
163 GNUNET_SET_listen (enum GNUNET_SET_Operation operation,
164 const struct GNUNET_HashCode *app_id,
165 GNUNET_SET_ListenCallback listen_cb,
172 GNUNET_SET_listen_cancel (struct GNUNET_SET_ListenHandle *lh);
176 * Accept a request we got via GNUNET_SET_listen
178 * @param request request to accept
179 * @param set set used for the requested operation
180 * @param timeout timeout for the set operation
181 * @param result_cb callback for the results
182 * @param cls closure for result_cb
184 struct GNUNET_SET_OperationHandle *
185 GNUNET_SET_accept (struct GNUNET_SET_Request *request,
186 struct GNUNET_SET_Handle *set,
187 struct GNUNET_TIME_Relative timeout,
188 GNUNET_SET_ResultIterator result_cb,
194 GNUNET_SET_operation_cancel (struct GNUNET_SET_OperationHandle *op);