|
@@ -38,6 +38,7 @@
|
|
#include <stdbool.h>
|
|
#include <stdbool.h>
|
|
#include "ftp.h"
|
|
#include "ftp.h"
|
|
#include "lwip/tcp.h"
|
|
#include "lwip/tcp.h"
|
|
|
|
+#include "sockets.h"
|
|
#include "stm32f4xx.h"
|
|
#include "stm32f4xx.h"
|
|
#include "common_config.h"
|
|
#include "common_config.h"
|
|
#include "spi_flash.h"
|
|
#include "spi_flash.h"
|
|
@@ -257,6 +258,14 @@ static void lwftp_control_close(lwftp_session_t *s, int result)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void set_timeout(struct tcp_pcb *tpcb, unsigned seconds)
|
|
|
|
+{
|
|
|
|
+ struct timeval timeout;
|
|
|
|
+ timeout.tv_sec = seconds;
|
|
|
|
+ timeout.tv_usec = 0;
|
|
|
|
+ setsockopt(tpcb, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, sizeof(timeout));
|
|
|
|
+}
|
|
|
|
+
|
|
/** Main client state machine
|
|
/** Main client state machine
|
|
* @param pointer to lwftp session data
|
|
* @param pointer to lwftp session data
|
|
* @param pointer to PCB
|
|
* @param pointer to PCB
|
|
@@ -357,6 +366,7 @@ anonymous:
|
|
if (response>0) {
|
|
if (response>0) {
|
|
if (response==150) {
|
|
if (response==150) {
|
|
s->control_state = LWFTP_XFERING;
|
|
s->control_state = LWFTP_XFERING;
|
|
|
|
+ set_timeout(s->control_pcb, 0);
|
|
} else if (response==550) {
|
|
} else if (response==550) {
|
|
s->control_state = LWFTP_QUIT;
|
|
s->control_state = LWFTP_QUIT;
|
|
s->error = "Failed to open file";
|
|
s->error = "Failed to open file";
|
|
@@ -538,6 +548,9 @@ err_t lwftp_store(lwftp_session_t *s)
|
|
error = ERR_MEM;
|
|
error = ERR_MEM;
|
|
goto close_pcb;
|
|
goto close_pcb;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ set_timeout(s->control_pcb, 5);
|
|
|
|
+ set_timeout(s->data_pcb, 5);
|
|
// Open control session
|
|
// Open control session
|
|
tcp_arg(s->control_pcb, s);
|
|
tcp_arg(s->control_pcb, s);
|
|
tcp_err(s->control_pcb, lwftp_control_err);
|
|
tcp_err(s->control_pcb, lwftp_control_err);
|