diff options
-rw-r--r-- | src/include/gnunet_client_lib.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_protocols.h | 18 | ||||
-rw-r--r-- | src/include/gnunet_regex_service.h | 14 | ||||
-rw-r--r-- | src/regex/Makefile.am | 12 | ||||
-rw-r--r-- | src/regex/regex_api.c | 333 | ||||
-rw-r--r-- | src/regex/regex_ipc.h | 112 |
6 files changed, 483 insertions, 8 deletions
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index 51da46de6..8642dd941 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h | |||
@@ -84,7 +84,7 @@ GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *client); | |||
84 | */ | 84 | */ |
85 | typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls, | 85 | typedef void (*GNUNET_CLIENT_MessageHandler) (void *cls, |
86 | const struct GNUNET_MessageHeader | 86 | const struct GNUNET_MessageHeader |
87 | * msg); | 87 | *msg); |
88 | 88 | ||
89 | 89 | ||
90 | /** | 90 | /** |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 9325416ec..15bbae2e8 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -1881,7 +1881,23 @@ extern "C" | |||
1881 | #define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE 611 | 1881 | #define GNUNET_MESSAGE_TYPE_EXPERIMENTATION_RESPONSE 611 |
1882 | 1882 | ||
1883 | /** | 1883 | /** |
1884 | * Next available: 620 | 1884 | * Advertise regex capability. |
1885 | */ | ||
1886 | #define GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE 620 | ||
1887 | |||
1888 | /** | ||
1889 | * Search for peer with matching capability. | ||
1890 | */ | ||
1891 | #define GNUNET_MESSAGE_TYPE_REGEX_SEARCH 621 | ||
1892 | |||
1893 | /** | ||
1894 | * Result in response to regex search. | ||
1895 | */ | ||
1896 | #define GNUNET_MESSAGE_TYPE_REGEX_RESULT 622 | ||
1897 | |||
1898 | |||
1899 | /** | ||
1900 | * Next available: 624 | ||
1885 | */ | 1901 | */ |
1886 | 1902 | ||
1887 | 1903 | ||
diff --git a/src/include/gnunet_regex_service.h b/src/include/gnunet_regex_service.h index 57f98b19f..2a176f401 100644 --- a/src/include/gnunet_regex_service.h +++ b/src/include/gnunet_regex_service.h | |||
@@ -60,6 +60,7 @@ struct GNUNET_REGEX_Search; | |||
60 | * not free resources, must call GNUNET_REGEX_announce_cancel for | 60 | * not free resources, must call GNUNET_REGEX_announce_cancel for |
61 | * that. | 61 | * that. |
62 | * | 62 | * |
63 | * @param cfg configuration to use | ||
63 | * @param id ID to announce as provider of regex. Own ID in most cases. | 64 | * @param id ID to announce as provider of regex. Own ID in most cases. |
64 | * @param regex Regular expression to announce. | 65 | * @param regex Regular expression to announce. |
65 | * @param refresh_delay after what delay should the announcement be repeated? | 66 | * @param refresh_delay after what delay should the announcement be repeated? |
@@ -68,7 +69,8 @@ struct GNUNET_REGEX_Search; | |||
68 | * Must be freed by calling GNUNET_REGEX_announce_cancel. | 69 | * Must be freed by calling GNUNET_REGEX_announce_cancel. |
69 | */ | 70 | */ |
70 | struct GNUNET_REGEX_Announcement * | 71 | struct GNUNET_REGEX_Announcement * |
71 | GNUNET_REGEX_announce (const struct GNUNET_PeerIdentity *id, | 72 | GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, |
73 | const struct GNUNET_PeerIdentity *id, | ||
72 | const char *regex, | 74 | const char *regex, |
73 | struct GNUNET_TIME_Relative refresh_delay, | 75 | struct GNUNET_TIME_Relative refresh_delay, |
74 | uint16_t compression); | 76 | uint16_t compression); |
@@ -77,10 +79,10 @@ GNUNET_REGEX_announce (const struct GNUNET_PeerIdentity *id, | |||
77 | /** | 79 | /** |
78 | * Stop announcing the regex specified by the given handle. | 80 | * Stop announcing the regex specified by the given handle. |
79 | * | 81 | * |
80 | * @param h handle returned by a previous GNUNET_REGEX_announce call. | 82 | * @param a handle returned by a previous GNUNET_REGEX_announce call. |
81 | */ | 83 | */ |
82 | void | 84 | void |
83 | GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *h); | 85 | GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a); |
84 | 86 | ||
85 | 87 | ||
86 | /** | 88 | /** |
@@ -106,6 +108,7 @@ typedef void (*GNUNET_REGEX_Found)(void *cls, | |||
106 | * The search runs until GNUNET_REGEX_search_cancel is called, even if results | 108 | * The search runs until GNUNET_REGEX_search_cancel is called, even if results |
107 | * are returned. | 109 | * are returned. |
108 | * | 110 | * |
111 | * @param cfg configuration to use | ||
109 | * @param string String to match against the regexes in the DHT. | 112 | * @param string String to match against the regexes in the DHT. |
110 | * @param callback Callback for found peers. | 113 | * @param callback Callback for found peers. |
111 | * @param callback_cls Closure for @c callback. | 114 | * @param callback_cls Closure for @c callback. |
@@ -113,7 +116,8 @@ typedef void (*GNUNET_REGEX_Found)(void *cls, | |||
113 | * Must be freed by calling GNUNET_REGEX_search_cancel. | 116 | * Must be freed by calling GNUNET_REGEX_search_cancel. |
114 | */ | 117 | */ |
115 | struct GNUNET_REGEX_Search * | 118 | struct GNUNET_REGEX_Search * |
116 | GNUNET_REGEX_search (const char *string, | 119 | GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, |
120 | const char *string, | ||
117 | GNUNET_REGEX_Found callback, | 121 | GNUNET_REGEX_Found callback, |
118 | void *callback_cls); | 122 | void *callback_cls); |
119 | 123 | ||
@@ -124,7 +128,7 @@ GNUNET_REGEX_search (const char *string, | |||
124 | * @param h Handle returned by a previous GNUNET_REGEX_search call. | 128 | * @param h Handle returned by a previous GNUNET_REGEX_search call. |
125 | */ | 129 | */ |
126 | void | 130 | void |
127 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *h); | 131 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s); |
128 | 132 | ||
129 | 133 | ||
130 | #if 0 /* keep Emacsens' auto-indent happy */ | 134 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am index 4900e5e91..e88938054 100644 --- a/src/regex/Makefile.am +++ b/src/regex/Makefile.am | |||
@@ -9,7 +9,8 @@ if USE_COVERAGE | |||
9 | endif | 9 | endif |
10 | 10 | ||
11 | lib_LTLIBRARIES = libgnunetregexblock.la \ | 11 | lib_LTLIBRARIES = libgnunetregexblock.la \ |
12 | libgnunetregex.la | 12 | libgnunetregex.la \ |
13 | libgnunetregexnew.la | ||
13 | 14 | ||
14 | 15 | ||
15 | libgnunetregexblock_la_SOURCES = \ | 16 | libgnunetregexblock_la_SOURCES = \ |
@@ -38,6 +39,15 @@ libgnunetregex_la_LDFLAGS = \ | |||
38 | -version-info 2:0:1 | 39 | -version-info 2:0:1 |
39 | 40 | ||
40 | 41 | ||
42 | libgnunetregexnew_la_SOURCES = \ | ||
43 | regex_api.c regex_ipc.h | ||
44 | libgnunetregexnew_la_LIBADD = \ | ||
45 | $(top_builddir)/src/util/libgnunetutil.la | ||
46 | libgnunetregexnew_la_LDFLAGS = \ | ||
47 | $(GN_LIB_LDFLAGS) \ | ||
48 | -version-info 3:0:0 | ||
49 | |||
50 | |||
41 | plugindir = $(libdir)/gnunet | 51 | plugindir = $(libdir)/gnunet |
42 | 52 | ||
43 | plugin_LTLIBRARIES = \ | 53 | plugin_LTLIBRARIES = \ |
diff --git a/src/regex/regex_api.c b/src/regex/regex_api.c new file mode 100644 index 000000000..ec9ee0de8 --- /dev/null +++ b/src/regex/regex_api.c | |||
@@ -0,0 +1,333 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file include/gnunet_regex_service.h | ||
22 | * @brief access regex service to advertise capabilities via regex and discover | ||
23 | * respective peers using matching strings | ||
24 | * @author Maximilian Szengel | ||
25 | * @author Christian Grothoff | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet_protocols.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_regex_service.h" | ||
31 | #include "regex_ipc.h" | ||
32 | |||
33 | /** | ||
34 | * Handle to store cached data about a regex announce. | ||
35 | */ | ||
36 | struct GNUNET_REGEX_Announcement | ||
37 | { | ||
38 | /** | ||
39 | * Connection to the regex service. | ||
40 | */ | ||
41 | struct GNUNET_CLIENT_Connection *client; | ||
42 | |||
43 | /** | ||
44 | * Our configuration. | ||
45 | */ | ||
46 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
47 | |||
48 | /** | ||
49 | * Message we're sending to the service. | ||
50 | */ | ||
51 | struct AnnounceMessage msg; | ||
52 | }; | ||
53 | |||
54 | |||
55 | /** | ||
56 | * We got a response (!?) or disconnect after asking regex | ||
57 | * to do the announcement. Retry. | ||
58 | * | ||
59 | * @param cls the 'struct GNUNET_REGEX_Announcement' to retry | ||
60 | * @param msg NULL on disconnect | ||
61 | */ | ||
62 | static void | ||
63 | handle_a_reconnect (void *cls, | ||
64 | const struct GNUNET_MessageHeader *msg); | ||
65 | |||
66 | |||
67 | /** | ||
68 | * Try sending the announcement request to regex. On | ||
69 | * errors (i.e. regex died), try again. | ||
70 | * | ||
71 | * @param a the announcement to retry | ||
72 | */ | ||
73 | static void | ||
74 | retry_announcement (struct GNUNET_REGEX_Announcement *a) | ||
75 | { | ||
76 | GNUNET_assert (NULL != a->client); | ||
77 | GNUNET_assert (GNUNET_OK == | ||
78 | GNUNET_CLIENT_transmit_and_get_response (a->client, | ||
79 | &a->msg.header, | ||
80 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
81 | GNUNET_YES, | ||
82 | &handle_a_reconnect, | ||
83 | a)); | ||
84 | } | ||
85 | |||
86 | |||
87 | /** | ||
88 | * We got a response (!?) or disconnect after asking regex | ||
89 | * to do the announcement. Retry. | ||
90 | * | ||
91 | * @param cls the 'struct GNUNET_REGEX_Announcement' to retry | ||
92 | * @param msg NULL on disconnect | ||
93 | */ | ||
94 | static void | ||
95 | handle_a_reconnect (void *cls, | ||
96 | const struct GNUNET_MessageHeader *msg) | ||
97 | { | ||
98 | struct GNUNET_REGEX_Announcement *a = cls; | ||
99 | |||
100 | GNUNET_CLIENT_disconnect (a->client); | ||
101 | a->client = GNUNET_CLIENT_connect ("regex", a->cfg); | ||
102 | retry_announcement (a); | ||
103 | } | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Announce the given peer under the given regular expression. Does | ||
108 | * not free resources, must call GNUNET_REGEX_announce_cancel for | ||
109 | * that. | ||
110 | * | ||
111 | * @param cfg configuration to use | ||
112 | * @param id ID to announce as provider of regex. Own ID in most cases. | ||
113 | * @param regex Regular expression to announce. | ||
114 | * @param refresh_delay after what delay should the announcement be repeated? | ||
115 | * @param compression How many characters per edge can we squeeze? | ||
116 | * @return Handle to reuse o free cached resources. | ||
117 | * Must be freed by calling GNUNET_REGEX_announce_cancel. | ||
118 | */ | ||
119 | struct GNUNET_REGEX_Announcement * | ||
120 | GNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
121 | const struct GNUNET_PeerIdentity *id, | ||
122 | const char *regex, | ||
123 | struct GNUNET_TIME_Relative refresh_delay, | ||
124 | uint16_t compression) | ||
125 | { | ||
126 | struct GNUNET_REGEX_Announcement *a; | ||
127 | size_t slen; | ||
128 | |||
129 | slen = strlen (regex) + 1; | ||
130 | if (slen + sizeof (struct AnnounceMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | ||
131 | { | ||
132 | GNUNET_break (0); | ||
133 | return NULL; | ||
134 | } | ||
135 | a = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Announcement) + slen); | ||
136 | a->cfg = cfg; | ||
137 | a->client = GNUNET_CLIENT_connect ("regex", cfg); | ||
138 | if (NULL == a->client) | ||
139 | return NULL; | ||
140 | a->msg.header.type = htons (GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE); | ||
141 | a->msg.header.size = htons (slen + sizeof (struct AnnounceMessage)); | ||
142 | a->msg.compression = htons (compression); | ||
143 | a->msg.reserved = htons (0); | ||
144 | a->msg.refresh_delay = GNUNET_TIME_relative_hton (refresh_delay); | ||
145 | a->msg.pid = *id; | ||
146 | memcpy (&a[1], regex, slen); | ||
147 | retry_announcement (a); | ||
148 | return a; | ||
149 | } | ||
150 | |||
151 | |||
152 | /** | ||
153 | * Stop announcing the regex specified by the given handle. | ||
154 | * | ||
155 | * @param a handle returned by a previous GNUNET_REGEX_announce call. | ||
156 | */ | ||
157 | void | ||
158 | GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a) | ||
159 | { | ||
160 | GNUNET_CLIENT_disconnect (a->client); | ||
161 | GNUNET_free (a); | ||
162 | } | ||
163 | |||
164 | |||
165 | /** | ||
166 | * Handle to store data about a regex search. | ||
167 | */ | ||
168 | struct GNUNET_REGEX_Search | ||
169 | { | ||
170 | /** | ||
171 | * Connection to the regex service. | ||
172 | */ | ||
173 | struct GNUNET_CLIENT_Connection *client; | ||
174 | |||
175 | /** | ||
176 | * Our configuration. | ||
177 | */ | ||
178 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
179 | |||
180 | /** | ||
181 | * Function to call with results. | ||
182 | */ | ||
183 | GNUNET_REGEX_Found callback; | ||
184 | |||
185 | /** | ||
186 | * Closure for 'callback'. | ||
187 | */ | ||
188 | void *callback_cls; | ||
189 | |||
190 | /** | ||
191 | * Search message to transmit to the service. | ||
192 | */ | ||
193 | struct SearchMessage msg; | ||
194 | }; | ||
195 | |||
196 | |||
197 | /** | ||
198 | * We got a response or disconnect after asking regex | ||
199 | * to do the search. Handle it. | ||
200 | * | ||
201 | * @param cls the 'struct GNUNET_REGEX_Search' to retry | ||
202 | * @param msg NULL on disconnect | ||
203 | */ | ||
204 | static void | ||
205 | handle_search_response (void *cls, | ||
206 | const struct GNUNET_MessageHeader *msg); | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Try sending the search request to regex. On | ||
211 | * errors (i.e. regex died), try again. | ||
212 | * | ||
213 | * @param s the search to retry | ||
214 | */ | ||
215 | static void | ||
216 | retry_search (struct GNUNET_REGEX_Search *s) | ||
217 | { | ||
218 | GNUNET_assert (NULL != s->client); | ||
219 | GNUNET_assert (GNUNET_OK == | ||
220 | GNUNET_CLIENT_transmit_and_get_response (s->client, | ||
221 | &s->msg.header, | ||
222 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
223 | GNUNET_YES, | ||
224 | &handle_search_response, | ||
225 | s)); | ||
226 | } | ||
227 | |||
228 | |||
229 | /** | ||
230 | * We got a response or disconnect after asking regex | ||
231 | * to do the search. Handle it. | ||
232 | * | ||
233 | * @param cls the 'struct GNUNET_REGEX_Search' to retry | ||
234 | * @param msg NULL on disconnect, otherwise presumably a response | ||
235 | */ | ||
236 | static void | ||
237 | handle_search_response (void *cls, | ||
238 | const struct GNUNET_MessageHeader *msg) | ||
239 | { | ||
240 | struct GNUNET_REGEX_Search *s = cls; | ||
241 | const struct ResultMessage *result; | ||
242 | uint16_t size; | ||
243 | uint16_t gpl; | ||
244 | uint16_t ppl; | ||
245 | |||
246 | if (NULL == msg) | ||
247 | { | ||
248 | GNUNET_CLIENT_disconnect (s->client); | ||
249 | s->client = GNUNET_CLIENT_connect ("regex", s->cfg); | ||
250 | retry_search (s); | ||
251 | return; | ||
252 | } | ||
253 | size = ntohs (msg->size); | ||
254 | if ( (GNUNET_MESSAGE_TYPE_REGEX_RESULT == ntohs (msg->type)) && | ||
255 | (size >= sizeof (struct ResultMessage)) ) | ||
256 | { | ||
257 | result = (const struct ResultMessage *) msg; | ||
258 | gpl = ntohs (result->get_path_length); | ||
259 | ppl = ntohs (result->put_path_length); | ||
260 | if (size == (sizeof (struct ResultMessage) + | ||
261 | (gpl + ppl) * sizeof (struct GNUNET_PeerIdentity))) | ||
262 | { | ||
263 | const struct GNUNET_PeerIdentity *pid; | ||
264 | |||
265 | GNUNET_CLIENT_receive (s->client, | ||
266 | &handle_search_response, s, | ||
267 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
268 | pid = &result->id; | ||
269 | s->callback (s->callback_cls, | ||
270 | pid, | ||
271 | &pid[1], gpl, | ||
272 | &pid[1 + gpl], ppl); | ||
273 | return; | ||
274 | } | ||
275 | } | ||
276 | GNUNET_break (0); | ||
277 | GNUNET_CLIENT_disconnect (s->client); | ||
278 | s->client = GNUNET_CLIENT_connect ("regex", s->cfg); | ||
279 | retry_search (s); | ||
280 | } | ||
281 | |||
282 | |||
283 | /** | ||
284 | * Search for a peer offering a regex matching certain string in the DHT. | ||
285 | * The search runs until GNUNET_REGEX_search_cancel is called, even if results | ||
286 | * are returned. | ||
287 | * | ||
288 | * @param cfg configuration to use | ||
289 | * @param string String to match against the regexes in the DHT. | ||
290 | * @param callback Callback for found peers. | ||
291 | * @param callback_cls Closure for @c callback. | ||
292 | * @return Handle to stop search and free resources. | ||
293 | * Must be freed by calling GNUNET_REGEX_search_cancel. | ||
294 | */ | ||
295 | struct GNUNET_REGEX_Search * | ||
296 | GNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
297 | const char *string, | ||
298 | GNUNET_REGEX_Found callback, | ||
299 | void *callback_cls) | ||
300 | { | ||
301 | struct GNUNET_REGEX_Search *s; | ||
302 | size_t slen; | ||
303 | |||
304 | slen = strlen (string) + 1; | ||
305 | s = GNUNET_malloc (sizeof (struct GNUNET_REGEX_Announcement) + slen); | ||
306 | s->cfg = cfg; | ||
307 | s->client = GNUNET_CLIENT_connect ("regex", cfg); | ||
308 | if (NULL == s->client) | ||
309 | return NULL; | ||
310 | s->callback = callback; | ||
311 | s->callback_cls = callback_cls; | ||
312 | s->msg.header.type = htons (GNUNET_MESSAGE_TYPE_REGEX_SEARCH); | ||
313 | s->msg.header.size = htons (sizeof (struct SearchMessage) + slen); | ||
314 | memcpy (&s[1], string, slen); | ||
315 | retry_search (s); | ||
316 | return s; | ||
317 | } | ||
318 | |||
319 | |||
320 | /** | ||
321 | * Stop search and free all data used by a GNUNET_REGEX_search call. | ||
322 | * | ||
323 | * @param s Handle returned by a previous GNUNET_REGEX_search call. | ||
324 | */ | ||
325 | void | ||
326 | GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s) | ||
327 | { | ||
328 | GNUNET_CLIENT_disconnect (s->client); | ||
329 | GNUNET_free (s); | ||
330 | } | ||
331 | |||
332 | |||
333 | /* end of regex_api.c */ | ||
diff --git a/src/regex/regex_ipc.h b/src/regex/regex_ipc.h new file mode 100644 index 000000000..b94fceb86 --- /dev/null +++ b/src/regex/regex_ipc.h | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file regex/regex_ipc.h | ||
22 | * @brief regex IPC messages (not called 'regex.h' due to conflict with | ||
23 | * system headers) | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef REGEX_IPC_H | ||
27 | #define REGEX_IPC_H | ||
28 | |||
29 | #include "gnunet_util_lib.h" | ||
30 | |||
31 | /** | ||
32 | * Request for regex service to announce capability. | ||
33 | */ | ||
34 | struct AnnounceMessage | ||
35 | { | ||
36 | |||
37 | /** | ||
38 | * Type is GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE | ||
39 | */ | ||
40 | struct GNUNET_MessageHeader header; | ||
41 | |||
42 | /** | ||
43 | * How many characters can we squeeze per edge? | ||
44 | */ | ||
45 | uint16_t compression; | ||
46 | |||
47 | /** | ||
48 | * Always zero. | ||
49 | */ | ||
50 | uint16_t reserved; | ||
51 | |||
52 | /** | ||
53 | * Delay between repeated announcements. | ||
54 | */ | ||
55 | struct GNUNET_TIME_RelativeNBO refresh_delay; | ||
56 | |||
57 | /** | ||
58 | * Which PID to announce as the provider? | ||
59 | */ | ||
60 | struct GNUNET_PeerIdentity pid; | ||
61 | |||
62 | /* followed by 0-terminated regex as string */ | ||
63 | }; | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Message to initiate regex search. | ||
68 | */ | ||
69 | struct SearchMessage | ||
70 | { | ||
71 | /** | ||
72 | * Type is GNUNET_MESSAGE_TYPE_REGEX_SEARCH | ||
73 | */ | ||
74 | struct GNUNET_MessageHeader header; | ||
75 | |||
76 | /* followed by 0-terminated search string */ | ||
77 | |||
78 | }; | ||
79 | |||
80 | |||
81 | /** | ||
82 | * Result from regex search. | ||
83 | */ | ||
84 | struct ResultMessage | ||
85 | { | ||
86 | /** | ||
87 | * Type is GNUNET_MESSAGE_TYPE_REGEX_RESULT | ||
88 | */ | ||
89 | struct GNUNET_MessageHeader header; | ||
90 | |||
91 | /** | ||
92 | * Number of entries in the GET path. | ||
93 | */ | ||
94 | uint16_t get_path_length; | ||
95 | |||
96 | /** | ||
97 | * Number of entries in the PUT path. | ||
98 | */ | ||
99 | uint16_t put_path_length; | ||
100 | |||
101 | /** | ||
102 | * Identity of the peer that was found. | ||
103 | */ | ||
104 | struct GNUNET_PeerIdentity id; | ||
105 | |||
106 | /* followed by GET path and PUT path arrays */ | ||
107 | |||
108 | }; | ||
109 | |||
110 | |||
111 | /* end of regex_ipc.h */ | ||
112 | #endif | ||