[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 16/39: http3: Prepare work for the cid_map
From: |
gnunet |
Subject: |
[gnunet] 16/39: http3: Prepare work for the cid_map |
Date: |
Sun, 25 Aug 2024 15:16:12 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 91888c12e2ae76bf740f62d75e04574aa4b5373e
Author: Shichao <mrrr61@outlook.com>
AuthorDate: Tue Jun 4 09:52:50 2024 +0800
http3: Prepare work for the cid_map
---
src/service/transport/gnunet-communicator-http3.c | 96 ++++++++++++++++++++++-
1 file changed, 92 insertions(+), 4 deletions(-)
diff --git a/src/service/transport/gnunet-communicator-http3.c
b/src/service/transport/gnunet-communicator-http3.c
index 548e6fa9a..4e364665e 100644
--- a/src/service/transport/gnunet-communicator-http3.c
+++ b/src/service/transport/gnunet-communicator-http3.c
@@ -53,6 +53,12 @@
*/
struct GNUNET_CONTAINER_MultiHashMap *addr_map;
+/**
+ * Map of connection id (cid) -> struct Connection.
+ * Key is scid, which is the scid of the packet we sent.
+ */
+struct GNUNET_CONTAINER_MultiHashMap *cid_map;
+
/**
* Our configuration.
*/
@@ -530,6 +536,76 @@ remove_stream (struct Connection *connection, int64_t
stream_id)
}
+/**
+ *
+ *
+ * @param connection
+ * @param stream_id
+ *
+ * @return
+ */
+static struct Connection *
+cid_map_find (const uint8_t *cid, size_t cidlen)
+{
+ struct GNUNET_HashCode cid_key;
+ struct Connection *connection;
+
+ GNUNET_CRYPTO_hash (cid, cidlen, &cid_key);
+ connection = GNUNET_CONTAINER_multihashmap_get (cid_map, &cid_key);
+
+ return connection;
+}
+
+
+/**
+ *
+ *
+ * @param connection
+ * @param stream_id
+ *
+ * @return
+ */
+static void
+cid_map_insert (const uint8_t *cid, size_t cidlen, struct Connection
*connection
+ )
+{
+ struct GNUNET_HashCode cid_key;
+
+ GNUNET_CRYPTO_hash (cid, cidlen, &cid_key);
+ GNUNET_CONTAINER_multihashmap_put (cid_map,
+ &cid_key,
+ connection,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+}
+
+
+/**
+ *
+ *
+ * @param connection
+ * @param stream_id
+ *
+ * @return
+ */
+static void
+cid_map_erase (const uint8_t *cid, size_t cidlen)
+{
+ struct GNUNET_HashCode cid_key;
+ struct Connection *connection;
+ int rv;
+
+ GNUNET_CRYPTO_hash (cid, cidlen, &cid_key);
+ connection = GNUNET_CONTAINER_multihashmap_get (cid_map, &cid_key);
+ rv = GNUNET_CONTAINER_multihashmap_remove (cid_map, &cid_key, connection);
+
+ if (GNUNET_NO == rv)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "cid not in cid_map, can't remove it\n");
+ }
+}
+
+
/**
* As the client, initialize the corresponding connection.
*
@@ -952,16 +1028,16 @@ recv_stream_data_cb (ngtcp2_conn *conn, uint32_t flags,
int64_t stream_id,
void *stream_user_data)
{
/**
- * FIXME: When server side(!is_initiator) receives stream data, it should
+ * FIXME: When server side(!is_initiator) receives stream data, it should
* call create_stream to create a new stream and reply something.
- * But currently server has nothing to reply, so we don't call
create_stream,
+ * But currently server has nothing to reply, so we don't call create_stream,
* and the callback.stream_close won't find the stream in hashmap.
* There will be stream data to be sent after HTTP3 layer is implemented.
*/
/* extend connection-level and stream-level flow control window. */
- ngtcp2_conn_extend_max_offset(conn, datalen);
- ngtcp2_conn_extend_max_stream_offset(conn, stream_id, datalen);
+ ngtcp2_conn_extend_max_offset (conn, datalen);
+ ngtcp2_conn_extend_max_stream_offset (conn, stream_id, datalen);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"recv_stream_data: datalen = %lu\n", datalen);
struct Connection *connection = user_data;
@@ -1773,6 +1849,18 @@ sock_read (void *cls)
GNUNET_free (addr_string);
connection = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key);
+ // if (NULL == connection)
+ // {
+ // ngtcp2_version_cid vc;
+ // rv = ngtcp2_pkt_decode_version_cid (&vc, buf, rcvd,
NGTCP2_MAX_CIDLEN);
+ // if (rv < 0)
+ // {
+ // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ // "ngtcp2_pkt_decode_version_cid error: %s\n",
+ // ngtcp2_strerror (rv));
+ // }
+ // connection = cid_map_find (vc.scid, vc.scidlen);
+ // }
if (NULL == connection)
{
connection = accept_connection (local_addr, local_addrlen,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] branch master updated (637daa8cb -> 68da2e047), gnunet, 2024/08/25
- [gnunet] 04/39: http3: handle read from sock., gnunet, 2024/08/25
- [gnunet] 01/39: http3: create http3 file, update Makefile.am and add .gitignore, gnunet, 2024/08/25
- [gnunet] 03/39: http3: write to connection and send packet, gnunet, 2024/08/25
- [gnunet] 12/39: http3: add stream shutdown after send my_identity, gnunet, 2024/08/25
- [gnunet] 05/39: http3: use one cred, and initialized it, gnunet, 2024/08/25
- [gnunet] 02/39: http3: Complete the run and mq_init functions, gnunet, 2024/08/25
- [gnunet] 07/39: http3: receive stream data, gnunet, 2024/08/25
- [gnunet] 16/39: http3: Prepare work for the cid_map,
gnunet <=
- [gnunet] 06/39: http3: handle mq, gnunet, 2024/08/25
- [gnunet] 08/39: http3: do shutdown, gnunet, 2024/08/25
- [gnunet] 14/39: http3: rename COMMUNICATOR_ADDRESS_PREFIX, gnunet, 2024/08/25
- [gnunet] 19/39: http3: Add the functions to handle disconnection, gnunet, 2024/08/25
- [gnunet] 15/39: http3: Correct the value of statistics value # connections active, gnunet, 2024/08/25
- [gnunet] 09/39: http3: add http3 test, gnunet, 2024/08/25
- [gnunet] 10/39: http3: fix the log of ngtcp2_conn_writev_stream, gnunet, 2024/08/25
- [gnunet] 13/39: http3: extend flow control window, now can pass basic test., gnunet, 2024/08/25
- [gnunet] 22/39: http3: Complete the callbacks of nghttp3 and ngtcp2, gnunet, 2024/08/25
- [gnunet] 25/39: http3: make meson compie; remove application handle, gnunet, 2024/08/25