diff options
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 1 | ||||
-rw-r--r-- | src/transport/gnunet-communicator-tcp.c | 15 | ||||
-rw-r--r-- | src/transport/plugin_cmd_simple_send.c | 23 | ||||
-rw-r--r-- | src/transport/transport-testing-cmds.h | 15 | ||||
-rw-r--r-- | src/transport/transport-testing2.h | 37 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 74 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_send_simple.c | 24 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_start_peer.c | 34 |
8 files changed, 136 insertions, 87 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 3d8fa7774..55a338729 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -171,6 +171,7 @@ libgnunettransporttesting2_la_SOURCES = \ | |||
171 | transport_api_cmd_start_peer.c \ | 171 | transport_api_cmd_start_peer.c \ |
172 | transport_api_cmd_send_simple.c \ | 172 | transport_api_cmd_send_simple.c \ |
173 | transport-testing2.c transport-testing2.h \ | 173 | transport-testing2.c transport-testing2.h \ |
174 | transport-testing-cmds.h \ | ||
174 | transport-testing-filenames2.c \ | 175 | transport-testing-filenames2.c \ |
175 | transport-testing-loggers2.c \ | 176 | transport-testing-loggers2.c \ |
176 | transport-testing-main2.c \ | 177 | transport-testing-main2.c \ |
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index 1b838bf9c..fde85923b 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -1900,6 +1900,9 @@ queue_read (void *cls) | |||
1900 | BUF_SIZE - queue->cread_off); | 1900 | BUF_SIZE - queue->cread_off); |
1901 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1901 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1902 | "Received %lu bytes from TCP queue\n", rcvd); | 1902 | "Received %lu bytes from TCP queue\n", rcvd); |
1903 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
1904 | "transport", | ||
1905 | "Received %lu bytes from TCP queue\n", rcvd); | ||
1903 | if (-1 == rcvd) | 1906 | if (-1 == rcvd) |
1904 | { | 1907 | { |
1905 | if ((EAGAIN != errno) && (EINTR != errno)) | 1908 | if ((EAGAIN != errno) && (EINTR != errno)) |
@@ -2675,6 +2678,9 @@ proto_read_kx (void *cls) | |||
2675 | sizeof(pq->ibuf) - pq->ibuf_off); | 2678 | sizeof(pq->ibuf) - pq->ibuf_off); |
2676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2679 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2677 | "Received %lu bytes for KX\n", rcvd); | 2680 | "Received %lu bytes for KX\n", rcvd); |
2681 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
2682 | "transport", | ||
2683 | "Received %lu bytes for KX\n", rcvd); | ||
2678 | if (-1 == rcvd) | 2684 | if (-1 == rcvd) |
2679 | { | 2685 | { |
2680 | if ((EAGAIN != errno) && (EINTR != errno)) | 2686 | if ((EAGAIN != errno) && (EINTR != errno)) |
@@ -2824,6 +2830,10 @@ queue_read_kx (void *cls) | |||
2824 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2830 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2825 | "Received %lu bytes for KX\n", | 2831 | "Received %lu bytes for KX\n", |
2826 | rcvd); | 2832 | rcvd); |
2833 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
2834 | "transport", | ||
2835 | "Received %lu bytes for KX\n", | ||
2836 | rcvd); | ||
2827 | if (-1 == rcvd) | 2837 | if (-1 == rcvd) |
2828 | { | 2838 | { |
2829 | if ((EAGAIN != errno) && (EINTR != errno)) | 2839 | if ((EAGAIN != errno) && (EINTR != errno)) |
@@ -2918,6 +2928,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2918 | 2928 | ||
2919 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2920 | "Connecting to %s\n", address); | 2930 | "Connecting to %s\n", address); |
2931 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
2932 | "transport", | ||
2933 | "Connecting to %s\n", address); | ||
2921 | if (0 != strncmp (address, | 2934 | if (0 != strncmp (address, |
2922 | COMMUNICATOR_ADDRESS_PREFIX "-", | 2935 | COMMUNICATOR_ADDRESS_PREFIX "-", |
2923 | strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) | 2936 | strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) |
@@ -3238,7 +3251,7 @@ init_socket (struct sockaddr *addr, | |||
3238 | return GNUNET_SYSERR; | 3251 | return GNUNET_SYSERR; |
3239 | } | 3252 | } |
3240 | 3253 | ||
3241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3242 | "address %s\n", | 3255 | "address %s\n", |
3243 | GNUNET_a2s (addr, in_len)); | 3256 | GNUNET_a2s (addr, in_len)); |
3244 | 3257 | ||
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c index 62bb7544b..e2407c8c0 100644 --- a/src/transport/plugin_cmd_simple_send.c +++ b/src/transport/plugin_cmd_simple_send.c | |||
@@ -30,6 +30,7 @@ | |||
30 | // #include "gnunet_transport_service.h" | 30 | // #include "gnunet_transport_service.h" |
31 | #include "gnunet_testbed_ng_service.h" | 31 | #include "gnunet_testbed_ng_service.h" |
32 | #include "transport-testing2.h" | 32 | #include "transport-testing2.h" |
33 | #include "transport-testing-cmds.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * Generic logging shortcut | 36 | * Generic logging shortcut |
@@ -85,20 +86,25 @@ static void | |||
85 | start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, | 86 | start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, |
86 | char *node_ip, | 87 | char *node_ip, |
87 | char *m, | 88 | char *m, |
88 | char *n) | 89 | char *n, |
90 | char *local_m) | ||
89 | { | 91 | { |
90 | char *testdir; | 92 | char *testdir; |
91 | char *cfgname; | 93 | char *cfgname; |
92 | 94 | ||
93 | GNUNET_asprintf (&cfgname, | 95 | GNUNET_asprintf (&cfgname, |
94 | "%s%s.conf", | 96 | "%s%s.conf", |
95 | "test_transport_api2_tcp_peer", | 97 | "test_transport_api2_tcp_node", |
96 | n); | 98 | n); |
97 | 99 | ||
98 | LOG (GNUNET_ERROR_TYPE_ERROR, | 100 | LOG (GNUNET_ERROR_TYPE_ERROR, |
99 | "cfgname: %s\n", | 101 | "cfgname: %s\n", |
100 | cfgname); | 102 | cfgname); |
101 | 103 | ||
104 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
105 | "node ip: %s\n", | ||
106 | node_ip); | ||
107 | |||
102 | testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n) | 108 | testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n) |
103 | + 1); | 109 | + 1); |
104 | 110 | ||
@@ -125,6 +131,7 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, | |||
125 | "system-create-1", | 131 | "system-create-1", |
126 | m, | 132 | m, |
127 | n, | 133 | n, |
134 | local_m, | ||
128 | handlers, | 135 | handlers, |
129 | cfgname), | 136 | cfgname), |
130 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1", | 137 | GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1", |
@@ -134,12 +141,12 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, | |||
134 | GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1", | 141 | GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1", |
135 | "start-peer-1", | 142 | "start-peer-1", |
136 | "this is useless"), | 143 | "this is useless"), |
137 | /*GNUNET_TESTING_cmd_send_simple ("send-simple-1", | 144 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple-1", |
138 | char *m, | 145 | m, |
139 | char *n, | 146 | n, |
140 | uint32_t num, | 147 | 0, |
141 | const char *peer1_label, | 148 | "start-peer-1", |
142 | const char *peer2_label),*/ | 149 | "this is useless"), |
143 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1", | 150 | GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1", |
144 | write_message) | 151 | write_message) |
145 | }; | 152 | }; |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index fed4e8d5a..4edd334f0 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -24,8 +24,8 @@ | |||
24 | * @author Matthias Wachs | 24 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | */ | 26 | */ |
27 | #ifndef TRANSPORT_TESTING_H | 27 | #ifndef TRANSPORT_TESTING_CMDS_H |
28 | #define TRANSPORT_TESTING_H | 28 | #define TRANSPORT_TESTING__CMDS_H |
29 | #include "gnunet_testing_lib.h" | 29 | #include "gnunet_testing_lib.h" |
30 | 30 | ||
31 | struct GNUNET_TESTING_Command | 31 | struct GNUNET_TESTING_Command |
@@ -33,6 +33,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
33 | const char *system_label, | 33 | const char *system_label, |
34 | char *m, | 34 | char *m, |
35 | char *n, | 35 | char *n, |
36 | char *local_m, | ||
36 | struct GNUNET_MQ_MessageHandler *handlers, | 37 | struct GNUNET_MQ_MessageHandler *handlers, |
37 | const char *cfgname); | 38 | const char *cfgname); |
38 | 39 | ||
@@ -41,6 +42,14 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
41 | const char *peer1_label, | 42 | const char *peer1_label, |
42 | const char *peer2_label); | 43 | const char *peer2_label); |
43 | 44 | ||
45 | struct GNUNET_TESTING_Command | ||
46 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, | ||
47 | char *m, | ||
48 | char *n, | ||
49 | uint32_t num, | ||
50 | const char *peer1_label, | ||
51 | const char *peer2_label); | ||
52 | |||
44 | int | 53 | int |
45 | GNUNET_TRANSPORT_get_trait_peer_id (const struct | 54 | GNUNET_TRANSPORT_get_trait_peer_id (const struct |
46 | GNUNET_TESTING_Command *cmd, | 55 | GNUNET_TESTING_Command *cmd, |
@@ -51,7 +60,7 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | |||
51 | GNUNET_TESTING_Command | 60 | GNUNET_TESTING_Command |
52 | *cmd, | 61 | *cmd, |
53 | struct | 62 | struct |
54 | GNUNET_CONTAINER_MultiPeerMap ** | 63 | GNUNET_CONTAINER_MultiShortmap ** |
55 | connected_peers_map); | 64 | connected_peers_map); |
56 | int | 65 | int |
57 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | 66 | GNUNET_TRANSPORT_get_trait_hello_size (const struct |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index a6732e308..e2167ca7e 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -920,42 +920,5 @@ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable, | |||
920 | char * | 920 | char * |
921 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file); | 921 | GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file); |
922 | 922 | ||
923 | struct GNUNET_TESTING_Command | ||
924 | GNUNET_TRANSPORT_cmd_start_peer (const char *label, | ||
925 | const char *system_label, | ||
926 | char *m, | ||
927 | char *n, | ||
928 | struct GNUNET_MQ_MessageHandler *handlers, | ||
929 | const char *cfgname); | ||
930 | |||
931 | struct GNUNET_TESTING_Command | ||
932 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | ||
933 | const char *peer1_label, | ||
934 | const char *peer2_label); | ||
935 | |||
936 | int | ||
937 | GNUNET_TRANSPORT_get_trait_peer_id (const struct | ||
938 | GNUNET_TESTING_Command *cmd, | ||
939 | struct GNUNET_PeerIdentity **id); | ||
940 | |||
941 | int | ||
942 | GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | ||
943 | GNUNET_TESTING_Command | ||
944 | *cmd, | ||
945 | struct | ||
946 | GNUNET_CONTAINER_MultiPeerMap ** | ||
947 | connected_peers_map); | ||
948 | int | ||
949 | GNUNET_TRANSPORT_get_trait_hello_size (const struct | ||
950 | GNUNET_TESTING_Command | ||
951 | *cmd, | ||
952 | size_t **hello_size); | ||
953 | |||
954 | int | ||
955 | GNUNET_TRANSPORT_get_trait_hello (const struct | ||
956 | GNUNET_TESTING_Command | ||
957 | *cmd, | ||
958 | char **hello); | ||
959 | |||
960 | #endif | 923 | #endif |
961 | /* end of transport_testing.h */ | 924 | /* end of transport_testing.h */ |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 69a4f385e..f4b2e935f 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -41,6 +41,8 @@ struct ConnectPeersState | |||
41 | const char *peer1_label; | 41 | const char *peer1_label; |
42 | 42 | ||
43 | const char *peer2_label; | 43 | const char *peer2_label; |
44 | |||
45 | struct GNUNET_PeerIdentity *id; | ||
44 | }; | 46 | }; |
45 | 47 | ||
46 | 48 | ||
@@ -53,12 +55,13 @@ connect_peers_run (void *cls, | |||
53 | const struct GNUNET_TESTING_Command *peer1_cmd; | 55 | const struct GNUNET_TESTING_Command *peer1_cmd; |
54 | const struct GNUNET_TESTING_Command *peer2_cmd; | 56 | const struct GNUNET_TESTING_Command *peer2_cmd; |
55 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | 57 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
56 | struct GNUNET_PeerIdentity *id; | 58 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); |
57 | char *addr; | 59 | char *addr; |
58 | struct GNUNET_TIME_Absolute t; | 60 | struct GNUNET_TIME_Absolute t; |
59 | char *hello; | 61 | char *hello; |
60 | size_t *hello_size; | 62 | size_t *hello_size; |
61 | enum GNUNET_NetworkType nt = 0; | 63 | enum GNUNET_NetworkType nt = 0; |
64 | char *peer_id; | ||
62 | 65 | ||
63 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); | 66 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); |
64 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | 67 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, |
@@ -71,6 +74,31 @@ connect_peers_run (void *cls, | |||
71 | "hello: %s\n", | 74 | "hello: %s\n", |
72 | hello); | 75 | hello); |
73 | 76 | ||
77 | /*GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | ||
78 | &id); | ||
79 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
80 | "pid %s\n", | ||
81 | GNUNET_i2s_full(id));*/ | ||
82 | |||
83 | if(strstr(hello, "60002") != NULL) | ||
84 | { | ||
85 | addr = "tcp-192.168.15.2:60003"; | ||
86 | peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | addr = "tcp-192.168.15.1:60002"; | ||
91 | peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; | ||
92 | } | ||
93 | |||
94 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
95 | "get pub key\n"); | ||
96 | GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | ||
97 | strlen (peer_id), | ||
98 | &peer->public_key); | ||
99 | |||
100 | cps->id = peer; | ||
101 | |||
74 | // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. | 102 | // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. |
75 | // --------------------------------------------- | 103 | // --------------------------------------------- |
76 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | 104 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); |
@@ -85,14 +113,16 @@ connect_peers_run (void *cls, | |||
85 | *hello_size, | 113 | *hello_size, |
86 | id, | 114 | id, |
87 | &nt, | 115 | &nt, |
88 | &t); | 116 | &t);*/ |
89 | 117 | ||
90 | //---------------------------------------------- | 118 | //---------------------------------------------- |
91 | 119 | ||
120 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
121 | "application validate\n"); | ||
92 | GNUNET_TRANSPORT_application_validate (ah, | 122 | GNUNET_TRANSPORT_application_validate (ah, |
93 | id, | 123 | peer, |
94 | nt, | 124 | nt, |
95 | addr);*/ | 125 | addr); |
96 | } | 126 | } |
97 | 127 | ||
98 | 128 | ||
@@ -101,34 +131,38 @@ connect_peers_finish (void *cls, | |||
101 | GNUNET_SCHEDULER_TaskCallback cont, | 131 | GNUNET_SCHEDULER_TaskCallback cont, |
102 | void *cont_cls) | 132 | void *cont_cls) |
103 | { | 133 | { |
104 | /*struct ConnectPeersState *cps = cls; | 134 | struct ConnectPeersState *cps = cls; |
105 | const struct GNUNET_TESTING_Command *peer1_cmd; | 135 | const struct GNUNET_TESTING_Command *peer1_cmd; |
106 | const struct GNUNET_TESTING_Command *peer2_cmd; | 136 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
107 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; | ||
108 | unsigned int ret; | 137 | unsigned int ret; |
109 | struct GNUNET_PeerIdentity *id; | 138 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); |
139 | struct GNUNET_HashCode hc; | ||
140 | int node_number; | ||
110 | 141 | ||
111 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); | 142 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); |
112 | GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | 143 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, |
113 | &id); | ||
114 | |||
115 | peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | ||
116 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer2_cmd, | ||
117 | &connected_peers_map); | 144 | &connected_peers_map); |
118 | 145 | ||
119 | ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map, | 146 | node_number = 1; |
120 | id); | 147 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); |
148 | |||
149 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | ||
150 | memcpy (key, | ||
151 | &hc, | ||
152 | sizeof (*key)); | ||
153 | ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map, | ||
154 | key); | ||
121 | 155 | ||
122 | if (GNUNET_YES == ret) | 156 | if (GNUNET_YES == ret) |
123 | { | 157 | { |
124 | cont (cont_cls); | 158 | cont (cont_cls); |
125 | } | ||
126 | |||
127 | return ret;*/ | ||
128 | cont (cont_cls); | ||
129 | LOG (GNUNET_ERROR_TYPE_ERROR, | 159 | LOG (GNUNET_ERROR_TYPE_ERROR, |
130 | "connect peer finish\n"); | 160 | "connect peer finish\n"); |
131 | return GNUNET_OK; | 161 | } |
162 | |||
163 | return ret; | ||
164 | /*cont (cont_cls); | ||
165 | return GNUNET_OK;*/ | ||
132 | } | 166 | } |
133 | 167 | ||
134 | 168 | ||
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c index 4a60f1a12..6e7b89497 100644 --- a/src/transport/transport_api_cmd_send_simple.c +++ b/src/transport/transport_api_cmd_send_simple.c | |||
@@ -26,7 +26,8 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_testing_ng_lib.h" | 28 | #include "gnunet_testing_ng_lib.h" |
29 | #include "transport-testing.h" | 29 | #include "transport-testing2.h" |
30 | #include "transport-testing-cmds.h" | ||
30 | 31 | ||
31 | struct SendSimpleState | 32 | struct SendSimpleState |
32 | { | 33 | { |
@@ -70,21 +71,26 @@ send_simple_run (void *cls, | |||
70 | struct GNUNET_MQ_Envelope *env; | 71 | struct GNUNET_MQ_Envelope *env; |
71 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; | 72 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; |
72 | struct GNUNET_MQ_Handle *mq; | 73 | struct GNUNET_MQ_Handle *mq; |
73 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; | 74 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
74 | struct GNUNET_PeerIdentity *id; | 75 | struct GNUNET_PeerIdentity *id; |
75 | const struct GNUNET_TESTING_Command *peer1_cmd; | 76 | const struct GNUNET_TESTING_Command *peer1_cmd; |
76 | const struct GNUNET_TESTING_Command *peer2_cmd; | 77 | const struct GNUNET_TESTING_Command *peer2_cmd; |
78 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
79 | struct GNUNET_HashCode hc; | ||
80 | int node_number; | ||
77 | 81 | ||
78 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label); | 82 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label); |
79 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | 83 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, |
80 | &connected_peers_map); | 84 | &connected_peers_map); |
81 | 85 | ||
82 | peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer2_label); | 86 | node_number = 1; |
83 | GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd, | 87 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); |
84 | &id); | 88 | memcpy (key, |
85 | 89 | &hc, | |
86 | mq = GNUNET_CONTAINER_multipeermap_get (connected_peers_map, | 90 | sizeof (*key)); |
87 | id); | 91 | |
92 | mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, | ||
93 | key); | ||
88 | 94 | ||
89 | env = GNUNET_MQ_msg_extra (test, | 95 | env = GNUNET_MQ_msg_extra (test, |
90 | 2600 - sizeof(*test), | 96 | 2600 - sizeof(*test), |
@@ -110,7 +116,7 @@ send_simple_run (void *cls, | |||
110 | * @return command. | 116 | * @return command. |
111 | */ | 117 | */ |
112 | struct GNUNET_TESTING_Command | 118 | struct GNUNET_TESTING_Command |
113 | GNUNET_TESTING_cmd_send_simple (const char *label, | 119 | GNUNET_TRANSPORT_cmd_send_simple (const char *label, |
114 | char *m, | 120 | char *m, |
115 | char *n, | 121 | char *n, |
116 | uint32_t num, | 122 | uint32_t num, |
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index c2cc20a2a..b2b26194a 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c | |||
@@ -95,6 +95,8 @@ struct StartPeerState | |||
95 | 95 | ||
96 | char *n; | 96 | char *n; |
97 | 97 | ||
98 | char *local_m; | ||
99 | |||
98 | unsigned int finished; | 100 | unsigned int finished; |
99 | 101 | ||
100 | const char *system_label; | 102 | const char *system_label; |
@@ -104,7 +106,7 @@ struct StartPeerState | |||
104 | */ | 106 | */ |
105 | unsigned int no; | 107 | unsigned int no; |
106 | 108 | ||
107 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; | 109 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; |
108 | 110 | ||
109 | struct GNUNET_TESTING_System *tl_system; | 111 | struct GNUNET_TESTING_System *tl_system; |
110 | 112 | ||
@@ -190,7 +192,9 @@ notify_connect (void *cls, | |||
190 | struct GNUNET_MQ_Handle *mq) | 192 | struct GNUNET_MQ_Handle *mq) |
191 | { | 193 | { |
192 | struct StartPeerState *sps = cls; | 194 | struct StartPeerState *sps = cls; |
193 | 195 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | |
196 | struct GNUNET_HashCode hc; | ||
197 | int node_number; | ||
194 | 198 | ||
195 | void *ret; | 199 | void *ret; |
196 | 200 | ||
@@ -201,8 +205,16 @@ notify_connect (void *cls, | |||
201 | sps->no, | 205 | sps->no, |
202 | GNUNET_i2s (&sps->id)); | 206 | GNUNET_i2s (&sps->id)); |
203 | 207 | ||
204 | GNUNET_CONTAINER_multipeermap_put (sps->connected_peers_map, | 208 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. |
205 | peer, | 209 | node_number = 1; |
210 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | ||
211 | |||
212 | |||
213 | memcpy (key, | ||
214 | &hc, | ||
215 | sizeof (*key)); | ||
216 | GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map, | ||
217 | key, | ||
206 | mq, | 218 | mq, |
207 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 219 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
208 | 220 | ||
@@ -428,7 +440,7 @@ start_peer_traits (void *cls, | |||
428 | struct StartPeerState *sps = cls; | 440 | struct StartPeerState *sps = cls; |
429 | struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; | 441 | struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; |
430 | struct GNUNET_PeerIdentity *id = &sps->id; | 442 | struct GNUNET_PeerIdentity *id = &sps->id; |
431 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map = | 443 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = |
432 | sps->connected_peers_map; | 444 | sps->connected_peers_map; |
433 | char *hello = sps->hello; | 445 | char *hello = sps->hello; |
434 | size_t hello_size = sps->hello_size; | 446 | size_t hello_size = sps->hello_size; |
@@ -498,7 +510,7 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct | |||
498 | GNUNET_TESTING_Command | 510 | GNUNET_TESTING_Command |
499 | *cmd, | 511 | *cmd, |
500 | struct | 512 | struct |
501 | GNUNET_CONTAINER_MultiPeerMap ** | 513 | GNUNET_CONTAINER_MultiShortmap ** |
502 | connected_peers_map) | 514 | connected_peers_map) |
503 | { | 515 | { |
504 | return cmd->traits (cmd->cls, | 516 | return cmd->traits (cmd->cls, |
@@ -545,20 +557,24 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, | |||
545 | const char *system_label, | 557 | const char *system_label, |
546 | char *m, | 558 | char *m, |
547 | char *n, | 559 | char *n, |
560 | char *local_m, | ||
548 | struct GNUNET_MQ_MessageHandler *handlers, | 561 | struct GNUNET_MQ_MessageHandler *handlers, |
549 | const char *cfgname) | 562 | const char *cfgname) |
550 | { | 563 | { |
551 | struct StartPeerState *sps; | 564 | struct StartPeerState *sps; |
552 | struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map = | 565 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = |
553 | GNUNET_CONTAINER_multipeermap_create (1,GNUNET_NO); | 566 | GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); |
554 | unsigned int i; | 567 | unsigned int i; |
555 | 568 | ||
556 | LOG (GNUNET_ERROR_TYPE_ERROR, | 569 | LOG (GNUNET_ERROR_TYPE_ERROR, |
557 | "start peer 0.1\n"); | 570 | "start peer 0.1 with cfg: %s\n", |
571 | cfgname); | ||
558 | 572 | ||
559 | sps = GNUNET_new (struct StartPeerState); | 573 | sps = GNUNET_new (struct StartPeerState); |
560 | sps->m = m; | 574 | sps->m = m; |
561 | sps->n = n; | 575 | sps->n = n; |
576 | sps->local_m = local_m; | ||
577 | sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m); | ||
562 | sps->system_label = system_label; | 578 | sps->system_label = system_label; |
563 | sps->connected_peers_map = connected_peers_map; | 579 | sps->connected_peers_map = connected_peers_map; |
564 | sps->cfgname = cfgname; | 580 | sps->cfgname = cfgname; |