master
1#ifndef HEADER_CURL_FTP_INT_H
2#define HEADER_CURL_FTP_INT_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
28#include "pingpong.h"
30#ifndef CURL_DISABLE_FTP
32/****************************************************************************
33 * FTP unique setup
34 ***************************************************************************/
35enum {
36 FTP_STOP, /* do nothing state, stops the state machine */
37 FTP_WAIT220, /* waiting for the initial 220 response immediately after
38 a connect */
39 FTP_AUTH,
40 FTP_USER,
41 FTP_PASS,
42 FTP_ACCT,
43 FTP_PBSZ,
44 FTP_PROT,
45 FTP_CCC,
46 FTP_PWD,
47 FTP_SYST,
48 FTP_NAMEFMT,
49 FTP_QUOTE, /* waiting for a response to a command sent in a quote list */
50 FTP_RETR_PREQUOTE,
51 FTP_STOR_PREQUOTE,
52 FTP_LIST_PREQUOTE,
53 FTP_POSTQUOTE,
54 FTP_CWD, /* change directory */
55 FTP_MKD, /* if the directory did not exist */
56 FTP_MDTM, /* to figure out the datestamp */
57 FTP_TYPE, /* to set type when doing a head-like request */
58 FTP_LIST_TYPE, /* set type when about to do a directory list */
59 FTP_RETR_LIST_TYPE,
60 FTP_RETR_TYPE, /* set type when about to RETR a file */
61 FTP_STOR_TYPE, /* set type when about to STOR a file */
62 FTP_SIZE, /* get the remote file's size for head-like request */
63 FTP_RETR_SIZE, /* get the remote file's size for RETR */
64 FTP_STOR_SIZE, /* get the size for STOR */
65 FTP_REST, /* when used to check if the server supports it in head-like */
66 FTP_RETR_REST, /* when asking for "resume" in for RETR */
67 FTP_PORT, /* generic state for PORT, LPRT and EPRT, check count1 */
68 FTP_PRET, /* generic state for PRET RETR, PRET STOR and PRET LIST/NLST */
69 FTP_PASV, /* generic state for PASV and EPSV, check count1 */
70 FTP_LIST, /* generic state for LIST, NLST or a custom list command */
71 FTP_RETR,
72 FTP_STOR, /* generic state for STOR and APPE */
73 FTP_QUIT,
74 FTP_LAST /* never used */
75};
76typedef unsigned char ftpstate; /* use the enum values */
78struct ftp_parselist_data; /* defined later in ftplistparser.c */
80struct ftp_wc {
81 struct ftp_parselist_data *parser;
82};
84/* This FTP struct is used in the Curl_easy. All FTP data that is
85 connection-oriented must be in FTP_conn to properly deal with the fact that
86 perhaps the Curl_easy is changed between the times the connection is
87 used. */
88struct FTP {
89 char *path; /* points to the urlpieces struct field */
90 char *pathalloc; /* if non-NULL a pointer to an allocated path */
92 /* transfer a file/body or not, done as a typedefed enum to make debuggers
93 display the full symbol and not the numerical value */
94 curl_pp_transfer transfer;
95 curl_off_t downloadsize;
96};
98/* one struct entry for each path component (of 'rawpath') */
99struct pathcomp {
100 int start; /* start column */
101 int len; /* length in bytes */
102};
104/* ftp_conn is used for struct connection-oriented data in the connectdata
105 struct */
106struct ftp_conn {
107 struct pingpong pp;
108 char *account;
109 char *alternative_to_user;
110 char *entrypath; /* the PWD reply when we logged on */
111 const char *file; /* URL-decoded filename (or path), points into rawpath */
112 char *rawpath; /* URL decoded, allocated, version of the path */
113 struct pathcomp *dirs; /* allocated array for path components */
114 char *prevpath; /* URL-decoded conn->path from the previous transfer */
115 char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
116 and others (A/I or zero) */
117 char *server_os; /* The target server operating system. */
118 curl_off_t known_filesize; /* file size is different from -1, if wildcard
119 LIST parsing was done and wc_statemach set
120 it */
121 int count1; /* general purpose counter for the state machine */
122 int count2; /* general purpose counter for the state machine */
123 int count3; /* general purpose counter for the state machine */
124 unsigned short dirdepth; /* number of entries used in the 'dirs' array,
125 < FTP_MAX_DIR_DEPTH */
126 unsigned short cwdcount; /* number of CWD commands issued,
127 < FTP_MAX_DIR_DEPTH */
128 unsigned char state; /* (ftpstate enum) always use ftp.c:state() to change
129 state! */
130 unsigned char use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or
131 IMAP or POP3 or others! (type: curl_usessl)*/
132 unsigned char ccc; /* ccc level for this connection */
133 BIT(ftp_trying_alternative);
134 BIT(dont_check); /* Set to TRUE to prevent the final (post-transfer)
135 file size and 226/250 status check. It should still
136 read the line, ignore the result. */
137 BIT(ctl_valid); /* Tells Curl_ftp_quit() whether or not to do anything. If
138 the connection has timed out or been closed, this
139 should be FALSE when it gets to Curl_ftp_quit() */
140 BIT(cwddone); /* if it has been determined that the proper CWD combo
141 already has been done */
142 BIT(cwdfail); /* set TRUE if a CWD command fails, as then we must prevent
143 caching the current directory */
144 BIT(wait_data_conn); /* this is set TRUE if data connection is waited */
145 BIT(shutdown); /* connection is being shutdown, e.g. QUIT */
146};
148/* meta key for storing `struct FTP` as easy meta data */
149#define CURL_META_FTP_EASY "meta:proto:ftp:easy"
150/* meta key for storing `struct ftp_conn` as connection meta data */
151#define CURL_META_FTP_CONN "meta:proto:ftp:conn"
153#endif /* CURL_DISABLE_FTP */
155#endif /* HEADER_CURL_FTP_INT_H */
Diagnostics4 git calls · 36 ms
CallStatusSizeTime036 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=UPDATING git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=30 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.6 KiB · hit31 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2696 git.response.cache=HIT git.response.duration_ms=31 git.fetch.wants=0bf6b9a245778c2f11db478b299b9b22e31aaf1e git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2696 git.pkt.payload.max=2675 git.sideband.band1.bytes=2674 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1cdb3da67c6f8
- Request
- 55375e54…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format