[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 07/07: test_multicast_multipeer.c: add ping pong t
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 07/07: test_multicast_multipeer.c: add ping pong test |
Date: |
Wed, 08 Mar 2017 23:41:27 +0100 |
This is an automated email from the git hooks/post-receive script.
xrs pushed a commit to branch master
in repository gnunet.
commit 4bf28bcaa25b8da6c28520a1aa18275dbe5f27a4
Author: xrs <address@hidden>
AuthorDate: Wed Mar 8 23:39:47 2017 +0100
test_multicast_multipeer.c: add ping pong test
---
src/multicast/Makefile.am | 3 +-
src/multicast/test_multicast_multipeer.c | 51 ++++++++++++++++++++++++--------
2 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am
index 9abe38506..0fa7f27a5 100644
--- a/src/multicast/Makefile.am
+++ b/src/multicast/Makefile.am
@@ -55,7 +55,8 @@ check_PROGRAMS = \
test_multicast_multipeer
if ENABLE_TEST_RUN
-AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};
export PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH; unset XDG_DATA_HOME;
unset XDG_CONFIG_HOME; export GNUNET_FORCE_LOG=';;;;INFO'
+#AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};
export PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH; unset XDG_DATA_HOME;
unset XDG_CONFIG_HOME; export GNUNET_FORCE_LOG=';;;;INFO';
+AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};
export PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH; unset XDG_DATA_HOME;
unset XDG_CONFIG_HOME; export GNUNET_FORCE_LOG='multicast;;;;INFO';
TESTS = $(check_PROGRAMS)
endif
diff --git a/src/multicast/test_multicast_multipeer.c
b/src/multicast/test_multicast_multipeer.c
index 0f973517d..58e43d4ba 100644
--- a/src/multicast/test_multicast_multipeer.c
+++ b/src/multicast/test_multicast_multipeer.c
@@ -129,15 +129,13 @@ int notify (void *cls,
size_t *data_size,
void *data)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Member sents message to origin.\n");
char text[] = "ping";
- *data_size = strlen(text);
+ *data_size = strlen(text)+1;
GNUNET_memcpy(data, text, *data_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "len: %i.\n", strlen(text));
+ "Member sents message to origin: %s\n", text);
return GNUNET_YES;
}
@@ -162,6 +160,7 @@ member_join_decision (void *cls,
0,
notify,
NULL);
+
}
}
@@ -184,6 +183,10 @@ member_message ()
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"member message...\n");
+
+ // FIXME: not finished here
+ result = GNUNET_YES;
+ GNUNET_SCHEDULER_shutdown ();
}
static void
@@ -197,9 +200,9 @@ origin_join_request (void *cls,
uint8_t data_size = ntohs (join_msg->size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "origin: got a join request...\n");
+ "origin got a join request...\n");
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "member to origin: '%s'\n", (char *)&join_msg[1]);
+ "origin receives: '%s'\n", (char *)&join_msg[1]);
char data[] = "Come in!";
data_size = strlen (data) + 1;
@@ -208,6 +211,9 @@ origin_join_request (void *cls,
join_resp->type = htons (123);
GNUNET_memcpy (&join_resp[1], data, data_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "origin sends: '%s'\n", data);
+
GNUNET_MULTICAST_join_decision (jh,
GNUNET_YES,
0,
@@ -239,18 +245,37 @@ origin_replay_msg (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay msg\n");
}
+
+int
+origin_notify (void *cls,
+ size_t *data_size,
+ void *data)
+{
+ char text[] = "pong";
+ *data_size = strlen(text)+1;
+ memcpy(data, text, *data_size);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends (to all): %s\n", text);
+
+ return GNUNET_YES;
+}
+
+
static void
origin_request (void *cls,
const struct GNUNET_MULTICAST_RequestHeader *req)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin request msg\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin receives: %s\n", (char
*)&req[1]);
- //FIXME: get req content and send a pong
- //GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- // "Member sent: '%s'\n", req);
+ if (0 != strncmp ("ping", (char *)&req[1], 4)) {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "origin didn't reveice a correct
request");
+ }
- result = GNUNET_OK;
- GNUNET_SCHEDULER_shutdown ();
+ GNUNET_MULTICAST_origin_to_all (origin,
+ 0,
+ 0,
+ origin_notify,
+ NULL);
}
static void
@@ -480,7 +505,7 @@ testbed_master (void *cls,
GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); /* Schedule a new task
on shutdown */
/* Schedule the shutdown task with a delay of a few Seconds */
- timeout_tid = GNUNET_SCHEDULER_add_delayed
(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40),
+ timeout_tid = GNUNET_SCHEDULER_add_delayed
(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 48),
&timeout_task, NULL);
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (95646a7b4 -> 4bf28bcaa), gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 01/07: More API function tests..., gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 05/07: Merge branch 'master' of ssh://gnunet.org/gnunet, gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 02/07: More API function tests..., gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 06/07: Merge branch 'master' of ssh://gnunet.org/gnunet, gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 04/07: Merge branch 'master' of ssh://gnunet.org/gnunet, gnunet, 2017/03/08
- [GNUnet-SVN] [gnunet] 07/07: test_multicast_multipeer.c: add ping pong test,
gnunet <=
- [GNUnet-SVN] [gnunet] 03/07: Merge branch 'master' of ssh://gnunet.org/gnunet, gnunet, 2017/03/08