File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / curl / lib / urldata.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Jun 3 10:01:15 2020 UTC (4 years, 1 month ago) by misho
Branches: curl, MAIN
CVS tags: v7_70_0p4, HEAD
curl

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>