mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 17:18:48 -05:00
quiche: update for network path aware API
Latest version of quiche requires the application to pass the peer address of received packets, and it provides the address for outgoing packets back. Closes #7120
This commit is contained in:
parent
a62e6435f4
commit
424aa64d54
@ -2925,6 +2925,11 @@ if test X"$want_quiche" != Xno; then
|
||||
CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_QUICHE"
|
||||
export CURL_LIBRARY_PATH
|
||||
AC_MSG_NOTICE([Added $DIR_QUICHE to CURL_LIBRARY_PATH]),
|
||||
[],
|
||||
[
|
||||
AC_INCLUDES_DEFAULT
|
||||
#include <sys/socket.h>
|
||||
]
|
||||
)
|
||||
],
|
||||
dnl not found, revert back to clean variables
|
||||
|
@ -226,7 +226,7 @@ CURLcode Curl_quic_connect(struct Curl_easy *data,
|
||||
quiche_config_log_keys(qs->cfg);
|
||||
|
||||
qs->conn = quiche_connect(conn->host.name, (const uint8_t *) qs->scid,
|
||||
sizeof(qs->scid), qs->cfg);
|
||||
sizeof(qs->scid), addr, addrlen, qs->cfg);
|
||||
if(!qs->conn) {
|
||||
failf(data, "can't create quiche connection");
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
@ -360,6 +360,9 @@ static CURLcode process_ingress(struct Curl_easy *data, int sockfd,
|
||||
ssize_t recvd;
|
||||
uint8_t *buf = (uint8_t *)data->state.buffer;
|
||||
size_t bufsize = data->set.buffer_size;
|
||||
struct sockaddr_storage from;
|
||||
socklen_t from_len;
|
||||
quiche_recv_info recv_info;
|
||||
|
||||
DEBUGASSERT(qs->conn);
|
||||
|
||||
@ -367,17 +370,24 @@ static CURLcode process_ingress(struct Curl_easy *data, int sockfd,
|
||||
quiche_conn_on_timeout(qs->conn);
|
||||
|
||||
do {
|
||||
recvd = recv(sockfd, buf, bufsize, 0);
|
||||
from_len = sizeof(from);
|
||||
|
||||
recvd = recvfrom(sockfd, buf, bufsize, 0,
|
||||
(struct sockaddr *)&from, &from_len);
|
||||
|
||||
if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
|
||||
break;
|
||||
|
||||
if(recvd < 0) {
|
||||
failf(data, "quiche: recv() unexpectedly returned %zd "
|
||||
failf(data, "quiche: recvfrom() unexpectedly returned %zd "
|
||||
"(errno: %d, socket %d)", recvd, SOCKERRNO, sockfd);
|
||||
return CURLE_RECV_ERROR;
|
||||
}
|
||||
|
||||
recvd = quiche_conn_recv(qs->conn, buf, recvd);
|
||||
recv_info.from = (struct sockaddr *) &from;
|
||||
recv_info.from_len = from_len;
|
||||
|
||||
recvd = quiche_conn_recv(qs->conn, buf, recvd, &recv_info);
|
||||
if(recvd == QUICHE_ERR_DONE)
|
||||
break;
|
||||
|
||||
@ -400,9 +410,10 @@ static CURLcode flush_egress(struct Curl_easy *data, int sockfd,
|
||||
ssize_t sent;
|
||||
uint8_t out[1200];
|
||||
int64_t timeout_ns;
|
||||
quiche_send_info send_info;
|
||||
|
||||
do {
|
||||
sent = quiche_conn_send(qs->conn, out, sizeof(out));
|
||||
sent = quiche_conn_send(qs->conn, out, sizeof(out), &send_info);
|
||||
if(sent == QUICHE_ERR_DONE)
|
||||
break;
|
||||
|
||||
@ -411,9 +422,10 @@ static CURLcode flush_egress(struct Curl_easy *data, int sockfd,
|
||||
return CURLE_SEND_ERROR;
|
||||
}
|
||||
|
||||
sent = send(sockfd, out, sent, 0);
|
||||
sent = sendto(sockfd, out, sent, 0,
|
||||
(struct sockaddr *)&send_info.to, send_info.to_len);
|
||||
if(sent < 0) {
|
||||
failf(data, "send() returned %zd", sent);
|
||||
failf(data, "sendto() returned %zd", sent);
|
||||
return CURLE_SEND_ERROR;
|
||||
}
|
||||
} while(1);
|
||||
|
Loading…
Reference in New Issue
Block a user