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