1 #ifndef HEADER_CURL_URLDATA_H 2 #define HEADER_CURL_URLDATA_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 27 /* This file is for lib internal stuff */ 28 29 #include "curl_setup.h" 30 31 #define PORT_FTP 21 32 #define PORT_FTPS 990 33 #define PORT_TELNET 23 34 #define PORT_HTTP 80 35 #define PORT_HTTPS 443 36 #define PORT_DICT 2628 37 #define PORT_LDAP 389 38 #define PORT_LDAPS 636 39 #define PORT_TFTP 69 40 #define PORT_SSH 22 41 #define PORT_IMAP 143 42 #define PORT_IMAPS 993 43 #define PORT_POP3 110 44 #define PORT_POP3S 995 45 #define PORT_SMB 445 46 #define PORT_SMBS 445 47 #define PORT_SMTP 25 48 #define PORT_SMTPS 465 /* sometimes called SSMTP */ 49 #define PORT_RTSP 554 50 #define PORT_RTMP 1935 51 #define PORT_RTMPT PORT_HTTP 52 #define PORT_RTMPS PORT_HTTPS 53 #define PORT_GOPHER 70 54 #define PORT_MQTT 1883 55 56 struct curl_trc_featt; 57 58 #ifdef USE_ECH 59 /* CURLECH_ bits for the tls_ech option */ 60 # define CURLECH_DISABLE (1<<0) 61 # define CURLECH_GREASE (1<<1) 62 # define CURLECH_ENABLE (1<<2) 63 # define CURLECH_HARD (1<<3) 64 # define CURLECH_CLA_CFG (1<<4) 65 #endif 66 67 #ifdef USE_WEBSOCKETS 68 /* CURLPROTO_GOPHERS (29) is the highest publicly used protocol bit number, 69 * the rest are internal information. If we use higher bits we only do this on 70 * platforms that have a >= 64 bit type and then we use such a type for the 71 * protocol fields in the protocol handler. 72 */ 73 #define CURLPROTO_WS (1<<30) 74 #define CURLPROTO_WSS ((curl_prot_t)1<<31) 75 #else 76 #define CURLPROTO_WS 0 77 #define CURLPROTO_WSS 0 78 #endif 79 80 /* This should be undefined once we need bit 32 or higher */ 81 #define PROTO_TYPE_SMALL 82 83 #ifndef PROTO_TYPE_SMALL 84 typedef curl_off_t curl_prot_t; 85 #else 86 typedef unsigned int curl_prot_t; 87 #endif 88 89 /* This mask is for all the old protocols that are provided and defined in the 90 public header and shall exclude protocols added since which are not exposed 91 in the API */ 92 #define CURLPROTO_MASK (0x3ffffff) 93 94 #define DICT_MATCH "/MATCH:" 95 #define DICT_MATCH2 "/M:" 96 #define DICT_MATCH3 "/FIND:" 97 #define DICT_DEFINE "/DEFINE:" 98 #define DICT_DEFINE2 "/D:" 99 #define DICT_DEFINE3 "/LOOKUP:" 100 101 #define CURL_DEFAULT_USER "anonymous" 102 #define CURL_DEFAULT_PASSWORD "ftp@example.com" 103 104 /* Convenience defines for checking protocols or their SSL based version. Each 105 protocol handler should only ever have a single CURLPROTO_ in its protocol 106 field. */ 107 #define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_WS| \ 108 CURLPROTO_WSS) 109 #define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS) 110 #define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S) 111 #define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS) 112 #define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS) 113 #define PROTO_FAMILY_SSH (CURLPROTO_SCP|CURLPROTO_SFTP) 114 115 #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \ 116 !defined(CURL_DISABLE_POP3) || !defined(CURL_DISABLE_FILE) 117 /* these protocols support CURLOPT_DIRLISTONLY */ 118 #define CURL_LIST_ONLY_PROTOCOL 1 119 #endif 120 121 #define DEFAULT_CONNCACHE_SIZE 5 122 123 /* length of longest IPv6 address string including the trailing null */ 124 #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") 125 126 /* Default FTP/IMAP etc response timeout in milliseconds */ 127 #define RESP_TIMEOUT (120*1000) 128 129 /* Max string input length is a precaution against abuse and to detect junk 130 input easier and better. */ 131 #define CURL_MAX_INPUT_LENGTH 8000000 132 133 134 #include "cookie.h" 135 #include "psl.h" 136 #include "formdata.h" 137 138 #ifdef HAVE_NETINET_IN_H 139 #include <netinet/in.h> 140 #endif 141 #ifdef HAVE_NETINET_IN6_H 142 #include <netinet/in6.h> 143 #endif 144 145 #include "timeval.h" 146 147 #include <curl/curl.h> 148 149 #include "http_chunks.h" /* for the structs and enum stuff */ 150 #include "hostip.h" 151 #include "hash.h" 152 #include "splay.h" 153 #include "dynbuf.h" 154 #include "dynhds.h" 155 #include "request.h" 156 157 /* return the count of bytes sent, or -1 on error */ 158 typedef ssize_t (Curl_send)(struct Curl_easy *data, /* transfer */ 159 int sockindex, /* socketindex */ 160 const void *buf, /* data to write */ 161 size_t len, /* max amount to write */ 162 CURLcode *err); /* error to return */ 163 164 /* return the count of bytes read, or -1 on error */ 165 typedef ssize_t (Curl_recv)(struct Curl_easy *data, /* transfer */ 166 int sockindex, /* socketindex */ 167 char *buf, /* store data here */ 168 size_t len, /* max amount to read */ 169 CURLcode *err); /* error to return */ 170 171 #ifdef USE_HYPER 172 typedef CURLcode (*Curl_datastream)(struct Curl_easy *data, 173 struct connectdata *conn, 174 int *didwhat, 175 int select_res); 176 #endif 177 178 #include "mime.h" 179 #include "imap.h" 180 #include "pop3.h" 181 #include "smtp.h" 182 #include "ftp.h" 183 #include "file.h" 184 #include "vssh/ssh.h" 185 #include "http.h" 186 #include "rtsp.h" 187 #include "smb.h" 188 #include "mqtt.h" 189 #include "ftplistparser.h" 190 #include "multihandle.h" 191 #include "c-hyper.h" 192 #include "cf-socket.h" 193 194 #ifdef HAVE_GSSAPI 195 # ifdef HAVE_GSSGNU 196 # include <gss.h> 197 # elif defined HAVE_GSSAPI_GSSAPI_H 198 # include <gssapi/gssapi.h> 199 # else 200 # include <gssapi.h> 201 # endif 202 # ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H 203 # include <gssapi/gssapi_generic.h> 204 # endif 205 #endif 206 207 #ifdef USE_LIBSSH2 208 #include <libssh2.h> 209 #include <libssh2_sftp.h> 210 #endif /* USE_LIBSSH2 */ 211 212 #define READBUFFER_SIZE CURL_MAX_WRITE_SIZE 213 #define READBUFFER_MAX CURL_MAX_READ_SIZE 214 #define READBUFFER_MIN 1024 215 216 /* The default upload buffer size, should not be smaller than 217 CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in 218 a write callback. 219 220 The size was 16KB for many years but was bumped to 64KB because it makes 221 libcurl able to do significantly faster uploads in some circumstances. Even 222 larger buffers can help further, but this is deemed a fair memory/speed 223 compromise. */ 224 #define UPLOADBUFFER_DEFAULT 65536 225 #define UPLOADBUFFER_MAX (2*1024*1024) 226 #define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE 227 228 #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU 229 #ifdef DEBUGBUILD 230 /* On a debug build, we want to fail hard on easy handles that 231 * are not NULL, but no longer have the MAGIC touch. This gives 232 * us early warning on things only discovered by valgrind otherwise. */ 233 #define GOOD_EASY_HANDLE(x) \ 234 (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \ 235 (DEBUGASSERT(!(x)), FALSE)) 236 #else 237 #define GOOD_EASY_HANDLE(x) \ 238 ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) 239 #endif 240 241 #ifdef HAVE_GSSAPI 242 /* Types needed for krb5-ftp connections */ 243 struct krb5buffer { 244 void *data; 245 size_t size; 246 size_t index; 247 BIT(eof_flag); 248 }; 249 250 enum protection_level { 251 PROT_NONE, /* first in list */ 252 PROT_CLEAR, 253 PROT_SAFE, 254 PROT_CONFIDENTIAL, 255 PROT_PRIVATE, 256 PROT_CMD, 257 PROT_LAST /* last in list */ 258 }; 259 #endif 260 261 /* enum for the nonblocking SSL connection state machine */ 262 typedef enum { 263 ssl_connect_1, 264 ssl_connect_2, 265 ssl_connect_2_reading, 266 ssl_connect_2_writing, 267 ssl_connect_3, 268 ssl_connect_done 269 } ssl_connect_state; 270 271 typedef enum { 272 ssl_connection_none, 273 ssl_connection_negotiating, 274 ssl_connection_complete 275 } ssl_connection_state; 276 277 /* SSL backend-specific data; declared differently by each SSL backend */ 278 struct ssl_backend_data; 279 280 typedef enum { 281 CURL_SSL_PEER_DNS, 282 CURL_SSL_PEER_IPV4, 283 CURL_SSL_PEER_IPV6 284 } ssl_peer_type; 285 286 struct ssl_peer { 287 char *hostname; /* hostname for verification */ 288 char *dispname; /* display version of hostname */ 289 char *sni; /* SNI version of hostname or NULL if not usable */ 290 ssl_peer_type type; /* type of the peer information */ 291 int port; /* port we are talking to */ 292 int transport; /* TCP or QUIC */ 293 }; 294 295 struct ssl_primary_config { 296 char *CApath; /* certificate dir (doesn't work on windows) */ 297 char *CAfile; /* certificate to verify peer against */ 298 char *issuercert; /* optional issuer certificate filename */ 299 char *clientcert; 300 char *cipher_list; /* list of ciphers to use */ 301 char *cipher_list13; /* list of TLS 1.3 cipher suites to use */ 302 char *pinned_key; 303 char *CRLfile; /* CRL to check certificate revocation */ 304 struct curl_blob *cert_blob; 305 struct curl_blob *ca_info_blob; 306 struct curl_blob *issuercert_blob; 307 #ifdef USE_TLS_SRP 308 char *username; /* TLS username (for, e.g., SRP) */ 309 char *password; /* TLS password (for, e.g., SRP) */ 310 #endif 311 char *curves; /* list of curves to use */ 312 unsigned char ssl_options; /* the CURLOPT_SSL_OPTIONS bitmask */ 313 unsigned int version_max; /* max supported version the client wants to use */ 314 unsigned char version; /* what version the client wants to use */ 315 BIT(verifypeer); /* set TRUE if this is desired */ 316 BIT(verifyhost); /* set TRUE if CN/SAN must match hostname */ 317 BIT(verifystatus); /* set TRUE if certificate status must be checked */ 318 BIT(sessionid); /* cache session IDs or not */ 319 }; 320 321 struct ssl_config_data { 322 struct ssl_primary_config primary; 323 long certverifyresult; /* result from the certificate verification */ 324 curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */ 325 void *fsslctxp; /* parameter for call back */ 326 char *cert_type; /* format for certificate (default: PEM)*/ 327 char *key; /* private key file name */ 328 struct curl_blob *key_blob; 329 char *key_type; /* format for private key (default: PEM) */ 330 char *key_passwd; /* plain text private key password */ 331 BIT(certinfo); /* gather lots of certificate info */ 332 BIT(falsestart); 333 BIT(enable_beast); /* allow this flaw for interoperability's sake */ 334 BIT(no_revoke); /* disable SSL certificate revocation checks */ 335 BIT(no_partialchain); /* don't accept partial certificate chains */ 336 BIT(revoke_best_effort); /* ignore SSL revocation offline/missing revocation 337 list errors */ 338 BIT(native_ca_store); /* use the native ca store of operating system */ 339 BIT(auto_client_cert); /* automatically locate and use a client 340 certificate for authentication (Schannel) */ 341 }; 342 343 struct ssl_general_config { 344 size_t max_ssl_sessions; /* SSL session id cache size */ 345 int ca_cache_timeout; /* Certificate store cache timeout (seconds) */ 346 }; 347 348 typedef void Curl_ssl_sessionid_dtor(void *sessionid, size_t idsize); 349 350 /* information stored about one single SSL session */ 351 struct Curl_ssl_session { 352 char *name; /* host name for which this ID was used */ 353 char *conn_to_host; /* host name for the connection (may be NULL) */ 354 const char *scheme; /* protocol scheme used */ 355 void *sessionid; /* as returned from the SSL layer */ 356 size_t idsize; /* if known, otherwise 0 */ 357 Curl_ssl_sessionid_dtor *sessionid_free; /* free `sessionid` callback */ 358 long age; /* just a number, the higher the more recent */ 359 int remote_port; /* remote port */ 360 int conn_to_port; /* remote port for the connection (may be -1) */ 361 int transport; /* TCP or QUIC */ 362 struct ssl_primary_config ssl_config; /* setup for this session */ 363 }; 364 365 #ifdef USE_WINDOWS_SSPI 366 #include "curl_sspi.h" 367 #endif 368 369 #ifndef CURL_DISABLE_DIGEST_AUTH 370 /* Struct used for Digest challenge-response authentication */ 371 struct digestdata { 372 #if defined(USE_WINDOWS_SSPI) 373 BYTE *input_token; 374 size_t input_token_len; 375 CtxtHandle *http_context; 376 /* copy of user/passwd used to make the identity for http_context. 377 either may be NULL. */ 378 char *user; 379 char *passwd; 380 #else 381 char *nonce; 382 char *cnonce; 383 char *realm; 384 char *opaque; 385 char *qop; 386 char *algorithm; 387 int nc; /* nonce count */ 388 unsigned char algo; 389 BIT(stale); /* set true for re-negotiation */ 390 BIT(userhash); 391 #endif 392 }; 393 #endif 394 395 typedef enum { 396 NTLMSTATE_NONE, 397 NTLMSTATE_TYPE1, 398 NTLMSTATE_TYPE2, 399 NTLMSTATE_TYPE3, 400 NTLMSTATE_LAST 401 } curlntlm; 402 403 typedef enum { 404 GSS_AUTHNONE, 405 GSS_AUTHRECV, 406 GSS_AUTHSENT, 407 GSS_AUTHDONE, 408 GSS_AUTHSUCC 409 } curlnegotiate; 410 411 /* Struct used for GSSAPI (Kerberos V5) authentication */ 412 #if defined(USE_KERBEROS5) 413 struct kerberos5data { 414 #if defined(USE_WINDOWS_SSPI) 415 CredHandle *credentials; 416 CtxtHandle *context; 417 TCHAR *spn; 418 SEC_WINNT_AUTH_IDENTITY identity; 419 SEC_WINNT_AUTH_IDENTITY *p_identity; 420 size_t token_max; 421 BYTE *output_token; 422 #else 423 gss_ctx_id_t context; 424 gss_name_t spn; 425 #endif 426 }; 427 #endif 428 429 /* Struct used for SCRAM-SHA-1 authentication */ 430 #ifdef USE_GSASL 431 #include <gsasl.h> 432 struct gsasldata { 433 Gsasl *ctx; 434 Gsasl_session *client; 435 }; 436 #endif 437 438 /* Struct used for NTLM challenge-response authentication */ 439 #if defined(USE_NTLM) 440 struct ntlmdata { 441 #ifdef USE_WINDOWS_SSPI 442 /* The sslContext is used for the Schannel bindings. The 443 * api is available on the Windows 7 SDK and later. 444 */ 445 #ifdef SECPKG_ATTR_ENDPOINT_BINDINGS 446 CtxtHandle *sslContext; 447 #endif 448 CredHandle *credentials; 449 CtxtHandle *context; 450 SEC_WINNT_AUTH_IDENTITY identity; 451 SEC_WINNT_AUTH_IDENTITY *p_identity; 452 size_t token_max; 453 BYTE *output_token; 454 BYTE *input_token; 455 size_t input_token_len; 456 TCHAR *spn; 457 #else 458 unsigned int flags; 459 unsigned char nonce[8]; 460 unsigned int target_info_len; 461 void *target_info; /* TargetInfo received in the ntlm type-2 message */ 462 #endif 463 }; 464 #endif 465 466 /* Struct used for Negotiate (SPNEGO) authentication */ 467 #ifdef USE_SPNEGO 468 struct negotiatedata { 469 #ifdef HAVE_GSSAPI 470 OM_uint32 status; 471 gss_ctx_id_t context; 472 gss_name_t spn; 473 gss_buffer_desc output_token; 474 #else 475 #ifdef USE_WINDOWS_SSPI 476 #ifdef SECPKG_ATTR_ENDPOINT_BINDINGS 477 CtxtHandle *sslContext; 478 #endif 479 DWORD status; 480 CredHandle *credentials; 481 CtxtHandle *context; 482 SEC_WINNT_AUTH_IDENTITY identity; 483 SEC_WINNT_AUTH_IDENTITY *p_identity; 484 TCHAR *spn; 485 size_t token_max; 486 BYTE *output_token; 487 size_t output_token_length; 488 #endif 489 #endif 490 BIT(noauthpersist); 491 BIT(havenoauthpersist); 492 BIT(havenegdata); 493 BIT(havemultiplerequests); 494 }; 495 #endif 496 497 #ifdef CURL_DISABLE_PROXY 498 #define CONN_IS_PROXIED(x) 0 499 #else 500 #define CONN_IS_PROXIED(x) x->bits.proxy 501 #endif 502 503 /* 504 * Boolean values that concerns this connection. 505 */ 506 struct ConnectBits { 507 #ifndef CURL_DISABLE_PROXY 508 BIT(httpproxy); /* if set, this transfer is done through an HTTP proxy */ 509 BIT(socksproxy); /* if set, this transfer is done through a socks proxy */ 510 BIT(proxy_user_passwd); /* user+password for the proxy? */ 511 BIT(tunnel_proxy); /* if CONNECT is used to "tunnel" through the proxy. 512 This is implicit when SSL-protocols are used through 513 proxies, but can also be enabled explicitly by 514 apps */ 515 BIT(proxy_connect_closed); /* TRUE if a proxy disconnected the connection 516 in a CONNECT request with auth, so that 517 libcurl should reconnect and continue. */ 518 BIT(proxy); /* if set, this transfer is done through a proxy - any type */ 519 #endif 520 /* always modify bits.close with the connclose() and connkeep() macros! */ 521 BIT(close); /* if set, we close the connection after this request */ 522 BIT(reuse); /* if set, this is a reused connection */ 523 BIT(altused); /* this is an alt-svc "redirect" */ 524 BIT(conn_to_host); /* if set, this connection has a "connect to host" 525 that overrides the host in the URL */ 526 BIT(conn_to_port); /* if set, this connection has a "connect to port" 527 that overrides the port in the URL (remote port) */ 528 BIT(ipv6_ip); /* we communicate with a remote site specified with pure IPv6 529 IP address */ 530 BIT(ipv6); /* we communicate with a site using an IPv6 address */ 531 BIT(do_more); /* this is set TRUE if the ->curl_do_more() function is 532 supposed to be called, after ->curl_do() */ 533 BIT(protoconnstart);/* the protocol layer has STARTED its operation after 534 the TCP layer connect */ 535 BIT(retry); /* this connection is about to get closed and then 536 re-attempted at another connection. */ 537 #ifndef CURL_DISABLE_FTP 538 BIT(ftp_use_epsv); /* As set with CURLOPT_FTP_USE_EPSV, but if we find out 539 EPSV doesn't work we disable it for the forthcoming 540 requests */ 541 BIT(ftp_use_eprt); /* As set with CURLOPT_FTP_USE_EPRT, but if we find out 542 EPRT doesn't work we disable it for the forthcoming 543 requests */ 544 BIT(ftp_use_data_ssl); /* Enabled SSL for the data connection */ 545 BIT(ftp_use_control_ssl); /* Enabled SSL for the control connection */ 546 #endif 547 #ifndef CURL_DISABLE_NETRC 548 BIT(netrc); /* name+password provided by netrc */ 549 #endif 550 BIT(bound); /* set true if bind() has already been done on this socket/ 551 connection */ 552 BIT(multiplex); /* connection is multiplexed */ 553 BIT(tcp_fastopen); /* use TCP Fast Open */ 554 BIT(tls_enable_alpn); /* TLS ALPN extension? */ 555 #ifndef CURL_DISABLE_DOH 556 BIT(doh); 557 #endif 558 #ifdef USE_UNIX_SOCKETS 559 BIT(abstract_unix_socket); 560 #endif 561 BIT(tls_upgraded); 562 BIT(sock_accepted); /* TRUE if the SECONDARYSOCKET was created with 563 accept() */ 564 BIT(parallel_connect); /* set TRUE when a parallel connect attempt has 565 started (happy eyeballs) */ 566 }; 567 568 struct hostname { 569 char *rawalloc; /* allocated "raw" version of the name */ 570 char *encalloc; /* allocated IDN-encoded version of the name */ 571 char *name; /* name to use internally, might be encoded, might be raw */ 572 const char *dispname; /* name to display, as 'name' might be encoded */ 573 }; 574 575 /* 576 * Flags on the keepon member of the Curl_transfer_keeper 577 */ 578 579 #define KEEP_NONE 0 580 #define KEEP_RECV (1<<0) /* there is or may be data to read */ 581 #define KEEP_SEND (1<<1) /* there is or may be data to write */ 582 #define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there 583 might still be data to read */ 584 #define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there 585 might still be data to write */ 586 #define KEEP_RECV_PAUSE (1<<4) /* reading is paused */ 587 #define KEEP_SEND_PAUSE (1<<5) /* writing is paused */ 588 589 /* KEEP_SEND_TIMED is set when the transfer should attempt sending 590 * at timer (or other) events. A transfer waiting on a timer will 591 * remove KEEP_SEND to suppress POLLOUTs of the connection. 592 * Adding KEEP_SEND_TIMED will then attempt to send whenever the transfer 593 * enters the "readwrite" loop, e.g. when a timer fires. 594 * This is used in HTTP for 'Expect: 100-continue' waiting. */ 595 #define KEEP_SEND_TIMED (1<<6) 596 597 #define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE) 598 #define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE) 599 600 /* transfer wants to send is not PAUSE or HOLD */ 601 #define CURL_WANT_SEND(data) \ 602 (((data)->req.keepon & KEEP_SENDBITS) == KEEP_SEND) 603 /* transfer receive is not on PAUSE or HOLD */ 604 #define CURL_WANT_RECV(data) \ 605 (((data)->req.keepon & KEEP_RECVBITS) == KEEP_RECV) 606 607 #if defined(CURLRES_ASYNCH) || !defined(CURL_DISABLE_DOH) 608 #define USE_CURL_ASYNC 609 struct Curl_async { 610 char *hostname; 611 struct Curl_dns_entry *dns; 612 struct thread_data *tdata; 613 void *resolver; /* resolver state, if it is used in the URL state - 614 ares_channel e.g. */ 615 int port; 616 int status; /* if done is TRUE, this is the status from the callback */ 617 BIT(done); /* set TRUE when the lookup is complete */ 618 }; 619 620 #endif 621 622 #define FIRSTSOCKET 0 623 #define SECONDARYSOCKET 1 624 625 /* Polling requested by an easy handle. 626 * `action` is CURL_POLL_IN, CURL_POLL_OUT or CURL_POLL_INOUT. 627 */ 628 struct easy_pollset { 629 curl_socket_t sockets[MAX_SOCKSPEREASYHANDLE]; 630 unsigned int num; 631 unsigned char actions[MAX_SOCKSPEREASYHANDLE]; 632 }; 633 634 enum doh_slots { 635 /* Explicit values for first two symbols so as to match hard-coded 636 * constants in existing code 637 */ 638 DOH_PROBE_SLOT_IPADDR_V4 = 0, /* make 'V4' stand out for readability */ 639 DOH_PROBE_SLOT_IPADDR_V6 = 1, /* 'V6' likewise */ 640 641 /* Space here for (possibly build-specific) additional slot definitions */ 642 #ifdef USE_HTTPSRR 643 DOH_PROBE_SLOT_HTTPS = 2, /* for HTTPS RR */ 644 #endif 645 646 /* for example */ 647 /* #ifdef WANT_DOH_FOOBAR_TXT */ 648 /* DOH_PROBE_SLOT_FOOBAR_TXT, */ 649 /* #endif */ 650 651 /* AFTER all slot definitions, establish how many we have */ 652 DOH_PROBE_SLOTS 653 }; 654 655 /* 656 * Specific protocol handler. 657 */ 658 659 struct Curl_handler { 660 const char *scheme; /* URL scheme name. */ 661 662 /* Complement to setup_connection_internals(). This is done before the 663 transfer "owns" the connection. */ 664 CURLcode (*setup_connection)(struct Curl_easy *data, 665 struct connectdata *conn); 666 667 /* These two functions MUST be set to be protocol dependent */ 668 CURLcode (*do_it)(struct Curl_easy *data, bool *done); 669 CURLcode (*done)(struct Curl_easy *, CURLcode, bool); 670 671 /* If the curl_do() function is better made in two halves, this 672 * curl_do_more() function will be called afterwards, if set. For example 673 * for doing the FTP stuff after the PASV/PORT command. 674 */ 675 CURLcode (*do_more)(struct Curl_easy *, int *); 676 677 /* This function *MAY* be set to a protocol-dependent function that is run 678 * after the connect() and everything is done, as a step in the connection. 679 * The 'done' pointer points to a bool that should be set to TRUE if the 680 * function completes before return. If it doesn't complete, the caller 681 * should call the ->connecting() function until it is. 682 */ 683 CURLcode (*connect_it)(struct Curl_easy *data, bool *done); 684 685 /* See above. */ 686 CURLcode (*connecting)(struct Curl_easy *data, bool *done); 687 CURLcode (*doing)(struct Curl_easy *data, bool *done); 688 689 /* Called from the multi interface during the PROTOCONNECT phase, and it 690 should then return a proper fd set */ 691 int (*proto_getsock)(struct Curl_easy *data, 692 struct connectdata *conn, curl_socket_t *socks); 693 694 /* Called from the multi interface during the DOING phase, and it should 695 then return a proper fd set */ 696 int (*doing_getsock)(struct Curl_easy *data, 697 struct connectdata *conn, curl_socket_t *socks); 698 699 /* Called from the multi interface during the DO_MORE phase, and it should 700 then return a proper fd set */ 701 int (*domore_getsock)(struct Curl_easy *data, 702 struct connectdata *conn, curl_socket_t *socks); 703 704 /* Called from the multi interface during the DO_DONE, PERFORM and 705 WAITPERFORM phases, and it should then return a proper fd set. Not setting 706 this will make libcurl use the generic default one. */ 707 int (*perform_getsock)(struct Curl_easy *data, 708 struct connectdata *conn, curl_socket_t *socks); 709 710 /* This function *MAY* be set to a protocol-dependent function that is run 711 * by the curl_disconnect(), as a step in the disconnection. If the handler 712 * is called because the connection has been considered dead, 713 * dead_connection is set to TRUE. The connection is (again) associated with 714 * the transfer here. 715 */ 716 CURLcode (*disconnect)(struct Curl_easy *, struct connectdata *, 717 bool dead_connection); 718 719 /* If used, this function gets called from transfer.c to 720 allow the protocol to do extra handling in writing response to 721 the client. */ 722 CURLcode (*write_resp)(struct Curl_easy *data, const char *buf, size_t blen, 723 bool is_eos); 724 725 /* If used, this function gets called from transfer.c to 726 allow the protocol to do extra handling in writing a single response 727 header line to the client. */ 728 CURLcode (*write_resp_hd)(struct Curl_easy *data, 729 const char *hd, size_t hdlen, bool is_eos); 730 731 /* This function can perform various checks on the connection. See 732 CONNCHECK_* for more information about the checks that can be performed, 733 and CONNRESULT_* for the results that can be returned. */ 734 unsigned int (*connection_check)(struct Curl_easy *data, 735 struct connectdata *conn, 736 unsigned int checks_to_perform); 737 738 /* attach() attaches this transfer to this connection */ 739 void (*attach)(struct Curl_easy *data, struct connectdata *conn); 740 741 int defport; /* Default port. */ 742 curl_prot_t protocol; /* See CURLPROTO_* - this needs to be the single 743 specific protocol bit */ 744 curl_prot_t family; /* single bit for protocol family; basically the 745 non-TLS name of the protocol this is */ 746 unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */ 747 748 }; 749 750 #define PROTOPT_NONE 0 /* nothing extra */ 751 #define PROTOPT_SSL (1<<0) /* uses SSL */ 752 #define PROTOPT_DUAL (1<<1) /* this protocol uses two connections */ 753 #define PROTOPT_CLOSEACTION (1<<2) /* need action before socket close */ 754 /* some protocols will have to call the underlying functions without regard to 755 what exact state the socket signals. IE even if the socket says "readable", 756 the send function might need to be called while uploading, or vice versa. 757 */ 758 #define PROTOPT_DIRLOCK (1<<3) 759 #define PROTOPT_NONETWORK (1<<4) /* protocol doesn't use the network! */ 760 #define PROTOPT_NEEDSPWD (1<<5) /* needs a password, and if none is set it 761 gets a default */ 762 #define PROTOPT_NOURLQUERY (1<<6) /* protocol can't handle 763 url query strings (?foo=bar) ! */ 764 #define PROTOPT_CREDSPERREQUEST (1<<7) /* requires login credentials per 765 request instead of per connection */ 766 #define PROTOPT_ALPN (1<<8) /* set ALPN for this */ 767 /* (1<<9) was PROTOPT_STREAM, now free */ 768 #define PROTOPT_URLOPTIONS (1<<10) /* allow options part in the userinfo field 769 of the URL */ 770 #define PROTOPT_PROXY_AS_HTTP (1<<11) /* allow this non-HTTP scheme over a 771 HTTP proxy as HTTP proxies may know 772 this protocol and act as a gateway */ 773 #define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */ 774 #define PROTOPT_USERPWDCTRL (1<<13) /* Allow "control bytes" (< 32 ascii) in 775 user name and password */ 776 #define PROTOPT_NOTCPPROXY (1<<14) /* this protocol can't proxy over TCP */ 777 778 #define CONNCHECK_NONE 0 /* No checks */ 779 #define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */ 780 #define CONNCHECK_KEEPALIVE (1<<1) /* Perform any keepalive function. */ 781 782 #define CONNRESULT_NONE 0 /* No extra information. */ 783 #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */ 784 785 struct ip_quadruple { 786 char remote_ip[MAX_IPADR_LEN]; 787 char local_ip[MAX_IPADR_LEN]; 788 int remote_port; 789 int local_port; 790 }; 791 792 struct proxy_info { 793 struct hostname host; 794 int port; 795 unsigned char proxytype; /* curl_proxytype: what kind of proxy that is in 796 use */ 797 char *user; /* proxy user name string, allocated */ 798 char *passwd; /* proxy password string, allocated */ 799 }; 800 801 struct ldapconninfo; 802 803 #define TRNSPRT_TCP 3 804 #define TRNSPRT_UDP 4 805 #define TRNSPRT_QUIC 5 806 #define TRNSPRT_UNIX 6 807 808 /* 809 * The connectdata struct contains all fields and variables that should be 810 * unique for an entire connection. 811 */ 812 struct connectdata { 813 struct Curl_llist_element bundle_node; /* conncache */ 814 815 curl_closesocket_callback fclosesocket; /* function closing the socket(s) */ 816 void *closesocket_client; 817 818 /* This is used by the connection cache logic. If this returns TRUE, this 819 handle is still used by one or more easy handles and can only used by any 820 other easy handle without careful consideration (== only for 821 multiplexing) and it cannot be used by another multi handle! */ 822 #define CONN_INUSE(c) ((c)->easyq.size) 823 824 /**** Fields set when inited and not modified again */ 825 curl_off_t connection_id; /* Contains a unique number to make it easier to 826 track the connections in the log output */ 827 828 /* 'dns_entry' is the particular host we use. This points to an entry in the 829 DNS cache and it will not get pruned while locked. It gets unlocked in 830 multi_done(). This entry will be NULL if the connection is reused as then 831 there is no name resolve done. */ 832 struct Curl_dns_entry *dns_entry; 833 834 /* 'remote_addr' is the particular IP we connected to. it is owned, set 835 * and NULLed by the connected socket filter (if there is one). */ 836 const struct Curl_sockaddr_ex *remote_addr; 837 838 struct hostname host; 839 char *hostname_resolve; /* host name to resolve to address, allocated */ 840 char *secondaryhostname; /* secondary socket host name (ftp) */ 841 struct hostname conn_to_host; /* the host to connect to. valid only if 842 bits.conn_to_host is set */ 843 #ifndef CURL_DISABLE_PROXY 844 struct proxy_info socks_proxy; 845 struct proxy_info http_proxy; 846 #endif 847 /* 'primary' and 'secondary' get filled with IP quadruple 848 (local/remote numerical ip address and port) whenever a is *attempted*. 849 When more than one address is tried for a connection these will hold data 850 for the last attempt. When the connection is actually established 851 these are updated with data which comes directly from the socket. */ 852 struct ip_quadruple primary; 853 struct ip_quadruple secondary; 854 char *user; /* user name string, allocated */ 855 char *passwd; /* password string, allocated */ 856 char *options; /* options string, allocated */ 857 char *sasl_authzid; /* authorization identity string, allocated */ 858 char *oauth_bearer; /* OAUTH2 bearer, allocated */ 859 struct curltime now; /* "current" time */ 860 struct curltime created; /* creation time */ 861 struct curltime lastused; /* when returned to the connection cache */ 862 curl_socket_t sock[2]; /* two sockets, the second is used for the data 863 transfer when doing FTP */ 864 Curl_recv *recv[2]; 865 Curl_send *send[2]; 866 struct Curl_cfilter *cfilter[2]; /* connection filters */ 867 868 struct ssl_primary_config ssl_config; 869 #ifndef CURL_DISABLE_PROXY 870 struct ssl_primary_config proxy_ssl_config; 871 #endif 872 struct ConnectBits bits; /* various state-flags for this connection */ 873 874 const struct Curl_handler *handler; /* Connection's protocol handler */ 875 const struct Curl_handler *given; /* The protocol first given */ 876 877 /* Protocols can use a custom keepalive mechanism to keep connections alive. 878 This allows those protocols to track the last time the keepalive mechanism 879 was used on this connection. */ 880 struct curltime keepalive; 881 882 /**** curl_get() phase fields */ 883 884 curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */ 885 curl_socket_t writesockfd; /* socket to write to, it may very 886 well be the same we read from. 887 CURL_SOCKET_BAD disables */ 888 889 #ifdef HAVE_GSSAPI 890 BIT(sec_complete); /* if Kerberos is enabled for this connection */ 891 unsigned char command_prot; /* enum protection_level */ 892 unsigned char data_prot; /* enum protection_level */ 893 unsigned char request_data_prot; /* enum protection_level */ 894 size_t buffer_size; 895 struct krb5buffer in_buffer; 896 void *app_data; 897 const struct Curl_sec_client_mech *mech; 898 struct sockaddr_in local_addr; 899 #endif 900 901 #if defined(USE_KERBEROS5) /* Consider moving some of the above GSS-API */ 902 struct kerberos5data krb5; /* variables into the structure definition, */ 903 #endif /* however, some of them are ftp specific. */ 904 905 struct Curl_llist easyq; /* List of easy handles using this connection */ 906 907 /*************** Request - specific items ************/ 908 #if defined(USE_WINDOWS_SSPI) && defined(SECPKG_ATTR_ENDPOINT_BINDINGS) 909 CtxtHandle *sslContext; 910 #endif 911 912 #if defined(_WIN32) && defined(USE_WINSOCK) 913 struct curltime last_sndbuf_update; /* last time readwrite_upload called 914 win_update_buffer_size */ 915 #endif 916 917 #ifdef USE_GSASL 918 struct gsasldata gsasl; 919 #endif 920 921 #if defined(USE_NTLM) 922 curlntlm http_ntlm_state; 923 curlntlm proxy_ntlm_state; 924 925 struct ntlmdata ntlm; /* NTLM differs from other authentication schemes 926 because it authenticates connections, not 927 single requests! */ 928 struct ntlmdata proxyntlm; /* NTLM data for proxy */ 929 #endif 930 931 #ifdef USE_SPNEGO 932 curlnegotiate http_negotiate_state; 933 curlnegotiate proxy_negotiate_state; 934 935 struct negotiatedata negotiate; /* state data for host Negotiate auth */ 936 struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */ 937 #endif 938 939 union { 940 #ifndef CURL_DISABLE_FTP 941 struct ftp_conn ftpc; 942 #endif 943 #ifdef USE_SSH 944 struct ssh_conn sshc; 945 #endif 946 #ifndef CURL_DISABLE_TFTP 947 struct tftp_state_data *tftpc; 948 #endif 949 #ifndef CURL_DISABLE_IMAP 950 struct imap_conn imapc; 951 #endif 952 #ifndef CURL_DISABLE_POP3 953 struct pop3_conn pop3c; 954 #endif 955 #ifndef CURL_DISABLE_SMTP 956 struct smtp_conn smtpc; 957 #endif 958 #ifndef CURL_DISABLE_RTSP 959 struct rtsp_conn rtspc; 960 #endif 961 #ifndef CURL_DISABLE_SMB 962 struct smb_conn smbc; 963 #endif 964 #ifdef USE_LIBRTMP 965 void *rtmp; 966 #endif 967 #ifdef USE_OPENLDAP 968 struct ldapconninfo *ldapc; 969 #endif 970 #ifndef CURL_DISABLE_MQTT 971 struct mqtt_conn mqtt; 972 #endif 973 #ifdef USE_WEBSOCKETS 974 struct websocket *ws; 975 #endif 976 unsigned int unused:1; /* avoids empty union */ 977 } proto; 978 979 struct connectbundle *bundle; /* The bundle we are member of */ 980 #ifdef USE_UNIX_SOCKETS 981 char *unix_domain_socket; 982 #endif 983 #ifdef USE_HYPER 984 /* if set, an alternative data transfer function */ 985 Curl_datastream datastream; 986 #endif 987 /* When this connection is created, store the conditions for the local end 988 bind. This is stored before the actual bind and before any connection is 989 made and will serve the purpose of being used for comparison reasons so 990 that subsequent bound-requested connections aren't accidentally reusing 991 wrong connections. */ 992 char *localdev; 993 unsigned short localportrange; 994 int waitfor; /* current READ/WRITE bits to wait for */ 995 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) 996 int socks5_gssapi_enctype; 997 #endif 998 /* The field below gets set in connect.c:connecthost() */ 999 int remote_port; /* the remote port, not the proxy port! */ 1000 int conn_to_port; /* the remote port to connect to. valid only if 1001 bits.conn_to_port is set */ 1002 #ifdef USE_IPV6 1003 unsigned int scope_id; /* Scope id for IPv6 */ 1004 #endif 1005 unsigned short localport; 1006 unsigned short secondary_port; /* secondary socket remote port to connect to 1007 (ftp) */ 1008 unsigned char alpn; /* APLN TLS negotiated protocol, a CURL_HTTP_VERSION* 1009 value */ 1010 #ifndef CURL_DISABLE_PROXY 1011 unsigned char proxy_alpn; /* APLN of proxy tunnel, CURL_HTTP_VERSION* */ 1012 #endif 1013 unsigned char transport; /* one of the TRNSPRT_* defines */ 1014 unsigned char ip_version; /* copied from the Curl_easy at creation time */ 1015 unsigned char httpversion; /* the HTTP version*10 reported by the server */ 1016 unsigned char connect_only; 1017 unsigned char gssapi_delegation; /* inherited from set.gssapi_delegation */ 1018 }; 1019 1020 #ifndef CURL_DISABLE_PROXY 1021 #define CURL_CONN_HOST_DISPNAME(c) \ 1022 ((c)->bits.socksproxy ? (c)->socks_proxy.host.dispname : \ 1023 (c)->bits.httpproxy ? (c)->http_proxy.host.dispname : \ 1024 (c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \ 1025 (c)->host.dispname) 1026 #else 1027 #define CURL_CONN_HOST_DISPNAME(c) \ 1028 (c)->bits.conn_to_host ? (c)->conn_to_host.dispname : \ 1029 (c)->host.dispname 1030 #endif 1031 1032 /* The end of connectdata. */ 1033 1034 /* 1035 * Struct to keep statistical and informational data. 1036 * All variables in this struct must be initialized/reset in Curl_initinfo(). 1037 */ 1038 struct PureInfo { 1039 int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */ 1040 int httpproxycode; /* response code from proxy when received separate */ 1041 int httpversion; /* the http version number X.Y = X*10+Y */ 1042 time_t filetime; /* If requested, this is might get set. Set to -1 if the 1043 time was unretrievable. */ 1044 curl_off_t request_size; /* the amount of bytes sent in the request(s) */ 1045 unsigned long proxyauthavail; /* what proxy auth types were announced */ 1046 unsigned long httpauthavail; /* what host auth types were announced */ 1047 long numconnects; /* how many new connection did libcurl created */ 1048 char *contenttype; /* the content type of the object */ 1049 char *wouldredirect; /* URL this would've been redirected to if asked to */ 1050 curl_off_t retry_after; /* info from Retry-After: header */ 1051 unsigned int header_size; /* size of read header(s) in bytes */ 1052 1053 /* PureInfo primary ip_quadruple is copied over from the connectdata 1054 struct in order to allow curl_easy_getinfo() to return this information 1055 even when the session handle is no longer associated with a connection, 1056 and also allow curl_easy_reset() to clear this information from the 1057 session handle without disturbing information which is still alive, and 1058 that might be reused, in the connection cache. */ 1059 struct ip_quadruple primary; 1060 int conn_remote_port; /* this is the "remote port", which is the port 1061 number of the used URL, independent of proxy or 1062 not */ 1063 const char *conn_scheme; 1064 unsigned int conn_protocol; 1065 struct curl_certinfo certs; /* info about the certs. Asked for with 1066 CURLOPT_CERTINFO / CURLINFO_CERTINFO */ 1067 CURLproxycode pxcode; 1068 BIT(timecond); /* set to TRUE if the time condition didn't match, which 1069 thus made the document NOT get fetched */ 1070 BIT(used_proxy); /* the transfer used a proxy */ 1071 }; 1072 1073 1074 struct Progress { 1075 time_t lastshow; /* time() of the last displayed progress meter or NULL to 1076 force redraw at next call */ 1077 curl_off_t size_dl; /* total expected size */ 1078 curl_off_t size_ul; /* total expected size */ 1079 curl_off_t downloaded; /* transferred so far */ 1080 curl_off_t uploaded; /* transferred so far */ 1081 1082 curl_off_t current_speed; /* uses the currently fastest transfer */ 1083 1084 int width; /* screen width at download start */ 1085 int flags; /* see progress.h */ 1086 1087 timediff_t timespent; 1088 1089 curl_off_t dlspeed; 1090 curl_off_t ulspeed; 1091 1092 timediff_t t_postqueue; 1093 timediff_t t_nslookup; 1094 timediff_t t_connect; 1095 timediff_t t_appconnect; 1096 timediff_t t_pretransfer; 1097 timediff_t t_starttransfer; 1098 timediff_t t_redirect; 1099 1100 struct curltime start; 1101 struct curltime t_startsingle; 1102 struct curltime t_startop; 1103 struct curltime t_acceptdata; 1104 1105 1106 /* upload speed limit */ 1107 struct curltime ul_limit_start; 1108 curl_off_t ul_limit_size; 1109 /* download speed limit */ 1110 struct curltime dl_limit_start; 1111 curl_off_t dl_limit_size; 1112 1113 #define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */ 1114 1115 curl_off_t speeder[ CURR_TIME ]; 1116 struct curltime speeder_time[ CURR_TIME ]; 1117 int speeder_c; 1118 BIT(callback); /* set when progress callback is used */ 1119 BIT(is_t_startransfer_set); 1120 }; 1121 1122 typedef enum { 1123 RTSPREQ_NONE, /* first in list */ 1124 RTSPREQ_OPTIONS, 1125 RTSPREQ_DESCRIBE, 1126 RTSPREQ_ANNOUNCE, 1127 RTSPREQ_SETUP, 1128 RTSPREQ_PLAY, 1129 RTSPREQ_PAUSE, 1130 RTSPREQ_TEARDOWN, 1131 RTSPREQ_GET_PARAMETER, 1132 RTSPREQ_SET_PARAMETER, 1133 RTSPREQ_RECORD, 1134 RTSPREQ_RECEIVE, 1135 RTSPREQ_LAST /* last in list */ 1136 } Curl_RtspReq; 1137 1138 struct auth { 1139 unsigned long want; /* Bitmask set to the authentication methods wanted by 1140 app (with CURLOPT_HTTPAUTH or CURLOPT_PROXYAUTH). */ 1141 unsigned long picked; 1142 unsigned long avail; /* Bitmask for what the server reports to support for 1143 this resource */ 1144 BIT(done); /* TRUE when the auth phase is done and ready to do the 1145 actual request */ 1146 BIT(multipass); /* TRUE if this is not yet authenticated but within the 1147 auth multipass negotiation */ 1148 BIT(iestyle); /* TRUE if digest should be done IE-style or FALSE if it 1149 should be RFC compliant */ 1150 }; 1151 1152 #ifdef USE_NGHTTP2 1153 struct Curl_data_prio_node { 1154 struct Curl_data_prio_node *next; 1155 struct Curl_easy *data; 1156 }; 1157 #endif 1158 1159 /** 1160 * Priority information for an easy handle in relation to others 1161 * on the same connection. 1162 * TODO: we need to adapt it to the new priority scheme as defined in RFC 9218 1163 */ 1164 struct Curl_data_priority { 1165 #ifdef USE_NGHTTP2 1166 /* tree like dependencies only implemented in nghttp2 */ 1167 struct Curl_easy *parent; 1168 struct Curl_data_prio_node *children; 1169 #endif 1170 int weight; 1171 #ifdef USE_NGHTTP2 1172 BIT(exclusive); 1173 #endif 1174 }; 1175 1176 /* Timers */ 1177 typedef enum { 1178 EXPIRE_100_TIMEOUT, 1179 EXPIRE_ASYNC_NAME, 1180 EXPIRE_CONNECTTIMEOUT, 1181 EXPIRE_DNS_PER_NAME, /* family1 */ 1182 EXPIRE_DNS_PER_NAME2, /* family2 */ 1183 EXPIRE_HAPPY_EYEBALLS_DNS, /* See asyn-ares.c */ 1184 EXPIRE_HAPPY_EYEBALLS, 1185 EXPIRE_MULTI_PENDING, 1186 EXPIRE_RUN_NOW, 1187 EXPIRE_SPEEDCHECK, 1188 EXPIRE_TIMEOUT, 1189 EXPIRE_TOOFAST, 1190 EXPIRE_QUIC, 1191 EXPIRE_FTP_ACCEPT, 1192 EXPIRE_ALPN_EYEBALLS, 1193 EXPIRE_LAST /* not an actual timer, used as a marker only */ 1194 } expire_id; 1195 1196 1197 typedef enum { 1198 TRAILERS_NONE, 1199 TRAILERS_INITIALIZED, 1200 TRAILERS_SENDING, 1201 TRAILERS_DONE 1202 } trailers_state; 1203 1204 1205 /* 1206 * One instance for each timeout an easy handle can set. 1207 */ 1208 struct time_node { 1209 struct Curl_llist_element list; 1210 struct curltime time; 1211 expire_id eid; 1212 }; 1213 1214 /* individual pieces of the URL */ 1215 struct urlpieces { 1216 char *scheme; 1217 char *hostname; 1218 char *port; 1219 char *user; 1220 char *password; 1221 char *options; 1222 char *path; 1223 char *query; 1224 }; 1225 1226 struct UrlState { 1227 /* Points to the connection cache */ 1228 struct conncache *conn_cache; 1229 /* buffers to store authentication data in, as parsed from input options */ 1230 struct curltime keeps_speed; /* for the progress meter really */ 1231 1232 curl_off_t lastconnect_id; /* The last connection, -1 if undefined */ 1233 curl_off_t recent_conn_id; /* The most recent connection used, might no 1234 * longer exist */ 1235 struct dynbuf headerb; /* buffer to store headers in */ 1236 struct curl_slist *hstslist; /* list of HSTS files set by 1237 curl_easy_setopt(HSTS) calls */ 1238 curl_off_t current_speed; /* the ProgressShow() function sets this, 1239 bytes / second */ 1240 1241 /* host name, port number and protocol of the first (not followed) request. 1242 if set, this should be the host name that we will sent authorization to, 1243 no else. Used to make Location: following not keep sending user+password. 1244 This is strdup()ed data. */ 1245 char *first_host; 1246 int first_remote_port; 1247 curl_prot_t first_remote_protocol; 1248 1249 int retrycount; /* number of retries on a new connection */ 1250 struct Curl_ssl_session *session; /* array of 'max_ssl_sessions' size */ 1251 long sessionage; /* number of the most recent session */ 1252 int os_errno; /* filled in with errno whenever an error occurs */ 1253 char *scratch; /* huge buffer[set.buffer_size*2] for upload CRLF replacing */ 1254 long followlocation; /* redirect counter */ 1255 int requests; /* request counter: redirects + authentication retakes */ 1256 #ifdef HAVE_SIGNAL 1257 /* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */ 1258 void (*prev_signal)(int sig); 1259 #endif 1260 #ifndef CURL_DISABLE_DIGEST_AUTH 1261 struct digestdata digest; /* state data for host Digest auth */ 1262 struct digestdata proxydigest; /* state data for proxy Digest auth */ 1263 #endif 1264 struct auth authhost; /* auth details for host */ 1265 struct auth authproxy; /* auth details for proxy */ 1266 #ifdef USE_CURL_ASYNC 1267 struct Curl_async async; /* asynchronous name resolver data */ 1268 #endif 1269 1270 #if defined(USE_OPENSSL) 1271 /* void instead of ENGINE to avoid bleeding OpenSSL into this header */ 1272 void *engine; 1273 #endif /* USE_OPENSSL */ 1274 struct curltime expiretime; /* set this with Curl_expire() only */ 1275 struct Curl_tree timenode; /* for the splay stuff */ 1276 struct Curl_llist timeoutlist; /* list of pending timeouts */ 1277 struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */ 1278 1279 /* a place to store the most recently set (S)FTP entrypath */ 1280 char *most_recent_ftp_entrypath; 1281 #if !defined(_WIN32) && !defined(MSDOS) && !defined(__EMX__) 1282 /* do FTP line-end conversions on most platforms */ 1283 #define CURL_DO_LINEEND_CONV 1284 /* for FTP downloads: how many CRLFs did we converted to LFs? */ 1285 curl_off_t crlf_conversions; 1286 #endif 1287 char *range; /* range, if used. See README for detailed specification on 1288 this syntax. */ 1289 curl_off_t resume_from; /* continue [ftp] transfer from here */ 1290 1291 #ifndef CURL_DISABLE_RTSP 1292 /* This RTSP state information survives requests and connections */ 1293 long rtsp_next_client_CSeq; /* the session's next client CSeq */ 1294 long rtsp_next_server_CSeq; /* the session's next server CSeq */ 1295 long rtsp_CSeq_recv; /* most recent CSeq received */ 1296 1297 unsigned char rtp_channel_mask[32]; /* for the correctness checking of the 1298 interleaved data */ 1299 #endif 1300 1301 curl_off_t infilesize; /* size of file to upload, -1 means unknown. 1302 Copied from set.filesize at start of operation */ 1303 #if defined(USE_HTTP2) || defined(USE_HTTP3) 1304 struct Curl_data_priority priority; /* shallow copy of data->set */ 1305 #endif 1306 1307 curl_read_callback fread_func; /* read callback/function */ 1308 void *in; /* CURLOPT_READDATA */ 1309 CURLU *uh; /* URL handle for the current parsed URL */ 1310 struct urlpieces up; 1311 char *url; /* work URL, copied from UserDefined */ 1312 char *referer; /* referer string */ 1313 struct curl_slist *resolve; /* set to point to the set.resolve list when 1314 this should be dealt with in pretransfer */ 1315 #ifndef CURL_DISABLE_HTTP 1316 curl_mimepart *mimepost; 1317 #ifndef CURL_DISABLE_FORM_API 1318 curl_mimepart *formp; /* storage for old API form-posting, allocated on 1319 demand */ 1320 #endif 1321 size_t trailers_bytes_sent; 1322 struct dynbuf trailers_buf; /* a buffer containing the compiled trailing 1323 headers */ 1324 struct Curl_llist httphdrs; /* received headers */ 1325 struct curl_header headerout[2]; /* for external purposes */ 1326 struct Curl_header_store *prevhead; /* the latest added header */ 1327 trailers_state trailers_state; /* whether we are sending trailers 1328 and what stage are we at */ 1329 #endif 1330 #ifndef CURL_DISABLE_COOKIES 1331 struct curl_slist *cookielist; /* list of cookie files set by 1332 curl_easy_setopt(COOKIEFILE) calls */ 1333 #endif 1334 #ifdef USE_HYPER 1335 bool hconnect; /* set if a CONNECT request */ 1336 CURLcode hresult; /* used to pass return codes back from hyper callbacks */ 1337 #endif 1338 1339 #ifndef CURL_DISABLE_VERBOSE_STRINGS 1340 struct curl_trc_feat *feat; /* opt. trace feature transfer is part of */ 1341 #endif 1342 1343 /* Dynamically allocated strings, MUST be freed before this struct is 1344 killed. */ 1345 struct dynamically_allocated_data { 1346 char *uagent; 1347 char *accept_encoding; 1348 char *userpwd; 1349 char *rangeline; 1350 char *ref; 1351 char *host; 1352 #ifndef CURL_DISABLE_COOKIES 1353 char *cookiehost; 1354 #endif 1355 #ifndef CURL_DISABLE_RTSP 1356 char *rtsp_transport; 1357 #endif 1358 char *te; /* TE: request header */ 1359 1360 /* transfer credentials */ 1361 char *user; 1362 char *passwd; 1363 #ifndef CURL_DISABLE_PROXY 1364 char *proxyuserpwd; 1365 char *proxyuser; 1366 char *proxypasswd; 1367 #endif 1368 } aptr; 1369 1370 unsigned char httpwant; /* when non-zero, a specific HTTP version requested 1371 to be used in the library's request(s) */ 1372 unsigned char httpversion; /* the lowest HTTP version*10 reported by any 1373 server involved in this request */ 1374 unsigned char httpreq; /* Curl_HttpReq; what kind of HTTP request (if any) 1375 is this */ 1376 unsigned char select_bits; /* != 0 -> bitmask of socket events for this 1377 transfer overriding anything the socket may 1378 report */ 1379 #ifdef CURLDEBUG 1380 BIT(conncache_lock); 1381 #endif 1382 /* when curl_easy_perform() is called, the multi handle is "owned" by 1383 the easy handle so curl_easy_cleanup() on such an easy handle will 1384 also close the multi handle! */ 1385 BIT(multi_owned_by_easy); 1386 1387 BIT(this_is_a_follow); /* this is a followed Location: request */ 1388 BIT(refused_stream); /* this was refused, try again */ 1389 BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in. 1390 This must be set to FALSE every time _easy_perform() is 1391 called. */ 1392 BIT(allow_port); /* Is set.use_port allowed to take effect or not. This 1393 is always set TRUE when curl_easy_perform() is called. */ 1394 BIT(authproblem); /* TRUE if there's some problem authenticating */ 1395 /* set after initial USER failure, to prevent an authentication loop */ 1396 BIT(wildcardmatch); /* enable wildcard matching */ 1397 BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous 1398 417 response */ 1399 BIT(use_range); 1400 BIT(rangestringalloc); /* the range string is malloc()'ed */ 1401 BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE 1402 when multi_done() is called, to prevent multi_done() to get 1403 invoked twice when the multi interface is used. */ 1404 #ifndef CURL_DISABLE_COOKIES 1405 BIT(cookie_engine); 1406 #endif 1407 BIT(prefer_ascii); /* ASCII rather than binary */ 1408 #ifdef CURL_LIST_ONLY_PROTOCOL 1409 BIT(list_only); /* list directory contents */ 1410 #endif 1411 BIT(url_alloc); /* URL string is malloc()'ed */ 1412 BIT(referer_alloc); /* referer string is malloc()ed */ 1413 BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */ 1414 BIT(upload); /* upload request */ 1415 BIT(internal); /* internal: true if this easy handle was created for 1416 internal use and the user does not have ownership of the 1417 handle. */ 1418 }; 1419 1420 /* 1421 * This 'UserDefined' struct must only contain data that is set once to go 1422 * for many (perhaps) independent connections. Values that are generated or 1423 * calculated internally for the "session handle" MUST be defined within the 1424 * 'struct UrlState' instead. The only exceptions MUST note the changes in 1425 * the 'DynamicStatic' struct. 1426 * Character pointer fields point to dynamic storage, unless otherwise stated. 1427 */ 1428 1429 struct Curl_multi; /* declared in multihandle.c */ 1430 1431 enum dupstring { 1432 STRING_CERT, /* client certificate file name */ 1433 STRING_CERT_TYPE, /* format for certificate (default: PEM)*/ 1434 STRING_KEY, /* private key file name */ 1435 STRING_KEY_PASSWD, /* plain text private key password */ 1436 STRING_KEY_TYPE, /* format for private key (default: PEM) */ 1437 STRING_SSL_CAPATH, /* CA directory name (doesn't work on windows) */ 1438 STRING_SSL_CAFILE, /* certificate file to verify peer against */ 1439 STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */ 1440 STRING_SSL_CIPHER_LIST, /* list of ciphers to use */ 1441 STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */ 1442 STRING_SSL_CRLFILE, /* crl file to check certificate */ 1443 STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */ 1444 STRING_SERVICE_NAME, /* Service name */ 1445 #ifndef CURL_DISABLE_PROXY 1446 STRING_CERT_PROXY, /* client certificate file name */ 1447 STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/ 1448 STRING_KEY_PROXY, /* private key file name */ 1449 STRING_KEY_PASSWD_PROXY, /* plain text private key password */ 1450 STRING_KEY_TYPE_PROXY, /* format for private key (default: PEM) */ 1451 STRING_SSL_CAPATH_PROXY, /* CA directory name (doesn't work on windows) */ 1452 STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */ 1453 STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */ 1454 STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */ 1455 STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */ 1456 STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */ 1457 STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */ 1458 STRING_PROXY_SERVICE_NAME, /* Proxy service name */ 1459 #endif 1460 #ifndef CURL_DISABLE_COOKIES 1461 STRING_COOKIE, /* HTTP cookie string to send */ 1462 STRING_COOKIEJAR, /* dump all cookies to this file */ 1463 #endif 1464 STRING_CUSTOMREQUEST, /* HTTP/FTP/RTSP request/method to use */ 1465 STRING_DEFAULT_PROTOCOL, /* Protocol to use when the URL doesn't specify */ 1466 STRING_DEVICE, /* local network interface/address to use */ 1467 STRING_ENCODING, /* Accept-Encoding string */ 1468 #ifndef CURL_DISABLE_FTP 1469 STRING_FTP_ACCOUNT, /* ftp account data */ 1470 STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */ 1471 STRING_FTPPORT, /* port to send with the FTP PORT command */ 1472 #endif 1473 #if defined(HAVE_GSSAPI) 1474 STRING_KRB_LEVEL, /* krb security level */ 1475 #endif 1476 #ifndef CURL_DISABLE_NETRC 1477 STRING_NETRC_FILE, /* if not NULL, use this instead of trying to find 1478 $HOME/.netrc */ 1479 #endif 1480 #ifndef CURL_DISABLE_PROXY 1481 STRING_PROXY, /* proxy to use */ 1482 STRING_PRE_PROXY, /* pre socks proxy to use */ 1483 #endif 1484 STRING_SET_RANGE, /* range, if used */ 1485 STRING_SET_REFERER, /* custom string for the HTTP referer field */ 1486 STRING_SET_URL, /* what original URL to work on */ 1487 STRING_USERAGENT, /* User-Agent string */ 1488 STRING_SSL_ENGINE, /* name of ssl engine */ 1489 STRING_USERNAME, /* <username>, if used */ 1490 STRING_PASSWORD, /* <password>, if used */ 1491 STRING_OPTIONS, /* <options>, if used */ 1492 #ifndef CURL_DISABLE_PROXY 1493 STRING_PROXYUSERNAME, /* Proxy <username>, if used */ 1494 STRING_PROXYPASSWORD, /* Proxy <password>, if used */ 1495 STRING_NOPROXY, /* List of hosts which should not use the proxy, if 1496 used */ 1497 #endif 1498 #ifndef CURL_DISABLE_RTSP 1499 STRING_RTSP_SESSION_ID, /* Session ID to use */ 1500 STRING_RTSP_STREAM_URI, /* Stream URI for this request */ 1501 STRING_RTSP_TRANSPORT, /* Transport for this session */ 1502 #endif 1503 #ifdef USE_SSH 1504 STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */ 1505 STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */ 1506 STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */ 1507 STRING_SSH_HOST_PUBLIC_KEY_SHA256, /* sha256 of host public key in base64 */ 1508 STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */ 1509 #endif 1510 #ifndef CURL_DISABLE_SMTP 1511 STRING_MAIL_FROM, 1512 STRING_MAIL_AUTH, 1513 #endif 1514 #ifdef USE_TLS_SRP 1515 STRING_TLSAUTH_USERNAME, /* TLS auth <username> */ 1516 STRING_TLSAUTH_PASSWORD, /* TLS auth <password> */ 1517 #ifndef CURL_DISABLE_PROXY 1518 STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */ 1519 STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */ 1520 #endif 1521 #endif 1522 STRING_BEARER, /* <bearer>, if used */ 1523 #ifdef USE_UNIX_SOCKETS 1524 STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */ 1525 #endif 1526 STRING_TARGET, /* CURLOPT_REQUEST_TARGET */ 1527 #ifndef CURL_DISABLE_DOH 1528 STRING_DOH, /* CURLOPT_DOH_URL */ 1529 #endif 1530 #ifndef CURL_DISABLE_ALTSVC 1531 STRING_ALTSVC, /* CURLOPT_ALTSVC */ 1532 #endif 1533 #ifndef CURL_DISABLE_HSTS 1534 STRING_HSTS, /* CURLOPT_HSTS */ 1535 #endif 1536 STRING_SASL_AUTHZID, /* CURLOPT_SASL_AUTHZID */ 1537 #ifdef USE_ARES 1538 STRING_DNS_SERVERS, 1539 STRING_DNS_INTERFACE, 1540 STRING_DNS_LOCAL_IP4, 1541 STRING_DNS_LOCAL_IP6, 1542 #endif 1543 STRING_SSL_EC_CURVES, 1544 #ifndef CURL_DISABLE_AWS 1545 STRING_AWS_SIGV4, /* Parameters for V4 signature */ 1546 #endif 1547 #ifndef CURL_DISABLE_PROXY 1548 STRING_HAPROXY_CLIENT_IP, /* CURLOPT_HAPROXY_CLIENT_IP */ 1549 #endif 1550 STRING_ECH_CONFIG, /* CURLOPT_ECH_CONFIG */ 1551 STRING_ECH_PUBLIC, /* CURLOPT_ECH_PUBLIC */ 1552 1553 /* -- end of null-terminated strings -- */ 1554 1555 STRING_LASTZEROTERMINATED, 1556 1557 /* -- below this are pointers to binary data that cannot be strdup'ed. --- */ 1558 1559 STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */ 1560 1561 STRING_LAST /* not used, just an end-of-list marker */ 1562 }; 1563 1564 enum dupblob { 1565 BLOB_CERT, 1566 BLOB_KEY, 1567 BLOB_SSL_ISSUERCERT, 1568 BLOB_CAINFO, 1569 #ifndef CURL_DISABLE_PROXY 1570 BLOB_CERT_PROXY, 1571 BLOB_KEY_PROXY, 1572 BLOB_SSL_ISSUERCERT_PROXY, 1573 BLOB_CAINFO_PROXY, 1574 #endif 1575 BLOB_LAST 1576 }; 1577 1578 /* callback that gets called when this easy handle is completed within a multi 1579 handle. Only used for internally created transfers, like for example 1580 DoH. */ 1581 typedef int (*multidone_func)(struct Curl_easy *easy, CURLcode result); 1582 1583 struct UserDefined { 1584 FILE *err; /* the stderr user data goes here */ 1585 void *debugdata; /* the data that will be passed to fdebug */ 1586 char *errorbuffer; /* (Static) store failure messages in here */ 1587 void *out; /* CURLOPT_WRITEDATA */ 1588 void *in_set; /* CURLOPT_READDATA */ 1589 void *writeheader; /* write the header to this if non-NULL */ 1590 unsigned short use_port; /* which port to use (when not using default) */ 1591 unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */ 1592 unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */ 1593 long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1 1594 for infinity */ 1595 1596 void *postfields; /* if POST, set the fields' values here */ 1597 curl_seek_callback seek_func; /* function that seeks the input */ 1598 curl_off_t postfieldsize; /* if POST, this might have a size to use instead 1599 of strlen(), and then the data *may* be binary 1600 (contain zero bytes) */ 1601 #ifndef CURL_DISABLE_BINDLOCAL 1602 unsigned short localport; /* local port number to bind to */ 1603 unsigned short localportrange; /* number of additional port numbers to test 1604 in case the 'localport' one can't be 1605 bind()ed */ 1606 #endif 1607 curl_write_callback fwrite_func; /* function that stores the output */ 1608 curl_write_callback fwrite_header; /* function that stores headers */ 1609 curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */ 1610 curl_read_callback fread_func_set; /* function that reads the input */ 1611 curl_progress_callback fprogress; /* OLD and deprecated progress callback */ 1612 curl_xferinfo_callback fxferinfo; /* progress callback */ 1613 curl_debug_callback fdebug; /* function that write informational data */ 1614 curl_ioctl_callback ioctl_func; /* function for I/O control */ 1615 curl_sockopt_callback fsockopt; /* function for setting socket options */ 1616 void *sockopt_client; /* pointer to pass to the socket options callback */ 1617 curl_opensocket_callback fopensocket; /* function for checking/translating 1618 the address and opening the 1619 socket */ 1620 void *opensocket_client; 1621 curl_closesocket_callback fclosesocket; /* function for closing the 1622 socket */ 1623 void *closesocket_client; 1624 curl_prereq_callback fprereq; /* pre-initial request callback */ 1625 void *prereq_userp; /* pre-initial request user data */ 1626 1627 void *seek_client; /* pointer to pass to the seek callback */ 1628 #ifndef CURL_DISABLE_HSTS 1629 curl_hstsread_callback hsts_read; 1630 void *hsts_read_userp; 1631 curl_hstswrite_callback hsts_write; 1632 void *hsts_write_userp; 1633 #endif 1634 void *progress_client; /* pointer to pass to the progress callback */ 1635 void *ioctl_client; /* pointer to pass to the ioctl callback */ 1636 unsigned int timeout; /* ms, 0 means no timeout */ 1637 unsigned int connecttimeout; /* ms, 0 means no timeout */ 1638 unsigned int happy_eyeballs_timeout; /* ms, 0 is a valid value */ 1639 unsigned int server_response_timeout; /* ms, 0 means no timeout */ 1640 long maxage_conn; /* in seconds, max idle time to allow a connection that 1641 is to be reused */ 1642 long maxlifetime_conn; /* in seconds, max time since creation to allow a 1643 connection that is to be reused */ 1644 #ifndef CURL_DISABLE_TFTP 1645 long tftp_blksize; /* in bytes, 0 means use default */ 1646 #endif 1647 curl_off_t filesize; /* size of file to upload, -1 means unknown */ 1648 long low_speed_limit; /* bytes/second */ 1649 long low_speed_time; /* number of seconds */ 1650 curl_off_t max_send_speed; /* high speed limit in bytes/second for upload */ 1651 curl_off_t max_recv_speed; /* high speed limit in bytes/second for 1652 download */ 1653 curl_off_t set_resume_from; /* continue [ftp] transfer from here */ 1654 struct curl_slist *headers; /* linked list of extra headers */ 1655 struct curl_httppost *httppost; /* linked list of old POST data */ 1656 #if !defined(CURL_DISABLE_MIME) || !defined(CURL_DISABLE_FORM_API) 1657 curl_mimepart mimepost; /* MIME/POST data. */ 1658 #endif 1659 #ifndef CURL_DISABLE_TELNET 1660 struct curl_slist *telnet_options; /* linked list of telnet options */ 1661 #endif 1662 struct curl_slist *resolve; /* list of names to add/remove from 1663 DNS cache */ 1664 struct curl_slist *connect_to; /* list of host:port mappings to override 1665 the hostname and port to connect to */ 1666 time_t timevalue; /* what time to compare with */ 1667 unsigned char timecondition; /* kind of time comparison: curl_TimeCond */ 1668 unsigned char method; /* what kind of HTTP request: Curl_HttpReq */ 1669 unsigned char httpwant; /* when non-zero, a specific HTTP version requested 1670 to be used in the library's request(s) */ 1671 struct ssl_config_data ssl; /* user defined SSL stuff */ 1672 #ifndef CURL_DISABLE_PROXY 1673 struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */ 1674 struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */ 1675 unsigned short proxyport; /* If non-zero, use this port number by 1676 default. If the proxy string features a 1677 ":[port]" that one will override this. */ 1678 unsigned char proxytype; /* what kind of proxy: curl_proxytype */ 1679 unsigned char socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */ 1680 #endif 1681 struct ssl_general_config general_ssl; /* general user defined SSL stuff */ 1682 int dns_cache_timeout; /* DNS cache timeout (seconds) */ 1683 unsigned int buffer_size; /* size of receive buffer to use */ 1684 unsigned int upload_buffer_size; /* size of upload buffer to use, 1685 keep it >= CURL_MAX_WRITE_SIZE */ 1686 void *private_data; /* application-private data */ 1687 #ifndef CURL_DISABLE_HTTP 1688 struct curl_slist *http200aliases; /* linked list of aliases for http200 */ 1689 #endif 1690 unsigned char ipver; /* the CURL_IPRESOLVE_* defines in the public header 1691 file 0 - whatever, 1 - v2, 2 - v6 */ 1692 curl_off_t max_filesize; /* Maximum file size to download */ 1693 #ifndef CURL_DISABLE_FTP 1694 unsigned char ftp_filemethod; /* how to get to a file: curl_ftpfile */ 1695 unsigned char ftpsslauth; /* what AUTH XXX to try: curl_ftpauth */ 1696 unsigned char ftp_ccc; /* FTP CCC options: curl_ftpccc */ 1697 unsigned int accepttimeout; /* in milliseconds, 0 means no timeout */ 1698 #endif 1699 #if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) 1700 struct curl_slist *quote; /* after connection is established */ 1701 struct curl_slist *postquote; /* after the transfer */ 1702 struct curl_slist *prequote; /* before the transfer, after type */ 1703 /* Despite the name, ftp_create_missing_dirs is for FTP(S) and SFTP 1704 1 - create directories that don't exist 1705 2 - the same but also allow MKD to fail once 1706 */ 1707 unsigned char ftp_create_missing_dirs; 1708 #endif 1709 #ifdef USE_LIBSSH2 1710 curl_sshhostkeycallback ssh_hostkeyfunc; /* hostkey check callback */ 1711 void *ssh_hostkeyfunc_userp; /* custom pointer to callback */ 1712 #endif 1713 #ifdef USE_SSH 1714 curl_sshkeycallback ssh_keyfunc; /* key matching callback */ 1715 void *ssh_keyfunc_userp; /* custom pointer to callback */ 1716 int ssh_auth_types; /* allowed SSH auth types */ 1717 unsigned int new_directory_perms; /* when creating remote dirs */ 1718 #endif 1719 #ifndef CURL_DISABLE_NETRC 1720 unsigned char use_netrc; /* enum CURL_NETRC_OPTION values */ 1721 #endif 1722 unsigned int new_file_perms; /* when creating remote files */ 1723 char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */ 1724 struct curl_blob *blobs[BLOB_LAST]; 1725 #ifdef USE_IPV6 1726 unsigned int scope_id; /* Scope id for IPv6 */ 1727 #endif 1728 curl_prot_t allowed_protocols; 1729 curl_prot_t redir_protocols; 1730 #ifndef CURL_DISABLE_RTSP 1731 void *rtp_out; /* write RTP to this if non-NULL */ 1732 /* Common RTSP header options */ 1733 Curl_RtspReq rtspreq; /* RTSP request type */ 1734 #endif 1735 #ifndef CURL_DISABLE_FTP 1736 curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer 1737 starts */ 1738 curl_chunk_end_callback chunk_end; /* called after part transferring 1739 stopped */ 1740 curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds 1741 to pattern (e.g. if WILDCARDMATCH is on) */ 1742 void *fnmatch_data; 1743 void *wildcardptr; 1744 #endif 1745 /* GSS-API credential delegation, see the documentation of 1746 CURLOPT_GSSAPI_DELEGATION */ 1747 unsigned char gssapi_delegation; 1748 1749 int tcp_keepidle; /* seconds in idle before sending keepalive probe */ 1750 int tcp_keepintvl; /* seconds between TCP keepalive probes */ 1751 1752 long expect_100_timeout; /* in milliseconds */ 1753 #if defined(USE_HTTP2) || defined(USE_HTTP3) 1754 struct Curl_data_priority priority; 1755 #endif 1756 curl_resolver_start_callback resolver_start; /* optional callback called 1757 before resolver start */ 1758 void *resolver_start_client; /* pointer to pass to resolver start callback */ 1759 long upkeep_interval_ms; /* Time between calls for connection upkeep. */ 1760 multidone_func fmultidone; 1761 #ifndef CURL_DISABLE_DOH 1762 struct Curl_easy *dohfor; /* this is a DoH request for that transfer */ 1763 #endif 1764 CURLU *uh; /* URL handle for the current parsed URL */ 1765 #ifndef CURL_DISABLE_HTTP 1766 void *trailer_data; /* pointer to pass to trailer data callback */ 1767 curl_trailer_callback trailer_callback; /* trailing data callback */ 1768 #endif 1769 char keep_post; /* keep POSTs as POSTs after a 30x request; each 1770 bit represents a request, from 301 to 303 */ 1771 #ifndef CURL_DISABLE_SMTP 1772 struct curl_slist *mail_rcpt; /* linked list of mail recipients */ 1773 BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some 1774 recipients */ 1775 #endif 1776 unsigned int maxconnects; /* Max idle connections in the connection cache */ 1777 unsigned char use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or 1778 IMAP or POP3 or others! (type: curl_usessl)*/ 1779 unsigned char connect_only; /* make connection/request, then let 1780 application use the socket */ 1781 #ifndef CURL_DISABLE_MIME 1782 BIT(mime_formescape); 1783 #endif 1784 BIT(is_fread_set); /* has read callback been set to non-NULL? */ 1785 #ifndef CURL_DISABLE_TFTP 1786 BIT(tftp_no_options); /* do not send TFTP options requests */ 1787 #endif 1788 BIT(sep_headers); /* handle host and proxy headers separately */ 1789 #ifndef CURL_DISABLE_COOKIES 1790 BIT(cookiesession); /* new cookie session? */ 1791 #endif 1792 BIT(crlf); /* convert crlf on ftp upload(?) */ 1793 #ifdef USE_SSH 1794 BIT(ssh_compression); /* enable SSH compression */ 1795 #endif 1796 1797 /* Here follows boolean settings that define how to behave during 1798 this session. They are STATIC, set by libcurl users or at least initially 1799 and they don't change during operations. */ 1800 BIT(quick_exit); /* set 1L when it is okay to leak things (like 1801 threads), as we're about to exit() anyway and 1802 don't want lengthy cleanups to delay termination, 1803 e.g. after a DNS timeout */ 1804 BIT(get_filetime); /* get the time and get of the remote file */ 1805 #ifndef CURL_DISABLE_PROXY 1806 BIT(tunnel_thru_httpproxy); /* use CONNECT through an HTTP proxy */ 1807 #endif 1808 BIT(prefer_ascii); /* ASCII rather than binary */ 1809 BIT(remote_append); /* append, not overwrite, on upload */ 1810 #ifdef CURL_LIST_ONLY_PROTOCOL 1811 BIT(list_only); /* list directory */ 1812 #endif 1813 #ifndef CURL_DISABLE_FTP 1814 BIT(ftp_use_port); /* use the FTP PORT command */ 1815 BIT(ftp_use_epsv); /* if EPSV is to be attempted or not */ 1816 BIT(ftp_use_eprt); /* if EPRT is to be attempted or not */ 1817 BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */ 1818 BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to 1819 us */ 1820 BIT(wildcard_enabled); /* enable wildcard matching */ 1821 #endif 1822 BIT(hide_progress); /* don't use the progress meter */ 1823 BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */ 1824 BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */ 1825 BIT(http_follow_location); /* follow HTTP redirects */ 1826 BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */ 1827 BIT(allow_auth_to_other_hosts); 1828 BIT(include_header); /* include received protocol headers in data output */ 1829 BIT(http_set_referer); /* is a custom referer used */ 1830 BIT(http_auto_referer); /* set "correct" referer when following 1831 location: */ 1832 BIT(opt_no_body); /* as set with CURLOPT_NOBODY */ 1833 BIT(verbose); /* output verbosity */ 1834 #if defined(HAVE_GSSAPI) 1835 BIT(krb); /* Kerberos connection requested */ 1836 #endif 1837 BIT(reuse_forbid); /* forbidden to be reused, close after use */ 1838 BIT(reuse_fresh); /* do not reuse an existing connection */ 1839 BIT(no_signal); /* do not use any signal/alarm handler */ 1840 BIT(tcp_nodelay); /* whether to enable TCP_NODELAY or not */ 1841 BIT(ignorecl); /* ignore content length */ 1842 BIT(http_te_skip); /* pass the raw body data to the user, even when 1843 transfer-encoded (chunked, compressed) */ 1844 BIT(http_ce_skip); /* pass the raw body data to the user, even when 1845 content-encoded (chunked, compressed) */ 1846 BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing 1847 FTP via an HTTP proxy */ 1848 #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) 1849 BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */ 1850 #endif 1851 BIT(sasl_ir); /* Enable/disable SASL initial response */ 1852 BIT(tcp_keepalive); /* use TCP keepalives */ 1853 BIT(tcp_fastopen); /* use TCP Fast Open */ 1854 BIT(ssl_enable_alpn);/* TLS ALPN extension? */ 1855 BIT(path_as_is); /* allow dotdots? */ 1856 BIT(pipewait); /* wait for multiplex status before starting a new 1857 connection */ 1858 BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers 1859 from user callbacks */ 1860 BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */ 1861 #ifndef CURL_DISABLE_PROXY 1862 BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1 1863 header */ 1864 #endif 1865 #ifdef USE_UNIX_SOCKETS 1866 BIT(abstract_unix_socket); 1867 #endif 1868 BIT(disallow_username_in_url); /* disallow username in url */ 1869 #ifndef CURL_DISABLE_DOH 1870 BIT(doh); /* DNS-over-HTTPS enabled */ 1871 BIT(doh_verifypeer); /* DoH certificate peer verification */ 1872 BIT(doh_verifyhost); /* DoH certificate hostname verification */ 1873 BIT(doh_verifystatus); /* DoH certificate status verification */ 1874 #endif 1875 BIT(http09_allowed); /* allow HTTP/0.9 responses */ 1876 #ifdef USE_WEBSOCKETS 1877 BIT(ws_raw_mode); 1878 #endif 1879 #ifdef USE_ECH 1880 int tls_ech; /* TLS ECH configuration */ 1881 #endif 1882 }; 1883 1884 #ifndef CURL_DISABLE_MIME 1885 #define IS_MIME_POST(a) ((a)->set.mimepost.kind != MIMEKIND_NONE) 1886 #else 1887 #define IS_MIME_POST(a) FALSE 1888 #endif 1889 1890 struct Names { 1891 struct Curl_hash *hostcache; 1892 enum { 1893 HCACHE_NONE, /* not pointing to anything */ 1894 HCACHE_MULTI, /* points to a shared one in the multi handle */ 1895 HCACHE_SHARED /* points to a shared one in a shared object */ 1896 } hostcachetype; 1897 }; 1898 1899 /* 1900 * The 'connectdata' struct MUST have all the connection oriented stuff as we 1901 * may have several simultaneous connections and connection structs in memory. 1902 * 1903 * The 'struct UserDefined' must only contain data that is set once to go for 1904 * many (perhaps) independent connections. Values that are generated or 1905 * calculated internally for the "session handle" must be defined within the 1906 * 'struct UrlState' instead. 1907 */ 1908 1909 struct Curl_easy { 1910 /* First a simple identifier to easier detect if a user mix up this easy 1911 handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */ 1912 unsigned int magic; 1913 /* once an easy handle is tied to a connection cache 1914 a non-negative number to distinguish this transfer from 1915 other using the same cache. For easier tracking 1916 in log output. 1917 This may wrap around after LONG_MAX to 0 again, so it 1918 has no uniqueness guarantee for very large processings. */ 1919 curl_off_t id; 1920 1921 /* first, two fields for the linked list of these */ 1922 struct Curl_easy *next; 1923 struct Curl_easy *prev; 1924 1925 struct connectdata *conn; 1926 struct Curl_llist_element connect_queue; /* for the pending and msgsent 1927 lists */ 1928 struct Curl_llist_element conn_queue; /* list per connectdata */ 1929 1930 CURLMstate mstate; /* the handle's state */ 1931 CURLcode result; /* previous result */ 1932 1933 struct Curl_message msg; /* A single posted message. */ 1934 1935 /* Array with the plain socket numbers this handle takes care of, in no 1936 particular order. Note that all sockets are added to the sockhash, where 1937 the state etc are also kept. This array is mostly used to detect when a 1938 socket is to be removed from the hash. See singlesocket(). */ 1939 struct easy_pollset last_poll; 1940 1941 struct Names dns; 1942 struct Curl_multi *multi; /* if non-NULL, points to the multi handle 1943 struct to which this "belongs" when used by 1944 the multi interface */ 1945 struct Curl_multi *multi_easy; /* if non-NULL, points to the multi handle 1946 struct to which this "belongs" when used 1947 by the easy interface */ 1948 struct Curl_share *share; /* Share, handles global variable mutexing */ 1949 #ifdef USE_LIBPSL 1950 struct PslCache *psl; /* The associated PSL cache. */ 1951 #endif 1952 struct SingleRequest req; /* Request-specific data */ 1953 struct UserDefined set; /* values set by the libcurl user */ 1954 #ifndef CURL_DISABLE_COOKIES 1955 struct CookieInfo *cookies; /* the cookies, read from files and servers. 1956 NOTE that the 'cookie' field in the 1957 UserDefined struct defines if the "engine" 1958 is to be used or not. */ 1959 #endif 1960 #ifndef CURL_DISABLE_HSTS 1961 struct hsts *hsts; 1962 #endif 1963 #ifndef CURL_DISABLE_ALTSVC 1964 struct altsvcinfo *asi; /* the alt-svc cache */ 1965 #endif 1966 struct Progress progress; /* for all the progress meter data */ 1967 struct UrlState state; /* struct for fields used for state info and 1968 other dynamic purposes */ 1969 #ifndef CURL_DISABLE_FTP 1970 struct WildcardData *wildcard; /* wildcard download state info */ 1971 #endif 1972 struct PureInfo info; /* stats, reports and info data */ 1973 struct curl_tlssessioninfo tsi; /* Information about the TLS session, only 1974 valid after a client has asked for it */ 1975 #ifdef USE_HYPER 1976 struct hyptransfer hyp; 1977 #endif 1978 }; 1979 1980 #define LIBCURL_NAME "libcurl" 1981 1982 #endif /* HEADER_CURL_URLDATA_H */ 1983