-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_func.h
84 lines (74 loc) · 2.31 KB
/
server_func.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <dirent.h>
#include <time.h>
#include <fcntl.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <signal.h>
#include <pthread.h>
#define PORTNUM 2300
#define MAX_ARGUMENTS 5
#define STRING_SIZE 200
#define BUF_SIZE 8192
#define YEL "\x1B[33m"
#define RED "\x1B[31m"
#define NRM "\x1B[0m"
#define BLU "\x1B[34m"
#define GRN "\x1B[32m"
struct connection_status {
char actual_path[STRING_SIZE];
int connection_ok;
int data_session;
int data_session_port;
int control_session;
char type;
char *server_address;
char *client_address;
int taxa_transmissao;
int modo_passivo;
};
typedef struct connection_status ConnectionStatus;
/* INICIALIZAÇÃO DA CONEXÃO */
ConnectionStatus *initializeStatus();
char *getIPaddress(char *interface);
int createSocketToServe(char *address, int port);
int createConnectionToAccept(int socket);
int createConnectionToConnect(int socket, char* address, int port);
/* DECODIFICAÇÃO DO COMANDO */
int decode_message (char *command);
void strlwr (char *s);
int number_words(char **m);
char **split_words(char *m, char *limit);
int hex_to_dec(char *hex, int n);
char *dec_to_hex(int dec, int n);
/* CONTROLE DE ACESSO */
char *func_user(ConnectionStatus *c, char *message);
char *func_pass(ConnectionStatus *c, char *message);
char *func_cwd(ConnectionStatus *c, char *message);
char *func_cdup(ConnectionStatus *c, char *message);
char *func_quit(ConnectionStatus *c, char *message);
/* PARÂMETROS DE TRANSFERÊNCIA */
char *func_port(ConnectionStatus *c, char *message);
char *func_type(ConnectionStatus *c, char *message);
char *func_pasv(ConnectionStatus *c, char *message);
/* COMANDOS FTP */
char *func_list(ConnectionStatus *c, char *message);
char *func_pwd(ConnectionStatus *c,char *message);
char *func_mkd(ConnectionStatus *c,char *message);
char *func_rmd(ConnectionStatus *c, char *message);
char *func_noop(ConnectionStatus *c, char *message);
char *func_syst(ConnectionStatus *c, char *message);
char *func_retr(ConnectionStatus *c, char *message);
char *func_stor(ConnectionStatus *c, char *message);
/* THREAD */
void *multUser(void *_c);