aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_communicator_unix.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2019-04-20 10:57:18 +0200
committerJulius Bünger <buenger@mytum.de>2019-04-20 10:57:18 +0200
commitb26f2bce0710217bf68fd829ba6a652ca09cbfa8 (patch)
tree4c18650585f86f1bf80462ce939df0867234be95 /src/transport/test_communicator_unix.c
parent4ab00a8c15cf7cf286e290bc6227c5cbf3469dac (diff)
downloadgnunet-b26f2bce0710217bf68fd829ba6a652ca09cbfa8.tar.gz
gnunet-b26f2bce0710217bf68fd829ba6a652ca09cbfa8.zip
TNG testing: Add ability to open queue
Diffstat (limited to 'src/transport/test_communicator_unix.c')
-rw-r--r--src/transport/test_communicator_unix.c79
1 files changed, 72 insertions, 7 deletions
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c
index fd189659c..64ba1d5f5 100644
--- a/src/transport/test_communicator_unix.c
+++ b/src/transport/test_communicator_unix.c
@@ -30,6 +30,8 @@
30#include "gnunet_signatures.h" 30#include "gnunet_signatures.h"
31#include "transport.h" 31#include "transport.h"
32 32
33#include <inttypes.h>
34
33/** 35/**
34 * TODO 36 * TODO
35 * - start two communicators 37 * - start two communicators
@@ -45,28 +47,91 @@
45 47
46#define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__) 48#define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__)
47 49
50#define NUM_PEERS 2
51
52static struct GNUNET_PeerIdentity peer_id[NUM_PEERS];
53
54static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PEERS];
55
56//static char *addresses[NUM_PEERS];
57
58static void
59communicator_available_cb (void *cls,
60 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
61 enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc,
62 char *address_prefix)
63{
64 LOG (GNUNET_ERROR_TYPE_DEBUG,
65 "Communicator available. (cc: %u, prefix: %s)\n",
66 cc,
67 address_prefix);
68}
69
70
71static void
72add_address_cb (void *cls,
73 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
74 const char *address,
75 struct GNUNET_TIME_Relative expiration,
76 uint32_t aid,
77 enum GNUNET_NetworkType nt)
78{
79 LOG (GNUNET_ERROR_TYPE_DEBUG,
80 "New address. (addr: %s, expir: %" PRIu32 ", ID: %" PRIu32 ", nt: %u\n",
81 address,
82 expiration.rel_value_us,
83 aid,
84 nt);
85 //addresses[1] = GNUNET_strdup (address);
86 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0],
87 &peer_id[1],
88 address);
89}
90
91
92static void
93queue_create_reply_cb (void *cls,
94 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
95 int success)
96{
97 if (GNUNET_YES == success)
98 LOG (GNUNET_ERROR_TYPE_DEBUG,
99 "Got Queue!\n");
100 else
101 LOG (GNUNET_ERROR_TYPE_DEBUG,
102 "Failed getting queue!\n");
103}
104
105
48static void 106static void
49communicator_available (void *cls, 107add_queue_cb (void *cls,
50 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) 108 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
51{ 109{
52 LOG (GNUNET_ERROR_TYPE_DEBUG, 110 LOG (GNUNET_ERROR_TYPE_DEBUG,
53 "communicator_available()\n"); 111 "Got Queue!\n");
54} 112}
55 113
114
56static void 115static void
57run (void *cls) 116run (void *cls)
58{ 117{
59 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 118 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
60 119
61 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 120 tc_hs[0] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
62 "transport", 121 "transport",
63 "test_communicator_1.conf", 122 "test_communicator_1.conf",
64 &communicator_available, 123 &communicator_available_cb,
124 NULL,
125 &queue_create_reply_cb,
126 &add_queue_cb,
65 NULL); /* cls */ 127 NULL); /* cls */
66 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 128 tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
67 "transport", 129 "transport",
68 "test_communicator_2.conf", 130 "test_communicator_2.conf",
69 &communicator_available, 131 &communicator_available_cb,
132 &add_address_cb,
133 NULL,
134 &add_queue_cb,
70 NULL); /* cls */ 135 NULL); /* cls */
71} 136}
72 137