diff options
Diffstat (limited to 'src/messenger/messenger_api_message.c')
-rw-r--r-- | src/messenger/messenger_api_message.c | 582 |
1 files changed, 318 insertions, 264 deletions
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c index 31d0c94b8..3d9e125a4 100644 --- a/src/messenger/messenger_api_message.c +++ b/src/messenger/messenger_api_message.c | |||
@@ -41,8 +41,7 @@ struct GNUNET_MESSENGER_ShortMessage | |||
41 | struct GNUNET_MESSENGER_Message* | 41 | struct GNUNET_MESSENGER_Message* |
42 | create_message (enum GNUNET_MESSENGER_MessageKind kind) | 42 | create_message (enum GNUNET_MESSENGER_MessageKind kind) |
43 | { | 43 | { |
44 | struct GNUNET_MESSENGER_Message *message = GNUNET_new (struct | 44 | struct GNUNET_MESSENGER_Message *message = GNUNET_new(struct GNUNET_MESSENGER_Message); |
45 | GNUNET_MESSENGER_Message); | ||
46 | 45 | ||
47 | message->header.kind = kind; | 46 | message->header.kind = kind; |
48 | 47 | ||
@@ -68,36 +67,32 @@ create_message (enum GNUNET_MESSENGER_MessageKind kind) | |||
68 | return message; | 67 | return message; |
69 | } | 68 | } |
70 | 69 | ||
71 | |||
72 | struct GNUNET_MESSENGER_Message* | 70 | struct GNUNET_MESSENGER_Message* |
73 | copy_message (const struct GNUNET_MESSENGER_Message *message) | 71 | copy_message (const struct GNUNET_MESSENGER_Message *message) |
74 | { | 72 | { |
75 | GNUNET_assert (message); | 73 | GNUNET_assert(message); |
76 | 74 | ||
77 | struct GNUNET_MESSENGER_Message *copy = GNUNET_new (struct | 75 | struct GNUNET_MESSENGER_Message *copy = GNUNET_new(struct GNUNET_MESSENGER_Message); |
78 | GNUNET_MESSENGER_Message); | ||
79 | 76 | ||
80 | GNUNET_memcpy (copy, message, sizeof(struct GNUNET_MESSENGER_Message)); | 77 | GNUNET_memcpy(copy, message, sizeof(struct GNUNET_MESSENGER_Message)); |
81 | 78 | ||
82 | switch (message->header.kind) | 79 | switch (message->header.kind) |
83 | { | 80 | { |
84 | case GNUNET_MESSENGER_KIND_NAME: | 81 | case GNUNET_MESSENGER_KIND_NAME: |
85 | copy->body.name.name = GNUNET_strdup (message->body.name.name); | 82 | copy->body.name.name = GNUNET_strdup(message->body.name.name); |
86 | break; | 83 | break; |
87 | case GNUNET_MESSENGER_KIND_TEXT: | 84 | case GNUNET_MESSENGER_KIND_TEXT: |
88 | copy->body.text.text = GNUNET_strdup (message->body.text.text); | 85 | copy->body.text.text = GNUNET_strdup(message->body.text.text); |
89 | break; | 86 | break; |
90 | case GNUNET_MESSENGER_KIND_FILE: | 87 | case GNUNET_MESSENGER_KIND_FILE: |
91 | copy->body.file.uri = GNUNET_strdup (message->body.file.uri); | 88 | copy->body.file.uri = GNUNET_strdup(message->body.file.uri); |
92 | break; | 89 | break; |
93 | case GNUNET_MESSENGER_KIND_PRIVATE: | 90 | case GNUNET_MESSENGER_KIND_PRIVATE: |
94 | copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc ( | 91 | copy->body.privacy.data = copy->body.privacy.length ? GNUNET_malloc(copy->body.privacy.length) : NULL; |
95 | copy->body.privacy.length) : NULL; | ||
96 | 92 | ||
97 | if (copy->body.privacy.data) | 93 | if (copy->body.privacy.data) |
98 | { | 94 | { |
99 | GNUNET_memcpy (copy->body.privacy.data, message->body.privacy.data, | 95 | GNUNET_memcpy(copy->body.privacy.data, message->body.privacy.data, copy->body.privacy.length); |
100 | copy->body.privacy.length); | ||
101 | } | 96 | } |
102 | 97 | ||
103 | break; | 98 | break; |
@@ -108,7 +103,6 @@ copy_message (const struct GNUNET_MESSENGER_Message *message) | |||
108 | return copy; | 103 | return copy; |
109 | } | 104 | } |
110 | 105 | ||
111 | |||
112 | static void | 106 | static void |
113 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, | 107 | destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, |
114 | struct GNUNET_MESSENGER_MessageBody *body) | 108 | struct GNUNET_MESSENGER_MessageBody *body) |
@@ -116,47 +110,44 @@ destroy_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
116 | switch (kind) | 110 | switch (kind) |
117 | { | 111 | { |
118 | case GNUNET_MESSENGER_KIND_NAME: | 112 | case GNUNET_MESSENGER_KIND_NAME: |
119 | GNUNET_free (body->name.name); | 113 | GNUNET_free(body->name.name); |
120 | break; | 114 | break; |
121 | case GNUNET_MESSENGER_KIND_TEXT: | 115 | case GNUNET_MESSENGER_KIND_TEXT: |
122 | GNUNET_free (body->text.text); | 116 | GNUNET_free(body->text.text); |
123 | break; | 117 | break; |
124 | case GNUNET_MESSENGER_KIND_FILE: | 118 | case GNUNET_MESSENGER_KIND_FILE: |
125 | GNUNET_free (body->file.uri); | 119 | GNUNET_free(body->file.uri); |
126 | break; | 120 | break; |
127 | case GNUNET_MESSENGER_KIND_PRIVATE: | 121 | case GNUNET_MESSENGER_KIND_PRIVATE: |
128 | GNUNET_free (body->privacy.data); | 122 | GNUNET_free(body->privacy.data); |
129 | break; | 123 | break; |
130 | default: | 124 | default: |
131 | break; | 125 | break; |
132 | } | 126 | } |
133 | } | 127 | } |
134 | 128 | ||
135 | |||
136 | void | 129 | void |
137 | cleanup_message (struct GNUNET_MESSENGER_Message *message) | 130 | cleanup_message (struct GNUNET_MESSENGER_Message *message) |
138 | { | 131 | { |
139 | GNUNET_assert (message); | 132 | GNUNET_assert(message); |
140 | 133 | ||
141 | destroy_message_body (message->header.kind, &(message->body)); | 134 | destroy_message_body (message->header.kind, &(message->body)); |
142 | } | 135 | } |
143 | 136 | ||
144 | |||
145 | void | 137 | void |
146 | destroy_message (struct GNUNET_MESSENGER_Message *message) | 138 | destroy_message (struct GNUNET_MESSENGER_Message *message) |
147 | { | 139 | { |
148 | GNUNET_assert (message); | 140 | GNUNET_assert(message); |
149 | 141 | ||
150 | destroy_message_body (message->header.kind, &(message->body)); | 142 | destroy_message_body (message->header.kind, &(message->body)); |
151 | 143 | ||
152 | GNUNET_free (message); | 144 | GNUNET_free(message); |
153 | } | 145 | } |
154 | 146 | ||
155 | |||
156 | int | 147 | int |
157 | is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) | 148 | is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) |
158 | { | 149 | { |
159 | GNUNET_assert (message); | 150 | GNUNET_assert(message); |
160 | 151 | ||
161 | if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) || | 152 | if ((GNUNET_MESSENGER_KIND_JOIN == message->header.kind) || |
162 | (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind) || | 153 | (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind) || |
@@ -168,18 +159,15 @@ is_message_session_bound (const struct GNUNET_MESSENGER_Message *message) | |||
168 | return GNUNET_NO; | 159 | return GNUNET_NO; |
169 | } | 160 | } |
170 | 161 | ||
171 | |||
172 | static void | 162 | static void |
173 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, | 163 | fold_short_message (const struct GNUNET_MESSENGER_Message *message, |
174 | struct GNUNET_MESSENGER_ShortMessage *shortened) | 164 | struct GNUNET_MESSENGER_ShortMessage *shortened) |
175 | { | 165 | { |
176 | shortened->kind = message->header.kind; | 166 | shortened->kind = message->header.kind; |
177 | 167 | ||
178 | GNUNET_memcpy (&(shortened->body), &(message->body), sizeof(struct | 168 | GNUNET_memcpy(&(shortened->body), &(message->body), sizeof(struct GNUNET_MESSENGER_MessageBody)); |
179 | GNUNET_MESSENGER_MessageBody)); | ||
180 | } | 169 | } |
181 | 170 | ||
182 | |||
183 | static void | 171 | static void |
184 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, | 172 | unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, |
185 | struct GNUNET_MESSENGER_Message *message) | 173 | struct GNUNET_MESSENGER_Message *message) |
@@ -188,11 +176,9 @@ unfold_short_message (struct GNUNET_MESSENGER_ShortMessage *shortened, | |||
188 | 176 | ||
189 | message->header.kind = shortened->kind; | 177 | message->header.kind = shortened->kind; |
190 | 178 | ||
191 | GNUNET_memcpy (&(message->body), &(shortened->body), sizeof(struct | 179 | GNUNET_memcpy(&(message->body), &(shortened->body), sizeof(struct GNUNET_MESSENGER_MessageBody)); |
192 | GNUNET_MESSENGER_MessageBody)); | ||
193 | } | 180 | } |
194 | 181 | ||
195 | |||
196 | #define member_size(type, member) sizeof(((type*) NULL)->member) | 182 | #define member_size(type, member) sizeof(((type*) NULL)->member) |
197 | 183 | ||
198 | static uint16_t | 184 | static uint16_t |
@@ -203,40 +189,40 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
203 | switch (kind) | 189 | switch (kind) |
204 | { | 190 | { |
205 | case GNUNET_MESSENGER_KIND_INFO: | 191 | case GNUNET_MESSENGER_KIND_INFO: |
206 | length += member_size (struct GNUNET_MESSENGER_Message, | 192 | length += member_size(struct GNUNET_MESSENGER_Message, body.info.messenger_version); |
207 | body.info.messenger_version); | ||
208 | break; | 193 | break; |
209 | case GNUNET_MESSENGER_KIND_PEER: | 194 | case GNUNET_MESSENGER_KIND_PEER: |
210 | length += member_size (struct GNUNET_MESSENGER_Message, body.peer.peer); | 195 | length += member_size(struct GNUNET_MESSENGER_Message, body.peer.peer); |
211 | break; | 196 | break; |
212 | case GNUNET_MESSENGER_KIND_ID: | 197 | case GNUNET_MESSENGER_KIND_ID: |
213 | length += member_size (struct GNUNET_MESSENGER_Message, body.id.id); | 198 | length += member_size(struct GNUNET_MESSENGER_Message, body.id.id); |
214 | break; | 199 | break; |
215 | case GNUNET_MESSENGER_KIND_MISS: | 200 | case GNUNET_MESSENGER_KIND_MISS: |
216 | length += member_size (struct GNUNET_MESSENGER_Message, body.miss.peer); | 201 | length += member_size(struct GNUNET_MESSENGER_Message, body.miss.peer); |
217 | break; | 202 | break; |
218 | case GNUNET_MESSENGER_KIND_MERGE: | 203 | case GNUNET_MESSENGER_KIND_MERGE: |
219 | length += member_size (struct GNUNET_MESSENGER_Message, | 204 | length += member_size(struct GNUNET_MESSENGER_Message, body.merge.previous); |
220 | body.merge.previous); | ||
221 | break; | 205 | break; |
222 | case GNUNET_MESSENGER_KIND_REQUEST: | 206 | case GNUNET_MESSENGER_KIND_REQUEST: |
223 | length += member_size (struct GNUNET_MESSENGER_Message, body.request.hash); | 207 | length += member_size(struct GNUNET_MESSENGER_Message, body.request.hash); |
224 | break; | 208 | break; |
225 | case GNUNET_MESSENGER_KIND_INVITE: | 209 | case GNUNET_MESSENGER_KIND_INVITE: |
226 | length += member_size (struct GNUNET_MESSENGER_Message, body.invite.door); | 210 | length += member_size(struct GNUNET_MESSENGER_Message, body.invite.door); |
227 | length += member_size (struct GNUNET_MESSENGER_Message, body.invite.key); | 211 | length += member_size(struct GNUNET_MESSENGER_Message, body.invite.key); |
228 | break; | 212 | break; |
229 | case GNUNET_MESSENGER_KIND_TEXT: | 213 | case GNUNET_MESSENGER_KIND_TEXT: |
230 | break; | 214 | break; |
231 | case GNUNET_MESSENGER_KIND_FILE: | 215 | case GNUNET_MESSENGER_KIND_FILE: |
232 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.key); | 216 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.key); |
233 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.hash); | 217 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.hash); |
234 | length += member_size (struct GNUNET_MESSENGER_Message, body.file.name); | 218 | length += member_size(struct GNUNET_MESSENGER_Message, body.file.name); |
219 | break; | ||
220 | case GNUNET_MESSENGER_KIND_PRIVATE: | ||
221 | length += member_size(struct GNUNET_MESSENGER_Message, body.privacy.key); | ||
235 | break; | 222 | break; |
236 | case GNUNET_MESSENGER_KIND_DELETE: | 223 | case GNUNET_MESSENGER_KIND_DELETE: |
237 | length += member_size (struct GNUNET_MESSENGER_Message, body.deletion.hash); | 224 | length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.hash); |
238 | length += member_size (struct GNUNET_MESSENGER_Message, | 225 | length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.delay); |
239 | body.deletion.delay); | ||
240 | break; | 226 | break; |
241 | default: | 227 | default: |
242 | break; | 228 | break; |
@@ -245,7 +231,6 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind) | |||
245 | return length; | 231 | return length; |
246 | } | 232 | } |
247 | 233 | ||
248 | |||
249 | typedef uint32_t kind_t; | 234 | typedef uint32_t kind_t; |
250 | 235 | ||
251 | uint16_t | 236 | uint16_t |
@@ -256,9 +241,9 @@ get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
256 | 241 | ||
257 | if (GNUNET_YES == include_header) | 242 | if (GNUNET_YES == include_header) |
258 | { | 243 | { |
259 | length += member_size (struct GNUNET_MESSENGER_Message, header.timestamp); | 244 | length += member_size(struct GNUNET_MESSENGER_Message, header.timestamp); |
260 | length += member_size (struct GNUNET_MESSENGER_Message, header.sender_id); | 245 | length += member_size(struct GNUNET_MESSENGER_Message, header.sender_id); |
261 | length += member_size (struct GNUNET_MESSENGER_Message, header.previous); | 246 | length += member_size(struct GNUNET_MESSENGER_Message, header.previous); |
262 | } | 247 | } |
263 | 248 | ||
264 | length += sizeof(kind_t); | 249 | length += sizeof(kind_t); |
@@ -266,7 +251,6 @@ get_message_kind_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
266 | return length + get_message_body_kind_size (kind); | 251 | return length + get_message_body_kind_size (kind); |
267 | } | 252 | } |
268 | 253 | ||
269 | |||
270 | static uint16_t | 254 | static uint16_t |
271 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | 255 | get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, |
272 | const struct GNUNET_MESSENGER_MessageBody *body) | 256 | const struct GNUNET_MESSENGER_MessageBody *body) |
@@ -275,17 +259,14 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
275 | 259 | ||
276 | switch (kind) | 260 | switch (kind) |
277 | { | 261 | { |
278 | case GNUNET_MESSENGER_KIND_INFO: | ||
279 | length += GNUNET_IDENTITY_public_key_get_length (&(body->info.host_key)); | ||
280 | break; | ||
281 | case GNUNET_MESSENGER_KIND_JOIN: | 262 | case GNUNET_MESSENGER_KIND_JOIN: |
282 | length += GNUNET_IDENTITY_public_key_get_length (&(body->join.key)); | 263 | length += GNUNET_IDENTITY_public_key_get_length(&(body->join.key)); |
283 | break; | 264 | break; |
284 | case GNUNET_MESSENGER_KIND_NAME: | 265 | case GNUNET_MESSENGER_KIND_NAME: |
285 | length += (body->name.name ? strlen (body->name.name) : 0); | 266 | length += (body->name.name ? strlen (body->name.name) : 0); |
286 | break; | 267 | break; |
287 | case GNUNET_MESSENGER_KIND_KEY: | 268 | case GNUNET_MESSENGER_KIND_KEY: |
288 | length += GNUNET_IDENTITY_public_key_get_length (&(body->key.key)); | 269 | length += GNUNET_IDENTITY_public_key_get_length(&(body->key.key)); |
289 | break; | 270 | break; |
290 | case GNUNET_MESSENGER_KIND_TEXT: | 271 | case GNUNET_MESSENGER_KIND_TEXT: |
291 | length += strlen (body->text.text); | 272 | length += strlen (body->text.text); |
@@ -303,18 +284,16 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind, | |||
303 | return length; | 284 | return length; |
304 | } | 285 | } |
305 | 286 | ||
306 | |||
307 | uint16_t | 287 | uint16_t |
308 | get_message_size (const struct GNUNET_MESSENGER_Message *message, | 288 | get_message_size (const struct GNUNET_MESSENGER_Message *message, |
309 | int include_header) | 289 | int include_header) |
310 | { | 290 | { |
311 | GNUNET_assert (message); | 291 | GNUNET_assert(message); |
312 | 292 | ||
313 | uint16_t length = 0; | 293 | uint16_t length = 0; |
314 | 294 | ||
315 | if (GNUNET_YES == include_header) | 295 | if (GNUNET_YES == include_header) |
316 | length += GNUNET_IDENTITY_signature_get_length ( | 296 | length += GNUNET_IDENTITY_signature_get_length(&(message->header.signature)); |
317 | &(message->header.signature)); | ||
318 | 297 | ||
319 | length += get_message_kind_size (message->header.kind, include_header); | 298 | length += get_message_kind_size (message->header.kind, include_header); |
320 | length += get_message_body_size (message->header.kind, &(message->body)); | 299 | length += get_message_body_size (message->header.kind, &(message->body)); |
@@ -322,7 +301,6 @@ get_message_size (const struct GNUNET_MESSENGER_Message *message, | |||
322 | return length; | 301 | return length; |
323 | } | 302 | } |
324 | 303 | ||
325 | |||
326 | static uint16_t | 304 | static uint16_t |
327 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, | 305 | get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, |
328 | int include_body) | 306 | int include_body) |
@@ -331,24 +309,19 @@ get_short_message_size (const struct GNUNET_MESSENGER_ShortMessage *message, | |||
331 | 309 | ||
332 | if (message) | 310 | if (message) |
333 | return minimum_size + get_message_body_kind_size (message->kind) | 311 | return minimum_size + get_message_body_kind_size (message->kind) |
334 | + (include_body == GNUNET_YES? get_message_body_size (message->kind, | 312 | + (include_body == GNUNET_YES? get_message_body_size (message->kind, &(message->body)) : 0); |
335 | &(message->body)) | ||
336 | : 0); | ||
337 | else | 313 | else |
338 | return minimum_size; | 314 | return minimum_size; |
339 | } | 315 | } |
340 | 316 | ||
341 | |||
342 | static uint16_t | 317 | static uint16_t |
343 | calc_usual_padding () | 318 | calc_usual_padding () |
344 | { | 319 | { |
345 | uint16_t padding = 0; | 320 | uint16_t padding = 0; |
346 | uint16_t kind_size; | 321 | uint16_t kind_size; |
347 | 322 | ||
348 | for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) | 323 | for (int i = 0; i <= GNUNET_MESSENGER_KIND_MAX; i++) { |
349 | { | 324 | kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, GNUNET_YES); |
350 | kind_size = get_message_kind_size ((enum GNUNET_MESSENGER_MessageKind) i, | ||
351 | GNUNET_YES); | ||
352 | 325 | ||
353 | if (kind_size > padding) | 326 | if (kind_size > padding) |
354 | padding = kind_size; | 327 | padding = kind_size; |
@@ -357,7 +330,6 @@ calc_usual_padding () | |||
357 | return padding + GNUNET_MESSENGER_PADDING_MIN; | 330 | return padding + GNUNET_MESSENGER_PADDING_MIN; |
358 | } | 331 | } |
359 | 332 | ||
360 | |||
361 | #define max(x, y) (x > y? x : y) | 333 | #define max(x, y) (x > y? x : y) |
362 | 334 | ||
363 | static uint16_t | 335 | static uint16_t |
@@ -365,13 +337,13 @@ calc_padded_length (uint16_t length) | |||
365 | { | 337 | { |
366 | static uint16_t usual_padding = 0; | 338 | static uint16_t usual_padding = 0; |
367 | 339 | ||
368 | if (! usual_padding) | 340 | if (!usual_padding) |
369 | usual_padding = calc_usual_padding (); | 341 | usual_padding = calc_usual_padding(); |
370 | 342 | ||
371 | const uint16_t padded_length = max ( | 343 | const uint16_t padded_length = max( |
372 | length + GNUNET_MESSENGER_PADDING_MIN, | 344 | length + GNUNET_MESSENGER_PADDING_MIN, |
373 | usual_padding | 345 | usual_padding |
374 | ); | 346 | ); |
375 | 347 | ||
376 | if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0) | 348 | if (padded_length <= GNUNET_MESSENGER_PADDING_LEVEL0) |
377 | return GNUNET_MESSENGER_PADDING_LEVEL0; | 349 | return GNUNET_MESSENGER_PADDING_LEVEL0; |
@@ -386,35 +358,34 @@ calc_padded_length (uint16_t length) | |||
386 | 358 | ||
387 | } | 359 | } |
388 | 360 | ||
389 | |||
390 | #define min(x, y) (x < y? x : y) | 361 | #define min(x, y) (x < y? x : y) |
391 | 362 | ||
392 | #define encode_step_ext(dst, offset, src, size) do { \ | 363 | #define encode_step_ext(dst, offset, src, size) do { \ |
393 | GNUNET_memcpy (dst + offset, src, size); \ | 364 | GNUNET_memcpy(dst + offset, src, size); \ |
394 | offset += size; \ | 365 | offset += size; \ |
395 | } while (0) | 366 | } while (0) |
396 | 367 | ||
397 | #define encode_step(dst, offset, src) do { \ | 368 | #define encode_step(dst, offset, src) do { \ |
398 | encode_step_ext (dst, offset, src, sizeof(*src)); \ | 369 | encode_step_ext(dst, offset, src, sizeof(*src)); \ |
399 | } while (0) | 370 | } while (0) |
400 | 371 | ||
401 | #define encode_step_key(dst, offset, src, length) do { \ | 372 | #define encode_step_key(dst, offset, src, length) do { \ |
402 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer ( \ | 373 | ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer( \ |
403 | src, dst + offset, length - offset \ | 374 | src, dst + offset, length - offset \ |
404 | ); \ | 375 | ); \ |
405 | if (result < 0) \ | 376 | if (result < 0) \ |
406 | GNUNET_break (0); \ | 377 | GNUNET_break (0); \ |
407 | else \ | 378 | else \ |
408 | offset += result; \ | 379 | offset += result; \ |
409 | } while (0) | 380 | } while (0) |
410 | 381 | ||
411 | #define encode_step_signature(dst, offset, src, length) do { \ | 382 | #define encode_step_signature(dst, offset, src, length) do { \ |
412 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer ( \ | 383 | ssize_t result = GNUNET_IDENTITY_write_signature_to_buffer( \ |
413 | src, dst + offset, length - offset \ | 384 | src, dst + offset, length - offset \ |
414 | ); \ | 385 | ); \ |
415 | if (result < 0) \ | 386 | if (result < 0) \ |
416 | GNUNET_break (0); \ | 387 | GNUNET_break (0); \ |
417 | else \ | 388 | else \ |
418 | offset += result; \ | 389 | offset += result; \ |
419 | } while (0) | 390 | } while (0) |
420 | 391 | ||
@@ -429,63 +400,55 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
429 | switch (kind) | 400 | switch (kind) |
430 | { | 401 | { |
431 | case GNUNET_MESSENGER_KIND_INFO: | 402 | case GNUNET_MESSENGER_KIND_INFO: |
432 | version = GNUNET_htobe32 (body->info.messenger_version); | 403 | version = GNUNET_htobe32(body->info.messenger_version); |
433 | 404 | ||
434 | encode_step_key (buffer, offset, &(body->info.host_key), length); | 405 | encode_step(buffer, offset, &version); |
435 | encode_step (buffer, offset, &version); | ||
436 | break; | 406 | break; |
437 | case GNUNET_MESSENGER_KIND_JOIN: | 407 | case GNUNET_MESSENGER_KIND_JOIN: |
438 | encode_step_key (buffer, offset, &(body->join.key), length); | 408 | encode_step_key(buffer, offset, &(body->join.key), length); |
439 | break; | 409 | break; |
440 | case GNUNET_MESSENGER_KIND_NAME: | 410 | case GNUNET_MESSENGER_KIND_NAME: |
441 | if (body->name.name) | 411 | if (body->name.name) |
442 | encode_step_ext (buffer, offset, body->name.name, min (length - offset, | 412 | encode_step_ext(buffer, offset, body->name.name, min(length - offset, strlen(body->name.name))); |
443 | strlen ( | ||
444 | body->name.name))); | ||
445 | break; | 413 | break; |
446 | case GNUNET_MESSENGER_KIND_KEY: | 414 | case GNUNET_MESSENGER_KIND_KEY: |
447 | encode_step_key (buffer, offset, &(body->key.key), length); | 415 | encode_step_key(buffer, offset, &(body->key.key), length); |
448 | break; | 416 | break; |
449 | case GNUNET_MESSENGER_KIND_PEER: | 417 | case GNUNET_MESSENGER_KIND_PEER: |
450 | encode_step (buffer, offset, &(body->peer.peer)); | 418 | encode_step(buffer, offset, &(body->peer.peer)); |
451 | break; | 419 | break; |
452 | case GNUNET_MESSENGER_KIND_ID: | 420 | case GNUNET_MESSENGER_KIND_ID: |
453 | encode_step (buffer, offset, &(body->id.id)); | 421 | encode_step(buffer, offset, &(body->id.id)); |
454 | break; | 422 | break; |
455 | case GNUNET_MESSENGER_KIND_MISS: | 423 | case GNUNET_MESSENGER_KIND_MISS: |
456 | encode_step (buffer, offset, &(body->miss.peer)); | 424 | encode_step(buffer, offset, &(body->miss.peer)); |
457 | break; | 425 | break; |
458 | case GNUNET_MESSENGER_KIND_MERGE: | 426 | case GNUNET_MESSENGER_KIND_MERGE: |
459 | encode_step (buffer, offset, &(body->merge.previous)); | 427 | encode_step(buffer, offset, &(body->merge.previous)); |
460 | break; | 428 | break; |
461 | case GNUNET_MESSENGER_KIND_REQUEST: | 429 | case GNUNET_MESSENGER_KIND_REQUEST: |
462 | encode_step (buffer, offset, &(body->request.hash)); | 430 | encode_step(buffer, offset, &(body->request.hash)); |
463 | break; | 431 | break; |
464 | case GNUNET_MESSENGER_KIND_INVITE: | 432 | case GNUNET_MESSENGER_KIND_INVITE: |
465 | encode_step (buffer, offset, &(body->invite.door)); | 433 | encode_step(buffer, offset, &(body->invite.door)); |
466 | encode_step (buffer, offset, &(body->invite.key)); | 434 | encode_step(buffer, offset, &(body->invite.key)); |
467 | break; | 435 | break; |
468 | case GNUNET_MESSENGER_KIND_TEXT: | 436 | case GNUNET_MESSENGER_KIND_TEXT: |
469 | encode_step_ext (buffer, offset, body->text.text, min (length - offset, | 437 | encode_step_ext(buffer, offset, body->text.text, min(length - offset, strlen(body->text.text))); |
470 | strlen ( | ||
471 | body->text.text))); | ||
472 | break; | 438 | break; |
473 | case GNUNET_MESSENGER_KIND_FILE: | 439 | case GNUNET_MESSENGER_KIND_FILE: |
474 | encode_step (buffer, offset, &(body->file.key)); | 440 | encode_step(buffer, offset, &(body->file.key)); |
475 | encode_step (buffer, offset, &(body->file.hash)); | 441 | encode_step(buffer, offset, &(body->file.hash)); |
476 | encode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name)); | 442 | encode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name)); |
477 | encode_step_ext (buffer, offset, body->file.uri, min (length - offset, | 443 | encode_step_ext(buffer, offset, body->file.uri, min(length - offset, strlen(body->file.uri))); |
478 | strlen ( | ||
479 | body->file.uri))); | ||
480 | break; | 444 | break; |
481 | case GNUNET_MESSENGER_KIND_PRIVATE: | 445 | case GNUNET_MESSENGER_KIND_PRIVATE: |
482 | encode_step_ext (buffer, offset, body->privacy.data, min (length - offset, | 446 | encode_step(buffer, offset, &(body->privacy.key)); |
483 | body->privacy. | 447 | encode_step_ext(buffer, offset, body->privacy.data, min(length - offset, body->privacy.length)); |
484 | length)); | ||
485 | break; | 448 | break; |
486 | case GNUNET_MESSENGER_KIND_DELETE: | 449 | case GNUNET_MESSENGER_KIND_DELETE: |
487 | encode_step (buffer, offset, &(body->deletion.hash)); | 450 | encode_step(buffer, offset, &(body->deletion.hash)); |
488 | encode_step (buffer, offset, &(body->deletion.delay)); | 451 | encode_step(buffer, offset, &(body->deletion.delay)); |
489 | break; | 452 | break; |
490 | default: | 453 | default: |
491 | break; | 454 | break; |
@@ -497,48 +460,43 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind, | |||
497 | const uint16_t padding = length - offset; | 460 | const uint16_t padding = length - offset; |
498 | const uint16_t used_padding = sizeof(padding) + sizeof(char); | 461 | const uint16_t used_padding = sizeof(padding) + sizeof(char); |
499 | 462 | ||
500 | GNUNET_assert (padding >= used_padding); | 463 | GNUNET_assert(padding >= used_padding); |
501 | 464 | ||
502 | buffer[offset++] = '\0'; | 465 | buffer[offset++] = '\0'; |
503 | 466 | ||
504 | if (padding > used_padding) | 467 | if (padding > used_padding) |
505 | GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, buffer + offset, | 468 | GNUNET_CRYPTO_random_block(GNUNET_CRYPTO_QUALITY_WEAK, buffer + offset, padding - used_padding); |
506 | padding - used_padding); | ||
507 | 469 | ||
508 | GNUNET_memcpy (buffer + length - sizeof(padding), &padding, sizeof(padding)); | 470 | GNUNET_memcpy(buffer + length - sizeof(padding), &padding, sizeof(padding)); |
509 | } | 471 | } |
510 | 472 | ||
511 | |||
512 | void | 473 | void |
513 | encode_message (const struct GNUNET_MESSENGER_Message *message, | 474 | encode_message (const struct GNUNET_MESSENGER_Message *message, |
514 | uint16_t length, | 475 | uint16_t length, |
515 | char *buffer, | 476 | char *buffer, |
516 | int include_header) | 477 | int include_header) |
517 | { | 478 | { |
518 | GNUNET_assert ((message) && (buffer)); | 479 | GNUNET_assert((message) && (buffer)); |
519 | 480 | ||
520 | uint16_t offset = 0; | 481 | uint16_t offset = 0; |
521 | 482 | ||
522 | if (GNUNET_YES == include_header) | 483 | if (GNUNET_YES == include_header) |
523 | encode_step_signature (buffer, offset, &(message->header.signature), | 484 | encode_step_signature(buffer, offset, &(message->header.signature), length); |
524 | length); | ||
525 | 485 | ||
526 | const kind_t kind = GNUNET_htobe32 ((kind_t) message->header.kind); | 486 | const kind_t kind = GNUNET_htobe32((kind_t) message->header.kind); |
527 | 487 | ||
528 | if (GNUNET_YES == include_header) | 488 | if (GNUNET_YES == include_header) |
529 | { | 489 | { |
530 | encode_step (buffer, offset, &(message->header.timestamp)); | 490 | encode_step(buffer, offset, &(message->header.timestamp)); |
531 | encode_step (buffer, offset, &(message->header.sender_id)); | 491 | encode_step(buffer, offset, &(message->header.sender_id)); |
532 | encode_step (buffer, offset, &(message->header.previous)); | 492 | encode_step(buffer, offset, &(message->header.previous)); |
533 | } | 493 | } |
534 | 494 | ||
535 | encode_step (buffer, offset, &kind); | 495 | encode_step(buffer, offset, &kind); |
536 | 496 | ||
537 | encode_message_body (message->header.kind, &(message->body), length, buffer, | 497 | encode_message_body (message->header.kind, &(message->body), length, buffer, offset); |
538 | offset); | ||
539 | } | 498 | } |
540 | 499 | ||
541 | |||
542 | static void | 500 | static void |
543 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, | 501 | encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, |
544 | uint16_t length, | 502 | uint16_t length, |
@@ -547,46 +505,45 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message, | |||
547 | struct GNUNET_HashCode hash; | 505 | struct GNUNET_HashCode hash; |
548 | uint16_t offset = sizeof(hash); | 506 | uint16_t offset = sizeof(hash); |
549 | 507 | ||
550 | const kind_t kind = GNUNET_htobe32 ((kind_t) message->kind); | 508 | const kind_t kind = GNUNET_htobe32((kind_t) message->kind); |
551 | 509 | ||
552 | encode_step (buffer, offset, &kind); | 510 | encode_step(buffer, offset, &kind); |
553 | 511 | ||
554 | encode_message_body (message->kind, &(message->body), length, buffer, offset); | 512 | encode_message_body (message->kind, &(message->body), length, buffer, offset); |
555 | 513 | ||
556 | GNUNET_CRYPTO_hash ( | 514 | GNUNET_CRYPTO_hash( |
557 | buffer + sizeof(hash), | 515 | buffer + sizeof(hash), |
558 | length - sizeof(hash), | 516 | length - sizeof(hash), |
559 | &hash | 517 | &hash |
560 | ); | 518 | ); |
561 | 519 | ||
562 | GNUNET_memcpy (buffer, &hash, sizeof(hash)); | 520 | GNUNET_memcpy(buffer, &hash, sizeof(hash)); |
563 | } | 521 | } |
564 | 522 | ||
565 | |||
566 | #define decode_step_ext(src, offset, dst, size) do { \ | 523 | #define decode_step_ext(src, offset, dst, size) do { \ |
567 | GNUNET_memcpy (dst, src + offset, size); \ | 524 | GNUNET_memcpy(dst, src + offset, size); \ |
568 | offset += size; \ | 525 | offset += size; \ |
569 | } while (0) | 526 | } while (0) |
570 | 527 | ||
571 | #define decode_step(src, offset, dst) do { \ | 528 | #define decode_step(src, offset, dst) do { \ |
572 | decode_step_ext (src, offset, dst, sizeof(*dst)); \ | 529 | decode_step_ext(src, offset, dst, sizeof(*dst)); \ |
573 | } while (0) | 530 | } while (0) |
574 | 531 | ||
575 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ | 532 | #define decode_step_malloc(src, offset, dst, size, zero) do { \ |
576 | dst = GNUNET_malloc (size + zero); \ | 533 | dst = GNUNET_malloc(size + zero); \ |
577 | if (zero) dst[size] = 0; \ | 534 | if (zero) dst[size] = 0; \ |
578 | decode_step_ext (src, offset, dst, size); \ | 535 | decode_step_ext(src, offset, dst, size); \ |
579 | } while (0) | 536 | } while (0) |
580 | 537 | ||
581 | #define decode_step_key(src, offset, dst, length) do { \ | 538 | #define decode_step_key(src, offset, dst, length) do { \ |
582 | enum GNUNET_GenericReturnValue result; \ | 539 | enum GNUNET_GenericReturnValue result; \ |
583 | size_t read; \ | 540 | size_t read; \ |
584 | result = GNUNET_IDENTITY_read_public_key_from_buffer ( \ | 541 | result = GNUNET_IDENTITY_read_public_key_from_buffer( \ |
585 | src + offset, length - offset, dst, &read \ | 542 | src + offset, length - offset, dst, &read \ |
586 | ); \ | 543 | ); \ |
587 | if (GNUNET_SYSERR == result) \ | 544 | if (GNUNET_SYSERR == result) \ |
588 | GNUNET_break (0); \ | 545 | GNUNET_break(0); \ |
589 | else \ | 546 | else \ |
590 | offset += read; \ | 547 | offset += read; \ |
591 | } while (0) | 548 | } while (0) |
592 | 549 | ||
@@ -599,7 +556,7 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
599 | { | 556 | { |
600 | uint16_t padding = 0; | 557 | uint16_t padding = 0; |
601 | 558 | ||
602 | GNUNET_memcpy (&padding, buffer + length - sizeof(padding), sizeof(padding)); | 559 | GNUNET_memcpy(&padding, buffer + length - sizeof(padding), sizeof(padding)); |
603 | 560 | ||
604 | if (padding > length - offset) | 561 | if (padding > length - offset) |
605 | padding = 0; | 562 | padding = 0; |
@@ -615,58 +572,59 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
615 | switch (*kind) | 572 | switch (*kind) |
616 | { | 573 | { |
617 | case GNUNET_MESSENGER_KIND_INFO: { | 574 | case GNUNET_MESSENGER_KIND_INFO: { |
618 | decode_step_key (buffer, offset, &(body->info.host_key), length); | 575 | decode_step(buffer, offset, &version); |
619 | decode_step (buffer, offset, &version); | 576 | |
620 | 577 | body->info.messenger_version = GNUNET_be32toh(version); | |
621 | body->info.messenger_version = GNUNET_be32toh (version); | 578 | break; |
622 | break; | 579 | } case GNUNET_MESSENGER_KIND_JOIN: { |
623 | } case GNUNET_MESSENGER_KIND_JOIN: { | 580 | decode_step_key(buffer, offset, &(body->join.key), length); |
624 | decode_step_key (buffer, offset, &(body->join.key), length); | 581 | break; |
625 | break; | 582 | } case GNUNET_MESSENGER_KIND_NAME: |
626 | } case GNUNET_MESSENGER_KIND_NAME: | ||
627 | if (length - offset > 0) | 583 | if (length - offset > 0) |
628 | decode_step_malloc (buffer, offset, body->name.name, length - offset, 1); | 584 | decode_step_malloc(buffer, offset, body->name.name, length - offset, 1); |
629 | else | 585 | else |
630 | body->name.name = NULL; | 586 | body->name.name = NULL; |
631 | break; | 587 | break; |
632 | case GNUNET_MESSENGER_KIND_KEY: | 588 | case GNUNET_MESSENGER_KIND_KEY: |
633 | decode_step_key (buffer, offset, &(body->key.key), length); | 589 | decode_step_key(buffer, offset, &(body->key.key), length); |
634 | break; | 590 | break; |
635 | case GNUNET_MESSENGER_KIND_PEER: | 591 | case GNUNET_MESSENGER_KIND_PEER: |
636 | decode_step (buffer, offset, &(body->peer.peer)); | 592 | decode_step(buffer, offset, &(body->peer.peer)); |
637 | break; | 593 | break; |
638 | case GNUNET_MESSENGER_KIND_ID: | 594 | case GNUNET_MESSENGER_KIND_ID: |
639 | decode_step (buffer, offset, &(body->id.id)); | 595 | decode_step(buffer, offset, &(body->id.id)); |
640 | break; | 596 | break; |
641 | case GNUNET_MESSENGER_KIND_MISS: | 597 | case GNUNET_MESSENGER_KIND_MISS: |
642 | decode_step (buffer, offset, &(body->miss.peer)); | 598 | decode_step(buffer, offset, &(body->miss.peer)); |
643 | break; | 599 | break; |
644 | case GNUNET_MESSENGER_KIND_MERGE: | 600 | case GNUNET_MESSENGER_KIND_MERGE: |
645 | decode_step (buffer, offset, &(body->merge.previous)); | 601 | decode_step(buffer, offset, &(body->merge.previous)); |
646 | break; | 602 | break; |
647 | case GNUNET_MESSENGER_KIND_REQUEST: | 603 | case GNUNET_MESSENGER_KIND_REQUEST: |
648 | decode_step (buffer, offset, &(body->request.hash)); | 604 | decode_step(buffer, offset, &(body->request.hash)); |
649 | break; | 605 | break; |
650 | case GNUNET_MESSENGER_KIND_INVITE: | 606 | case GNUNET_MESSENGER_KIND_INVITE: |
651 | decode_step (buffer, offset, &(body->invite.door)); | 607 | decode_step(buffer, offset, &(body->invite.door)); |
652 | decode_step (buffer, offset, &(body->invite.key)); | 608 | decode_step(buffer, offset, &(body->invite.key)); |
653 | break; | 609 | break; |
654 | case GNUNET_MESSENGER_KIND_TEXT: | 610 | case GNUNET_MESSENGER_KIND_TEXT: |
655 | decode_step_malloc (buffer, offset, body->text.text, length - offset, 1); | 611 | decode_step_malloc(buffer, offset, body->text.text, length - offset, 1); |
656 | break; | 612 | break; |
657 | case GNUNET_MESSENGER_KIND_FILE: | 613 | case GNUNET_MESSENGER_KIND_FILE: |
658 | decode_step (buffer, offset, &(body->file.key)); | 614 | decode_step(buffer, offset, &(body->file.key)); |
659 | decode_step (buffer, offset, &(body->file.hash)); | 615 | decode_step(buffer, offset, &(body->file.hash)); |
660 | decode_step_ext (buffer, offset, body->file.name, sizeof(body->file.name)); | 616 | decode_step_ext(buffer, offset, body->file.name, sizeof(body->file.name)); |
661 | decode_step_malloc (buffer, offset, body->file.uri, length - offset, 1); | 617 | decode_step_malloc(buffer, offset, body->file.uri, length - offset, 1); |
662 | break; | 618 | break; |
663 | case GNUNET_MESSENGER_KIND_PRIVATE: | 619 | case GNUNET_MESSENGER_KIND_PRIVATE: |
620 | decode_step(buffer, offset, &(body->privacy.key)); | ||
621 | |||
664 | body->privacy.length = (length - offset); | 622 | body->privacy.length = (length - offset); |
665 | decode_step_malloc (buffer, offset, body->privacy.data, length - offset, 0); | 623 | decode_step_malloc(buffer, offset, body->privacy.data, length - offset, 0); |
666 | break; | 624 | break; |
667 | case GNUNET_MESSENGER_KIND_DELETE: | 625 | case GNUNET_MESSENGER_KIND_DELETE: |
668 | decode_step (buffer, offset, &(body->deletion.hash)); | 626 | decode_step(buffer, offset, &(body->deletion.hash)); |
669 | decode_step (buffer, offset, &(body->deletion.delay)); | 627 | decode_step(buffer, offset, &(body->deletion.delay)); |
670 | break; | 628 | break; |
671 | default: | 629 | default: |
672 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; | 630 | *kind = GNUNET_MESSENGER_KIND_UNKNOWN; |
@@ -676,7 +634,6 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind, | |||
676 | return padding; | 634 | return padding; |
677 | } | 635 | } |
678 | 636 | ||
679 | |||
680 | int | 637 | int |
681 | decode_message (struct GNUNET_MESSENGER_Message *message, | 638 | decode_message (struct GNUNET_MESSENGER_Message *message, |
682 | uint16_t length, | 639 | uint16_t length, |
@@ -684,20 +641,19 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
684 | int include_header, | 641 | int include_header, |
685 | uint16_t *padding) | 642 | uint16_t *padding) |
686 | { | 643 | { |
687 | GNUNET_assert ( | 644 | GNUNET_assert( |
688 | (message) && | 645 | (message) && |
689 | (buffer) && | 646 | (buffer) && |
690 | (length >= get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, | 647 | (length >= get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, include_header)) |
691 | include_header)) | 648 | ); |
692 | ); | ||
693 | 649 | ||
694 | uint16_t offset = 0; | 650 | uint16_t offset = 0; |
695 | 651 | ||
696 | if (GNUNET_YES == include_header) | 652 | if (GNUNET_YES == include_header) |
697 | { | 653 | { |
698 | ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer ( | 654 | ssize_t result = GNUNET_IDENTITY_read_signature_from_buffer( |
699 | &(message->header.signature), buffer, length - offset | 655 | &(message->header.signature), buffer, length - offset |
700 | ); | 656 | ); |
701 | 657 | ||
702 | if (result < 0) | 658 | if (result < 0) |
703 | return GNUNET_NO; | 659 | return GNUNET_NO; |
@@ -707,30 +663,26 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
707 | 663 | ||
708 | const uint16_t count = length - offset; | 664 | const uint16_t count = length - offset; |
709 | 665 | ||
710 | if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, | 666 | if (count < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, include_header)) |
711 | include_header)) | ||
712 | return GNUNET_NO; | 667 | return GNUNET_NO; |
713 | 668 | ||
714 | kind_t kind; | 669 | kind_t kind; |
715 | 670 | ||
716 | if (GNUNET_YES == include_header) | 671 | if (GNUNET_YES == include_header) |
717 | { | 672 | { |
718 | decode_step (buffer, offset, &(message->header.timestamp)); | 673 | decode_step(buffer, offset, &(message->header.timestamp)); |
719 | decode_step (buffer, offset, &(message->header.sender_id)); | 674 | decode_step(buffer, offset, &(message->header.sender_id)); |
720 | decode_step (buffer, offset, &(message->header.previous)); | 675 | decode_step(buffer, offset, &(message->header.previous)); |
721 | } | 676 | } |
722 | 677 | ||
723 | decode_step (buffer, offset, &kind); | 678 | decode_step(buffer, offset, &kind); |
724 | 679 | ||
725 | message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh ( | 680 | message->header.kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind); |
726 | kind); | ||
727 | 681 | ||
728 | if (count < get_message_kind_size (message->header.kind, include_header)) | 682 | if (count < get_message_kind_size (message->header.kind, include_header)) |
729 | return GNUNET_NO; | 683 | return GNUNET_NO; |
730 | 684 | ||
731 | const uint16_t result = decode_message_body (&(message->header.kind), | 685 | const uint16_t result = decode_message_body (&(message->header.kind), &(message->body), length, buffer, offset); |
732 | &(message->body), length, buffer, | ||
733 | offset); | ||
734 | 686 | ||
735 | if (padding) | 687 | if (padding) |
736 | *padding = result; | 688 | *padding = result; |
@@ -738,7 +690,6 @@ decode_message (struct GNUNET_MESSENGER_Message *message, | |||
738 | return GNUNET_YES; | 690 | return GNUNET_YES; |
739 | } | 691 | } |
740 | 692 | ||
741 | |||
742 | static int | 693 | static int |
743 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | 694 | decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, |
744 | uint16_t length, | 695 | uint16_t length, |
@@ -750,28 +701,27 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | |||
750 | if (length < get_short_message_size (NULL, GNUNET_NO)) | 701 | if (length < get_short_message_size (NULL, GNUNET_NO)) |
751 | return GNUNET_NO; | 702 | return GNUNET_NO; |
752 | 703 | ||
753 | GNUNET_memcpy (&hash, buffer, sizeof(hash)); | 704 | GNUNET_memcpy(&hash, buffer, sizeof(hash)); |
754 | 705 | ||
755 | GNUNET_CRYPTO_hash ( | 706 | GNUNET_CRYPTO_hash( |
756 | buffer + sizeof(hash), | 707 | buffer + sizeof(hash), |
757 | length - sizeof(hash), | 708 | length - sizeof(hash), |
758 | &expected | 709 | &expected |
759 | ); | 710 | ); |
760 | 711 | ||
761 | if (0 != GNUNET_CRYPTO_hash_cmp (&hash, &expected)) | 712 | if (0 != GNUNET_CRYPTO_hash_cmp(&hash, &expected)) |
762 | return GNUNET_NO; | 713 | return GNUNET_NO; |
763 | 714 | ||
764 | kind_t kind; | 715 | kind_t kind; |
765 | 716 | ||
766 | decode_step (buffer, offset, &kind); | 717 | decode_step(buffer, offset, &kind); |
767 | 718 | ||
768 | message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh (kind); | 719 | message->kind = (enum GNUNET_MESSENGER_MessageKind) GNUNET_be32toh(kind); |
769 | 720 | ||
770 | if (length < get_short_message_size (message, GNUNET_NO)) | 721 | if (length < get_short_message_size (message, GNUNET_NO)) |
771 | return GNUNET_NO; | 722 | return GNUNET_NO; |
772 | 723 | ||
773 | decode_message_body (&(message->kind), &(message->body), length, buffer, | 724 | decode_message_body (&(message->kind), &(message->body), length, buffer, offset); |
774 | offset); | ||
775 | 725 | ||
776 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind) | 726 | if (GNUNET_MESSENGER_KIND_UNKNOWN == message->kind) |
777 | return GNUNET_NO; | 727 | return GNUNET_NO; |
@@ -779,53 +729,81 @@ decode_short_message (struct GNUNET_MESSENGER_ShortMessage *message, | |||
779 | return GNUNET_YES; | 729 | return GNUNET_YES; |
780 | } | 730 | } |
781 | 731 | ||
782 | |||
783 | void | 732 | void |
784 | hash_message (const struct GNUNET_MESSENGER_Message *message, | 733 | hash_message (const struct GNUNET_MESSENGER_Message *message, |
785 | uint16_t length, | 734 | uint16_t length, |
786 | const char *buffer, | 735 | const char *buffer, |
787 | struct GNUNET_HashCode *hash) | 736 | struct GNUNET_HashCode *hash) |
788 | { | 737 | { |
789 | GNUNET_assert ((message) && (buffer) && (hash)); | 738 | GNUNET_assert((message) && (buffer) && (hash)); |
790 | 739 | ||
791 | const ssize_t offset = GNUNET_IDENTITY_signature_get_length ( | 740 | const ssize_t offset = GNUNET_IDENTITY_signature_get_length( |
792 | &(message->header.signature) | 741 | &(message->header.signature) |
793 | ); | 742 | ); |
794 | 743 | ||
795 | GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash); | 744 | GNUNET_CRYPTO_hash (buffer + offset, length - offset, hash); |
796 | } | 745 | } |
797 | 746 | ||
798 | |||
799 | void | 747 | void |
800 | sign_message (struct GNUNET_MESSENGER_Message *message, | 748 | sign_message (struct GNUNET_MESSENGER_Message *message, |
801 | uint16_t length, | 749 | uint16_t length, |
802 | char *buffer, | 750 | char *buffer, |
803 | const struct GNUNET_HashCode *hash, | 751 | const struct GNUNET_HashCode *hash, |
804 | const struct GNUNET_MESSENGER_Ego *ego) | 752 | const struct GNUNET_IDENTITY_PrivateKey *key) |
805 | { | 753 | { |
806 | GNUNET_assert ((message) && (buffer) && (hash) && (ego)); | 754 | GNUNET_assert((message) && (buffer) && (hash) && (key)); |
755 | |||
756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sign message by member: %s\n", | ||
757 | GNUNET_h2s (hash)); | ||
807 | 758 | ||
808 | struct GNUNET_MESSENGER_MessageSignature signature; | 759 | struct GNUNET_MESSENGER_MessageSignature signature; |
809 | 760 | ||
810 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | 761 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); |
811 | signature.purpose.size = htonl (sizeof(signature)); | 762 | signature.purpose.size = htonl (sizeof(signature)); |
812 | 763 | ||
813 | GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | 764 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); |
814 | GNUNET_IDENTITY_sign (&(ego->priv), &signature, &(message->header.signature)); | 765 | GNUNET_IDENTITY_sign(key, &signature, &(message->header.signature)); |
766 | |||
767 | message->header.signature.type = key->type; | ||
815 | 768 | ||
816 | uint16_t offset = 0; | 769 | uint16_t offset = 0; |
817 | encode_step_signature (buffer, offset, &(message->header.signature), length); | 770 | encode_step_signature(buffer, offset, &(message->header.signature), length); |
818 | } | 771 | } |
819 | 772 | ||
773 | void | ||
774 | sign_message_by_peer (struct GNUNET_MESSENGER_Message *message, | ||
775 | uint16_t length, | ||
776 | char *buffer, | ||
777 | const struct GNUNET_HashCode *hash, | ||
778 | const struct GNUNET_CONFIGURATION_Handle* cfg) | ||
779 | { | ||
780 | GNUNET_assert((message) && (buffer) && (hash) && (cfg)); | ||
781 | |||
782 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sign message by peer: %s\n", | ||
783 | GNUNET_h2s (hash)); | ||
784 | |||
785 | struct GNUNET_MESSENGER_MessageSignature signature; | ||
786 | |||
787 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | ||
788 | signature.purpose.size = htonl (sizeof(signature)); | ||
789 | |||
790 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | ||
791 | GNUNET_CRYPTO_sign_by_peer_identity(cfg, &signature.purpose, &(message->header.signature.eddsa_signature)); | ||
792 | |||
793 | message->header.signature.type = htonl (GNUNET_IDENTITY_TYPE_EDDSA); | ||
794 | |||
795 | uint16_t offset = 0; | ||
796 | encode_step_signature(buffer, offset, &(message->header.signature), length); | ||
797 | } | ||
820 | 798 | ||
821 | int | 799 | int |
822 | verify_message (const struct GNUNET_MESSENGER_Message *message, | 800 | verify_message (const struct GNUNET_MESSENGER_Message *message, |
823 | const struct GNUNET_HashCode *hash, | 801 | const struct GNUNET_HashCode *hash, |
824 | const struct GNUNET_IDENTITY_PublicKey *key) | 802 | const struct GNUNET_IDENTITY_PublicKey *key) |
825 | { | 803 | { |
826 | GNUNET_assert ((message) && (hash) && (key)); | 804 | GNUNET_assert((message) && (hash) && (key)); |
827 | 805 | ||
828 | if (ntohl (key->type) != ntohl (message->header.signature.type)) | 806 | if (key->type != message->header.signature.type) |
829 | return GNUNET_SYSERR; | 807 | return GNUNET_SYSERR; |
830 | 808 | ||
831 | struct GNUNET_MESSENGER_MessageSignature signature; | 809 | struct GNUNET_MESSENGER_MessageSignature signature; |
@@ -833,19 +811,41 @@ verify_message (const struct GNUNET_MESSENGER_Message *message, | |||
833 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | 811 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); |
834 | signature.purpose.size = htonl (sizeof(signature)); | 812 | signature.purpose.size = htonl (sizeof(signature)); |
835 | 813 | ||
836 | GNUNET_memcpy (&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | 814 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); |
837 | 815 | ||
838 | return GNUNET_IDENTITY_signature_verify ( | 816 | return GNUNET_IDENTITY_signature_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, &signature, |
839 | GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, &signature, | 817 | &(message->header.signature), key); |
840 | &(message->header.signature), key); | ||
841 | } | 818 | } |
842 | 819 | ||
820 | int | ||
821 | verify_message_by_peer (const struct GNUNET_MESSENGER_Message *message, | ||
822 | const struct GNUNET_HashCode *hash, | ||
823 | const struct GNUNET_PeerIdentity *identity) | ||
824 | { | ||
825 | GNUNET_assert((message) && (hash) && (identity)); | ||
826 | |||
827 | if (ntohl (GNUNET_IDENTITY_TYPE_EDDSA) != message->header.signature.type) | ||
828 | return GNUNET_SYSERR; | ||
829 | |||
830 | struct GNUNET_MESSENGER_MessageSignature signature; | ||
831 | |||
832 | signature.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | ||
833 | signature.purpose.size = htonl (sizeof(signature)); | ||
834 | |||
835 | GNUNET_memcpy(&(signature.hash), hash, sizeof(struct GNUNET_HashCode)); | ||
836 | |||
837 | return GNUNET_CRYPTO_verify_peer_identity (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE, &signature.purpose, | ||
838 | &(message->header.signature.eddsa_signature), identity); | ||
839 | } | ||
843 | 840 | ||
844 | int | 841 | int |
845 | encrypt_message (struct GNUNET_MESSENGER_Message *message, | 842 | encrypt_message (struct GNUNET_MESSENGER_Message *message, |
846 | const struct GNUNET_IDENTITY_PublicKey *key) | 843 | const struct GNUNET_IDENTITY_PublicKey *key) |
847 | { | 844 | { |
848 | GNUNET_assert ((message) && (key)); | 845 | GNUNET_assert((message) && (key)); |
846 | |||
847 | if (GNUNET_YES == is_service_message(message)) | ||
848 | return GNUNET_NO; | ||
849 | 849 | ||
850 | struct GNUNET_MESSENGER_ShortMessage shortened; | 850 | struct GNUNET_MESSENGER_ShortMessage shortened; |
851 | 851 | ||
@@ -854,7 +854,7 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
854 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); | 854 | const uint16_t length = get_short_message_size (&shortened, GNUNET_YES); |
855 | const uint16_t padded_length = calc_padded_length ( | 855 | const uint16_t padded_length = calc_padded_length ( |
856 | length + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | 856 | length + GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES |
857 | ); | 857 | ); |
858 | 858 | ||
859 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; | 859 | message->header.kind = GNUNET_MESSENGER_KIND_PRIVATE; |
860 | message->body.privacy.data = GNUNET_malloc (padded_length); | 860 | message->body.privacy.data = GNUNET_malloc (padded_length); |
@@ -862,7 +862,7 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
862 | 862 | ||
863 | const uint16_t encoded_length = ( | 863 | const uint16_t encoded_length = ( |
864 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | 864 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES |
865 | ); | 865 | ); |
866 | 866 | ||
867 | encode_short_message (&shortened, encoded_length, message->body.privacy.data); | 867 | encode_short_message (&shortened, encoded_length, message->body.privacy.data); |
868 | 868 | ||
@@ -882,7 +882,6 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
882 | return GNUNET_YES; | 882 | return GNUNET_YES; |
883 | } | 883 | } |
884 | 884 | ||
885 | |||
886 | int | 885 | int |
887 | decrypt_message (struct GNUNET_MESSENGER_Message *message, | 886 | decrypt_message (struct GNUNET_MESSENGER_Message *message, |
888 | const struct GNUNET_IDENTITY_PrivateKey *key) | 887 | const struct GNUNET_IDENTITY_PrivateKey *key) |
@@ -901,7 +900,7 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
901 | 900 | ||
902 | const uint16_t encoded_length = ( | 901 | const uint16_t encoded_length = ( |
903 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES | 902 | padded_length - GNUNET_IDENTITY_ENCRYPT_OVERHEAD_BYTES |
904 | ); | 903 | ); |
905 | 904 | ||
906 | if (GNUNET_OK != GNUNET_IDENTITY_decrypt (message->body.privacy.data, | 905 | if (GNUNET_OK != GNUNET_IDENTITY_decrypt (message->body.privacy.data, |
907 | padded_length, | 906 | padded_length, |
@@ -930,34 +929,29 @@ decrypt_message (struct GNUNET_MESSENGER_Message *message, | |||
930 | return GNUNET_YES; | 929 | return GNUNET_YES; |
931 | } | 930 | } |
932 | 931 | ||
933 | |||
934 | struct GNUNET_MQ_Envelope* | 932 | struct GNUNET_MQ_Envelope* |
935 | pack_message (struct GNUNET_MESSENGER_Message *message, | 933 | pack_message (struct GNUNET_MESSENGER_Message *message, |
936 | struct GNUNET_HashCode *hash, | 934 | struct GNUNET_HashCode *hash, |
937 | const struct GNUNET_MESSENGER_Ego *ego, | 935 | const GNUNET_MESSENGER_SignFunction sign, |
938 | int mode) | 936 | int mode, |
937 | const void *cls) | ||
939 | { | 938 | { |
940 | GNUNET_assert (message); | 939 | GNUNET_assert(message); |
941 | |||
942 | if (ego) | ||
943 | message->header.signature.type = ego->priv.type; | ||
944 | 940 | ||
945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 941 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Packing message kind=%u and sender: %s\n", |
946 | "Packing message kind=%u and sender: %s\n", | 942 | message->header.kind, GNUNET_sh2s(&(message->header.sender_id))); |
947 | message->header.kind, GNUNET_sh2s (&(message->header.sender_id))); | ||
948 | 943 | ||
949 | struct GNUNET_MessageHeader *header; | 944 | struct GNUNET_MessageHeader *header; |
950 | 945 | ||
951 | const uint16_t length = get_message_size (message, GNUNET_YES); | 946 | const uint16_t length = get_message_size (message, GNUNET_YES); |
952 | const uint16_t padded_length = calc_padded_length (length); | 947 | const uint16_t padded_length = calc_padded_length(length); |
953 | 948 | ||
954 | struct GNUNET_MQ_Envelope *env; | 949 | struct GNUNET_MQ_Envelope *env; |
955 | char *buffer; | 950 | char *buffer; |
956 | 951 | ||
957 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE == mode) | 952 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE == mode) |
958 | { | 953 | { |
959 | env = GNUNET_MQ_msg_extra (header, padded_length, | 954 | env = GNUNET_MQ_msg_extra(header, padded_length, GNUNET_MESSAGE_TYPE_CADET_CLI); |
960 | GNUNET_MESSAGE_TYPE_CADET_CLI); | ||
961 | 955 | ||
962 | buffer = (char*) &(header[1]); | 956 | buffer = (char*) &(header[1]); |
963 | } | 957 | } |
@@ -965,7 +959,7 @@ pack_message (struct GNUNET_MESSENGER_Message *message, | |||
965 | { | 959 | { |
966 | env = NULL; | 960 | env = NULL; |
967 | 961 | ||
968 | buffer = GNUNET_malloc (padded_length); | 962 | buffer = GNUNET_malloc(padded_length); |
969 | } | 963 | } |
970 | 964 | ||
971 | encode_message (message, padded_length, buffer, GNUNET_YES); | 965 | encode_message (message, padded_length, buffer, GNUNET_YES); |
@@ -974,20 +968,80 @@ pack_message (struct GNUNET_MESSENGER_Message *message, | |||
974 | { | 968 | { |
975 | hash_message (message, length, buffer, hash); | 969 | hash_message (message, length, buffer, hash); |
976 | 970 | ||
977 | if (ego) | 971 | if (sign) |
978 | sign_message (message, length, buffer, hash, ego); | 972 | sign (cls, message, length, buffer, hash); |
979 | } | 973 | } |
980 | 974 | ||
981 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE != mode) | 975 | if (GNUNET_MESSENGER_PACK_MODE_ENVELOPE != mode) |
982 | GNUNET_free (buffer); | 976 | GNUNET_free(buffer); |
983 | 977 | ||
984 | return env; | 978 | return env; |
985 | } | 979 | } |
986 | 980 | ||
981 | int | ||
982 | is_peer_message (const struct GNUNET_MESSENGER_Message *message) | ||
983 | { | ||
984 | switch (message->header.kind) | ||
985 | { | ||
986 | case GNUNET_MESSENGER_KIND_INFO: | ||
987 | case GNUNET_MESSENGER_KIND_PEER: | ||
988 | case GNUNET_MESSENGER_KIND_MISS: | ||
989 | case GNUNET_MESSENGER_KIND_MERGE: | ||
990 | return GNUNET_YES; | ||
991 | default: | ||
992 | return GNUNET_NO; | ||
993 | } | ||
994 | } | ||
995 | |||
996 | int | ||
997 | is_service_message (const struct GNUNET_MESSENGER_Message *message) | ||
998 | { | ||
999 | if (GNUNET_YES == is_peer_message(message)) | ||
1000 | return GNUNET_YES; | ||
1001 | |||
1002 | switch (message->header.kind) | ||
1003 | { | ||
1004 | case GNUNET_MESSENGER_KIND_INFO: | ||
1005 | return GNUNET_YES; // Reserved for connection handling only! | ||
1006 | case GNUNET_MESSENGER_KIND_JOIN: | ||
1007 | return GNUNET_YES; // Reserved for member handling only! | ||
1008 | case GNUNET_MESSENGER_KIND_LEAVE: | ||
1009 | return GNUNET_YES; // Reserved for member handling only! | ||
1010 | case GNUNET_MESSENGER_KIND_NAME: | ||
1011 | return GNUNET_YES; // Reserved for member name handling only! | ||
1012 | case GNUNET_MESSENGER_KIND_KEY: | ||
1013 | return GNUNET_YES; // Reserved for member key handling only! | ||
1014 | case GNUNET_MESSENGER_KIND_PEER: | ||
1015 | return GNUNET_YES; // Reserved for connection handling only! | ||
1016 | case GNUNET_MESSENGER_KIND_ID: | ||
1017 | return GNUNET_YES; // Reserved for member id handling only! | ||
1018 | case GNUNET_MESSENGER_KIND_MISS: | ||
1019 | return GNUNET_YES; // Reserved for connection handling only! | ||
1020 | case GNUNET_MESSENGER_KIND_MERGE: | ||
1021 | return GNUNET_YES; // Reserved for peers only! | ||
1022 | case GNUNET_MESSENGER_KIND_REQUEST: | ||
1023 | return GNUNET_YES; // Requests should not apply individually! (inefficieny) | ||
1024 | case GNUNET_MESSENGER_KIND_INVITE: | ||
1025 | return GNUNET_NO; | ||
1026 | case GNUNET_MESSENGER_KIND_TEXT: | ||
1027 | return GNUNET_NO; | ||
1028 | case GNUNET_MESSENGER_KIND_FILE: | ||
1029 | return GNUNET_NO; | ||
1030 | case GNUNET_MESSENGER_KIND_PRIVATE: | ||
1031 | return GNUNET_YES; // Prevent duplicate encryption breaking all access! | ||
1032 | case GNUNET_MESSENGER_KIND_DELETE: | ||
1033 | return GNUNET_YES; // Deletion should not apply individually! (inefficieny) | ||
1034 | default: | ||
1035 | return GNUNET_SYSERR; | ||
1036 | } | ||
1037 | } | ||
987 | 1038 | ||
988 | int | 1039 | int |
989 | filter_message_sending (const struct GNUNET_MESSENGER_Message *message) | 1040 | filter_message_sending (const struct GNUNET_MESSENGER_Message *message) |
990 | { | 1041 | { |
1042 | if (GNUNET_YES == is_peer_message(message)) | ||
1043 | return GNUNET_SYSERR; // Requires signature of peer rather than ego! | ||
1044 | |||
991 | switch (message->header.kind) | 1045 | switch (message->header.kind) |
992 | { | 1046 | { |
993 | case GNUNET_MESSENGER_KIND_INFO: | 1047 | case GNUNET_MESSENGER_KIND_INFO: |
@@ -999,15 +1053,15 @@ filter_message_sending (const struct GNUNET_MESSENGER_Message *message) | |||
999 | case GNUNET_MESSENGER_KIND_NAME: | 1053 | case GNUNET_MESSENGER_KIND_NAME: |
1000 | return GNUNET_YES; | 1054 | return GNUNET_YES; |
1001 | case GNUNET_MESSENGER_KIND_KEY: | 1055 | case GNUNET_MESSENGER_KIND_KEY: |
1002 | return GNUNET_NO; // Use #GNUNET_MESSENGER_update(...) instead! | 1056 | return GNUNET_NO; // Use #GNUNET_MESSENGER_set_key_by_ego(...) instead! |
1003 | case GNUNET_MESSENGER_KIND_PEER: | 1057 | case GNUNET_MESSENGER_KIND_PEER: |
1004 | return GNUNET_NO; // Use #GNUNET_MESSENGER_open_room(...) instead! | 1058 | return GNUNET_SYSERR; // Use #GNUNET_MESSENGER_open_room(...) instead! |
1005 | case GNUNET_MESSENGER_KIND_ID: | 1059 | case GNUNET_MESSENGER_KIND_ID: |
1006 | return GNUNET_SYSERR; // Reserved for member id handling only! | 1060 | return GNUNET_NO; // Reserved for member id handling only! |
1007 | case GNUNET_MESSENGER_KIND_MISS: | 1061 | case GNUNET_MESSENGER_KIND_MISS: |
1008 | return GNUNET_SYSERR; // Reserved for connection handling only! | 1062 | return GNUNET_SYSERR; // Reserved for connection handling only! |
1009 | case GNUNET_MESSENGER_KIND_MERGE: | 1063 | case GNUNET_MESSENGER_KIND_MERGE: |
1010 | return GNUNET_YES; | 1064 | return GNUNET_SYSERR; // Reserved for peers only! |
1011 | case GNUNET_MESSENGER_KIND_REQUEST: | 1065 | case GNUNET_MESSENGER_KIND_REQUEST: |
1012 | return GNUNET_YES; | 1066 | return GNUNET_YES; |
1013 | case GNUNET_MESSENGER_KIND_INVITE: | 1067 | case GNUNET_MESSENGER_KIND_INVITE: |