diff --git a/build/Debug/GNU-Linux/ftpCommandElaborate.o b/build/Debug/GNU-Linux/ftpCommandElaborate.o
new file mode 100644
index 0000000..2bde9b2
Binary files /dev/null and b/build/Debug/GNU-Linux/ftpCommandElaborate.o differ
diff --git a/build/Debug/GNU-Linux/ftpCommandElaborate.o.d b/build/Debug/GNU-Linux/ftpCommandElaborate.o.d
new file mode 100644
index 0000000..3d2cb35
--- /dev/null
+++ b/build/Debug/GNU-Linux/ftpCommandElaborate.o.d
@@ -0,0 +1,32 @@
+build/Debug/GNU-Linux/ftpCommandElaborate.o: ftpCommandElaborate.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h ftpData.h library/dynamicVectors.h ftpServer.h \
+ library/logFunctions.h library/fileManagement.h library/configRead.h \
+ library/dynamicVectors.h library/../ftpData.h library/openSsl.h \
+ ftpCommandsElaborate.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+ftpData.h:
+
+library/dynamicVectors.h:
+
+ftpServer.h:
+
+library/logFunctions.h:
+
+library/fileManagement.h:
+
+library/configRead.h:
+
+library/dynamicVectors.h:
+
+library/../ftpData.h:
+
+library/openSsl.h:
+
+ftpCommandsElaborate.h:
diff --git a/build/Debug/GNU-Linux/ftpData.o b/build/Debug/GNU-Linux/ftpData.o
new file mode 100644
index 0000000..cd0e915
Binary files /dev/null and b/build/Debug/GNU-Linux/ftpData.o differ
diff --git a/build/Debug/GNU-Linux/ftpData.o.d b/build/Debug/GNU-Linux/ftpData.o.d
new file mode 100644
index 0000000..32965f1
--- /dev/null
+++ b/build/Debug/GNU-Linux/ftpData.o.d
@@ -0,0 +1,27 @@
+build/Debug/GNU-Linux/ftpData.o: ftpData.c library/dynamicVectors.h \
+ library/fileManagement.h library/dynamicVectors.h ftpServer.h \
+ ftpCommandsElaborate.h ftpData.h library/dynamicVectors.h \
+ library/configRead.h library/dynamicVectors.h library/../ftpData.h \
+ library/fileManagement.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+ftpServer.h:
+
+ftpCommandsElaborate.h:
+
+ftpData.h:
+
+library/dynamicVectors.h:
+
+library/configRead.h:
+
+library/dynamicVectors.h:
+
+library/../ftpData.h:
+
+library/fileManagement.h:
diff --git a/build/Debug/GNU-Linux/ftpServer.o b/build/Debug/GNU-Linux/ftpServer.o
new file mode 100644
index 0000000..47fe446
Binary files /dev/null and b/build/Debug/GNU-Linux/ftpServer.o differ
diff --git a/build/Debug/GNU-Linux/ftpServer.o.d b/build/Debug/GNU-Linux/ftpServer.o.d
new file mode 100644
index 0000000..4e17a31
--- /dev/null
+++ b/build/Debug/GNU-Linux/ftpServer.o.d
@@ -0,0 +1,36 @@
+build/Debug/GNU-Linux/ftpServer.o: ftpServer.c library/dynamicVectors.h \
+ library/fileManagement.h library/dynamicVectors.h ftpServer.h ftpData.h \
+ library/dynamicVectors.h ftpCommandsElaborate.h library/fileManagement.h \
+ library/logFunctions.h library/configRead.h library/dynamicVectors.h \
+ library/../ftpData.h library/signals.h library/openSsl.h \
+ library/connection.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+ftpServer.h:
+
+ftpData.h:
+
+library/dynamicVectors.h:
+
+ftpCommandsElaborate.h:
+
+library/fileManagement.h:
+
+library/logFunctions.h:
+
+library/configRead.h:
+
+library/dynamicVectors.h:
+
+library/../ftpData.h:
+
+library/signals.h:
+
+library/openSsl.h:
+
+library/connection.h:
diff --git a/build/Debug/GNU-Linux/library/configRead.o b/build/Debug/GNU-Linux/library/configRead.o
new file mode 100644
index 0000000..729e8a4
Binary files /dev/null and b/build/Debug/GNU-Linux/library/configRead.o differ
diff --git a/build/Debug/GNU-Linux/library/configRead.o.d b/build/Debug/GNU-Linux/library/configRead.o.d
new file mode 100644
index 0000000..18058fc
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/configRead.o.d
@@ -0,0 +1,23 @@
+build/Debug/GNU-Linux/library/configRead.o: library/configRead.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/configRead.h library/dynamicVectors.h \
+ library/../ftpData.h library/../library/dynamicVectors.h \
+ library/fileManagement.h library/daemon.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/configRead.h:
+
+library/dynamicVectors.h:
+
+library/../ftpData.h:
+
+library/../library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/daemon.h:
diff --git a/build/Debug/GNU-Linux/library/connection.o b/build/Debug/GNU-Linux/library/connection.o
new file mode 100644
index 0000000..7befb1a
Binary files /dev/null and b/build/Debug/GNU-Linux/library/connection.o differ
diff --git a/build/Debug/GNU-Linux/library/connection.o.d b/build/Debug/GNU-Linux/library/connection.o.d
new file mode 100644
index 0000000..9cfe267
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/connection.o.d
@@ -0,0 +1,16 @@
+build/Debug/GNU-Linux/library/connection.o: library/connection.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/../ftpData.h \
+ library/../library/dynamicVectors.h library/connection.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/../ftpData.h:
+
+library/../library/dynamicVectors.h:
+
+library/connection.h:
diff --git a/build/Debug/GNU-Linux/library/daemon.o b/build/Debug/GNU-Linux/library/daemon.o
new file mode 100644
index 0000000..c233c0f
Binary files /dev/null and b/build/Debug/GNU-Linux/library/daemon.o differ
diff --git a/build/Debug/GNU-Linux/library/daemon.o.d b/build/Debug/GNU-Linux/library/daemon.o.d
new file mode 100644
index 0000000..87c2092
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/daemon.o.d
@@ -0,0 +1,11 @@
+build/Debug/GNU-Linux/library/daemon.o: library/daemon.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/fileManagement.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
diff --git a/build/Debug/GNU-Linux/library/dynamicVectors.o b/build/Debug/GNU-Linux/library/dynamicVectors.o
new file mode 100644
index 0000000..b1fe279
Binary files /dev/null and b/build/Debug/GNU-Linux/library/dynamicVectors.o differ
diff --git a/build/Debug/GNU-Linux/library/dynamicVectors.o.d b/build/Debug/GNU-Linux/library/dynamicVectors.o.d
new file mode 100644
index 0000000..a02322d
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/dynamicVectors.o.d
@@ -0,0 +1,11 @@
+build/Debug/GNU-Linux/library/dynamicVectors.o: library/dynamicVectors.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/dynamicVectors.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/dynamicVectors.h:
diff --git a/build/Debug/GNU-Linux/library/fileManagement.o b/build/Debug/GNU-Linux/library/fileManagement.o
new file mode 100644
index 0000000..5ecefd3
Binary files /dev/null and b/build/Debug/GNU-Linux/library/fileManagement.o differ
diff --git a/build/Debug/GNU-Linux/library/fileManagement.o.d b/build/Debug/GNU-Linux/library/fileManagement.o.d
new file mode 100644
index 0000000..78e7134
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/fileManagement.o.d
@@ -0,0 +1,14 @@
+build/Debug/GNU-Linux/library/fileManagement.o: library/fileManagement.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
diff --git a/build/Debug/GNU-Linux/library/logFunctions.o b/build/Debug/GNU-Linux/library/logFunctions.o
new file mode 100644
index 0000000..6b5f61c
Binary files /dev/null and b/build/Debug/GNU-Linux/library/logFunctions.o differ
diff --git a/build/Debug/GNU-Linux/library/logFunctions.o.d b/build/Debug/GNU-Linux/library/logFunctions.o.d
new file mode 100644
index 0000000..e52d825
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/logFunctions.o.d
@@ -0,0 +1,11 @@
+build/Debug/GNU-Linux/library/logFunctions.o: library/logFunctions.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/logFunctions.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/logFunctions.h:
diff --git a/build/Debug/GNU-Linux/library/openSsl.o b/build/Debug/GNU-Linux/library/openSsl.o
new file mode 100644
index 0000000..fd26f74
Binary files /dev/null and b/build/Debug/GNU-Linux/library/openSsl.o differ
diff --git a/build/Debug/GNU-Linux/library/openSsl.o.d b/build/Debug/GNU-Linux/library/openSsl.o.d
new file mode 100644
index 0000000..894f475
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/openSsl.o.d
@@ -0,0 +1,11 @@
+build/Debug/GNU-Linux/library/openSsl.o: library/openSsl.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/openSsl.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/openSsl.h:
diff --git a/build/Debug/GNU-Linux/library/signals.o b/build/Debug/GNU-Linux/library/signals.o
new file mode 100644
index 0000000..78c4af6
Binary files /dev/null and b/build/Debug/GNU-Linux/library/signals.o differ
diff --git a/build/Debug/GNU-Linux/library/signals.o.d b/build/Debug/GNU-Linux/library/signals.o.d
new file mode 100644
index 0000000..ff9cc4d
--- /dev/null
+++ b/build/Debug/GNU-Linux/library/signals.o.d
@@ -0,0 +1,11 @@
+build/Debug/GNU-Linux/library/signals.o: library/signals.c \
+ library/dynamicVectors.h library/fileManagement.h \
+ library/dynamicVectors.h library/../ftpServer.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+library/../ftpServer.h:
diff --git a/build/Debug/GNU-Linux/uFTP.o b/build/Debug/GNU-Linux/uFTP.o
new file mode 100644
index 0000000..63c9847
Binary files /dev/null and b/build/Debug/GNU-Linux/uFTP.o differ
diff --git a/build/Debug/GNU-Linux/uFTP.o.d b/build/Debug/GNU-Linux/uFTP.o.d
new file mode 100644
index 0000000..2e331b6
--- /dev/null
+++ b/build/Debug/GNU-Linux/uFTP.o.d
@@ -0,0 +1,10 @@
+build/Debug/GNU-Linux/uFTP.o: uFTP.c library/dynamicVectors.h \
+ library/fileManagement.h library/dynamicVectors.h ftpServer.h
+
+library/dynamicVectors.h:
+
+library/fileManagement.h:
+
+library/dynamicVectors.h:
+
+ftpServer.h:
diff --git a/build/modules/ftpData.o b/build/modules/ftpData.o
index afc9ecb..2879bd9 100644
Binary files a/build/modules/ftpData.o and b/build/modules/ftpData.o differ
diff --git a/build/modules/ftpServer.o b/build/modules/ftpServer.o
index 227a415..b6a0803 100644
Binary files a/build/modules/ftpServer.o and b/build/modules/ftpServer.o differ
diff --git a/build/modules/openSsl.o b/build/modules/openSsl.o
index 8437d17..bbe6008 100644
Binary files a/build/modules/openSsl.o and b/build/modules/openSsl.o differ
diff --git a/build/modules/signals.o b/build/modules/signals.o
index f0007f5..43358f4 100644
Binary files a/build/modules/signals.o and b/build/modules/signals.o differ
diff --git a/build/uFTP b/build/uFTP
index 70fcd67..8d9ca31 100755
Binary files a/build/uFTP and b/build/uFTP differ
diff --git a/dist/Debug/GNU-Linux/uftp b/dist/Debug/GNU-Linux/uftp
deleted file mode 100755
index c62b2b6..0000000
Binary files a/dist/Debug/GNU-Linux/uftp and /dev/null differ
diff --git a/ftpServer.c b/ftpServer.c
index 1a316ae..66b59e4 100644
--- a/ftpServer.c
+++ b/ftpServer.c
@@ -356,9 +356,9 @@ void runFtpServer(void)
/* the maximum socket fd is now the main socket descriptor */
ftpData.connectionData.maxSocketFD = ftpData.connectionData.theMainSocket+1;
- init_openssl();
- ctx = create_context();
- configure_context(ctx);
+ initOpenssl();
+ ctx = createContext();
+ configureContext(ctx);
//Endless loop ftp process
while (1)
@@ -529,20 +529,30 @@ static int processCommand(int processingElement)
returnCode = dprintf(ftpData.clients[processingElement].socketDescriptor, "234 AUTH TLS OK..\r\n");
- ftpData.clients[processingElement].tlsIsEnabled = 1;
- SSL *ssl;
- ssl = SSL_new(ctx);
+ ftpData.clients[processingElement].tlsIsEnabled = 1;
+ SSL *ssl;
+ ssl = SSL_new(ctx);
SSL_set_fd(ssl, ftpData.clients[processingElement].socketDescriptor);
- if (SSL_accept(ssl) <= 0) {
- printf("\nSSL ERRORS");
- ERR_print_errors_fp(stderr);
+ int sslAcceptTimeout = 0;
+ do {
+ returnCode = SSL_accept(ssl);
+ printf("\nSSL waiting handshake %d.. return code = %d", sslAcceptTimeout, returnCode);
+ if (returnCode <= 0) {
+ printf("\nSSL ERRORS");
+ ERR_print_errors_fp(stderr);
+ }
+ else {
+ printf("\nSSL ACCEPTED");
+ fflush(0);
+ SSL_write(ssl, "ciao prova\r\n", strlen("ciao prova\r\n"));
+ }
+ sslAcceptTimeout++;
+
+ sleep(1);
}
- else {
- printf("\nSSL ACCEPTED");
- SSL_write(ssl, "ciao prova\r\n", strlen("ciao prova\r\n"));
- }
-
+ while(returnCode <=0 && sslAcceptTimeout < 3);
+ printf("\nReading ssl");
char buffer[100];
int readenb = 0;
while(1)
@@ -711,3 +721,9 @@ static int processCommand(int processingElement)
memset(ftpData.clients[processingElement].theCommandReceived, 0, CLIENT_COMMAND_STRING_SIZE);
return toReturn;
}
+
+
+void deallocateMemory(void)
+{
+ printf("\n Deallocating the memory.. ");
+}
\ No newline at end of file
diff --git a/ftpServer.h b/ftpServer.h
index ea57c39..d67da6c 100644
--- a/ftpServer.h
+++ b/ftpServer.h
@@ -33,6 +33,7 @@ void runFtpServer(void);
void *connectionWorkerHandle(void * socketId);
void workerCleanup(void *socketId);
void signal_callback_handler(int signum);
+void deallocateMemory(void);
#endif /* FTPSERVER_H */
diff --git a/library/openSsl.c b/library/openSsl.c
index b409580..28a8597 100644
--- a/library/openSsl.c
+++ b/library/openSsl.c
@@ -32,18 +32,18 @@
#include "openSsl.h"
-void init_openssl()
+void initOpenssl()
{
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
}
-void cleanup_openssl()
+void cleanupOpenssl()
{
EVP_cleanup();
}
-SSL_CTX *create_context()
+SSL_CTX *createContext()
{
const SSL_METHOD *method;
SSL_CTX *ctx;
@@ -60,7 +60,7 @@ SSL_CTX *create_context()
return ctx;
}
-void configure_context(SSL_CTX *ctx)
+void configureContext(SSL_CTX *ctx)
{
SSL_CTX_set_ecdh_auto(ctx, 1);
diff --git a/library/openSsl.h b/library/openSsl.h
index 93f1d67..a27958b 100644
--- a/library/openSsl.h
+++ b/library/openSsl.h
@@ -33,11 +33,10 @@
extern "C" {
#endif
-void init_openssl();
-void cleanup_openssl();
-SSL_CTX *create_context();
-void configure_context(SSL_CTX *ctx);
-
+void initOpenssl();
+void cleanupOpenssl();
+SSL_CTX *createContext();
+void configureContext(SSL_CTX *ctx);
#ifdef __cplusplus
}
diff --git a/library/signals.c b/library/signals.c
index 9b080fa..9c14041 100644
--- a/library/signals.c
+++ b/library/signals.c
@@ -56,9 +56,17 @@ static void ignore_sigpipe(void)
}
}
+void onUftpClose(void)
+{
+ printf("\nuFTP exit()\n");
+ deallocateMemory();
+ exit(0);
+}
+
void signalHandlerInstall(void)
{
//signal(SIGPIPE, signal_callback_handler);
+ signal(SIGINT,onUftpClose);
signal(SIGUSR2,SIG_IGN);
signal(SIGPIPE,SIG_IGN);
signal(SIGALRM,SIG_IGN);
diff --git a/library/signals.h b/library/signals.h
index d6570f1..a25d1ef 100644
--- a/library/signals.h
+++ b/library/signals.h
@@ -31,6 +31,7 @@ extern "C" {
void signalHandlerInstall(void);
void signal_callback_handler(int signum);
+void onUftpClose(void);
#ifdef __cplusplus
}
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
index a39859f..942cc37 100644
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -7,15 +7,19 @@
- file:/home/ugo/NetBeansProjects/uFTP/ftpData.c
- file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.h
- file:/home/ugo/NetBeansProjects/uFTP/ftpCommandElaborate.c
+ file:/home/ugo/NetBeansProjects/uFTP/library/signals.c
+ file:/home/ugo/NetBeansProjects/uFTP/library/signals.h
file:/home/ugo/NetBeansProjects/uFTP/ftpServer.c
+ file:/home/ugo/NetBeansProjects/uFTP/uFTP.c
file:/home/ugo/NetBeansProjects/uFTP/MakeFileGeneric
+ file:/home/ugo/NetBeansProjects/uFTP/ftpServer.h
file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.c
file:/home/ugo/NetBeansProjects/uFTP/ftpData.h
file:/home/ugo/NetBeansProjects/uFTP/library/configRead.c
file:/home/ugo/NetBeansProjects/uFTP/ftpCommandsElaborate.h
+ file:/home/ugo/NetBeansProjects/uFTP/ftpData.c
+ file:/home/ugo/NetBeansProjects/uFTP/library/openSsl.h
+ file:/home/ugo/NetBeansProjects/uFTP/ftpCommandElaborate.c