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.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c
index 7cf95368d..22e567a81 100644
--- a/src/transport/gnunet-communicator-quic.c
+++ b/src/transport/gnunet-communicator-quic.c
@@ -1,3 +1,4 @@
1#include "gnunet_common.h"
1#include "gnunet_util_lib.h" 2#include "gnunet_util_lib.h"
2#include "gnunet_core_service.h" 3#include "gnunet_core_service.h"
3#include "quiche.h" 4#include "quiche.h"
@@ -84,6 +85,7 @@ struct ReceiverAddress
84 85
85 /** 86 /**
86 * MTU we allowed transport for this receiver's default queue. 87 * MTU we allowed transport for this receiver's default queue.
88 * FIXME: You may want to get the MTU from quiche, possibly from quiche_path_stats struct.
87 */ 89 */
88 size_t d_mtu; 90 size_t d_mtu;
89 91
@@ -171,7 +173,7 @@ struct QUIC_header
171 * ASSUMES: connection is established to peer 173 * ASSUMES: connection is established to peer
172*/ 174*/
173static void 175static void
174recv_from_streams (quiche_conn *conn, char stream_buf[], size_t buf_size) 176recv_from_streams (quiche_conn *conn, char*stream_buf, size_t buf_size)
175{ 177{
176 uint64_t s = 0; 178 uint64_t s = 0;
177 quiche_stream_iter *readable; 179 quiche_stream_iter *readable;
@@ -223,7 +225,7 @@ mint_token (const uint8_t *dcid, size_t dcid_len,
223} 225}
224 226
225 227
226static bool 228static enum GNUNET_GenericReturnValue
227validate_token (const uint8_t *token, size_t token_len, 229validate_token (const uint8_t *token, size_t token_len,
228 struct sockaddr_storage *addr, socklen_t addr_len, 230 struct sockaddr_storage *addr, socklen_t addr_len,
229 uint8_t *odcid, size_t *odcid_len) 231 uint8_t *odcid, size_t *odcid_len)
@@ -231,7 +233,7 @@ validate_token (const uint8_t *token, size_t token_len,
231 if ((token_len < sizeof("quiche") - 1) || 233 if ((token_len < sizeof("quiche") - 1) ||
232 memcmp (token, "quiche", sizeof("quiche") - 1)) 234 memcmp (token, "quiche", sizeof("quiche") - 1))
233 { 235 {
234 return false; 236 return GNUNET_NO;
235 } 237 }
236 238
237 token += sizeof("quiche") - 1; 239 token += sizeof("quiche") - 1;
@@ -239,7 +241,7 @@ validate_token (const uint8_t *token, size_t token_len,
239 241
240 if ((token_len < addr_len) || memcmp (token, addr, addr_len)) 242 if ((token_len < addr_len) || memcmp (token, addr, addr_len))
241 { 243 {
242 return false; 244 return GNUNET_NO;
243 } 245 }
244 246
245 token += addr_len; 247 token += addr_len;
@@ -247,13 +249,13 @@ validate_token (const uint8_t *token, size_t token_len,
247 249
248 if (*odcid_len < token_len) 250 if (*odcid_len < token_len)
249 { 251 {
250 return false; 252 return GNUNET_NO;
251 } 253 }
252 254
253 memcpy (odcid, token, token_len); 255 memcpy (odcid, token, token_len);
254 *odcid_len = token_len; 256 *odcid_len = token_len;
255 257
256 return true; 258 return GNUNET_OK;
257} 259}
258 260
259 261
@@ -269,11 +271,17 @@ create_conn (uint8_t *scid, size_t scid_len,
269 quiche_conn *q_conn; 271 quiche_conn *q_conn;
270 struct GNUNET_HashCode conn_key; 272 struct GNUNET_HashCode conn_key;
271 273
274 /**
275 * FIXME:
276 * GNUnet has a convienience function:
277 * conn = GNUNET_new (struct quic_conn);
278 */
272 conn = GNUNET_malloc (sizeof(struct quic_conn)); 279 conn = GNUNET_malloc (sizeof(struct quic_conn));
273 if (scid_len != LOCAL_CONN_ID_LEN) 280 if (scid_len != LOCAL_CONN_ID_LEN)
274 { 281 {
275 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 282 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
276 "error while creating connection, scid length too short\n"); 283 "error while creating connection, scid length too short\n");
284 /* FIXME: Return? Handle error? Warn? */
277 } 285 }
278 286
279 GNUNET_memcpy (conn->cid, scid, LOCAL_CONN_ID_LEN); 287 GNUNET_memcpy (conn->cid, scid, LOCAL_CONN_ID_LEN);
@@ -917,9 +925,9 @@ sock_read (void *cls)
917 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent); 925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sent %zd bytes\n", sent);
918 } 926 }
919 927
920 if (0 == validate_token (quic_header.token, quic_header.token_len, 928 if (GNUNET_OK != validate_token (quic_header.token, quic_header.token_len,
921 &sa, salen, 929 &sa, salen,
922 quic_header.odcid, &quic_header.odcid_len)) 930 quic_header.odcid, &quic_header.odcid_len))
923 { 931 {
924 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 932 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
925 "invalid address validation token created\n"); 933 "invalid address validation token created\n");