summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorMichael Brown2006-04-30 14:02:07 +0200
committerMichael Brown2006-04-30 14:02:07 +0200
commitaec0e127d2d9aad667612a35dbf8b8ccf8cc001c (patch)
tree0a81238be2655837e08eb9c43d650f7598d49551 /src/include
parentAdd a temporary snprintf, so that safely-written code can at least (diff)
downloadipxe-aec0e127d2d9aad667612a35dbf8b8ccf8cc001c.tar.gz
ipxe-aec0e127d2d9aad667612a35dbf8b8ccf8cc001c.tar.xz
ipxe-aec0e127d2d9aad667612a35dbf8b8ccf8cc001c.zip
Proof-of-concept FTP implementation
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gpxe/ftp.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/include/gpxe/ftp.h b/src/include/gpxe/ftp.h
new file mode 100644
index 00000000..f2db5a13
--- /dev/null
+++ b/src/include/gpxe/ftp.h
@@ -0,0 +1,68 @@
+#ifndef _GPXE_FTP_H
+#define _GPXE_FTP_H
+
+/** @file
+ *
+ * File transfer protocol
+ *
+ */
+
+#include <stdint.h>
+#include <gpxe/tcp.h>
+
+enum ftp_state {
+ FTP_CONNECT = 0,
+ FTP_USER,
+ FTP_PASS,
+ FTP_TYPE,
+ FTP_PASV,
+ FTP_RETR,
+ FTP_QUIT,
+ FTP_DONE,
+};
+
+/**
+ * An FTP request
+ *
+ */
+struct ftp_request {
+ /** TCP connection for this request */
+ struct tcp_connection tcp;
+ /** File to download */
+ const char *filename;
+ /** Callback function
+ *
+ * @v data Received data
+ * @v len Length of received data
+ *
+ * This function is called for all data received from the
+ * remote server.
+ */
+ void ( *callback ) ( char *data, size_t len );
+ /** Completion indicator
+ *
+ * This will be set to a non-zero value when the transfer is
+ * complete. A negative value indicates an error.
+ */
+ int complete;
+
+ /** Current state */
+ enum ftp_state state;
+ /** Amount of current message already transmitted */
+ size_t already_sent;
+ /** Buffer to be filled with data received via the control channel */
+ char *recvbuf;
+ /** Remaining size of recvbuf */
+ size_t recvsize;
+ /** FTP status code, as text */
+ char status_text[4];
+ /** Passive-mode parameters, as text */
+ char passive_text[24]; /* "aaa,bbb,ccc,ddd,eee,fff" */
+
+ /** TCP connection for the data channel */
+ struct tcp_connection tcp_data;
+};
+
+extern void ftp_connect ( struct ftp_request *ftp );
+
+#endif