aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-02-13 21:53:41 +0000
committerng0 <ng0@n0.is>2019-02-13 21:53:41 +0000
commit7285ae216aeb5dad89055085f2d7710c4ed5934e (patch)
tree8fe342cb10cd6c0ef5115ba761a07591ddaf2e05 /src
parent1104fccaef9483fb92303eb5ce854b971b1b8151 (diff)
parent94911c3e57d5f77ddf68032789244d0475955149 (diff)
downloadgnunet-7285ae216aeb5dad89055085f2d7710c4ed5934e.tar.gz
gnunet-7285ae216aeb5dad89055085f2d7710c4ed5934e.zip
Merge branch 'master' of gnunet.org:gnunet
Diffstat (limited to 'src')
-rw-r--r--src/cadet/cadet.h10
-rw-r--r--src/cadet/cadet_api_get_path.c13
-rw-r--r--src/cadet/gnunet-cadet.c16
-rw-r--r--src/cadet/gnunet-service-cadet.c10
-rw-r--r--src/include/gnunet_cadet_service.h21
-rw-r--r--src/include/gnunet_hello_lib.h2
-rw-r--r--src/include/gnunet_protocols.h33
-rw-r--r--src/include/gnunet_transport_address_service.h4
-rw-r--r--src/rps/profiler_rps.conf1
-rw-r--r--src/transport/Makefile.am10
-rw-r--r--src/transport/gnunet-service-tng.c349
-rw-r--r--src/transport/transport.h26
-rw-r--r--src/transport/transport_api2_address.c249
13 files changed, 555 insertions, 189 deletions
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 51296ae50..f6cc860cc 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -323,9 +323,9 @@ struct GNUNET_CADET_LocalInfoPath
323 struct GNUNET_MessageHeader header; 323 struct GNUNET_MessageHeader header;
324 324
325 /** 325 /**
326 * Zero. 326 * Offset of the peer that was requested.
327 */ 327 */
328 uint32_t reserved GNUNET_PACKED; 328 uint32_t off GNUNET_PACKED;
329}; 329};
330 330
331 331
@@ -338,7 +338,7 @@ struct GNUNET_CADET_LocalInfoPeers
338 * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS 338 * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS
339 */ 339 */
340 struct GNUNET_MessageHeader header; 340 struct GNUNET_MessageHeader header;
341 341
342 /** 342 /**
343 * Number of paths. 343 * Number of paths.
344 */ 344 */
@@ -348,7 +348,7 @@ struct GNUNET_CADET_LocalInfoPeers
348 * Do we have a tunnel toward this peer? 348 * Do we have a tunnel toward this peer?
349 */ 349 */
350 int16_t tunnel GNUNET_PACKED; 350 int16_t tunnel GNUNET_PACKED;
351 351
352 /** 352 /**
353 * Shortest known path. 353 * Shortest known path.
354 */ 354 */
diff --git a/src/cadet/cadet_api_get_path.c b/src/cadet/cadet_api_get_path.c
index 2f35e365e..fcc79c3d5 100644
--- a/src/cadet/cadet_api_get_path.c
+++ b/src/cadet/cadet_api_get_path.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -66,7 +66,7 @@ struct GNUNET_CADET_GetPath
66 * Backoff for reconnect attempts. 66 * Backoff for reconnect attempts.
67 */ 67 */
68 struct GNUNET_TIME_Relative backoff; 68 struct GNUNET_TIME_Relative backoff;
69 69
70 /** 70 /**
71 * Peer we want information about. 71 * Peer we want information about.
72 */ 72 */
@@ -109,7 +109,7 @@ check_get_path (void *cls,
109/** 109/**
110 * Process a local peer info reply, pass info to the user. 110 * Process a local peer info reply, pass info to the user.
111 * 111 *
112 * @param cls Closure 112 * @param cls Closure
113 * @param message Message itself. 113 * @param message Message itself.
114 */ 114 */
115static void 115static void
@@ -118,9 +118,10 @@ handle_get_path (void *cls,
118{ 118{
119 struct GNUNET_CADET_GetPath *gp = cls; 119 struct GNUNET_CADET_GetPath *gp = cls;
120 struct GNUNET_CADET_PeerPathDetail ppd; 120 struct GNUNET_CADET_PeerPathDetail ppd;
121 121
122 ppd.peer = gp->id; 122 ppd.peer = gp->id;
123 ppd.path = (const struct GNUNET_PeerIdentity *) &message[1]; 123 ppd.path = (const struct GNUNET_PeerIdentity *) &message[1];
124 ppd.target_offset = ntohl (message->off);
124 ppd.path_length = (ntohs (message->header.size) - sizeof (*message)) 125 ppd.path_length = (ntohs (message->header.size) - sizeof (*message))
125 / sizeof (struct GNUNET_PeerIdentity); 126 / sizeof (struct GNUNET_PeerIdentity);
126 gp->path_cb (gp->path_cb_cls, 127 gp->path_cb (gp->path_cb_cls,
@@ -131,7 +132,7 @@ handle_get_path (void *cls,
131/** 132/**
132 * Process a local peer info reply, pass info to the user. 133 * Process a local peer info reply, pass info to the user.
133 * 134 *
134 * @param cls Closure 135 * @param cls Closure
135 * @param message Message itself. 136 * @param message Message itself.
136 */ 137 */
137static void 138static void
@@ -177,7 +178,7 @@ error_handler (void *cls,
177 gp); 178 gp);
178} 179}
179 180
180 181
181/** 182/**
182 * Reconnect to the service and try again. 183 * Reconnect to the service and try again.
183 * 184 *
diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c
index dba517a7b..932d069a1 100644
--- a/src/cadet/gnunet-cadet.c
+++ b/src/cadet/gnunet-cadet.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -103,7 +103,7 @@ static struct GNUNET_CADET_GetPath *gpo;
103 103
104/** 104/**
105 * Active peer listing operation. 105 * Active peer listing operation.
106 */ 106 */
107static struct GNUNET_CADET_PeersLister *plo; 107static struct GNUNET_CADET_PeersLister *plo;
108 108
109/** 109/**
@@ -220,7 +220,7 @@ shutdown_task (void *cls)
220 { 220 {
221 GNUNET_CADET_channel_destroy (ch); 221 GNUNET_CADET_channel_destroy (ch);
222 ch = NULL; 222 ch = NULL;
223 } 223 }
224 if (NULL != gpo) 224 if (NULL != gpo)
225 { 225 {
226 GNUNET_CADET_get_path_cancel (gpo); 226 GNUNET_CADET_get_path_cancel (gpo);
@@ -306,12 +306,12 @@ read_stdio (void *cls)
306 if (GNUNET_NO == echo) 306 if (GNUNET_NO == echo)
307 { 307 {
308 // Use MQ's notification if too much data of stdin is pooring in too fast. 308 // Use MQ's notification if too much data of stdin is pooring in too fast.
309 if (STREAM_BUFFER_SIZE < sent_pkt) 309 if (STREAM_BUFFER_SIZE < sent_pkt)
310 { 310 {
311 GNUNET_MQ_notify_sent (env, mq_cb, cls); 311 GNUNET_MQ_notify_sent (env, mq_cb, cls);
312 sent_pkt = 0; 312 sent_pkt = 0;
313 } 313 }
314 else 314 else
315 { 315 {
316 listen_stdio (); 316 listen_stdio ();
317 } 317 }
@@ -563,7 +563,7 @@ path_callback (void *cls,
563 ppd->path_length); 563 ppd->path_length);
564 for (unsigned int i = 0; i < ppd->path_length; i++) 564 for (unsigned int i = 0; i < ppd->path_length; i++)
565 FPRINTF (stdout, 565 FPRINTF (stdout,
566 "%s ", 566 (i == ppd->target_offset) ? "*%s* " : "%s ",
567 GNUNET_i2s (&ppd->path[i])); 567 GNUNET_i2s (&ppd->path[i]));
568 FPRINTF (stdout, 568 FPRINTF (stdout,
569 "\n"); 569 "\n");
@@ -626,7 +626,7 @@ show_peer (void *cls)
626 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, 626 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
627 strlen (peer_id), 627 strlen (peer_id),
628 &pid.public_key)) 628 &pid.public_key))
629 { 629 {
630 fprintf (stderr, 630 fprintf (stderr,
631 _("Invalid peer ID `%s'\n"), 631 _("Invalid peer ID `%s'\n"),
632 peer_id); 632 peer_id);
@@ -859,7 +859,7 @@ main (int argc,
859 GNUNET_GETOPT_option_flag ('e', 859 GNUNET_GETOPT_option_flag ('e',
860 "echo", 860 "echo",
861 gettext_noop ("Activate echo mode"), 861 gettext_noop ("Activate echo mode"),
862 &echo), 862 &echo),
863 GNUNET_GETOPT_option_string ('o', 863 GNUNET_GETOPT_option_string ('o',
864 "open-port", 864 "open-port",
865 "SHARED_SECRET", 865 "SHARED_SECRET",
diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c
index d64242943..e29330f99 100644
--- a/src/cadet/gnunet-service-cadet.c
+++ b/src/cadet/gnunet-service-cadet.c
@@ -886,6 +886,13 @@ path_info_iterator (void *cls,
886 path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; 886 path_size = sizeof (struct GNUNET_PeerIdentity) * path_length;
887 if (sizeof (*resp) + path_size > UINT16_MAX) 887 if (sizeof (*resp) + path_size > UINT16_MAX)
888 { 888 {
889 /* try just giving the relevant path */
890 path_length = GNUNET_MIN ((UINT16_MAX - sizeof (*resp)) / sizeof (struct GNUNET_PeerIdentity),
891 off);
892 path_size = sizeof (struct GNUNET_PeerIdentity) * path_length;
893 }
894 if (sizeof (*resp) + path_size > UINT16_MAX)
895 {
889 LOG (GNUNET_ERROR_TYPE_WARNING, 896 LOG (GNUNET_ERROR_TYPE_WARNING,
890 "Path of %u entries is too long for info message\n", 897 "Path of %u entries is too long for info message\n",
891 path_length); 898 path_length);
@@ -899,9 +906,10 @@ path_info_iterator (void *cls,
899 /* Don't copy first peer. First peer is always the local one. Last 906 /* Don't copy first peer. First peer is always the local one. Last
900 * peer is always the destination (leave as 0, EOL). 907 * peer is always the destination (leave as 0, EOL).
901 */ 908 */
902 for (unsigned int i = 0; i <= off; i++) 909 for (unsigned int i = 0; i < path_length; i++)
903 id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path, 910 id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path,
904 i)); 911 i));
912 resp->off = htonl (off);
905 GNUNET_MQ_send (mq, 913 GNUNET_MQ_send (mq,
906 env); 914 env);
907 return GNUNET_YES; 915 return GNUNET_YES;
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h
index ac3d11216..b8326657d 100644
--- a/src/include/gnunet_cadet_service.h
+++ b/src/include/gnunet_cadet_service.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -369,7 +369,7 @@ GNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel,
369 369
370/** 370/**
371 * Internal details about a channel. 371 * Internal details about a channel.
372 */ 372 */
373struct GNUNET_CADET_ChannelInternals 373struct GNUNET_CADET_ChannelInternals
374{ 374{
375 /** 375 /**
@@ -431,7 +431,7 @@ GNUNET_CADET_get_channel_cancel (struct GNUNET_CADET_ChannelMonitor *cm);
431 431
432/** 432/**
433 * Information we return per peer. 433 * Information we return per peer.
434 */ 434 */
435struct GNUNET_CADET_PeerListEntry 435struct GNUNET_CADET_PeerListEntry
436{ 436{
437 /** 437 /**
@@ -446,7 +446,7 @@ struct GNUNET_CADET_PeerListEntry
446 446
447 /** 447 /**
448 * Number of disjoint known paths to @e peer. 448 * Number of disjoint known paths to @e peer.
449 */ 449 */
450 unsigned int n_paths; 450 unsigned int n_paths;
451 451
452 /** 452 /**
@@ -504,7 +504,7 @@ GNUNET_CADET_list_peers_cancel (struct GNUNET_CADET_PeersLister *pl);
504 504
505/** 505/**
506 * Detailed information we return per peer. 506 * Detailed information we return per peer.
507 */ 507 */
508struct GNUNET_CADET_PeerPathDetail 508struct GNUNET_CADET_PeerPathDetail
509{ 509{
510 /** 510 /**
@@ -513,6 +513,11 @@ struct GNUNET_CADET_PeerPathDetail
513 struct GNUNET_PeerIdentity peer; 513 struct GNUNET_PeerIdentity peer;
514 514
515 /** 515 /**
516 * Offset of the target peer on the @e path.
517 */
518 unsigned int target_offset;
519
520 /**
516 * Number of entries on the @e path. 521 * Number of entries on the @e path.
517 */ 522 */
518 unsigned int path_length; 523 unsigned int path_length;
@@ -583,7 +588,7 @@ struct GNUNET_CADET_TunnelDetails
583 588
584 /** 589 /**
585 * How many channels use the tunnel. 590 * How many channels use the tunnel.
586 */ 591 */
587 uint32_t channels; 592 uint32_t channels;
588 593
589 /** 594 /**
@@ -597,8 +602,8 @@ struct GNUNET_CADET_TunnelDetails
597 uint16_t estate; 602 uint16_t estate;
598 603
599 /** 604 /**
600 * What is our connectivity state? 605 * What is our connectivity state?
601 */ 606 */
602 uint16_t cstate; 607 uint16_t cstate;
603}; 608};
604 609
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index c2256fd0a..fcd422701 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -526,7 +526,7 @@ GNUNET_HELLO_extract_address (const void *raw,
526 * 526 *
527 * @param address a peer's address 527 * @param address a peer's address
528 * @return NULL if the address is mal-formed, otherwise the prefix 528 * @return NULL if the address is mal-formed, otherwise the prefix
529 */ 529 */
530char * 530char *
531GNUNET_HELLO_address_to_prefix (const char *address); 531GNUNET_HELLO_address_to_prefix (const char *address);
532 532
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 793430184..29db8372f 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -3106,40 +3106,47 @@ extern "C"
3106/** 3106/**
3107 * Type of a fragment of a CORE message created by transport to adjust 3107 * Type of a fragment of a CORE message created by transport to adjust
3108 * message length to a queue's MTU. 3108 * message length to a queue's MTU.
3109 */ 3109 */
3110#define GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT 1214 3110#define GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT 1214
3111 3111
3112/** 3112/**
3113 * Acknowledgement generated for a fragment. 3113 * Acknowledgement generated for a fragment.
3114 */ 3114 */
3115#define GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK 1215 3115#define GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK 1215
3116 3116
3117/** 3117/**
3118 * Wrapper around non-fragmented CORE message used to measure RTT 3118 * Wrapper around non-fragmented CORE message used to measure RTT
3119 * and ensure reliability. 3119 * and ensure reliability.
3120 */ 3120 */
3121#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX 1216 3121#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX 1216
3122 3122
3123/** 3123/**
3124 * Confirmation for a #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX. 3124 * Confirmation for a #GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX.
3125 */ 3125 */
3126#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK 1217 3126#define GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK 1217
3127 3127
3128/** 3128/**
3129 * Message sent for topology discovery at transport level. 3129 * Message sent for topology discovery at transport level.
3130 */ 3130 */
3131#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN 1218 3131#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN 1218
3132 3132
3133/** 3133/**
3134 * Source-routed transport message based DV information gathered. 3134 * Source-routed transport message based DV information gathered.
3135 */ 3135 */
3136#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219 3136#define GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX 1219
3137 3137
3138/** 3138/**
3139 * Transport signalling incoming backchannel message to a communicator. 3139 * Transport signalling incoming backchannel message to a communicator.
3140 */ 3140 */
3141#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220 3141#define GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING 1220
3142 3142
3143/**
3144 * We learned a possible network address of another peer. Transport
3145 * should consider verifying it, and if successful, remembering it
3146 * in the Peerstore.
3147 */
3148#define GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY 1221
3149
3143 3150
3144/** 3151/**
3145 * Message sent to indicate to the transport that a monitor 3152 * Message sent to indicate to the transport that a monitor
@@ -3230,7 +3237,7 @@ extern "C"
3230 3237
3231/** 3238/**
3232 * TCP communicator end of stream. 3239 * TCP communicator end of stream.
3233 */ 3240 */
3234#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH 1452 3241#define GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH 1452
3235 3242
3236/** 3243/**
diff --git a/src/include/gnunet_transport_address_service.h b/src/include/gnunet_transport_address_service.h
index 86d0a423e..9f0717d00 100644
--- a/src/include/gnunet_transport_address_service.h
+++ b/src/include/gnunet_transport_address_service.h
@@ -90,11 +90,13 @@ GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *ch);
90 * lost. 90 * lost.
91 * 91 *
92 * @param ch communicator handle 92 * @param ch communicator handle
93 * @param pid peer the address is for
93 * @param raw raw address data 94 * @param raw raw address data
94 * @param raw_size number of bytes in @a raw 95 * @param raw_size number of bytes in @a raw
95 */ 96 */
96void 97void
97GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, 98GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
99 const struct GNUNET_PeerIdentity *pid,
98 const void *raw, 100 const void *raw,
99 const size_t raw_size); 101 const size_t raw_size);
100 102
diff --git a/src/rps/profiler_rps.conf b/src/rps/profiler_rps.conf
index 375015cae..6049da5a0 100644
--- a/src/rps/profiler_rps.conf
+++ b/src/rps/profiler_rps.conf
@@ -84,7 +84,6 @@ DISABLE_TRY_CONNECT = YES
84 84
85[cadet] 85[cadet]
86OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log 86OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log
87PREFIX = valgrind
88 87
89#[arm] 88#[arm]
90#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log 89#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 93615b023..9cf16ddb6 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -154,6 +154,7 @@ endif
154 154
155lib_LTLIBRARIES = \ 155lib_LTLIBRARIES = \
156 libgnunettransport.la \ 156 libgnunettransport.la \
157 libgnunettransportaddress.la \
157 libgnunettransportcore.la \ 158 libgnunettransportcore.la \
158 libgnunettransportcommunicator.la \ 159 libgnunettransportcommunicator.la \
159 libgnunettransportmonitor.la \ 160 libgnunettransportmonitor.la \
@@ -197,6 +198,15 @@ libgnunettransport_la_LDFLAGS = \
197 198
198 199
199 200
201libgnunettransportaddress_la_SOURCES = \
202 transport_api2_address.c
203libgnunettransportaddress_la_LIBADD = \
204 $(top_builddir)/src/util/libgnunetutil.la \
205 $(GN_LIBINTL)
206libgnunettransportaddress_la_LDFLAGS = \
207 $(GN_LIB_LDFLAGS) $(WINFLAGS) \
208 -version-info 0:0:0
209
200libgnunettransportcore_la_SOURCES = \ 210libgnunettransportcore_la_SOURCES = \
201 transport_api2_core.c 211 transport_api2_core.c
202libgnunettransportcore_la_LIBADD = \ 212libgnunettransportcore_la_LIBADD = \
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index a32d1872c..1d6329c21 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -33,16 +33,17 @@
33 * transport-to-transport traffic) 33 * transport-to-transport traffic)
34 * 34 *
35 * Implement next: 35 * Implement next:
36 * - ACK handling / retransmission 36 * - ACK handling / retransmission
37 * - address verification
37 * - track RTT, distance, loss, etc. 38 * - track RTT, distance, loss, etc.
38 * - DV data structures: 39 * - DV data structures:
39 * + learning 40 * + learning
40 * + forgetting 41 * + forgetting
41 * + using them! 42 * + using them!
42 * - routing of messages (using DV data structures!) 43 * - routing of messages (using DV data structures!)
43 * - handling of DV-boxed messages that need to be forwarded 44 * - handling of DV-boxed messages that need to be forwarded
44 * - backchannel message encryption & decryption 45 * - backchannel message encryption & decryption
45 * - 46 * -
46 * 47 *
47 * Easy: 48 * Easy:
48 * - use ATS bandwidth allocation callback and schedule transmissions! 49 * - use ATS bandwidth allocation callback and schedule transmissions!
@@ -59,7 +60,7 @@
59 * (requires planning at receiver, and additional MST-style demultiplex 60 * (requires planning at receiver, and additional MST-style demultiplex
60 * at receiver!) 61 * at receiver!)
61 * - could avoid copying body of message into each fragment and keep 62 * - could avoid copying body of message into each fragment and keep
62 * fragments as just pointers into the original message and only 63 * fragments as just pointers into the original message and only
63 * fully build fragments just before transmission (optimization, should 64 * fully build fragments just before transmission (optimization, should
64 * reduce CPU and memory use) 65 * reduce CPU and memory use)
65 * 66 *
@@ -128,7 +129,7 @@
128/** 129/**
129 * How many messages can we have pending for a given communicator 130 * How many messages can we have pending for a given communicator
130 * process before we start to throttle that communicator? 131 * process before we start to throttle that communicator?
131 * 132 *
132 * Used if a communicator might be CPU-bound and cannot handle the traffic. 133 * Used if a communicator might be CPU-bound and cannot handle the traffic.
133 */ 134 */
134#define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512 135#define COMMUNICATOR_TOTAL_QUEUE_LIMIT 512
@@ -137,7 +138,7 @@
137 * How many messages can we have pending for a given session (queue to 138 * How many messages can we have pending for a given session (queue to
138 * a particular peer via a communicator) process before we start to 139 * a particular peer via a communicator) process before we start to
139 * throttle that queue? 140 * throttle that queue?
140 * 141 *
141 * Used if ATS assigns more bandwidth to a particular transmission 142 * Used if ATS assigns more bandwidth to a particular transmission
142 * method than that transmission method can right now handle. (Yes, 143 * method than that transmission method can right now handle. (Yes,
143 * ATS should eventually notice utilization below allocation and 144 * ATS should eventually notice utilization below allocation and
@@ -182,7 +183,7 @@ struct TransportBackchannelEncapsulationMessage
182 183
183 // FIXME: probably should add random IV here as well, 184 // FIXME: probably should add random IV here as well,
184 // especially if we re-use ephemeral keys! 185 // especially if we re-use ephemeral keys!
185 186
186 /** 187 /**
187 * HMAC over the ciphertext of the encrypted, variable-size 188 * HMAC over the ciphertext of the encrypted, variable-size
188 * body that follows. Verified via DH of @e target and 189 * body that follows. Verified via DH of @e target and
@@ -211,8 +212,8 @@ struct EphemeralConfirmation
211 * only interpret the value as a mononic time and reject 212 * only interpret the value as a mononic time and reject
212 * "older" values than the last one observed. Even with this, 213 * "older" values than the last one observed. Even with this,
213 * there is no real guarantee against replay achieved here, 214 * there is no real guarantee against replay achieved here,
214 * as the latest timestamp is not persisted. This is 215 * as the latest timestamp is not persisted. This is
215 * necessary as we do not want to require synchronized 216 * necessary as we do not want to require synchronized
216 * clocks and may not have a bidirectional communication 217 * clocks and may not have a bidirectional communication
217 * channel. Communicators must protect against replay 218 * channel. Communicators must protect against replay
218 * attacks when using backchannel communication! 219 * attacks when using backchannel communication!
@@ -360,17 +361,17 @@ struct TransportFragmentBox
360 /** 361 /**
361 * Original message ID for of the message that all the1 362 * Original message ID for of the message that all the1
362 * fragments belong to. Must be the same for all fragments. 363 * fragments belong to. Must be the same for all fragments.
363 */ 364 */
364 struct GNUNET_ShortHashCode msg_uuid; 365 struct GNUNET_ShortHashCode msg_uuid;
365 366
366 /** 367 /**
367 * Offset of this fragment in the overall message. 368 * Offset of this fragment in the overall message.
368 */ 369 */
369 uint16_t frag_off GNUNET_PACKED; 370 uint16_t frag_off GNUNET_PACKED;
370 371
371 /** 372 /**
372 * Total size of the message that is being fragmented. 373 * Total size of the message that is being fragmented.
373 */ 374 */
374 uint16_t msg_size GNUNET_PACKED; 375 uint16_t msg_size GNUNET_PACKED;
375 376
376}; 377};
@@ -399,13 +400,13 @@ struct TransportFragmentAckMessage
399 /** 400 /**
400 * Bitfield of up to 64 additional fragments following the 401 * Bitfield of up to 64 additional fragments following the
401 * @e msg_uuid being acknowledged by this message. 402 * @e msg_uuid being acknowledged by this message.
402 */ 403 */
403 uint64_t extra_acks GNUNET_PACKED; 404 uint64_t extra_acks GNUNET_PACKED;
404 405
405 /** 406 /**
406 * Original message ID for of the message that all the 407 * Original message ID for of the message that all the
407 * fragments belong to. 408 * fragments belong to.
408 */ 409 */
409 struct GNUNET_ShortHashCode msg_uuid; 410 struct GNUNET_ShortHashCode msg_uuid;
410 411
411 /** 412 /**
@@ -431,7 +432,7 @@ struct TransportFragmentAckMessage
431 * to a subset of their neighbours to limit discoverability of the 432 * to a subset of their neighbours to limit discoverability of the
432 * network topology). To the extend that the @e bidirectional bits 433 * network topology). To the extend that the @e bidirectional bits
433 * are set, peers may learn the inverse paths even if they did not 434 * are set, peers may learn the inverse paths even if they did not
434 * initiate. 435 * initiate.
435 * 436 *
436 * Unless received on a bidirectional queue and @e num_hops just 437 * Unless received on a bidirectional queue and @e num_hops just
437 * zero, peers that can forward to the initator should always try to 438 * zero, peers that can forward to the initator should always try to
@@ -456,13 +457,13 @@ struct TransportDVLearn
456 * to possibly instantly learn a path in both directions. Each peer 457 * to possibly instantly learn a path in both directions. Each peer
457 * should shift this value by one to the left, and then set the 458 * should shift this value by one to the left, and then set the
458 * lowest bit IF the current sender can be reached from it (without 459 * lowest bit IF the current sender can be reached from it (without
459 * DV routing). 460 * DV routing).
460 */ 461 */
461 uint16_t bidirectional GNUNET_PACKED; 462 uint16_t bidirectional GNUNET_PACKED;
462 463
463 /** 464 /**
464 * Peers receiving this message and delaying forwarding to other 465 * Peers receiving this message and delaying forwarding to other
465 * peers for any reason should increment this value such as to 466 * peers for any reason should increment this value such as to
466 * enable the origin to determine the actual network-only delay 467 * enable the origin to determine the actual network-only delay
467 * in addition to the real-time delay (assuming the message loops 468 * in addition to the real-time delay (assuming the message loops
468 * back to the origin). 469 * back to the origin).
@@ -473,11 +474,11 @@ struct TransportDVLearn
473 * Identity of the peer that started this learning activity. 474 * Identity of the peer that started this learning activity.
474 */ 475 */
475 struct GNUNET_PeerIdentity initiator; 476 struct GNUNET_PeerIdentity initiator;
476 477
477 /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values, 478 /* Followed by @e num_hops `struct GNUNET_PeerIdentity` values,
478 excluding the initiator of the DV trace; the last entry is the 479 excluding the initiator of the DV trace; the last entry is the
479 current sender; the current peer must not be included. */ 480 current sender; the current peer must not be included. */
480 481
481}; 482};
482 483
483 484
@@ -514,7 +515,7 @@ struct TransportDVBox
514 * Number of hops this messages includes. In NBO. 515 * Number of hops this messages includes. In NBO.
515 */ 516 */
516 uint16_t num_hops GNUNET_PACKED; 517 uint16_t num_hops GNUNET_PACKED;
517 518
518 /** 519 /**
519 * Identity of the peer that originated the message. 520 * Identity of the peer that originated the message.
520 */ 521 */
@@ -564,7 +565,7 @@ enum ClientType
564/** 565/**
565 * Entry in our cache of ephemeral keys we currently use. 566 * Entry in our cache of ephemeral keys we currently use.
566 * This way, we only sign an ephemeral once per @e target, 567 * This way, we only sign an ephemeral once per @e target,
567 * and then can re-use it over multiple 568 * and then can re-use it over multiple
568 * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION 569 * #GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION
569 * messages (as signing is expensive). 570 * messages (as signing is expensive).
570 */ 571 */
@@ -632,39 +633,39 @@ struct DistanceVectorHop
632 633
633 /** 634 /**
634 * Kept in a MDLL, sorted by @e timeout. 635 * Kept in a MDLL, sorted by @e timeout.
635 */ 636 */
636 struct DistanceVectorHop *next_dv; 637 struct DistanceVectorHop *next_dv;
637 638
638 /** 639 /**
639 * Kept in a MDLL, sorted by @e timeout. 640 * Kept in a MDLL, sorted by @e timeout.
640 */ 641 */
641 struct DistanceVectorHop *prev_dv; 642 struct DistanceVectorHop *prev_dv;
642 643
643 /** 644 /**
644 * Kept in a MDLL. 645 * Kept in a MDLL.
645 */ 646 */
646 struct DistanceVectorHop *next_neighbour; 647 struct DistanceVectorHop *next_neighbour;
647 648
648 /** 649 /**
649 * Kept in a MDLL. 650 * Kept in a MDLL.
650 */ 651 */
651 struct DistanceVectorHop *prev_neighbour; 652 struct DistanceVectorHop *prev_neighbour;
652 653
653 /** 654 /**
654 * What would be the next hop to @e target? 655 * What would be the next hop to @e target?
655 */ 656 */
656 struct Neighbour *next_hop; 657 struct Neighbour *next_hop;
657 658
658 /** 659 /**
659 * Distance vector entry this hop belongs with. 660 * Distance vector entry this hop belongs with.
660 */ 661 */
661 struct DistanceVector *dv; 662 struct DistanceVector *dv;
662 663
663 /** 664 /**
664 * Array of @e distance hops to the target, excluding @e next_hop. 665 * Array of @e distance hops to the target, excluding @e next_hop.
665 * NULL if the entire path is us to @e next_hop to `target`. Allocated 666 * NULL if the entire path is us to @e next_hop to `target`. Allocated
666 * at the end of this struct. 667 * at the end of this struct.
667 */ 668 */
668 const struct GNUNET_PeerIdentity *path; 669 const struct GNUNET_PeerIdentity *path;
669 670
670 /** 671 /**
@@ -672,11 +673,11 @@ struct DistanceVectorHop
672 * while learning? 673 * while learning?
673 */ 674 */
674 struct GNUNET_TIME_Absolute timeout; 675 struct GNUNET_TIME_Absolute timeout;
675 676
676 /** 677 /**
677 * How many hops in total to the `target` (excluding @e next_hop and `target` itself), 678 * How many hops in total to the `target` (excluding @e next_hop and `target` itself),
678 * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)? 679 * thus 0 still means a distance of 2 hops (to @e next_hop and then to `target`)?
679 */ 680 */
680 unsigned int distance; 681 unsigned int distance;
681}; 682};
682 683
@@ -695,12 +696,12 @@ struct DistanceVector
695 696
696 /** 697 /**
697 * Known paths to @e target. 698 * Known paths to @e target.
698 */ 699 */
699 struct DistanceVectorHop *dv_head; 700 struct DistanceVectorHop *dv_head;
700 701
701 /** 702 /**
702 * Known paths to @e target. 703 * Known paths to @e target.
703 */ 704 */
704 struct DistanceVectorHop *dv_tail; 705 struct DistanceVectorHop *dv_tail;
705 706
706 /** 707 /**
@@ -724,19 +725,19 @@ struct QueueEntry
724 725
725 /** 726 /**
726 * Kept as a DLL. 727 * Kept as a DLL.
727 */ 728 */
728 struct QueueEntry *next; 729 struct QueueEntry *next;
729 730
730 /** 731 /**
731 * Kept as a DLL. 732 * Kept as a DLL.
732 */ 733 */
733 struct QueueEntry *prev; 734 struct QueueEntry *prev;
734 735
735 /** 736 /**
736 * ATS session this entry is queued with. 737 * ATS session this entry is queued with.
737 */ 738 */
738 struct GNUNET_ATS_Session *session; 739 struct GNUNET_ATS_Session *session;
739 740
740 /** 741 /**
741 * Message ID used for this message with the queue used for transmission. 742 * Message ID used for this message with the queue used for transmission.
742 */ 743 */
@@ -772,12 +773,12 @@ struct GNUNET_ATS_Session
772 773
773 /** 774 /**
774 * Head of DLL of unacked transmission requests. 775 * Head of DLL of unacked transmission requests.
775 */ 776 */
776 struct QueueEntry *queue_head; 777 struct QueueEntry *queue_head;
777 778
778 /** 779 /**
779 * End of DLL of unacked transmission requests. 780 * End of DLL of unacked transmission requests.
780 */ 781 */
781 struct QueueEntry *queue_tail; 782 struct QueueEntry *queue_tail;
782 783
783 /** 784 /**
@@ -803,9 +804,9 @@ struct GNUNET_ATS_Session
803 /** 804 /**
804 * Task scheduled for the time when this queue can (likely) transmit the 805 * Task scheduled for the time when this queue can (likely) transmit the
805 * next message. Still needs to check with the @e tracker_out to be sure. 806 * next message. Still needs to check with the @e tracker_out to be sure.
806 */ 807 */
807 struct GNUNET_SCHEDULER_Task *transmit_task; 808 struct GNUNET_SCHEDULER_Task *transmit_task;
808 809
809 /** 810 /**
810 * Our current RTT estimate for this ATS session. 811 * Our current RTT estimate for this ATS session.
811 */ 812 */
@@ -813,9 +814,9 @@ struct GNUNET_ATS_Session
813 814
814 /** 815 /**
815 * Message ID generator for transmissions on this queue. 816 * Message ID generator for transmissions on this queue.
816 */ 817 */
817 uint64_t mid_gen; 818 uint64_t mid_gen;
818 819
819 /** 820 /**
820 * Unique identifier of this ATS session with the communicator. 821 * Unique identifier of this ATS session with the communicator.
821 */ 822 */
@@ -845,7 +846,7 @@ struct GNUNET_ATS_Session
845 * Length of the DLL starting at @e queue_head. 846 * Length of the DLL starting at @e queue_head.
846 */ 847 */
847 unsigned int queue_length; 848 unsigned int queue_length;
848 849
849 /** 850 /**
850 * Network type offered by this ATS session. 851 * Network type offered by this ATS session.
851 */ 852 */
@@ -870,14 +871,14 @@ struct GNUNET_ATS_Session
870 871
871/** 872/**
872 * Information we keep for a message that we are reassembling. 873 * Information we keep for a message that we are reassembling.
873 */ 874 */
874struct ReassemblyContext 875struct ReassemblyContext
875{ 876{
876 877
877 /** 878 /**
878 * Original message ID for of the message that all the 879 * Original message ID for of the message that all the
879 * fragments belong to. 880 * fragments belong to.
880 */ 881 */
881 struct GNUNET_ShortHashCode msg_uuid; 882 struct GNUNET_ShortHashCode msg_uuid;
882 883
883 /** 884 /**
@@ -887,7 +888,7 @@ struct ReassemblyContext
887 888
888 /** 889 /**
889 * Entry in the reassembly heap (sorted by expiration). 890 * Entry in the reassembly heap (sorted by expiration).
890 */ 891 */
891 struct GNUNET_CONTAINER_HeapNode *hn; 892 struct GNUNET_CONTAINER_HeapNode *hn;
892 893
893 /** 894 /**
@@ -905,7 +906,7 @@ struct ReassemblyContext
905 * task is for the latter case. 906 * task is for the latter case.
906 */ 907 */
907 struct GNUNET_SCHEDULER_Task *ack_task; 908 struct GNUNET_SCHEDULER_Task *ack_task;
908 909
909 /** 910 /**
910 * At what time will we give up reassembly of this message? 911 * At what time will we give up reassembly of this message?
911 */ 912 */
@@ -928,7 +929,7 @@ struct ReassemblyContext
928 * to be acknowledged in the next cummulative ACK. 929 * to be acknowledged in the next cummulative ACK.
929 */ 930 */
930 uint64_t extra_acks; 931 uint64_t extra_acks;
931 932
932 /** 933 /**
933 * Unique ID of the lowest fragment UUID to be acknowledged in the 934 * Unique ID of the lowest fragment UUID to be acknowledged in the
934 * next cummulative ACK. Only valid if @e num_acks > 0. 935 * next cummulative ACK. Only valid if @e num_acks > 0.
@@ -940,7 +941,7 @@ struct ReassemblyContext
940 * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK. 941 * whenever we send a #GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT_ACK.
941 */ 942 */
942 unsigned int num_acks; 943 unsigned int num_acks;
943 944
944 /** 945 /**
945 * How big is the message we are reassembling in total? 946 * How big is the message we are reassembling in total?
946 */ 947 */
@@ -973,21 +974,21 @@ struct Neighbour
973 * Map with `struct ReassemblyContext` structs for fragments under 974 * Map with `struct ReassemblyContext` structs for fragments under
974 * reassembly. May be NULL if we currently have no fragments from 975 * reassembly. May be NULL if we currently have no fragments from
975 * this @e pid (lazy initialization). 976 * this @e pid (lazy initialization).
976 */ 977 */
977 struct GNUNET_CONTAINER_MultiShortmap *reassembly_map; 978 struct GNUNET_CONTAINER_MultiShortmap *reassembly_map;
978 979
979 /** 980 /**
980 * Heap with `struct ReassemblyContext` structs for fragments under 981 * Heap with `struct ReassemblyContext` structs for fragments under
981 * reassembly. May be NULL if we currently have no fragments from 982 * reassembly. May be NULL if we currently have no fragments from
982 * this @e pid (lazy initialization). 983 * this @e pid (lazy initialization).
983 */ 984 */
984 struct GNUNET_CONTAINER_Heap *reassembly_heap; 985 struct GNUNET_CONTAINER_Heap *reassembly_heap;
985 986
986 /** 987 /**
987 * Task to free old entries from the @e reassembly_heap and @e reassembly_map. 988 * Task to free old entries from the @e reassembly_heap and @e reassembly_map.
988 */ 989 */
989 struct GNUNET_SCHEDULER_Task *reassembly_timeout_task; 990 struct GNUNET_SCHEDULER_Task *reassembly_timeout_task;
990 991
991 /** 992 /**
992 * Head of list of messages pending for this neighbour. 993 * Head of list of messages pending for this neighbour.
993 */ 994 */
@@ -1001,13 +1002,13 @@ struct Neighbour
1001 /** 1002 /**
1002 * Head of MDLL of DV hops that have this neighbour as next hop. Must be 1003 * Head of MDLL of DV hops that have this neighbour as next hop. Must be
1003 * purged if this neighbour goes down. 1004 * purged if this neighbour goes down.
1004 */ 1005 */
1005 struct DistanceVectorHop *dv_head; 1006 struct DistanceVectorHop *dv_head;
1006 1007
1007 /** 1008 /**
1008 * Tail of MDLL of DV hops that have this neighbour as next hop. Must be 1009 * Tail of MDLL of DV hops that have this neighbour as next hop. Must be
1009 * purged if this neighbour goes down. 1010 * purged if this neighbour goes down.
1010 */ 1011 */
1011 struct DistanceVectorHop *dv_tail; 1012 struct DistanceVectorHop *dv_tail;
1012 1013
1013 /** 1014 /**
@@ -1022,7 +1023,7 @@ struct Neighbour
1022 1023
1023 /** 1024 /**
1024 * Task run to cleanup pending messages that have exceeded their timeout. 1025 * Task run to cleanup pending messages that have exceeded their timeout.
1025 */ 1026 */
1026 struct GNUNET_SCHEDULER_Task *timeout_task; 1027 struct GNUNET_SCHEDULER_Task *timeout_task;
1027 1028
1028 /** 1029 /**
@@ -1039,15 +1040,15 @@ struct Neighbour
1039 1040
1040 /** 1041 /**
1041 * What is the earliest timeout of any message in @e pending_msg_tail? 1042 * What is the earliest timeout of any message in @e pending_msg_tail?
1042 */ 1043 */
1043 struct GNUNET_TIME_Absolute earliest_timeout; 1044 struct GNUNET_TIME_Absolute earliest_timeout;
1044 1045
1045}; 1046};
1046 1047
1047 1048
1048/** 1049/**
1049 * Types of different pending messages. 1050 * Types of different pending messages.
1050 */ 1051 */
1051enum PendingMessageType 1052enum PendingMessageType
1052{ 1053{
1053 1054
@@ -1071,7 +1072,7 @@ enum PendingMessageType
1071 */ 1072 */
1072 PMT_ACKNOWLEDGEMENT = 3 1073 PMT_ACKNOWLEDGEMENT = 3
1073 1074
1074 1075
1075}; 1076};
1076 1077
1077 1078
@@ -1088,13 +1089,13 @@ enum PendingMessageType
1088 * either calculate the next fragment (based on @e frag_off) from the 1089 * either calculate the next fragment (based on @e frag_off) from the
1089 * current node, or, if all fragments have already been created, 1090 * current node, or, if all fragments have already been created,
1090 * descend to the @e head_frag. Even though the node was already 1091 * descend to the @e head_frag. Even though the node was already
1091 * fragmented, the fragment may be too big if the fragment was 1092 * fragmented, the fragment may be too big if the fragment was
1092 * generated for a queue with a larger MTU. In this case, the node 1093 * generated for a queue with a larger MTU. In this case, the node
1093 * may be fragmented again, thus creating a tree. 1094 * may be fragmented again, thus creating a tree.
1094 * 1095 *
1095 * When acknowledgements for fragments are received, the tree 1096 * When acknowledgements for fragments are received, the tree
1096 * must be pruned, removing those parts that were already 1097 * must be pruned, removing those parts that were already
1097 * acknowledged. When fragments are sent over a reliable 1098 * acknowledged. When fragments are sent over a reliable
1098 * channel, they can be immediately removed. 1099 * channel, they can be immediately removed.
1099 * 1100 *
1100 * If a message is ever fragmented, then the original "full" message 1101 * If a message is ever fragmented, then the original "full" message
@@ -1117,7 +1118,7 @@ struct PendingMessage
1117 * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) 1118 * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE)
1118 */ 1119 */
1119 struct PendingMessage *next_client; 1120 struct PendingMessage *next_client;
1120 1121
1121 /** 1122 /**
1122 * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE) 1123 * Kept in a MDLL of messages from this @a client (if @e pmt is #PMT_CORE)
1123 */ 1124 */
@@ -1127,7 +1128,7 @@ struct PendingMessage
1127 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx) 1128 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOx)
1128 */ 1129 */
1129 struct PendingMessage *next_frag; 1130 struct PendingMessage *next_frag;
1130 1131
1131 /** 1132 /**
1132 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX) 1133 * Kept in a MDLL of messages from this @a cpm (if @e pmt is #PMT_FRAGMENT_BOX)
1133 */ 1134 */
@@ -1135,24 +1136,24 @@ struct PendingMessage
1135 1136
1136 /** 1137 /**
1137 * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE. 1138 * This message, reliability boxed. Only possibly available if @e pmt is #PMT_CORE.
1138 */ 1139 */
1139 struct PendingMessage *bpm; 1140 struct PendingMessage *bpm;
1140 1141
1141 /** 1142 /**
1142 * Target of the request. 1143 * Target of the request.
1143 */ 1144 */
1144 struct Neighbour *target; 1145 struct Neighbour *target;
1145 1146
1146 /** 1147 /**
1147 * Client that issued the transmission request, if @e pmt is #PMT_CORE. 1148 * Client that issued the transmission request, if @e pmt is #PMT_CORE.
1148 */ 1149 */
1149 struct TransportClient *client; 1150 struct TransportClient *client;
1150 1151
1151 /** 1152 /**
1152 * Head of a MDLL of fragments created for this core message. 1153 * Head of a MDLL of fragments created for this core message.
1153 */ 1154 */
1154 struct PendingMessage *head_frag; 1155 struct PendingMessage *head_frag;
1155 1156
1156 /** 1157 /**
1157 * Tail of a MDLL of fragments created for this core message. 1158 * Tail of a MDLL of fragments created for this core message.
1158 */ 1159 */
@@ -1162,7 +1163,7 @@ struct PendingMessage
1162 * Our parent in the fragmentation tree. 1163 * Our parent in the fragmentation tree.
1163 */ 1164 */
1164 struct PendingMessage *frag_parent; 1165 struct PendingMessage *frag_parent;
1165 1166
1166 /** 1167 /**
1167 * At what time should we give up on the transmission (and no longer retry)? 1168 * At what time should we give up on the transmission (and no longer retry)?
1168 */ 1169 */
@@ -1178,12 +1179,12 @@ struct PendingMessage
1178 * initialized if @e msg_uuid_set is #GNUNET_YES). 1179 * initialized if @e msg_uuid_set is #GNUNET_YES).
1179 */ 1180 */
1180 struct GNUNET_ShortHashCode msg_uuid; 1181 struct GNUNET_ShortHashCode msg_uuid;
1181 1182
1182 /** 1183 /**
1183 * Counter incremented per generated fragment. 1184 * Counter incremented per generated fragment.
1184 */ 1185 */
1185 uint32_t frag_uuidgen; 1186 uint32_t frag_uuidgen;
1186 1187
1187 /** 1188 /**
1188 * Type of the pending message. 1189 * Type of the pending message.
1189 */ 1190 */
@@ -1196,14 +1197,14 @@ struct PendingMessage
1196 1197
1197 /** 1198 /**
1198 * Offset at which we should generate the next fragment. 1199 * Offset at which we should generate the next fragment.
1199 */ 1200 */
1200 uint16_t frag_off; 1201 uint16_t frag_off;
1201 1202
1202 /** 1203 /**
1203 * #GNUNET_YES once @e msg_uuid was initialized 1204 * #GNUNET_YES once @e msg_uuid was initialized
1204 */ 1205 */
1205 int16_t msg_uuid_set; 1206 int16_t msg_uuid_set;
1206 1207
1207 /* Followed by @e bytes_msg to transmit */ 1208 /* Followed by @e bytes_msg to transmit */
1208}; 1209};
1209 1210
@@ -1303,7 +1304,7 @@ struct TransportClient
1303 struct { 1304 struct {
1304 1305
1305 /** 1306 /**
1306 * Head of list of messages pending for this client, sorted by 1307 * Head of list of messages pending for this client, sorted by
1307 * transmission time ("next_attempt" + possibly internal prioritization). 1308 * transmission time ("next_attempt" + possibly internal prioritization).
1308 */ 1309 */
1309 struct PendingMessage *pending_msg_head; 1310 struct PendingMessage *pending_msg_head;
@@ -1371,7 +1372,7 @@ struct TransportClient
1371 * is globally unable to keep up. 1372 * is globally unable to keep up.
1372 */ 1373 */
1373 unsigned int total_queue_length; 1374 unsigned int total_queue_length;
1374 1375
1375 /** 1376 /**
1376 * Characteristics of this communicator. 1377 * Characteristics of this communicator.
1377 */ 1378 */
@@ -1546,7 +1547,7 @@ free_distance_vector_hop (struct DistanceVectorHop *dvh)
1546 GNUNET_free (dvh); 1547 GNUNET_free (dvh);
1547 if (NULL == dv->dv_head) 1548 if (NULL == dv->dv_head)
1548 { 1549 {
1549 GNUNET_assert (GNUNET_YES == 1550 GNUNET_assert (GNUNET_YES ==
1550 GNUNET_CONTAINER_multipeermap_remove (dv_routes, 1551 GNUNET_CONTAINER_multipeermap_remove (dv_routes,
1551 &dv->target, 1552 &dv->target,
1552 dv)); 1553 dv));
@@ -1751,7 +1752,7 @@ free_reassembly_cb (void *cls,
1751 struct ReassemblyContext *rc = value; 1752 struct ReassemblyContext *rc = value;
1752 (void) cls; 1753 (void) cls;
1753 (void) key; 1754 (void) key;
1754 1755
1755 free_reassembly_context (rc); 1756 free_reassembly_context (rc);
1756 return GNUNET_OK; 1757 return GNUNET_OK;
1757} 1758}
@@ -1766,7 +1767,7 @@ static void
1766free_neighbour (struct Neighbour *neighbour) 1767free_neighbour (struct Neighbour *neighbour)
1767{ 1768{
1768 struct DistanceVectorHop *dvh; 1769 struct DistanceVectorHop *dvh;
1769 1770
1770 GNUNET_assert (NULL == neighbour->session_head); 1771 GNUNET_assert (NULL == neighbour->session_head);
1771 GNUNET_assert (GNUNET_YES == 1772 GNUNET_assert (GNUNET_YES ==
1772 GNUNET_CONTAINER_multipeermap_remove (neighbours, 1773 GNUNET_CONTAINER_multipeermap_remove (neighbours,
@@ -1868,25 +1869,25 @@ cores_send_disconnect_info (const struct GNUNET_PeerIdentity *pid)
1868 1869
1869/** 1870/**
1870 * We believe we are ready to transmit a message on a queue. Double-checks 1871 * We believe we are ready to transmit a message on a queue. Double-checks
1871 * with the queue's "tracker_out" and then gives the message to the 1872 * with the queue's "tracker_out" and then gives the message to the
1872 * communicator for transmission (updating the tracker, and re-scheduling 1873 * communicator for transmission (updating the tracker, and re-scheduling
1873 * itself if applicable). 1874 * itself if applicable).
1874 * 1875 *
1875 * @param cls the `struct GNUNET_ATS_Session` to process transmissions for 1876 * @param cls the `struct GNUNET_ATS_Session` to process transmissions for
1876 */ 1877 */
1877static void 1878static void
1878transmit_on_queue (void *cls); 1879transmit_on_queue (void *cls);
1879 1880
1880 1881
1881/** 1882/**
1882 * Schedule next run of #transmit_on_queue(). Does NOTHING if 1883 * Schedule next run of #transmit_on_queue(). Does NOTHING if
1883 * we should run immediately or if the message queue is empty. 1884 * we should run immediately or if the message queue is empty.
1884 * Test for no task being added AND queue not being empty to 1885 * Test for no task being added AND queue not being empty to
1885 * transmit immediately afterwards! This function must only 1886 * transmit immediately afterwards! This function must only
1886 * be called if the message queue is non-empty! 1887 * be called if the message queue is non-empty!
1887 * 1888 *
1888 * @param queue the queue to do scheduling for 1889 * @param queue the queue to do scheduling for
1889 */ 1890 */
1890static void 1891static void
1891schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue) 1892schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue)
1892{ 1893{
@@ -1901,7 +1902,7 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue)
1901 GNUNET_STATISTICS_update (GST_stats, 1902 GNUNET_STATISTICS_update (GST_stats,
1902 "# Transmission throttled due to communicator queue limit", 1903 "# Transmission throttled due to communicator queue limit",
1903 1, 1904 1,
1904 GNUNET_NO); 1905 GNUNET_NO);
1905 return; 1906 return;
1906 } 1907 }
1907 if (queue->queue_length >= SESSION_QUEUE_LIMIT) 1908 if (queue->queue_length >= SESSION_QUEUE_LIMIT)
@@ -1909,10 +1910,10 @@ schedule_transmit_on_queue (struct GNUNET_ATS_Session *queue)
1909 GNUNET_STATISTICS_update (GST_stats, 1910 GNUNET_STATISTICS_update (GST_stats,
1910 "# Transmission throttled due to session queue limit", 1911 "# Transmission throttled due to session queue limit",
1911 1, 1912 1,
1912 GNUNET_NO); 1913 GNUNET_NO);
1913 return; 1914 return;
1914 } 1915 }
1915 1916
1916 wsize = (0 == queue->mtu) 1917 wsize = (0 == queue->mtu)
1917 ? pm->bytes_msg /* FIXME: add overheads? */ 1918 ? pm->bytes_msg /* FIXME: add overheads? */
1918 : queue->mtu; 1919 : queue->mtu;
@@ -2200,7 +2201,7 @@ check_client_send (void *cls,
2200 * Free fragment tree below @e root, excluding @e root itself. 2201 * Free fragment tree below @e root, excluding @e root itself.
2201 * 2202 *
2202 * @param root root of the tree to free 2203 * @param root root of the tree to free
2203 */ 2204 */
2204static void 2205static void
2205free_fragment_tree (struct PendingMessage *root) 2206free_fragment_tree (struct PendingMessage *root)
2206{ 2207{
@@ -2315,7 +2316,7 @@ check_queue_timeouts (void *cls)
2315 GNUNET_NO); 2316 GNUNET_NO);
2316 client_send_response (pm, 2317 client_send_response (pm,
2317 GNUNET_NO, 2318 GNUNET_NO,
2318 0); 2319 0);
2319 continue; 2320 continue;
2320 } 2321 }
2321 earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout, 2322 earliest_timeout = GNUNET_TIME_absolute_min (earliest_timeout,
@@ -2394,7 +2395,7 @@ handle_client_send (void *cls,
2394 target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us; 2395 target->earliest_timeout.abs_value_us = pm->timeout.abs_value_us;
2395 if (NULL != target->timeout_task) 2396 if (NULL != target->timeout_task)
2396 GNUNET_SCHEDULER_cancel (target->timeout_task); 2397 GNUNET_SCHEDULER_cancel (target->timeout_task);
2397 target->timeout_task 2398 target->timeout_task
2398 = GNUNET_SCHEDULER_add_at (target->earliest_timeout, 2399 = GNUNET_SCHEDULER_add_at (target->earliest_timeout,
2399 &check_queue_timeouts, 2400 &check_queue_timeouts,
2400 target); 2401 target);
@@ -2529,7 +2530,7 @@ expire_ephemerals (void *cls)
2529 * one, cache it and return it. 2530 * one, cache it and return it.
2530 * 2531 *
2531 * @param pid peer to look up ephemeral for 2532 * @param pid peer to look up ephemeral for
2532 * @param private_key[out] set to the private key 2533 * @param private_key[out] set to the private key
2533 * @param ephemeral_key[out] set to the key 2534 * @param ephemeral_key[out] set to the key
2534 * @param ephemeral_sender_sig[out] set to the signature 2535 * @param ephemeral_sender_sig[out] set to the signature
2535 * @param ephemeral_validity[out] set to the validity expiration time 2536 * @param ephemeral_validity[out] set to the validity expiration time
@@ -2543,7 +2544,7 @@ lookup_ephemeral (const struct GNUNET_PeerIdentity *pid,
2543{ 2544{
2544 struct EphemeralCacheEntry *ece; 2545 struct EphemeralCacheEntry *ece;
2545 struct EphemeralConfirmation ec; 2546 struct EphemeralConfirmation ec;
2546 2547
2547 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map, 2548 ece = GNUNET_CONTAINER_multipeermap_get (ephemeral_map,
2548 pid); 2549 pid);
2549 if ( (NULL != ece) && 2550 if ( (NULL != ece) &&
@@ -2605,7 +2606,7 @@ route_message (const struct GNUNET_PeerIdentity *target,
2605 GNUNET_free (hdr); 2606 GNUNET_free (hdr);
2606} 2607}
2607 2608
2608 2609
2609/** 2610/**
2610 * Communicator requests backchannel transmission. Process the request. 2611 * Communicator requests backchannel transmission. Process the request.
2611 * 2612 *
@@ -2623,7 +2624,7 @@ handle_communicator_backchannel (void *cls,
2623 struct TransportBackchannelRequestPayload ppay; 2624 struct TransportBackchannelRequestPayload ppay;
2624 char *mpos; 2625 char *mpos;
2625 uint16_t msize; 2626 uint16_t msize;
2626 2627
2627 /* encapsulate and encrypt message */ 2628 /* encapsulate and encrypt message */
2628 msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload); 2629 msize = ntohs (cb->header.size) - sizeof (*cb) + sizeof (struct TransportBackchannelRequestPayload);
2629 enc = GNUNET_malloc (sizeof (*enc) + msize); 2630 enc = GNUNET_malloc (sizeof (*enc) + msize);
@@ -2858,7 +2859,7 @@ struct CommunicatorMessageContext
2858 * 2859 *
2859 * @param cmc context for demultiplexing 2860 * @param cmc context for demultiplexing
2860 * @param msg message to demultiplex 2861 * @param msg message to demultiplex
2861 */ 2862 */
2862static void 2863static void
2863demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, 2864demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
2864 const struct GNUNET_MessageHeader *msg); 2865 const struct GNUNET_MessageHeader *msg);
@@ -2936,7 +2937,7 @@ handle_raw_message (void *cls,
2936 env); 2937 env);
2937 } 2938 }
2938 /* FIXME: consider doing this _only_ once the message 2939 /* FIXME: consider doing this _only_ once the message
2939 was drained from the CORE MQs to extend flow control to CORE! 2940 was drained from the CORE MQs to extend flow control to CORE!
2940 (basically, increment counter in cmc, decrement on MQ send continuation! */ 2941 (basically, increment counter in cmc, decrement on MQ send continuation! */
2941 finish_cmc_handling (cmc); 2942 finish_cmc_handling (cmc);
2942} 2943}
@@ -2961,12 +2962,12 @@ check_fragment_box (void *cls,
2961 GNUNET_break_op (0); 2962 GNUNET_break_op (0);
2962 return GNUNET_SYSERR; 2963 return GNUNET_SYSERR;
2963 } 2964 }
2964 if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size)) 2965 if (bsize + ntohs (fb->frag_off) > ntohs (fb->msg_size))
2965 { 2966 {
2966 GNUNET_break_op (0); 2967 GNUNET_break_op (0);
2967 return GNUNET_SYSERR; 2968 return GNUNET_SYSERR;
2968 } 2969 }
2969 if (ntohs (fb->frag_off) >= ntohs (fb->msg_size)) 2970 if (ntohs (fb->frag_off) >= ntohs (fb->msg_size))
2970 { 2971 {
2971 GNUNET_break_op (0); 2972 GNUNET_break_op (0);
2972 return GNUNET_SYSERR; 2973 return GNUNET_SYSERR;
@@ -3033,7 +3034,7 @@ handle_fragment_box (void *cls,
3033 if (NULL == n) 3034 if (NULL == n)
3034 { 3035 {
3035 struct GNUNET_SERVICE_Client *client = cmc->tc->client; 3036 struct GNUNET_SERVICE_Client *client = cmc->tc->client;
3036 3037
3037 GNUNET_break (0); 3038 GNUNET_break (0);
3038 finish_cmc_handling (cmc); 3039 finish_cmc_handling (cmc);
3039 GNUNET_SERVICE_client_drop (client); 3040 GNUNET_SERVICE_client_drop (client);
@@ -3083,7 +3084,7 @@ handle_fragment_box (void *cls,
3083 finish_cmc_handling (cmc); 3084 finish_cmc_handling (cmc);
3084 return; 3085 return;
3085 } 3086 }
3086 3087
3087 /* reassemble */ 3088 /* reassemble */
3088 fsize = ntohs (fb->header.size) - sizeof (*fb); 3089 fsize = ntohs (fb->header.size) - sizeof (*fb);
3089 frag_off = ntohs (fb->frag_off); 3090 frag_off = ntohs (fb->frag_off);
@@ -3099,7 +3100,7 @@ handle_fragment_box (void *cls,
3099 rc->msg_missing--; 3100 rc->msg_missing--;
3100 } 3101 }
3101 } 3102 }
3102 3103
3103 /* Compute cummulative ACK */ 3104 /* Compute cummulative ACK */
3104 frag_uuid = ntohl (fb->frag_uuid); 3105 frag_uuid = ntohl (fb->frag_uuid);
3105 cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag); 3106 cdelay = GNUNET_TIME_absolute_get_duration (rc->last_frag);
@@ -3138,7 +3139,7 @@ handle_fragment_box (void *cls,
3138 ( (rc->frag_uuid < frag_uuid + 64) && 3139 ( (rc->frag_uuid < frag_uuid + 64) &&
3139 (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) ) 3140 (rc->extra_acks == (rc->extra_acks & ~ ((1LLU << (64 - (rc->frag_uuid - frag_uuid))) - 1LLU))) ) ) )
3140 { 3141 {
3141 /* can fit ack by shifting extra acks and starting at 3142 /* can fit ack by shifting extra acks and starting at
3142 frag_uid, test above esured that the bits we will 3143 frag_uid, test above esured that the bits we will
3143 shift 'extra_acks' by are all zero. */ 3144 shift 'extra_acks' by are all zero. */
3144 rc->extra_acks <<= (rc->frag_uuid - frag_uuid); 3145 rc->extra_acks <<= (rc->frag_uuid - frag_uuid);
@@ -3149,8 +3150,8 @@ handle_fragment_box (void *cls,
3149 if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */ 3150 if (65 == rc->num_acks) /* FIXME: maybe use smaller threshold? This is very aggressive. */
3150 ack_now = GNUNET_YES; /* maximum acks received */ 3151 ack_now = GNUNET_YES; /* maximum acks received */
3151 // FIXME: possibly also ACK based on RTT (but for that we'd need to 3152 // FIXME: possibly also ACK based on RTT (but for that we'd need to
3152 // determine the session used for the ACK first!) 3153 // determine the session used for the ACK first!)
3153 3154
3154 /* is reassembly complete? */ 3155 /* is reassembly complete? */
3155 if (0 != rc->msg_missing) 3156 if (0 != rc->msg_missing)
3156 { 3157 {
@@ -3174,7 +3175,7 @@ handle_fragment_box (void *cls,
3174 msg); 3175 msg);
3175 /* FIXME: really free here? Might be bad if fragments are still 3176 /* FIXME: really free here? Might be bad if fragments are still
3176 en-route and we forget that we finished this reassembly immediately! 3177 en-route and we forget that we finished this reassembly immediately!
3177 -> keep around until timeout? 3178 -> keep around until timeout?
3178 -> shorten timeout based on ACK? */ 3179 -> shorten timeout based on ACK? */
3179 free_reassembly_context (rc); 3180 free_reassembly_context (rc);
3180} 3181}
@@ -3191,7 +3192,7 @@ handle_fragment_ack (void *cls,
3191 const struct TransportFragmentAckMessage *fa) 3192 const struct TransportFragmentAckMessage *fa)
3192{ 3193{
3193 struct CommunicatorMessageContext *cmc = cls; 3194 struct CommunicatorMessageContext *cmc = cls;
3194 3195
3195 // FIXME: do work: identify original message; then identify fragments being acked; 3196 // FIXME: do work: identify original message; then identify fragments being acked;
3196 // remove those from the tree to prevent retransmission; 3197 // remove those from the tree to prevent retransmission;
3197 // compute RTT 3198 // compute RTT
@@ -3235,10 +3236,10 @@ handle_reliability_box (void *cls,
3235 3236
3236 /* FIXME: implement cummulative ACKs and ack_countdown, 3237 /* FIXME: implement cummulative ACKs and ack_countdown,
3237 then setting the avg_ack_delay field below: */ 3238 then setting the avg_ack_delay field below: */
3238 ack = GNUNET_malloc (sizeof (*ack) + 3239 ack = GNUNET_malloc (sizeof (*ack) +
3239 sizeof (struct GNUNET_ShortHashCode)); 3240 sizeof (struct GNUNET_ShortHashCode));
3240 ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK); 3241 ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK);
3241 ack->header.size = htons (sizeof (*ack) + 3242 ack->header.size = htons (sizeof (*ack) +
3242 sizeof (struct GNUNET_ShortHashCode)); 3243 sizeof (struct GNUNET_ShortHashCode));
3243 memcpy (&ack[1], 3244 memcpy (&ack[1],
3244 &rb->msg_uuid, 3245 &rb->msg_uuid,
@@ -3263,7 +3264,7 @@ handle_reliability_ack (void *cls,
3263 const struct TransportReliabilityAckMessage *ra) 3264 const struct TransportReliabilityAckMessage *ra)
3264{ 3265{
3265 struct CommunicatorMessageContext *cmc = cls; 3266 struct CommunicatorMessageContext *cmc = cls;
3266 3267
3267 // FIXME: do work: find message that was acknowledged, and 3268 // FIXME: do work: find message that was acknowledged, and
3268 // remove from transmission queue; update RTT. 3269 // remove from transmission queue; update RTT.
3269 finish_cmc_handling (cmc); 3270 finish_cmc_handling (cmc);
@@ -3318,7 +3319,7 @@ handle_backchannel_encapsulation (void *cls,
3318 // FIXME: check HMAC 3319 // FIXME: check HMAC
3319 // FIXME: decrypt payload 3320 // FIXME: decrypt payload
3320 // FIXME: forward to specified communicator! 3321 // FIXME: forward to specified communicator!
3321 // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING) 3322 // (using GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING)
3322 finish_cmc_handling (cmc); 3323 finish_cmc_handling (cmc);
3323} 3324}
3324 3325
@@ -3375,7 +3376,7 @@ handle_dv_learn (void *cls,
3375 const struct TransportDVLearn *dvl) 3376 const struct TransportDVLearn *dvl)
3376{ 3377{
3377 struct CommunicatorMessageContext *cmc = cls; 3378 struct CommunicatorMessageContext *cmc = cls;
3378 3379
3379 // FIXME: learn path from DV message (if bi-directional flags are set) 3380 // FIXME: learn path from DV message (if bi-directional flags are set)
3380 // FIXME: expand DV message, forward on (unless path is getting too long) 3381 // FIXME: expand DV message, forward on (unless path is getting too long)
3381 finish_cmc_handling (cmc); 3382 finish_cmc_handling (cmc);
@@ -3406,7 +3407,7 @@ check_dv_box (void *cls,
3406 return GNUNET_SYSERR; 3407 return GNUNET_SYSERR;
3407 } 3408 }
3408 isize = ntohs (inbox->size); 3409 isize = ntohs (inbox->size);
3409 if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize) 3410 if (size != sizeof (*dvb) + num_hops * sizeof (struct GNUNET_PeerIdentity) + isize)
3410 { 3411 {
3411 GNUNET_break_op (0); 3412 GNUNET_break_op (0);
3412 return GNUNET_SYSERR; 3413 return GNUNET_SYSERR;
@@ -3442,14 +3443,14 @@ handle_dv_box (void *cls,
3442 { 3443 {
3443 // FIXME: if we are not the target, shorten path and forward along. 3444 // FIXME: if we are not the target, shorten path and forward along.
3444 // Try from the _end_ of hops array if we know the given 3445 // Try from the _end_ of hops array if we know the given
3445 // neighbour (shortening the path!). 3446 // neighbour (shortening the path!).
3446 // NOTE: increment total_hops! 3447 // NOTE: increment total_hops!
3447 finish_cmc_handling (cmc); 3448 finish_cmc_handling (cmc);
3448 return; 3449 return;
3449 } 3450 }
3450 /* We are the target. Unbox and handle message. */ 3451 /* We are the target. Unbox and handle message. */
3451 cmc->im.sender = dvb->origin; 3452 cmc->im.sender = dvb->origin;
3452 cmc->total_hops = ntohs (dvb->total_hops); 3453 cmc->total_hops = ntohs (dvb->total_hops);
3453 demultiplex_with_cmc (cmc, 3454 demultiplex_with_cmc (cmc,
3454 inbox); 3455 inbox);
3455} 3456}
@@ -3503,7 +3504,7 @@ handle_incoming_msg (void *cls,
3503 * 3504 *
3504 * @param cmc context for demultiplexing 3505 * @param cmc context for demultiplexing
3505 * @param msg message to demultiplex 3506 * @param msg message to demultiplex
3506 */ 3507 */
3507static void 3508static void
3508demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, 3509demultiplex_with_cmc (struct CommunicatorMessageContext *cmc,
3509 const struct GNUNET_MessageHeader *msg) 3510 const struct GNUNET_MessageHeader *msg)
@@ -3593,7 +3594,7 @@ tracker_update_in_cb (void *cls)
3593 struct GNUNET_ATS_Session *queue = cls; 3594 struct GNUNET_ATS_Session *queue = cls;
3594 struct GNUNET_TIME_Relative in_delay; 3595 struct GNUNET_TIME_Relative in_delay;
3595 unsigned int rsize; 3596 unsigned int rsize;
3596 3597
3597 rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu; 3598 rsize = (0 == queue->mtu) ? IN_PACKET_SIZE_WITHOUT_MTU : queue->mtu;
3598 in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in, 3599 in_delay = GNUNET_BANDWIDTH_tracker_get_delay (&queue->tracker_in,
3599 rsize); 3600 rsize);
@@ -3619,7 +3620,7 @@ set_pending_message_uuid (struct PendingMessage *pm)
3619 3620
3620 3621
3621/** 3622/**
3622 * Fragment the given @a pm to the given @a mtu. Adds 3623 * Fragment the given @a pm to the given @a mtu. Adds
3623 * additional fragments to the neighbour as well. If the 3624 * additional fragments to the neighbour as well. If the
3624 * @a mtu is too small, generates and error for the @a pm 3625 * @a mtu is too small, generates and error for the @a pm
3625 * and returns NULL. 3626 * and returns NULL.
@@ -3635,7 +3636,7 @@ fragment_message (struct PendingMessage *pm,
3635 struct PendingMessage *ff; 3636 struct PendingMessage *ff;
3636 3637
3637 set_pending_message_uuid (pm); 3638 set_pending_message_uuid (pm);
3638 3639
3639 /* This invariant is established in #handle_add_queue_message() */ 3640 /* This invariant is established in #handle_add_queue_message() */
3640 GNUNET_assert (mtu > sizeof (struct TransportFragmentBox)); 3641 GNUNET_assert (mtu > sizeof (struct TransportFragmentBox));
3641 3642
@@ -3743,7 +3744,7 @@ reliability_box_message (struct PendingMessage *pm)
3743 if (NULL != pm->bpm) 3744 if (NULL != pm->bpm)
3744 return pm->bpm; /* already computed earlier: do nothing */ 3745 return pm->bpm; /* already computed earlier: do nothing */
3745 GNUNET_assert (NULL == pm->head_frag); 3746 GNUNET_assert (NULL == pm->head_frag);
3746 if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX) 3747 if (pm->bytes_msg + sizeof (rbox) > UINT16_MAX)
3747 { 3748 {
3748 /* failed hard */ 3749 /* failed hard */
3749 GNUNET_break (0); 3750 GNUNET_break (0);
@@ -3753,7 +3754,7 @@ reliability_box_message (struct PendingMessage *pm)
3753 return NULL; 3754 return NULL;
3754 } 3755 }
3755 bpm = GNUNET_malloc (sizeof (struct PendingMessage) + 3756 bpm = GNUNET_malloc (sizeof (struct PendingMessage) +
3756 sizeof (rbox) + 3757 sizeof (rbox) +
3757 pm->bytes_msg); 3758 pm->bytes_msg);
3758 bpm->target = pm->target; 3759 bpm->target = pm->target;
3759 bpm->frag_parent = pm; 3760 bpm->frag_parent = pm;
@@ -3783,12 +3784,12 @@ reliability_box_message (struct PendingMessage *pm)
3783 3784
3784/** 3785/**
3785 * We believe we are ready to transmit a message on a queue. Double-checks 3786 * We believe we are ready to transmit a message on a queue. Double-checks
3786 * with the queue's "tracker_out" and then gives the message to the 3787 * with the queue's "tracker_out" and then gives the message to the
3787 * communicator for transmission (updating the tracker, and re-scheduling 3788 * communicator for transmission (updating the tracker, and re-scheduling
3788 * itself if applicable). 3789 * itself if applicable).
3789 * 3790 *
3790 * @param cls the `struct GNUNET_ATS_Session` to process transmissions for 3791 * @param cls the `struct GNUNET_ATS_Session` to process transmissions for
3791 */ 3792 */
3792static void 3793static void
3793transmit_on_queue (void *cls) 3794transmit_on_queue (void *cls)
3794{ 3795{
@@ -3805,7 +3806,7 @@ transmit_on_queue (void *cls)
3805 if (NULL == (pm = n->pending_msg_head)) 3806 if (NULL == (pm = n->pending_msg_head))
3806 { 3807 {
3807 /* no message pending, nothing to do here! */ 3808 /* no message pending, nothing to do here! */
3808 return; 3809 return;
3809 } 3810 }
3810 schedule_transmit_on_queue (queue); 3811 schedule_transmit_on_queue (queue);
3811 if (NULL != queue->transmit_task) 3812 if (NULL != queue->transmit_task)
@@ -3861,7 +3862,7 @@ transmit_on_queue (void *cls)
3861 queue->tc->details.communicator.total_queue_length++; 3862 queue->tc->details.communicator.total_queue_length++;
3862 GNUNET_MQ_send (queue->tc->mq, 3863 GNUNET_MQ_send (queue->tc->mq,
3863 env); 3864 env);
3864 3865
3865 // FIXME: do something similar to the logic below 3866 // FIXME: do something similar to the logic below
3866 // in defragmentation / reliability ACK handling! 3867 // in defragmentation / reliability ACK handling!
3867 3868
@@ -3879,7 +3880,7 @@ transmit_on_queue (void *cls)
3879 (PMT_FRAGMENT_BOX == s->pmt) ) 3880 (PMT_FRAGMENT_BOX == s->pmt) )
3880 { 3881 {
3881 struct PendingMessage *pos; 3882 struct PendingMessage *pos;
3882 3883
3883 /* Fragment sent over reliabile channel */ 3884 /* Fragment sent over reliabile channel */
3884 free_fragment_tree (s); 3885 free_fragment_tree (s);
3885 pos = s->frag_parent; 3886 pos = s->frag_parent;
@@ -3899,9 +3900,9 @@ transmit_on_queue (void *cls)
3899 pos->head_frag, 3900 pos->head_frag,
3900 pos->tail_frag, 3901 pos->tail_frag,
3901 s); 3902 s);
3902 GNUNET_free (s); 3903 GNUNET_free (s);
3903 } 3904 }
3904 3905
3905 /* Was this the last applicable fragmment? */ 3906 /* Was this the last applicable fragmment? */
3906 if ( (NULL == pm->head_frag) && 3907 if ( (NULL == pm->head_frag) &&
3907 (pm->frag_off == pm->bytes_msg) ) 3908 (pm->frag_off == pm->bytes_msg) )
@@ -3968,7 +3969,7 @@ transmit_on_queue (void *cls)
3968 s); 3969 s);
3969 } 3970 }
3970 } 3971 }
3971 3972
3972 /* finally, re-schedule queue transmission task itself */ 3973 /* finally, re-schedule queue transmission task itself */
3973 schedule_transmit_on_queue (queue); 3974 schedule_transmit_on_queue (queue);
3974} 3975}
@@ -4010,13 +4011,13 @@ tracker_excess_out_cb (void *cls)
4010{ 4011{
4011 /* FIXME: trigger excess bandwidth report to core? Right now, 4012 /* FIXME: trigger excess bandwidth report to core? Right now,
4012 this is done internally within transport_api2_core already, 4013 this is done internally within transport_api2_core already,
4013 but we probably want to change the logic and trigger it 4014 but we probably want to change the logic and trigger it
4014 from here via a message instead! */ 4015 from here via a message instead! */
4015 /* TODO: maybe inform ATS at this point? */ 4016 /* TODO: maybe inform ATS at this point? */
4016 GNUNET_STATISTICS_update (GST_stats, 4017 GNUNET_STATISTICS_update (GST_stats,
4017 "# Excess outbound bandwidth reported", 4018 "# Excess outbound bandwidth reported",
4018 1, 4019 1,
4019 GNUNET_NO); 4020 GNUNET_NO);
4020} 4021}
4021 4022
4022 4023
@@ -4034,7 +4035,7 @@ tracker_excess_in_cb (void *cls)
4034 GNUNET_STATISTICS_update (GST_stats, 4035 GNUNET_STATISTICS_update (GST_stats,
4035 "# Excess inbound bandwidth reported", 4036 "# Excess inbound bandwidth reported",
4036 1, 4037 1,
4037 GNUNET_NO); 4038 GNUNET_NO);
4038} 4039}
4039 4040
4040 4041
@@ -4113,7 +4114,7 @@ handle_add_queue_message (void *cls,
4113 .nt = queue->nt, 4114 .nt = queue->nt,
4114 .cc = tc->details.communicator.cc 4115 .cc = tc->details.communicator.cc
4115 }; 4116 };
4116 4117
4117 queue->sr = GNUNET_ATS_session_add (ats, 4118 queue->sr = GNUNET_ATS_session_add (ats,
4118 &neighbour->pid, 4119 &neighbour->pid,
4119 queue->address, 4120 queue->address,
@@ -4211,7 +4212,7 @@ handle_send_message_ack (void *cls,
4211{ 4212{
4212 struct TransportClient *tc = cls; 4213 struct TransportClient *tc = cls;
4213 struct QueueEntry *queue; 4214 struct QueueEntry *queue;
4214 4215
4215 if (CT_COMMUNICATOR != tc->type) 4216 if (CT_COMMUNICATOR != tc->type)
4216 { 4217 {
4217 GNUNET_break (0); 4218 GNUNET_break (0);
@@ -4238,12 +4239,12 @@ handle_send_message_ack (void *cls,
4238 queue = qe; 4239 queue = qe;
4239 break; 4240 break;
4240 } 4241 }
4241 break; 4242 break;
4242 } 4243 }
4243 if (NULL == queue) 4244 if (NULL == queue)
4244 { 4245 {
4245 /* this should never happen */ 4246 /* this should never happen */
4246 GNUNET_break (0); 4247 GNUNET_break (0);
4247 GNUNET_SERVICE_client_drop (tc->client); 4248 GNUNET_SERVICE_client_drop (tc->client);
4248 return; 4249 return;
4249 } 4250 }
@@ -4273,10 +4274,10 @@ handle_send_message_ack (void *cls,
4273 GNUNET_STATISTICS_update (GST_stats, 4274 GNUNET_STATISTICS_update (GST_stats,
4274 "# Transmission throttled due to session queue limit", 4275 "# Transmission throttled due to session queue limit",
4275 -1, 4276 -1,
4276 GNUNET_NO); 4277 GNUNET_NO);
4277 schedule_transmit_on_queue (queue->session); 4278 schedule_transmit_on_queue (queue->session);
4278 } 4279 }
4279 4280
4280 /* TODO: we also should react on the status! */ 4281 /* TODO: we also should react on the status! */
4281 // FIXME: this probably requires queue->pm = s assignment! 4282 // FIXME: this probably requires queue->pm = s assignment!
4282 // FIXME: react to communicator status about transmission request. We got: 4283 // FIXME: react to communicator status about transmission request. We got:
@@ -4439,7 +4440,7 @@ ats_suggestion_cb (void *cls,
4439 GNUNET_STATISTICS_update (GST_stats, 4440 GNUNET_STATISTICS_update (GST_stats,
4440 "# ATS suggestions ignored due to missing communicator", 4441 "# ATS suggestions ignored due to missing communicator",
4441 1, 4442 1,
4442 GNUNET_NO); 4443 GNUNET_NO);
4443 return; 4444 return;
4444 } 4445 }
4445 /* forward suggestion for queue creation to communicator */ 4446 /* forward suggestion for queue creation to communicator */
@@ -4468,7 +4469,7 @@ ats_suggestion_cb (void *cls,
4468 * 4469 *
4469 * @param cls the `struct TransportClient` 4470 * @param cls the `struct TransportClient`
4470 * @param cqr confirmation message 4471 * @param cqr confirmation message
4471 */ 4472 */
4472static void 4473static void
4473handle_queue_create_ok (void *cls, 4474handle_queue_create_ok (void *cls,
4474 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) 4475 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
@@ -4488,7 +4489,7 @@ handle_queue_create_ok (void *cls,
4488 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4489 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4489 "Request #%u for communicator to create queue succeeded\n", 4490 "Request #%u for communicator to create queue succeeded\n",
4490 (unsigned int) ntohs (cqr->request_id)); 4491 (unsigned int) ntohs (cqr->request_id));
4491 GNUNET_SERVICE_client_continue (tc->client); 4492 GNUNET_SERVICE_client_continue (tc->client);
4492} 4493}
4493 4494
4494 4495
@@ -4499,7 +4500,7 @@ handle_queue_create_ok (void *cls,
4499 * 4500 *
4500 * @param cls the `struct TransportClient` 4501 * @param cls the `struct TransportClient`
4501 * @param cqr failure message 4502 * @param cqr failure message
4502 */ 4503 */
4503static void 4504static void
4504handle_queue_create_fail (void *cls, 4505handle_queue_create_fail (void *cls,
4505 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr) 4506 const struct GNUNET_TRANSPORT_CreateQueueResponse *cqr)
@@ -4519,7 +4520,61 @@ handle_queue_create_fail (void *cls,
4519 "# ATS suggestions failed in queue creation at communicator", 4520 "# ATS suggestions failed in queue creation at communicator",
4520 1, 4521 1,
4521 GNUNET_NO); 4522 GNUNET_NO);
4522 GNUNET_SERVICE_client_continue (tc->client); 4523 GNUNET_SERVICE_client_continue (tc->client);
4524}
4525
4526
4527/**
4528 * Check #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY
4529 * messages. We do nothing here, real verification is done later.
4530 *
4531 * @param cls a `struct TransportClient *`
4532 * @param msg message to verify
4533 * @return #GNUNET_OK
4534 */
4535static int
4536check_address_consider_verify (void *cls,
4537 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
4538{
4539 (void) cls;
4540 (void) hdr;
4541 return GNUNET_OK;
4542}
4543
4544
4545/**
4546 * Given another peers address, consider checking it for validity
4547 * and then adding it to the Peerstore.
4548 *
4549 * @param cls a `struct TransportClient`
4550 * @param hdr message containing the raw address data and
4551 * signature in the body, see #GNUNET_HELLO_extract_address()
4552 */
4553static void
4554handle_address_consider_verify (void *cls,
4555 const struct GNUNET_TRANSPORT_AddressToVerify *hdr)
4556{
4557 char *address;
4558 enum GNUNET_NetworkType nt;
4559 struct GNUNET_TIME_Absolute expiration;
4560
4561 (void) cls;
4562 // FIXME: pre-check: do we know this address already?
4563 // FIXME: pre-check: rate-limit signature verification / validation!
4564 address = GNUNET_HELLO_extract_address (&hdr[1],
4565 ntohs (hdr->header.size) - sizeof (*hdr),
4566 &hdr->peer,
4567 &nt,
4568 &expiration);
4569 if (NULL == address)
4570 {
4571 GNUNET_break_op (0);
4572 return;
4573 }
4574 if (0 == GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us)
4575 return; /* expired */
4576 // FIXME: do begin actual verification here!
4577 GNUNET_free (address);
4523} 4578}
4524 4579
4525 4580
@@ -4762,6 +4817,10 @@ GNUNET_SERVICE_MAIN
4762 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, 4817 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
4763 struct GNUNET_TRANSPORT_AddQueueMessage, 4818 struct GNUNET_TRANSPORT_AddQueueMessage,
4764 NULL), 4819 NULL),
4820 GNUNET_MQ_hd_var_size (address_consider_verify,
4821 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY,
4822 struct GNUNET_TRANSPORT_AddressToVerify,
4823 NULL),
4765 GNUNET_MQ_hd_fixed_size (del_queue_message, 4824 GNUNET_MQ_hd_fixed_size (del_queue_message,
4766 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, 4825 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
4767 struct GNUNET_TRANSPORT_DelQueueMessage, 4826 struct GNUNET_TRANSPORT_DelQueueMessage,
diff --git a/src/transport/transport.h b/src/transport/transport.h
index 931ba4810..c0e02c3d9 100644
--- a/src/transport/transport.h
+++ b/src/transport/transport.h
@@ -1081,6 +1081,32 @@ struct GNUNET_TRANSPORT_MonitorData
1081 1081
1082}; 1082};
1083 1083
1084
1085/**
1086 * Request to verify address.
1087 */
1088struct GNUNET_TRANSPORT_AddressToVerify
1089{
1090
1091 /**
1092 * Type will be #GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY.
1093 */
1094 struct GNUNET_MessageHeader header;
1095
1096 /**
1097 * Reserved. 0.
1098 */
1099 uint32_t reserved;
1100
1101 /**
1102 * Peer the address is from.
1103 */
1104 struct GNUNET_PeerIdentity peer;
1105
1106 /* followed by variable-size raw address */
1107};
1108
1109
1084#endif 1110#endif
1085 1111
1086GNUNET_NETWORK_STRUCT_END 1112GNUNET_NETWORK_STRUCT_END
diff --git a/src/transport/transport_api2_address.c b/src/transport/transport_api2_address.c
new file mode 100644
index 000000000..1ae1e5b1e
--- /dev/null
+++ b/src/transport/transport_api2_address.c
@@ -0,0 +1,249 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2009-2013, 2016, 2018, 2019 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19*/
20
21/**
22 * @file transport/transport_api2_address.c
23 * @brief library to inform the transport service about addresses to be validated
24 * @author Christian Grothoff
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_constants.h"
29#include "gnunet_protocols.h"
30#include "gnunet_transport_address_service.h"
31#include "gnunet_ats_transport_service.h"
32#include "transport.h"
33
34#define LOG(kind,...) GNUNET_log_from (kind, "transport-api-address",__VA_ARGS__)
35
36
37/**
38 * Handle for the transport service (includes all of the
39 * state for the transport service).
40 */
41struct GNUNET_TRANSPORT_AddressHandle
42{
43
44 /**
45 * My client connection to the transport service.
46 */
47 struct GNUNET_MQ_Handle *mq;
48
49 /**
50 * My configuration.
51 */
52 const struct GNUNET_CONFIGURATION_Handle *cfg;
53
54 /**
55 * ID of the task trying to reconnect to the service.
56 */
57 struct GNUNET_SCHEDULER_Task *reconnect_task;
58
59 /**
60 * Delay until we try to reconnect.
61 */
62 struct GNUNET_TIME_Relative reconnect_delay;
63
64};
65
66
67/**
68 * Function that will schedule the job that will try
69 * to connect us again to the client.
70 *
71 * @param h transport service to reconnect
72 */
73static void
74disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h);
75
76
77/**
78 * Generic error handler, called with the appropriate
79 * error code and the same closure specified at the creation of
80 * the message queue.
81 * Not every message queue implementation supports an error handler.
82 *
83 * @param cls closure with the `struct GNUNET_TRANSPORT_AddressHandle *`
84 * @param error error code
85 */
86static void
87mq_error_handler (void *cls,
88 enum GNUNET_MQ_Error error)
89{
90 struct GNUNET_TRANSPORT_AddressHandle *h = cls;
91
92 LOG (GNUNET_ERROR_TYPE_DEBUG,
93 "Error receiving from transport service, disconnecting temporarily.\n");
94 disconnect_and_schedule_reconnect (h);
95}
96
97
98/**
99 * Try again to connect to transport service.
100 *
101 * @param cls the handle to the transport service
102 */
103static void
104reconnect (void *cls)
105{
106 struct GNUNET_TRANSPORT_AddressHandle *h = cls;
107 struct GNUNET_MQ_MessageHandler handlers[] = {
108 GNUNET_MQ_handler_end ()
109 };
110
111 h->reconnect_task = NULL;
112 LOG (GNUNET_ERROR_TYPE_DEBUG,
113 "Connecting to transport service.\n");
114 GNUNET_assert (NULL == h->mq);
115 h->mq = GNUNET_CLIENT_connect (h->cfg,
116 "transport",
117 handlers,
118 &mq_error_handler,
119 h);
120}
121
122
123/**
124 * Disconnect from the transport service.
125 *
126 * @param h transport service to reconnect
127 */
128static void
129disconnect (struct GNUNET_TRANSPORT_AddressHandle *h)
130{
131 if (NULL != h->mq)
132 {
133 GNUNET_MQ_destroy (h->mq);
134 h->mq = NULL;
135 }
136}
137
138
139/**
140 * Function that will schedule the job that will try
141 * to connect us again to the client.
142 *
143 * @param h transport service to reconnect
144 */
145static void
146disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_AddressHandle *h)
147{
148 GNUNET_assert (NULL == h->reconnect_task);
149 disconnect (h);
150 LOG (GNUNET_ERROR_TYPE_DEBUG,
151 "Scheduling task to reconnect to transport service in %s.\n",
152 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay,
153 GNUNET_YES));
154 h->reconnect_task =
155 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
156 &reconnect,
157 h);
158 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
159}
160
161
162/**
163 * Connect to the transport service.
164 *
165 * @param cfg configuration to use
166 * @return NULL on error
167 */
168struct GNUNET_TRANSPORT_AddressHandle *
169GNUNET_TRANSPORT_address_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
170{
171 struct GNUNET_TRANSPORT_AddressHandle *h;
172
173 h = GNUNET_new (struct GNUNET_TRANSPORT_AddressHandle);
174 h->cfg = cfg;
175 h->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
176 LOG (GNUNET_ERROR_TYPE_DEBUG,
177 "Connecting to transport service\n");
178 reconnect (h);
179 if (NULL == h->mq)
180 {
181 GNUNET_free (h);
182 return NULL;
183 }
184 return h;
185}
186
187
188/**
189 * Disconnect from the transport service.
190 *
191 * @param handle handle to the service as returned from #GNUNET_TRANSPORT_address_connect()
192 */
193void
194GNUNET_TRANSPORT_address_disconnect (struct GNUNET_TRANSPORT_AddressHandle *handle)
195{
196 LOG (GNUNET_ERROR_TYPE_DEBUG,
197 "Transport disconnect called!\n");
198 /* this disconnects all neighbours... */
199 disconnect (handle);
200 /* and now we stop trying to connect again... */
201 if (NULL != handle->reconnect_task)
202 {
203 GNUNET_SCHEDULER_cancel (handle->reconnect_task);
204 handle->reconnect_task = NULL;
205 }
206 GNUNET_free (handle);
207}
208
209
210/**
211 * The client has learned about a possible address for peer @a pid
212 * (i.e. via broadcast, multicast, DHT, ...). The transport service
213 * should consider validating it. Note that the plugin is NOT expected
214 * to have verified the signature, the transport service must decide
215 * whether to check the signature.
216 *
217 * While the notification is sent to @a ch asynchronously, this API
218 * does not return a handle as the delivery of addresses is simply
219 * unreliable, and if @a ch is down, the data provided will simply be
220 * lost.
221 *
222 * @param ch communicator handle
223 * @param pid peer the address is for
224 * @param raw raw address data
225 * @param raw_size number of bytes in @a raw
226 */
227void
228GNUNET_TRANSPORT_address_try (struct GNUNET_TRANSPORT_AddressHandle *ch,
229 const struct GNUNET_PeerIdentity *pid,
230 const void *raw,
231 const size_t raw_size)
232{
233 struct GNUNET_MQ_Envelope *env;
234 struct GNUNET_TRANSPORT_AddressToVerify *hdr;
235
236 env = GNUNET_MQ_msg_extra (hdr,
237 raw_size,
238 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_CONSIDER_VERIFY);
239 hdr->peer = *pid;
240 memcpy (&hdr[1],
241 raw,
242 raw_size);
243 GNUNET_MQ_send (ch->mq,
244 env);
245}
246
247
248
249/* end of transport_api2_address.c */