aboutsummaryrefslogtreecommitdiff
path: root/src/social
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-07-24 07:59:21 +0000
committerGabor X Toth <*@tg-x.net>2014-07-24 07:59:21 +0000
commita0a1be272163eb4dfbe73450cc08dc236f4e62fc (patch)
tree0a978a11b4ba5676ca7f1aed8792ffa0a85a972b /src/social
parentaab770ce9a17e4ad2e608b4974008e0269914408 (diff)
downloadgnunet-a0a1be272163eb4dfbe73450cc08dc236f4e62fc.tar.gz
gnunet-a0a1be272163eb4dfbe73450cc08dc236f4e62fc.zip
social: guest_talk test; multicast: fix member_to_origin_resume()
Diffstat (limited to 'src/social')
-rw-r--r--src/social/gnunet-service-social.c46
-rw-r--r--src/social/social_api.c7
-rw-r--r--src/social/test_social.c33
3 files changed, 46 insertions, 40 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c
index 90d12200d..de4163720 100644
--- a/src/social/gnunet-service-social.c
+++ b/src/social/gnunet-service-social.c
@@ -857,11 +857,6 @@ psyc_transmit_queue_next_part (struct Place *plc,
857 struct FragmentTransmitQueue *tmit_frag) 857 struct FragmentTransmitQueue *tmit_frag)
858{ 858{
859 uint16_t psize = ntohs (tmit_frag->next_part->size); 859 uint16_t psize = ntohs (tmit_frag->next_part->size);
860 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
861 "%p psyc_transmit_queue_next_part: %x + %u - %x = %u < %u\n",
862 plc, tmit_frag->next_part, psize, &tmit_frag[1],
863 (char *) tmit_frag->next_part + psize - ((char *) &tmit_frag[1]),
864 tmit_frag->size);
865 if ((char *) tmit_frag->next_part + psize - ((char *) &tmit_frag[1]) 860 if ((char *) tmit_frag->next_part + psize - ((char *) &tmit_frag[1])
866 < tmit_frag->size) 861 < tmit_frag->size)
867 { 862 {
@@ -952,11 +947,15 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
952 break; 947 break;
953 948
954 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: 949 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
955 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
956 *data_size = 0; 950 *data_size = 0;
957 ret = GNUNET_YES; 951 ret = GNUNET_YES;
958 break; 952 break;
959 953
954 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
955 *data_size = 0;
956 ret = GNUNET_SYSERR;
957 break;
958
960 default: 959 default:
961 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 960 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
962 "%p psyc_transmit_notify_data: unexpected message part of type %u.\n", 961 "%p psyc_transmit_notify_data: unexpected message part of type %u.\n",
@@ -964,7 +963,7 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
964 ret = GNUNET_SYSERR; 963 ret = GNUNET_SYSERR;
965 } 964 }
966 965
967 if (GNUNET_SYSERR == ret) 966 if (GNUNET_SYSERR == ret && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL != ptype)
968 { 967 {
969 *data_size = 0; 968 *data_size = 0;
970 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg); 969 tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
@@ -975,7 +974,27 @@ psyc_transmit_notify_data (void *cls, uint16_t *data_size, void *data)
975 } 974 }
976 else 975 else
977 { 976 {
978 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag); 977 tmit_frag = psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
978 if (NULL != tmit_frag)
979 {
980 struct GNUNET_MessageHeader *pmsg = tmit_frag->next_part;
981 ptype = ntohs (pmsg->type);
982 switch (ptype)
983 {
984 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
985 ret = GNUNET_YES;
986 break;
987 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
988 ret = GNUNET_SYSERR;
989 break;
990 }
991 switch (ptype)
992 {
993 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
994 case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
995 tmit_frag = psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
996 }
997 }
979 998
980 if (NULL == tmit_msg->frags_head 999 if (NULL == tmit_msg->frags_head
981 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) 1000 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
@@ -1060,12 +1079,6 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
1060 *data_size = mod_size; 1079 *data_size = mod_size;
1061 memcpy (data, &pmod[1], mod_size); 1080 memcpy (data, &pmod[1], mod_size);
1062 ret = GNUNET_NO; 1081 ret = GNUNET_NO;
1063#if REMOVE // FIXME
1064 ret = (mod_size - strnlen ((char *) &pmod[1], mod_size) - 1
1065 == *full_value_size)
1066 ? GNUNET_YES
1067 : GNUNET_NO;
1068#endif
1069 break; 1082 break;
1070 } 1083 }
1071 1084
@@ -1120,7 +1133,8 @@ psyc_transmit_notify_mod (void *cls, uint16_t *data_size, void *data,
1120 } 1133 }
1121 else 1134 else
1122 { 1135 {
1123 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag); 1136 if (GNUNET_YES != ret)
1137 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
1124 1138
1125 if (NULL == tmit_msg->frags_head 1139 if (NULL == tmit_msg->frags_head
1126 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype) 1140 && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
@@ -1241,7 +1255,6 @@ psyc_transmit_queue_next_method (struct Place *plc,
1241 1255
1242 uint16_t psize = ntohs (pmsg->size); 1256 uint16_t psize = ntohs (pmsg->size);
1243 *pmeth = (struct GNUNET_PSYC_MessageMethod *) pmsg; 1257 *pmeth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
1244
1245 if (psize < sizeof (**pmeth) + 1 || '\0' != *((char *) *pmeth + psize - 1)) 1258 if (psize < sizeof (**pmeth) + 1 || '\0' != *((char *) *pmeth + psize - 1))
1246 { 1259 {
1247 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1260 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1253,6 +1266,7 @@ psyc_transmit_queue_next_method (struct Place *plc,
1253 GNUNET_break (0); 1266 GNUNET_break (0);
1254 return GNUNET_SYSERR; 1267 return GNUNET_SYSERR;
1255 } 1268 }
1269
1256 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag); 1270 psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
1257 return GNUNET_OK; 1271 return GNUNET_OK;
1258} 1272}
diff --git a/src/social/social_api.c b/src/social/social_api.c
index d19f83e89..76fd0f9f9 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -1458,14 +1458,17 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_CONFIGURATION_Handle *cfg
1458 * otherwise handle to cancel the request. 1458 * otherwise handle to cancel the request.
1459 */ 1459 */
1460struct GNUNET_SOCIAL_TalkRequest * 1460struct GNUNET_SOCIAL_TalkRequest *
1461GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest, 1461GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst,
1462 const char *method_name, 1462 const char *method_name,
1463 const struct GNUNET_ENV_Environment *env, 1463 const struct GNUNET_ENV_Environment *env,
1464 GNUNET_PSYC_TransmitNotifyData notify_data, 1464 GNUNET_PSYC_TransmitNotifyData notify_data,
1465 void *notify_data_cls, 1465 void *notify_data_cls,
1466 enum GNUNET_SOCIAL_TalkFlags flags) 1466 enum GNUNET_SOCIAL_TalkFlags flags)
1467{ 1467{
1468 return NULL; 1468 if (GNUNET_OK ==
1469 GNUNET_PSYC_transmit_message (gst->plc.tmit, method_name, env,
1470 NULL, notify_data, notify_data_cls, flags));
1471 return (struct GNUNET_SOCIAL_TalkRequest *) gst->plc.tmit;
1469} 1472}
1470 1473
1471 1474
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 340c4482a..fa3ce6e6d 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -38,7 +38,7 @@
38 38
39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 39#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
40 40
41#define DEBUG_SERVICE 0 41#define DEBUG_SERVICE 1
42#define DATA2ARG(data) data, sizeof (data) 42#define DATA2ARG(data) data, sizeof (data)
43 43
44/** 44/**
@@ -110,9 +110,8 @@ enum
110 TEST_HOST_ANNOUNCE = 5, 110 TEST_HOST_ANNOUNCE = 5,
111 TEST_HOST_ANNOUNCE_END = 6, 111 TEST_HOST_ANNOUNCE_END = 6,
112 TEST_GUEST_TALK = 7, 112 TEST_GUEST_TALK = 7,
113 TEST_GUEST_TALK_END = 8, 113 TEST_GUEST_LEAVE = 8,
114 TEST_GUEST_LEAVE = 9, 114 TEST_HOST_LEAVE = 9,
115 TEST_HOST_LEAVE = 10,
116} test; 115} test;
117 116
118 117
@@ -294,6 +293,8 @@ host_farewell (void *cls,
294 size_t variable_count, 293 size_t variable_count,
295 struct GNUNET_ENV_Modifier *variables) 294 struct GNUNET_ENV_Modifier *variables)
296{ 295{
296 // FIXME: this function is not called yet
297
297 struct GNUNET_CRYPTO_EcdsaPublicKey * 298 struct GNUNET_CRYPTO_EcdsaPublicKey *
298 nym_key = GNUNET_SOCIAL_nym_get_key (nym); 299 nym_key = GNUNET_SOCIAL_nym_get_key (nym);
299 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 300 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -319,7 +320,7 @@ guest_left (void *cls)
319 320
320 321
321void 322void
322schedule_guest_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 323guest_leave()
323{ 324{
324 test = TEST_GUEST_LEAVE; 325 test = TEST_GUEST_LEAVE;
325 /* FIXME test keep_active */ 326 /* FIXME test keep_active */
@@ -396,14 +397,6 @@ guest_recv_eom (void *cls,
396 guest_talk (); 397 guest_talk ();
397 break; 398 break;
398 399
399 case TEST_GUEST_TALK:
400 test = TEST_GUEST_TALK_END;
401 break;
402
403 case TEST_GUEST_TALK_END:
404 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
405 break;
406
407 default: 400 default:
408 GNUNET_assert (0); 401 GNUNET_assert (0);
409 } 402 }
@@ -480,11 +473,7 @@ host_recv_eom (void *cls,
480 break; 473 break;
481 474
482 case TEST_GUEST_TALK: 475 case TEST_GUEST_TALK:
483 test = TEST_GUEST_TALK_END; 476 guest_leave ();
484 break;
485
486 case TEST_GUEST_TALK_END:
487 GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
488 break; 477 break;
489 478
490 default: 479 default:
@@ -509,10 +498,10 @@ guest_talk ()
509 tmit.data[2] = "testing ten nine eight"; 498 tmit.data[2] = "testing ten nine eight";
510 tmit.data_count = 3; 499 tmit.data_count = 3;
511 500
512 tmit.host_ann 501 tmit.guest_talk
513 = GNUNET_SOCIAL_host_announce (hst, "_message_guest", tmit.env, 502 = GNUNET_SOCIAL_guest_talk (gst, "_message_guest", tmit.env,
514 &notify_data, &tmit, 503 &notify_data, &tmit,
515 GNUNET_SOCIAL_TALK_NONE); 504 GNUNET_SOCIAL_TALK_NONE);
516} 505}
517 506
518void 507void