diff options
Diffstat (limited to 'src/transport/gnunet-communicator-quic.c')
-rw-r--r-- | src/transport/gnunet-communicator-quic.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c index 60a20c581..a710c80de 100644 --- a/src/transport/gnunet-communicator-quic.c +++ b/src/transport/gnunet-communicator-quic.c | |||
@@ -29,11 +29,13 @@ | |||
29 | sizeof(struct sockaddr_storage) + \ | 29 | sizeof(struct sockaddr_storage) + \ |
30 | QUICHE_MAX_CONN_ID_LEN | 30 | QUICHE_MAX_CONN_ID_LEN |
31 | 31 | ||
32 | /** | ||
33 | * Map of DCID (uint8_t) -> quic_conn for quickly retrieving connections to other peers. | ||
34 | */ | ||
35 | struct GNUNET_CONTAINER_MultiHashMap *conn_map; | ||
36 | |||
32 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 37 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
33 | static struct GNUNET_TIME_Relative rekey_interval; | 38 | static struct GNUNET_TIME_Relative rekey_interval; |
34 | /** | ||
35 | * the socket to transmit data on | ||
36 | */ | ||
37 | static struct GNUNET_NETWORK_Handle *udp_sock; | 39 | static struct GNUNET_NETWORK_Handle *udp_sock; |
38 | // static struct GNUNET_STATISTICS_Handle *stats; | 40 | // static struct GNUNET_STATISTICS_Handle *stats; |
39 | // static struct GNUNET_CONTAINER_MultiPeerMap *senders; | 41 | // static struct GNUNET_CONTAINER_MultiPeerMap *senders; |
@@ -59,8 +61,10 @@ static int have_v6_socket; | |||
59 | static uint16_t my_port; | 61 | static uint16_t my_port; |
60 | static unsigned long long rekey_max_bytes; | 62 | static unsigned long long rekey_max_bytes; |
61 | 63 | ||
62 | struct quiche_conn *conn; | 64 | /** |
63 | 65 | * QUIC connection object. A connection has a unique SCID/DCID pair. Here we store our SCID | |
66 | * (incoming packet DCID field == outgoing packet SCID field) for a given connection. | ||
67 | */ | ||
64 | struct quic_conn { | 68 | struct quic_conn { |
65 | 69 | ||
66 | uint8_t cid[LOCAL_CONN_ID_LEN]; | 70 | uint8_t cid[LOCAL_CONN_ID_LEN]; |
@@ -88,7 +92,6 @@ static uint64_t gen_streamid() | |||
88 | * 0x02: client-initiated, unidirectional | 92 | * 0x02: client-initiated, unidirectional |
89 | * 0x03: server-initiated, unidirectional | 93 | * 0x03: server-initiated, unidirectional |
90 | */ | 94 | */ |
91 | |||
92 | return sid; | 95 | return sid; |
93 | } | 96 | } |
94 | 97 | ||
@@ -304,8 +307,7 @@ sock_read (void *cls) | |||
304 | * | 307 | * |
305 | * - create structure for individual connections (how many can we have concurrently) | 308 | * - create structure for individual connections (how many can we have concurrently) |
306 | */ | 309 | */ |
307 | struct quic_conn *tmp_conn; | 310 | struct quic_conn *conn; |
308 | |||
309 | 311 | ||
310 | uint8_t new_cid[LOCAL_CONN_ID_LEN]; | 312 | uint8_t new_cid[LOCAL_CONN_ID_LEN]; |
311 | uint8_t type; | 313 | uint8_t type; |
@@ -332,9 +334,43 @@ sock_read (void *cls) | |||
332 | } | 334 | } |
333 | 335 | ||
334 | /* look for connection in hashtable */ | 336 | /* look for connection in hashtable */ |
337 | /* each connection to the peer should have a unique incoming DCID */ | ||
338 | /* check against a conn SCID */ | ||
339 | struct GNUNET_HashCode *conn_key; | ||
340 | GNUNET_CRYPTO_hash(dcid, sizeof(dcid), conn_key); | ||
341 | conn = GNUNET_CONTAINER_multihashmap_get(conn_map, conn_key); | ||
335 | 342 | ||
343 | if (NULL == conn) | ||
344 | { | ||
345 | /** | ||
346 | * create_conn(), error check for problems with creation | ||
347 | */ | ||
348 | } | ||
336 | 349 | ||
350 | /** | ||
351 | * TODO: today finish sock_read, make create_conn, get compilation working | ||
352 | */ | ||
353 | char *bindto; | ||
354 | socklen_t in_len; | ||
355 | if (GNUNET_OK != | ||
356 | GNUNET_CONFIGURATION_get_value_string (cfg, | ||
357 | COMMUNICATOR_CONFIG_SECTION, | ||
358 | "BINDTO", | ||
359 | &bindto)) | ||
360 | { | ||
361 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | ||
362 | COMMUNICATOR_CONFIG_SECTION, | ||
363 | "BINDTO"); | ||
364 | return; | ||
365 | } | ||
366 | struct sock_addr *recv_sock = udp_address_to_sockaddr(bindto, in_len); | ||
367 | quiche_recv_info recv_info = { | ||
368 | (struct sockaddr *)&sa, | ||
369 | salen, | ||
337 | 370 | ||
371 | recv_sock, | ||
372 | in_len, | ||
373 | }; | ||
338 | 374 | ||
339 | // if (rcvd > sizeof(struct UDPRekey)) | 375 | // if (rcvd > sizeof(struct UDPRekey)) |
340 | // { | 376 | // { |
@@ -700,6 +736,7 @@ main(int argc, char *const *argv) | |||
700 | * Setup QUICHE configuration | 736 | * Setup QUICHE configuration |
701 | */ | 737 | */ |
702 | quiche_config *quiche_conf = quiche_config_new(QUICHE_PROTOCOL_VERSION); | 738 | quiche_config *quiche_conf = quiche_config_new(QUICHE_PROTOCOL_VERSION); |
739 | conn_map = GNUNET_CONTAINER_multihashmap_create(2, GNUNET_NO); | ||
703 | 740 | ||
704 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 741 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
705 | GNUNET_GETOPT_OPTION_END | 742 | GNUNET_GETOPT_OPTION_END |