diff options
Diffstat (limited to '')
-rw-r--r-- | include/client.hpp | 5 | ||||
-rw-r--r-- | include/comms.hpp | 7 | ||||
-rw-r--r-- | include/server.hpp | 3 | ||||
-rw-r--r-- | include/util.hpp | 24 |
4 files changed, 27 insertions, 12 deletions
diff --git a/include/client.hpp b/include/client.hpp index dfc3e0c..8ee71ff 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -1,3 +1,6 @@ +// Author Name: Matt Strapp +// Date: 25 April 2022 +// x500: strap012 #ifndef client_H #define client_H @@ -8,7 +11,7 @@ int Send_Blocking(int sockFD, const BYTE *data, int len); void DoClient(const char *svrIP, int svrPort, const char *fileName); -void doClientCommand(int i); +void DoCommand(int i); void prepareSend(int i, Header header); int processReception(int i); diff --git a/include/comms.hpp b/include/comms.hpp index 1b2a942..4db1807 100644 --- a/include/comms.hpp +++ b/include/comms.hpp @@ -1,3 +1,6 @@ +// Author Name: Matt Strapp +// Date: 25 April 2022 +// x500: strap012 #ifndef COMM_UTIL_H #define COMM_UTIL_H #include "util.hpp" @@ -8,7 +11,7 @@ struct CONN_STAT { // in struct timeb lastTime; // Last time this connection was used (used to detect // s2c closure) - bool recInitHeader; // False until initial header is recieved + bool recInitHeader; // False until initial header is received bool expectingHeader; // The message to be read is a header (irrelevent for // senders) enum LinkType linkType; // MESSAGE_LINK (persistent) or FILE_LINK (one off) @@ -20,7 +23,7 @@ struct CONN_STAT { // len --> 0) bool changeDirection; // Flag to change the direction of the connection once // the current communication finishes - bool shouldClose; // Flag to destroy this connection + bool shouldClose; // Flag to destroy this connection }; int Send_NonBlocking(int sockFD, BYTE *data, struct CONN_STAT *pStat, diff --git a/include/server.hpp b/include/server.hpp index f660514..59f8dc7 100644 --- a/include/server.hpp +++ b/include/server.hpp @@ -1,3 +1,6 @@ +// Author Name: Matt Strapp +// Date: 25 April 2022 +// x500: strap012 #ifndef server_H #define server_H diff --git a/include/util.hpp b/include/util.hpp index 51783a1..d3ba6e1 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -1,8 +1,12 @@ +// Author Name: Matt Strapp +// Date: 25 April 2022 +// x500: strap012 #ifndef UTIL_H #define UTIL_H // Get your libraries here #include <arpa/inet.h> +#include <cstddef> #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -15,6 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <string> #include <sys/socket.h> #include <sys/stat.h> #include <sys/timeb.h> @@ -23,7 +28,7 @@ #include <unistd.h> #define NAME "SERVER" -#define ANON "Anonymous" +#define ANON "ANON" #define LINE_SIZE 5000 // overkill #define BUF_LEN 12000000 // overkill @@ -32,6 +37,7 @@ #define MAX_USERNAME_LEN 8 #define MIN_PASSWORD_LEN 4 #define MAX_PASSWORD_LEN 8 +#define MAX_COMMAND_LEN 10 enum Command { REGISTER = 0, // [username] [password] Register a new account @@ -48,9 +54,9 @@ enum Command { DELAY = 10, // [N] A special command that delays for N seconds before // executing the next command in the script - GETF = 11, // [filename] Server telling clinet to request a file, clinet - // requesting a file - PING = 12, // Check that connection is still there (nop) + GETF = 11, // [filename] Server telling clinet to request a file, clinet + // requesting a file + PING = 12, // Check that connection is still there, doesn't do anything else CONNECT = 13, // [unique id] Allows the server to identify specific users when // they are logged in multiple times @@ -63,17 +69,17 @@ typedef unsigned char BYTE; typedef unsigned int DWORD; typedef unsigned short WORD; -enum Command parse_command(char *line); +Command parse_command(char *line); bool isValidUsername(char *username); bool isValidPassword(char *password); void Error(const char *format, ...); void Log(const char *format, ...); -void buf2i(BYTE *buf, int &i); -void i2buf(int &i, BYTE *buf); +void BigEndianToLittle(BYTE *buf, int &i); +void LittleEndianToBig(int &i, BYTE *buf); -const char *com2str(enum Command command); +const char *com2str(Command command); double timeDifference(struct timeb a, struct timeb b); @@ -99,7 +105,7 @@ public: enum Flag m_flag; enum Recipient m_recipient; enum Trace m_trace; - enum Command m_command; + Command m_command; BYTE m_name[9]; |