aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authormarshall <stmr@umich.edu>2023-08-23 15:59:08 -0400
committermarshall <stmr@umich.edu>2023-08-23 15:59:08 -0400
commit227bceda73093c37c1a0ab8e340be775b830d40f (patch)
treee36ccec5d5f15f5c24e82efc0aef523e0918e59a /src/transport
parentc311186fa3ae22cff3d5e9f6cca127d0ee2524ec (diff)
downloadgnunet-227bceda73093c37c1a0ab8e340be775b830d40f.tar.gz
gnunet-227bceda73093c37c1a0ab8e340be775b830d40f.zip
quic: differentiate receiver
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-quic.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c
index 13600a3fb..7c89b10b6 100644
--- a/src/transport/gnunet-communicator-quic.c
+++ b/src/transport/gnunet-communicator-quic.c
@@ -28,7 +28,6 @@
28#define TOKEN_LEN sizeof(uint8_t) * MAX_TOKEN_LEN 28#define TOKEN_LEN sizeof(uint8_t) * MAX_TOKEN_LEN
29/* Generic, bidirectional, client-initiated quic stream id */ 29/* Generic, bidirectional, client-initiated quic stream id */
30#define STREAMID_BI 4 30#define STREAMID_BI 4
31#define PEERID_LEN sizeof(struct GNUNET_PeerIdentity)
32/** 31/**
33 * How long do we believe our addresses to remain up (before 32 * How long do we believe our addresses to remain up (before
34 * the other peer should revalidate). 33 * the other peer should revalidate).
@@ -92,6 +91,11 @@ struct PeerAddress
92 int id_sent; 91 int id_sent;
93 92
94 /** 93 /**
94 * Flag to indicate if we are the initiator of the connection
95 */
96 int is_receiver;
97
98 /**
95 * Address of the receiver in the human-readable format 99 * Address of the receiver in the human-readable format
96 * with the #COMMUNICATOR_ADDRESS_PREFIX. 100 * with the #COMMUNICATOR_ADDRESS_PREFIX.
97 */ 101 */
@@ -239,9 +243,9 @@ recv_from_streams (struct PeerAddress *peer)
239 break; 243 break;
240 } 244 }
241 /** 245 /**
242 * Initial packet should contain peerid 246 * Initial packet should contain peerid if they are the initiator
243 */ 247 */
244 if (GNUNET_NO == peer->id_rcvd) 248 if (! peer->is_receiver && GNUNET_NO == peer->id_rcvd)
245 { 249 {
246 if (recv_len < sizeof(struct GNUNET_PeerIdentity)) 250 if (recv_len < sizeof(struct GNUNET_PeerIdentity))
247 { 251 {
@@ -1015,6 +1019,8 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const
1015 peer->address = in; 1019 peer->address = in;
1016 peer->address_len = in_len; 1020 peer->address_len = in_len;
1017 peer->target = *peer_id; 1021 peer->target = *peer_id;
1022 peer->id_rcvd = GNUNET_YES;
1023 peer->is_receiver = GNUNET_YES;
1018 peer->nt = GNUNET_NT_scanner_get_type (is, in, in_len); 1024 peer->nt = GNUNET_NT_scanner_get_type (is, in, in_len);
1019 peer->timeout = 1025 peer->timeout =
1020 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); 1026 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
@@ -1256,6 +1262,7 @@ sock_read (void *cls)
1256 peer->address_len = salen; 1262 peer->address_len = salen;
1257 peer->id_rcvd = GNUNET_NO; 1263 peer->id_rcvd = GNUNET_NO;
1258 peer->id_sent = GNUNET_NO; 1264 peer->id_sent = GNUNET_NO;
1265 peer->is_receiver = GNUNET_NO;
1259 peer->conn = NULL; 1266 peer->conn = NULL;
1260 peer->foreign_addr = sockaddr_to_udpaddr_string (peer->address, 1267 peer->foreign_addr = sockaddr_to_udpaddr_string (peer->address,
1261 peer->address_len); 1268 peer->address_len);
@@ -1403,16 +1410,16 @@ sock_read (void *cls)
1403 /** 1410 /**
1404 * Send our PeerIdentity if the connection is established now 1411 * Send our PeerIdentity if the connection is established now
1405 */ 1412 */
1406 if (quiche_conn_is_established (peer->conn->conn) && ! peer->id_sent) 1413 if (quiche_conn_is_established (peer->conn->conn) && ! peer->id_sent &&
1414 peer->is_receiver)
1407 { 1415 {
1408 char my_pid[PEERID_LEN];
1409 ssize_t send_len; 1416 ssize_t send_len;
1410 1417
1411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1418 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1412 "handshake established with peer, sending our peer id\n"); 1419 "handshake established with peer, sending our peer id\n");
1413 GNUNET_memcpy (my_pid, &my_identity, PEERID_LEN); 1420 send_len = quiche_conn_stream_send (peer->conn->conn, STREAMID_BI,
1414 send_len = quiche_conn_stream_send (peer->conn->conn, STREAMID_BI, my_pid, 1421 (const uint8_t *) &my_identity,
1415 PEERID_LEN, 1422 sizeof(my_identity),
1416 true); 1423 true);
1417 if (0 > send_len) 1424 if (0 > send_len)
1418 { 1425 {