diff options
author | Gabor X Toth <*@tg-x.net> | 2016-09-24 00:38:39 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2016-09-24 00:38:39 +0000 |
commit | 8b6ec81b6bb0cb27845cb59ebc864041a250201d (patch) | |
tree | 15e098a97e18785626ea4c432b952c8e01ae9cc6 /src/social | |
parent | 238594c75922318bbe5b8b8ee62920bc3fd06d95 (diff) | |
download | gnunet-8b6ec81b6bb0cb27845cb59ebc864041a250201d.tar.gz gnunet-8b6ec81b6bb0cb27845cb59ebc864041a250201d.zip |
social: switch to SERVICE API
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 781 | ||||
-rw-r--r-- | src/social/social.h | 6 | ||||
-rw-r--r-- | src/social/social_api.c | 1 |
3 files changed, 472 insertions, 316 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 681d469bc..685eb71ca 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -46,6 +46,11 @@ | |||
46 | */ | 46 | */ |
47 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 47 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
48 | 48 | ||
49 | /** | ||
50 | * Service handle. | ||
51 | */ | ||
52 | struct GNUNET_SERVICE_Handle *service; | ||
53 | |||
49 | /* Handles to other services */ | 54 | /* Handles to other services */ |
50 | static struct GNUNET_IDENTITY_Handle *id; | 55 | static struct GNUNET_IDENTITY_Handle *id; |
51 | static struct GNUNET_GNS_Handle *gns; | 56 | static struct GNUNET_GNS_Handle *gns; |
@@ -58,11 +63,6 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
58 | static struct GNUNET_PeerIdentity this_peer; | 63 | static struct GNUNET_PeerIdentity this_peer; |
59 | 64 | ||
60 | /** | 65 | /** |
61 | * Notification context, simplifies client broadcasts. | ||
62 | */ | ||
63 | static struct GNUNET_SERVER_NotificationContext *nc; | ||
64 | |||
65 | /** | ||
66 | * All connected hosts. | 66 | * All connected hosts. |
67 | * H(place_pub_key) -> struct Host | 67 | * H(place_pub_key) -> struct Host |
68 | */ | 68 | */ |
@@ -137,7 +137,7 @@ struct FragmentTransmitQueue | |||
137 | struct FragmentTransmitQueue *prev; | 137 | struct FragmentTransmitQueue *prev; |
138 | struct FragmentTransmitQueue *next; | 138 | struct FragmentTransmitQueue *next; |
139 | 139 | ||
140 | struct GNUNET_SERVER_Client *client; | 140 | struct GNUNET_SERVICE_Client *client; |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Pointer to the next message part inside the data after this struct. | 143 | * Pointer to the next message part inside the data after this struct. |
@@ -169,7 +169,7 @@ struct MessageTransmitQueue | |||
169 | struct FragmentTransmitQueue *frags_head; | 169 | struct FragmentTransmitQueue *frags_head; |
170 | struct FragmentTransmitQueue *frags_tail; | 170 | struct FragmentTransmitQueue *frags_tail; |
171 | 171 | ||
172 | struct GNUNET_SERVER_Client *client; | 172 | struct GNUNET_SERVICE_Client *client; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | /** | 175 | /** |
@@ -180,7 +180,7 @@ struct ClientListItem | |||
180 | struct ClientListItem *prev; | 180 | struct ClientListItem *prev; |
181 | struct ClientListItem *next; | 181 | struct ClientListItem *next; |
182 | 182 | ||
183 | struct GNUNET_SERVER_Client *client; | 183 | struct GNUNET_SERVICE_Client *client; |
184 | }; | 184 | }; |
185 | 185 | ||
186 | 186 | ||
@@ -249,11 +249,6 @@ struct Place | |||
249 | uint8_t file_save; | 249 | uint8_t file_save; |
250 | 250 | ||
251 | /** | 251 | /** |
252 | * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)? | ||
253 | */ | ||
254 | uint8_t is_host; | ||
255 | |||
256 | /** | ||
257 | * Is this place ready to receive messages from client? | 252 | * Is this place ready to receive messages from client? |
258 | * #GNUNET_YES or #GNUNET_NO | 253 | * #GNUNET_YES or #GNUNET_NO |
259 | */ | 254 | */ |
@@ -264,6 +259,16 @@ struct Place | |||
264 | * #GNUNET_YES or #GNUNET_NO | 259 | * #GNUNET_YES or #GNUNET_NO |
265 | */ | 260 | */ |
266 | uint8_t is_disconnected; | 261 | uint8_t is_disconnected; |
262 | |||
263 | /** | ||
264 | * Is this a host (#GNUNET_YES), or guest (#GNUNET_NO)? | ||
265 | */ | ||
266 | uint8_t is_host; | ||
267 | |||
268 | union { | ||
269 | struct Host *host; | ||
270 | struct Guest *guest; | ||
271 | }; | ||
267 | }; | 272 | }; |
268 | 273 | ||
269 | 274 | ||
@@ -275,7 +280,7 @@ struct Host | |||
275 | /** | 280 | /** |
276 | * Place struct common for Host and Guest | 281 | * Place struct common for Host and Guest |
277 | */ | 282 | */ |
278 | struct Place plc; | 283 | struct Place place; |
279 | 284 | ||
280 | /** | 285 | /** |
281 | * Handle for the multicast origin. | 286 | * Handle for the multicast origin. |
@@ -313,7 +318,7 @@ struct Guest | |||
313 | /** | 318 | /** |
314 | * Place struct common for Host and Guest. | 319 | * Place struct common for Host and Guest. |
315 | */ | 320 | */ |
316 | struct Place plc; | 321 | struct Place place; |
317 | 322 | ||
318 | /** | 323 | /** |
319 | * Handle for the PSYC slave. | 324 | * Handle for the PSYC slave. |
@@ -363,9 +368,14 @@ struct Guest | |||
363 | struct Client | 368 | struct Client |
364 | { | 369 | { |
365 | /** | 370 | /** |
371 | * Client handle. | ||
372 | */ | ||
373 | struct GNUNET_SERVICE_Client *client; | ||
374 | |||
375 | /** | ||
366 | * Place where the client entered. | 376 | * Place where the client entered. |
367 | */ | 377 | */ |
368 | struct Place *plc; | 378 | struct Place *place; |
369 | 379 | ||
370 | /** | 380 | /** |
371 | * Message queue for the message currently being transmitted | 381 | * Message queue for the message currently being transmitted |
@@ -395,8 +405,7 @@ struct Ego { | |||
395 | 405 | ||
396 | struct OperationClosure | 406 | struct OperationClosure |
397 | { | 407 | { |
398 | struct GNUNET_SERVER_Client *client; | 408 | struct Client *client; |
399 | struct Place *plc; | ||
400 | uint64_t op_id; | 409 | uint64_t op_id; |
401 | uint32_t flags; | 410 | uint32_t flags; |
402 | }; | 411 | }; |
@@ -417,7 +426,7 @@ cleanup_place (void *cls); | |||
417 | 426 | ||
418 | static struct MessageTransmitQueue * | 427 | static struct MessageTransmitQueue * |
419 | psyc_transmit_queue_message (struct Place *plc, | 428 | psyc_transmit_queue_message (struct Place *plc, |
420 | struct GNUNET_SERVER_Client *client, | 429 | struct GNUNET_SERVICE_Client *client, |
421 | size_t data_size, | 430 | size_t data_size, |
422 | const void *data, | 431 | const void *data, |
423 | uint16_t first_ptype, uint16_t last_ptype, | 432 | uint16_t first_ptype, uint16_t last_ptype, |
@@ -447,11 +456,6 @@ shutdown_task (void *cls) | |||
447 | GNUNET_CONTAINER_multihashmap_iterate (hosts, place_entry_cleanup, NULL); | 456 | GNUNET_CONTAINER_multihashmap_iterate (hosts, place_entry_cleanup, NULL); |
448 | GNUNET_CONTAINER_multihashmap_iterate (guests, place_entry_cleanup, NULL); | 457 | GNUNET_CONTAINER_multihashmap_iterate (guests, place_entry_cleanup, NULL); |
449 | 458 | ||
450 | if (NULL != nc) | ||
451 | { | ||
452 | GNUNET_SERVER_notification_context_destroy (nc); | ||
453 | nc = NULL; | ||
454 | } | ||
455 | if (NULL != id) | 459 | if (NULL != id) |
456 | { | 460 | { |
457 | GNUNET_IDENTITY_disconnect (id); | 461 | GNUNET_IDENTITY_disconnect (id); |
@@ -481,7 +485,7 @@ shutdown_task (void *cls) | |||
481 | static void | 485 | static void |
482 | cleanup_host (struct Host *hst) | 486 | cleanup_host (struct Host *hst) |
483 | { | 487 | { |
484 | struct Place *plc = &hst->plc; | 488 | struct Place *plc = &hst->place; |
485 | 489 | ||
486 | if (NULL != hst->master) | 490 | if (NULL != hst->master) |
487 | GNUNET_PSYC_master_stop (hst->master, GNUNET_NO, NULL, NULL); // FIXME | 491 | GNUNET_PSYC_master_stop (hst->master, GNUNET_NO, NULL, NULL); // FIXME |
@@ -497,7 +501,7 @@ cleanup_host (struct Host *hst) | |||
497 | static void | 501 | static void |
498 | cleanup_guest (struct Guest *gst) | 502 | cleanup_guest (struct Guest *gst) |
499 | { | 503 | { |
500 | struct Place *plc = &gst->plc; | 504 | struct Place *plc = &gst->place; |
501 | struct GNUNET_CONTAINER_MultiHashMap * | 505 | struct GNUNET_CONTAINER_MultiHashMap * |
502 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, | 506 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, |
503 | &plc->pub_key_hash); | 507 | &plc->pub_key_hash); |
@@ -549,30 +553,22 @@ cleanup_place (void *cls) | |||
549 | * Called whenever a client is disconnected. | 553 | * Called whenever a client is disconnected. |
550 | * Frees our resources associated with that client. | 554 | * Frees our resources associated with that client. |
551 | * | 555 | * |
552 | * @param cls Closure. | 556 | * @param cls closure |
553 | * @param client Identification of the client. | 557 | * @param client identification of the client |
558 | * @param app_ctx must match @a client | ||
554 | */ | 559 | */ |
555 | static void | 560 | static void |
556 | client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 561 | client_notify_disconnect (void *cls, |
562 | struct GNUNET_SERVICE_Client *client, | ||
563 | void *app_ctx) | ||
557 | { | 564 | { |
558 | if (NULL == client) | 565 | struct Client *c = app_ctx; |
559 | return; | 566 | struct Place *plc = c->place; |
560 | 567 | ||
561 | struct Client * | 568 | if (NULL != c->app_id) |
562 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 569 | GNUNET_free (c->app_id); |
563 | if (NULL == ctx) | ||
564 | { | ||
565 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
566 | "%p User context is NULL in client_disconnect()\n", ctx); | ||
567 | return; | ||
568 | } | ||
569 | |||
570 | struct Place *plc = ctx->plc; | ||
571 | |||
572 | if (NULL != ctx->app_id) | ||
573 | GNUNET_free (ctx->app_id); | ||
574 | 570 | ||
575 | GNUNET_free (ctx); | 571 | GNUNET_free (c); |
576 | 572 | ||
577 | if (NULL == plc) | 573 | if (NULL == plc) |
578 | return; // application client, nothing to do | 574 | return; // application client, nothing to do |
@@ -597,14 +593,39 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
597 | 593 | ||
598 | 594 | ||
599 | /** | 595 | /** |
596 | * A new client connected. | ||
597 | * | ||
598 | * @param cls NULL | ||
599 | * @param client client to add | ||
600 | * @param mq message queue for @a client | ||
601 | * @return @a client | ||
602 | */ | ||
603 | static void * | ||
604 | client_notify_connect (void *cls, | ||
605 | struct GNUNET_SERVICE_Client *client, | ||
606 | struct GNUNET_MQ_Handle *mq) | ||
607 | { | ||
608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client connected: %p\n", client); | ||
609 | |||
610 | struct Client *c = GNUNET_malloc (sizeof (*c)); | ||
611 | c->client = client; | ||
612 | |||
613 | return c; | ||
614 | } | ||
615 | |||
616 | |||
617 | /** | ||
600 | * Send message to a client. | 618 | * Send message to a client. |
601 | */ | 619 | */ |
602 | static inline void | 620 | static inline void |
603 | client_send_msg (struct GNUNET_SERVER_Client *client, | 621 | client_send_msg (struct GNUNET_SERVICE_Client *client, |
604 | const struct GNUNET_MessageHeader *msg) | 622 | const struct GNUNET_MessageHeader *msg) |
605 | { | 623 | { |
606 | GNUNET_SERVER_notification_context_add (nc, client); | 624 | struct GNUNET_MQ_Envelope * |
607 | GNUNET_SERVER_notification_context_unicast (nc, client, msg, GNUNET_NO); | 625 | env = GNUNET_MQ_msg_copy (msg); |
626 | |||
627 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
628 | env); | ||
608 | } | 629 | } |
609 | 630 | ||
610 | 631 | ||
@@ -642,7 +663,7 @@ place_send_msg (const struct Place *plc, | |||
642 | * Size of @a data. | 663 | * Size of @a data. |
643 | */ | 664 | */ |
644 | static void | 665 | static void |
645 | client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id, | 666 | client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id, |
646 | int64_t result_code, const void *data, uint16_t data_size) | 667 | int64_t result_code, const void *data, uint16_t data_size) |
647 | { | 668 | { |
648 | struct GNUNET_OperationResultMessage *res; | 669 | struct GNUNET_OperationResultMessage *res; |
@@ -666,10 +687,10 @@ client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id, | |||
666 | 687 | ||
667 | 688 | ||
668 | static void | 689 | static void |
669 | client_send_host_enter_ack (struct GNUNET_SERVER_Client *client, | 690 | client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client, |
670 | struct Host *hst, uint32_t result) | 691 | struct Host *hst, uint32_t result) |
671 | { | 692 | { |
672 | struct Place *plc = &hst->plc; | 693 | struct Place *plc = &hst->place; |
673 | 694 | ||
674 | struct HostEnterAck hack; | 695 | struct HostEnterAck hack; |
675 | hack.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); | 696 | hack.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); |
@@ -692,7 +713,7 @@ static void | |||
692 | psyc_master_started (void *cls, int result, uint64_t max_message_id) | 713 | psyc_master_started (void *cls, int result, uint64_t max_message_id) |
693 | { | 714 | { |
694 | struct Host *hst = cls; | 715 | struct Host *hst = cls; |
695 | struct Place *plc = &hst->plc; | 716 | struct Place *plc = &hst->place; |
696 | plc->max_message_id = max_message_id; | 717 | plc->max_message_id = max_message_id; |
697 | plc->is_ready = GNUNET_YES; | 718 | plc->is_ready = GNUNET_YES; |
698 | 719 | ||
@@ -715,7 +736,7 @@ psyc_recv_join_request (void *cls, | |||
715 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); | 736 | GNUNET_CRYPTO_hash (slave_key, sizeof (*slave_key), &slave_key_hash); |
716 | GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh, | 737 | GNUNET_CONTAINER_multihashmap_put (hst->join_reqs, &slave_key_hash, jh, |
717 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 738 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
718 | place_send_msg (&hst->plc, &req->header); | 739 | place_send_msg (&hst->place, &req->header); |
719 | } | 740 | } |
720 | 741 | ||
721 | 742 | ||
@@ -726,7 +747,7 @@ static void | |||
726 | psyc_slave_connected (void *cls, int result, uint64_t max_message_id) | 747 | psyc_slave_connected (void *cls, int result, uint64_t max_message_id) |
727 | { | 748 | { |
728 | struct Guest *gst = cls; | 749 | struct Guest *gst = cls; |
729 | struct Place *plc = &gst->plc; | 750 | struct Place *plc = &gst->place; |
730 | plc->max_message_id = max_message_id; | 751 | plc->max_message_id = max_message_id; |
731 | plc->is_ready = GNUNET_YES; | 752 | plc->is_ready = GNUNET_YES; |
732 | 753 | ||
@@ -750,7 +771,7 @@ psyc_recv_join_dcsn (void *cls, | |||
750 | const struct GNUNET_PSYC_Message *join_msg) | 771 | const struct GNUNET_PSYC_Message *join_msg) |
751 | { | 772 | { |
752 | struct Guest *gst = cls; | 773 | struct Guest *gst = cls; |
753 | place_send_msg (&gst->plc, &dcsn->header); | 774 | place_send_msg (&gst->place, &dcsn->header); |
754 | } | 775 | } |
755 | 776 | ||
756 | 777 | ||
@@ -806,7 +827,7 @@ host_relay_message_part (struct Host *hst, | |||
806 | "FIXME: last message was unfinished.\n"); | 827 | "FIXME: last message was unfinished.\n"); |
807 | } | 828 | } |
808 | 829 | ||
809 | tmit_msg = psyc_transmit_queue_message (&hst->plc, NULL, ntohs (pmsg->size), | 830 | tmit_msg = psyc_transmit_queue_message (&hst->place, NULL, ntohs (pmsg->size), |
810 | pmsg, ptype, ptype, tmit_msg); | 831 | pmsg, ptype, ptype, tmit_msg); |
811 | 832 | ||
812 | switch (ptype) | 833 | switch (ptype) |
@@ -1340,7 +1361,7 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst) | |||
1340 | hst->join_reqs = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 1361 | hst->join_reqs = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
1341 | hst->relay_msgs = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 1362 | hst->relay_msgs = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
1342 | 1363 | ||
1343 | struct Place *plc = &hst->plc; | 1364 | struct Place *plc = &hst->place; |
1344 | place_init (plc); | 1365 | place_init (plc); |
1345 | plc->is_host = GNUNET_YES; | 1366 | plc->is_host = GNUNET_YES; |
1346 | plc->pub_key = hreq->place_pub_key; | 1367 | plc->pub_key = hreq->place_pub_key; |
@@ -1362,13 +1383,12 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst) | |||
1362 | } | 1383 | } |
1363 | 1384 | ||
1364 | 1385 | ||
1365 | const struct MsgProcRequest * | 1386 | static int |
1366 | msg_proc_parse (const struct GNUNET_MessageHeader *msg, | 1387 | msg_proc_parse (const struct MsgProcRequest *mpreq, |
1367 | uint32_t *flags, | 1388 | uint32_t *flags, |
1368 | const char **method_prefix, | 1389 | const char **method_prefix, |
1369 | struct GNUNET_HashCode *method_hash) | 1390 | struct GNUNET_HashCode *method_hash) |
1370 | { | 1391 | { |
1371 | const struct MsgProcRequest *mpreq = (const struct MsgProcRequest *) msg; | ||
1372 | uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); | 1392 | uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq); |
1373 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], | 1393 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &mpreq[1], |
1374 | method_size, 1, method_prefix); | 1394 | method_size, 1, method_prefix); |
@@ -1378,12 +1398,20 @@ msg_proc_parse (const struct GNUNET_MessageHeader *msg, | |||
1378 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1398 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1379 | "offset = %u, method_size = %u, method_name = %s\n", | 1399 | "offset = %u, method_size = %u, method_name = %s\n", |
1380 | offset, method_size, *method_prefix); | 1400 | offset, method_size, *method_prefix); |
1381 | return NULL; | 1401 | return GNUNET_SYSERR; |
1382 | } | 1402 | } |
1383 | 1403 | ||
1384 | GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); | 1404 | GNUNET_CRYPTO_hash (*method_prefix, method_size, method_hash); |
1385 | *flags = ntohl (mpreq->flags); | 1405 | *flags = ntohl (mpreq->flags); |
1386 | return mpreq; | 1406 | return GNUNET_OK; |
1407 | } | ||
1408 | |||
1409 | |||
1410 | static int | ||
1411 | check_client_msg_proc_set (void *cls, | ||
1412 | const struct MsgProcRequest *mpreq) | ||
1413 | { | ||
1414 | return GNUNET_OK; | ||
1387 | } | 1415 | } |
1388 | 1416 | ||
1389 | 1417 | ||
@@ -1391,23 +1419,28 @@ msg_proc_parse (const struct GNUNET_MessageHeader *msg, | |||
1391 | * Handle a client setting message proccesing flags for a method prefix. | 1419 | * Handle a client setting message proccesing flags for a method prefix. |
1392 | */ | 1420 | */ |
1393 | static void | 1421 | static void |
1394 | client_recv_msg_proc_set (void *cls, struct GNUNET_SERVER_Client *client, | 1422 | handle_client_msg_proc_set (void *cls, |
1395 | const struct GNUNET_MessageHeader *msg) | 1423 | const struct MsgProcRequest *mpreq) |
1396 | { | 1424 | { |
1397 | struct Client * | 1425 | struct Client *c = cls; |
1398 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 1426 | struct GNUNET_SERVICE_Client *client = c->client; |
1399 | GNUNET_assert (NULL != ctx); | 1427 | struct Place *plc = c->place; |
1400 | struct Place *plc = ctx->plc; | 1428 | if (NULL == plc) |
1429 | { | ||
1430 | GNUNET_break (0); | ||
1431 | GNUNET_SERVICE_client_drop (client); | ||
1432 | return; | ||
1433 | } | ||
1401 | 1434 | ||
1402 | const char *method_prefix = NULL; | 1435 | const char *method_prefix = NULL; |
1403 | uint32_t flags = 0; | 1436 | uint32_t flags = 0; |
1404 | struct GNUNET_HashCode method_hash; | 1437 | struct GNUNET_HashCode method_hash; |
1405 | const struct MsgProcRequest * | ||
1406 | mpreq = msg_proc_parse (msg, &flags, &method_prefix, &method_hash); | ||
1407 | 1438 | ||
1408 | if (NULL == mpreq) { | 1439 | if (GNUNET_OK != |
1440 | msg_proc_parse (mpreq, &flags, &method_prefix, &method_hash)) | ||
1441 | { | ||
1409 | GNUNET_break (0); | 1442 | GNUNET_break (0); |
1410 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1443 | GNUNET_SERVICE_client_drop (client); |
1411 | return; | 1444 | return; |
1412 | } | 1445 | } |
1413 | #if 0 | 1446 | #if 0 |
@@ -1443,7 +1476,7 @@ client_recv_msg_proc_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
1443 | 1476 | ||
1444 | /** @todo Save flags to be able to resume relaying/saving after restart */ | 1477 | /** @todo Save flags to be able to resume relaying/saving after restart */ |
1445 | 1478 | ||
1446 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1479 | GNUNET_SERVICE_client_continue (client); |
1447 | } | 1480 | } |
1448 | 1481 | ||
1449 | 1482 | ||
@@ -1451,21 +1484,30 @@ client_recv_msg_proc_set (void *cls, struct GNUNET_SERVER_Client *client, | |||
1451 | * Handle a connecting client requesting to clear all relay rules. | 1484 | * Handle a connecting client requesting to clear all relay rules. |
1452 | */ | 1485 | */ |
1453 | static void | 1486 | static void |
1454 | client_recv_msg_proc_clear (void *cls, struct GNUNET_SERVER_Client *client, | 1487 | handle_client_msg_proc_clear (void *cls, |
1455 | const struct GNUNET_MessageHeader *msg) | 1488 | const struct GNUNET_MessageHeader *msg) |
1456 | { | 1489 | { |
1457 | struct Client * | 1490 | struct Client *c = cls; |
1458 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 1491 | struct GNUNET_SERVICE_Client *client = c->client; |
1459 | GNUNET_assert (NULL != ctx); | 1492 | struct Place *plc = c->place; |
1460 | struct Place *plc = ctx->plc; | 1493 | if (NULL == plc) |
1461 | if (GNUNET_YES != plc->is_host) { | 1494 | { |
1462 | GNUNET_break (0); | 1495 | GNUNET_break (0); |
1463 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1496 | GNUNET_SERVICE_client_drop (client); |
1464 | return; | 1497 | return; |
1465 | } | 1498 | } |
1499 | |||
1466 | GNUNET_PSYC_slicer_clear (plc->slicer); | 1500 | GNUNET_PSYC_slicer_clear (plc->slicer); |
1467 | 1501 | ||
1468 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1502 | GNUNET_SERVICE_client_continue (client); |
1503 | } | ||
1504 | |||
1505 | |||
1506 | static int | ||
1507 | check_client_host_enter (void *cls, | ||
1508 | const struct HostEnterRequest *hr) | ||
1509 | { | ||
1510 | return GNUNET_OK; | ||
1469 | } | 1511 | } |
1470 | 1512 | ||
1471 | 1513 | ||
@@ -1473,11 +1515,14 @@ client_recv_msg_proc_clear (void *cls, struct GNUNET_SERVER_Client *client, | |||
1473 | * Handle a connecting client entering a place as host. | 1515 | * Handle a connecting client entering a place as host. |
1474 | */ | 1516 | */ |
1475 | static void | 1517 | static void |
1476 | client_recv_host_enter (void *cls, struct GNUNET_SERVER_Client *client, | 1518 | handle_client_host_enter (void *cls, |
1477 | const struct GNUNET_MessageHeader *msg) | 1519 | const struct HostEnterRequest *hr) |
1478 | { | 1520 | { |
1479 | struct HostEnterRequest *hreq | 1521 | struct Client *c = cls; |
1480 | = (struct HostEnterRequest *) GNUNET_copy_message (msg); | 1522 | struct GNUNET_SERVICE_Client *client = c->client; |
1523 | |||
1524 | struct HostEnterRequest * | ||
1525 | hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); | ||
1481 | 1526 | ||
1482 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); | 1527 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); |
1483 | const char *app_id = NULL; | 1528 | const char *app_id = NULL; |
@@ -1489,7 +1534,7 @@ client_recv_host_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1489 | "offset = %u, app_id_size = %u, app_id = %s\n", | 1534 | "offset = %u, app_id_size = %u, app_id = %s\n", |
1490 | offset, app_id_size, app_id); | 1535 | offset, app_id_size, app_id); |
1491 | GNUNET_break (0); | 1536 | GNUNET_break (0); |
1492 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1537 | GNUNET_SERVICE_client_drop (client); |
1493 | return; | 1538 | return; |
1494 | } | 1539 | } |
1495 | 1540 | ||
@@ -1515,12 +1560,14 @@ client_recv_host_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1515 | switch (host_enter (hreq, &hst)) | 1560 | switch (host_enter (hreq, &hst)) |
1516 | { | 1561 | { |
1517 | case GNUNET_YES: | 1562 | case GNUNET_YES: |
1518 | plc = &hst->plc; | 1563 | plc = c->place = &hst->place; |
1564 | plc->host = hst; | ||
1519 | break; | 1565 | break; |
1520 | 1566 | ||
1521 | case GNUNET_NO: | 1567 | case GNUNET_NO: |
1522 | { | 1568 | { |
1523 | plc = &hst->plc; | 1569 | plc = c->place = &hst->place; |
1570 | plc->host = hst; | ||
1524 | client_send_host_enter_ack (client, hst, GNUNET_OK); | 1571 | client_send_host_enter_ack (client, hst, GNUNET_OK); |
1525 | break; | 1572 | break; |
1526 | } | 1573 | } |
@@ -1538,15 +1585,16 @@ client_recv_host_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1538 | struct ClientListItem *cli = GNUNET_new (struct ClientListItem); | 1585 | struct ClientListItem *cli = GNUNET_new (struct ClientListItem); |
1539 | cli->client = client; | 1586 | cli->client = client; |
1540 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); | 1587 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); |
1541 | 1588 | c->place = plc; | |
1542 | struct Client *ctx = GNUNET_new (struct Client); | ||
1543 | ctx->plc = plc; | ||
1544 | GNUNET_SERVER_client_set_user_context (client, ctx); | ||
1545 | } | 1589 | } |
1546 | 1590 | ||
1547 | GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); | 1591 | GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); |
1548 | GNUNET_free (hreq); | 1592 | GNUNET_free (hreq); |
1549 | GNUNET_SERVER_receive_done (client, ret); | 1593 | |
1594 | if (GNUNET_OK == ret) | ||
1595 | GNUNET_SERVICE_client_continue (client); | ||
1596 | else | ||
1597 | GNUNET_SERVICE_client_drop (client); | ||
1550 | } | 1598 | } |
1551 | 1599 | ||
1552 | 1600 | ||
@@ -1648,7 +1696,7 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1648 | 1696 | ||
1649 | gst->join_flags = ntohl (greq->flags); | 1697 | gst->join_flags = ntohl (greq->flags); |
1650 | 1698 | ||
1651 | struct Place *plc = &gst->plc; | 1699 | struct Place *plc = &gst->place; |
1652 | place_init (plc); | 1700 | place_init (plc); |
1653 | plc->is_host = GNUNET_NO; | 1701 | plc->is_host = GNUNET_NO; |
1654 | plc->pub_key = greq->place_pub_key; | 1702 | plc->pub_key = greq->place_pub_key; |
@@ -1685,15 +1733,23 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1685 | } | 1733 | } |
1686 | 1734 | ||
1687 | 1735 | ||
1736 | static int | ||
1737 | check_client_guest_enter (void *cls, | ||
1738 | const struct GuestEnterRequest *greq) | ||
1739 | { | ||
1740 | return GNUNET_OK; | ||
1741 | } | ||
1742 | |||
1743 | |||
1688 | /** | 1744 | /** |
1689 | * Handle a connecting client entering a place as guest. | 1745 | * Handle a connecting client entering a place as guest. |
1690 | */ | 1746 | */ |
1691 | static void | 1747 | static void |
1692 | client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | 1748 | handle_client_guest_enter (void *cls, |
1693 | const struct GNUNET_MessageHeader *msg) | 1749 | const struct GuestEnterRequest *greq) |
1694 | { | 1750 | { |
1695 | const struct GuestEnterRequest * | 1751 | struct Client *c = cls; |
1696 | greq = (const struct GuestEnterRequest *) msg; | 1752 | struct GNUNET_SERVICE_Client *client = c->client; |
1697 | 1753 | ||
1698 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); | 1754 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); |
1699 | const char *app_id = NULL; | 1755 | const char *app_id = NULL; |
@@ -1702,7 +1758,7 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1702 | if (0 == offset) | 1758 | if (0 == offset) |
1703 | { | 1759 | { |
1704 | GNUNET_break (0); | 1760 | GNUNET_break (0); |
1705 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1761 | GNUNET_SERVICE_client_drop (client); |
1706 | return; | 1762 | return; |
1707 | } | 1763 | } |
1708 | 1764 | ||
@@ -1712,13 +1768,15 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1712 | switch (guest_enter (greq, &gst)) | 1768 | switch (guest_enter (greq, &gst)) |
1713 | { | 1769 | { |
1714 | case GNUNET_YES: | 1770 | case GNUNET_YES: |
1715 | plc = &gst->plc; | 1771 | plc = c->place = &gst->place; |
1772 | plc->guest = gst; | ||
1716 | app_place_save (app_id, (const struct PlaceEnterRequest *) greq); | 1773 | app_place_save (app_id, (const struct PlaceEnterRequest *) greq); |
1717 | break; | 1774 | break; |
1718 | 1775 | ||
1719 | case GNUNET_NO: | 1776 | case GNUNET_NO: |
1720 | { | 1777 | { |
1721 | plc = &gst->plc; | 1778 | plc = c->place = &gst->place; |
1779 | plc->guest = gst; | ||
1722 | 1780 | ||
1723 | struct GNUNET_PSYC_CountersResultMessage res; | 1781 | struct GNUNET_PSYC_CountersResultMessage res; |
1724 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); | 1782 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); |
@@ -1734,7 +1792,7 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1734 | } | 1792 | } |
1735 | case GNUNET_SYSERR: | 1793 | case GNUNET_SYSERR: |
1736 | GNUNET_break (0); | 1794 | GNUNET_break (0); |
1737 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1795 | GNUNET_SERVICE_client_drop (client); |
1738 | return; | 1796 | return; |
1739 | } | 1797 | } |
1740 | 1798 | ||
@@ -1746,16 +1804,14 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
1746 | cli->client = client; | 1804 | cli->client = client; |
1747 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); | 1805 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); |
1748 | 1806 | ||
1749 | struct Client *ctx = GNUNET_new (struct Client); | 1807 | c->place = plc; |
1750 | ctx->plc = plc; | 1808 | GNUNET_SERVICE_client_continue (client); |
1751 | GNUNET_SERVER_client_set_user_context (client, ctx); | ||
1752 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1753 | } | 1809 | } |
1754 | 1810 | ||
1755 | 1811 | ||
1756 | struct GuestEnterByNameClosure | 1812 | struct GuestEnterByNameClosure |
1757 | { | 1813 | { |
1758 | struct GNUNET_SERVER_Client *client; | 1814 | struct Client *client; |
1759 | char *app_id; | 1815 | char *app_id; |
1760 | char *password; | 1816 | char *password; |
1761 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; | 1817 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; |
@@ -1773,8 +1829,10 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, | |||
1773 | const struct GNUNET_GNSRECORD_Data *rd) | 1829 | const struct GNUNET_GNSRECORD_Data *rd) |
1774 | { | 1830 | { |
1775 | struct GuestEnterByNameClosure *gcls = cls; | 1831 | struct GuestEnterByNameClosure *gcls = cls; |
1832 | struct Client *c = gcls->client; | ||
1776 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1833 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1777 | "%p GNS result: %u records.\n", gcls->client, rd_count); | 1834 | "%p GNS result: %u records.\n", |
1835 | c, rd_count); | ||
1778 | 1836 | ||
1779 | const struct GNUNET_GNSRECORD_PlaceData * | 1837 | const struct GNUNET_GNSRECORD_PlaceData * |
1780 | rec = (const struct GNUNET_GNSRECORD_PlaceData *) rd->data; | 1838 | rec = (const struct GNUNET_GNSRECORD_PlaceData *) rd->data; |
@@ -1782,7 +1840,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, | |||
1782 | if (0 == rd_count || rd->data_size < sizeof (*rec)) | 1840 | if (0 == rd_count || rd->data_size < sizeof (*rec)) |
1783 | { | 1841 | { |
1784 | GNUNET_break (0); | 1842 | GNUNET_break (0); |
1785 | GNUNET_SERVER_receive_done (gcls->client, GNUNET_SYSERR); | 1843 | GNUNET_SERVICE_client_drop (c->client); |
1786 | return; | 1844 | return; |
1787 | } | 1845 | } |
1788 | 1846 | ||
@@ -1824,7 +1882,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, | |||
1824 | p += relay_size; | 1882 | p += relay_size; |
1825 | GNUNET_memcpy (p, gcls->join_msg, join_msg_size); | 1883 | GNUNET_memcpy (p, gcls->join_msg, join_msg_size); |
1826 | 1884 | ||
1827 | client_recv_guest_enter (NULL, gcls->client, &greq->header); | 1885 | handle_client_guest_enter (c, greq); |
1828 | 1886 | ||
1829 | GNUNET_free (gcls->app_id); | 1887 | GNUNET_free (gcls->app_id); |
1830 | if (NULL != gcls->password) | 1888 | if (NULL != gcls->password) |
@@ -1836,20 +1894,28 @@ gns_result_guest_enter (void *cls, uint32_t rd_count, | |||
1836 | } | 1894 | } |
1837 | 1895 | ||
1838 | 1896 | ||
1897 | static int | ||
1898 | check_client_guest_enter_by_name (void *cls, | ||
1899 | const struct GuestEnterByNameRequest *greq) | ||
1900 | { | ||
1901 | return GNUNET_OK; | ||
1902 | } | ||
1903 | |||
1904 | |||
1839 | /** | 1905 | /** |
1840 | * Handle a connecting client entering a place as guest using a GNS address. | 1906 | * Handle a connecting client entering a place as guest using a GNS address. |
1841 | * | 1907 | * |
1842 | * Look up GNS address and generate a GuestEnterRequest from that. | 1908 | * Look up GNS address and generate a GuestEnterRequest from that. |
1843 | */ | 1909 | */ |
1844 | static void | 1910 | static void |
1845 | client_recv_guest_enter_by_name (void *cls, struct GNUNET_SERVER_Client *client, | 1911 | handle_client_guest_enter_by_name (void *cls, |
1846 | const struct GNUNET_MessageHeader *msg) | 1912 | const struct GuestEnterByNameRequest *greq) |
1847 | { | 1913 | { |
1848 | const struct GuestEnterByNameRequest * | 1914 | struct Client *c = cls; |
1849 | greq = (const struct GuestEnterByNameRequest *) msg; | 1915 | struct GNUNET_SERVICE_Client *client = c->client; |
1850 | 1916 | ||
1851 | struct GuestEnterByNameClosure *gcls = GNUNET_malloc (sizeof (*gcls)); | 1917 | struct GuestEnterByNameClosure *gcls = GNUNET_malloc (sizeof (*gcls)); |
1852 | gcls->client = client; | 1918 | gcls->client = c; |
1853 | gcls->ego_pub_key = greq->ego_pub_key; | 1919 | gcls->ego_pub_key = greq->ego_pub_key; |
1854 | 1920 | ||
1855 | const char *p = (const char *) &greq[1]; | 1921 | const char *p = (const char *) &greq[1]; |
@@ -1874,7 +1940,7 @@ client_recv_guest_enter_by_name (void *cls, struct GNUNET_SERVER_Client *client, | |||
1874 | GNUNET_free (gcls->join_msg); | 1940 | GNUNET_free (gcls->join_msg); |
1875 | GNUNET_free (gcls); | 1941 | GNUNET_free (gcls); |
1876 | GNUNET_break (0); | 1942 | GNUNET_break (0); |
1877 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1943 | GNUNET_SERVICE_client_drop (client); |
1878 | return; | 1944 | return; |
1879 | } | 1945 | } |
1880 | 1946 | ||
@@ -1897,7 +1963,7 @@ client_recv_guest_enter_by_name (void *cls, struct GNUNET_SERVER_Client *client, | |||
1897 | 1963 | ||
1898 | void | 1964 | void |
1899 | app_notify_place (struct GNUNET_MessageHeader *msg, | 1965 | app_notify_place (struct GNUNET_MessageHeader *msg, |
1900 | struct GNUNET_SERVER_Client *client) | 1966 | struct GNUNET_SERVICE_Client *client) |
1901 | { | 1967 | { |
1902 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1968 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1903 | "%p Sending place notification of type %u to client.\n", | 1969 | "%p Sending place notification of type %u to client.\n", |
@@ -1939,7 +2005,7 @@ app_notify_place (struct GNUNET_MessageHeader *msg, | |||
1939 | 2005 | ||
1940 | 2006 | ||
1941 | void | 2007 | void |
1942 | app_notify_place_end (struct GNUNET_SERVER_Client *client) | 2008 | app_notify_place_end (struct GNUNET_SERVICE_Client *client) |
1943 | { | 2009 | { |
1944 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1945 | "%p Sending end of place list notification to client\n", | 2011 | "%p Sending end of place list notification to client\n", |
@@ -1954,7 +2020,7 @@ app_notify_place_end (struct GNUNET_SERVER_Client *client) | |||
1954 | 2020 | ||
1955 | 2021 | ||
1956 | void | 2022 | void |
1957 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVER_Client *client) | 2023 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) |
1958 | { | 2024 | { |
1959 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2025 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1960 | "%p Sending ego notification to client: %s\n", | 2026 | "%p Sending ego notification to client: %s\n", |
@@ -1974,7 +2040,7 @@ app_notify_ego (struct Ego *ego, struct GNUNET_SERVER_Client *client) | |||
1974 | 2040 | ||
1975 | 2041 | ||
1976 | void | 2042 | void |
1977 | app_notify_ego_end (struct GNUNET_SERVER_Client *client) | 2043 | app_notify_ego_end (struct GNUNET_SERVICE_Client *client) |
1978 | { | 2044 | { |
1979 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2045 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1980 | "%p Sending end of ego list notification to client\n", | 2046 | "%p Sending end of ego list notification to client\n", |
@@ -2007,15 +2073,23 @@ ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
2007 | } | 2073 | } |
2008 | 2074 | ||
2009 | 2075 | ||
2076 | static int | ||
2077 | check_client_app_connect (void *cls, | ||
2078 | const struct AppConnectRequest *creq) | ||
2079 | { | ||
2080 | return GNUNET_OK; | ||
2081 | } | ||
2082 | |||
2083 | |||
2010 | /** | 2084 | /** |
2011 | * Handle application connection. | 2085 | * Handle application connection. |
2012 | */ | 2086 | */ |
2013 | static void | 2087 | static void |
2014 | client_recv_app_connect (void *cls, struct GNUNET_SERVER_Client *client, | 2088 | handle_client_app_connect (void *cls, |
2015 | const struct GNUNET_MessageHeader *msg) | 2089 | const struct AppConnectRequest *creq) |
2016 | { | 2090 | { |
2017 | const struct AppConnectRequest *creq | 2091 | struct Client *c = cls; |
2018 | = (const struct AppConnectRequest *) msg; | 2092 | struct GNUNET_SERVICE_Client *client = c->client; |
2019 | 2093 | ||
2020 | uint8_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); | 2094 | uint8_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); |
2021 | const char *app_id = NULL; | 2095 | const char *app_id = NULL; |
@@ -2024,7 +2098,7 @@ client_recv_app_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2024 | if (0 == offset || offset != app_id_size) | 2098 | if (0 == offset || offset != app_id_size) |
2025 | { | 2099 | { |
2026 | GNUNET_break (0); | 2100 | GNUNET_break (0); |
2027 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2101 | GNUNET_SERVICE_client_drop (client); |
2028 | return; | 2102 | return; |
2029 | } | 2103 | } |
2030 | 2104 | ||
@@ -2054,12 +2128,10 @@ client_recv_app_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2128 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2055 | "%p Application %s connected.\n", app, app_id); | 2129 | "%p Application %s connected.\n", app, app_id); |
2056 | 2130 | ||
2057 | struct Client *ctx = GNUNET_new (struct Client); | 2131 | c->app_id = GNUNET_malloc (app_id_size); |
2058 | ctx->app_id = GNUNET_malloc (app_id_size); | 2132 | GNUNET_memcpy (c->app_id, app_id, app_id_size); |
2059 | GNUNET_memcpy (ctx->app_id, app_id, app_id_size); | ||
2060 | 2133 | ||
2061 | GNUNET_SERVER_client_set_user_context (client, ctx); | 2134 | GNUNET_SERVICE_client_continue (client); |
2062 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
2063 | } | 2135 | } |
2064 | 2136 | ||
2065 | 2137 | ||
@@ -2067,22 +2139,16 @@ client_recv_app_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2067 | * Handle application detach request. | 2139 | * Handle application detach request. |
2068 | */ | 2140 | */ |
2069 | static void | 2141 | static void |
2070 | client_recv_app_detach (void *cls, struct GNUNET_SERVER_Client *client, | 2142 | handle_client_app_detach (void *cls, |
2071 | const struct GNUNET_MessageHeader *msg) | 2143 | const struct AppDetachRequest *req) |
2072 | { | 2144 | { |
2073 | struct Client * | 2145 | struct Client *c = cls; |
2074 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 2146 | struct GNUNET_SERVICE_Client *client = c->client; |
2075 | GNUNET_assert (NULL != ctx); | ||
2076 | |||
2077 | struct Place *plc = ctx->plc; | ||
2078 | |||
2079 | const struct AppDetachRequest *req | ||
2080 | = (const struct AppDetachRequest *) msg; | ||
2081 | 2147 | ||
2082 | int ret = app_place_remove (ctx->app_id, &plc->ego_pub_key, &req->place_pub_key); | 2148 | int ret = app_place_remove (c->app_id, &req->ego_pub_key, &req->place_pub_key); |
2083 | client_send_result (client, req->op_id, ret, NULL, 0); | 2149 | client_send_result (client, req->op_id, ret, NULL, 0); |
2084 | 2150 | ||
2085 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2151 | GNUNET_SERVICE_client_continue (client); |
2086 | } | 2152 | } |
2087 | 2153 | ||
2088 | 2154 | ||
@@ -2097,16 +2163,21 @@ app_places_entry_remove (void *cls, const struct GNUNET_HashCode *key, void *val | |||
2097 | 2163 | ||
2098 | 2164 | ||
2099 | /** | 2165 | /** |
2100 | * Handle application detach request. | 2166 | * Handle application leave request. |
2101 | */ | 2167 | */ |
2102 | static void | 2168 | static void |
2103 | client_recv_place_leave (void *cls, struct GNUNET_SERVER_Client *client, | 2169 | handle_client_place_leave (void *cls, |
2104 | const struct GNUNET_MessageHeader *msg) | 2170 | const struct GNUNET_MessageHeader *msg) |
2105 | { | 2171 | { |
2106 | struct Client * | 2172 | struct Client *c = cls; |
2107 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 2173 | struct GNUNET_SERVICE_Client *client = c->client; |
2108 | GNUNET_assert (NULL != ctx); | 2174 | struct Place *plc = c->place; |
2109 | struct Place *plc = ctx->plc; | 2175 | if (NULL == plc) |
2176 | { | ||
2177 | GNUNET_break (0); | ||
2178 | GNUNET_SERVICE_client_drop (client); | ||
2179 | return; | ||
2180 | } | ||
2110 | 2181 | ||
2111 | /* FIXME: remove all app subscriptions and leave this place */ | 2182 | /* FIXME: remove all app subscriptions and leave this place */ |
2112 | 2183 | ||
@@ -2124,7 +2195,7 @@ client_recv_place_leave (void *cls, struct GNUNET_SERVER_Client *client, | |||
2124 | while (NULL != cli) | 2195 | while (NULL != cli) |
2125 | { | 2196 | { |
2126 | GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); | 2197 | GNUNET_CONTAINER_DLL_remove (plc->clients_head, plc->clients_tail, cli); |
2127 | GNUNET_SERVER_client_disconnect (cli->client); | 2198 | GNUNET_SERVICE_client_drop (cli->client); |
2128 | next = cli->next; | 2199 | next = cli->next; |
2129 | GNUNET_free (cli); | 2200 | GNUNET_free (cli); |
2130 | cli = next; | 2201 | cli = next; |
@@ -2167,30 +2238,36 @@ psyc_send_join_decision (void *cls, const struct GNUNET_HashCode *pub_key_hash, | |||
2167 | } | 2238 | } |
2168 | 2239 | ||
2169 | 2240 | ||
2241 | static int | ||
2242 | check_client_join_decision (void *cls, | ||
2243 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn) | ||
2244 | { | ||
2245 | return GNUNET_OK; | ||
2246 | } | ||
2247 | |||
2248 | |||
2170 | /** | 2249 | /** |
2171 | * Handle an entry decision from a host client. | 2250 | * Handle an entry decision from a host client. |
2172 | */ | 2251 | */ |
2173 | static void | 2252 | static void |
2174 | client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | 2253 | handle_client_join_decision (void *cls, |
2175 | const struct GNUNET_MessageHeader *msg) | 2254 | const struct GNUNET_PSYC_JoinDecisionMessage *dcsn) |
2176 | { | 2255 | { |
2177 | struct Client * | 2256 | struct Client *c = cls; |
2178 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 2257 | struct GNUNET_SERVICE_Client *client = c->client; |
2179 | GNUNET_assert (NULL != ctx); | 2258 | struct Place *plc = c->place; |
2180 | struct Place *plc = ctx->plc; | 2259 | if (NULL == plc || GNUNET_YES != plc->is_host) |
2181 | if (GNUNET_YES != plc->is_host) { | 2260 | { |
2182 | GNUNET_break (0); | 2261 | GNUNET_break (0); |
2183 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2262 | GNUNET_SERVICE_client_drop (client); |
2184 | return; | 2263 | return; |
2185 | } | 2264 | } |
2186 | struct Host *hst = (struct Host *) plc; | 2265 | struct Host *hst = plc->host; |
2187 | 2266 | ||
2188 | struct GNUNET_PSYC_JoinDecisionMessage * | ||
2189 | dcsn = (struct GNUNET_PSYC_JoinDecisionMessage *) msg; | ||
2190 | struct JoinDecisionClosure jcls; | 2267 | struct JoinDecisionClosure jcls; |
2191 | jcls.is_admitted = ntohl (dcsn->is_admitted); | 2268 | jcls.is_admitted = ntohl (dcsn->is_admitted); |
2192 | jcls.msg | 2269 | jcls.msg |
2193 | = (sizeof (*dcsn) + sizeof (*jcls.msg) <= ntohs (msg->size)) | 2270 | = (sizeof (*dcsn) + sizeof (*jcls.msg) <= ntohs (dcsn->header.size)) |
2194 | ? (struct GNUNET_PSYC_Message *) &dcsn[1] | 2271 | ? (struct GNUNET_PSYC_Message *) &dcsn[1] |
2195 | : NULL; | 2272 | : NULL; |
2196 | 2273 | ||
@@ -2208,7 +2285,8 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
2208 | GNUNET_CONTAINER_multihashmap_get_multiple (hst->join_reqs, &slave_pub_hash, | 2285 | GNUNET_CONTAINER_multihashmap_get_multiple (hst->join_reqs, &slave_pub_hash, |
2209 | &psyc_send_join_decision, &jcls); | 2286 | &psyc_send_join_decision, &jcls); |
2210 | GNUNET_CONTAINER_multihashmap_remove_all (hst->join_reqs, &slave_pub_hash); | 2287 | GNUNET_CONTAINER_multihashmap_remove_all (hst->join_reqs, &slave_pub_hash); |
2211 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2288 | |
2289 | GNUNET_SERVICE_client_continue (client); | ||
2212 | } | 2290 | } |
2213 | 2291 | ||
2214 | 2292 | ||
@@ -2220,7 +2298,7 @@ client_recv_join_decision (void *cls, struct GNUNET_SERVER_Client *client, | |||
2220 | * @param plc The place struct for the client. | 2298 | * @param plc The place struct for the client. |
2221 | */ | 2299 | */ |
2222 | static void | 2300 | static void |
2223 | send_message_ack (struct Place *plc, struct GNUNET_SERVER_Client *client) | 2301 | send_message_ack (struct Place *plc, struct GNUNET_SERVICE_Client *client) |
2224 | { | 2302 | { |
2225 | struct GNUNET_MessageHeader res; | 2303 | struct GNUNET_MessageHeader res; |
2226 | res.size = htons (sizeof (res)); | 2304 | res.size = htons (sizeof (res)); |
@@ -2358,7 +2436,7 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data) | |||
2358 | *data_size = 0; | 2436 | *data_size = 0; |
2359 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); | 2437 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); |
2360 | plc->is_disconnected = GNUNET_YES; | 2438 | plc->is_disconnected = GNUNET_YES; |
2361 | GNUNET_SERVER_client_disconnect (tmit_frag->client); | 2439 | GNUNET_SERVICE_client_drop (tmit_frag->client); |
2362 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); | 2440 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); |
2363 | return ret; | 2441 | return ret; |
2364 | } | 2442 | } |
@@ -2518,7 +2596,7 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data, | |||
2518 | ret = GNUNET_SYSERR; | 2596 | ret = GNUNET_SYSERR; |
2519 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); | 2597 | tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); |
2520 | plc->is_disconnected = GNUNET_YES; | 2598 | plc->is_disconnected = GNUNET_YES; |
2521 | GNUNET_SERVER_client_disconnect (tmit_frag->client); | 2599 | GNUNET_SERVICE_client_drop (tmit_frag->client); |
2522 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); | 2600 | GNUNET_SCHEDULER_add_now (&cleanup_place, plc); |
2523 | } | 2601 | } |
2524 | else | 2602 | else |
@@ -2668,7 +2746,7 @@ psyc_transmit_queue_next_method (struct Place *plc) | |||
2668 | static int | 2746 | static int |
2669 | psyc_master_transmit_message (struct Host *hst) | 2747 | psyc_master_transmit_message (struct Host *hst) |
2670 | { | 2748 | { |
2671 | struct Place *plc = &hst->plc; | 2749 | struct Place *plc = &hst->place; |
2672 | 2750 | ||
2673 | if (NULL == hst->tmit_handle) | 2751 | if (NULL == hst->tmit_handle) |
2674 | { | 2752 | { |
@@ -2701,7 +2779,7 @@ psyc_master_transmit_message (struct Host *hst) | |||
2701 | static int | 2779 | static int |
2702 | psyc_slave_transmit_message (struct Guest *gst) | 2780 | psyc_slave_transmit_message (struct Guest *gst) |
2703 | { | 2781 | { |
2704 | struct Place *plc = &gst->plc; | 2782 | struct Place *plc = &gst->place; |
2705 | 2783 | ||
2706 | if (NULL == gst->tmit_handle) | 2784 | if (NULL == gst->tmit_handle) |
2707 | { | 2785 | { |
@@ -2753,7 +2831,7 @@ psyc_transmit_message (struct Place *plc) | |||
2753 | */ | 2831 | */ |
2754 | static struct MessageTransmitQueue * | 2832 | static struct MessageTransmitQueue * |
2755 | psyc_transmit_queue_message (struct Place *plc, | 2833 | psyc_transmit_queue_message (struct Place *plc, |
2756 | struct GNUNET_SERVER_Client *client, | 2834 | struct GNUNET_SERVICE_Client *client, |
2757 | size_t data_size, | 2835 | size_t data_size, |
2758 | const void *data, | 2836 | const void *data, |
2759 | uint16_t first_ptype, uint16_t last_ptype, | 2837 | uint16_t first_ptype, uint16_t last_ptype, |
@@ -2789,7 +2867,7 @@ psyc_transmit_queue_message (struct Place *plc, | |||
2789 | * @param client Client the message originates from. | 2867 | * @param client Client the message originates from. |
2790 | */ | 2868 | */ |
2791 | static void | 2869 | static void |
2792 | psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVER_Client *client) | 2870 | psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) |
2793 | { | 2871 | { |
2794 | uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; | 2872 | uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; |
2795 | 2873 | ||
@@ -2804,17 +2882,31 @@ psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVER_Client *client) | |||
2804 | } | 2882 | } |
2805 | 2883 | ||
2806 | 2884 | ||
2885 | static int | ||
2886 | check_client_psyc_message (void *cls, | ||
2887 | const struct GNUNET_MessageHeader *msg) | ||
2888 | { | ||
2889 | return GNUNET_OK; | ||
2890 | } | ||
2891 | |||
2892 | |||
2807 | /** | 2893 | /** |
2808 | * Handle an incoming message from a client, to be transmitted to the place. | 2894 | * Handle an incoming message from a client, to be transmitted to the place. |
2809 | */ | 2895 | */ |
2810 | static void | 2896 | static void |
2811 | client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | 2897 | handle_client_psyc_message (void *cls, |
2812 | const struct GNUNET_MessageHeader *msg) | 2898 | const struct GNUNET_MessageHeader *msg) |
2813 | { | 2899 | { |
2814 | struct Client * | 2900 | struct Client *c = cls; |
2815 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 2901 | struct GNUNET_SERVICE_Client *client = c->client; |
2816 | GNUNET_assert (NULL != ctx); | 2902 | struct Place *plc = c->place; |
2817 | struct Place *plc = ctx->plc; | 2903 | if (NULL == plc) |
2904 | { | ||
2905 | GNUNET_break (0); | ||
2906 | GNUNET_SERVICE_client_drop (client); | ||
2907 | return; | ||
2908 | } | ||
2909 | |||
2818 | int ret = GNUNET_SYSERR; | 2910 | int ret = GNUNET_SYSERR; |
2819 | 2911 | ||
2820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2826,7 +2918,7 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2826 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2918 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2827 | "%p Place is not ready yet, disconnecting client.\n", plc); | 2919 | "%p Place is not ready yet, disconnecting client.\n", plc); |
2828 | GNUNET_break (0); | 2920 | GNUNET_break (0); |
2829 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2921 | GNUNET_SERVICE_client_drop (client); |
2830 | return; | 2922 | return; |
2831 | } | 2923 | } |
2832 | 2924 | ||
@@ -2840,7 +2932,7 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2840 | plc, psize); | 2932 | plc, psize); |
2841 | GNUNET_break (0); | 2933 | GNUNET_break (0); |
2842 | psyc_transmit_cancel (plc, client); | 2934 | psyc_transmit_cancel (plc, client); |
2843 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2935 | GNUNET_SERVICE_client_drop (client); |
2844 | return; | 2936 | return; |
2845 | } | 2937 | } |
2846 | 2938 | ||
@@ -2853,20 +2945,20 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2853 | "%p Received invalid message part from client.\n", plc); | 2945 | "%p Received invalid message part from client.\n", plc); |
2854 | GNUNET_break (0); | 2946 | GNUNET_break (0); |
2855 | psyc_transmit_cancel (plc, client); | 2947 | psyc_transmit_cancel (plc, client); |
2856 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2948 | GNUNET_SERVICE_client_drop (client); |
2857 | return; | 2949 | return; |
2858 | } | 2950 | } |
2859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2951 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2860 | "%p Received message with first part type %u and last part type %u.\n", | 2952 | "%p Received message with first part type %u and last part type %u.\n", |
2861 | plc, first_ptype, last_ptype); | 2953 | plc, first_ptype, last_ptype); |
2862 | 2954 | ||
2863 | ctx->tmit_msg | 2955 | c->tmit_msg |
2864 | = psyc_transmit_queue_message (plc, client, psize, &msg[1], | 2956 | = psyc_transmit_queue_message (plc, client, psize, &msg[1], |
2865 | first_ptype, last_ptype, ctx->tmit_msg); | 2957 | first_ptype, last_ptype, c->tmit_msg); |
2866 | if (NULL != ctx->tmit_msg) | 2958 | if (NULL != c->tmit_msg) |
2867 | { | 2959 | { |
2868 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= last_ptype) | 2960 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= last_ptype) |
2869 | ctx->tmit_msg = NULL; | 2961 | c->tmit_msg = NULL; |
2870 | ret = psyc_transmit_message (plc); | 2962 | ret = psyc_transmit_message (plc); |
2871 | } | 2963 | } |
2872 | 2964 | ||
@@ -2878,7 +2970,11 @@ client_recv_psyc_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
2878 | psyc_transmit_cancel (plc, client); | 2970 | psyc_transmit_cancel (plc, client); |
2879 | ret = GNUNET_SYSERR; | 2971 | ret = GNUNET_SYSERR; |
2880 | } | 2972 | } |
2881 | GNUNET_SERVER_receive_done (client, ret); | 2973 | |
2974 | if (GNUNET_OK == ret) | ||
2975 | GNUNET_SERVICE_client_continue (client); | ||
2976 | else | ||
2977 | GNUNET_SERVICE_client_drop (client); | ||
2882 | } | 2978 | } |
2883 | 2979 | ||
2884 | 2980 | ||
@@ -2889,7 +2985,8 @@ static void | |||
2889 | psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) | 2985 | psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) |
2890 | { | 2986 | { |
2891 | struct OperationClosure *opcls = cls; | 2987 | struct OperationClosure *opcls = cls; |
2892 | struct Place *plc = opcls->plc; | 2988 | struct Client *c = opcls->client; |
2989 | struct Place *plc = c->place; | ||
2893 | 2990 | ||
2894 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2991 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2895 | "%p Received historic message #%" PRId64 " (flags: %x)\n", | 2992 | "%p Received historic message #%" PRId64 " (flags: %x)\n", |
@@ -2921,14 +3018,25 @@ psyc_recv_history_result (void *cls, int64_t result, | |||
2921 | const void *err_msg, uint16_t err_msg_size) | 3018 | const void *err_msg, uint16_t err_msg_size) |
2922 | { | 3019 | { |
2923 | struct OperationClosure *opcls = cls; | 3020 | struct OperationClosure *opcls = cls; |
3021 | struct Client *c = opcls->client; | ||
3022 | struct Place *plc = c->place; | ||
3023 | |||
2924 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3024 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2925 | "%p History replay #%" PRIu64 ": " | 3025 | "%p History replay #%" PRIu64 ": " |
2926 | "PSYCstore returned %" PRId64 " (%.*s)\n", | 3026 | "PSYCstore returned %" PRId64 " (%.*s)\n", |
2927 | opcls->plc, GNUNET_ntohll (opcls->op_id), result, | 3027 | plc, GNUNET_ntohll (opcls->op_id), result, |
2928 | err_msg_size, (const char *) err_msg); | 3028 | err_msg_size, (const char *) err_msg); |
2929 | 3029 | ||
2930 | // FIXME: place might have been destroyed | 3030 | // FIXME: place might have been destroyed |
2931 | client_send_result (opcls->client, opcls->op_id, result, err_msg, err_msg_size); | 3031 | client_send_result (c->client, opcls->op_id, result, err_msg, err_msg_size); |
3032 | } | ||
3033 | |||
3034 | |||
3035 | static int | ||
3036 | check_client_history_replay (void *cls, | ||
3037 | const struct GNUNET_PSYC_HistoryRequestMessage *req) | ||
3038 | { | ||
3039 | return GNUNET_OK; | ||
2932 | } | 3040 | } |
2933 | 3041 | ||
2934 | 3042 | ||
@@ -2936,17 +3044,20 @@ psyc_recv_history_result (void *cls, int64_t result, | |||
2936 | * Client requests channel history. | 3044 | * Client requests channel history. |
2937 | */ | 3045 | */ |
2938 | static void | 3046 | static void |
2939 | client_recv_history_replay (void *cls, struct GNUNET_SERVER_Client *client, | 3047 | handle_client_history_replay (void *cls, |
2940 | const struct GNUNET_MessageHeader *msg) | 3048 | const struct GNUNET_PSYC_HistoryRequestMessage *req) |
2941 | { | 3049 | { |
2942 | struct Client * | 3050 | struct Client *c = cls; |
2943 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 3051 | struct GNUNET_SERVICE_Client *client = c->client; |
2944 | GNUNET_assert (NULL != ctx); | 3052 | struct Place *plc = c->place; |
2945 | struct Place *plc = ctx->plc; | 3053 | if (NULL == plc) |
3054 | { | ||
3055 | GNUNET_break (0); | ||
3056 | GNUNET_SERVICE_client_drop (client); | ||
3057 | return; | ||
3058 | } | ||
2946 | 3059 | ||
2947 | const struct GNUNET_PSYC_HistoryRequestMessage * | 3060 | uint16_t size = ntohs (req->header.size); |
2948 | req = (const struct GNUNET_PSYC_HistoryRequestMessage *) msg; | ||
2949 | uint16_t size = ntohs (msg->size); | ||
2950 | const char *method_prefix = (const char *) &req[1]; | 3061 | const char *method_prefix = (const char *) &req[1]; |
2951 | 3062 | ||
2952 | if (size < sizeof (*req) + 1 | 3063 | if (size < sizeof (*req) + 1 |
@@ -2957,13 +3068,12 @@ client_recv_history_replay (void *cls, struct GNUNET_SERVER_Client *client, | |||
2957 | "invalid method prefix. size: %u < %zu?\n", | 3068 | "invalid method prefix. size: %u < %zu?\n", |
2958 | plc, GNUNET_ntohll (req->op_id), size, sizeof (*req) + 1); | 3069 | plc, GNUNET_ntohll (req->op_id), size, sizeof (*req) + 1); |
2959 | GNUNET_break (0); | 3070 | GNUNET_break (0); |
2960 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 3071 | GNUNET_SERVICE_client_drop (client); |
2961 | return; | 3072 | return; |
2962 | } | 3073 | } |
2963 | 3074 | ||
2964 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); | 3075 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); |
2965 | opcls->client = client; | 3076 | opcls->client = c; |
2966 | opcls->plc = plc; | ||
2967 | opcls->op_id = req->op_id; | 3077 | opcls->op_id = req->op_id; |
2968 | opcls->flags = ntohl (req->flags); | 3078 | opcls->flags = ntohl (req->flags); |
2969 | 3079 | ||
@@ -2981,7 +3091,7 @@ client_recv_history_replay (void *cls, struct GNUNET_SERVER_Client *client, | |||
2981 | psyc_recv_history_message, NULL, | 3091 | psyc_recv_history_message, NULL, |
2982 | psyc_recv_history_result, opcls); | 3092 | psyc_recv_history_result, opcls); |
2983 | 3093 | ||
2984 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3094 | GNUNET_SERVICE_client_continue (client); |
2985 | } | 3095 | } |
2986 | 3096 | ||
2987 | 3097 | ||
@@ -2997,7 +3107,8 @@ psyc_recv_state_var (void *cls, | |||
2997 | uint32_t full_value_size) | 3107 | uint32_t full_value_size) |
2998 | { | 3108 | { |
2999 | struct OperationClosure *opcls = cls; | 3109 | struct OperationClosure *opcls = cls; |
3000 | struct Place *plc = opcls->plc; | 3110 | struct Client *c = opcls->client; |
3111 | struct Place *plc = c->place; | ||
3001 | 3112 | ||
3002 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3003 | "%p Received state variable %s from PSYC\n", | 3114 | "%p Received state variable %s from PSYC\n", |
@@ -3029,14 +3140,25 @@ psyc_recv_state_result (void *cls, int64_t result, | |||
3029 | const void *err_msg, uint16_t err_msg_size) | 3140 | const void *err_msg, uint16_t err_msg_size) |
3030 | { | 3141 | { |
3031 | struct OperationClosure *opcls = cls; | 3142 | struct OperationClosure *opcls = cls; |
3143 | struct Client *c = opcls->client; | ||
3144 | struct Place *plc = c->place; | ||
3145 | |||
3032 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3033 | "%p State get #%" PRIu64 ": " | 3147 | "%p State get #%" PRIu64 ": " |
3034 | "PSYCstore returned %" PRId64 " (%.*s)\n", | 3148 | "PSYCstore returned %" PRId64 " (%.*s)\n", |
3035 | opcls->plc, GNUNET_ntohll (opcls->op_id), result, | 3149 | plc, GNUNET_ntohll (opcls->op_id), result, |
3036 | err_msg_size, (const char *) err_msg); | 3150 | err_msg_size, (const char *) err_msg); |
3037 | 3151 | ||
3038 | // FIXME: place might have been destroyed | 3152 | // FIXME: place might have been destroyed |
3039 | client_send_result (opcls->client, opcls->op_id, result, err_msg, err_msg_size); | 3153 | client_send_result (c->client, opcls->op_id, result, err_msg, err_msg_size); |
3154 | } | ||
3155 | |||
3156 | |||
3157 | static int | ||
3158 | check_client_state_get (void *cls, | ||
3159 | const struct GNUNET_PSYC_StateRequestMessage *req) | ||
3160 | { | ||
3161 | return GNUNET_OK; | ||
3040 | } | 3162 | } |
3041 | 3163 | ||
3042 | 3164 | ||
@@ -3044,17 +3166,20 @@ psyc_recv_state_result (void *cls, int64_t result, | |||
3044 | * Client requests channel history. | 3166 | * Client requests channel history. |
3045 | */ | 3167 | */ |
3046 | static void | 3168 | static void |
3047 | client_recv_state_get (void *cls, struct GNUNET_SERVER_Client *client, | 3169 | handle_client_state_get (void *cls, |
3048 | const struct GNUNET_MessageHeader *msg) | 3170 | const struct GNUNET_PSYC_StateRequestMessage *req) |
3049 | { | 3171 | { |
3050 | struct Client * | 3172 | struct Client *c = cls; |
3051 | ctx = GNUNET_SERVER_client_get_user_context (client, struct Client); | 3173 | struct GNUNET_SERVICE_Client *client = c->client; |
3052 | GNUNET_assert (NULL != ctx); | 3174 | struct Place *plc = c->place; |
3053 | struct Place *plc = ctx->plc; | 3175 | if (NULL == plc) |
3176 | { | ||
3177 | GNUNET_break (0); | ||
3178 | GNUNET_SERVICE_client_drop (client); | ||
3179 | return; | ||
3180 | } | ||
3054 | 3181 | ||
3055 | const struct GNUNET_PSYC_StateRequestMessage * | 3182 | uint16_t size = ntohs (req->header.size); |
3056 | req = (const struct GNUNET_PSYC_StateRequestMessage *) msg; | ||
3057 | uint16_t size = ntohs (msg->size); | ||
3058 | const char *name = (const char *) &req[1]; | 3183 | const char *name = (const char *) &req[1]; |
3059 | 3184 | ||
3060 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3185 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -3069,16 +3194,15 @@ client_recv_state_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
3069 | "invalid name. size: %u < %zu?\n", | 3194 | "invalid name. size: %u < %zu?\n", |
3070 | plc, GNUNET_ntohll (req->op_id), size, sizeof (*req) + 1); | 3195 | plc, GNUNET_ntohll (req->op_id), size, sizeof (*req) + 1); |
3071 | GNUNET_break (0); | 3196 | GNUNET_break (0); |
3072 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 3197 | GNUNET_SERVICE_client_drop (client); |
3073 | return; | 3198 | return; |
3074 | } | 3199 | } |
3075 | 3200 | ||
3076 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); | 3201 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); |
3077 | opcls->client = client; | 3202 | opcls->client = c; |
3078 | opcls->plc = plc; | ||
3079 | opcls->op_id = req->op_id; | 3203 | opcls->op_id = req->op_id; |
3080 | 3204 | ||
3081 | switch (ntohs (msg->type)) | 3205 | switch (ntohs (req->header.type)) |
3082 | { | 3206 | { |
3083 | case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET: | 3207 | case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET: |
3084 | GNUNET_PSYC_channel_state_get (plc->channel, name, | 3208 | GNUNET_PSYC_channel_state_get (plc->channel, name, |
@@ -3096,18 +3220,33 @@ client_recv_state_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
3096 | GNUNET_assert (0); | 3220 | GNUNET_assert (0); |
3097 | } | 3221 | } |
3098 | 3222 | ||
3099 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3223 | GNUNET_SERVICE_client_continue (client); |
3100 | } | 3224 | } |
3101 | 3225 | ||
3102 | 3226 | ||
3227 | #define check_client_state_get_prefix check_client_state_get | ||
3228 | #define handle_client_state_get_prefix handle_client_state_get | ||
3229 | |||
3230 | |||
3103 | static void | 3231 | static void |
3104 | namestore_recv_records_store_result (void *cls, int32_t result, | 3232 | namestore_recv_records_store_result (void *cls, int32_t result, |
3105 | const char *err_msg) | 3233 | const char *err_msg) |
3106 | { | 3234 | { |
3107 | struct OperationClosure *ocls = cls; | 3235 | struct OperationClosure *opcls = cls; |
3108 | client_send_result (ocls->client, ocls->op_id, result, err_msg, | 3236 | struct Client *c = opcls->client; |
3237 | |||
3238 | // FIXME: client might have been disconnected | ||
3239 | client_send_result (c->client, opcls->op_id, result, err_msg, | ||
3109 | (NULL != err_msg) ? strlen (err_msg) : 0); | 3240 | (NULL != err_msg) ? strlen (err_msg) : 0); |
3110 | GNUNET_free (ocls); | 3241 | GNUNET_free (opcls); |
3242 | } | ||
3243 | |||
3244 | |||
3245 | static int | ||
3246 | check_client_zone_add_place (void *cls, | ||
3247 | const struct ZoneAddPlaceRequest *preq) | ||
3248 | { | ||
3249 | return GNUNET_OK; | ||
3111 | } | 3250 | } |
3112 | 3251 | ||
3113 | 3252 | ||
@@ -3115,11 +3254,11 @@ namestore_recv_records_store_result (void *cls, int32_t result, | |||
3115 | * Handle request to add PLACE record to GNS zone. | 3254 | * Handle request to add PLACE record to GNS zone. |
3116 | */ | 3255 | */ |
3117 | static void | 3256 | static void |
3118 | client_recv_zone_add_place (void *cls, struct GNUNET_SERVER_Client *client, | 3257 | handle_client_zone_add_place (void *cls, |
3119 | const struct GNUNET_MessageHeader *msg) | 3258 | const struct ZoneAddPlaceRequest *preq) |
3120 | { | 3259 | { |
3121 | const struct ZoneAddPlaceRequest *preq | 3260 | struct Client *c = cls; |
3122 | = (const struct ZoneAddPlaceRequest *) msg; | 3261 | struct GNUNET_SERVICE_Client *client = c->client; |
3123 | 3262 | ||
3124 | uint16_t remaining = ntohs (preq->header.size) - sizeof (*preq); | 3263 | uint16_t remaining = ntohs (preq->header.size) - sizeof (*preq); |
3125 | const char *p = (const char *) &preq[1]; | 3264 | const char *p = (const char *) &preq[1]; |
@@ -3136,7 +3275,7 @@ client_recv_zone_add_place (void *cls, struct GNUNET_SERVER_Client *client, | |||
3136 | { | 3275 | { |
3137 | GNUNET_break (0); | 3276 | GNUNET_break (0); |
3138 | client_send_result (client, preq->op_id, GNUNET_SYSERR, NULL, 0); | 3277 | client_send_result (client, preq->op_id, GNUNET_SYSERR, NULL, 0); |
3139 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3278 | GNUNET_SERVICE_client_drop (client); |
3140 | return; | 3279 | return; |
3141 | } | 3280 | } |
3142 | 3281 | ||
@@ -3164,15 +3303,23 @@ client_recv_zone_add_place (void *cls, struct GNUNET_SERVER_Client *client, | |||
3164 | } | 3303 | } |
3165 | else | 3304 | else |
3166 | { | 3305 | { |
3167 | struct OperationClosure *ocls = GNUNET_malloc (sizeof (*ocls)); | 3306 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); |
3168 | ocls->client = client; | 3307 | opcls->client = c; |
3169 | ocls->op_id = preq->op_id; | 3308 | opcls->op_id = preq->op_id; |
3170 | GNUNET_NAMESTORE_records_store (namestore, &ego->key, | 3309 | GNUNET_NAMESTORE_records_store (namestore, &ego->key, |
3171 | name, 1, &rd, | 3310 | name, 1, &rd, |
3172 | namestore_recv_records_store_result, ocls); | 3311 | namestore_recv_records_store_result, opcls); |
3173 | /** @todo refresh stored records later */ | 3312 | /** @todo refresh stored records later */ |
3174 | } | 3313 | } |
3175 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3314 | GNUNET_SERVICE_client_continue (client); |
3315 | } | ||
3316 | |||
3317 | |||
3318 | static int | ||
3319 | check_client_zone_add_nym (void *cls, | ||
3320 | const struct ZoneAddNymRequest *nreq) | ||
3321 | { | ||
3322 | return GNUNET_OK; | ||
3176 | } | 3323 | } |
3177 | 3324 | ||
3178 | 3325 | ||
@@ -3180,11 +3327,11 @@ client_recv_zone_add_place (void *cls, struct GNUNET_SERVER_Client *client, | |||
3180 | * Handle request to add PLACE record to GNS zone. | 3327 | * Handle request to add PLACE record to GNS zone. |
3181 | */ | 3328 | */ |
3182 | static void | 3329 | static void |
3183 | client_recv_zone_add_nym (void *cls, struct GNUNET_SERVER_Client *client, | 3330 | handle_client_zone_add_nym (void *cls, |
3184 | const struct GNUNET_MessageHeader *msg) | 3331 | const struct ZoneAddNymRequest *nreq) |
3185 | { | 3332 | { |
3186 | const struct ZoneAddNymRequest *nreq | 3333 | struct Client *c = cls; |
3187 | = (const struct ZoneAddNymRequest *) msg; | 3334 | struct GNUNET_SERVICE_Client *client = c->client; |
3188 | 3335 | ||
3189 | uint16_t name_size = ntohs (nreq->header.size) - sizeof (*nreq); | 3336 | uint16_t name_size = ntohs (nreq->header.size) - sizeof (*nreq); |
3190 | const char *name = NULL; | 3337 | const char *name = NULL; |
@@ -3194,7 +3341,7 @@ client_recv_zone_add_nym (void *cls, struct GNUNET_SERVER_Client *client, | |||
3194 | { | 3341 | { |
3195 | GNUNET_break (0); | 3342 | GNUNET_break (0); |
3196 | client_send_result (client, nreq->op_id, GNUNET_SYSERR, NULL, 0); | 3343 | client_send_result (client, nreq->op_id, GNUNET_SYSERR, NULL, 0); |
3197 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3344 | GNUNET_SERVICE_client_continue (client); |
3198 | return; | 3345 | return; |
3199 | } | 3346 | } |
3200 | 3347 | ||
@@ -3214,68 +3361,18 @@ client_recv_zone_add_nym (void *cls, struct GNUNET_SERVER_Client *client, | |||
3214 | } | 3361 | } |
3215 | else | 3362 | else |
3216 | { | 3363 | { |
3217 | struct OperationClosure *ocls = GNUNET_malloc (sizeof (*ocls)); | 3364 | struct OperationClosure *opcls = GNUNET_malloc (sizeof (*opcls)); |
3218 | ocls->client = client; | 3365 | opcls->client = c; |
3219 | ocls->op_id = nreq->op_id; | 3366 | opcls->op_id = nreq->op_id; |
3220 | GNUNET_NAMESTORE_records_store (namestore, &ego->key, | 3367 | GNUNET_NAMESTORE_records_store (namestore, &ego->key, |
3221 | name, 1, &rd, | 3368 | name, 1, &rd, |
3222 | namestore_recv_records_store_result, ocls); | 3369 | namestore_recv_records_store_result, opcls); |
3223 | /** @todo refresh stored records later */ | 3370 | /** @todo refresh stored records later */ |
3224 | } | 3371 | } |
3225 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 3372 | GNUNET_SERVICE_client_continue (client); |
3226 | } | 3373 | } |
3227 | 3374 | ||
3228 | 3375 | ||
3229 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | ||
3230 | { client_recv_host_enter, NULL, | ||
3231 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 0 }, | ||
3232 | |||
3233 | { client_recv_guest_enter, NULL, | ||
3234 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, 0 }, | ||
3235 | |||
3236 | { client_recv_guest_enter_by_name, NULL, | ||
3237 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, 0 }, | ||
3238 | |||
3239 | { client_recv_join_decision, NULL, | ||
3240 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, 0 }, | ||
3241 | |||
3242 | { client_recv_psyc_message, NULL, | ||
3243 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 0 }, | ||
3244 | |||
3245 | { client_recv_history_replay, NULL, | ||
3246 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 0 }, | ||
3247 | |||
3248 | { client_recv_state_get, NULL, | ||
3249 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 0 }, | ||
3250 | |||
3251 | { client_recv_state_get, NULL, | ||
3252 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 0 }, | ||
3253 | |||
3254 | { client_recv_zone_add_place, NULL, | ||
3255 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, 0 }, | ||
3256 | |||
3257 | { client_recv_zone_add_nym, NULL, | ||
3258 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, 0 }, | ||
3259 | |||
3260 | { client_recv_app_connect, NULL, | ||
3261 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, 0 }, | ||
3262 | |||
3263 | { client_recv_app_detach, NULL, | ||
3264 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, 0 }, | ||
3265 | |||
3266 | { client_recv_place_leave, NULL, | ||
3267 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, 0 }, | ||
3268 | |||
3269 | { client_recv_msg_proc_set, NULL, | ||
3270 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, 0 }, | ||
3271 | |||
3272 | { client_recv_msg_proc_clear, NULL, | ||
3273 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, 0 }, | ||
3274 | |||
3275 | { NULL, NULL, 0, 0 } | ||
3276 | }; | ||
3277 | |||
3278 | |||
3279 | const char * | 3376 | const char * |
3280 | path_basename (const char *path) | 3377 | path_basename (const char *path) |
3281 | { | 3378 | { |
@@ -3468,10 +3565,12 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, | |||
3468 | * @param c Configuration to use. | 3565 | * @param c Configuration to use. |
3469 | */ | 3566 | */ |
3470 | static void | 3567 | static void |
3471 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 3568 | run (void *cls, |
3472 | const struct GNUNET_CONFIGURATION_Handle *c) | 3569 | const struct GNUNET_CONFIGURATION_Handle *c, |
3570 | struct GNUNET_SERVICE_Handle *svc) | ||
3473 | { | 3571 | { |
3474 | cfg = c; | 3572 | cfg = c; |
3573 | service = svc; | ||
3475 | GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); | 3574 | GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); |
3476 | 3575 | ||
3477 | hosts = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); | 3576 | hosts = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); |
@@ -3505,27 +3604,79 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
3505 | 3604 | ||
3506 | GNUNET_DISK_directory_scan (dir_apps, scan_app_dir, NULL); | 3605 | GNUNET_DISK_directory_scan (dir_apps, scan_app_dir, NULL); |
3507 | 3606 | ||
3508 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 3607 | GNUNET_SCHEDULER_add_shutdown (shutdown_task, NULL); |
3509 | GNUNET_SERVER_add_handlers (server, handlers); | 3608 | } |
3510 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); | 3609 | |
3511 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); | 3610 | |
3512 | } | 3611 | /** |
3513 | 3612 | * Define "main" method using service macro. | |
3514 | 3613 | */ | |
3515 | /** | 3614 | GNUNET_SERVICE_MAIN |
3516 | * The main function for the service. | 3615 | ("social", |
3517 | * | 3616 | GNUNET_SERVICE_OPTION_NONE, |
3518 | * @param argc number of arguments from the command line | 3617 | run, |
3519 | * @param argv command line arguments | 3618 | client_notify_connect, |
3520 | * @return 0 ok, 1 on error | 3619 | client_notify_disconnect, |
3521 | */ | 3620 | NULL, |
3522 | int | 3621 | GNUNET_MQ_hd_var_size (client_host_enter, |
3523 | main (int argc, char *const *argv) | 3622 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, |
3524 | { | 3623 | struct HostEnterRequest, |
3525 | return (GNUNET_OK == | 3624 | NULL), |
3526 | GNUNET_SERVICE_run (argc, argv, "social", | 3625 | GNUNET_MQ_hd_var_size (client_guest_enter, |
3527 | GNUNET_SERVICE_OPTION_NONE, | 3626 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, |
3528 | &run, NULL)) ? 0 : 1; | 3627 | struct GuestEnterRequest, |
3529 | } | 3628 | NULL), |
3629 | GNUNET_MQ_hd_var_size (client_guest_enter_by_name, | ||
3630 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, | ||
3631 | struct GuestEnterByNameRequest, | ||
3632 | NULL), | ||
3633 | GNUNET_MQ_hd_var_size (client_join_decision, | ||
3634 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, | ||
3635 | struct GNUNET_PSYC_JoinDecisionMessage, | ||
3636 | NULL), | ||
3637 | GNUNET_MQ_hd_var_size (client_psyc_message, | ||
3638 | GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, | ||
3639 | struct GNUNET_MessageHeader, | ||
3640 | NULL), | ||
3641 | GNUNET_MQ_hd_var_size (client_history_replay, | ||
3642 | GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, | ||
3643 | struct GNUNET_PSYC_HistoryRequestMessage, | ||
3644 | NULL), | ||
3645 | GNUNET_MQ_hd_var_size (client_state_get, | ||
3646 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, | ||
3647 | struct GNUNET_PSYC_StateRequestMessage, | ||
3648 | NULL), | ||
3649 | GNUNET_MQ_hd_var_size (client_state_get_prefix, | ||
3650 | GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, | ||
3651 | struct GNUNET_PSYC_StateRequestMessage, | ||
3652 | NULL), | ||
3653 | GNUNET_MQ_hd_var_size (client_zone_add_place, | ||
3654 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, | ||
3655 | struct ZoneAddPlaceRequest, | ||
3656 | NULL), | ||
3657 | GNUNET_MQ_hd_var_size (client_zone_add_nym, | ||
3658 | GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, | ||
3659 | struct ZoneAddNymRequest, | ||
3660 | NULL), | ||
3661 | GNUNET_MQ_hd_var_size (client_app_connect, | ||
3662 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, | ||
3663 | struct AppConnectRequest, | ||
3664 | NULL), | ||
3665 | GNUNET_MQ_hd_fixed_size (client_app_detach, | ||
3666 | GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, | ||
3667 | struct AppDetachRequest, | ||
3668 | NULL), | ||
3669 | GNUNET_MQ_hd_fixed_size (client_place_leave, | ||
3670 | GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, | ||
3671 | struct GNUNET_MessageHeader, | ||
3672 | NULL), | ||
3673 | GNUNET_MQ_hd_var_size (client_msg_proc_set, | ||
3674 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, | ||
3675 | struct MsgProcRequest, | ||
3676 | NULL), | ||
3677 | GNUNET_MQ_hd_fixed_size (client_msg_proc_clear, | ||
3678 | GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, | ||
3679 | struct GNUNET_MessageHeader, | ||
3680 | NULL)); | ||
3530 | 3681 | ||
3531 | /* end of gnunet-service-social.c */ | 3682 | /* end of gnunet-service-social.c */ |
diff --git a/src/social/social.h b/src/social/social.h index 3e32a4464..751ad186c 100644 --- a/src/social/social.h +++ b/src/social/social.h | |||
@@ -73,10 +73,14 @@ struct AppDetachRequest | |||
73 | struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key; | 73 | struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Public key of ego. | ||
77 | */ | ||
78 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; | ||
79 | |||
80 | /** | ||
76 | * Operation ID. | 81 | * Operation ID. |
77 | */ | 82 | */ |
78 | uint64_t op_id GNUNET_PACKED; | 83 | uint64_t op_id GNUNET_PACKED; |
79 | |||
80 | }; | 84 | }; |
81 | 85 | ||
82 | 86 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index f05e437ca..f78cb9a85 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -2736,6 +2736,7 @@ GNUNET_SOCIAL_app_detach (struct GNUNET_SOCIAL_App *app, | |||
2736 | struct GNUNET_MQ_Envelope * | 2736 | struct GNUNET_MQ_Envelope * |
2737 | env = GNUNET_MQ_msg (dreq, GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH); | 2737 | env = GNUNET_MQ_msg (dreq, GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH); |
2738 | dreq->place_pub_key = plc->pub_key; | 2738 | dreq->place_pub_key = plc->pub_key; |
2739 | dreq->ego_pub_key = plc->ego_pub_key; | ||
2739 | 2740 | ||
2740 | GNUNET_MQ_send (app->mq, env); | 2741 | GNUNET_MQ_send (app->mq, env); |
2741 | } | 2742 | } |