~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/urldata.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *                            | (__| |_| |  _ <| |___
8
8
 *                             \___|\___/|_| \_\_____|
9
9
 *
10
 
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
 
10
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
11
11
 *
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.
22
22
 *
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
 ***************************************************************************/
25
25
 
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"
50
50
 
 
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")
 
53
 
51
54
#include "cookie.h"
52
55
#include "formdata.h"
53
56
 
72
75
#include "pem.h"
73
76
#include "ssl.h"
74
77
#include "err.h"
 
78
#ifdef HAVE_OPENSSL_ENGINE_H
 
79
#include <engine.h>
 
80
#endif
 
81
#ifdef HAVE_OPENSSL_PKCS12_H
 
82
#include <pkcs12.h>
 
83
#endif
75
84
#endif /* USE_OPENSSL */
76
85
#ifdef USE_GNUTLS
77
86
#error Configuration error; cannot use GnuTLS *and* OpenSSL.
98
107
 
99
108
#ifdef HAVE_ZLIB_H
100
109
#include <zlib.h>               /* for content-encoding */
 
110
#ifdef __SYMBIAN32__
 
111
/* zlib pollutes the namespace with this definition */
 
112
#undef WIN32
 
113
#endif
101
114
#endif
102
115
 
103
116
#ifdef USE_ARES
137
150
 
138
151
#define CURLEASY_MAGIC_NUMBER 0xc0dedbadU
139
152
 
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))
 
157
 
143
158
 
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 */
220
238
};
221
239
 
222
240
/* information stored about one single SSL session */
251
269
} curlntlm;
252
270
 
253
271
#ifdef USE_WINDOWS_SSPI
254
 
/* When including these headers, you must define either SECURITY_WIN32
255
 
 * or SECURITY_KERNEL, indicating who is compiling the code.
256
 
 */
257
 
#define SECURITY_WIN32 1
258
 
#include <security.h>
259
 
#include <sspi.h>
260
 
#include <rpc.h>
 
272
#include "curl_sspi.h"
261
273
#endif
262
274
 
263
275
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
283
295
 
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;
298
313
struct HTTP {
299
314
  struct FormData *sendit;
300
315
  curl_off_t postsize; /* off_t to handle large file sizes */
301
 
  char *postdata;
 
316
  const char *postdata;
302
317
 
303
318
  const char *p_pragma;      /* Pragma: string */
304
319
  const char *p_accept;      /* Accept: string */
311
326
  struct back {
312
327
    curl_read_callback fread_func; /* backup storage for fread pointer */
313
328
    void *fread_in;           /* backup storage for fread_in pointer */
314
 
    char *postdata;
 
329
    const char *postdata;
315
330
    curl_off_t postsize;
316
331
  } backup;
317
332
 
394
409
  curl_off_t downloadsize;
395
410
};
396
411
 
397
 
/* ftp_conn is used for striuct connection-oriented data in the connectdata
 
412
/* ftp_conn is used for struct connection-oriented data in the connectdata
398
413
   struct */
399
414
struct ftp_conn {
400
415
  char *entrypath; /* the PWD reply when we logged on */
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
 
443
                         read */
426
444
 
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 */
544
564
};
545
565
 
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() */
573
593
 
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 */
623
643
};
624
644
 
625
645
/*
683
703
/*
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
689
709
 */
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 */
733
752
 
734
753
  int content_encoding;         /* What content encoding. sec 3.5, RFC2616. */
735
754
 
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 */
740
759
 
832
851
                       curl_socket_t *socks,
833
852
                       int numsocks);
834
853
 
 
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,
 
859
                         int numsocks);
 
860
 
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.
837
863
   */
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
 
905
 
 
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
 
908
   things easier. */
 
909
 
 
910
#define PROT_EXTMASK 0xffff
 
911
 
 
912
#define PROT_SSL     (1<<22) /* protocol requires SSL */
 
913
#define PROT_MISSING (1<<23)
881
914
 
882
915
#define PROT_CLOSEACTION PROT_FTP /* these ones need action before socket
883
916
                                     close */
 
917
#define PROT_DUALCHANNEL PROT_FTP /* these protocols use two connections */
884
918
 
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;
895
929
 
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
899
 
     set. */
900
 
  char *ip_addr_str;
 
932
     the ip_addr itself. */
 
933
  char ip_addr_str[MAX_IPADR_LEN];
 
934
 
 
935
  unsigned int scope;    /* address scope for IPv6 */
901
936
 
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 */
918
953
 
 
954
  int httpversion;              /* the HTTP version*10 reported by the server */
 
955
 
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;
961
998
#endif
962
999
 
 
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. */
 
1003
 
963
1004
  bool readchannel_inuse;  /* whether the read channel is in use by an easy
964
1005
                              handle */
965
1006
  bool writechannel_inuse; /* whether the write channel is in use by an easy
1011
1052
  union {
1012
1053
    struct ftp_conn ftpc;
1013
1054
    struct ssh_conn sshc;
 
1055
    struct tftp_state_data *tftpc;
1014
1056
  } proto;
1015
1057
 
1016
1058
  int cselect_bits; /* bitmask of socket events */
 
1059
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
 
1060
  int socks5_gssapi_enctype;
 
1061
#endif
1017
1062
};
1018
1063
 
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
1031
1076
                    OpenVMS. */
 
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 */
1039
1092
};
1040
1093
 
1041
1094
 
1060
1113
 
1061
1114
  double t_nslookup;
1062
1115
  double t_connect;
 
1116
  double t_appconnect;
1063
1117
  double t_pretransfer;
1064
1118
  double t_starttransfer;
1065
1119
  double t_redirect;
1107
1161
                 request */
1108
1162
  bool multi; /* TRUE if this is not yet authenticated but within the auth
1109
1163
                 multipass negotiation */
1110
 
 
 
1164
  bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
 
1165
                   be RFC compliant */
1111
1166
};
1112
1167
 
1113
1168
struct conncache {
1192
1247
  struct timeval expiretime; /* set this with Curl_expire() only */
1193
1248
  struct Curl_tree timenode; /* for the splay stuff */
1194
1249
 
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;
1197
1252
 
1198
1253
  /* set after initial USER failure, to prevent an authentication loop */
1199
1254
  bool ftp_trying_alternative;
1200
1255
 
 
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 */
1202
1259
 
1203
1260
  bool pipe_broke; /* TRUE if the connection we were pipelined on broke
1204
1261
                      and we need to restart from the beginning */
1205
1262
 
1206
 
#ifndef WIN32
 
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
   *************************************************************************/
1240
1298
  union {
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 */
1247
1305
    void *generic;
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
 
1378
                             used */
 
1379
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
 
1380
  STRING_SOCKS5_GSSAPI_SERVICE,  /* GSSAPI service name */
 
1381
#endif
1315
1382
 
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
1337
1404
                        301 */
 
1405
  bool post302;      /* keep POSTs as POSTs after a 302 */
1338
1406
  bool free_referer; /* set TRUE if 'referer' points to a string we
1339
1407
                        allocated */
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 */
1416
1485
 
1417
1486
  curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used  */
1418
1487
 
 
1488
  int ftp_create_missing_dirs; /* 1 - create directories that don't exist
 
1489
                                  2 - the same but also allow MKD to fail once
 
1490
                               */
 
1491
 
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 */
 
1547
#endif
1470
1548
};
1471
1549
 
1472
1550
struct Names {
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
1499
1577
                                      in removal. */
1500
1578
  struct Curl_share *share;    /* Share, handles global variable mutexing */