master
1#ifndef HEADER_CURL_CFILTERS_H
2#define HEADER_CURL_CFILTERS_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curlx/timediff.h"
28struct bufq;
29struct Curl_cfilter;
30struct Curl_easy;
31struct Curl_dns_entry;
32struct connectdata;
33struct ip_quadruple;
34struct curl_tlssessioninfo;
36/* Callback to destroy resources held by this filter instance.
37 * Implementations MUST NOT chain calls to cf->next.
38 */
39typedef void Curl_cft_destroy_this(struct Curl_cfilter *cf,
40 struct Curl_easy *data);
42/* Callback to close the connection filter gracefully, non-blocking.
43 * Implementations MUST NOT chain calls to cf->next.
44 */
45typedef CURLcode Curl_cft_shutdown(struct Curl_cfilter *cf,
46 struct Curl_easy *data,
47 bool *done);
49typedef CURLcode Curl_cft_connect(struct Curl_cfilter *cf,
50 struct Curl_easy *data,
51 bool *done);
53struct easy_pollset;
55/* Passing in an easy_pollset for monitoring of sockets, let
56 * filters add or remove sockets actions (CURL_POLL_OUT, CURL_POLL_IN).
57 * This may add a socket or, in case no actions remain, remove
58 * a socket from the set.
59 *
60 * Filter implementations need to call filters "below" *after* they have
61 * made their adjustments. This allows lower filters to override "upper"
62 * actions. If a "lower" filter is unable to write, it needs to be able
63 * to disallow POLL_OUT.
64 *
65 * A filter without own restrictions/preferences should not modify
66 * the pollset. Filters, whose filter "below" is not connected, should
67 * also do no adjustments.
68 *
69 * Examples: a TLS handshake, while ongoing, might remove POLL_IN when it
70 * needs to write, or vice versa. An HTTP/2 filter might remove POLL_OUT when
71 * a stream window is exhausted and a WINDOW_UPDATE needs to be received first
72 * and add instead POLL_IN.
73 *
74 * @param cf the filter to ask
75 * @param data the easy handle the pollset is about
76 * @param ps the pollset (inout) for the easy handle
77 */
78typedef CURLcode Curl_cft_adjust_pollset(struct Curl_cfilter *cf,
79 struct Curl_easy *data,
80 struct easy_pollset *ps);
82typedef bool Curl_cft_data_pending(struct Curl_cfilter *cf,
83 const struct Curl_easy *data);
85typedef CURLcode Curl_cft_send(struct Curl_cfilter *cf,
86 struct Curl_easy *data, /* transfer */
87 const uint8_t *buf, /* data to write */
88 size_t len, /* amount to write */
89 bool eos, /* last chunk */
90 size_t *pnwritten); /* how much sent */
92typedef CURLcode Curl_cft_recv(struct Curl_cfilter *cf,
93 struct Curl_easy *data, /* transfer */
94 char *buf, /* store data here */
95 size_t len, /* amount to read */
96 size_t *pnread); /* how much received */
98typedef bool Curl_cft_conn_is_alive(struct Curl_cfilter *cf,
99 struct Curl_easy *data,
100 bool *input_pending);
102typedef CURLcode Curl_cft_conn_keep_alive(struct Curl_cfilter *cf,
103 struct Curl_easy *data);
105/**
106 * Events/controls for connection filters, their arguments and
107 * return code handling. Filter callbacks are invoked "top down".
108 * Return code handling:
109 * "first fail" meaning that the first filter returning != CURLE_OK, will
110 * abort further event distribution and determine the result.
111 * "ignored" meaning return values are ignored and the event is distributed
112 * to all filters in the chain. Overall result is always CURLE_OK.
113 */
114/* data event arg1 arg2 return */
115#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
116/* unused now 5 */
117#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
118#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
119#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
120/* update conn info at connection and data */
121#define CF_CTRL_CONN_INFO_UPDATE (256 + 0) /* 0 NULL ignored */
122#define CF_CTRL_FORGET_SOCKET (256 + 1) /* 0 NULL ignored */
123#define CF_CTRL_FLUSH (256 + 2) /* 0 NULL first fail */
124#define CF_CTRL_REPORT_STATS (256 + 3) /* 0 NULL ignored */
126/**
127 * Handle event/control for the filter.
128 * Implementations MUST NOT chain calls to cf->next.
129 */
130typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf,
131 struct Curl_easy *data,
132 int event, int arg1, void *arg2);
134/**
135 * Queries to ask via a `Curl_cft_query *query` method on a cfilter chain.
136 * - MAX_CONCURRENT: the maximum number of parallel transfers the filter
137 * chain expects to handle at the same time.
138 * default: 1 if no filter overrides.
139 * - CONNECT_REPLY_MS: milliseconds until the first indication of a server
140 * response was received on a connect. For TCP, this
141 * reflects the time until the socket connected. On UDP
142 * this gives the time the first bytes from the server
143 * were received.
144 * -1 if not determined yet.
145 * - CF_QUERY_SOCKET: the socket used by the filter chain
146 * - CF_QUERY_NEED_FLUSH: TRUE iff any of the filters have unsent data
147 * - CF_QUERY_IP_INFO: res1 says if connection used IPv6, res2 is the
148 * ip quadruple
149 * - CF_QUERY_HOST_PORT: the remote hostname and port a filter talks to
150 * - CF_QUERY_SSL_INFO: fill out the passed curl_tlssessioninfo with the
151 * internal from the SSL secured connection when
152 * available.
153 * - CF_QUERY_SSL_CTX_INFO: same as CF_QUERY_SSL_INFO, but give the SSL_CTX
154 * when available, or the same internal pointer
155 * when the TLS stack does not differentiate.
156 * - CF_QUERY_ALPN_NEGOTIATED: The ALPN selected by the server as
157 null-terminated string or NULL if none
158 selected/handshake not done. Implemented by filter
159 types CF_TYPE_SSL or CF_TYPE_IP_CONNECT.
160 * - CF_QUERY_REALLY_CONNECTED: implemented in socket filters to return
161 * if a reply from a server has really arrived. For
162 * non-UDP sockets this is TRUE when the socket became
163 * writable. For UDP sockets, this is TRUE when the
164 * first byte from the peer was received.
165 */
166/* query res1 res2 */
167#define CF_QUERY_MAX_CONCURRENT 1 /* number - */
168#define CF_QUERY_CONNECT_REPLY_MS 2 /* number - */
169#define CF_QUERY_SOCKET 3 /* - curl_socket_t */
170/* unused 4 + 5 */
171#define CF_QUERY_STREAM_ERROR 6 /* error code - */
172#define CF_QUERY_NEED_FLUSH 7 /* TRUE/FALSE - */
173#define CF_QUERY_IP_INFO 8 /* TRUE/FALSE struct ip_quadruple */
174#define CF_QUERY_HTTP_VERSION 9 /* number (10/11/20/30) - */
175/* pass in a `const struct Curl_sockaddr_ex **` as `pres2`. Gets set
176 * to NULL when not connected. */
177#define CF_QUERY_REMOTE_ADDR 10 /* - `Curl_sockaddr_ex *` */
178#define CF_QUERY_HOST_PORT 11 /* port const char * */
179#define CF_QUERY_SSL_INFO 12 /* - struct curl_tlssessioninfo * */
180#define CF_QUERY_SSL_CTX_INFO 13 /* - struct curl_tlssessioninfo * */
181#define CF_QUERY_TRANSPORT 14 /* TRNSPRT_* - * */
182#define CF_QUERY_ALPN_NEGOTIATED 15 /* - const char * */
183#define CF_QUERY_REALLY_CONNECTED 16 /* TRUE/FALSE - */
185/**
186 * Query the cfilter for properties. Filters ignorant of a query will
187 * pass it "down" the filter chain.
188 */
189typedef CURLcode Curl_cft_query(struct Curl_cfilter *cf,
190 struct Curl_easy *data,
191 int query, int *pres1, void *pres2);
193/**
194 * Type flags for connection filters. A filter can have none, one or
195 * many of those. Use to evaluate state/capabilities of a filter chain.
196 *
197 * CF_TYPE_IP_CONNECT: provides an IP connection or sth equivalent, like
198 * a CONNECT tunnel, a UNIX domain socket, a QUIC
199 * connection, etc.
200 * CF_TYPE_SSL: provide SSL/TLS
201 * CF_TYPE_MULTIPLEX: provides multiplexing of easy handles
202 * CF_TYPE_PROXY provides proxying
203 * CF_TYPE_HTTP implement a version of the HTTP protocol
204 * CF_TYPE_SETUP filter is only needed for connection setup and
205 * can be removed once connected
206 * CF_TYPE_DNS filter managing DNS resolve operations
207 */
208#define CF_TYPE_IP_CONNECT (1 << 0)
209#define CF_TYPE_SSL (1 << 1)
210#define CF_TYPE_MULTIPLEX (1 << 2)
211#define CF_TYPE_PROXY (1 << 3)
212#define CF_TYPE_HTTP (1 << 4)
213#define CF_TYPE_SETUP (1 << 5)
214#define CF_TYPE_DNS (1 << 6)
216/* A connection filter type, e.g. specific implementation. */
217struct Curl_cftype {
218 const char *name; /* name of the filter type */
219 int flags; /* flags of filter type */
220 int log_level; /* log level for such filters */
221 Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
222 Curl_cft_connect *do_connect; /* establish connection */
223 Curl_cft_shutdown *do_shutdown; /* shutdown conn */
224 Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
225 Curl_cft_data_pending *has_data_pending; /* conn has data pending */
226 Curl_cft_send *do_send; /* send data */
227 Curl_cft_recv *do_recv; /* receive data */
228 Curl_cft_cntrl *cntrl; /* events/control */
229 Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
230 Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
231 Curl_cft_query *query; /* query filter chain */
232};
234/* A connection filter instance, e.g. registered at a connection */
235struct Curl_cfilter {
236 const struct Curl_cftype *cft; /* the type providing implementation */
237 struct Curl_cfilter *next; /* next filter in chain */
238 void *ctx; /* filter type specific settings */
239 struct connectdata *conn; /* the connection this filter belongs to */
240 int8_t sockindex; /* the index the filter is installed at */
241 BIT(connected); /* != 0 iff this filter is connected */
242 BIT(shutdown); /* != 0 iff this filter has shut down */
243};
245/* Default implementations for the type functions, implementing nop. */
246void Curl_cf_def_destroy_this(struct Curl_cfilter *cf,
247 struct Curl_easy *data);
249/* Default implementations for the type functions, implementing pass-through
250 * the filter chain. */
251CURLcode Curl_cf_def_adjust_pollset(struct Curl_cfilter *cf,
252 struct Curl_easy *data,
253 struct easy_pollset *ps);
254bool Curl_cf_def_data_pending(struct Curl_cfilter *cf,
255 const struct Curl_easy *data);
256CURLcode Curl_cf_def_send(struct Curl_cfilter *cf, struct Curl_easy *data,
257 const uint8_t *buf, size_t len, bool eos,
258 size_t *pnwritten);
259CURLcode Curl_cf_def_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
260 char *buf, size_t len, size_t *pnread);
261CURLcode Curl_cf_def_cntrl(struct Curl_cfilter *cf,
262 struct Curl_easy *data,
263 int event, int arg1, void *arg2);
264bool Curl_cf_def_conn_is_alive(struct Curl_cfilter *cf,
265 struct Curl_easy *data,
266 bool *input_pending);
267CURLcode Curl_cf_def_conn_keep_alive(struct Curl_cfilter *cf,
268 struct Curl_easy *data);
269CURLcode Curl_cf_def_query(struct Curl_cfilter *cf,
270 struct Curl_easy *data,
271 int query, int *pres1, void *pres2);
272CURLcode Curl_cf_def_shutdown(struct Curl_cfilter *cf,
273 struct Curl_easy *data, bool *done);
274CURLcode Curl_cf_def_connect(struct Curl_cfilter *cf,
275 struct Curl_easy *data, bool *done);
277/**
278 * Create a new filter instance, unattached to the filter chain.
279 * Use Curl_conn_cf_add() to add it to the chain.
280 * @param pcf on success holds the created instance
281 * @param cft the filter type
282 * @param ctx the type specific context to use
283 */
284CURLcode Curl_cf_create(struct Curl_cfilter **pcf,
285 const struct Curl_cftype *cft,
286 void *ctx);
288/**
289 * Add a filter instance to the `sockindex` filter chain at connection
290 * `conn`. The filter must not already be attached. It is inserted at
291 * the start of the chain (top).
292 */
293void Curl_conn_cf_add(struct Curl_easy *data,
294 struct connectdata *conn,
295 int8_t sockindex,
296 struct Curl_cfilter *cf);
298/**
299 * Insert a filter (chain) after `cf_at`.
300 * `cf_new` must not already be attached.
301 */
302void Curl_conn_cf_insert_after(struct Curl_cfilter *cf_at,
303 struct Curl_cfilter *cf_new);
305/**
306 * Extract filter `*pcf` from its connection filter chain.
307 * Destroy `*pcf`, even if it was not part of the chain and NULL it.
308 * Returns TRUE of cf has been part of chain.
309 */
310bool Curl_conn_cf_discard(struct Curl_cfilter **pcf,
311 struct Curl_easy *data);
313/**
314 * Discard all cfilters starting with `*pcf` and clearing it afterwards.
315 */
316void Curl_conn_cf_discard_chain(struct Curl_cfilter **pcf,
317 struct Curl_easy *data);
319/**
320 * Remove and destroy all filters at chain `sockindex` on connection `conn`.
321 */
322void Curl_conn_cf_discard_all(struct Curl_easy *data,
323 struct connectdata *conn, int8_t sockindex);
325CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf,
326 struct Curl_easy *data,
327 bool *done);
328CURLcode Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data,
329 const uint8_t *buf, size_t len, bool eos,
330 size_t *pnwritten);
331CURLcode Curl_conn_cf_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
332 char *buf, size_t len, size_t *pnread);
333CURLcode Curl_conn_cf_cntrl(struct Curl_cfilter *cf,
334 struct Curl_easy *data,
335 bool ignore_result,
336 int event, int arg1, void *arg2);
338/**
339 * Get the socket used by the filter chain starting at `cf`.
340 * Returns CURL_SOCKET_BAD if not available.
341 */
342curl_socket_t Curl_conn_cf_get_socket(struct Curl_cfilter *cf,
343 struct Curl_easy *data);
345CURLcode Curl_conn_cf_get_ip_info(struct Curl_cfilter *cf,
346 struct Curl_easy *data,
347 bool *is_ipv6, struct ip_quadruple *ipquad);
349bool Curl_conn_cf_needs_flush(struct Curl_cfilter *cf,
350 struct Curl_easy *data);
352bool Curl_conn_cf_is_ip_connected(struct Curl_cfilter *cf,
353 struct Curl_easy *data);
355unsigned char Curl_conn_cf_get_transport(struct Curl_cfilter *cf,
356 struct Curl_easy *data);
358int Curl_socktype_for_transport(uint8_t transport);
359int Curl_protocol_for_transport(uint8_t transport);
361const char *Curl_conn_cf_get_alpn_negotiated(struct Curl_cfilter *cf,
362 struct Curl_easy *data);
364#define CURL_CF_SSL_DEFAULT (-1)
365#define CURL_CF_SSL_DISABLE 0
366#define CURL_CF_SSL_ENABLE 1
368/**
369 * Check if a filter chain at `sockindex` for connection `conn` exists.
370 */
371bool Curl_conn_is_setup(struct connectdata *conn, int8_t sockindex);
373/**
374 * Check if the filter chain at `sockindex` for connection `conn` is
375 * completely connected.
376 */
377bool Curl_conn_is_connected(struct connectdata *conn, int8_t sockindex);
379/**
380 * Determine if we have reached the remote host on IP level, e.g.
381 * have a TCP connection. This turns TRUE before a possible SSL
382 * handshake has been started/done.
383 */
384bool Curl_conn_is_ip_connected(struct Curl_easy *data, int8_t sockindex);
386/**
387 * Determine if the connection is using SSL to the remote host
388 * (or will be once connected). This will return FALSE, if SSL
389 * is only used in proxying and not for the tunnel itself.
390 */
391bool Curl_conn_is_ssl(struct connectdata *conn, int8_t sockindex);
393/* Determine if the connection has one or more proxy filters.
394 * e.g. is tunneling. */
395bool Curl_conn_is_tunneling(struct connectdata *conn, int8_t sockindex);
397/*
398 * Fill `info` with information about the TLS instance securing the connection
399 * when available, otherwise e.g. when Curl_conn_is_ssl() is FALSE, return
400 * FALSE. 'query' should be CF_QUERY_SSL_INFO or CF_QUERY_SSL_CTX_INFO.
401 */
402bool Curl_conn_get_ssl_info(struct Curl_easy *data,
403 struct connectdata *conn, int8_t sockindex,
404 int query,
405 struct curl_tlssessioninfo *info);
407CURLcode Curl_conn_get_ip_info(struct Curl_easy *data,
408 struct connectdata *conn, int8_t sockindex,
409 bool *is_ipv6, struct ip_quadruple *ipquad);
411/**
412 * Connection provides multiplexing of easy handles at `socketindex`.
413 */
414bool Curl_conn_is_multiplex(struct connectdata *conn, int8_t sockindex);
416/**
417 * Return the HTTP version used on the FIRSTSOCKET connection filters
418 * or 0 if unknown. Value otherwise is 09, 10, 11, etc.
419 */
420uint8_t Curl_conn_http_version(struct Curl_easy *data,
421 struct connectdata *conn);
423/* Return the HTTP version used on the connection filter chain
424 * or 0 if unknown. Value otherwise is 09, 10, 11, etc. */
425uint8_t Curl_conn_cf_http_version(struct Curl_easy *data,
426 struct Curl_cfilter *cf);
428/* Get the TRNSPRT_* the connection is using */
429unsigned char Curl_conn_get_transport(struct Curl_easy *data,
430 struct connectdata *conn);
432void Curl_conn_cntrl_update_info(struct Curl_easy *data,
433 struct connectdata *conn);
435void Curl_conn_cntrl_report_stats(struct Curl_easy *data,
436 struct connectdata *conn,
437 int sockindex);
439void Curl_conn_remove_setup_filters(struct Curl_easy *data,
440 int8_t sockindex);
442/**
443 * Return if data is pending in some connection filter at chain
444 * `sockindex` for connection `data->conn`.
445 */
446bool Curl_conn_data_pending(struct Curl_easy *data,
447 int8_t sockindex);
449/**
450 * Return TRUE if any of the connection filters at chain `sockindex`
451 * have data still to send.
452 */
453bool Curl_conn_needs_flush(struct Curl_easy *data, int8_t sockindex);
455/**
456 * Flush any pending data on the connection filters at chain `sockindex`.
457 */
458CURLcode Curl_conn_flush(struct Curl_easy *data, int8_t sockindex);
460/**
461 * Return the socket used on data's connection for FIRSTSOCKET,
462 * querying filters if the whole chain has not connected yet.
463 * Returns CURL_SOCKET_BAD if not available.
464 */
465curl_socket_t Curl_conn_get_first_socket(struct Curl_easy *data);
467/* Return a pointer to the connected socket address or NULL. */
468const struct Curl_sockaddr_ex *
469Curl_conn_get_remote_addr(struct Curl_easy *data, int8_t sockindex);
471/**
472 * Tell filters to forget about the socket at sockindex.
473 */
474void Curl_conn_forget_socket(struct Curl_easy *data, int8_t sockindex);
476/**
477 * Adjust the pollset for the filter chain starting at `cf`.
478 */
479CURLcode Curl_conn_cf_adjust_pollset(struct Curl_cfilter *cf,
480 struct Curl_easy *data,
481 struct easy_pollset *ps);
483/**
484 * Adjust pollset from filters installed at transfer's connection.
485 */
486CURLcode Curl_conn_adjust_pollset(struct Curl_easy *data,
487 struct connectdata *conn,
488 struct easy_pollset *ps);
490/**
491 * Curl_poll() the filter chain at `cf` with timeout `timeout_ms`.
492 * Returns 0 on timeout, negative on error or number of sockets
493 * with requested poll events.
494 */
495int Curl_conn_cf_poll(struct Curl_cfilter *cf,
496 struct Curl_easy *data,
497 timediff_t timeout_ms);
499/**
500 * Receive data through the filter chain at `sockindex` for connection
501 * `data->conn`. Copy at most `len` bytes into `buf`. Return the
502 * actual number of bytes copied in `*pnread`or an error.
503 */
504CURLcode Curl_cf_recv(struct Curl_easy *data, int8_t sockindex, char *buf,
505 size_t len, size_t *pnread);
507/**
508 * Send `len` bytes of data from `buf` through the filter chain `sockindex`
509 * at connection `data->conn`. Return the actual number of bytes written
510 * in `*pnwritten` or on error.
511 */
512CURLcode Curl_cf_send(struct Curl_easy *data, int8_t sockindex,
513 const uint8_t *buf, size_t len, bool eos,
514 size_t *pnwritten);
516/**
517 * Receive bytes from connection filter `cf` into `bufq`.
518 * Convenience wrapper around `Curl_bufq_sipn()`,
519 * so users do not have to implement a callback.
520 */
521CURLcode Curl_cf_recv_bufq(struct Curl_cfilter *cf,
522 struct Curl_easy *data,
523 struct bufq *bufq,
524 size_t maxlen,
525 size_t *pnread);
527/**
528 * Send bytes in `bufq` using connection filter `cf`.
529 * A convenience wrapper around `Curl_bufq_write_pass()`,
530 * so users do not have to implement a callback.
531 */
532CURLcode Curl_cf_send_bufq(struct Curl_cfilter *cf,
533 struct Curl_easy *data,
534 struct bufq *bufq,
535 const unsigned char *buf, size_t blen,
536 size_t *pnwritten);
538/**
539 * Notify connection filters that they need to setup data for
540 * a transfer.
541 */
542CURLcode Curl_conn_ev_data_setup(struct Curl_easy *data);
544/**
545 * Notify connection filters that the transfer represented by `data`
546 * is done with sending data (e.g. has uploaded everything).
547 */
548void Curl_conn_ev_data_done_send(struct Curl_easy *data);
550/**
551 * Notify connection filters that the transfer represented by `data`
552 * is finished - eventually premature, e.g. before being complete.
553 */
554void Curl_conn_ev_data_done(struct Curl_easy *data, bool premature);
556/**
557 * Notify connection filters that the transfer of data is paused/unpaused.
558 */
559CURLcode Curl_conn_ev_data_pause(struct Curl_easy *data, bool do_pause);
561/**
562 * Check if FIRSTSOCKET's cfilter chain deems connection alive.
563 */
564bool Curl_conn_is_alive(struct Curl_easy *data, struct connectdata *conn,
565 bool *input_pending);
567/**
568 * Try to upkeep the connection filters.
569 */
570CURLcode Curl_conn_keep_alive(struct Curl_easy *data,
571 struct connectdata *conn);
573/**
574 * Get the remote hostname and port that the connection is currently
575 * talking to (or will talk to).
576 * Once connected or before connect starts,
577 * it is `conn->origin->hostname` and `conn->origin->port`.
578 * During connect, when tunneling proxies are involved (http or socks),
579 * it will be the name and port the proxy currently negotiates with.
580 */
581void Curl_conn_get_current_host(struct Curl_easy *data, int8_t sockindex,
582 const char **phost, int *pport);
584/**
585 * Get the maximum number of parallel transfers the connection
586 * expects to be able to handle at `sockindex`.
587 */
588size_t Curl_conn_get_max_concurrent(struct Curl_easy *data,
589 struct connectdata *conn,
590 int8_t sockindex);
592/**
593 * Get the underlying error code for a transfer stream or 0 if not known.
594 */
595int Curl_conn_get_stream_error(struct Curl_easy *data,
596 struct connectdata *conn,
597 int8_t sockindex);
599#ifdef CURLVERBOSE
600void Curl_conn_trc_filters(struct Curl_easy *data,
601 int8_t sockindex, const char *info);
602#endif
604/**
605 * Get the index of the given socket in the connection's sockets.
606 * Useful in calling `Curl_conn_send()/Curl_conn_recv()` with the
607 * correct socket index.
608 */
609int8_t Curl_conn_sockindex(struct Curl_easy *data, curl_socket_t sockfd);
611/*
612 * Receive data on the connection, using FIRSTSOCKET/SECONDARYSOCKET.
613 * Return CURLE_AGAIN iff blocked on receiving.
614 */
615CURLcode Curl_conn_recv(struct Curl_easy *data, int8_t sockindex,
616 char *buf, size_t len, size_t *pnread);
618/*
619 * Send data on the connection, using FIRSTSOCKET/SECONDARYSOCKET.
620 * Return CURLE_AGAIN iff blocked on sending.
621 */
622CURLcode Curl_conn_send(struct Curl_easy *data, int8_t sockindex,
623 const void *buf, size_t len, bool eos,
624 size_t *pnwritten);
626/**
627 * Types and macros used to keep the current easy handle in filter calls,
628 * allowing for nested invocations. See #10336.
629 *
630 * `cf_call_data` is intended to be a member of the cfilter's `ctx` type.
631 * A filter defines the macro `CF_CTX_CALL_DATA` to give access to that.
632 *
633 * With all values 0, the default, this indicates that there is no cfilter
634 * call with `data` ongoing.
635 * Macro `CF_DATA_SAVE` preserves the current `cf_call_data` in a local
636 * variable and sets the `data` given, incrementing the `depth` counter.
637 *
638 * Macro `CF_DATA_RESTORE` restores the old values from the local variable,
639 * while checking that `depth` values are as expected (debug build), catching
640 * cases where a "lower" RESTORE was not called.
641 *
642 * Finally, macro `CF_DATA_CURRENT` gives the easy handle of the current
643 * invocation.
644 */
645struct cf_call_data {
646 struct Curl_easy *data;
647#ifdef DEBUGBUILD
648 int depth;
649#endif
650};
652/**
653 * define to access the `struct cf_call_data for a cfilter. Normally
654 * a member in the cfilter's `ctx`.
655 *
656 * #define CF_CTX_CALL_DATA(cf) -> struct cf_call_data instance
657 */
659#ifdef DEBUGBUILD
661#define CF_DATA_SAVE(save, cf, data) \
662 do { \
663 (save) = CF_CTX_CALL_DATA(cf); \
664 DEBUGASSERT(!(save).data || (save).depth > 0); \
665 CF_CTX_CALL_DATA(cf).depth++; \
666 CF_CTX_CALL_DATA(cf).data = (struct Curl_easy *)CURL_UNCONST(data); \
667 } while(0)
669#define CF_DATA_RESTORE(cf, save) \
670 do { \
671 DEBUGASSERT(CF_CTX_CALL_DATA(cf).depth == (save).depth + 1); \
672 DEBUGASSERT(!(save).data || (save).depth > 0); \
673 CF_CTX_CALL_DATA(cf) = (save); \
674 } while(0)
676#else /* DEBUGBUILD */
678#define CF_DATA_SAVE(save, cf, data) \
679 do { \
680 (save) = CF_CTX_CALL_DATA(cf); \
681 CF_CTX_CALL_DATA(cf).data = (struct Curl_easy *)CURL_UNCONST(data); \
682 } while(0)
684#define CF_DATA_RESTORE(cf, save) \
685 do { \
686 CF_CTX_CALL_DATA(cf) = (save); \
687 } while(0)
689#endif /* !DEBUGBUILD */
691#define CF_DATA_CURRENT(cf) ((cf) ? (CF_CTX_CALL_DATA(cf).data) : NULL)
693#endif /* HEADER_CURL_CFILTERS_H */
Diagnostics4 git calls · 477 ms
CallStatusSizeTime0477 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=473 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2007.9 KiB473 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=8041 git.response.cache=MISS git.response.duration_ms=473 git.fetch.wants=8c7b42f6b509c204de0068a1e0ca194d62925ef1 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=8041 git.pkt.payload.max=8020 git.sideband.band1.bytes=8019 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e30b6c39daee28
- Request
- ef00a5bf…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format