aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/vquic/quiche.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/curl/lib/vquic/quiche.c
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/vquic/quiche.c')
-rw-r--r--contrib/libs/curl/lib/vquic/quiche.c256
1 files changed, 128 insertions, 128 deletions
diff --git a/contrib/libs/curl/lib/vquic/quiche.c b/contrib/libs/curl/lib/vquic/quiche.c
index c50cccd4b3..6b3eaf470e 100644
--- a/contrib/libs/curl/lib/vquic/quiche.c
+++ b/contrib/libs/curl/lib/vquic/quiche.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -34,7 +34,7 @@
#include "multiif.h"
#include "connect.h"
#include "strerror.h"
-#error #include "vquic.h"
+#error #include "vquic.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -46,12 +46,12 @@
#ifdef DEBUG_HTTP3
#define H3BUGF(x) x
#else
-#define H3BUGF(x) do { } while(0)
+#define H3BUGF(x) do { } while(0)
#endif
#define QUIC_MAX_STREAMS (256*1024)
#define QUIC_MAX_DATA (1*1024*1024)
-#define QUIC_IDLE_TIMEOUT (60 * 1000) /* milliseconds */
+#define QUIC_IDLE_TIMEOUT (60 * 1000) /* milliseconds */
static CURLcode process_ingress(struct connectdata *conn,
curl_socket_t sockfd,
@@ -89,43 +89,43 @@ static int quiche_perform_getsock(const struct connectdata *conn,
return quiche_getsock((struct connectdata *)conn, socks);
}
-static CURLcode qs_disconnect(struct connectdata *conn,
- struct quicsocket *qs)
-{
- if(qs->conn) {
- (void)quiche_conn_close(qs->conn, TRUE, 0, NULL, 0);
- /* flushing the egress is not a failsafe way to deliver all the
- outstanding packets, but we also don't want to get stuck here... */
- (void)flush_egress(conn, qs->sockfd, qs);
- quiche_conn_free(qs->conn);
- qs->conn = NULL;
- }
- if(qs->h3config)
- quiche_h3_config_free(qs->h3config);
- if(qs->h3c)
- quiche_h3_conn_free(qs->h3c);
- if(qs->cfg) {
- quiche_config_free(qs->cfg);
- qs->cfg = NULL;
- }
- return CURLE_OK;
-}
-
+static CURLcode qs_disconnect(struct connectdata *conn,
+ struct quicsocket *qs)
+{
+ if(qs->conn) {
+ (void)quiche_conn_close(qs->conn, TRUE, 0, NULL, 0);
+ /* flushing the egress is not a failsafe way to deliver all the
+ outstanding packets, but we also don't want to get stuck here... */
+ (void)flush_egress(conn, qs->sockfd, qs);
+ quiche_conn_free(qs->conn);
+ qs->conn = NULL;
+ }
+ if(qs->h3config)
+ quiche_h3_config_free(qs->h3config);
+ if(qs->h3c)
+ quiche_h3_conn_free(qs->h3c);
+ if(qs->cfg) {
+ quiche_config_free(qs->cfg);
+ qs->cfg = NULL;
+ }
+ return CURLE_OK;
+}
+
static CURLcode quiche_disconnect(struct connectdata *conn,
bool dead_connection)
{
struct quicsocket *qs = conn->quic;
(void)dead_connection;
- return qs_disconnect(conn, qs);
-}
-
-void Curl_quic_disconnect(struct connectdata *conn,
- int tempindex)
-{
- if(conn->transport == TRNSPRT_QUIC)
- qs_disconnect(conn, &conn->hequic[tempindex]);
+ return qs_disconnect(conn, qs);
}
+void Curl_quic_disconnect(struct connectdata *conn,
+ int tempindex)
+{
+ if(conn->transport == TRNSPRT_QUIC)
+ qs_disconnect(conn, &conn->hequic[tempindex]);
+}
+
static unsigned int quiche_conncheck(struct connectdata *conn,
unsigned int checks_to_perform)
{
@@ -136,7 +136,7 @@ static unsigned int quiche_conncheck(struct connectdata *conn,
static CURLcode quiche_do(struct connectdata *conn, bool *done)
{
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
stream->h3req = FALSE; /* not sent */
return Curl_http(conn, done);
}
@@ -159,7 +159,7 @@ static const struct Curl_handler Curl_handler_http3 = {
quiche_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
- CURLPROTO_HTTP, /* family */
+ CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
};
@@ -178,7 +178,7 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
CURLcode result;
struct quicsocket *qs = &conn->hequic[sockindex];
struct Curl_easy *data = conn->data;
- char *keylog_file = NULL;
+ char *keylog_file = NULL;
#ifdef DEBUG_QUICHE
/* initialize debug log callback only once */
@@ -192,14 +192,14 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
(void)addr;
(void)addrlen;
- qs->sockfd = sockfd;
+ qs->sockfd = sockfd;
qs->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION);
if(!qs->cfg) {
failf(data, "can't create quiche config");
return CURLE_FAILED_INIT;
}
- quiche_config_set_max_idle_timeout(qs->cfg, QUIC_IDLE_TIMEOUT);
+ quiche_config_set_max_idle_timeout(qs->cfg, QUIC_IDLE_TIMEOUT);
quiche_config_set_initial_max_data(qs->cfg, QUIC_MAX_DATA);
quiche_config_set_initial_max_stream_data_bidi_local(qs->cfg, QUIC_MAX_DATA);
quiche_config_set_initial_max_stream_data_bidi_remote(qs->cfg,
@@ -217,9 +217,9 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
if(result)
return result;
- keylog_file = getenv("SSLKEYLOGFILE");
-
- if(keylog_file)
+ keylog_file = getenv("SSLKEYLOGFILE");
+
+ if(keylog_file)
quiche_config_log_keys(qs->cfg);
qs->conn = quiche_connect(conn->host.name, (const uint8_t *) qs->scid,
@@ -229,53 +229,53 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
return CURLE_OUT_OF_MEMORY;
}
- if(keylog_file)
- quiche_conn_set_keylog_path(qs->conn, keylog_file);
-
- /* Known to not work on Windows */
-#if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
- {
- int qfd;
- (void)Curl_qlogdir(data, qs->scid, sizeof(qs->scid), &qfd);
- if(qfd != -1)
- quiche_conn_set_qlog_fd(qs->conn, qfd,
- "qlog title", "curl qlog");
- }
-#endif
-
+ if(keylog_file)
+ quiche_conn_set_keylog_path(qs->conn, keylog_file);
+
+ /* Known to not work on Windows */
+#if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
+ {
+ int qfd;
+ (void)Curl_qlogdir(data, qs->scid, sizeof(qs->scid), &qfd);
+ if(qfd != -1)
+ quiche_conn_set_qlog_fd(qs->conn, qfd,
+ "qlog title", "curl qlog");
+ }
+#endif
+
result = flush_egress(conn, sockfd, qs);
if(result)
return result;
/* store the used address as a string */
- if(!Curl_addr2string((struct sockaddr*)addr, addrlen,
+ if(!Curl_addr2string((struct sockaddr*)addr, addrlen,
conn->primary_ip, &conn->primary_port)) {
char buffer[STRERROR_LEN];
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
- SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_BAD_FUNCTION_ARGUMENT;
}
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
- Curl_persistconninfo(conn);
-
+ Curl_persistconninfo(conn);
+
/* for connection reuse purposes: */
conn->ssl[FIRSTSOCKET].state = ssl_connection_complete;
- {
- unsigned char alpn_protocols[] = QUICHE_H3_APPLICATION_PROTOCOL;
- unsigned alpn_len, offset = 0;
-
- /* Replace each ALPN length prefix by a comma. */
- while(offset < sizeof(alpn_protocols) - 1) {
- alpn_len = alpn_protocols[offset];
- alpn_protocols[offset] = ',';
- offset += 1 + alpn_len;
- }
-
- infof(data, "Sent QUIC client Initial, ALPN: %s\n",
- alpn_protocols + 1);
- }
-
+ {
+ unsigned char alpn_protocols[] = QUICHE_H3_APPLICATION_PROTOCOL;
+ unsigned alpn_len, offset = 0;
+
+ /* Replace each ALPN length prefix by a comma. */
+ while(offset < sizeof(alpn_protocols) - 1) {
+ alpn_len = alpn_protocols[offset];
+ alpn_protocols[offset] = ',';
+ offset += 1 + alpn_len;
+ }
+
+ infof(data, "Sent QUIC client Initial, ALPN: %s\n",
+ alpn_protocols + 1);
+ }
+
return CURLE_OK;
}
@@ -293,7 +293,7 @@ static CURLcode quiche_has_connected(struct connectdata *conn,
conn->httpversion = 30;
conn->bundle->multiuse = BUNDLE_MULTIPLEX;
- qs->h3config = quiche_h3_config_new();
+ qs->h3config = quiche_h3_config_new();
if(!qs->h3config)
return CURLE_OUT_OF_MEMORY;
@@ -329,11 +329,11 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
result = process_ingress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
result = flush_egress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
if(quiche_conn_is_established(qs->conn)) {
*done = TRUE;
@@ -342,9 +342,9 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
}
return result;
- error:
- qs_disconnect(conn, qs);
- return result;
+ error:
+ qs_disconnect(conn, qs);
+ return result;
}
static CURLcode process_ingress(struct connectdata *conn, int sockfd,
@@ -360,11 +360,11 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd,
do {
recvd = recv(sockfd, buf, bufsize, 0);
- if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
+ if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
break;
if(recvd < 0) {
- failf(conn->data, "quiche: recv() unexpectedly returned %zd "
+ failf(conn->data, "quiche: recv() unexpectedly returned %zd "
"(errno: %d, socket %d)", recvd, SOCKERRNO, sockfd);
return CURLE_RECV_ERROR;
}
@@ -374,7 +374,7 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd,
break;
if(recvd < 0) {
- failf(conn->data, "quiche_conn_recv() == %zd", recvd);
+ failf(conn->data, "quiche_conn_recv() == %zd", recvd);
return CURLE_RECV_ERROR;
}
} while(1);
@@ -390,7 +390,7 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd,
struct quicsocket *qs)
{
ssize_t sent;
- uint8_t out[1200];
+ uint8_t out[1200];
int64_t timeout_ns;
do {
@@ -438,9 +438,9 @@ static int cb_each_header(uint8_t *name, size_t name_len,
headers->destlen, "HTTP/3 %.*s\n",
(int) value_len, value);
}
- else if(!headers->nlen) {
- return CURLE_HTTP3;
- }
+ else if(!headers->nlen) {
+ return CURLE_HTTP3;
+ }
else {
msnprintf(headers->dest,
headers->destlen, "%.*s: %.*s\n",
@@ -466,14 +466,14 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
quiche_h3_event *ev;
int rc;
struct h3h1header headers;
- struct Curl_easy *data = conn->data;
- struct HTTP *stream = data->req.p.http;
+ struct Curl_easy *data = conn->data;
+ struct HTTP *stream = data->req.p.http;
headers.dest = buf;
headers.destlen = buffersize;
headers.nlen = 0;
if(process_ingress(conn, sockfd, qs)) {
- infof(data, "h3_stream_recv returns on ingress\n");
+ infof(data, "h3_stream_recv returns on ingress\n");
*curlcode = CURLE_RECV_ERROR;
return -1;
}
@@ -486,7 +486,7 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
if(s != stream->stream3_id) {
/* another transfer, ignore for now */
- infof(data, "Got h3 for stream %u, expects %u\n",
+ infof(data, "Got h3 for stream %u, expects %u\n",
s, stream->stream3_id);
continue;
}
@@ -495,9 +495,9 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
case QUICHE_H3_EVENT_HEADERS:
rc = quiche_h3_event_for_each_header(ev, cb_each_header, &headers);
if(rc) {
- *curlcode = rc;
- failf(data, "Error in HTTP/3 response header");
- break;
+ *curlcode = rc;
+ failf(data, "Error in HTTP/3 response header");
+ break;
}
recvd = headers.nlen;
break;
@@ -523,7 +523,7 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
break;
case QUICHE_H3_EVENT_FINISHED:
- streamclose(conn, "End of stream");
+ streamclose(conn, "End of stream");
recvd = 0; /* end of stream */
break;
default:
@@ -540,9 +540,9 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
*curlcode = (-1 == recvd)? CURLE_AGAIN : CURLE_OK;
if(recvd >= 0)
/* Get this called again to drain the event queue */
- Curl_expire(data, 0, EXPIRE_QUIC);
-
- data->state.drain = (recvd >= 0) ? 1 : 0;
+ Curl_expire(data, 0, EXPIRE_QUIC);
+
+ data->state.drain = (recvd >= 0) ? 1 : 0;
return recvd;
}
@@ -555,7 +555,7 @@ static ssize_t h3_stream_send(struct connectdata *conn,
ssize_t sent;
struct quicsocket *qs = conn->quic;
curl_socket_t sockfd = conn->sock[sockindex];
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
if(!stream->h3req) {
CURLcode result = http_request(conn, mem, len);
@@ -591,7 +591,7 @@ static ssize_t h3_stream_send(struct connectdata *conn,
*/
int Curl_quic_ver(char *p, size_t len)
{
- return msnprintf(p, len, "quiche/%s", quiche_version());
+ return msnprintf(p, len, "quiche/%s", quiche_version());
}
/* Index where :authority header field will appear in request header
@@ -603,7 +603,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
{
/*
*/
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
size_t nheader;
size_t i;
size_t authority_idx;
@@ -711,9 +711,9 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
nva[i].name_len = strlen((char *)nva[i].name);
}
else {
- nva[i].name_len = (size_t)(end - hdbuf);
- /* Lower case the header name for HTTP/3 */
- Curl_strntolower((char *)hdbuf, hdbuf, nva[i].name_len);
+ nva[i].name_len = (size_t)(end - hdbuf);
+ /* Lower case the header name for HTTP/3 */
+ Curl_strntolower((char *)hdbuf, hdbuf, nva[i].name_len);
nva[i].name = (unsigned char *)hdbuf;
}
hdbuf = end + 1;
@@ -768,12 +768,12 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
if(acc > MAX_ACC) {
infof(data, "http_request: Warning: The cumulative length of all "
- "headers exceeds %d bytes and that could cause the "
+ "headers exceeds %d bytes and that could cause the "
"stream to be rejected.\n", MAX_ACC);
}
}
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
@@ -831,7 +831,7 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
if(conn->handler == &Curl_handler_http3) {
/* only for HTTP/3 transfers */
ssize_t sent;
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
struct quicsocket *qs = conn->quic;
fprintf(stderr, "!!! Curl_quic_done_sending\n");
stream->upload_done = TRUE;
@@ -844,23 +844,23 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
return CURLE_OK;
}
-/*
- * Called from http.c:Curl_http_done when a request completes.
- */
-void Curl_quic_done(struct Curl_easy *data, bool premature)
-{
- (void)data;
- (void)premature;
-}
-
-/*
- * Called from transfer.c:data_pending to know if we should keep looping
- * to receive more data from the connection.
- */
-bool Curl_quic_data_pending(const struct Curl_easy *data)
-{
- (void)data;
- return FALSE;
-}
-
+/*
+ * Called from http.c:Curl_http_done when a request completes.
+ */
+void Curl_quic_done(struct Curl_easy *data, bool premature)
+{
+ (void)data;
+ (void)premature;
+}
+
+/*
+ * Called from transfer.c:data_pending to know if we should keep looping
+ * to receive more data from the connection.
+ */
+bool Curl_quic_data_pending(const struct Curl_easy *data)
+{
+ (void)data;
+ return FALSE;
+}
+
#endif