aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/social/gnunet-service-social.c652
1 files changed, 351 insertions, 301 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index cda96e5..6fd2383 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -96,7 +96,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *apps_places;
96 * Application subscriptions per place. 96 * Application subscriptions per place.
97 * H(place_pub_key) -> H(app_id) 97 * H(place_pub_key) -> H(app_id)
98 */ 98 */
99//static struct GNUNET_CONTAINER_MultiHashMap *places_apps; 99// static struct GNUNET_CONTAINER_MultiHashMap *places_apps;
100 100
101/** 101/**
102 * Connected applications. 102 * Connected applications.
@@ -265,7 +265,8 @@ struct Place
265 */ 265 */
266 uint8_t is_host; 266 uint8_t is_host;
267 267
268 union { 268 union
269 {
269 struct Host *host; 270 struct Host *host;
270 struct Guest *guest; 271 struct Guest *guest;
271 }; 272 };
@@ -397,7 +398,8 @@ struct Application
397}; 398};
398 399
399 400
400struct Ego { 401struct Ego
402{
401 struct GNUNET_CRYPTO_EcdsaPrivateKey key; 403 struct GNUNET_CRYPTO_EcdsaPrivateKey key;
402 char *name; 404 char *name;
403}; 405};
@@ -629,7 +631,7 @@ place_send_msg (const struct Place *plc,
629 struct GNUNET_MQ_Envelope *env) 631 struct GNUNET_MQ_Envelope *env)
630{ 632{
631 struct ClientListItem *cli = plc->clients_head; 633 struct ClientListItem *cli = plc->clients_head;
632 634
633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
634 "%p Sending message to clients of place.\n", plc); 636 "%p Sending message to clients of place.\n", plc);
635 while (NULL != cli) 637 while (NULL != cli)
@@ -649,14 +651,14 @@ static void
649place_send_leave_ack (struct Place *plc) 651place_send_leave_ack (struct Place *plc)
650{ 652{
651 struct GNUNET_MQ_Envelope *env; 653 struct GNUNET_MQ_Envelope *env;
652 654
653 for (struct ClientListItem *cli = plc->clients_head; 655 for (struct ClientListItem *cli = plc->clients_head;
654 NULL != cli; 656 NULL != cli;
655 cli = cli->next) 657 cli = cli->next)
656 { 658 {
657 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK); 659 env = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE_ACK);
658 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client), 660 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (cli->client),
659 env); 661 env);
660 } 662 }
661} 663}
662 664
@@ -690,9 +692,9 @@ client_send_result (struct GNUNET_SERVICE_Client *client, uint64_t op_id,
690 if (0 < data_size) 692 if (0 < data_size)
691 GNUNET_memcpy (&res[1], data, data_size); 693 GNUNET_memcpy (&res[1], data, data_size);
692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 694 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
693 "%p Sending result to client for operation #%" PRIu64 ": " 695 "%p Sending result to client for operation #%" PRIu64 ": "
694 "%" PRId64 " (size: %u)\n", 696 "%" PRId64 " (size: %u)\n",
695 client, GNUNET_ntohll (op_id), result_code, data_size); 697 client, GNUNET_ntohll (op_id), result_code, data_size);
696 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); 698 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
697} 699}
698 700
@@ -706,7 +708,7 @@ client_send_host_enter_ack (struct GNUNET_SERVICE_Client *client,
706 struct Place *plc = &hst->place; 708 struct Place *plc = &hst->place;
707 709
708 env = GNUNET_MQ_msg (hack, 710 env = GNUNET_MQ_msg (hack,
709 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); 711 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK);
710 hack->result_code = htonl (result); 712 hack->result_code = htonl (result);
711 hack->max_message_id = GNUNET_htonll (plc->max_message_id); 713 hack->max_message_id = GNUNET_htonll (plc->max_message_id);
712 hack->place_pub_key = plc->pub_key; 714 hack->place_pub_key = plc->pub_key;
@@ -855,7 +857,8 @@ host_relay_message_part (struct Host *hst,
855 GNUNET_CRYPTO_hash (nym_pub_key, sizeof (*nym_pub_key), &nym_pub_hash); 857 GNUNET_CRYPTO_hash (nym_pub_key, sizeof (*nym_pub_key), &nym_pub_hash);
856 858
857 struct MessageTransmitQueue * 859 struct MessageTransmitQueue *
858 tmit_msg = GNUNET_CONTAINER_multihashmap_get (hst->relay_msgs, &nym_pub_hash); 860 tmit_msg = GNUNET_CONTAINER_multihashmap_get (hst->relay_msgs,
861 &nym_pub_hash);
859 862
860 uint16_t ptype = ntohs (pmsg->type); 863 uint16_t ptype = ntohs (pmsg->type);
861 864
@@ -863,7 +866,7 @@ host_relay_message_part (struct Host *hst,
863 { 866 {
864 /* FIXME: last message was unfinished, cancel & remove from queue */ 867 /* FIXME: last message was unfinished, cancel & remove from queue */
865 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 868 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
866 "FIXME: last message was unfinished.\n"); 869 "FIXME: last message was unfinished.\n");
867 } 870 }
868 871
869 tmit_msg = psyc_transmit_queue_message (&hst->place, NULL, ntohs (pmsg->size), 872 tmit_msg = psyc_transmit_queue_message (&hst->place, NULL, ntohs (pmsg->size),
@@ -873,13 +876,13 @@ host_relay_message_part (struct Host *hst,
873 { 876 {
874 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: 877 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
875 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put 878 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put
876 (hst->relay_msgs, &nym_pub_hash, tmit_msg, 879 (hst->relay_msgs, &nym_pub_hash, tmit_msg,
877 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 880 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
878 break; 881 break;
879 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: 882 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
880 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: 883 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
881 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove 884 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove
882 (hst->relay_msgs, &nym_pub_hash, tmit_msg)); 885 (hst->relay_msgs, &nym_pub_hash, tmit_msg));
883 break; 886 break;
884 } 887 }
885} 888}
@@ -898,7 +901,7 @@ place_recv_relay_method (void *cls,
898 struct Place *plc = cls; 901 struct Place *plc = cls;
899 902
900 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) 903 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags)
901 && GNUNET_YES == plc->is_host) 904 && (GNUNET_YES == plc->is_host))
902 { 905 {
903 struct Host *hst = cls; 906 struct Host *hst = cls;
904 host_relay_message_part (hst, &meth->header, &msg->slave_pub_key); 907 host_relay_message_part (hst, &meth->header, &msg->slave_pub_key);
@@ -923,13 +926,14 @@ place_recv_relay_modifier (void *cls,
923 struct Place *plc = cls; 926 struct Place *plc = cls;
924 927
925 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) 928 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags)
926 && GNUNET_YES == plc->is_host) 929 && (GNUNET_YES == plc->is_host))
927 { 930 {
928 struct Host *hst = cls; 931 struct Host *hst = cls;
929 host_relay_message_part (hst, pmsg, &msg->slave_pub_key); 932 host_relay_message_part (hst, pmsg, &msg->slave_pub_key);
930 } 933 }
931} 934}
932 935
936
933/** 937/**
934 * Received a data fragment to be relayed from a guest. 938 * Received a data fragment to be relayed from a guest.
935 */ 939 */
@@ -944,7 +948,7 @@ place_recv_relay_data (void *cls,
944 struct Place *plc = cls; 948 struct Place *plc = cls;
945 949
946 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) 950 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags)
947 && GNUNET_YES == plc->is_host) 951 && (GNUNET_YES == plc->is_host))
948 { 952 {
949 struct Host *hst = cls; 953 struct Host *hst = cls;
950 host_relay_message_part (hst, pmsg, &msg->slave_pub_key); 954 host_relay_message_part (hst, pmsg, &msg->slave_pub_key);
@@ -965,7 +969,7 @@ place_recv_relay_eom (void *cls,
965 struct Place *plc = cls; 969 struct Place *plc = cls;
966 970
967 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags) 971 if (GNUNET_PSYC_MESSAGE_REQUEST & ntohs (msg->flags)
968 && GNUNET_YES == plc->is_host) 972 && (GNUNET_YES == plc->is_host))
969 { 973 {
970 struct Host *hst = cls; 974 struct Host *hst = cls;
971 host_relay_message_part (hst, pmsg, &msg->slave_pub_key); 975 host_relay_message_part (hst, pmsg, &msg->slave_pub_key);
@@ -990,7 +994,8 @@ place_recv_save_method (void *cls,
990 plc->file_offset = 0; 994 plc->file_offset = 0;
991 plc->file_save = GNUNET_NO; 995 plc->file_save = GNUNET_NO;
992 996
993 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); 997 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (
998 &plc->pub_key);
994 char *filename = NULL; 999 char *filename = NULL;
995 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part", 1000 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part",
996 dir_social, DIR_SEPARATOR, 1001 dir_social, DIR_SEPARATOR,
@@ -1002,9 +1007,10 @@ place_recv_save_method (void *cls,
1002 /* save if does not already exist */ 1007 /* save if does not already exist */
1003 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 1008 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
1004 { 1009 {
1005 if (0 == GNUNET_DISK_fn_write (filename, NULL, 0, 1010 if (GNUNET_OK ==
1006 GNUNET_DISK_PERM_USER_READ 1011 GNUNET_DISK_fn_write (filename, NULL, 0,
1007 | GNUNET_DISK_PERM_USER_WRITE)) 1012 GNUNET_DISK_PERM_USER_READ
1013 | GNUNET_DISK_PERM_USER_WRITE))
1008 { 1014 {
1009 plc->file_save = GNUNET_YES; 1015 plc->file_save = GNUNET_YES;
1010 } 1016 }
@@ -1034,7 +1040,8 @@ place_recv_save_data (void *cls,
1034 if (GNUNET_YES != plc->file_save) 1040 if (GNUNET_YES != plc->file_save)
1035 return; 1041 return;
1036 1042
1037 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); 1043 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (
1044 &plc->pub_key);
1038 char *filename = NULL; 1045 char *filename = NULL;
1039 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part", 1046 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%" PRIu64 ".part",
1040 dir_social, DIR_SEPARATOR, 1047 dir_social, DIR_SEPARATOR,
@@ -1055,7 +1062,8 @@ place_recv_save_data (void *cls,
1055 if (NULL != fh) 1062 if (NULL != fh)
1056 { 1063 {
1057 if (plc->file_offset != GNUNET_DISK_file_seek 1064 if (plc->file_offset != GNUNET_DISK_file_seek
1058 (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) { 1065 (fh, plc->file_offset, GNUNET_DISK_SEEK_SET))
1066 {
1059 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename); 1067 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename);
1060 GNUNET_DISK_file_close (fh); 1068 GNUNET_DISK_file_close (fh);
1061 GNUNET_free (filename); 1069 GNUNET_free (filename);
@@ -1090,7 +1098,8 @@ place_recv_save_eom (void *cls,
1090 if (GNUNET_YES != plc->file_save) 1098 if (GNUNET_YES != plc->file_save)
1091 return; 1099 return;
1092 1100
1093 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&plc->pub_key); 1101 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (
1102 &plc->pub_key);
1094 char *fn = NULL; 1103 char *fn = NULL;
1095 GNUNET_asprintf (&fn, "%s%c%s%c%s%c%" PRIu64, 1104 GNUNET_asprintf (&fn, "%s%c%s%c%s%c%" PRIu64,
1096 dir_social, DIR_SEPARATOR, 1105 dir_social, DIR_SEPARATOR,
@@ -1101,10 +1110,11 @@ place_recv_save_eom (void *cls,
1101 char *fn_part = NULL; 1110 char *fn_part = NULL;
1102 GNUNET_asprintf (&fn_part, "%s.part", fn); 1111 GNUNET_asprintf (&fn_part, "%s.part", fn);
1103 1112
1104 if (rename (fn_part, fn)) { 1113 if (rename (fn_part, fn))
1105 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1114 {
1106 "Failed to rename %s into %s: %s (%d)\n", 1115 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1107 fn_part, fn, strerror (errno), errno); 1116 "Failed to rename %s into %s: %s (%d)\n",
1117 fn_part, fn, strerror (errno), errno);
1108 } 1118 }
1109 1119
1110 GNUNET_free (fn); 1120 GNUNET_free (fn);
@@ -1140,7 +1150,8 @@ place_add (const struct PlaceEnterRequest *ereq)
1140 .place_pub_key = ereq->place_pub_key, 1150 .place_pub_key = ereq->place_pub_key,
1141 }; 1151 };
1142 struct GNUNET_HashCode ego_place_pub_hash; 1152 struct GNUNET_HashCode ego_place_pub_hash;
1143 GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), &ego_place_pub_hash); 1153 GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key),
1154 &ego_place_pub_hash);
1144 1155
1145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1146 " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash)); 1157 " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash));
@@ -1151,7 +1162,9 @@ place_add (const struct PlaceEnterRequest *ereq)
1151 return GNUNET_NO; 1162 return GNUNET_NO;
1152 1163
1153 place_msg = GNUNET_copy_message (&ereq->header); 1164 place_msg = GNUNET_copy_message (&ereq->header);
1154 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places, &ego_place_pub_hash, place_msg, 1165 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places,
1166 &ego_place_pub_hash,
1167 place_msg,
1155 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 1168 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
1156 { 1169 {
1157 GNUNET_break (0); 1170 GNUNET_break (0);
@@ -1162,6 +1175,7 @@ place_add (const struct PlaceEnterRequest *ereq)
1162 return GNUNET_OK; 1175 return GNUNET_OK;
1163} 1176}
1164 1177
1178
1165/** 1179/**
1166 * Add a place to the @e app_places hash map. 1180 * Add a place to the @e app_places hash map.
1167 * 1181 *
@@ -1191,7 +1205,8 @@ app_place_add (const char *app_id,
1191 .place_pub_key = ereq->place_pub_key, 1205 .place_pub_key = ereq->place_pub_key,
1192 }; 1206 };
1193 struct GNUNET_HashCode ego_place_pub_hash; 1207 struct GNUNET_HashCode ego_place_pub_hash;
1194 GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key), &ego_place_pub_hash); 1208 GNUNET_CRYPTO_hash (&ego_place_pub_key, sizeof (ego_place_pub_key),
1209 &ego_place_pub_hash);
1195 1210
1196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1197 " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash)); 1212 " ego_place_pub_hash = %s\n", GNUNET_h2s (&ego_place_pub_hash));
@@ -1205,7 +1220,8 @@ app_place_add (const char *app_id,
1205 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1220 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1206 } 1221 }
1207 1222
1208 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (app_places, &ego_place_pub_hash)) 1223 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (app_places,
1224 &ego_place_pub_hash))
1209 return GNUNET_NO; 1225 return GNUNET_NO;
1210 1226
1211 if (GNUNET_SYSERR == place_add (ereq)) 1227 if (GNUNET_SYSERR == place_add (ereq))
@@ -1213,7 +1229,8 @@ app_place_add (const char *app_id,
1213 return GNUNET_SYSERR; 1229 return GNUNET_SYSERR;
1214 } 1230 }
1215 1231
1216 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, 1232 if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places,
1233 &ego_place_pub_hash, NULL,
1217 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) 1234 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST))
1218 { 1235 {
1219 GNUNET_break (0); 1236 GNUNET_break (0);
@@ -1243,19 +1260,20 @@ app_place_save (const char *app_id,
1243 if (NULL == dir_places) 1260 if (NULL == dir_places)
1244 return GNUNET_SYSERR; 1261 return GNUNET_SYSERR;
1245 1262
1246 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&ereq->ego_pub_key); 1263 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (
1247 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (&ereq->place_pub_key); 1264 &ereq->ego_pub_key);
1265 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (
1266 &ereq->place_pub_key);
1248 char *filename = NULL; 1267 char *filename = NULL;
1249 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%s", 1268 GNUNET_asprintf (&filename, "%s%c" "%s%c" "%s%c" "%s",
1250 dir_social, DIR_SEPARATOR, 1269 dir_social, DIR_SEPARATOR,
1251 "places", DIR_SEPARATOR, 1270 "places", DIR_SEPARATOR,
1252 ego_pub_str, DIR_SEPARATOR, 1271 ego_pub_str, DIR_SEPARATOR,
1253 place_pub_str); 1272 place_pub_str);
1254 int ret = GNUNET_DISK_directory_create_for_file (filename); 1273 if (GNUNET_OK !=
1255 if (GNUNET_OK != ret 1274 GNUNET_DISK_fn_write (filename, ereq, ntohs (ereq->header.size),
1256 || 0 > GNUNET_DISK_fn_write (filename, ereq, ntohs (ereq->header.size), 1275 GNUNET_DISK_PERM_USER_READ
1257 GNUNET_DISK_PERM_USER_READ 1276 | GNUNET_DISK_PERM_USER_WRITE))
1258 | GNUNET_DISK_PERM_USER_WRITE))
1259 { 1277 {
1260 GNUNET_break (0); 1278 GNUNET_break (0);
1261 ret = GNUNET_SYSERR; 1279 ret = GNUNET_SYSERR;
@@ -1271,10 +1289,10 @@ app_place_save (const char *app_id,
1271 ego_pub_str, DIR_SEPARATOR, 1289 ego_pub_str, DIR_SEPARATOR,
1272 place_pub_str); 1290 place_pub_str);
1273 ret = GNUNET_DISK_directory_create_for_file (filename); 1291 ret = GNUNET_DISK_directory_create_for_file (filename);
1274 if (GNUNET_OK != ret 1292 if ((GNUNET_OK != ret)
1275 || 0 > GNUNET_DISK_fn_write (filename, "", 0, 1293 || (0 > GNUNET_DISK_fn_write (filename, "", 0,
1276 GNUNET_DISK_PERM_USER_READ 1294 GNUNET_DISK_PERM_USER_READ
1277 | GNUNET_DISK_PERM_USER_WRITE)) 1295 | GNUNET_DISK_PERM_USER_WRITE)))
1278 { 1296 {
1279 GNUNET_break (0); 1297 GNUNET_break (0);
1280 ret = GNUNET_SYSERR; 1298 ret = GNUNET_SYSERR;
@@ -1298,7 +1316,8 @@ app_place_remove (const char *app_id,
1298 GNUNET_CRYPTO_hash (place_pub_key, sizeof (*place_pub_key), &place_pub_hash); 1316 GNUNET_CRYPTO_hash (place_pub_key, sizeof (*place_pub_key), &place_pub_hash);
1299 1317
1300 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key); 1318 char *ego_pub_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key);
1301 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (place_pub_key); 1319 char *place_pub_str = GNUNET_CRYPTO_eddsa_public_key_to_string (
1320 place_pub_key);
1302 char *app_place_filename = NULL; 1321 char *app_place_filename = NULL;
1303 GNUNET_asprintf (&app_place_filename, 1322 GNUNET_asprintf (&app_place_filename,
1304 "%s%c" "%s%c" "%s%c" "%s%c" "%s", 1323 "%s%c" "%s%c" "%s%c" "%s%c" "%s",
@@ -1406,7 +1425,7 @@ msg_proc_parse (const struct MsgProcRequest *mpreq,
1406 method_size, 1425 method_size,
1407 1, 1426 1,
1408 method_prefix); 1427 method_prefix);
1409 if (0 == offset || offset != method_size || *method_prefix == NULL) 1428 if ((0 == offset) || (offset != method_size) || (*method_prefix == NULL))
1410 { 1429 {
1411 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1430 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1412 "MsgProcRequest contains invalid method\n"); 1431 "MsgProcRequest contains invalid method\n");
@@ -1425,44 +1444,44 @@ app_notify_place (const struct GNUNET_MessageHeader *msg,
1425 struct AppPlaceMessage *amsg; 1444 struct AppPlaceMessage *amsg;
1426 struct GNUNET_MQ_Envelope *env; 1445 struct GNUNET_MQ_Envelope *env;
1427 uint16_t msg_size = ntohs (msg->size); 1446 uint16_t msg_size = ntohs (msg->size);
1428 1447
1429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1448 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1430 "%p Sending place notification of type %u to client.\n", 1449 "%p Sending place notification of type %u to client.\n",
1431 client, ntohs (msg->type)); 1450 client, ntohs (msg->type));
1432 switch (ntohs (msg->type)) 1451 switch (ntohs (msg->type))
1433 { 1452 {
1434 case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: 1453 case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER:
1435 { 1454 {
1436 struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; 1455 struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg;
1437 if (msg_size < sizeof (struct HostEnterRequest)) 1456 if (msg_size < sizeof (struct HostEnterRequest))
1438 return; 1457 return;
1439 env = GNUNET_MQ_msg (amsg, 1458 env = GNUNET_MQ_msg (amsg,
1440 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); 1459 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE);
1441 // FIXME: also notify about not entered places 1460 // FIXME: also notify about not entered places
1442 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; 1461 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED;
1443 amsg->is_host = GNUNET_YES; 1462 amsg->is_host = GNUNET_YES;
1444 amsg->ego_pub_key = hreq->ego_pub_key; 1463 amsg->ego_pub_key = hreq->ego_pub_key;
1445 amsg->place_pub_key = hreq->place_pub_key; 1464 amsg->place_pub_key = hreq->place_pub_key;
1446 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 1465 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1447 env); 1466 env);
1448 break; 1467 break;
1449 } 1468 }
1450 case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: 1469 case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER:
1451 { 1470 {
1452 if (msg_size < sizeof (struct GuestEnterRequest)) 1471 if (msg_size < sizeof (struct GuestEnterRequest))
1453 return; 1472 return;
1454 struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; 1473 struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg;
1455 env = GNUNET_MQ_msg (amsg, 1474 env = GNUNET_MQ_msg (amsg,
1456 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); 1475 GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE);
1457 // FIXME: also notify about not entered places 1476 // FIXME: also notify about not entered places
1458 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; 1477 amsg->place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED;
1459 amsg->is_host = GNUNET_NO; 1478 amsg->is_host = GNUNET_NO;
1460 amsg->ego_pub_key = greq->ego_pub_key; 1479 amsg->ego_pub_key = greq->ego_pub_key;
1461 amsg->place_pub_key = greq->place_pub_key; 1480 amsg->place_pub_key = greq->place_pub_key;
1462 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 1481 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1463 env); 1482 env);
1464 break; 1483 break;
1465 } 1484 }
1466 default: 1485 default:
1467 return; 1486 return;
1468 } 1487 }
@@ -1518,7 +1537,8 @@ app_notify_ego_end (struct GNUNET_SERVICE_Client *client)
1518 1537
1519 1538
1520int 1539int
1521app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) 1540app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key,
1541 void *value)
1522{ 1542{
1523 struct GNUNET_MessageHeader * 1543 struct GNUNET_MessageHeader *
1524 msg = GNUNET_CONTAINER_multihashmap_get (places, key); 1544 msg = GNUNET_CONTAINER_multihashmap_get (places, key);
@@ -1656,7 +1676,7 @@ handle_client_host_enter (void *cls,
1656 const char *app_id = NULL; 1676 const char *app_id = NULL;
1657 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], 1677 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1],
1658 app_id_size, 1, &app_id); 1678 app_id_size, 1, &app_id);
1659 if (0 == offset || offset != app_id_size || app_id == NULL) 1679 if ((0 == offset) || (offset != app_id_size) || (app_id == NULL))
1660 { 1680 {
1661 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1681 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1662 "offset = %u, app_id_size = %u, app_id = %s\n", 1682 "offset = %u, app_id_size = %u, app_id = %s\n",
@@ -1673,7 +1693,8 @@ handle_client_host_enter (void *cls,
1673 struct GNUNET_CRYPTO_EddsaPublicKey empty_pub_key; 1693 struct GNUNET_CRYPTO_EddsaPublicKey empty_pub_key;
1674 memset (&empty_pub_key, 0, sizeof (empty_pub_key)); 1694 memset (&empty_pub_key, 0, sizeof (empty_pub_key));
1675 1695
1676 if (0 == memcmp (&hreq->place_pub_key, &empty_pub_key, sizeof (empty_pub_key))) 1696 if (0 == memcmp (&hreq->place_pub_key, &empty_pub_key,
1697 sizeof (empty_pub_key)))
1677 { // no public key set: create new private key & save the place 1698 { // no public key set: create new private key & save the place
1678 struct GNUNET_CRYPTO_EddsaPrivateKey * 1699 struct GNUNET_CRYPTO_EddsaPrivateKey *
1679 place_key = GNUNET_CRYPTO_eddsa_key_create (); 1700 place_key = GNUNET_CRYPTO_eddsa_key_create ();
@@ -1693,12 +1714,12 @@ handle_client_host_enter (void *cls,
1693 break; 1714 break;
1694 1715
1695 case GNUNET_NO: 1716 case GNUNET_NO:
1696 { 1717 {
1697 plc = c->place = &hst->place; 1718 plc = c->place = &hst->place;
1698 plc->host = hst; 1719 plc->host = hst;
1699 client_send_host_enter_ack (client, hst, GNUNET_OK); 1720 client_send_host_enter_ack (client, hst, GNUNET_OK);
1700 break; 1721 break;
1701 } 1722 }
1702 case GNUNET_SYSERR: 1723 case GNUNET_SYSERR:
1703 ret = GNUNET_SYSERR; 1724 ret = GNUNET_SYSERR;
1704 } 1725 }
@@ -1779,7 +1800,8 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1779 gst = GNUNET_new (struct Guest); 1800 gst = GNUNET_new (struct Guest);
1780 new_guest = GNUNET_YES; 1801 new_guest = GNUNET_YES;
1781 } 1802 }
1782 else new_guest = GNUNET_NO; 1803 else
1804 new_guest = GNUNET_NO;
1783 1805
1784 if (NULL == gst->slave) 1806 if (NULL == gst->slave)
1785 { 1807 {
@@ -1853,15 +1875,17 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst)
1853 if (NULL == plc_gst) 1875 if (NULL == plc_gst)
1854 { 1876 {
1855 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); 1877 plc_gst = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES);
1856 (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, 1878 (void) GNUNET_CONTAINER_multihashmap_put (place_guests,
1879 &plc->pub_key_hash, plc_gst,
1857 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1880 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1858 } 1881 }
1859 if (GNUNET_YES == new_guest) 1882 if (GNUNET_YES == new_guest)
1860 { 1883 {
1861 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, 1884 (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash,
1885 gst,
1862 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1886 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1863 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, 1887 (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst,
1864 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1888 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
1865 1889
1866 } 1890 }
1867 gst->slave 1891 gst->slave
@@ -1909,41 +1933,41 @@ client_guest_enter (struct Client *c,
1909 switch (guest_enter (greq, &gst)) 1933 switch (guest_enter (greq, &gst))
1910 { 1934 {
1911 case GNUNET_YES: 1935 case GNUNET_YES:
1912 { 1936 {
1913 plc = c->place = &gst->place; 1937 plc = c->place = &gst->place;
1914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1938 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1915 "guest entered successfully to local place %s\n", 1939 "guest entered successfully to local place %s\n",
1916 GNUNET_h2s (&plc->pub_key_hash)); 1940 GNUNET_h2s (&plc->pub_key_hash));
1917 plc->guest = gst; 1941 plc->guest = gst;
1918 app_place_save (app_id, (const struct PlaceEnterRequest *) greq); 1942 app_place_save (app_id, (const struct PlaceEnterRequest *) greq);
1919 app_notify_place (&greq->header, client); 1943 app_notify_place (&greq->header, client);
1920 break; 1944 break;
1921 } 1945 }
1922 case GNUNET_NO: 1946 case GNUNET_NO:
1923 { 1947 {
1924 plc = c->place = &gst->place; 1948 plc = c->place = &gst->place;
1925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1949 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1926 "guest re-entered successfully to local place %s\n", 1950 "guest re-entered successfully to local place %s\n",
1927 GNUNET_h2s (&plc->pub_key_hash)); 1951 GNUNET_h2s (&plc->pub_key_hash));
1928 plc->guest = gst; 1952 plc->guest = gst;
1929 env = GNUNET_MQ_msg (result_msg, 1953 env = GNUNET_MQ_msg (result_msg,
1930 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); 1954 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK);
1931 result_msg->result_code = htonl (GNUNET_OK); 1955 result_msg->result_code = htonl (GNUNET_OK);
1932 result_msg->max_message_id = GNUNET_htonll (plc->max_message_id); 1956 result_msg->max_message_id = GNUNET_htonll (plc->max_message_id);
1933 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1934 env);
1935 if (NULL != gst->join_dcsn)
1936 {
1937 env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header);
1938 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 1957 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1939 env); 1958 env);
1959 if (NULL != gst->join_dcsn)
1960 {
1961 env = GNUNET_MQ_msg_copy (&gst->join_dcsn->header);
1962 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client),
1963 env);
1964 }
1965 break;
1940 } 1966 }
1941 break;
1942 }
1943 case GNUNET_SYSERR: 1967 case GNUNET_SYSERR:
1944 { 1968 {
1945 return GNUNET_SYSERR; 1969 return GNUNET_SYSERR;
1946 } 1970 }
1947 } 1971 }
1948 1972
1949 struct ClientListItem *cli = GNUNET_new (struct ClientListItem); 1973 struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
@@ -2008,7 +2032,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
2008 const struct GNUNET_GNSRECORD_PlaceData * 2032 const struct GNUNET_GNSRECORD_PlaceData *
2009 rec = (const struct GNUNET_GNSRECORD_PlaceData *) rd->data; 2033 rec = (const struct GNUNET_GNSRECORD_PlaceData *) rd->data;
2010 2034
2011 if (0 == rd_count || rd->data_size < sizeof (*rec)) 2035 if ((0 == rd_count) || (rd->data_size < sizeof (*rec)))
2012 { 2036 {
2013 GNUNET_break (0); 2037 GNUNET_break (0);
2014 GNUNET_SERVICE_client_drop (c->client); 2038 GNUNET_SERVICE_client_drop (c->client);
@@ -2020,7 +2044,8 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
2020 2044
2021 if (0 < relay_count) 2045 if (0 < relay_count)
2022 { 2046 {
2023 if (rd->data_size == sizeof (*rec) + relay_count * sizeof (struct GNUNET_PeerIdentity)) 2047 if (rd->data_size == sizeof (*rec) + relay_count * sizeof (struct
2048 GNUNET_PeerIdentity))
2024 { 2049 {
2025 relays = (struct GNUNET_PeerIdentity *) &rec[1]; 2050 relays = (struct GNUNET_PeerIdentity *) &rec[1];
2026 } 2051 }
@@ -2037,7 +2062,7 @@ gns_result_guest_enter (void *cls, uint32_t rd_count,
2037 if (NULL != gcls->join_msg) 2062 if (NULL != gcls->join_msg)
2038 join_msg_size = ntohs (gcls->join_msg->size); 2063 join_msg_size = ntohs (gcls->join_msg->size);
2039 uint16_t greq_size = sizeof (struct GuestEnterRequest) 2064 uint16_t greq_size = sizeof (struct GuestEnterRequest)
2040 + app_id_size + relay_size + join_msg_size; 2065 + app_id_size + relay_size + join_msg_size;
2041 struct GuestEnterRequest *greq = GNUNET_malloc (greq_size); 2066 struct GuestEnterRequest *greq = GNUNET_malloc (greq_size);
2042 greq->header.size = htons (greq_size); 2067 greq->header.size = htons (greq_size);
2043 greq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER); 2068 greq->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER);
@@ -2099,13 +2124,13 @@ handle_client_guest_enter_by_name (void *cls,
2099 p += offset; 2124 p += offset;
2100 remaining -= offset; 2125 remaining -= offset;
2101 2126
2102 if (0 != offset && sizeof (*gcls->join_msg) <= remaining) 2127 if ((0 != offset) && (sizeof (*gcls->join_msg) <= remaining))
2103 { 2128 {
2104 gcls->join_msg = GNUNET_copy_message ((struct GNUNET_MessageHeader *) p); 2129 gcls->join_msg = GNUNET_copy_message ((struct GNUNET_MessageHeader *) p);
2105 remaining -= ntohs (gcls->join_msg->size); 2130 remaining -= ntohs (gcls->join_msg->size);
2106 } 2131 }
2107 2132
2108 if (0 == offset || 0 != remaining) 2133 if ((0 == offset) || (0 != remaining))
2109 { 2134 {
2110 if (NULL != gcls->join_msg) 2135 if (NULL != gcls->join_msg)
2111 GNUNET_free (gcls->join_msg); 2136 GNUNET_free (gcls->join_msg);
@@ -2155,7 +2180,7 @@ handle_client_app_connect (void *cls,
2155 ssize_t app_id_size = ntohs (creq->header.size) - sizeof (*creq); 2180 ssize_t app_id_size = ntohs (creq->header.size) - sizeof (*creq);
2156 const char *app_id = NULL; 2181 const char *app_id = NULL;
2157 uint16_t offset; 2182 uint16_t offset;
2158 2183
2159 if (app_id_size < 0) 2184 if (app_id_size < 0)
2160 { 2185 {
2161 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2186 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -2167,12 +2192,12 @@ handle_client_app_connect (void *cls,
2167 2192
2168 offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1], 2193 offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &creq[1],
2169 (size_t) app_id_size, 2194 (size_t) app_id_size,
2170 1, 2195 1,
2171 &app_id); 2196 &app_id);
2172 if (0 == offset || offset != app_id_size) 2197 if ((0 == offset) || (offset != app_id_size))
2173 { 2198 {
2174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2199 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2175 "AppConnectRequest contains invalid app ID\n"); 2200 "AppConnectRequest contains invalid app ID\n");
2176 GNUNET_break (0); 2201 GNUNET_break (0);
2177 GNUNET_SERVICE_client_drop (client); 2202 GNUNET_SERVICE_client_drop (client);
2178 return; 2203 return;
@@ -2187,14 +2212,16 @@ handle_client_app_connect (void *cls,
2187 struct GNUNET_CONTAINER_MultiHashMap * 2212 struct GNUNET_CONTAINER_MultiHashMap *
2188 app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash); 2213 app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash);
2189 if (NULL != app_places) 2214 if (NULL != app_places)
2190 GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify, client); 2215 GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify,
2216 client);
2191 app_notify_place_end (client); 2217 app_notify_place_end (client);
2192 2218
2193 struct ClientListItem *cli = GNUNET_new (struct ClientListItem); 2219 struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
2194 cli->client = client; 2220 cli->client = client;
2195 struct Application *app = GNUNET_CONTAINER_multihashmap_get (apps, 2221 struct Application *app = GNUNET_CONTAINER_multihashmap_get (apps,
2196 &app_id_hash); 2222 &app_id_hash);
2197 if (NULL == app) { 2223 if (NULL == app)
2224 {
2198 app = GNUNET_malloc (sizeof (*app)); 2225 app = GNUNET_malloc (sizeof (*app));
2199 (void) GNUNET_CONTAINER_multihashmap_put (apps, &app_id_hash, app, 2226 (void) GNUNET_CONTAINER_multihashmap_put (apps, &app_id_hash, app,
2200 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 2227 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
@@ -2221,7 +2248,8 @@ handle_client_app_detach (void *cls,
2221 struct Client *c = cls; 2248 struct Client *c = cls;
2222 struct GNUNET_SERVICE_Client *client = c->client; 2249 struct GNUNET_SERVICE_Client *client = c->client;
2223 2250
2224 int ret = app_place_remove (c->app_id, &req->ego_pub_key, &req->place_pub_key); 2251 int ret = app_place_remove (c->app_id, &req->ego_pub_key,
2252 &req->place_pub_key);
2225 client_send_result (client, req->op_id, ret, NULL, 0); 2253 client_send_result (client, req->op_id, ret, NULL, 0);
2226 2254
2227 GNUNET_SERVICE_client_continue (client); 2255 GNUNET_SERVICE_client_continue (client);
@@ -2254,7 +2282,7 @@ handle_client_place_leave (void *cls,
2254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2255 "got leave request from %s for place %s", 2283 "got leave request from %s for place %s",
2256 plc->is_host? "host" : "slave", 2284 plc->is_host? "host" : "slave",
2257 GNUNET_h2s (&plc->pub_key_hash)); 2285 GNUNET_h2s (&plc->pub_key_hash));
2258 if (NULL == plc) 2286 if (NULL == plc)
2259 { 2287 {
2260 GNUNET_break (0); 2288 GNUNET_break (0);
@@ -2327,7 +2355,7 @@ handle_client_join_decision (void *cls,
2327 struct Client *c = cls; 2355 struct Client *c = cls;
2328 struct GNUNET_SERVICE_Client *client = c->client; 2356 struct GNUNET_SERVICE_Client *client = c->client;
2329 struct Place *plc = c->place; 2357 struct Place *plc = c->place;
2330 if (NULL == plc || GNUNET_YES != plc->is_host) 2358 if ((NULL == plc) || (GNUNET_YES != plc->is_host))
2331 { 2359 {
2332 GNUNET_break (0); 2360 GNUNET_break (0);
2333 GNUNET_SERVICE_client_drop (client); 2361 GNUNET_SERVICE_client_drop (client);
@@ -2410,7 +2438,8 @@ psyc_transmit_queue_next_part (struct Place *plc,
2410 { 2438 {
2411 if (NULL != tmit_frag->client) 2439 if (NULL != tmit_frag->client)
2412 send_message_ack (plc, tmit_frag->client); 2440 send_message_ack (plc, tmit_frag->client);
2413 GNUNET_CONTAINER_DLL_remove (tmit_msg->frags_head, tmit_msg->frags_tail, tmit_frag); 2441 GNUNET_CONTAINER_DLL_remove (tmit_msg->frags_head, tmit_msg->frags_tail,
2442 tmit_frag);
2414 GNUNET_free (tmit_frag); 2443 GNUNET_free (tmit_frag);
2415 tmit_frag = NULL; 2444 tmit_frag = NULL;
2416 } 2445 }
@@ -2432,7 +2461,8 @@ static struct MessageTransmitQueue *
2432psyc_transmit_queue_next_msg (struct Place *plc, 2461psyc_transmit_queue_next_msg (struct Place *plc,
2433 struct MessageTransmitQueue *tmit_msg) 2462 struct MessageTransmitQueue *tmit_msg)
2434{ 2463{
2435 GNUNET_CONTAINER_DLL_remove (plc->tmit_msgs_head, plc->tmit_msgs_tail, tmit_msg); 2464 GNUNET_CONTAINER_DLL_remove (plc->tmit_msgs_head, plc->tmit_msgs_tail,
2465 tmit_msg);
2436 GNUNET_free (tmit_msg); 2466 GNUNET_free (tmit_msg);
2437 return plc->tmit_msgs_head; 2467 return plc->tmit_msgs_head;
2438} 2468}
@@ -2476,7 +2506,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2476 if (*data_size < pdata_size) 2506 if (*data_size < pdata_size)
2477 { 2507 {
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2479 "%p psyc_transmit_notify_data: buffer size too small for data.\n", plc); 2509 "%p psyc_transmit_notify_data: buffer size too small for data.\n",
2510 plc);
2480 *data_size = 0; 2511 *data_size = 0;
2481 return GNUNET_NO; 2512 return GNUNET_NO;
2482 } 2513 }
@@ -2506,7 +2537,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2506 ret = GNUNET_SYSERR; 2537 ret = GNUNET_SYSERR;
2507 } 2538 }
2508 2539
2509 if (GNUNET_SYSERR == ret && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL != ptype) 2540 if ((GNUNET_SYSERR == ret) && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL !=
2541 ptype) )
2510 { 2542 {
2511 *data_size = 0; 2543 *data_size = 0;
2512 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2544 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
@@ -2538,8 +2570,8 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
2538 } 2570 }
2539 } 2571 }
2540 2572
2541 if (NULL == tmit_msg->frags_head 2573 if ((NULL == tmit_msg->frags_head)
2542 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) 2574 && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype))
2543 { /* Reached end of current message. */ 2575 { /* Reached end of current message. */
2544 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2576 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2545 } 2577 }
@@ -2592,59 +2624,62 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
2592 switch (ptype) 2624 switch (ptype)
2593 { 2625 {
2594 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER: 2626 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER:
2595 {
2596 if (NULL == oper)
2597 { 2627 {
2598 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 2628 if (NULL == oper)
2599 "%p psyc_transmit_notify_mod: oper is NULL.\n", plc); 2629 {
2600 ret = GNUNET_SYSERR; 2630 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2631 "%p psyc_transmit_notify_mod: oper is NULL.\n", plc);
2632 ret = GNUNET_SYSERR;
2633 break;
2634 }
2635 struct GNUNET_PSYC_MessageModifier *
2636 pmod = (struct GNUNET_PSYC_MessageModifier *) tmit_frag->next_part;
2637 uint16_t mod_size = ntohs (pmod->header.size) - sizeof (*pmod);
2638
2639 if (*data_size < mod_size)
2640 {
2641 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2642 "%p psyc_transmit_notify_mod: buffer size too small for data.\n",
2643 plc);
2644 *data_size = 0;
2645 return GNUNET_NO;
2646 }
2647
2648 *full_value_size = ntohl (pmod->value_size);
2649 *oper = pmod->oper;
2650 *data_size = mod_size;
2651 GNUNET_memcpy (data, &pmod[1], mod_size);
2652 ret = GNUNET_NO;
2601 break; 2653 break;
2602 } 2654 }
2603 struct GNUNET_PSYC_MessageModifier *
2604 pmod = (struct GNUNET_PSYC_MessageModifier *) tmit_frag->next_part;
2605 uint16_t mod_size = ntohs (pmod->header.size) - sizeof (*pmod);
2606 2655
2607 if (*data_size < mod_size) 2656 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT:
2608 { 2657 {
2658 if (NULL != oper)
2659 {
2660 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2661 "%p psyc_transmit_notify_mod: oper is not NULL.\n", plc);
2662 ret = GNUNET_SYSERR;
2663 break;
2664 }
2665 uint16_t mod_size = ntohs (pmsg->size) - sizeof (*pmsg);
2666 if (*data_size < mod_size)
2667 {
2668 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2669 "%p psyc_transmit_notify_mod: buffer size too small for data.\n",
2670 plc);
2671 *data_size = 0;
2672 return GNUNET_NO;
2673 }
2609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2674 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2610 "%p psyc_transmit_notify_mod: buffer size too small for data.\n", plc); 2675 "%p psyc_transmit_notify_mod: sending %u bytes.\n", plc,
2611 *data_size = 0; 2676 mod_size);
2612 return GNUNET_NO;
2613 }
2614
2615 *full_value_size = ntohl (pmod->value_size);
2616 *oper = pmod->oper;
2617 *data_size = mod_size;
2618 GNUNET_memcpy (data, &pmod[1], mod_size);
2619 ret = GNUNET_NO;
2620 break;
2621 }
2622 2677
2623 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT: 2678 *data_size = mod_size;
2624 { 2679 GNUNET_memcpy (data, &pmsg[1], *data_size);
2625 if (NULL != oper) 2680 ret = GNUNET_NO;
2626 {
2627 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
2628 "%p psyc_transmit_notify_mod: oper is not NULL.\n", plc);
2629 ret = GNUNET_SYSERR;
2630 break; 2681 break;
2631 } 2682 }
2632 uint16_t mod_size = ntohs (pmsg->size) - sizeof (*pmsg);
2633 if (*data_size < mod_size)
2634 {
2635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2636 "%p psyc_transmit_notify_mod: buffer size too small for data.\n", plc);
2637 *data_size = 0;
2638 return GNUNET_NO;
2639 }
2640 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2641 "%p psyc_transmit_notify_mod: sending %u bytes.\n", plc, mod_size);
2642
2643 *data_size = mod_size;
2644 GNUNET_memcpy (data, &pmsg[1], *data_size);
2645 ret = GNUNET_NO;
2646 break;
2647 }
2648 2683
2649 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA: 2684 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA:
2650 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: 2685 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
@@ -2673,8 +2708,8 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
2673 if (GNUNET_YES != ret) 2708 if (GNUNET_YES != ret)
2674 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag); 2709 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
2675 2710
2676 if (NULL == tmit_msg->frags_head 2711 if ((NULL == tmit_msg->frags_head)
2677 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) 2712 && (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype))
2678 { /* Reached end of current message. */ 2713 { /* Reached end of current message. */
2679 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 2714 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
2680 } 2715 }
@@ -2682,6 +2717,7 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
2682 return ret; 2717 return ret;
2683} 2718}
2684 2719
2720
2685/** 2721/**
2686 * Callback for data transmission from a host to PSYC. 2722 * Callback for data transmission from a host to PSYC.
2687 */ 2723 */
@@ -2777,8 +2813,8 @@ psyc_transmit_queue_next_method (struct Place *plc)
2777 } 2813 }
2778 2814
2779 struct GNUNET_MessageHeader *pmsg = tmit_frag->next_part; 2815 struct GNUNET_MessageHeader *pmsg = tmit_frag->next_part;
2780 if (NULL == pmsg 2816 if ((NULL == pmsg)
2781 || GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD != ntohs (pmsg->type)) 2817 || (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD != ntohs (pmsg->type)))
2782 { 2818 {
2783 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2819 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2784 "%p psyc_transmit_queue_next_method: unexpected message part of type %u.\n", 2820 "%p psyc_transmit_queue_next_method: unexpected message part of type %u.\n",
@@ -2791,7 +2827,7 @@ psyc_transmit_queue_next_method (struct Place *plc)
2791 struct GNUNET_PSYC_MessageMethod * 2827 struct GNUNET_PSYC_MessageMethod *
2792 pmeth = (struct GNUNET_PSYC_MessageMethod *) GNUNET_copy_message (pmsg); 2828 pmeth = (struct GNUNET_PSYC_MessageMethod *) GNUNET_copy_message (pmsg);
2793 2829
2794 if (psize < sizeof (*pmeth) + 1 || '\0' != *((char *) pmeth + psize - 1)) 2830 if ((psize < sizeof (*pmeth) + 1) || ('\0' != *((char *) pmeth + psize - 1)))
2795 { 2831 {
2796 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2832 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2797 "%p psyc_transmit_queue_next_method: invalid method name.\n", 2833 "%p psyc_transmit_queue_next_method: invalid method name.\n",
@@ -2826,9 +2862,11 @@ psyc_master_transmit_message (struct Host *hst)
2826 2862
2827 hst->tmit_handle = (void *) &hst->tmit_handle; 2863 hst->tmit_handle = (void *) &hst->tmit_handle;
2828 struct GNUNET_PSYC_MasterTransmitHandle * 2864 struct GNUNET_PSYC_MasterTransmitHandle *
2829 tmit_handle = GNUNET_PSYC_master_transmit (hst->master, (const char *) &pmeth[1], 2865 tmit_handle = GNUNET_PSYC_master_transmit (hst->master, (const
2866 char *) &pmeth[1],
2830 &host_transmit_notify_mod, 2867 &host_transmit_notify_mod,
2831 &host_transmit_notify_data, hst, 2868 &host_transmit_notify_data,
2869 hst,
2832 pmeth->flags); 2870 pmeth->flags);
2833 if (NULL != hst->tmit_handle) 2871 if (NULL != hst->tmit_handle)
2834 hst->tmit_handle = tmit_handle; 2872 hst->tmit_handle = tmit_handle;
@@ -2859,10 +2897,12 @@ psyc_slave_transmit_message (struct Guest *gst)
2859 2897
2860 gst->tmit_handle = (void *) &gst->tmit_handle; 2898 gst->tmit_handle = (void *) &gst->tmit_handle;
2861 struct GNUNET_PSYC_SlaveTransmitHandle * 2899 struct GNUNET_PSYC_SlaveTransmitHandle *
2862 tmit_handle = GNUNET_PSYC_slave_transmit (gst->slave, (const char *) &pmeth[1], 2900 tmit_handle = GNUNET_PSYC_slave_transmit (gst->slave, (const
2863 &guest_transmit_notify_mod, 2901 char *) &pmeth[1],
2864 &guest_transmit_notify_data, gst, 2902 &guest_transmit_notify_mod,
2865 pmeth->flags); 2903 &guest_transmit_notify_data,
2904 gst,
2905 pmeth->flags);
2866 if (NULL != gst->tmit_handle) 2906 if (NULL != gst->tmit_handle)
2867 gst->tmit_handle = tmit_handle; 2907 gst->tmit_handle = tmit_handle;
2868 GNUNET_free (pmeth); 2908 GNUNET_free (pmeth);
@@ -2909,7 +2949,8 @@ psyc_transmit_queue_message (struct Place *plc,
2909 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == first_ptype) 2949 if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == first_ptype)
2910 { 2950 {
2911 tmit_msg = GNUNET_malloc (sizeof (*tmit_msg)); 2951 tmit_msg = GNUNET_malloc (sizeof (*tmit_msg));
2912 GNUNET_CONTAINER_DLL_insert_tail (plc->tmit_msgs_head, plc->tmit_msgs_tail, tmit_msg); 2952 GNUNET_CONTAINER_DLL_insert_tail (plc->tmit_msgs_head, plc->tmit_msgs_tail,
2953 tmit_msg);
2913 } 2954 }
2914 else if (NULL == tmit_msg) 2955 else if (NULL == tmit_msg)
2915 { 2956 {
@@ -2923,7 +2964,8 @@ psyc_transmit_queue_message (struct Place *plc,
2923 tmit_frag->client = client; 2964 tmit_frag->client = client;
2924 tmit_frag->size = data_size; 2965 tmit_frag->size = data_size;
2925 2966
2926 GNUNET_CONTAINER_DLL_insert_tail (tmit_msg->frags_head, tmit_msg->frags_tail, tmit_frag); 2967 GNUNET_CONTAINER_DLL_insert_tail (tmit_msg->frags_head, tmit_msg->frags_tail,
2968 tmit_frag);
2927 tmit_msg->client = client; 2969 tmit_msg->client = client;
2928 return tmit_msg; 2970 return tmit_msg;
2929} 2971}
@@ -2935,9 +2977,9 @@ psyc_transmit_queue_message (struct Place *plc,
2935// * @param plc Place to send to. 2977// * @param plc Place to send to.
2936// * @param client Client the message originates from. 2978// * @param client Client the message originates from.
2937// */ 2979// */
2938//static void 2980// static void
2939//psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client) 2981// psyc_transmit_cancel (struct Place *plc, struct GNUNET_SERVICE_Client *client)
2940//{ 2982// {
2941// uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL; 2983// uint16_t type = GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL;
2942// 2984//
2943// struct GNUNET_MessageHeader msg; 2985// struct GNUNET_MessageHeader msg;
@@ -2948,7 +2990,7 @@ psyc_transmit_queue_message (struct Place *plc,
2948// psyc_transmit_message (plc); 2990// psyc_transmit_message (plc);
2949// 2991//
2950// /* FIXME: cleanup */ 2992// /* FIXME: cleanup */
2951//} 2993// }
2952 2994
2953 2995
2954static int 2996static int
@@ -2981,7 +3023,8 @@ handle_client_psyc_message (void *cls,
2981 return; 3023 return;
2982 } 3024 }
2983 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3025 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2984 "%p Received message of type %d from client.\n", plc, ntohs (msg->type)); 3026 "%p Received message of type %d from client.\n", plc, ntohs (
3027 msg->type));
2985 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg); 3028 GNUNET_PSYC_log_message (GNUNET_ERROR_TYPE_DEBUG, msg);
2986 3029
2987 if (GNUNET_YES != plc->is_ready) 3030 if (GNUNET_YES != plc->is_ready)
@@ -2995,8 +3038,8 @@ handle_client_psyc_message (void *cls,
2995 3038
2996 uint16_t size = ntohs (msg->size); 3039 uint16_t size = ntohs (msg->size);
2997 uint16_t psize = size - sizeof (*msg); 3040 uint16_t psize = size - sizeof (*msg);
2998 if (psize < sizeof (struct GNUNET_MessageHeader) 3041 if ((psize < sizeof (struct GNUNET_MessageHeader))
2999 || GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < psize) 3042 || (GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD < psize))
3000 { 3043 {
3001 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3044 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3002 "%p Received message with invalid payload size (%u) from client.\n", 3045 "%p Received message with invalid payload size (%u) from client.\n",
@@ -3051,7 +3094,8 @@ handle_client_psyc_message (void *cls,
3051 * A historic message arrived from PSYC. 3094 * A historic message arrived from PSYC.
3052 */ 3095 */
3053static void 3096static void
3054psyc_recv_history_message (void *cls, const struct GNUNET_PSYC_MessageHeader *msg) 3097psyc_recv_history_message (void *cls, const struct
3098 GNUNET_PSYC_MessageHeader *msg)
3055{ 3099{
3056 struct OperationClosure *opcls = cls; 3100 struct OperationClosure *opcls = cls;
3057 struct Client *c = opcls->client; 3101 struct Client *c = opcls->client;
@@ -3103,7 +3147,8 @@ psyc_recv_history_result (void *cls, int64_t result,
3103 3147
3104static int 3148static int
3105check_client_history_replay (void *cls, 3149check_client_history_replay (void *cls,
3106 const struct GNUNET_PSYC_HistoryRequestMessage *req) 3150 const struct
3151 GNUNET_PSYC_HistoryRequestMessage *req)
3107{ 3152{
3108 return GNUNET_OK; 3153 return GNUNET_OK;
3109} 3154}
@@ -3114,7 +3159,8 @@ check_client_history_replay (void *cls,
3114 */ 3159 */
3115static void 3160static void
3116handle_client_history_replay (void *cls, 3161handle_client_history_replay (void *cls,
3117 const struct GNUNET_PSYC_HistoryRequestMessage *req) 3162 const struct
3163 GNUNET_PSYC_HistoryRequestMessage *req)
3118{ 3164{
3119 struct Client *c = cls; 3165 struct Client *c = cls;
3120 struct GNUNET_SERVICE_Client *client = c->client; 3166 struct GNUNET_SERVICE_Client *client = c->client;
@@ -3129,8 +3175,8 @@ handle_client_history_replay (void *cls,
3129 uint16_t size = ntohs (req->header.size); 3175 uint16_t size = ntohs (req->header.size);
3130 const char *method_prefix = (const char *) &req[1]; 3176 const char *method_prefix = (const char *) &req[1];
3131 3177
3132 if (size < sizeof (*req) + 1 3178 if ((size < sizeof (*req) + 1)
3133 || '\0' != method_prefix[size - sizeof (*req) - 1]) 3179 || ('\0' != method_prefix[size - sizeof (*req) - 1]))
3134 { 3180 {
3135 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3181 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3136 "%p History replay #%" PRIu64 ": " 3182 "%p History replay #%" PRIu64 ": "
@@ -3155,7 +3201,8 @@ handle_client_history_replay (void *cls,
3155 psyc_recv_history_result, opcls); 3201 psyc_recv_history_result, opcls);
3156 else 3202 else
3157 GNUNET_PSYC_channel_history_replay_latest (plc->channel, 3203 GNUNET_PSYC_channel_history_replay_latest (plc->channel,
3158 GNUNET_ntohll (req->message_limit), 3204 GNUNET_ntohll (
3205 req->message_limit),
3159 method_prefix, opcls->flags, 3206 method_prefix, opcls->flags,
3160 psyc_recv_history_message, NULL, 3207 psyc_recv_history_message, NULL,
3161 psyc_recv_history_result, opcls); 3208 psyc_recv_history_result, opcls);
@@ -3250,8 +3297,8 @@ handle_client_state_get (void *cls,
3250 "%p State get #%" PRIu64 ": %s\n", 3297 "%p State get #%" PRIu64 ": %s\n",
3251 plc, GNUNET_ntohll (req->op_id), name); 3298 plc, GNUNET_ntohll (req->op_id), name);
3252 3299
3253 if (size < sizeof (*req) + 1 3300 if ((size < sizeof (*req) + 1)
3254 || '\0' != name[size - sizeof (*req) - 1]) 3301 || ('\0' != name[size - sizeof (*req) - 1]))
3255 { 3302 {
3256 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3303 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3257 "%p State get #%" PRIu64 ": " 3304 "%p State get #%" PRIu64 ": "
@@ -3269,19 +3316,19 @@ handle_client_state_get (void *cls,
3269 switch (ntohs (req->header.type)) 3316 switch (ntohs (req->header.type))
3270 { 3317 {
3271 case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET: 3318 case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET:
3272 GNUNET_PSYC_channel_state_get (plc->channel, name, 3319 GNUNET_PSYC_channel_state_get (plc->channel, name,
3273 psyc_recv_state_var, 3320 psyc_recv_state_var,
3274 psyc_recv_state_result, opcls); 3321 psyc_recv_state_result, opcls);
3275 break; 3322 break;
3276 3323
3277 case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX: 3324 case GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX:
3278 GNUNET_PSYC_channel_state_get_prefix (plc->channel, name, 3325 GNUNET_PSYC_channel_state_get_prefix (plc->channel, name,
3279 psyc_recv_state_var, 3326 psyc_recv_state_var,
3280 psyc_recv_state_result, opcls); 3327 psyc_recv_state_result, opcls);
3281 break; 3328 break;
3282 3329
3283 default: 3330 default:
3284 GNUNET_assert (0); 3331 GNUNET_assert (0);
3285 } 3332 }
3286 3333
3287 GNUNET_SERVICE_client_continue (client); 3334 GNUNET_SERVICE_client_continue (client);
@@ -3335,7 +3382,7 @@ handle_client_zone_add_place (void *cls,
3335 relays = (const struct GNUNET_PeerIdentity *) p; 3382 relays = (const struct GNUNET_PeerIdentity *) p;
3336 uint16_t relay_size = ntohl (preq->relay_count) * sizeof (*relays); 3383 uint16_t relay_size = ntohl (preq->relay_count) * sizeof (*relays);
3337 3384
3338 if (0 == offset || remaining != relay_size) 3385 if ((0 == offset) || (remaining != relay_size))
3339 { 3386 {
3340 GNUNET_break (0); 3387 GNUNET_break (0);
3341 client_send_result (client, preq->op_id, GNUNET_SYSERR, NULL, 0); 3388 client_send_result (client, preq->op_id, GNUNET_SYSERR, NULL, 0);
@@ -3359,7 +3406,8 @@ handle_client_zone_add_place (void *cls,
3359 rd.data_size = sizeof (*rec) + relay_size; 3406 rd.data_size = sizeof (*rec) + relay_size;
3360 3407
3361 struct GNUNET_HashCode ego_pub_hash; 3408 struct GNUNET_HashCode ego_pub_hash;
3362 GNUNET_CRYPTO_hash (&preq->ego_pub_key, sizeof (preq->ego_pub_key), &ego_pub_hash); 3409 GNUNET_CRYPTO_hash (&preq->ego_pub_key, sizeof (preq->ego_pub_key),
3410 &ego_pub_hash);
3363 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); 3411 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash);
3364 if (NULL == ego) 3412 if (NULL == ego)
3365 { 3413 {
@@ -3401,7 +3449,7 @@ handle_client_zone_add_nym (void *cls,
3401 const char *name = NULL; 3449 const char *name = NULL;
3402 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &nreq[1], 3450 uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &nreq[1],
3403 name_size, 1, &name); 3451 name_size, 1, &name);
3404 if (0 == offset || offset != name_size) 3452 if ((0 == offset) || (offset != name_size))
3405 { 3453 {
3406 GNUNET_break (0); 3454 GNUNET_break (0);
3407 client_send_result (client, nreq->op_id, GNUNET_SYSERR, NULL, 0); 3455 client_send_result (client, nreq->op_id, GNUNET_SYSERR, NULL, 0);
@@ -3417,7 +3465,8 @@ handle_client_zone_add_nym (void *cls,
3417 rd.data_size = sizeof (nreq->nym_pub_key); 3465 rd.data_size = sizeof (nreq->nym_pub_key);
3418 3466
3419 struct GNUNET_HashCode ego_pub_hash; 3467 struct GNUNET_HashCode ego_pub_hash;
3420 GNUNET_CRYPTO_hash (&nreq->ego_pub_key, sizeof (nreq->ego_pub_key), &ego_pub_hash); 3468 GNUNET_CRYPTO_hash (&nreq->ego_pub_key, sizeof (nreq->ego_pub_key),
3469 &ego_pub_hash);
3421 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); 3470 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash);
3422 if (NULL == ego) 3471 if (NULL == ego)
3423 { 3472 {
@@ -3444,7 +3493,7 @@ path_basename (const char *path)
3444 if (NULL != basename) 3493 if (NULL != basename)
3445 basename++; 3494 basename++;
3446 3495
3447 if (NULL == basename || '\0' == *basename) 3496 if ((NULL == basename) || ('\0' == *basename))
3448 return NULL; 3497 return NULL;
3449 3498
3450 return basename; 3499 return basename;
@@ -3479,9 +3528,9 @@ file_place_load (void *cls, const char *place_filename)
3479 place_pub_str); 3528 place_pub_str);
3480 3529
3481 uint64_t file_size = 0; 3530 uint64_t file_size = 0;
3482 if (GNUNET_OK != 3531 if ((GNUNET_OK !=
3483 GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES, GNUNET_YES) 3532 GNUNET_DISK_file_size (filename, &file_size, GNUNET_YES, GNUNET_YES))
3484 || file_size < sizeof (struct PlaceEnterRequest)) 3533 || (file_size < sizeof (struct PlaceEnterRequest)))
3485 { 3534 {
3486 GNUNET_free (filename); 3535 GNUNET_free (filename);
3487 return GNUNET_OK; 3536 return GNUNET_OK;
@@ -3490,7 +3539,7 @@ file_place_load (void *cls, const char *place_filename)
3490 struct PlaceEnterRequest *ereq = GNUNET_malloc (file_size); 3539 struct PlaceEnterRequest *ereq = GNUNET_malloc (file_size);
3491 ssize_t read_size = GNUNET_DISK_fn_read (filename, ereq, file_size); 3540 ssize_t read_size = GNUNET_DISK_fn_read (filename, ereq, file_size);
3492 GNUNET_free (filename); 3541 GNUNET_free (filename);
3493 if (read_size < 0 || read_size < sizeof (*ereq)) 3542 if ((read_size < 0) || (read_size < sizeof (*ereq)))
3494 { 3543 {
3495 GNUNET_free (ereq); 3544 GNUNET_free (ereq);
3496 return GNUNET_OK; 3545 return GNUNET_OK;
@@ -3558,6 +3607,7 @@ scan_app_ego_dir (void *cls, const char *dir_ego)
3558 return GNUNET_OK; 3607 return GNUNET_OK;
3559} 3608}
3560 3609
3610
3561/** 3611/**
3562 * Read @e ego_pub_str entries in @a dir_app 3612 * Read @e ego_pub_str entries in @a dir_app
3563 * 3613 *
@@ -3599,7 +3649,7 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego,
3599 GNUNET_CRYPTO_hash (&ego_pub_key, sizeof (ego_pub_key), &ego_pub_hash); 3649 GNUNET_CRYPTO_hash (&ego_pub_key, sizeof (ego_pub_key), &ego_pub_hash);
3600 3650
3601 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); 3651 struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash);
3602 if (NULL == ego && NULL == name) 3652 if ((NULL == ego) && (NULL == name))
3603 { 3653 {
3604 // an ego that is none of our business has been deleted 3654 // an ego that is none of our business has been deleted
3605 return; 3655 return;
@@ -3657,9 +3707,9 @@ run (void *cls,
3657 3707
3658 egos = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); 3708 egos = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
3659 apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); 3709 apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
3660 places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3710 places = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
3661 apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3711 apps_places = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
3662 //places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); 3712 // places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO);
3663 3713
3664 id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); 3714 id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL);
3665 gns = GNUNET_GNS_connect (cfg); 3715 gns = GNUNET_GNS_connect (cfg);
@@ -3690,71 +3740,71 @@ run (void *cls,
3690 * Define "main" method using service macro. 3740 * Define "main" method using service macro.
3691 */ 3741 */
3692GNUNET_SERVICE_MAIN 3742GNUNET_SERVICE_MAIN
3693("social", 3743 ("social",
3694 GNUNET_SERVICE_OPTION_NONE, 3744 GNUNET_SERVICE_OPTION_NONE,
3695 run, 3745 run,
3696 client_notify_connect, 3746 client_notify_connect,
3697 client_notify_disconnect, 3747 client_notify_disconnect,
3698 NULL, 3748 NULL,
3699 GNUNET_MQ_hd_var_size (client_host_enter, 3749 GNUNET_MQ_hd_var_size (client_host_enter,
3700 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER, 3750 GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER,
3701 struct HostEnterRequest, 3751 struct HostEnterRequest,
3702 NULL), 3752 NULL),
3703 GNUNET_MQ_hd_var_size (client_guest_enter, 3753 GNUNET_MQ_hd_var_size (client_guest_enter,
3704 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER, 3754 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER,
3705 struct GuestEnterRequest, 3755 struct GuestEnterRequest,
3706 NULL), 3756 NULL),
3707 GNUNET_MQ_hd_var_size (client_guest_enter_by_name, 3757 GNUNET_MQ_hd_var_size (client_guest_enter_by_name,
3708 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME, 3758 GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_BY_NAME,
3709 struct GuestEnterByNameRequest, 3759 struct GuestEnterByNameRequest,
3710 NULL), 3760 NULL),
3711 GNUNET_MQ_hd_var_size (client_join_decision, 3761 GNUNET_MQ_hd_var_size (client_join_decision,
3712 GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION, 3762 GNUNET_MESSAGE_TYPE_PSYC_JOIN_DECISION,
3713 struct GNUNET_PSYC_JoinDecisionMessage, 3763 struct GNUNET_PSYC_JoinDecisionMessage,
3714 NULL), 3764 NULL),
3715 GNUNET_MQ_hd_var_size (client_psyc_message, 3765 GNUNET_MQ_hd_var_size (client_psyc_message,
3716 GNUNET_MESSAGE_TYPE_PSYC_MESSAGE, 3766 GNUNET_MESSAGE_TYPE_PSYC_MESSAGE,
3717 struct GNUNET_MessageHeader, 3767 struct GNUNET_MessageHeader,
3718 NULL), 3768 NULL),
3719 GNUNET_MQ_hd_var_size (client_history_replay, 3769 GNUNET_MQ_hd_var_size (client_history_replay,
3720 GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY, 3770 GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY,
3721 struct GNUNET_PSYC_HistoryRequestMessage, 3771 struct GNUNET_PSYC_HistoryRequestMessage,
3722 NULL), 3772 NULL),
3723 GNUNET_MQ_hd_var_size (client_state_get, 3773 GNUNET_MQ_hd_var_size (client_state_get,
3724 GNUNET_MESSAGE_TYPE_PSYC_STATE_GET, 3774 GNUNET_MESSAGE_TYPE_PSYC_STATE_GET,
3725 struct GNUNET_PSYC_StateRequestMessage, 3775 struct GNUNET_PSYC_StateRequestMessage,
3726 NULL), 3776 NULL),
3727 GNUNET_MQ_hd_var_size (client_state_get_prefix, 3777 GNUNET_MQ_hd_var_size (client_state_get_prefix,
3728 GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX, 3778 GNUNET_MESSAGE_TYPE_PSYC_STATE_GET_PREFIX,
3729 struct GNUNET_PSYC_StateRequestMessage, 3779 struct GNUNET_PSYC_StateRequestMessage,
3730 NULL), 3780 NULL),
3731 GNUNET_MQ_hd_var_size (client_zone_add_place, 3781 GNUNET_MQ_hd_var_size (client_zone_add_place,
3732 GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE, 3782 GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_PLACE,
3733 struct ZoneAddPlaceRequest, 3783 struct ZoneAddPlaceRequest,
3734 NULL), 3784 NULL),
3735 GNUNET_MQ_hd_var_size (client_zone_add_nym, 3785 GNUNET_MQ_hd_var_size (client_zone_add_nym,
3736 GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM, 3786 GNUNET_MESSAGE_TYPE_SOCIAL_ZONE_ADD_NYM,
3737 struct ZoneAddNymRequest, 3787 struct ZoneAddNymRequest,
3738 NULL), 3788 NULL),
3739 GNUNET_MQ_hd_var_size (client_app_connect, 3789 GNUNET_MQ_hd_var_size (client_app_connect,
3740 GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT, 3790 GNUNET_MESSAGE_TYPE_SOCIAL_APP_CONNECT,
3741 struct AppConnectRequest, 3791 struct AppConnectRequest,
3742 NULL), 3792 NULL),
3743 GNUNET_MQ_hd_fixed_size (client_app_detach, 3793 GNUNET_MQ_hd_fixed_size (client_app_detach,
3744 GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH, 3794 GNUNET_MESSAGE_TYPE_SOCIAL_APP_DETACH,
3745 struct AppDetachRequest, 3795 struct AppDetachRequest,
3746 NULL), 3796 NULL),
3747 GNUNET_MQ_hd_fixed_size (client_place_leave, 3797 GNUNET_MQ_hd_fixed_size (client_place_leave,
3748 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE, 3798 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE,
3749 struct GNUNET_MessageHeader, 3799 struct GNUNET_MessageHeader,
3750 NULL), 3800 NULL),
3751 GNUNET_MQ_hd_var_size (client_msg_proc_set, 3801 GNUNET_MQ_hd_var_size (client_msg_proc_set,
3752 GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET, 3802 GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET,
3753 struct MsgProcRequest, 3803 struct MsgProcRequest,
3754 NULL), 3804 NULL),
3755 GNUNET_MQ_hd_fixed_size (client_msg_proc_clear, 3805 GNUNET_MQ_hd_fixed_size (client_msg_proc_clear,
3756 GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR, 3806 GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_CLEAR,
3757 struct GNUNET_MessageHeader, 3807 struct GNUNET_MessageHeader,
3758 NULL)); 3808 NULL));
3759 3809
3760/* end of gnunet-service-social.c */ 3810/* end of gnunet-service-social.c */