12#include <openssl/err.h>
13#include <openssl/sha.h>
14#include <openssl/ssl.h>
20#include <unordered_map>
25#define AUTH_REQUEST "AUTH"
26#define STATUS_AUTH_FAILED 430
27#define STATUS_AUTH_SUCCESS 230
30#define LIST_REQUEST "LIST"
31#define GET_REQUEST "GET"
32#define STATUS_MISSING_FILE_NAME 400
33#define STATUS_LISTING_FILES 150
34#define STATUS_FILE_TRANSFER 160
35#define STATUS_TRANSFER_COMPLETE 226
38#define STATUS_CHECKSUM_VERIFY 151
41#define STATUS_FILE_NOT_FOUND 550
42#define STATUS_UNKNOWN_COMMAND 500
45#define QUIT_REQUEST "QUIT"
46#define STATUS_GOODBYE 221
49#define BUFFER_SIZE 1024
51#define ATTEMPT_DELAY 2000
53#define SERVER_CERT "server_cert.pem"
54#define SERVER_KEY "server_key.pem"
58#define SERVER_IP "127.0.0.1"
59#define CA_CERT "server_cert.pem"
66 return "--> 430: Too many failed attempts\n";
68 return "--> 230: Authentication successful!";
70 return "--> 550: File not found or invalid file path\n";
72 return "--> 500: Unknown command\n";
74 return "--> 400: Missing file name\n";
76 return "--> 150: Listing files:\n";
78 return "--> 226: Transfer complete\n";
80 return "--> 221: Goodbye\n";
82 return "--> 160: Starting File Transfer:\n";
84 return "--> 151: Verifying checksum..\n";
86 return "--> 500: Unknown status code\n";
93 SSL_write(ssl, error_msg, strlen(error_msg));
#define STATUS_FILE_NOT_FOUND
Definition protocols.h:41
#define STATUS_AUTH_SUCCESS
Definition protocols.h:27
void send_protocol_message(SSL *ssl, int status_code)
Definition protocols.h:90
#define STATUS_LISTING_FILES
Definition protocols.h:33
#define STATUS_FILE_TRANSFER
Definition protocols.h:34
#define STATUS_CHECKSUM_VERIFY
Definition protocols.h:38
#define STATUS_GOODBYE
Definition protocols.h:46
const char * get_error_message(int status_code)
Definition protocols.h:61
#define STATUS_MISSING_FILE_NAME
Definition protocols.h:32
#define STATUS_AUTH_FAILED
Definition protocols.h:26
#define STATUS_TRANSFER_COMPLETE
Definition protocols.h:35
#define STATUS_UNKNOWN_COMMAND
Definition protocols.h:42