aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-communicator-quic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-communicator-quic.c')
-rw-r--r--src/transport/gnunet-communicator-quic.c69
1 files changed, 65 insertions, 4 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c
index f779297de..60a20c581 100644
--- a/src/transport/gnunet-communicator-quic.c
+++ b/src/transport/gnunet-communicator-quic.c
@@ -20,7 +20,14 @@
20 20
21 21
22// #define STREAM_ID_MAX (UINT64_MAX - (0b11 << 62)) 22// #define STREAM_ID_MAX (UINT64_MAX - (0b11 << 62))
23#define STREAM_ID_MAX UINT64_MAX - 0xC000000000000000 23// #define STREAM_ID_MAX UINT64_MAX - 0xC000000000000000
24
25/* Currently equivalent to QUICHE_MAX_CONN_ID_LEN */
26#define LOCAL_CONN_ID_LEN 20
27#define MAX_TOKEN_LEN \
28 sizeof("quiche") - 1 + \
29 sizeof(struct sockaddr_storage) + \
30 QUICHE_MAX_CONN_ID_LEN
24 31
25static const struct GNUNET_CONFIGURATION_Handle *cfg; 32static const struct GNUNET_CONFIGURATION_Handle *cfg;
26static struct GNUNET_TIME_Relative rekey_interval; 33static struct GNUNET_TIME_Relative rekey_interval;
@@ -52,15 +59,24 @@ static int have_v6_socket;
52static uint16_t my_port; 59static uint16_t my_port;
53static unsigned long long rekey_max_bytes; 60static unsigned long long rekey_max_bytes;
54 61
62struct quiche_conn *conn;
63
64struct quic_conn {
65
66 uint8_t cid[LOCAL_CONN_ID_LEN];
67
68 quiche_conn *conn;
69};
70
55/** 71/**
56 * @param stream_type ... 72 * @param stream_type ...
57 * Generate a unique stream ID with indicated stream type 73 * Generate a unique stream ID with indicated stream type
58 * quiche library has QUICHE_MAX_CONN_ID_LEN = 20? 74 * quiche library has QUICHE_MAX_CONN_ID_LEN = 20?
59*/ 75*/
60uint64_t gen_streamid() 76static uint64_t gen_streamid()
61{ 77{
62 uint64_t sid; 78 uint64_t sid;
63 sid = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, STREAM_ID_MAX); 79 // sid = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_STRONG, STREAM_ID_MAX);
64 /** 80 /**
65 * Ensure each peer does NOT reuse one of their own stream ID 81 * Ensure each peer does NOT reuse one of their own stream ID
66 */ 82 */
@@ -77,6 +93,14 @@ uint64_t gen_streamid()
77} 93}
78 94
79/** 95/**
96 * Generate a new connection ID
97*/
98static uint8_t *gen_cid(uint8_t *cid, size_t cid_len)
99{
100 int rand_cid = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, UINT8_MAX);
101}
102
103/**
80 * Shutdown the UNIX communicator. 104 * Shutdown the UNIX communicator.
81 * 105 *
82 * @param cls NULL (always) 106 * @param cls NULL (always)
@@ -265,7 +289,6 @@ sock_read (void *cls)
265 (struct sockaddr *) &sa, 289 (struct sockaddr *) &sa,
266 &salen); 290 &salen);
267 291
268 // ssize_t quic_rcvd = quiche_conn_recv(conn, buf, rcvd, &recv_info)
269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
270 "Read %lu bytes\n", rcvd); 293 "Read %lu bytes\n", rcvd);
271 294
@@ -274,6 +297,44 @@ sock_read (void *cls)
274 GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv"); 297 GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv");
275 return; 298 return;
276 } 299 }
300 /**
301 * TODO:
302 * - handle connection ID (not stream ID) -> associate incoming packets by connection ID
303 * with previous connection or generate new connection
304 *
305 * - create structure for individual connections (how many can we have concurrently)
306 */
307 struct quic_conn *tmp_conn;
308
309
310 uint8_t new_cid[LOCAL_CONN_ID_LEN];
311 uint8_t type;
312 uint32_t version;
313
314 uint8_t scid[QUICHE_MAX_CONN_ID_LEN];
315 size_t scid_len = sizeof(scid);
316
317 uint8_t dcid[QUICHE_MAX_CONN_ID_LEN];
318 size_t dcid_len = sizeof(dcid);
319
320 uint8_t odcid[QUICHE_MAX_CONN_ID_LEN];
321 size_t odcid_len = sizeof(odcid);
322
323 uint8_t token[MAX_TOKEN_LEN];
324 size_t token_len = sizeof(token);
325
326 int rc = quiche_header_info(buf, read, LOCAL_CONN_ID_LEN, &version,
327 &type, scid, &scid_len, dcid, &dcid_len,
328 token, &token_len);
329 if (rc < 0)
330 {
331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "failed to parse quic header: %d", rc);
332 }
333
334 /* look for connection in hashtable */
335
336
337
277 338
278 // if (rcvd > sizeof(struct UDPRekey)) 339 // if (rcvd > sizeof(struct UDPRekey))
279 // { 340 // {