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.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c
index e2fd970bf..b31d86cf7 100644
--- a/src/transport/gnunet-communicator-quic.c
+++ b/src/transport/gnunet-communicator-quic.c
@@ -254,18 +254,38 @@ recv_from_streams (struct PeerAddress *peer)
254 buf_ptr += sizeof(struct GNUNET_PeerIdentity); 254 buf_ptr += sizeof(struct GNUNET_PeerIdentity);
255 recv_len -= sizeof(struct GNUNET_PeerIdentity); 255 recv_len -= sizeof(struct GNUNET_PeerIdentity);
256 } 256 }
257 257 /**
258 if (recv_len < sizeof(struct GNUNET_MessageHeader)) 258 * Parse messages to pass to communicator
259 */
260 while (recv_len >= sizeof(struct GNUNET_MessageHeader))
261 {
262 hdr = (struct GNUNET_MessageHeader *) buf_ptr;
263 if (ntohs (hdr->size) > recv_len)
264 {
265 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
266 "message size stated is greater than length of recvd data!\n");
267 return;
268 }
269 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %zd bytes to core\n",
270 recv_len);
271 GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr,
272 ADDRESS_VALIDITY_PERIOD, NULL,
273 NULL);
274 recv_len -= ntohs (hdr->size);
275 buf_ptr += ntohs (hdr->size);
276 }
277 /**
278 * Check for leftover bytes
279 */
280 if (0 != recv_len)
259 { 281 {
260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 282 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
261 "message recv len of %zd less than length of message header\n", 283 "message recv len of %zd less than length of message header\n",
262 recv_len); 284 recv_len);
263 } 285 }
264 hdr = (struct GNUNET_MessageHeader *) buf_ptr; 286 /**
265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %zd bytes to core\n", 287 * fin
266 recv_len); 288 */
267 GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr,
268 ADDRESS_VALIDITY_PERIOD, NULL, NULL);
269 if (fin) 289 if (fin)
270 { 290 {
271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -966,6 +986,10 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const
966 path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; 986 path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")];
967 in = udp_address_to_sockaddr (path, &in_len); 987 in = udp_address_to_sockaddr (path, &in_len);
968 988
989 /**
990 * TODO: Check for existing peer (i.e. if we received a message from this address before)
991 */
992
969 peer = GNUNET_new (struct PeerAddress); 993 peer = GNUNET_new (struct PeerAddress);
970 peer->address = in; 994 peer->address = in;
971 peer->address_len = in_len; 995 peer->address_len = in_len;
@@ -1040,6 +1064,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const
1040 { 1064 {
1041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1065 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1042 "tried to add duplicate address into address map\n"); 1066 "tried to add duplicate address into address map\n");
1067 peer_destroy (peer);
1068 GNUNET_free (local_addr);
1069 return GNUNET_SYSERR;
1043 } 1070 }
1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new peer to the addr map\n"); 1071 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Added new peer to the addr map\n");
1045 setup_peer_mq (peer); 1072 setup_peer_mq (peer);