~ubuntu-branches/ubuntu/natty/curl/natty-security

« back to all changes in this revision

Viewing changes to lib/urldata.h

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2010-06-20 13:56:28 UTC
  • mfrom: (3.4.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100620135628-e30tp9jldq6hq985
Tags: 7.21.0-1ubuntu1
* Merge from debian unstable.  Remaining changes: LP: #596334
  - Keep build deps in main:
    - Drop build dependencies: stunnel, libssh2-1-dev
    - Add build-dependency on openssh-server
    - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *                            | (__| |_| |  _ <| |___
8
8
 *                             \___|\___/|_| \_\_____|
9
9
 *
10
 
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
 
10
 * Copyright (C) 1998 - 2010, 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.420 2009-10-29 03:48:00 yangtse Exp $
24
23
 ***************************************************************************/
25
24
 
26
25
/* This file is for lib internal stuff */
37
36
#define PORT_LDAPS 636
38
37
#define PORT_TFTP 69
39
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_SMTP 25
 
44
#define PORT_SMTPS 465 /* sometimes called SSMTP */
 
45
#define PORT_RTSP 554
 
46
#define PORT_RTMP 1935
 
47
#define PORT_RTMPT PORT_HTTP
 
48
#define PORT_RTMPS PORT_HTTPS
40
49
 
41
50
#define DICT_MATCH "/MATCH:"
42
51
#define DICT_MATCH2 "/M:"
51
60
/* length of longest IPv6 address string including the trailing null */
52
61
#define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
53
62
 
 
63
/* Default FTP/IMAP etc response timeout in milliseconds.
 
64
   Symbian OS panics when given a timeout much greater than 1/2 hour.
 
65
*/
 
66
#define RESP_TIMEOUT (1800*1000)
 
67
 
54
68
#include "cookie.h"
55
69
#include "formdata.h"
56
70
 
91
105
#include <gnutls/gnutls.h>
92
106
#endif
93
107
 
 
108
#ifdef USE_POLARSSL
 
109
#include <polarssl/havege.h>
 
110
#include <polarssl/ssl.h>
 
111
#endif
 
112
 
94
113
#ifdef USE_NSS
95
114
#include <nspr.h>
96
115
#include <pk11pub.h>
129
148
#include "hash.h"
130
149
#include "splay.h"
131
150
 
 
151
#include "imap.h"
 
152
#include "pop3.h"
 
153
#include "smtp.h"
 
154
#include "ftp.h"
 
155
#include "file.h"
 
156
#include "ssh.h"
 
157
#include "http.h"
 
158
#include "rtsp.h"
 
159
#include "wildcard.h"
 
160
 
132
161
#ifdef HAVE_GSSAPI
133
162
# ifdef HAVE_GSSGNU
134
163
#  include <gss.h>
211
240
#ifdef USE_GNUTLS
212
241
  gnutls_session session;
213
242
  gnutls_certificate_credentials cred;
 
243
  ssl_connect_state connecting_state;
214
244
#endif /* USE_GNUTLS */
 
245
#ifdef USE_POLARSSL
 
246
  havege_state hs;
 
247
  ssl_context ssl;
 
248
  ssl_session ssn;
 
249
  int server_fd;
 
250
  x509_cert cacert;
 
251
  x509_cert clicert;
 
252
  x509_crl crl;
 
253
  rsa_context rsa;
 
254
#endif /* USE_POLARSSL */
215
255
#ifdef USE_NSS
216
256
  PRFileDesc *handle;
217
257
  char *client_nickname;
317
357
};
318
358
#endif
319
359
 
320
 
/****************************************************************************
321
 
 * HTTP unique setup
322
 
 ***************************************************************************/
323
 
struct HTTP {
324
 
  struct FormData *sendit;
325
 
  curl_off_t postsize; /* off_t to handle large file sizes */
326
 
  const char *postdata;
327
 
 
328
 
  const char *p_pragma;      /* Pragma: string */
329
 
  const char *p_accept;      /* Accept: string */
330
 
  curl_off_t readbytecount;
331
 
  curl_off_t writebytecount;
332
 
 
333
 
  /* For FORM posting */
334
 
  struct Form form;
335
 
 
336
 
  struct back {
337
 
    curl_read_callback fread_func; /* backup storage for fread pointer */
338
 
    void *fread_in;           /* backup storage for fread_in pointer */
339
 
    const char *postdata;
340
 
    curl_off_t postsize;
341
 
  } backup;
342
 
 
343
 
  enum {
344
 
    HTTPSEND_NADA,    /* init */
345
 
    HTTPSEND_REQUEST, /* sending a request */
346
 
    HTTPSEND_BODY,    /* sending body */
347
 
    HTTPSEND_LAST     /* never use this */
348
 
  } sending;
349
 
 
350
 
  void *send_buffer; /* used if the request couldn't be sent in one chunk,
351
 
                        points to an allocated send_buffer struct */
352
 
};
353
 
 
354
 
/****************************************************************************
355
 
 * FTP unique setup
356
 
 ***************************************************************************/
357
 
typedef enum {
358
 
  FTP_STOP,    /* do nothing state, stops the state machine */
359
 
  FTP_WAIT220, /* waiting for the initial 220 response immediately after
360
 
                  a connect */
361
 
  FTP_AUTH,
362
 
  FTP_USER,
363
 
  FTP_PASS,
364
 
  FTP_ACCT,
365
 
  FTP_PBSZ,
366
 
  FTP_PROT,
367
 
  FTP_CCC,
368
 
  FTP_PWD,
369
 
  FTP_SYST,
370
 
  FTP_NAMEFMT,
371
 
  FTP_QUOTE, /* waiting for a response to a command sent in a quote list */
372
 
  FTP_RETR_PREQUOTE,
373
 
  FTP_STOR_PREQUOTE,
374
 
  FTP_POSTQUOTE,
375
 
  FTP_CWD,  /* change dir */
376
 
  FTP_MKD,  /* if the dir didn't exist */
377
 
  FTP_MDTM, /* to figure out the datestamp */
378
 
  FTP_TYPE, /* to set type when doing a head-like request */
379
 
  FTP_LIST_TYPE, /* set type when about to do a dir list */
380
 
  FTP_RETR_TYPE, /* set type when about to RETR a file */
381
 
  FTP_STOR_TYPE, /* set type when about to STOR a file */
382
 
  FTP_SIZE, /* get the remote file's size for head-like request */
383
 
  FTP_RETR_SIZE, /* get the remote file's size for RETR */
384
 
  FTP_STOR_SIZE, /* get the size for (resumed) STOR */
385
 
  FTP_REST, /* when used to check if the server supports it in head-like */
386
 
  FTP_RETR_REST, /* when asking for "resume" in for RETR */
387
 
  FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */
388
 
  FTP_PASV, /* generic state for PASV and EPSV, check count1 */
389
 
  FTP_LIST, /* generic state for LIST, NLST or a custom list command */
390
 
  FTP_RETR,
391
 
  FTP_STOR, /* generic state for STOR and APPE */
392
 
  FTP_QUIT,
393
 
  FTP_LAST  /* never used */
394
 
} ftpstate;
395
 
 
396
 
typedef enum {
397
 
  FTPFILE_MULTICWD  = 1, /* as defined by RFC1738 */
398
 
  FTPFILE_NOCWD     = 2, /* use SIZE / RETR / STOR on the full path */
399
 
  FTPFILE_SINGLECWD = 3  /* make one CWD, then SIZE / RETR / STOR on the file */
400
 
} curl_ftpfile;
401
 
 
402
 
typedef enum {
403
 
  FTPTRANSFER_BODY, /* yes do transfer a body */
404
 
  FTPTRANSFER_INFO, /* do still go through to get info/headers */
405
 
  FTPTRANSFER_NONE, /* don't get anything and don't get info */
406
 
  FTPTRANSFER_LAST  /* end of list marker, never used */
407
 
} curl_ftptransfer;
408
 
 
409
 
/* This FTP struct is used in the SessionHandle. All FTP data that is
410
 
   connection-oriented must be in FTP_conn to properly deal with the fact that
411
 
   perhaps the SessionHandle is changed between the times the connection is
412
 
   used. */
413
 
struct FTP {
414
 
  curl_off_t *bytecountp;
415
 
  char *user;    /* user name string */
416
 
  char *passwd;  /* password string */
417
 
 
418
 
  /* transfer a file/body or not, done as a typedefed enum just to make
419
 
     debuggers display the full symbol and not just the numerical value */
420
 
  curl_ftptransfer transfer;
421
 
  curl_off_t downloadsize;
422
 
};
423
 
 
424
 
/* ftp_conn is used for struct connection-oriented data in the connectdata
425
 
   struct */
426
 
struct ftp_conn {
427
 
  char *entrypath; /* the PWD reply when we logged on */
428
 
  char **dirs;   /* realloc()ed array for path components */
429
 
  int dirdepth;  /* number of entries used in the 'dirs' array */
430
 
  int diralloc;  /* number of entries allocated for the 'dirs' array */
431
 
  char *file;    /* decoded file */
432
 
  char *cache;       /* data cache between getresponse()-calls */
433
 
  curl_off_t cache_size; /* size of cache in bytes */
434
 
  bool dont_check;  /* Set to TRUE to prevent the final (post-transfer)
435
 
                       file size and 226/250 status check. It should still
436
 
                       read the line, just ignore the result. */
437
 
  long response_time; /* When no timeout is given, this is the amount of
438
 
                         seconds we await for an FTP response. Initialized
439
 
                         in Curl_ftp_connect() */
440
 
  bool ctl_valid;   /* Tells Curl_ftp_quit() whether or not to do anything. If
441
 
                       the connection has timed out or been closed, this
442
 
                       should be FALSE when it gets to Curl_ftp_quit() */
443
 
  bool cwddone;     /* if it has been determined that the proper CWD combo
444
 
                       already has been done */
445
 
  bool cwdfail;     /* set TRUE if a CWD command fails, as then we must prevent
446
 
                       caching the current directory */
447
 
  char *prevpath;   /* conn->path from the previous transfer */
448
 
  char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
449
 
                        and others (A/I or zero) */
450
 
  size_t nread_resp; /* number of bytes currently read of a server response */
451
 
  char *linestart_resp; /* line start pointer for the FTP server response
452
 
                           reader function */
453
 
  bool pending_resp;  /* set TRUE when a server response is pending or in
454
 
                         progress, and is cleared once the last response is
455
 
                         read */
456
 
 
457
 
  int count1; /* general purpose counter for the state machine */
458
 
  int count2; /* general purpose counter for the state machine */
459
 
  int count3; /* general purpose counter for the state machine */
460
 
  char *sendthis; /* allocated pointer to a buffer that is to be sent to the
461
 
                     ftp server */
462
 
  size_t sendleft; /* number of bytes left to send from the sendthis buffer */
463
 
  size_t sendsize; /* total size of the sendthis buffer */
464
 
  struct timeval response; /* set to Curl_tvnow() when a command has been sent
465
 
                              off, used to time-out response reading */
466
 
  ftpstate state; /* always use ftp.c:state() to change state! */
467
 
  char * server_os;     /* The target server operating system. */
468
 
};
469
 
 
470
 
/****************************************************************************
471
 
 * SSH unique setup
472
 
 ***************************************************************************/
473
 
typedef enum {
474
 
  SSH_NO_STATE = -1,  /* Used for "nextState" so say there is none */
475
 
  SSH_STOP = 0,       /* do nothing state, stops the state machine */
476
 
 
477
 
  SSH_S_STARTUP,      /* Session startup, First state in SSH-CONNECT */
478
 
  SSH_HOSTKEY,        /* verify hostkey */
479
 
  SSH_AUTHLIST,
480
 
  SSH_AUTH_PKEY_INIT,
481
 
  SSH_AUTH_PKEY,
482
 
  SSH_AUTH_PASS_INIT,
483
 
  SSH_AUTH_PASS,
484
 
  SSH_AUTH_HOST_INIT,
485
 
  SSH_AUTH_HOST,
486
 
  SSH_AUTH_KEY_INIT,
487
 
  SSH_AUTH_KEY,
488
 
  SSH_AUTH_DONE,
489
 
  SSH_SFTP_INIT,
490
 
  SSH_SFTP_REALPATH,   /* Last state in SSH-CONNECT */
491
 
 
492
 
  SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
493
 
  SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
494
 
  SSH_SFTP_QUOTE,
495
 
  SSH_SFTP_NEXT_QUOTE,
496
 
  SSH_SFTP_QUOTE_STAT,
497
 
  SSH_SFTP_QUOTE_SETSTAT,
498
 
  SSH_SFTP_QUOTE_SYMLINK,
499
 
  SSH_SFTP_QUOTE_MKDIR,
500
 
  SSH_SFTP_QUOTE_RENAME,
501
 
  SSH_SFTP_QUOTE_RMDIR,
502
 
  SSH_SFTP_QUOTE_UNLINK,
503
 
  SSH_SFTP_TRANS_INIT,
504
 
  SSH_SFTP_UPLOAD_INIT,
505
 
  SSH_SFTP_CREATE_DIRS_INIT,
506
 
  SSH_SFTP_CREATE_DIRS,
507
 
  SSH_SFTP_CREATE_DIRS_MKDIR,
508
 
  SSH_SFTP_READDIR_INIT,
509
 
  SSH_SFTP_READDIR,
510
 
  SSH_SFTP_READDIR_LINK,
511
 
  SSH_SFTP_READDIR_BOTTOM,
512
 
  SSH_SFTP_READDIR_DONE,
513
 
  SSH_SFTP_DOWNLOAD_INIT,
514
 
  SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
515
 
  SSH_SFTP_CLOSE,    /* Last state in SFTP-DONE */
516
 
  SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
517
 
  SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
518
 
  SSH_SCP_UPLOAD_INIT,
519
 
  SSH_SCP_DOWNLOAD_INIT,
520
 
  SSH_SCP_DONE,
521
 
  SSH_SCP_SEND_EOF,
522
 
  SSH_SCP_WAIT_EOF,
523
 
  SSH_SCP_WAIT_CLOSE,
524
 
  SSH_SCP_CHANNEL_FREE,   /* Last state in SCP-DONE */
525
 
  SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
526
 
  SSH_SESSION_FREE,       /* Last state in SCP/SFTP-DISCONNECT */
527
 
  SSH_QUIT,
528
 
  SSH_LAST  /* never used */
529
 
} sshstate;
530
 
 
531
 
/* this struct is used in the HandleData struct which is part of the
532
 
   SessionHandle, which means this is used on a per-easy handle basis.
533
 
   Everything that is strictly related to a connection is banned from this
534
 
   struct. */
535
 
struct SSHPROTO {
536
 
  char *path;                  /* the path we operate on */
537
 
};
538
 
 
539
 
/* ssh_conn is used for struct connection-oriented data in the connectdata
540
 
   struct */
541
 
struct ssh_conn {
542
 
  const char *authlist;       /* List of auth. methods, managed by libssh2 */
543
 
#ifdef USE_LIBSSH2
544
 
  const char *passphrase;     /* pass-phrase to use */
545
 
  char *rsa_pub;              /* path name */
546
 
  char *rsa;                  /* path name */
547
 
  bool authed;                /* the connection has been authenticated fine */
548
 
  sshstate state;             /* always use ssh.c:state() to change state! */
549
 
  sshstate nextstate;         /* the state to goto after stopping */
550
 
  CURLcode actualcode;        /* the actual error code */
551
 
  struct curl_slist *quote_item; /* for the quote option */
552
 
  char *quote_path1;          /* two generic pointers for the QUOTE stuff */
553
 
  char *quote_path2;
554
 
  LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
555
 
  char *homedir;              /* when doing SFTP we figure out home dir in the
556
 
                                 connect phase */
557
 
 
558
 
  /* Here's a set of struct members used by the SFTP_READDIR state */
559
 
  LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
560
 
  char *readdir_filename;
561
 
  char *readdir_longentry;
562
 
  int readdir_len, readdir_totalLen, readdir_currLen;
563
 
  char *readdir_line;
564
 
  char *readdir_linkPath;
565
 
  /* end of READDIR stuff */
566
 
 
567
 
  int secondCreateDirs;         /* counter use by the code to see if the
568
 
                                   second attempt has been made to change
569
 
                                   to/create a directory */
570
 
  char *slash_pos;              /* used by the SFTP_CREATE_DIRS state */
571
 
  LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
572
 
  LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
573
 
  LIBSSH2_SFTP *sftp_session;   /* SFTP handle */
574
 
  LIBSSH2_SFTP_HANDLE *sftp_handle;
575
 
  int orig_waitfor;             /* default READ/WRITE bits wait for */
576
 
 
577
 
  /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
578
 
     header */
579
 
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
580
 
  LIBSSH2_KNOWNHOSTS *kh;
581
 
#endif
582
 
#endif /* USE_LIBSSH2 */
583
 
};
584
 
 
585
 
 
586
 
/****************************************************************************
587
 
 * FILE unique setup
588
 
 ***************************************************************************/
589
 
struct FILEPROTO {
590
 
  char *path; /* the path we operate on */
591
 
  char *freepath; /* pointer to the allocated block we must free, this might
592
 
                     differ from the 'path' pointer */
593
 
  int fd;     /* open file descriptor to read from! */
594
 
};
595
360
 
596
361
/*
597
362
 * Boolean values that concerns this connection.
690
455
} zlibInitState;
691
456
#endif
692
457
 
693
 
#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \
694
 
    defined(USE_THREADING_GETADDRINFO)
 
458
#ifdef CURLRES_ASYNCH
695
459
struct Curl_async {
696
460
  char *hostname;
697
461
  int port;
766
530
  bool content_range;           /* set TRUE if Content-Range: was found */
767
531
  curl_off_t offset;            /* possible resume offset read from the
768
532
                                   Content-Range: header */
769
 
  int httpcode;                 /* error code from the 'HTTP/1.? XXX' line */
 
533
  int httpcode;                 /* error code from the 'HTTP/1.? XXX' or
 
534
                                   'RTSP/1.? XXX' line */
770
535
  struct timeval start100;      /* time stamp to wait for the 100 code from */
771
536
  enum expect100 exp100;        /* expect 100 continue state */
772
537
 
887
652
  long protocol;      /* PROT_* flags concerning the protocol set */
888
653
};
889
654
 
 
655
/* return the count of bytes sent, or -1 on error */
 
656
typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
 
657
                            int sockindex,            /* socketindex */
 
658
                            const void *buf,          /* data to write */
 
659
                            size_t len,               /* max amount to write */
 
660
                            CURLcode *err);           /* error to return */
 
661
 
 
662
/* return the count of bytes read, or -1 on error */
 
663
typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
 
664
                            int sockindex,            /* socketindex */
 
665
                            char *buf,                /* store data here */
 
666
                            size_t len,               /* max amount to read */
 
667
                            CURLcode *err);           /* error to return */
 
668
 
890
669
/*
891
670
 * The connectdata struct contains all fields and variables that should be
892
671
 * unique for an entire connection.
922
701
#define PROT_TFTP    CURLPROTO_TFTP
923
702
#define PROT_SCP     CURLPROTO_SCP
924
703
#define PROT_SFTP    CURLPROTO_SFTP
925
 
 
926
 
/* CURLPROTO_TFTP (1<<11) is currently the highest used bit in the public
927
 
   bitmask. We make sure we use "private bits" above the first 16 to make
928
 
   things easier. */
929
 
 
930
 
#define PROT_EXTMASK 0xffff
931
 
 
932
 
#define PROT_SSL     (1<<22) /* protocol requires SSL */
933
 
#define PROT_MISSING (1<<23)
934
 
 
935
 
#define PROT_CLOSEACTION PROT_FTP /* these ones need action before socket
936
 
                                     close */
 
704
#define PROT_IMAP    CURLPROTO_IMAP
 
705
#define PROT_IMAPS   CURLPROTO_IMAPS
 
706
#define PROT_POP3    CURLPROTO_POP3
 
707
#define PROT_POP3S   CURLPROTO_POP3S
 
708
#define PROT_SMTP    CURLPROTO_SMTP
 
709
#define PROT_SMTPS   CURLPROTO_SMTPS
 
710
#define PROT_RTSP    CURLPROTO_RTSP
 
711
#define PROT_RTMP    CURLPROTO_RTMP
 
712
#define PROT_RTMPT   CURLPROTO_RTMPT
 
713
#define PROT_RTMPE   CURLPROTO_RTMPE
 
714
#define PROT_RTMPTE  CURLPROTO_RTMPTE
 
715
#define PROT_RTMPS   CURLPROTO_RTMPS
 
716
#define PROT_RTMPTS  CURLPROTO_RTMPTS
 
717
 
 
718
/* (1<<24) is currently the highest used bit in the public bitmask. We make
 
719
   sure we use "private bits" above the public ones to make things easier. */
 
720
 
 
721
#define PROT_EXTMASK 0xffffff
 
722
 
 
723
#define PROT_SSL     (1<<29) /* protocol requires SSL */
 
724
 
 
725
/* these ones need action before socket close */
 
726
#define PROT_CLOSEACTION (PROT_FTP | PROT_IMAP | PROT_POP3)
937
727
#define PROT_DUALCHANNEL PROT_FTP /* these protocols use two connections */
938
728
 
939
729
  /* 'dns_entry' is the particular host we use. This points to an entry in the
954
744
 
955
745
  unsigned int scope;    /* address scope for IPv6 */
956
746
 
957
 
  char protostr[16];  /* store the protocol string in this buffer */
958
747
  int socktype;  /* SOCK_STREAM or SOCK_DGRAM */
959
748
 
960
749
  struct hostname host;
971
760
  char *proxypasswd;  /* proxy password string, allocated */
972
761
  curl_proxytype proxytype; /* what kind of proxy that is in use */
973
762
 
974
 
  int httpversion;              /* the HTTP version*10 reported by the server */
 
763
  int httpversion;        /* the HTTP version*10 reported by the server */
 
764
  int rtspversion;        /* the RTSP version*10 reported by the server */
975
765
 
976
766
  struct timeval now;     /* "current" time */
977
767
  struct timeval created; /* creation time */
978
768
  curl_socket_t sock[2]; /* two sockets, the second is used for the data
979
769
                            transfer when doing FTP */
980
770
 
 
771
  Curl_recv *recv[2];
 
772
  Curl_send *send[2];
 
773
 
981
774
  struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
982
775
  struct ssl_config_data ssl_config;
983
776
 
1003
796
    char *ref; /* free later if not NULL! */
1004
797
    char *host; /* free later if not NULL */
1005
798
    char *cookiehost; /* free later if not NULL */
 
799
    char *rtsp_transport; /* free later if not NULL */
1006
800
  } allocptr;
1007
801
 
1008
802
  int sec_complete; /* if kerberos is enabled for this connection */
1035
829
  struct curl_llist *pend_pipe; /* List of pending handles on
1036
830
                                   this pipeline */
1037
831
  struct curl_llist *done_pipe; /* Handles that are finished, but
1038
 
                                   still reference this connectdata */
 
832
                                   still reference this connectdata */
1039
833
#define MAX_PIPELINE_LENGTH 5
1040
834
 
1041
835
  char* master_buffer; /* The master buffer allocated on-demand;
1060
854
 
1061
855
  char syserr_buf [256]; /* buffer for Curl_strerror() */
1062
856
 
1063
 
#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \
1064
 
    defined(USE_THREADING_GETADDRINFO)
 
857
#ifdef CURLRES_ASYNCH
1065
858
  /* data used for the asynch name resolve callback */
1066
859
  struct Curl_async async;
1067
860
#endif
1075
868
    struct ftp_conn ftpc;
1076
869
    struct ssh_conn sshc;
1077
870
    struct tftp_state_data *tftpc;
 
871
    struct imap_conn imapc;
 
872
    struct pop3_conn pop3c;
 
873
    struct smtp_conn smtpc;
 
874
    struct rtsp_conn rtspc;
 
875
    void *generic;
1078
876
  } proto;
1079
877
 
1080
878
  int cselect_bits; /* bitmask of socket events */
1083
881
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1084
882
  int socks5_gssapi_enctype;
1085
883
#endif
 
884
 
 
885
  long verifypeer;
 
886
  long verifyhost;
1086
887
};
1087
888
 
1088
889
/* The end of connectdata. */
1091
892
 * Struct to keep statistical and informational data.
1092
893
 */
1093
894
struct PureInfo {
1094
 
  int httpcode;  /* Recent HTTP or FTP response code */
 
895
  int httpcode;  /* Recent HTTP, FTP, or RTSP response code */
1095
896
  int httpproxycode; /* response code from proxy when received separate */
1096
897
  int httpversion; /* the http version number X.Y = X*10+Y */
1097
898
  long filetime; /* If requested, this is might get set. Set to -1 if the time
1110
911
  char ip[MAX_IPADR_LEN]; /* this buffer gets the numerical ip version stored
1111
912
                             at the connect *attempt* so it will get the last
1112
913
                             tried connect IP even on failures */
 
914
  long port; /* the remote port the last connection was established to */
 
915
  char localip[MAX_IPADR_LEN]; /* this buffer gets the numerical (local) ip
 
916
                                  stored from where the last connection was
 
917
                                  established */
 
918
  long localport; /* the local (src) port the last connection
 
919
                     originated from */
1113
920
  struct curl_certinfo certs; /* info about the certs, only populated in
1114
921
                                 OpenSSL builds. Asked for with
1115
922
                                 CURLOPT_CERTINFO / CURLINFO_CERTINFO */
1162
969
  HTTPREQ_LAST /* last in list */
1163
970
} Curl_HttpReq;
1164
971
 
 
972
typedef enum {
 
973
    RTSPREQ_NONE, /* first in list */
 
974
    RTSPREQ_OPTIONS,
 
975
    RTSPREQ_DESCRIBE,
 
976
    RTSPREQ_ANNOUNCE,
 
977
    RTSPREQ_SETUP,
 
978
    RTSPREQ_PLAY,
 
979
    RTSPREQ_PAUSE,
 
980
    RTSPREQ_TEARDOWN,
 
981
    RTSPREQ_GET_PARAMETER,
 
982
    RTSPREQ_SET_PARAMETER,
 
983
    RTSPREQ_RECORD,
 
984
    RTSPREQ_RECEIVE,
 
985
    RTSPREQ_LAST /* last in list */
 
986
} Curl_RtspReq;
 
987
 
1165
988
/*
1166
989
 * Values that are generated, temporary or calculated internally for a
1167
990
 * "session handle" must be defined within the 'struct UrlState'.  This struct
1312
1135
                  this syntax. */
1313
1136
  curl_off_t resume_from; /* continue [ftp] transfer from here */
1314
1137
 
 
1138
  /* This RTSP state information survives requests and connections */
 
1139
  long rtsp_next_client_CSeq; /* the session's next client CSeq */
 
1140
  long rtsp_next_server_CSeq; /* the session's next server CSeq */
 
1141
  long rtsp_CSeq_recv; /* most recent CSeq received */
 
1142
 
1315
1143
  /* Protocol specific data.
1316
1144
   *
1317
1145
   *************************************************************************
1322
1150
  union {
1323
1151
    struct HTTP *http;
1324
1152
    struct HTTP *https;  /* alias, just for the sake of being more readable */
 
1153
    struct RTSP *rtsp;
1325
1154
    struct FTP *ftp;
1326
1155
    /* void *tftp;    not used */
1327
1156
    struct FILEPROTO *file;
1328
1157
    void *telnet;        /* private for telnet.c-eyes only */
1329
1158
    void *generic;
1330
1159
    struct SSHPROTO *ssh;
 
1160
    struct FTP *imap;
 
1161
    struct FTP *pop3;
 
1162
    struct FTP *smtp;
1331
1163
  } proto;
1332
1164
  /* current user of this SessionHandle instance, or NULL */
1333
1165
  struct connectdata *current_conn;
 
1166
 
 
1167
  /* if true, force SSL connection retry (workaround for certain servers) */
 
1168
  bool ssl_connect_retry;
1334
1169
};
1335
1170
 
1336
1171
 
1366
1201
  STRING_CERT_TYPE,       /* format for certificate (default: PEM)*/
1367
1202
  STRING_COOKIE,          /* HTTP cookie string to send */
1368
1203
  STRING_COOKIEJAR,       /* dump all cookies to this file */
1369
 
  STRING_CUSTOMREQUEST,   /* HTTP/FTP request/method to use */
 
1204
  STRING_CUSTOMREQUEST,   /* HTTP/FTP/RTSP request/method to use */
1370
1205
  STRING_DEVICE,          /* local network interface/address to use */
1371
1206
  STRING_ENCODING,        /* Accept-Encoding string */
1372
1207
  STRING_FTP_ACCOUNT,     /* ftp account data */
1397
1232
  STRING_PROXYPASSWORD,   /* Proxy <password>, if used */
1398
1233
  STRING_NOPROXY,         /* List of hosts which should not use the proxy, if
1399
1234
                             used */
 
1235
  STRING_RTSP_SESSION_ID, /* Session ID to use */
 
1236
  STRING_RTSP_STREAM_URI, /* Stream URI for this request */
 
1237
  STRING_RTSP_TRANSPORT,  /* Transport for this session */
1400
1238
#ifdef USE_LIBSSH2
1401
1239
  STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
1402
1240
  STRING_SSH_PUBLIC_KEY,  /* path to the public key file for auth */
1406
1244
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1407
1245
  STRING_SOCKS5_GSSAPI_SERVICE,  /* GSSAPI service name */
1408
1246
#endif
 
1247
  STRING_MAIL_FROM,
1409
1248
 
1410
1249
  /* -- end of strings -- */
1411
1250
  STRING_LAST /* not used, just an end-of-list marker */
1421
1260
  void *out;         /* the fetched file goes here */
1422
1261
  void *in;          /* the uploaded file is read from here */
1423
1262
  void *writeheader; /* write the header to this if non-NULL */
 
1263
  void *rtp_out;     /* write RTP to this if non-NULL */
1424
1264
  long use_port;     /* which port to use (when not using default) */
1425
1265
  long httpauth;     /* what kind of HTTP authentication to use (bitmask) */
1426
1266
  long proxyauth;    /* what kind of proxy authentication to use (bitmask) */
1442
1282
                         'localport' one can't be bind()ed */
1443
1283
  curl_write_callback fwrite_func;   /* function that stores the output */
1444
1284
  curl_write_callback fwrite_header; /* function that stores headers */
 
1285
  curl_write_callback fwrite_rtp;    /* function that stores interleaved RTP */
1445
1286
  curl_read_callback fread_func;     /* function that reads the input */
 
1287
  int is_fread_set; /* boolean, has read callback been set to non-NULL? */
 
1288
  int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */
1446
1289
  curl_progress_callback fprogress;  /* function for progress information */
1447
1290
  curl_debug_callback fdebug;      /* function that write informational data */
1448
1291
  curl_ioctl_callback ioctl_func;  /* function for I/O control */
1465
1308
  void *ioctl_client;   /* pointer to pass to the ioctl callback */
1466
1309
  long timeout;         /* in milliseconds, 0 means no timeout */
1467
1310
  long connecttimeout;  /* in milliseconds, 0 means no timeout */
1468
 
  long ftp_response_timeout; /* in milliseconds, 0 means no timeout */
 
1311
  long server_response_timeout; /* in milliseconds, 0 means no timeout */
1469
1312
  long tftp_blksize ; /* in bytes, 0 means use default */
1470
1313
  curl_off_t infilesize;      /* size of file to upload, -1 means unknown */
1471
1314
  long low_speed_limit; /* bytes/second */
1548
1391
  bool reuse_fresh;      /* do not re-use an existing connection  */
1549
1392
  bool ftp_use_epsv;     /* if EPSV is to be attempted or not */
1550
1393
  bool ftp_use_eprt;     /* if EPRT is to be attempted or not */
 
1394
  bool ftp_use_pret;     /* if PRET is to be used before PASV or not */
1551
1395
 
1552
 
  curl_usessl ftp_ssl;   /* if AUTH TLS is to be attempted etc */
 
1396
  curl_usessl ftp_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or
 
1397
                            IMAP or POP3 or others! */
1553
1398
  curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
1554
1399
  curl_ftpccc ftp_ccc;   /* FTP CCC options */
1555
1400
  bool no_signal;        /* do not use any signal/alarm handler */
1575
1420
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
1576
1421
  long socks5_gssapi_nec; /* flag to support nec socks5 server */
1577
1422
#endif
 
1423
  struct curl_slist *mail_rcpt; /* linked list of mail recipients */
 
1424
  /* Common RTSP header options */
 
1425
  Curl_RtspReq rtspreq; /* RTSP request type */
 
1426
  long rtspversion; /* like httpversion, for RTSP */
 
1427
  bool wildcardmatch; /* enable wildcard matching */
 
1428
  curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer starts */
 
1429
  curl_chunk_end_callback chunk_end; /* called after part transferring
 
1430
                                        stopped */
 
1431
  curl_fnmatch_callback fnmatch; /* callback to decide which file corresponds
 
1432
                                    to pattern (e.g. if WILDCARDMATCH is on) */
 
1433
  void *fnmatch_data;
1578
1434
};
1579
1435
 
1580
1436
struct Names {
1616
1472
  struct Progress progress;    /* for all the progress meter data */
1617
1473
  struct UrlState state;       /* struct for fields used for state info and
1618
1474
                                  other dynamic purposes */
 
1475
  struct WildcardData wildcard; /* wildcard download state info */
1619
1476
  struct PureInfo info;        /* stats, reports and info data */
1620
1477
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
1621
1478
  iconv_t outbound_cd;         /* for translating to the network encoding */