105 DBGC ( ftp,
"FTP %p freed\n", ftp );
162 static char *ftp_default_user =
"anonymous";
173 static char *ftp_default_password =
"ipxe@ipxe.org";
233 ftp_string->
variable ( ftp ) :
"" );
254 if ( separator !=
' ' )
258 if ( status_major ==
'1' )
264 if ( ( status_major ==
'5' ) && ( ftp->
state ==
FTP_SIZE ) ) {
273 if ( ! ( ( status_major ==
'2' ) ||
274 ( ( status_major ==
'3' ) && ( ftp->
state ==
FTP_USER ) ) ) ){
287 if ( *endptr !=
'\0' ) {
288 DBGC ( ftp,
"FTP %p invalid SIZE \"%s\"\n",
295 DBGC ( ftp,
"FTP %p file size is %zd bytes\n", ftp, filesize );
311 sizeof (
sa.sin.sin_addr ) );
313 sizeof (
sa.sin.sin_port ) );
316 DBGC ( ftp,
"FTP %p could not open data connection\n",
350 if ( (
c ==
'\r' ) || (
c ==
'\n' ) ) {
370 recvsize =
sizeof ( ftp->
filesize ) - 1;
373 if ( recvsize > 0 ) {
420 DBGC ( ftp,
"FTP %p data connection closed: %s\n",
475 while ( (
c = *(
string++) ) ) {
508 ftp =
zalloc (
sizeof ( *ftp ) );
519 DBGC ( ftp,
"FTP %p fetching %s\n", ftp, ftp->
uri->
path );
522 memset ( &server, 0,
sizeof ( server ) );
535 DBGC ( ftp,
"FTP %p could not create request: %s\n",
static void ftp_done(struct ftp_request *ftp, int rc)
Mark FTP operation as complete.
#define EINVAL
Invalid argument.
An object interface operation.
struct arbelprm_rc_send_wqe rc
void intf_close(struct interface *intf, int rc)
Close an object interface.
static __always_inline void off_t int c
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
static void uri_put(struct uri *uri)
Decrement URI reference count.
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
static const char * ftp_user(struct ftp_request *ftp)
Retrieve FTP user.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
#define FEATURE_PROTOCOL
Network protocols.
#define ref_init(refcnt, free)
Initialise a reference counter.
int xfer_open_socket(struct interface *intf, int semantics, struct sockaddr *peer, struct sockaddr *local)
Open socket.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct uri * uri
URI being fetched.
struct uri_opener ftp_uri_opener __uri_opener
FTP URI opener.
const char *(* variable)(struct ftp_request *ftp)
Variable portion.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
An FTP control channel string.
char * recvbuf
Buffer to be filled with data received via the control channel.
static int ftp_check_string(const char *string)
Check validity of FTP control channel string.
static void ftp_parse_value(char **text, uint8_t *value, size_t len)
Parse FTP byte sequence value.
Uniform Resource Identifiers.
static struct interface_operation ftp_data_operations[]
FTP data channel interface operations.
char status_text[5]
FTP status code, as text.
static struct interface_operation ftp_control_operations[]
FTP control channel interface operations.
static int isprint(int character)
Check if character is printable.
Data transfer interfaces.
#define ENOMEM
Not enough space.
static struct interface_descriptor ftp_control_desc
FTP control channel interface descriptor.
size_t recvsize
Remaining size of recvbuf.
#define container_of(ptr, type, field)
Get containing structure.
static void ftp_free(struct refcnt *refcnt)
Free FTP request.
pseudo_bit_t value[0x00020]
#define __unused
Declare a variable or data structure as unused.
static void ftp_data_closed(struct ftp_request *ftp, int rc)
Handle FTP data channel being closed.
const char * path
Path (after URI decoding)
const char * scheme
URI protocol name.
Transport-network layer interface.
#define EPROTO
Protocol error.
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
uint16_t st_port
TCP/IP port.
Generalized socket address structure.
An object interface descriptor.
static int ftp_control_deliver(struct ftp_request *ftp, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Handle new data arriving on FTP control channel.
static struct interface_descriptor ftp_data_desc
FTP data channel interface descriptor.
char * strerror(int errno)
Retrieve string representation of error number.
static void(* free)(struct refcnt *refcnt))
static const char * ftp_uri_path(struct ftp_request *ftp)
Retrieve FTP pathname.
void * zalloc(size_t size)
Allocate cleared memory.
char filesize[20]
File size, as text.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Data transfer interface opening.
static struct interface_operation ftp_xfer_operations[]
FTP data transfer interface operations.
const char * host
Host name.
int xfer_printf(struct interface *intf, const char *format,...)
Deliver formatted string.
static int ftp_open(struct interface *xfer, struct uri *uri)
Initiate an FTP connection.
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
static void ftp_reply(struct ftp_request *ftp)
Handle an FTP control channel response.
static void ftp_next_state(struct ftp_request *ftp)
Move to next state and send the appropriate FTP control string.
static const char * ftp_password(struct ftp_request *ftp)
Retrieve FTP password.
void * data
Start of data.
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
enum ftp_state state
Current state.
uint8_t data[48]
Additional event data.
const char * password
Password.
struct interface xfer
Data transfer interface.
const char * user
User name.
A Uniform Resource Identifier.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
static struct interface_descriptor ftp_xfer_desc
FTP data transfer interface descriptor.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
const char * literal
Literal portion.
struct interface data
FTP data channel interface.
#define NULL
NULL pointer (VOID *)
static struct ftp_control_string ftp_strings[]
FTP control channel strings.
struct interface control
FTP control channel interface.
#define DHCP_EB_FEATURE_FTP
FTP protocol.
#define AF_INET
IPv4 Internet addresses.
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
#define ref_put(refcnt)
Drop reference to object.
char passive_text[24]
Passive-mode parameters, as text.
FEATURE(FEATURE_PROTOCOL, "FTP", DHCP_EB_FEATURE_FTP, 1)
void * memset(void *dest, int character, size_t len) __nonnull
struct refcnt refcnt
Reference counter.
#define FTP_PORT
FTP default port.