aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-10-29 18:41:16 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-10-29 18:41:16 +0900
commitd7147f52d822da0022e59b2b666091ef548222a6 (patch)
tree8d2d803f90c759c4f84ab5f99560497d6b9ca17a
parent914fd6adac878abfa3050568ba02a1c57a150e8e (diff)
downloadgnunet-d7147f52d822da0022e59b2b666091ef548222a6.tar.gz
gnunet-d7147f52d822da0022e59b2b666091ef548222a6.zip
-fix ftbfs
-rw-r--r--src/messenger/gnunet-service-messenger.c247
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c4
-rw-r--r--src/messenger/messenger_api.c14
-rw-r--r--src/messenger/messenger_api_message.c13
4 files changed, 171 insertions, 107 deletions
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index 506ab7443..974bdbd37 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -42,7 +42,7 @@ static int
42check_create (void *cls, 42check_create (void *cls,
43 const struct GNUNET_MESSENGER_CreateMessage *msg) 43 const struct GNUNET_MESSENGER_CreateMessage *msg)
44{ 44{
45 GNUNET_MQ_check_zero_termination(msg); 45 GNUNET_MQ_check_zero_termination (msg);
46 return GNUNET_OK; 46 return GNUNET_OK;
47} 47}
48 48
@@ -54,7 +54,7 @@ handle_create (void *cls,
54 54
55 const char *name = ((const char*) msg) + sizeof(*msg); 55 const char *name = ((const char*) msg) + sizeof(*msg);
56 56
57 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name); 57 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name);
58 58
59 setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL); 59 setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL);
60 60
@@ -85,7 +85,7 @@ static int
85check_set_name (void *cls, 85check_set_name (void *cls,
86 const struct GNUNET_MESSENGER_NameMessage *msg) 86 const struct GNUNET_MESSENGER_NameMessage *msg)
87{ 87{
88 GNUNET_MQ_check_zero_termination(msg); 88 GNUNET_MQ_check_zero_termination (msg);
89 return GNUNET_OK; 89 return GNUNET_OK;
90} 90}
91 91
@@ -97,7 +97,7 @@ handle_set_name (void *cls,
97 97
98 const char *name = ((const char*) msg) + sizeof(*msg); 98 const char *name = ((const char*) msg) + sizeof(*msg);
99 99
100 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name); 100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name);
101 101
102 set_srv_handle_name (msg_client->handle, name); 102 set_srv_handle_name (msg_client->handle, name);
103 103
@@ -110,23 +110,27 @@ handle_room_open (void *cls,
110{ 110{
111 struct GNUNET_MESSENGER_Client *msg_client = cls; 111 struct GNUNET_MESSENGER_Client *msg_client = cls;
112 112
113 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (&(msg->key))); 113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (
114 &(msg->key)));
114 115
115 if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key))) 116 if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key)))
116 { 117 {
117 const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key)); 118 const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
119 msg_client->handle, &(msg->key));
118 120
119 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n", GNUNET_sh2s (member_id)); 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n",
122 GNUNET_sh2s (member_id));
120 123
121 struct GNUNET_MESSENGER_RoomMessage *response; 124 struct GNUNET_MESSENGER_RoomMessage *response;
122 struct GNUNET_MQ_Envelope *env; 125 struct GNUNET_MQ_Envelope *env;
123 126
124 env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN); 127 env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN);
125 GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); 128 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
126 GNUNET_MQ_send (msg_client->handle->mq, env); 129 GNUNET_MQ_send (msg_client->handle->mq, env);
127 } 130 }
128 else 131 else
129 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n", GNUNET_h2s (&(msg->key))); 132 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n",
133 GNUNET_h2s (&(msg->key)));
130 134
131 GNUNET_SERVICE_client_continue (msg_client->client); 135 GNUNET_SERVICE_client_continue (msg_client->client);
132} 136}
@@ -137,25 +141,30 @@ handle_room_entry (void *cls,
137{ 141{
138 struct GNUNET_MESSENGER_Client *msg_client = cls; 142 struct GNUNET_MESSENGER_Client *msg_client = cls;
139 143
140 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (&(msg->key)), GNUNET_i2s (&(msg->door))); 144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (
145 &(msg->key)), GNUNET_i2s (&(msg->door)));
141 146
142 if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door), &(msg->key))) 147 if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door),
148 &(msg->key)))
143 { 149 {
144 const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (msg_client->handle, &(msg->key)); 150 const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
151 msg_client->handle, &(msg->key));
145 152
146 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n", GNUNET_sh2s (member_id)); 153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n",
154 GNUNET_sh2s (member_id));
147 155
148 struct GNUNET_MESSENGER_RoomMessage *response; 156 struct GNUNET_MESSENGER_RoomMessage *response;
149 struct GNUNET_MQ_Envelope *env; 157 struct GNUNET_MQ_Envelope *env;
150 158
151 env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY); 159 env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY);
152 GNUNET_memcpy(&(response->door), &(msg->door), sizeof(msg->door)); 160 GNUNET_memcpy (&(response->door), &(msg->door), sizeof(msg->door));
153 GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); 161 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
154 GNUNET_MQ_send (msg_client->handle->mq, env); 162 GNUNET_MQ_send (msg_client->handle->mq, env);
155 } 163 }
156 else 164 else
157 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n", GNUNET_h2s (&(msg->key)), 165 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n",
158 GNUNET_i2s (&(msg->door))); 166 GNUNET_h2s (&(msg->key)),
167 GNUNET_i2s (&(msg->door)));
159 168
160 GNUNET_SERVICE_client_continue (msg_client->client); 169 GNUNET_SERVICE_client_continue (msg_client->client);
161} 170}
@@ -166,21 +175,24 @@ handle_room_close (void *cls,
166{ 175{
167 struct GNUNET_MESSENGER_Client *msg_client = cls; 176 struct GNUNET_MESSENGER_Client *msg_client = cls;
168 177
169 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (&(msg->key))); 178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (
179 &(msg->key)));
170 180
171 if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key))) 181 if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key)))
172 { 182 {
173 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n", GNUNET_h2s (&(msg->key))); 183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n",
184 GNUNET_h2s (&(msg->key)));
174 185
175 struct GNUNET_MESSENGER_RoomMessage *response; 186 struct GNUNET_MESSENGER_RoomMessage *response;
176 struct GNUNET_MQ_Envelope *env; 187 struct GNUNET_MQ_Envelope *env;
177 188
178 env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE); 189 env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE);
179 GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key)); 190 GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
180 GNUNET_MQ_send (msg_client->handle->mq, env); 191 GNUNET_MQ_send (msg_client->handle->mq, env);
181 } 192 }
182 else 193 else
183 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n", GNUNET_h2s (&(msg->key))); 194 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n",
195 GNUNET_h2s (&(msg->key)));
184 196
185 GNUNET_SERVICE_client_continue (msg_client->client); 197 GNUNET_SERVICE_client_continue (msg_client->client);
186} 198}
@@ -195,39 +207,42 @@ check_send_message (void *cls,
195 return GNUNET_NO; 207 return GNUNET_NO;
196 208
197 const enum GNUNET_MESSENGER_MessageFlags flags = ( 209 const enum GNUNET_MESSENGER_MessageFlags flags = (
198 (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) 210 (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
199 ); 211 );
200 212
201 const uint16_t length = full_length - sizeof(*msg); 213 const uint16_t length = full_length - sizeof(*msg);
202 const char *buffer = ((const char*) msg) + sizeof(*msg); 214 const char *buffer = ((const char*) msg) + sizeof(*msg);
203 215
204 ssize_t key_length = 0; 216 size_t key_length = 0;
205 217
206 if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE)) 218 if (! (flags & GNUNET_MESSENGER_FLAG_PRIVATE))
207 goto check_for_message; 219 goto check_for_message;
208 220
209 struct GNUNET_IDENTITY_PublicKey public_key; 221 struct GNUNET_IDENTITY_PublicKey public_key;
210 222
211 key_length = GNUNET_IDENTITY_read_key_from_buffer(&public_key, buffer, length); 223 if (GNUNET_SYSERR ==
212 224 GNUNET_IDENTITY_read_public_key_from_buffer (buffer, length,
213check_for_message: 225 &public_key,
214 if (key_length < 0) 226 &key_length))
215 return GNUNET_NO; 227 return GNUNET_NO;
216 228
229 check_for_message:
230
217 const uint16_t msg_length = length - key_length; 231 const uint16_t msg_length = length - key_length;
218 const char* msg_buffer = buffer + key_length; 232 const char*msg_buffer = buffer + key_length;
219 233
220 struct GNUNET_MESSENGER_Message message; 234 struct GNUNET_MESSENGER_Message message;
221 235
222 if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO)) 236 if (length < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO))
223 return GNUNET_NO; 237 return GNUNET_NO;
224 238
225 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL)) 239 if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO,
240 NULL))
226 return GNUNET_NO; 241 return GNUNET_NO;
227 242
228 const int allowed = filter_message_sending(&message); 243 const int allowed = filter_message_sending (&message);
229 244
230 cleanup_message(&message); 245 cleanup_message (&message);
231 return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO; 246 return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO;
232} 247}
233 248
@@ -238,45 +253,47 @@ handle_send_message (void *cls,
238 struct GNUNET_MESSENGER_Client *msg_client = cls; 253 struct GNUNET_MESSENGER_Client *msg_client = cls;
239 254
240 const enum GNUNET_MESSENGER_MessageFlags flags = ( 255 const enum GNUNET_MESSENGER_MessageFlags flags = (
241 (enum GNUNET_MESSENGER_MessageFlags) (msg->flags) 256 (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
242 ); 257 );
243 258
244 const struct GNUNET_HashCode *key = &(msg->key); 259 const struct GNUNET_HashCode *key = &(msg->key);
245 const char *buffer = ((const char*) msg) + sizeof(*msg); 260 const char *buffer = ((const char*) msg) + sizeof(*msg);
246 261
247 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg); 262 const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
248 ssize_t key_length = 0; 263 size_t key_length = 0;
249 264
250 struct GNUNET_IDENTITY_PublicKey public_key; 265 struct GNUNET_IDENTITY_PublicKey public_key;
251 266
252 if (flags & GNUNET_MESSENGER_FLAG_PRIVATE) 267 if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
253 key_length = GNUNET_IDENTITY_read_key_from_buffer( 268 GNUNET_IDENTITY_read_public_key_from_buffer (
254 &public_key, buffer, length 269 buffer, length, &public_key, &key_length);
255 );
256 270
257 const uint16_t msg_length = length - key_length; 271 const uint16_t msg_length = length - key_length;
258 const char* msg_buffer = buffer + key_length; 272 const char*msg_buffer = buffer + key_length;
259 273
260 struct GNUNET_MESSENGER_Message message; 274 struct GNUNET_MESSENGER_Message message;
261 decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL); 275 decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL);
262 276
263 if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) && 277 if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) &&
264 (GNUNET_YES != encrypt_message(&message, &public_key))) 278 (GNUNET_YES != encrypt_message (&message, &public_key)))
265 { 279 {
266 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Encrypting message failed: Message got dropped!\n"); 280 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
281 "Encrypting message failed: Message got dropped!\n");
267 282
268 goto end_handling; 283 goto end_handling;
269 } 284 }
270 285
271 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n", 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n",
272 GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key)); 287 GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (
288 key));
273 289
274 if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message)) 290 if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message))
275 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n", 291 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
276 GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key)); 292 GNUNET_MESSENGER_name_of_kind (message.header.kind),
293 GNUNET_h2s (key));
277 294
278end_handling: 295 end_handling:
279 cleanup_message(&message); 296 cleanup_message (&message);
280 297
281 GNUNET_SERVICE_client_continue (msg_client->client); 298 GNUNET_SERVICE_client_continue (msg_client->client);
282} 299}
@@ -289,26 +306,30 @@ callback_found_message (void *cls,
289{ 306{
290 struct GNUNET_MESSENGER_Client *msg_client = cls; 307 struct GNUNET_MESSENGER_Client *msg_client = cls;
291 308
292 if (!message) 309 if (! message)
293 { 310 {
294 send_srv_room_message(room, msg_client->handle, create_message_request(hash)); 311 send_srv_room_message (room, msg_client->handle, create_message_request (
312 hash));
295 return; 313 return;
296 } 314 }
297 315
298 struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store(room); 316 struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store (room);
299 317
300 struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message); 318 struct GNUNET_MESSENGER_Member *member = get_store_member_of (store, message);
301 319
302 if (!member) 320 if (! member)
303 { 321 {
304 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (hash)); 322 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n",
323 GNUNET_h2s (hash));
305 return; 324 return;
306 } 325 }
307 326
308 struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash); 327 struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of (
328 member, message, hash);
309 329
310 if (session) 330 if (session)
311 notify_srv_handle_message (msg_client->handle, room, session, message, hash); 331 notify_srv_handle_message (msg_client->handle, room, session, message,
332 hash);
312} 333}
313 334
314static void 335static void
@@ -317,39 +338,55 @@ handle_get_message (void *cls,
317{ 338{
318 struct GNUNET_MESSENGER_Client *msg_client = cls; 339 struct GNUNET_MESSENGER_Client *msg_client = cls;
319 340
320 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n", GNUNET_h2s (&(msg->key))); 341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n",
342 GNUNET_h2s (&(msg->key)));
321 343
322 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger, &(msg->key)); 344 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger,
345 &(msg->key));
323 346
324 if (!room) 347 if (! room)
325 { 348 {
326 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (&(msg->key))); 349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (
350 &(msg->key)));
327 goto end_handling; 351 goto end_handling;
328 } 352 }
329 353
330 struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room); 354 struct GNUNET_MESSENGER_MemberStore *member_store =
355 get_srv_room_member_store (room);
331 356
332 struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, get_srv_handle_member_id( 357 struct GNUNET_MESSENGER_Member *member = get_store_member (member_store,
333 msg_client->handle, &(msg->key) 358 get_srv_handle_member_id (
334 )); 359 msg_client->
360 handle,
361 &(msg->key)
362 ));
335 363
336 if (!member) 364 if (! member)
337 { 365 {
338 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Member not valid to request a message!\n"); 366 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
367 "Member not valid to request a message!\n");
339 goto end_handling; 368 goto end_handling;
340 } 369 }
341 370
342 struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_srv_handle_ego(msg_client->handle)->pub)); 371 struct GNUNET_MESSENGER_MemberSession *session = get_member_session (member,
372 &(
373 get_srv_handle_ego (
374 msg_client
375 ->
376 handle)
377 ->pub));
343 378
344 if (!session) 379 if (! session)
345 { 380 {
346 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Session not valid to request a message!\n"); 381 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
382 "Session not valid to request a message!\n");
347 goto end_handling; 383 goto end_handling;
348 } 384 }
349 385
350 request_srv_room_message (room, &(msg->hash), session, callback_found_message, msg_client); 386 request_srv_room_message (room, &(msg->hash), session, callback_found_message,
387 msg_client);
351 388
352end_handling: 389 end_handling:
353 GNUNET_SERVICE_client_continue (msg_client->client); 390 GNUNET_SERVICE_client_continue (msg_client->client);
354} 391}
355 392
@@ -358,7 +395,8 @@ callback_client_connect (void *cls,
358 struct GNUNET_SERVICE_Client *client, 395 struct GNUNET_SERVICE_Client *client,
359 struct GNUNET_MQ_Handle *mq) 396 struct GNUNET_MQ_Handle *mq)
360{ 397{
361 struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client); 398 struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new (struct
399 GNUNET_MESSENGER_Client);
362 400
363 msg_client->client = client; 401 msg_client->client = client;
364 msg_client->handle = add_service_handle (messenger, mq); 402 msg_client->handle = add_service_handle (messenger, mq);
@@ -375,7 +413,7 @@ callback_client_disconnect (void *cls,
375 413
376 remove_service_handle (messenger, msg_client->handle); 414 remove_service_handle (messenger, msg_client->handle);
377 415
378 GNUNET_free(msg_client); 416 GNUNET_free (msg_client);
379} 417}
380 418
381/** 419/**
@@ -392,27 +430,46 @@ run (void *cls,
392{ 430{
393 messenger = create_service (config, service); 431 messenger = create_service (config, service);
394 432
395 if (!messenger) 433 if (! messenger)
396 GNUNET_SCHEDULER_shutdown (); 434 GNUNET_SCHEDULER_shutdown ();
397} 435}
398 436
399/** 437/**
400 * Define "main" method using service macro. 438 * Define "main" method using service macro.
401 */ 439 */
402GNUNET_SERVICE_MAIN( 440GNUNET_SERVICE_MAIN (
403 GNUNET_MESSENGER_SERVICE_NAME, 441 GNUNET_MESSENGER_SERVICE_NAME,
404 GNUNET_SERVICE_OPTION_NONE, 442 GNUNET_SERVICE_OPTION_NONE,
405 &run, 443 &run,
406 &callback_client_connect, 444 &callback_client_connect,
407 &callback_client_disconnect, 445 &callback_client_disconnect,
408 NULL, 446 NULL,
409 GNUNET_MQ_hd_var_size( create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL ), 447 GNUNET_MQ_hd_var_size (create,
410 GNUNET_MQ_hd_fixed_size( update, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, struct GNUNET_MESSENGER_UpdateMessage, NULL ), 448 GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct
411 GNUNET_MQ_hd_fixed_size( destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL ), 449 GNUNET_MESSENGER_CreateMessage, NULL),
412 GNUNET_MQ_hd_var_size( set_name, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, struct GNUNET_MESSENGER_NameMessage, NULL ), 450 GNUNET_MQ_hd_fixed_size (update,
413 GNUNET_MQ_hd_fixed_size( room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL ), 451 GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE,
414 GNUNET_MQ_hd_fixed_size( room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL ), 452 struct
415 GNUNET_MQ_hd_fixed_size( room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL ), 453 GNUNET_MESSENGER_UpdateMessage, NULL),
416 GNUNET_MQ_hd_var_size( send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL ), 454 GNUNET_MQ_hd_fixed_size (destroy,
417 GNUNET_MQ_hd_fixed_size( get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_GetMessage, NULL ), 455 GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY,
418 GNUNET_MQ_handler_end()); 456 struct
457 GNUNET_MESSENGER_DestroyMessage, NULL),
458 GNUNET_MQ_hd_var_size (set_name,
459 GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME,
460 struct
461 GNUNET_MESSENGER_NameMessage, NULL),
462 GNUNET_MQ_hd_fixed_size (room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN,
463 struct GNUNET_MESSENGER_RoomMessage, NULL),
464 GNUNET_MQ_hd_fixed_size (room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY,
465 struct GNUNET_MESSENGER_RoomMessage, NULL),
466 GNUNET_MQ_hd_fixed_size (room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE,
467 struct GNUNET_MESSENGER_RoomMessage, NULL),
468 GNUNET_MQ_hd_var_size (send_message,
469 GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct
470 GNUNET_MESSENGER_SendMessage, NULL),
471 GNUNET_MQ_hd_fixed_size (get_message,
472 GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE,
473 struct
474 GNUNET_MESSENGER_GetMessage, NULL),
475 GNUNET_MQ_handler_end ());
diff --git a/src/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index a4fa81623..28fa022c7 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -216,7 +216,7 @@ change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
216 216
217 ego = get_srv_handle_ego (handle); 217 ego = get_srv_handle_ego (handle);
218 218
219 const uint16_t length = GNUNET_IDENTITY_key_get_length(&(ego->pub)); 219 const uint16_t length = GNUNET_IDENTITY_public_key_get_length(&(ego->pub));
220 220
221 struct GNUNET_MESSENGER_KeyMessage *msg; 221 struct GNUNET_MESSENGER_KeyMessage *msg;
222 struct GNUNET_MQ_Envelope *env; 222 struct GNUNET_MQ_Envelope *env;
@@ -225,7 +225,7 @@ change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
225 225
226 char *extra = ((char*) msg) + sizeof(*msg); 226 char *extra = ((char*) msg) + sizeof(*msg);
227 227
228 if (GNUNET_IDENTITY_write_key_to_buffer(&(ego->pub), extra, length) < 0) 228 if (GNUNET_IDENTITY_write_public_key_to_buffer(&(ego->pub), extra, length) < 0)
229 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Could not write key to buffer.\n"); 229 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Could not write key to buffer.\n");
230 230
231 GNUNET_MQ_send (handle->mq, env); 231 GNUNET_MQ_send (handle->mq, env);
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index 8cbe26549..85092fc43 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -105,7 +105,10 @@ check_get_key (void *cls,
105 const char *buffer = ((const char*) msg) + sizeof(*msg); 105 const char *buffer = ((const char*) msg) + sizeof(*msg);
106 106
107 struct GNUNET_IDENTITY_PublicKey pubkey; 107 struct GNUNET_IDENTITY_PublicKey pubkey;
108 if (GNUNET_IDENTITY_read_key_from_buffer(&pubkey, buffer, length) < 0) 108 size_t read;
109 if (GNUNET_SYSERR ==
110 GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length,
111 &pubkey, &read))
109 return GNUNET_NO; 112 return GNUNET_NO;
110 113
111 return GNUNET_OK; 114 return GNUNET_OK;
@@ -121,7 +124,10 @@ handle_get_key (void *cls,
121 const char *buffer = ((const char*) msg) + sizeof(*msg); 124 const char *buffer = ((const char*) msg) + sizeof(*msg);
122 125
123 struct GNUNET_IDENTITY_PublicKey pubkey; 126 struct GNUNET_IDENTITY_PublicKey pubkey;
124 if (GNUNET_IDENTITY_read_key_from_buffer(&pubkey, buffer, length) < 0) 127 size_t read;
128 if (GNUNET_SYSERR ==
129 GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length,
130 &pubkey, &read))
125 return; 131 return;
126 132
127 char* str = GNUNET_IDENTITY_public_key_to_string (&pubkey); 133 char* str = GNUNET_IDENTITY_public_key_to_string (&pubkey);
@@ -719,7 +725,7 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
719 ); 725 );
720 726
721 if (public_key) 727 if (public_key)
722 key_length = GNUNET_IDENTITY_key_get_length(public_key); 728 key_length = GNUNET_IDENTITY_public_key_get_length(public_key);
723 else 729 else
724 key_length = -1; 730 key_length = -1;
725 } 731 }
@@ -752,7 +758,7 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
752 char *msg_buffer = buffer + key_length; 758 char *msg_buffer = buffer + key_length;
753 759
754 if (key_length > 0) 760 if (key_length > 0)
755 GNUNET_IDENTITY_write_key_to_buffer(get_contact_key(contact), buffer, key_length); 761 GNUNET_IDENTITY_write_public_key_to_buffer(get_contact_key(contact), buffer, key_length);
756 762
757 encode_message (message, msg_length, msg_buffer, GNUNET_NO); 763 encode_message (message, msg_length, msg_buffer, GNUNET_NO);
758 764
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index 3814def70..2e4f46bff 100644
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -259,16 +259,16 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind,
259 switch (kind) 259 switch (kind)
260 { 260 {
261 case GNUNET_MESSENGER_KIND_INFO: 261 case GNUNET_MESSENGER_KIND_INFO:
262 length += GNUNET_IDENTITY_key_get_length(&(body->info.host_key)); 262 length += GNUNET_IDENTITY_public_key_get_length(&(body->info.host_key));
263 break; 263 break;
264 case GNUNET_MESSENGER_KIND_JOIN: 264 case GNUNET_MESSENGER_KIND_JOIN:
265 length += GNUNET_IDENTITY_key_get_length(&(body->join.key)); 265 length += GNUNET_IDENTITY_public_key_get_length(&(body->join.key));
266 break; 266 break;
267 case GNUNET_MESSENGER_KIND_NAME: 267 case GNUNET_MESSENGER_KIND_NAME:
268 length += (body->name.name ? strlen (body->name.name) : 0); 268 length += (body->name.name ? strlen (body->name.name) : 0);
269 break; 269 break;
270 case GNUNET_MESSENGER_KIND_KEY: 270 case GNUNET_MESSENGER_KIND_KEY:
271 length += GNUNET_IDENTITY_key_get_length(&(body->key.key)); 271 length += GNUNET_IDENTITY_public_key_get_length(&(body->key.key));
272 break; 272 break;
273 case GNUNET_MESSENGER_KIND_TEXT: 273 case GNUNET_MESSENGER_KIND_TEXT:
274 length += strlen (body->text.text); 274 length += strlen (body->text.text);
@@ -372,7 +372,7 @@ calc_padded_length (uint16_t length)
372} while (0) 372} while (0)
373 373
374#define encode_step_key(dst, offset, src, length) do { \ 374#define encode_step_key(dst, offset, src, length) do { \
375 ssize_t result = GNUNET_IDENTITY_write_key_to_buffer( \ 375 ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer( \
376 src, dst + offset, length - offset \ 376 src, dst + offset, length - offset \
377 ); \ 377 ); \
378 if (result < 0) \ 378 if (result < 0) \
@@ -539,8 +539,9 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message,
539} while (0) 539} while (0)
540 540
541#define decode_step_key(src, offset, dst, length) do { \ 541#define decode_step_key(src, offset, dst, length) do { \
542 ssize_t result = GNUNET_IDENTITY_read_key_from_buffer( \ 542 size_t read; \
543 dst, src + offset, length - offset \ 543 ssize_t result = GNUNET_IDENTITY_read_public_key_from_buffer( \
544 src + offset, length - offset, dst, &read \
544 ); \ 545 ); \
545 if (result < 0) \ 546 if (result < 0) \
546 GNUNET_break(0); \ 547 GNUNET_break(0); \