diff options
-rw-r--r-- | src/set/gnunet-service-set_intersection.h | 79 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.h | 239 |
2 files changed, 318 insertions, 0 deletions
diff --git a/src/set/gnunet-service-set_intersection.h b/src/set/gnunet-service-set_intersection.h new file mode 100644 index 000000000..3bd255142 --- /dev/null +++ b/src/set/gnunet-service-set_intersection.h | |||
@@ -0,0 +1,79 @@ | |||
1 | |||
2 | /* | ||
3 | This file is part of GNUnet | ||
4 | Copyright (C) 2013-2017 GNUnet e.V. | ||
5 | |||
6 | GNUnet is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published | ||
8 | by the Free Software Foundation; either version 3, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | GNUnet is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNUnet; see the file COPYING. If not, write to the | ||
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | ||
20 | */ | ||
21 | /** | ||
22 | * @file set/gnunet-service-set_intersection.h | ||
23 | * @brief two-peer set operations | ||
24 | * @author Florian Dold | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_SET_INTERSECTION_H | ||
28 | #define GNUNET_SERVICE_SET_INTERSECTION_H | ||
29 | |||
30 | #include "gnunet-service-set.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Check an BF message from a remote peer. | ||
35 | * | ||
36 | * @param cls the intersection operation | ||
37 | * @param msg the header of the message | ||
38 | * @return #GNUNET_OK if @a msg is well-formed | ||
39 | */ | ||
40 | int | ||
41 | check_intersection_p2p_bf (void *cls, | ||
42 | const struct BFMessage *msg); | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Handle an BF message from a remote peer. | ||
47 | * | ||
48 | * @param cls the intersection operation | ||
49 | * @param msg the header of the message | ||
50 | */ | ||
51 | void | ||
52 | handle_intersection_p2p_bf (void *cls, | ||
53 | const struct BFMessage *msg); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Handle the initial `struct IntersectionElementInfoMessage` from a | ||
58 | * remote peer. | ||
59 | * | ||
60 | * @param cls the intersection operation | ||
61 | * @param mh the header of the message | ||
62 | */ | ||
63 | void | ||
64 | handle_intersection_p2p_element_info (void *cls, | ||
65 | const struct IntersectionElementInfoMessage *msg); | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Handle a done message from a remote peer | ||
70 | * | ||
71 | * @param cls the intersection operation | ||
72 | * @param mh the message | ||
73 | */ | ||
74 | void | ||
75 | handle_intersection_p2p_done (void *cls, | ||
76 | const struct IntersectionDoneMessage *idm); | ||
77 | |||
78 | |||
79 | #endif | ||
diff --git a/src/set/gnunet-service-set_union.h b/src/set/gnunet-service-set_union.h new file mode 100644 index 000000000..cbf60bcbc --- /dev/null +++ b/src/set/gnunet-service-set_union.h | |||
@@ -0,0 +1,239 @@ | |||
1 | |||
2 | /* | ||
3 | This file is part of GNUnet | ||
4 | Copyright (C) 2013-2017 GNUnet e.V. | ||
5 | |||
6 | GNUnet is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published | ||
8 | by the Free Software Foundation; either version 3, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | GNUnet is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNUnet; see the file COPYING. If not, write to the | ||
18 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | ||
20 | */ | ||
21 | /** | ||
22 | * @file set/gnunet-service-set_union.h | ||
23 | * @brief two-peer set operations | ||
24 | * @author Florian Dold | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #ifndef GNUNET_SERVICE_SET_UNION_H | ||
28 | #define GNUNET_SERVICE_SET_UNION_H | ||
29 | |||
30 | #include "gnunet-service-set.h" | ||
31 | #include "gnunet-service-set_protocol.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Handle a strata estimator from a remote peer | ||
36 | * | ||
37 | * @param cls the union operation | ||
38 | * @param msg the message | ||
39 | */ | ||
40 | int | ||
41 | check_union_p2p_strata_estimator (void *cls, | ||
42 | const struct StrataEstimatorMessage *msg); | ||
43 | |||
44 | |||
45 | /** | ||
46 | * Handle a strata estimator from a remote peer | ||
47 | * | ||
48 | * @param cls the union operation | ||
49 | * @param msg the message | ||
50 | */ | ||
51 | void | ||
52 | handle_union_p2p_strata_estimator (void *cls, | ||
53 | const struct StrataEstimatorMessage *msg); | ||
54 | |||
55 | |||
56 | /** | ||
57 | * Check an IBF message from a remote peer. | ||
58 | * | ||
59 | * Reassemble the IBF from multiple pieces, and | ||
60 | * process the whole IBF once possible. | ||
61 | * | ||
62 | * @param cls the union operation | ||
63 | * @param msg the header of the message | ||
64 | * @return #GNUNET_OK if @a msg is well-formed | ||
65 | */ | ||
66 | int | ||
67 | check_union_p2p_ibf (void *cls, | ||
68 | const struct IBFMessage *msg); | ||
69 | |||
70 | |||
71 | /** | ||
72 | * Handle an IBF message from a remote peer. | ||
73 | * | ||
74 | * Reassemble the IBF from multiple pieces, and | ||
75 | * process the whole IBF once possible. | ||
76 | * | ||
77 | * @param cls the union operation | ||
78 | * @param msg the header of the message | ||
79 | */ | ||
80 | void | ||
81 | handle_union_p2p_ibf (void *cls, | ||
82 | const struct IBFMessage *msg); | ||
83 | |||
84 | |||
85 | /** | ||
86 | * Check an element message from a remote peer. | ||
87 | * | ||
88 | * @param cls the union operation | ||
89 | * @param emsg the message | ||
90 | */ | ||
91 | int | ||
92 | check_union_p2p_elements (void *cls, | ||
93 | const struct GNUNET_SET_ElementMessage *emsg); | ||
94 | |||
95 | |||
96 | /** | ||
97 | * Handle an element message from a remote peer. | ||
98 | * Sent by the other peer either because we decoded an IBF and placed a demand, | ||
99 | * or because the other peer switched to full set transmission. | ||
100 | * | ||
101 | * @param cls the union operation | ||
102 | * @param emsg the message | ||
103 | */ | ||
104 | void | ||
105 | handle_union_p2p_elements (void *cls, | ||
106 | const struct GNUNET_SET_ElementMessage *emsg); | ||
107 | |||
108 | |||
109 | /** | ||
110 | * Check a full element message from a remote peer. | ||
111 | * | ||
112 | * @param cls the union operation | ||
113 | * @param emsg the message | ||
114 | */ | ||
115 | int | ||
116 | check_union_p2p_full_element (void *cls, | ||
117 | const struct GNUNET_SET_ElementMessage *emsg); | ||
118 | |||
119 | |||
120 | /** | ||
121 | * Handle an element message from a remote peer. | ||
122 | * | ||
123 | * @param cls the union operation | ||
124 | * @param emsg the message | ||
125 | */ | ||
126 | void | ||
127 | handle_union_p2p_full_element (void *cls, | ||
128 | const struct GNUNET_SET_ElementMessage *emsg); | ||
129 | |||
130 | |||
131 | /** | ||
132 | * Send offers (for GNUNET_Hash-es) in response | ||
133 | * to inquiries (for IBF_Key-s). | ||
134 | * | ||
135 | * @param cls the union operation | ||
136 | * @param msg the message | ||
137 | */ | ||
138 | int | ||
139 | check_union_p2p_inquiry (void *cls, | ||
140 | const struct InquiryMessage *msg); | ||
141 | |||
142 | |||
143 | /** | ||
144 | * Send offers (for GNUNET_Hash-es) in response | ||
145 | * to inquiries (for IBF_Key-s). | ||
146 | * | ||
147 | * @param cls the union operation | ||
148 | * @param msg the message | ||
149 | */ | ||
150 | void | ||
151 | handle_union_p2p_inquiry (void *cls, | ||
152 | const struct InquiryMessage *msg); | ||
153 | |||
154 | |||
155 | |||
156 | /** | ||
157 | * Handle a request for full set transmission. | ||
158 | * | ||
159 | * @parem cls closure, a set union operation | ||
160 | * @param mh the demand message | ||
161 | */ | ||
162 | void | ||
163 | handle_union_p2p_request_full (void *cls, | ||
164 | const struct GNUNET_MessageHeader *mh); | ||
165 | |||
166 | |||
167 | |||
168 | /** | ||
169 | * Handle a "full done" message. | ||
170 | * | ||
171 | * @parem cls closure, a set union operation | ||
172 | * @param mh the demand message | ||
173 | */ | ||
174 | void | ||
175 | handle_union_p2p_full_done (void *cls, | ||
176 | const struct GNUNET_MessageHeader *mh); | ||
177 | |||
178 | |||
179 | /** | ||
180 | * Check a demand by the other peer for elements based on a list | ||
181 | * of `struct GNUNET_HashCode`s. | ||
182 | * | ||
183 | * @parem cls closure, a set union operation | ||
184 | * @param mh the demand message | ||
185 | * @return #GNUNET_OK if @a mh is well-formed | ||
186 | */ | ||
187 | int | ||
188 | check_union_p2p_demand (void *cls, | ||
189 | const struct GNUNET_MessageHeader *mh); | ||
190 | |||
191 | |||
192 | /** | ||
193 | * Handle a demand by the other peer for elements based on a list | ||
194 | * of `struct GNUNET_HashCode`s. | ||
195 | * | ||
196 | * @parem cls closure, a set union operation | ||
197 | * @param mh the demand message | ||
198 | */ | ||
199 | void | ||
200 | handle_union_p2p_demand (void *cls, | ||
201 | const struct GNUNET_MessageHeader *mh); | ||
202 | |||
203 | |||
204 | /** | ||
205 | * Check offer (of `struct GNUNET_HashCode`s). | ||
206 | * | ||
207 | * @param cls the union operation | ||
208 | * @param mh the message | ||
209 | * @return #GNUNET_OK if @a mh is well-formed | ||
210 | */ | ||
211 | int | ||
212 | check_union_p2p_offer (void *cls, | ||
213 | const struct GNUNET_MessageHeader *mh); | ||
214 | |||
215 | |||
216 | /** | ||
217 | * Handle offers (of `struct GNUNET_HashCode`s) and | ||
218 | * respond with demands (of `struct GNUNET_HashCode`s). | ||
219 | * | ||
220 | * @param cls the union operation | ||
221 | * @param mh the message | ||
222 | */ | ||
223 | void | ||
224 | handle_union_p2p_offer (void *cls, | ||
225 | const struct GNUNET_MessageHeader *mh); | ||
226 | |||
227 | |||
228 | /** | ||
229 | * Handle a done message from a remote peer | ||
230 | * | ||
231 | * @param cls the union operation | ||
232 | * @param mh the message | ||
233 | */ | ||
234 | void | ||
235 | handle_union_p2p_done (void *cls, | ||
236 | const struct GNUNET_MessageHeader *mh); | ||
237 | |||
238 | |||
239 | #endif | ||