-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteam13_struct.h
81 lines (70 loc) · 1.73 KB
/
team13_struct.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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>
#ifndef _TFTP_H
#define _TFTP_H
enum packet_type {RRQ=1, WRQ, DATA, ACK, ERROR};
enum filemode {NETASCII, OCTET, MAIL};
static char *filemode[] = {
"netascii",
"octet",
"mail"
};
enum error_codes {NOTDEFERR, NOTFOUNDERR, ACCESSERR, DISKFULLERR,
ILLEGALOPERR, UNKNOWNIDERR, FILEEXISTSERR,
UNKNOWNUSERERR};
static char *errormsg[] = {
"Not defined, see error message",
"File not found",
"Access violation",
"Disk full or allocation exceeded",
"Illegal TFTP operation",
"Unknown transfer ID",
"File already exists",
"No such user"
};
typedef
struct generic_packet {
short unsigned opcode;
char info[512];
} generic_packet;
typedef
struct data_packet {
short unsigned opcode; /* 3 */
short unsigned block_number;
char data[512];
} data_packet;
typedef
struct ack_packet {
short unsigned opcode; /* 4 */
short unsigned block_number;
} ack_packet;
typedef
struct error_packet {
short unsigned opcode; /* 5 */
short unsigned error_code;
char error_msg[512];
} error_packet;
typedef
struct information_node{
int clientfd;
FILE* fp_local;
int block_number;
int filesize;
int lastsize;
char filename[512];
struct sockaddr_in client_addr;
struct timeval sendtime;
struct information_node* previous;
struct information_node* following;
}node;
#endif