FTP_TYPE,
FTP_PASV,
FTP_RETR,
+ FTP_WAIT,
FTP_QUIT,
FTP_DONE,
};
* snprintf() call.
*/
static const char * ftp_strings[] = {
- [FTP_CONNECT] = "",
+ [FTP_CONNECT] = NULL,
[FTP_USER] = "USER anonymous\r\n",
[FTP_PASS] = "PASS etherboot@etherboot.org\r\n",
[FTP_TYPE] = "TYPE I\r\n",
[FTP_PASV] = "PASV\r\n",
- [FTP_RETR] = "RETR %s\r\n",
+ [FTP_RETR] = "RETR %s\r\n",
+ [FTP_WAIT] = NULL,
[FTP_QUIT] = "QUIT\r\n",
- [FTP_DONE] = "",
+ [FTP_DONE] = NULL,
};
/**
} while ( --len );
}
+/**
+ * Move to next state and send the appropriate FTP control string
+ *
+ * @v ftp FTP request
+ *
+ */
+static void ftp_next_state ( struct ftp_request *ftp ) {
+
+ /* Move to next state */
+ if ( ftp->state < FTP_DONE )
+ ftp->state++;
+
+ /* Send control string if needed */
+ if ( ftp_strings[ftp->state] != NULL ) {
+ DBGC ( ftp, "FTP %p sending ", ftp );
+ DBGC ( ftp, ftp_strings[ftp->state], ftp->uri->path );
+ xfer_printf ( &ftp->control, ftp_strings[ftp->state],
+ ftp->uri->path );
+ }
+}
+
/**
* Handle an FTP control channel response
*
}
}
- /* Move to next state */
- if ( ftp->state < FTP_DONE )
- ftp->state++;
-
- /* Send control string */
- if ( ftp->state < FTP_DONE ) {
- DBGC ( ftp, "FTP %p sending ", ftp );
- DBGC ( ftp, ftp_strings[ftp->state], ftp->uri->path );
- xfer_printf ( &ftp->control, ftp_strings[ftp->state],
- ftp->uri->path );
- }
+ /* Move to next state and send control string */
+ ftp_next_state ( ftp );
+
}
/**
ftp, strerror ( rc ) );
/* If there was an error, close control channel and record status */
- if ( rc )
+ if ( rc ) {
ftp_done ( ftp, rc );
+ } else {
+ ftp_next_state ( ftp );
+ }
}
/**