gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated (b14eee0fd -> ba23b260c)


From: gnunet
Subject: [gnunet] branch master updated (b14eee0fd -> ba23b260c)
Date: Thu, 27 Jul 2023 03:43:57 +0200

This is an automated email from the git hooks/post-receive script.

marshall pushed a change to branch master
in repository gnunet.

    from b14eee0fd pq: expose array-type->oid mapping via function
     new bf1514352 transport (quic): error handling fixes
     new 1470f8232 transport (quic): parse msgs before passing to core
     new 42dce80dc rename id_recvd to id_rcvd
     new c84e4e646 quic: remove multipeermap, fix addr map
     new ba23b260c quic: optimize sock_read recv

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/transport/gnunet-communicator-quic.c | 482 +++++++++++++++++--------------
 1 file changed, 261 insertions(+), 221 deletions(-)

diff --git a/src/transport/gnunet-communicator-quic.c 
b/src/transport/gnunet-communicator-quic.c
index 566ad4287..0d47f1469 100644
--- a/src/transport/gnunet-communicator-quic.c
+++ b/src/transport/gnunet-communicator-quic.c
@@ -79,7 +79,7 @@ struct PeerAddress
   /**
    * Flag to indicate whether we know the PeerIdentity (target) yet
   */
-  int id_recvd;
+  int id_rcvd;
 
   /**
    * Address of the receiver in the human-readable format
@@ -139,11 +139,6 @@ struct PeerAddress
   struct GNUNET_CONTAINER_HeapNode *hn;
 };
 
-/**
- * Peers (map from peer identity to `struct PeerAddress`)
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *peers;
-
 /**
  * Expiration heap for peers (contains `struct PeerAddress`)
  */
@@ -236,22 +231,56 @@ recv_from_streams (struct PeerAddress *peer)
     /**
      * Initial packet should contain peerid
     */
-    if (GNUNET_NO == peer->id_recvd)
+    if (GNUNET_NO == peer->id_rcvd)
     {
+      if (recv_len < sizeof(struct GNUNET_PeerIdentity))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "message recv len of %zd less than length of peer 
identity\n",
+                    recv_len);
+        return;
+      }
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "receiving peer identity\n");
       struct GNUNET_PeerIdentity *pid = (struct
                                          GNUNET_PeerIdentity *) stream_buf;
       peer->target = *pid;
-      peer->id_recvd = GNUNET_YES;
+      peer->id_rcvd = GNUNET_YES;
       buf_ptr += sizeof(struct GNUNET_PeerIdentity);
       recv_len -= sizeof(struct GNUNET_PeerIdentity);
     }
-    hdr = (struct GNUNET_MessageHeader *) buf_ptr;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %lu bytes to core\n",
-                recv_len);
-    GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr,
-                                           ADDRESS_VALIDITY_PERIOD, NULL, 
NULL);
+    /**
+     * Parse messages to pass to communicator
+    */
+    while (recv_len >= sizeof(struct GNUNET_MessageHeader))
+    {
+      hdr = (struct GNUNET_MessageHeader *) buf_ptr;
+      if (ntohs (hdr->size) > recv_len)
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "message size stated is greater than length of rcvd 
data!\n");
+        return;
+      }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %zd bytes to core\n",
+                  recv_len);
+      GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr,
+                                             ADDRESS_VALIDITY_PERIOD, NULL,
+                                             NULL);
+      recv_len -= ntohs (hdr->size);
+      buf_ptr += ntohs (hdr->size);
+    }
+    /**
+     * Check for leftover bytes
+    */
+    if (0 != recv_len)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "message recv len of %zd less than length of message 
header\n",
+                  recv_len);
+    }
+    /**
+     * fin
+    */
     if (fin)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -327,7 +356,6 @@ create_conn (uint8_t *scid, size_t scid_len,
 {
   struct quic_conn *conn;
   quiche_conn *q_conn;
-  struct GNUNET_HashCode conn_key;
   conn = GNUNET_new (struct quic_conn);
   if (scid_len != LOCAL_CONN_ID_LEN)
   {
@@ -351,13 +379,6 @@ create_conn (uint8_t *scid, size_t scid_len,
     return NULL;
   }
   conn->conn = q_conn;
-  // GNUNET_CRYPTO_hash (conn->cid, sizeof(conn->cid), &conn_key);
-  // /**
-  //  * TODO: use UNIQUE_FAST instead?
-  // */
-  // GNUNET_CONTAINER_multihashmap_put (conn_map, &conn_key, conn,
-  //                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new quic connection created\n");
   return conn;
 }
@@ -420,6 +441,8 @@ reschedule_peer_timeout (struct PeerAddress *peer)
 static void
 peer_destroy (struct PeerAddress *peer)
 {
+  struct GNUNET_HashCode addr_key;
+
   peer->peer_destroy_called = GNUNET_YES;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Disconnecting peer for peer `%s'\n",
@@ -429,14 +452,21 @@ peer_destroy (struct PeerAddress *peer)
     GNUNET_TRANSPORT_communicator_mq_del (peer->d_qh);
     peer->d_qh = NULL;
   }
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multipeermap_remove (peers,
-                                                       &peer->target,
-                                                       peer));
   GNUNET_assert (peer == GNUNET_CONTAINER_heap_remove_node (peer->hn));
+  /**
+   * Remove peer from hashmap
+  */
+  GNUNET_CRYPTO_hash (peer->address, peer->address_len, &addr_key);
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (addr_map, &addr_key,
+                                                         peer))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "tried to remove non-existent peer from addr map\n");
+    return;
+  }
   GNUNET_STATISTICS_set (stats,
                          "# peers active",
-                         GNUNET_CONTAINER_multipeermap_size (peers),
+                         GNUNET_CONTAINER_multihashmap_size (addr_map),
                          GNUNET_NO);
   quiche_conn_free (peer->conn->conn);
   GNUNET_free (peer->address);
@@ -450,18 +480,18 @@ peer_destroy (struct PeerAddress *peer)
  * Iterator over all peers to clean up.
  *
  * @param cls NULL
- * @param target unused
- * @param value the queue to destroy
+ * @param key peer->address
+ * @param value the peer to destroy
  * @return #GNUNET_OK to continue to iterate
  */
 static int
 get_peer_delete_it (void *cls,
-                    const struct GNUNET_PeerIdentity *target,
+                    const struct GNUNET_Hashcode *key,
                     void *value)
 {
   struct PeerAddress *peer = value;
   (void) cls;
-  (void) target;
+  (void) key;
   peer_destroy (peer);
   return GNUNET_OK;
 }
@@ -919,6 +949,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity 
*peer_id, const
   const char *path;
   struct sockaddr *in;
   socklen_t in_len;
+  struct GNUNET_HashCode addr_key;
   uint8_t scid[LOCAL_CONN_ID_LEN];
 
   ssize_t send_len;
@@ -952,22 +983,22 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity 
*peer_id, const
   path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
   in = udp_address_to_sockaddr (path, &in_len);
 
+  /**
+   * If we already have a queue with this peer, ignore
+  */
+  GNUNET_CRYPTO_hash (&in, in_len, &addr_key);
+  peer = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key);
+  if (NULL != peer)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "ignoring transport service mq request, we already have an mq 
with this peer (address)\n");
+    return GNUNET_SYSERR;
+  }
   peer = GNUNET_new (struct PeerAddress);
   peer->address = in;
   peer->address_len = in_len;
   peer->target = *peer_id;
   peer->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
-  /**
-   * TODO: use addr_map
-  */
-  (void) GNUNET_CONTAINER_multipeermap_put (
-    peers,
-    &peer->target,
-    peer,
-    GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Added %s to peers\n",
-              GNUNET_i2s_full (&peer->target));
   peer->timeout =
     GNUNET_TIME_relative_to_absolute 
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
   peer->hn = GNUNET_CONTAINER_heap_insert (peers_heap,
@@ -975,7 +1006,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity 
*peer_id, const
                                            peer->timeout.abs_value_us);
   GNUNET_STATISTICS_set (stats,
                          "# peers active",
-                         GNUNET_CONTAINER_multipeermap_size (peers),
+                         GNUNET_CONTAINER_multihashmap_size (addr_map),
                          GNUNET_NO);
   peer->foreign_addr =
     sockaddr_to_udpaddr_string (peer->address, peer->address_len);
@@ -1019,14 +1050,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity 
*peer_id, const
   /**
    * Insert peer into hashmap
   */
-  struct GNUNET_HashCode key;
-  GNUNET_CRYPTO_hash (peer->address, peer->address_len, &key);
-  if (GNUNET_SYSERR ==  GNUNET_CONTAINER_multihashmap_put (addr_map, &key, 
peer,
-                                                           
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "tried to add duplicate address into address map\n");
-  }
+  GNUNET_CONTAINER_multihashmap_put (addr_map, &addr_key,
+                                     peer,
+                                     
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new peer to the addr map\n");
   setup_peer_mq (peer);
   if (NULL == timeout_task)
@@ -1046,13 +1072,8 @@ do_shutdown (void *cls)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "do_shutdown\n");
-  GNUNET_CONTAINER_multipeermap_iterate (peers, &get_peer_delete_it, NULL);
-  GNUNET_CONTAINER_multipeermap_destroy (peers);
-  /**
-   * TODO: remove peers, just use addr_map
-  */
-  // GNUNET_CONTAINER_multihashmap_iterate (addr_map, &get_peer_delete_it, 
NULL);
-  // GNUNET_CONTAINER_multihashmap_destroy (addr_map);
+  GNUNET_CONTAINER_multihashmap_iterate (addr_map, &get_peer_delete_it, NULL);
+  GNUNET_CONTAINER_multihashmap_destroy (addr_map);
   quiche_config_free (config);
 
   if (NULL != timeout_task)
@@ -1100,7 +1121,6 @@ sock_read (void *cls)
   uint8_t buf[UINT16_MAX];
   uint8_t out[MAX_DATAGRAM_SIZE];
   ssize_t rcvd;
-  (void) cls;
 
   ssize_t process_pkt;
   struct QUIC_header quic_header;
@@ -1109,6 +1129,7 @@ sock_read (void *cls)
   struct PeerAddress *peer;
   struct GNUNET_HashCode addr_key;
 
+  (void) cls;
   quic_header.scid_len = sizeof(quic_header.scid);
   quic_header.dcid_len = sizeof(quic_header.dcid);
   quic_header.odcid_len = sizeof(quic_header.odcid);
@@ -1135,201 +1156,220 @@ sock_read (void *cls)
                                              udp_sock,
                                              &sock_read,
                                              NULL);
-  rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock,
-                                         buf,
-                                         sizeof(buf),
-                                         (struct sockaddr *) &sa,
-                                         &salen);
+  while (1)
+  {
+    rcvd = GNUNET_NETWORK_socket_recvfrom (udp_sock,
+                                           buf,
+                                           sizeof(buf),
+                                           (struct sockaddr *) &sa,
+                                           &salen);
+    if (-1 == rcvd)
+    {
+      if (EAGAIN == errno)
+        break; // We are done reading data
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv");
+      return;
+    }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Read %lu bytes\n", rcvd);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Read %lu bytes\n", rcvd);
 
-  if (-1 == rcvd)
-  {
-    GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv");
-    return;
-  }
-  GNUNET_CRYPTO_hash ((struct sockaddr *) &sa, salen,
-                      &addr_key);
-  peer = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key);
+    if (-1 == rcvd)
+    {
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_DEBUG, "recv");
+      return;
+    }
+    GNUNET_CRYPTO_hash ((struct sockaddr *) &sa, salen,
+                        &addr_key);
+    peer = GNUNET_CONTAINER_multihashmap_get (addr_map, &addr_key);
+
+    if (NULL == peer)
+    {
+      /**
+       * Create new PeerAddress (receiver) with id_rcvd = false
+      */
+      peer = GNUNET_new (struct PeerAddress);
+      peer->address = GNUNET_memdup (&sa, salen);
+      peer->address_len = salen;
+      peer->id_rcvd = GNUNET_NO;
+      peer->conn = NULL;
+      peer->foreign_addr = sockaddr_to_udpaddr_string (peer->address,
+                                                       peer->address_len);
+      setup_peer_mq (peer);
+      if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (addr_map,
+                                                              &addr_key,
+                                                              peer,
+                                                              
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+      {
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "tried to add duplicate address into address map\n");
+        return;
+      }
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "added new peer to address map\n");
+    }
 
-  if (NULL == peer)
-  {
     /**
-     * Create new PeerAddress (receiver) with id_recvd = false
+     * Parse QUIC info
     */
-    peer = GNUNET_new (struct PeerAddress);
-    peer->address = GNUNET_memdup (&sa, salen);
-    peer->address_len = salen;
-    peer->id_recvd = GNUNET_NO;
-    peer->conn = NULL;
-    peer->foreign_addr = sockaddr_to_udpaddr_string (peer->address,
-                                                     peer->address_len);
-    if (GNUNET_SYSERR == GNUNET_CONTAINER_multihashmap_put (addr_map, 
&addr_key,
-                                                            peer,
-                                                            
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+    int rc = quiche_header_info (buf, rcvd, LOCAL_CONN_ID_LEN,
+                                 &quic_header.version,
+                                 &quic_header.type, quic_header.scid,
+                                 &quic_header.scid_len, quic_header.dcid,
+                                 &quic_header.dcid_len,
+                                 quic_header.token, &quic_header.token_len);
+    if (0 > rc)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "tried to add duplicate address into address map\n");
+                  "failed to parse quic header: %d\n",
+                  rc);
       return;
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "added new peer to address map\n");
-  }
 
-  /**
-   * Parse QUIC info
-  */
-  int rc = quiche_header_info (buf, rcvd, LOCAL_CONN_ID_LEN,
-                               &quic_header.version,
-                               &quic_header.type, quic_header.scid,
-                               &quic_header.scid_len, quic_header.dcid,
-                               &quic_header.dcid_len,
-                               quic_header.token, &quic_header.token_len);
-  if (0 > rc)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "failed to parse quic header: %d\n",
-                rc);
-    return;
-  }
-
-  /**
-   * New QUIC connection with peer
-  */
-  if (NULL == peer->conn)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "attempting to create new connection\n");
-    if (0 == quiche_version_is_supported (quic_header.version))
+    /**
+     * New QUIC connection with peer
+    */
+    if (NULL == peer->conn)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "quic version negotiation initiated\n");
-      /**
-       * Write a version negotiation packet to "out"
-      */
-      ssize_t written = quiche_negotiate_version (quic_header.scid,
-                                                  quic_header.scid_len,
-                                                  quic_header.dcid,
-                                                  quic_header.dcid_len,
-                                                  out, sizeof(out));
-      if (0 > written)
+                  "attempting to create new connection\n");
+      if (0 == quiche_version_is_supported (quic_header.version))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "quiche failed to generate version negotiation packet\n");
+                    "quic version negotiation initiated\n");
+        /**
+         * Write a version negotiation packet to "out"
+        */
+        ssize_t written = quiche_negotiate_version (quic_header.scid,
+                                                    quic_header.scid_len,
+                                                    quic_header.dcid,
+                                                    quic_header.dcid_len,
+                                                    out, sizeof(out));
+        if (0 > written)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "quiche failed to generate version negotiation 
packet\n");
+          return;
+        }
+        ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock,
+                                                     out,
+                                                     written,
+                                                     (struct sockaddr*) &sa,
+                                                     salen);
+        if (sent != written)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "failed to send version negotiation packet to peer\n");
+          return;
+        }
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                    "sent %zd bytes to peer during version negotiation\n",
+                    sent);
         return;
       }
-      ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock,
-                                                   out,
-                                                   written,
-                                                   (struct sockaddr*) &sa,
-                                                   salen);
-      if (sent != written)
+
+      if (0 == quic_header.token_len)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "failed to send version negotiation packet to peer\n");
-        return;
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "quic stateless retry\n");
+        mint_token (quic_header.dcid, quic_header.dcid_len, &sa, salen,
+                    quic_header.token, &quic_header.token_len);
+
+        uint8_t new_cid[LOCAL_CONN_ID_LEN];
+        GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, new_cid,
+                                    LOCAL_CONN_ID_LEN);
+
+        ssize_t written = quiche_retry (quic_header.scid, quic_header.scid_len,
+                                        quic_header.dcid, quic_header.dcid_len,
+                                        new_cid, LOCAL_CONN_ID_LEN,
+                                        quic_header.token,
+                                        quic_header.token_len,
+                                        quic_header.version, out, sizeof(out));
+        if (0 > written)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                      "quiche failed to write retry packet\n");
+          return;
+        }
+        ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock,
+                                                     out,
+                                                     written,
+                                                     (struct sockaddr*) &sa,
+                                                     salen);
+        if (written != sent)
+        {
+          GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "failed to send retry 
packet\n");
+          return;
+        }
+
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent);
       }
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "sent %zd bytes to peer during version negotiation\n", sent);
-      return;
-    }
 
-    if (0 == quic_header.token_len)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "quic stateless retry\n");
-      mint_token (quic_header.dcid, quic_header.dcid_len, &sa, salen,
-                  quic_header.token, &quic_header.token_len);
-
-      uint8_t new_cid[LOCAL_CONN_ID_LEN];
-      GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, new_cid,
-                                  LOCAL_CONN_ID_LEN);
-
-      ssize_t written = quiche_retry (quic_header.scid, quic_header.scid_len,
-                                      quic_header.dcid, quic_header.dcid_len,
-                                      new_cid, LOCAL_CONN_ID_LEN,
-                                      quic_header.token, quic_header.token_len,
-                                      quic_header.version, out, sizeof(out));
-      if (0 > written)
+      if (GNUNET_OK != validate_token (quic_header.token, 
quic_header.token_len,
+                                       &sa, salen,
+                                       quic_header.odcid,
+                                       &quic_header.odcid_len))
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "quiche failed to write retry packet\n");
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "invalid address validation token created\n");
+        return;
       }
-      ssize_t sent = GNUNET_NETWORK_socket_sendto (udp_sock,
-                                                   out,
-                                                   written,
-                                                   (struct sockaddr*) &sa,
-                                                   salen);
-      if (written != sent)
+      peer->conn = create_conn (quic_header.dcid, quic_header.dcid_len,
+                                quic_header.odcid, quic_header.odcid_len,
+                                local_addr, in_len,
+                                &sa, salen);
+      if (NULL == peer->conn)
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "failed to send retry packet\n");
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "failed to create quic connection with peer\n");
+        return;
       }
+    } // null connection
 
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent);
-    }
+    quiche_recv_info recv_info = {
+      (struct sockaddr *) &sa,
+      salen,
 
-    if (GNUNET_OK != validate_token (quic_header.token, quic_header.token_len,
-                                     &sa, salen,
-                                     quic_header.odcid, 
&quic_header.odcid_len))
+      local_addr,
+      in_len,
+    };
+    process_pkt = quiche_conn_recv (peer->conn->conn, buf, rcvd, &recv_info);
+    if (0 > process_pkt)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "invalid address validation token created\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                  "quiche failed to process received packet: %zd\n",
+                  process_pkt);
+      return;
     }
-    peer->conn = create_conn (quic_header.dcid, quic_header.dcid_len,
-                              quic_header.odcid, quic_header.odcid_len,
-                              local_addr, in_len,
-                              &sa, salen);
-    if (NULL == peer->conn)
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "quiche processed %zd bytes\n", process_pkt);
+    /**
+     * Check for connection establishment
+    */
+    if (quiche_conn_is_established (peer->conn->conn))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  "failed to create quic connection with peer\n");
+      // Check for data on all available streams
+      recv_from_streams (peer);
     }
-  } // null connection
-
-  quiche_recv_info recv_info = {
-    (struct sockaddr *) &sa,
-    salen,
-
-    local_addr,
-    in_len,
-  };
-  process_pkt = quiche_conn_recv (peer->conn->conn, buf, rcvd, &recv_info);
-  if (0 > process_pkt)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "quiche failed to process received packet: %zd\n",
-                process_pkt);
-    return;
-  }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "quiche processed %zd bytes\n", process_pkt);
-  /**
-   * Check for connection establishment
-  */
-  if (quiche_conn_is_established (peer->conn->conn))
-  {
-    // Check for data on all available streams
-    recv_from_streams (peer);
-  }
-  /**
-   * TODO: Should we use a list instead of hashmap?
-   * Overhead for hashing function, O(1) retrieval vs O(n) iteration with n=30?
-   *
-   * TODO: Is iteration necessary as in the quiche server example?
-  */
-  quiche_stats stats;
-  quiche_path_stats path_stats;
+    /**
+     * TODO: Should we use a list instead of hashmap?
+     * Overhead for hashing function, O(1) retrieval vs O(n) iteration with 
n=30?
+     *
+     * TODO: Is iteration necessary as in the quiche server example?
+    */
+    quiche_stats stats;
+    quiche_path_stats path_stats;
 
-  flush_egress (peer->conn);
+    flush_egress (peer->conn);
 
-  if (quiche_conn_is_closed (peer->conn->conn))
-  {
-    quiche_conn_stats (peer->conn->conn, &stats);
-    quiche_conn_path_stats (peer->conn->conn, 0, &path_stats);
+    if (quiche_conn_is_closed (peer->conn->conn))
+    {
+      quiche_conn_stats (peer->conn->conn, &stats);
+      quiche_conn_path_stats (peer->conn->conn, 0, &path_stats);
 
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "connection closed. quiche stats: sent=%zu, recv=%zu\n",
-                stats.sent, stats.recv);
-    peer_destroy (peer);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "connection closed. quiche stats: sent=%zu, recv=%zu\n",
+                  stats.sent, stats.recv);
+      peer_destroy (peer);
+    }
   }
   GNUNET_free (local_addr);
 }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]