iPXE
ftp.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 #include <stdint.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <assert.h>
25 #include <errno.h>
26 #include <ctype.h>
27 #include <byteswap.h>
28 #include <ipxe/socket.h>
29 #include <ipxe/tcpip.h>
30 #include <ipxe/in.h>
31 #include <ipxe/iobuf.h>
32 #include <ipxe/xfer.h>
33 #include <ipxe/open.h>
34 #include <ipxe/uri.h>
35 #include <ipxe/features.h>
36 #include <ipxe/ftp.h>
37 
38 /** @file
39  *
40  * File transfer protocol
41  *
42  */
43 
45 
46 /**
47  * FTP states
48  *
49  * These @b must be sequential, i.e. a successful FTP session must
50  * pass through each of these states in order.
51  */
52 enum ftp_state {
63 };
64 
65 /**
66  * An FTP request
67  *
68  */
69 struct ftp_request {
70  /** Reference counter */
71  struct refcnt refcnt;
72  /** Data transfer interface */
73  struct interface xfer;
74 
75  /** URI being fetched */
76  struct uri *uri;
77  /** FTP control channel interface */
79  /** FTP data channel interface */
80  struct interface data;
81 
82  /** Current state */
84  /** Buffer to be filled with data received via the control channel */
85  char *recvbuf;
86  /** Remaining size of recvbuf */
87  size_t recvsize;
88  /** FTP status code, as text */
89  char status_text[5];
90  /** Passive-mode parameters, as text */
91  char passive_text[24]; /* "aaa,bbb,ccc,ddd,eee,fff" */
92  /** File size, as text */
93  char filesize[20];
94 };
95 
96 /**
97  * Free FTP request
98  *
99  * @v refcnt Reference counter
100  */
101 static void ftp_free ( struct refcnt *refcnt ) {
102  struct ftp_request *ftp =
103  container_of ( refcnt, struct ftp_request, refcnt );
104 
105  DBGC ( ftp, "FTP %p freed\n", ftp );
106 
107  uri_put ( ftp->uri );
108  free ( ftp );
109 }
110 
111 /**
112  * Mark FTP operation as complete
113  *
114  * @v ftp FTP request
115  * @v rc Return status code
116  */
117 static void ftp_done ( struct ftp_request *ftp, int rc ) {
118 
119  DBGC ( ftp, "FTP %p completed (%s)\n", ftp, strerror ( rc ) );
120 
121  /* Close all data transfer interfaces */
122  intf_shutdown ( &ftp->data, rc );
123  intf_shutdown ( &ftp->control, rc );
124  intf_shutdown ( &ftp->xfer, rc );
125 }
126 
127 /*****************************************************************************
128  *
129  * FTP control channel
130  *
131  */
132 
133 /** An FTP control channel string */
135  /** Literal portion */
136  const char *literal;
137  /** Variable portion
138  *
139  * @v ftp FTP request
140  * @ret string Variable portion of string
141  */
142  const char * ( *variable ) ( struct ftp_request *ftp );
143 };
144 
145 /**
146  * Retrieve FTP pathname
147  *
148  * @v ftp FTP request
149  * @ret path FTP pathname
150  */
151 static const char * ftp_uri_path ( struct ftp_request *ftp ) {
152  return ftp->uri->path;
153 }
154 
155 /**
156  * Retrieve FTP user
157  *
158  * @v ftp FTP request
159  * @ret user FTP user
160  */
161 static const char * ftp_user ( struct ftp_request *ftp ) {
162  static char *ftp_default_user = "anonymous";
163  return ftp->uri->user ? ftp->uri->user : ftp_default_user;
164 }
165 
166 /**
167  * Retrieve FTP password
168  *
169  * @v ftp FTP request
170  * @ret password FTP password
171  */
172 static const char * ftp_password ( struct ftp_request *ftp ) {
173  static char *ftp_default_password = "ipxe@ipxe.org";
174  return ftp->uri->password ? ftp->uri->password : ftp_default_password;
175 }
176 
177 /** FTP control channel strings */
178 static struct ftp_control_string ftp_strings[] = {
179  [FTP_CONNECT] = { NULL, NULL },
180  [FTP_USER] = { "USER ", ftp_user },
181  [FTP_PASS] = { "PASS ", ftp_password },
182  [FTP_TYPE] = { "TYPE I", NULL },
183  [FTP_SIZE] = { "SIZE ", ftp_uri_path },
184  [FTP_PASV] = { "PASV", NULL },
185  [FTP_RETR] = { "RETR ", ftp_uri_path },
186  [FTP_WAIT] = { NULL, NULL },
187  [FTP_QUIT] = { "QUIT", NULL },
188  [FTP_DONE] = { NULL, NULL },
189 };
190 
191 /**
192  * Parse FTP byte sequence value
193  *
194  * @v text Text string
195  * @v value Value buffer
196  * @v len Length of value buffer
197  *
198  * This parses an FTP byte sequence value (e.g. the "aaa,bbb,ccc,ddd"
199  * form for IP addresses in PORT commands) into a byte sequence. @c
200  * *text will be updated to point beyond the end of the parsed byte
201  * sequence.
202  *
203  * This function is safe in the presence of malformed data, though the
204  * output is undefined.
205  */
206 static void ftp_parse_value ( char **text, uint8_t *value, size_t len ) {
207  do {
208  *(value++) = strtoul ( *text, text, 10 );
209  if ( **text )
210  (*text)++;
211  } while ( --len );
212 }
213 
214 /**
215  * Move to next state and send the appropriate FTP control string
216  *
217  * @v ftp FTP request
218  *
219  */
220 static void ftp_next_state ( struct ftp_request *ftp ) {
221  struct ftp_control_string *ftp_string;
222  const char *literal;
223  const char *variable;
224 
225  /* Move to next state */
226  if ( ftp->state < FTP_DONE )
227  ftp->state++;
228 
229  /* Send control string if needed */
230  ftp_string = &ftp_strings[ftp->state];
231  literal = ftp_string->literal;
232  variable = ( ftp_string->variable ?
233  ftp_string->variable ( ftp ) : "" );
234  if ( literal ) {
235  DBGC ( ftp, "FTP %p sending %s%s\n", ftp, literal, variable );
236  xfer_printf ( &ftp->control, "%s%s\r\n", literal, variable );
237  }
238 }
239 
240 /**
241  * Handle an FTP control channel response
242  *
243  * @v ftp FTP request
244  *
245  * This is called once we have received a complete response line.
246  */
247 static void ftp_reply ( struct ftp_request *ftp ) {
248  char status_major = ftp->status_text[0];
249  char separator = ftp->status_text[3];
250 
251  DBGC ( ftp, "FTP %p received status %s\n", ftp, ftp->status_text );
252 
253  /* Ignore malformed lines */
254  if ( separator != ' ' )
255  return;
256 
257  /* Ignore "intermediate" responses (1xx codes) */
258  if ( status_major == '1' )
259  return;
260 
261  /* If the SIZE command is not supported by the server, we go to
262  * the next step.
263  */
264  if ( ( status_major == '5' ) && ( ftp->state == FTP_SIZE ) ) {
265  ftp_next_state ( ftp );
266  return;
267  }
268 
269  /* Anything other than success (2xx) or, in the case of a
270  * repsonse to a "USER" command, a password prompt (3xx), is a
271  * fatal error.
272  */
273  if ( ! ( ( status_major == '2' ) ||
274  ( ( status_major == '3' ) && ( ftp->state == FTP_USER ) ) ) ){
275  /* Flag protocol error and close connections */
276  ftp_done ( ftp, -EPROTO );
277  return;
278  }
279 
280  /* Parse file size */
281  if ( ftp->state == FTP_SIZE ) {
282  size_t filesize;
283  char *endptr;
284 
285  /* Parse size */
286  filesize = strtoul ( ftp->filesize, &endptr, 10 );
287  if ( *endptr != '\0' ) {
288  DBGC ( ftp, "FTP %p invalid SIZE \"%s\"\n",
289  ftp, ftp->filesize );
290  ftp_done ( ftp, -EPROTO );
291  return;
292  }
293 
294  /* Use seek() to notify recipient of filesize */
295  DBGC ( ftp, "FTP %p file size is %zd bytes\n", ftp, filesize );
296  xfer_seek ( &ftp->xfer, filesize );
297  xfer_seek ( &ftp->xfer, 0 );
298  }
299 
300  /* Open passive connection when we get "PASV" response */
301  if ( ftp->state == FTP_PASV ) {
302  char *ptr = ftp->passive_text;
303  union {
304  struct sockaddr_in sin;
305  struct sockaddr sa;
306  } sa;
307  int rc;
308 
309  sa.sin.sin_family = AF_INET;
310  ftp_parse_value ( &ptr, ( uint8_t * ) &sa.sin.sin_addr,
311  sizeof ( sa.sin.sin_addr ) );
312  ftp_parse_value ( &ptr, ( uint8_t * ) &sa.sin.sin_port,
313  sizeof ( sa.sin.sin_port ) );
314  if ( ( rc = xfer_open_socket ( &ftp->data, SOCK_STREAM,
315  &sa.sa, NULL ) ) != 0 ) {
316  DBGC ( ftp, "FTP %p could not open data connection\n",
317  ftp );
318  ftp_done ( ftp, rc );
319  return;
320  }
321  }
322 
323  /* Move to next state and send control string */
324  ftp_next_state ( ftp );
325 
326 }
327 
328 /**
329  * Handle new data arriving on FTP control channel
330  *
331  * @v ftp FTP request
332  * @v iob I/O buffer
333  * @v meta Data transfer metadata
334  * @ret rc Return status code
335  *
336  * Data is collected until a complete line is received, at which point
337  * its information is passed to ftp_reply().
338  */
339 static int ftp_control_deliver ( struct ftp_request *ftp,
340  struct io_buffer *iobuf,
341  struct xfer_metadata *meta __unused ) {
342  char *data = iobuf->data;
343  size_t len = iob_len ( iobuf );
344  char *recvbuf = ftp->recvbuf;
345  size_t recvsize = ftp->recvsize;
346  char c;
347 
348  while ( len-- ) {
349  c = *(data++);
350  if ( ( c == '\r' ) || ( c == '\n' ) ) {
351  /* End of line: call ftp_reply() to handle
352  * completed reply. Avoid calling ftp_reply()
353  * twice if we receive both \r and \n.
354  */
355  if ( recvbuf != ftp->status_text )
356  ftp_reply ( ftp );
357  /* Start filling up the status code buffer */
358  recvbuf = ftp->status_text;
359  recvsize = sizeof ( ftp->status_text ) - 1;
360  } else if ( ( ftp->state == FTP_PASV ) && ( c == '(' ) ) {
361  /* Start filling up the passive parameter buffer */
362  recvbuf = ftp->passive_text;
363  recvsize = sizeof ( ftp->passive_text ) - 1;
364  } else if ( ( ftp->state == FTP_PASV ) && ( c == ')' ) ) {
365  /* Stop filling the passive parameter buffer */
366  recvsize = 0;
367  } else if ( ( ftp->state == FTP_SIZE ) && ( c == ' ' ) ) {
368  /* Start filling up the file size buffer */
369  recvbuf = ftp->filesize;
370  recvsize = sizeof ( ftp->filesize ) - 1;
371  } else {
372  /* Fill up buffer if applicable */
373  if ( recvsize > 0 ) {
374  *(recvbuf++) = c;
375  recvsize--;
376  }
377  }
378  }
379 
380  /* Store for next invocation */
381  ftp->recvbuf = recvbuf;
382  ftp->recvsize = recvsize;
383 
384  /* Free I/O buffer */
385  free_iob ( iobuf );
386 
387  return 0;
388 }
389 
390 /** FTP control channel interface operations */
393  INTF_OP ( intf_close, struct ftp_request *, ftp_done ),
394 };
395 
396 /** FTP control channel interface descriptor */
399 
400 /*****************************************************************************
401  *
402  * FTP data channel
403  *
404  */
405 
406 /**
407  * Handle FTP data channel being closed
408  *
409  * @v ftp FTP request
410  * @v rc Reason for closure
411  *
412  * When the data channel is closed, the control channel should be left
413  * alone; the server will send a completion message via the control
414  * channel which we'll pick up.
415  *
416  * If the data channel is closed due to an error, we abort the request.
417  */
418 static void ftp_data_closed ( struct ftp_request *ftp, int rc ) {
419 
420  DBGC ( ftp, "FTP %p data connection closed: %s\n",
421  ftp, strerror ( rc ) );
422 
423  /* If there was an error, close control channel and record status */
424  if ( rc ) {
425  ftp_done ( ftp, rc );
426  } else {
427  ftp_next_state ( ftp );
428  }
429 }
430 
431 /** FTP data channel interface operations */
434 };
435 
436 /** FTP data channel interface descriptor */
439  xfer );
440 
441 /*****************************************************************************
442  *
443  * Data transfer interface
444  *
445  */
446 
447 /** FTP data transfer interface operations */
449  INTF_OP ( intf_close, struct ftp_request *, ftp_done ),
450 };
451 
452 /** FTP data transfer interface descriptor */
455  data );
456 
457 /*****************************************************************************
458  *
459  * URI opener
460  *
461  */
462 
463 /**
464  * Check validity of FTP control channel string
465  *
466  * @v string String
467  * @ret rc Return status code
468  */
469 static int ftp_check_string ( const char *string ) {
470  char c;
471 
472  /* The FTP control channel is line-based. Check for invalid
473  * non-printable characters (e.g. newlines).
474  */
475  while ( ( c = *(string++) ) ) {
476  if ( ! isprint ( c ) )
477  return -EINVAL;
478  }
479  return 0;
480 }
481 
482 /**
483  * Initiate an FTP connection
484  *
485  * @v xfer Data transfer interface
486  * @v uri Uniform Resource Identifier
487  * @ret rc Return status code
488  */
489 static int ftp_open ( struct interface *xfer, struct uri *uri ) {
490  struct ftp_request *ftp;
491  struct sockaddr_tcpip server;
492  int rc;
493 
494  /* Sanity checks */
495  if ( ! uri->host )
496  return -EINVAL;
497  if ( ! uri->path )
498  return -EINVAL;
499  if ( ( rc = ftp_check_string ( uri->path ) ) != 0 )
500  return rc;
501  if ( uri->user && ( ( rc = ftp_check_string ( uri->user ) ) != 0 ) )
502  return rc;
503  if ( uri->password &&
504  ( ( rc = ftp_check_string ( uri->password ) ) != 0 ) )
505  return rc;
506 
507  /* Allocate and populate structure */
508  ftp = zalloc ( sizeof ( *ftp ) );
509  if ( ! ftp )
510  return -ENOMEM;
511  ref_init ( &ftp->refcnt, ftp_free );
512  intf_init ( &ftp->xfer, &ftp_xfer_desc, &ftp->refcnt );
513  intf_init ( &ftp->control, &ftp_control_desc, &ftp->refcnt );
514  intf_init ( &ftp->data, &ftp_data_desc, &ftp->refcnt );
515  ftp->uri = uri_get ( uri );
516  ftp->recvbuf = ftp->status_text;
517  ftp->recvsize = sizeof ( ftp->status_text ) - 1;
518 
519  DBGC ( ftp, "FTP %p fetching %s\n", ftp, ftp->uri->path );
520 
521  /* Open control connection */
522  memset ( &server, 0, sizeof ( server ) );
523  server.st_port = htons ( uri_port ( uri, FTP_PORT ) );
524  if ( ( rc = xfer_open_named_socket ( &ftp->control, SOCK_STREAM,
525  ( struct sockaddr * ) &server,
526  uri->host, NULL ) ) != 0 )
527  goto err;
528 
529  /* Attach to parent interface, mortalise self, and return */
530  intf_plug_plug ( &ftp->xfer, xfer );
531  ref_put ( &ftp->refcnt );
532  return 0;
533 
534  err:
535  DBGC ( ftp, "FTP %p could not create request: %s\n",
536  ftp, strerror ( rc ) );
537  ftp_done ( ftp, rc );
538  ref_put ( &ftp->refcnt );
539  return rc;
540 }
541 
542 /** FTP URI opener */
543 struct uri_opener ftp_uri_opener __uri_opener = {
544  .scheme = "ftp",
545  .open = ftp_open,
546 };
static void ftp_done(struct ftp_request *ftp, int rc)
Mark FTP operation as complete.
Definition: ftp.c:117
uint32_t c
Definition: md4.c:30
#define EINVAL
Invalid argument.
Definition: errno.h:428
An object interface operation.
Definition: interface.h:17
TCP/IP socket address.
Definition: tcpip.h:75
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
Data transfer metadata.
Definition: xfer.h:22
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
Definition: ftp.c:57
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:471
static const char * ftp_user(struct ftp_request *ftp)
Retrieve FTP user.
Definition: ftp.c:161
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:194
#define FEATURE_PROTOCOL
Network protocols.
Definition: features.h:21
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
Error codes.
int xfer_open_socket(struct interface *intf, int semantics, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.c:142
I/O buffers.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
struct uri * uri
URI being fetched.
Definition: ftp.c:76
struct uri_opener ftp_uri_opener __uri_opener
FTP URI opener.
Definition: ftp.c:543
Definition: ftp.c:56
const char *(* variable)(struct ftp_request *ftp)
Variable portion.
Definition: ftp.c:142
#define DBGC(...)
Definition: compiler.h:505
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
An FTP control channel string.
Definition: ftp.c:134
char * recvbuf
Buffer to be filled with data received via the control channel.
Definition: ftp.c:85
static int ftp_check_string(const char *string)
Check validity of FTP control channel string.
Definition: ftp.c:469
IPv4 socket address.
Definition: in.h:82
Character types.
static void ftp_parse_value(char **text, uint8_t *value, size_t len)
Parse FTP byte sequence value.
Definition: ftp.c:206
Uniform Resource Identifiers.
static struct interface_operation ftp_data_operations[]
FTP data channel interface operations.
Definition: ftp.c:432
char status_text[5]
FTP status code, as text.
Definition: ftp.c:89
static struct interface_operation ftp_control_operations[]
FTP control channel interface operations.
Definition: ftp.c:391
static int isprint(int character)
Check if character is printable.
Definition: ctype.h:97
Data transfer interfaces.
A reference counter.
Definition: refcnt.h:26
Definition: ftp.c:62
#define ENOMEM
Not enough space.
Definition: errno.h:534
static struct interface_descriptor ftp_control_desc
FTP control channel interface descriptor.
Definition: ftp.c:397
size_t recvsize
Remaining size of recvbuf.
Definition: ftp.c:87
Assertions.
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
An object interface.
Definition: interface.h:124
static void ftp_free(struct refcnt *refcnt)
Free FTP request.
Definition: ftp.c:101
static void ftp_data_closed(struct ftp_request *ftp, int rc)
Handle FTP data channel being closed.
Definition: ftp.c:418
const char * path
Path (after URI decoding)
Definition: uri.h:80
File transfer protocol.
const char * scheme
URI protocol name.
Definition: open.h:53
struct sockaddr sa
Definition: syslog.c:55
Transport-network layer interface.
Feature list.
An FTP request.
Definition: ftp.c:69
#define EPROTO
Protocol error.
Definition: errno.h:624
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
Definition: xfer.c:351
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
int meta(WINDOW *, bool)
uint16_t st_port
TCP/IP port.
Definition: tcpip.h:81
Generalized socket address structure.
Definition: socket.h:96
An object interface descriptor.
Definition: interface.h:55
Definition: ftp.c:59
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.
Definition: ftp.c:339
static struct interface_descriptor ftp_data_desc
FTP data channel interface descriptor.
Definition: ftp.c:437
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static const char * ftp_uri_path(struct ftp_request *ftp)
Retrieve FTP pathname.
Definition: ftp.c:151
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
char filesize[20]
File size, as text.
Definition: ftp.c:93
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
uint32_t control
Control.
Definition: myson.h:14
Definition: ftp.c:58
Definition: ftp.c:60
#define SOCK_STREAM
Definition: socket.h:24
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:194
unsigned char uint8_t
Definition: stdint.h:10
Data transfer interface opening.
static struct interface_operation ftp_xfer_operations[]
FTP data transfer interface operations.
Definition: ftp.c:448
const char * host
Host name.
Definition: uri.h:76
int xfer_printf(struct interface *intf, const char *format,...)
Deliver formatted string.
Definition: xfer.c:334
static int ftp_open(struct interface *xfer, struct uri *uri)
Initiate an FTP connection.
Definition: ftp.c:489
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
Definition: ftp.c:61
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
static void ftp_reply(struct ftp_request *ftp)
Handle an FTP control channel response.
Definition: ftp.c:247
uint32_t len
Length.
Definition: ena.h:14
static void ftp_next_state(struct ftp_request *ftp)
Move to next state and send the appropriate FTP control string.
Definition: ftp.c:220
static const char * ftp_password(struct ftp_request *ftp)
Retrieve FTP password.
Definition: ftp.c:172
void * data
Start of data.
Definition: iobuf.h:48
Definition: ftp.c:55
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
Definition: uri.c:455
enum ftp_state state
Current state.
Definition: ftp.c:83
uint8_t data[48]
Additional event data.
Definition: ena.h:22
const char * password
Password.
Definition: uri.h:74
Definition: ftp.c:54
ftp_state
FTP states.
Definition: ftp.c:52
struct interface xfer
Data transfer interface.
Definition: ftp.c:73
const char * user
User name.
Definition: uri.h:72
A Uniform Resource Identifier.
Definition: uri.h:64
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
Definition: interface.h:97
struct sockaddr_in sin
Definition: syslog.c:57
static struct interface_descriptor ftp_xfer_desc
FTP data transfer interface descriptor.
Definition: ftp.c:453
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
Socket addresses.
A URI opener.
Definition: open.h:47
const char * literal
Literal portion.
Definition: ftp.c:136
struct interface data
FTP data channel interface.
Definition: ftp.c:80
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
static struct ftp_control_string ftp_strings[]
FTP control channel strings.
Definition: ftp.c:178
struct interface control
FTP control channel interface.
Definition: ftp.c:78
#define DHCP_EB_FEATURE_FTP
FTP protocol.
Definition: features.h:42
#define htons(value)
Definition: byteswap.h:135
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
Definition: resolv.c:402
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
char passive_text[24]
Passive-mode parameters, as text.
Definition: ftp.c:91
FEATURE(FEATURE_PROTOCOL, "FTP", DHCP_EB_FEATURE_FTP, 1)
void * memset(void *dest, int character, size_t len) __nonnull
struct refcnt refcnt
Reference counter.
Definition: ftp.c:71
A persistent I/O buffer.
Definition: iobuf.h:33
#define FTP_PORT
FTP default port.
Definition: ftp.h:13