diff options
Diffstat (limited to 'src/transport/gnunet-communicator-quic.c')
-rw-r--r-- | src/transport/gnunet-communicator-quic.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/transport/gnunet-communicator-quic.c b/src/transport/gnunet-communicator-quic.c index 2349ce770..3ae120513 100644 --- a/src/transport/gnunet-communicator-quic.c +++ b/src/transport/gnunet-communicator-quic.c | |||
@@ -26,6 +26,13 @@ | |||
26 | QUICHE_MAX_CONN_ID_LEN | 26 | QUICHE_MAX_CONN_ID_LEN |
27 | #define CID_LEN sizeof(uint8_t) * QUICHE_MAX_CONN_ID_LEN | 27 | #define CID_LEN sizeof(uint8_t) * QUICHE_MAX_CONN_ID_LEN |
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 */ | ||
30 | #define STREAMID_BI 4 | ||
31 | /** | ||
32 | * How long do we believe our addresses to remain up (before | ||
33 | * the other peer should revalidate). | ||
34 | */ | ||
35 | #define ADDRESS_VALIDITY_PERIOD GNUNET_TIME_UNIT_HOURS | ||
29 | /** | 36 | /** |
30 | * Map of DCID (uint8_t) -> quic_conn for quickly retrieving connections to other peers. | 37 | * Map of DCID (uint8_t) -> quic_conn for quickly retrieving connections to other peers. |
31 | */ | 38 | */ |
@@ -188,6 +195,9 @@ recv_from_streams (struct PeerAddress *peer) | |||
188 | { | 195 | { |
189 | char stream_buf[UINT16_MAX]; | 196 | char stream_buf[UINT16_MAX]; |
190 | size_t buf_size = UINT16_MAX; | 197 | size_t buf_size = UINT16_MAX; |
198 | char *buf_ptr = stream_buf; | ||
199 | struct GNUNET_MessageHeader *hdr; | ||
200 | |||
191 | uint64_t s = 0; | 201 | uint64_t s = 0; |
192 | quiche_stream_iter *readable; | 202 | quiche_stream_iter *readable; |
193 | bool fin; | 203 | bool fin; |
@@ -207,10 +217,8 @@ recv_from_streams (struct PeerAddress *peer) | |||
207 | break; | 217 | break; |
208 | } | 218 | } |
209 | /** | 219 | /** |
210 | * Received and processed plaintext from peer: send to core/transport service | 220 | * Initial packet should contain peerid |
211 | * TODO: send msg to core, remove response below | ||
212 | */ | 221 | */ |
213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "msg received!\n"); | ||
214 | if (GNUNET_NO == peer->id_recvd) | 222 | if (GNUNET_NO == peer->id_recvd) |
215 | { | 223 | { |
216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -219,13 +227,22 @@ recv_from_streams (struct PeerAddress *peer) | |||
219 | GNUNET_PeerIdentity *) stream_buf; | 227 | GNUNET_PeerIdentity *) stream_buf; |
220 | peer->target = *pid; | 228 | peer->target = *pid; |
221 | peer->id_recvd = GNUNET_YES; | 229 | peer->id_recvd = GNUNET_YES; |
230 | buf_ptr += sizeof(struct GNUNET_PeerIdentity); | ||
231 | recv_len -= sizeof(struct GNUNET_PeerIdentity); | ||
222 | } | 232 | } |
233 | hdr = (struct GNUNET_MessageHeader *) buf_ptr; | ||
234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "passing %lu bytes to core\n", | ||
235 | recv_len); | ||
236 | GNUNET_TRANSPORT_communicator_receive (ch, &peer->target, hdr, | ||
237 | ADDRESS_VALIDITY_PERIOD, NULL, NULL); | ||
223 | if (fin) | 238 | if (fin) |
224 | { | 239 | { |
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
241 | "fin received, closing connection\n"); | ||
225 | if (0 > quiche_conn_close (peer->conn->conn, true, 0, NULL, 0)) | 242 | if (0 > quiche_conn_close (peer->conn->conn, true, 0, NULL, 0)) |
226 | { | 243 | { |
227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
228 | "fin received and quiche failed to close connection to peer\n"); | 245 | "quiche failed to close connection to peer\n"); |
229 | } | 246 | } |
230 | } | 247 | } |
231 | } | 248 | } |
@@ -873,6 +890,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const | |||
873 | socklen_t local_in_len; | 890 | socklen_t local_in_len; |
874 | struct sockaddr *local_addr; | 891 | struct sockaddr *local_addr; |
875 | 892 | ||
893 | |||
876 | if (GNUNET_OK != | 894 | if (GNUNET_OK != |
877 | GNUNET_CONFIGURATION_get_value_string (cfg, | 895 | GNUNET_CONFIGURATION_get_value_string (cfg, |
878 | COMMUNICATOR_CONFIG_SECTION, | 896 | COMMUNICATOR_CONFIG_SECTION, |
@@ -933,9 +951,8 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer_id, const | |||
933 | local_addr, | 951 | local_addr, |
934 | local_in_len, peer->address, peer->address_len, | 952 | local_in_len, peer->address, peer->address_len, |
935 | config); | 953 | config); |
936 | |||
937 | |||
938 | peer->conn = q_conn; | 954 | peer->conn = q_conn; |
955 | // quiche_conn_send (peer->conn->conn, ) | ||
939 | /** | 956 | /** |
940 | * Insert connection into hashmap | 957 | * Insert connection into hashmap |
941 | */ | 958 | */ |