7
7
* | (__| |_| | _ <| |___
8
8
* \___|\___/|_| \_\_____|
10
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
10
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
12
12
* This software is licensed as described in the file COPYING, which
13
13
* you should have received as part of this distribution. The terms
20
20
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
21
* KIND, either express or implied.
23
* $Id: urldata.h,v 1.378 2008-04-30 21:20:09 bagder Exp $
23
* $Id: urldata.h,v 1.409 2009-03-02 23:05:31 bagder Exp $
24
24
***************************************************************************/
26
26
/* This file is for lib internal stuff */
48
48
#define CURL_DEFAULT_USER "anonymous"
49
49
#define CURL_DEFAULT_PASSWORD "ftp@example.com"
51
/* length of longest IPv6 address string including the trailing null */
52
#define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
51
54
#include "cookie.h"
52
55
#include "formdata.h"
138
151
#define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
140
/* Just a convenience macro to get the larger value out of two given.
153
/* Some convenience macros to get the larger/smaller value out of two given.
141
154
We prefix with CURL to prevent name collisions. */
142
155
#define CURLMAX(x,y) ((x)>(y)?(x):(y))
156
#define CURLMIN(x,y) ((x)<(y)?(x):(y))
144
159
#if defined(HAVE_KRB4) || defined(HAVE_GSSAPI)
145
160
/* Types needed for krb4/5-ftp connections */
209
224
1: check that CN exists
210
225
2: CN must match hostname */
211
226
char *CApath; /* certificate dir (doesn't work on windows) */
212
char *CAfile; /* cerficate to verify peer against */
227
char *CAfile; /* certificate to verify peer against */
228
const char *CRLfile; /* CRL to check certificate revocation */
229
const char *issuercert;/* optional issuer certificate filename */
213
230
char *random_file; /* path to file containing "random" data */
214
231
char *egdsocket; /* path to file containing the EGD daemon socket */
215
232
char *cipher_list; /* list of ciphers to use */
217
234
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
218
235
void *fsslctxp; /* parameter for call back */
219
236
bool sessionid; /* cache session IDs or not */
237
bool certinfo; /* gather lots of certificate info */
222
240
/* information stored about one single SSL session */
284
296
#ifdef HAVE_GSSAPI
285
297
struct negotiatedata {
298
/* when doing Negotiate we first need to receive an auth token and then we
299
need to send our header */
300
enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state;
286
301
bool gss; /* Whether we're processing GSS-Negotiate or Negotiate */
287
302
const char* protocol; /* "GSS-Negotiate" or "Negotiate" */
288
303
OM_uint32 status;
423
438
size_t nread_resp; /* number of bytes currently read of a server response */
424
439
char *linestart_resp; /* line start pointer for the FTP server response
425
440
reader function */
441
bool pending_resp; /* set TRUE when a server response is pending or in
442
progress, and is cleared once the last response is
427
445
int count1; /* general purpose counter for the state machine */
428
446
int count2; /* general purpose counter for the state machine */
509
527
struct ssh_conn {
510
528
const char *authlist; /* List of auth. methods, managed by libssh2 */
511
529
#ifdef USE_LIBSSH2
512
const char *passphrase; /* passphrase to use */
530
const char *passphrase; /* pass-phrase to use */
513
531
char *rsa_pub; /* path name */
514
532
char *rsa; /* path name */
515
533
bool authed; /* the connection has been authenticated fine */
540
558
LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
541
559
LIBSSH2_SFTP *sftp_session; /* SFTP handle */
542
560
LIBSSH2_SFTP_HANDLE *sftp_handle;
561
int waitfor; /* current READ/WRITE bits to wait for */
562
int orig_waitfor; /* default READ/WRITE bits wait for */
543
563
#endif /* USE_LIBSSH2 */
571
591
bool do_more; /* this is set TRUE if the ->curl_do_more() function is
572
592
supposed to be called, after ->curl_do() */
574
bool tcpconnect; /* the TCP layer (or simimlar) is connected, this is set
594
bool tcpconnect; /* the TCP layer (or similar) is connected, this is set
575
595
the first time on the first connect function call */
576
596
bool protoconnstart;/* the protocol layer has STARTED its operation after
577
597
the TCP layer connect */
619
639
char *rawalloc; /* allocated "raw" version of the name */
620
640
char *encalloc; /* allocated IDN-encoded version of the name */
621
641
char *name; /* name to use internally, might be encoded, might be raw */
622
char *dispname; /* name to display, as 'name' might be encoded */
642
const char *dispname; /* name to display, as 'name' might be encoded */
684
704
* Request specific data in the easy handle (SessionHandle). Previously,
685
705
* these members were on the connectdata struct but since a conn struct may
686
* now be shared between different SessionHandles, we store connection-specifc
706
* now be shared between different SessionHandles, we store connection-specific
687
707
* data here. This struct only keeps stuff that's interesting for *this*
688
708
* request, as it will be cleared between multiple ones
727
747
curl_off_t offset; /* possible resume offset read from the
728
748
Content-Range: header */
729
749
int httpcode; /* error code from the 'HTTP/1.? XXX' line */
730
int httpversion; /* the HTTP version*10 */
731
750
struct timeval start100; /* time stamp to wait for the 100 code from */
732
751
enum expect100 exp100; /* expect 100 continue state */
734
753
int content_encoding; /* What content encoding. sec 3.5, RFC2616. */
736
755
#define IDENTITY 0 /* No encoding */
737
#define DEFLATE 1 /* zlib delfate [RFC 1950 & 1951] */
756
#define DEFLATE 1 /* zlib deflate [RFC 1950 & 1951] */
738
757
#define GZIP 2 /* gzip algorithm [RFC 1952] */
739
758
#define COMPRESS 3 /* Not handled, added for completeness */
832
851
curl_socket_t *socks,
854
/* Called from the multi interface during the DO_DONE, PERFORM and
855
WAITPERFORM phases, and it should then return a proper fd set. Not setting
856
this will make libcurl use the generic default one. */
857
int (*perform_getsock)(const struct connectdata *conn,
858
curl_socket_t *socks,
835
861
/* This function *MAY* be set to a protocol-dependent function that is run
836
862
* by the curl_disconnect(), as a step in the disconnection.
865
891
long connectindex; /* what index in the connection cache connects index this
866
892
particular struct has */
867
893
long protocol; /* PROT_* flags concerning the protocol set */
868
#define PROT_MISSING (1<<0)
869
#define PROT_HTTP (1<<2)
870
#define PROT_HTTPS (1<<3)
871
#define PROT_FTP (1<<4)
872
#define PROT_TELNET (1<<5)
873
#define PROT_DICT (1<<6)
874
#define PROT_LDAP (1<<7)
875
#define PROT_FILE (1<<8)
876
#define PROT_FTPS (1<<9)
877
#define PROT_SSL (1<<10) /* protocol requires SSL */
878
#define PROT_TFTP (1<<11)
879
#define PROT_SCP (1<<12)
880
#define PROT_SFTP (1<<13)
894
#define PROT_HTTP CURLPROTO_HTTP
895
#define PROT_HTTPS CURLPROTO_HTTPS
896
#define PROT_FTP CURLPROTO_FTP
897
#define PROT_TELNET CURLPROTO_TELNET
898
#define PROT_DICT CURLPROTO_DICT
899
#define PROT_LDAP CURLPROTO_LDAP
900
#define PROT_FILE CURLPROTO_FILE
901
#define PROT_FTPS CURLPROTO_FTPS
902
#define PROT_TFTP CURLPROTO_TFTP
903
#define PROT_SCP CURLPROTO_SCP
904
#define PROT_SFTP CURLPROTO_SFTP
906
/* CURLPROTO_TFTP (1<<11) is currently the highest used bit in the public
907
bitmask. We make sure we use "private bits" above the first 16 to make
910
#define PROT_EXTMASK 0xffff
912
#define PROT_SSL (1<<22) /* protocol requires SSL */
913
#define PROT_MISSING (1<<23)
882
915
#define PROT_CLOSEACTION PROT_FTP /* these ones need action before socket
917
#define PROT_DUALCHANNEL PROT_FTP /* these protocols use two connections */
885
919
/* 'dns_entry' is the particular host we use. This points to an entry in the
886
920
DNS cache and it will not get pruned while locked. It gets unlocked in
893
927
cache entry remains locked. It gets unlocked in Curl_done() */
894
928
Curl_addrinfo *ip_addr;
896
/* 'ip_addr_str' is the ip_addr data as a human readable malloc()ed string.
930
/* 'ip_addr_str' is the ip_addr data as a human readable string.
897
931
It remains available as long as the connection does, which is longer than
898
the ip_addr itself. Set with Curl_store_ip_addr() when ip_addr has been
932
the ip_addr itself. */
933
char ip_addr_str[MAX_IPADR_LEN];
935
unsigned int scope; /* address scope for IPv6 */
902
937
char protostr[16]; /* store the protocol string in this buffer */
903
938
int socktype; /* SOCK_STREAM or SOCK_DGRAM */
916
951
char *proxypasswd; /* proxy password string, allocated */
917
952
curl_proxytype proxytype; /* what kind of proxy that is in use */
954
int httpversion; /* the HTTP version*10 reported by the server */
919
956
struct timeval now; /* "current" time */
920
957
struct timeval created; /* creation time */
921
958
curl_socket_t sock[2]; /* two sockets, the second is used for the data
960
997
struct sockaddr_in local_addr;
1000
/* the two following *_inuse fields are only flags, not counters in any way.
1001
If TRUE it means the channel is in use, and if FALSE it means the channel
1002
is up for grabs by one. */
963
1004
bool readchannel_inuse; /* whether the read channel is in use by an easy
965
1006
bool writechannel_inuse; /* whether the write channel is in use by an easy
1012
1053
struct ftp_conn ftpc;
1013
1054
struct ssh_conn sshc;
1055
struct tftp_state_data *tftpc;
1016
1058
int cselect_bits; /* bitmask of socket events */
1059
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1060
int socks5_gssapi_enctype;
1019
1064
/* The end of connectdata. */
1029
1074
was unretrievable. We cannot have this of type time_t,
1030
1075
since time_t is unsigned on several platforms such as
1077
bool timecond; /* set to TRUE if the time condition didn't match, which
1078
thus made the document NOT get fetched */
1032
1079
long header_size; /* size of read header(s) in bytes */
1033
1080
long request_size; /* the amount of bytes sent in the request(s) */
1034
1081
long proxyauthavail; /* what proxy auth types were announced */
1036
1083
long numconnects; /* how many new connection did libcurl created */
1037
1084
char *contenttype; /* the content type of the object */
1038
1085
char *wouldredirect; /* URL this would've been redirected to if asked to */
1086
char ip[MAX_IPADR_LEN]; /* this buffer gets the numerical ip version stored
1087
at the connect *attempt* so it will get the last
1088
tried connect IP even on failures */
1089
struct curl_certinfo certs; /* info about the certs, only populated in
1090
OpenSSL builds. Asked for with
1091
CURLOPT_CERTINFO / CURLINFO_CERTINFO */
1192
1247
struct timeval expiretime; /* set this with Curl_expire() only */
1193
1248
struct Curl_tree timenode; /* for the splay stuff */
1195
/* a place to store the most recenlty set FTP entrypath */
1250
/* a place to store the most recently set FTP entrypath */
1196
1251
char *most_recent_ftp_entrypath;
1198
1253
/* set after initial USER failure, to prevent an authentication loop */
1199
1254
bool ftp_trying_alternative;
1256
int httpversion; /* the lowest HTTP version*10 reported by any server
1257
involved in this request */
1201
1258
bool expect100header; /* TRUE if we added Expect: 100-continue */
1203
1260
bool pipe_broke; /* TRUE if the connection we were pipelined on broke
1204
1261
and we need to restart from the beginning */
1263
#if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
1264
!defined(__SYMBIAN32__)
1207
1265
/* do FTP line-end conversions on most platforms */
1208
1266
#define CURL_DO_LINEEND_CONV
1209
1267
/* for FTP downloads: track CRLF sequences that span blocks */
1235
1293
*************************************************************************
1236
1294
* Note that this data will be REMOVED after each request, so anything that
1237
1295
* should be kept/stored on a per-connection basis and thus live for the
1238
* next requst on the same connection MUST be put in the connectdata struct!
1296
* next request on the same connection MUST be put in the connectdata struct!
1239
1297
*************************************************************************/
1241
1299
struct HTTP *http;
1242
1300
struct HTTP *https; /* alias, just for the sake of being more readable */
1243
1301
struct FTP *ftp;
1244
void *tftp; /* private for tftp.c-eyes only */
1302
/* void *tftp; not used */
1245
1303
struct FILEPROTO *file;
1246
1304
void *telnet; /* private for telnet.c-eyes only */
1298
1356
$HOME/.netrc */
1299
1357
STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
1300
1358
STRING_PROXY, /* proxy to use */
1301
STRING_PROXYUSERPWD, /* Proxy <user:password>, if used */
1302
1359
STRING_SET_RANGE, /* range, if used */
1303
1360
STRING_SET_REFERER, /* custom string for the HTTP referer field */
1304
1361
STRING_SET_URL, /* what original URL to work on */
1310
1367
STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */
1311
1368
STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
1312
1369
STRING_USERAGENT, /* User-Agent string */
1313
STRING_USERPWD, /* <user:password>, if used */
1314
1370
STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
1371
STRING_SSL_CRLFILE, /* crl file to check certificate */
1372
STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
1373
STRING_USERNAME, /* <username>, if used */
1374
STRING_PASSWORD, /* <password>, if used */
1375
STRING_PROXYUSERNAME, /* Proxy <username>, if used */
1376
STRING_PROXYPASSWORD, /* Proxy <password>, if used */
1377
STRING_NOPROXY, /* List of hosts which should not use the proxy, if
1379
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1380
STRING_SOCKS5_GSSAPI_SERVICE, /* GSSAPI service name */
1316
1383
/* -- end of strings -- */
1317
1384
STRING_LAST /* not used, just an end-of-list marker */
1335
1402
for infinity */
1336
1403
bool post301; /* Obey RFC 2616/10.3.2 and keep POSTs as POSTs after a
1405
bool post302; /* keep POSTs as POSTs after a 302 */
1338
1406
bool free_referer; /* set TRUE if 'referer' points to a string we
1340
1408
void *postfields; /* if POST, set the fields' values here */
1371
1439
long timeout; /* in milliseconds, 0 means no timeout */
1372
1440
long connecttimeout; /* in milliseconds, 0 means no timeout */
1373
1441
long ftp_response_timeout; /* in milliseconds, 0 means no timeout */
1442
long tftp_blksize ; /* in bytes, 0 means use default */
1374
1443
curl_off_t infilesize; /* size of file to upload, -1 means unknown */
1375
1444
long low_speed_limit; /* bytes/second */
1376
1445
long low_speed_time; /* number of seconds */
1417
1486
curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */
1488
int ftp_create_missing_dirs; /* 1 - create directories that don't exist
1489
2 - the same but also allow MKD to fail once
1419
1492
/* Here follows boolean settings that define how to behave during
1420
1493
this session. They are STATIC, set by libcurl users or at least initially
1421
1494
and they don't change during operations. */
1426
1499
bool prefer_ascii; /* ASCII rather than binary */
1427
1500
bool ftp_append; /* append, not overwrite, on upload */
1428
1501
bool ftp_list_only; /* switch FTP command for listing directories */
1429
bool ftp_create_missing_dirs; /* create directories that don't exist */
1430
1502
bool ftp_use_port; /* use the FTP PORT command */
1431
1503
bool hide_progress; /* don't use the progress meter */
1432
1504
bool http_fail_on_error; /* fail on HTTP error codes >= 300 */
1467
1539
bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
1468
1540
via an HTTP proxy */
1469
1541
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
1542
unsigned int scope; /* address scope for IPv6 */
1543
long allowed_protocols;
1544
long redir_protocols;
1545
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1546
long socks5_gssapi_nec; /* flag to support nec socks5 server */
1494
1572
struct Names dns;
1495
1573
struct Curl_multi *multi; /* if non-NULL, points to the multi handle
1496
1574
struct to which this "belongs" */
1497
struct Curl_one_easy *multi_pos; /* if non-NULL, points to the its position
1575
struct Curl_one_easy *multi_pos; /* if non-NULL, points to its position
1498
1576
in multi controlling structure to assist
1500
1578
struct Curl_share *share; /* Share, handles global variable mutexing */