about summary refs log tree commit diff stats
path: root/inc/packet.h
blob: d5f341c745dbe7b3f2d5af2100651dd55f8e2d7b (plain) (blame)
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
#ifndef NBT_TFTP_PACKET_H
#define NBT_TFTP_PACKET_H

#include <stdint.h>

typedef enum {
	RRQ	= 1,
	WRQ	= 2,
	DAT	= 3,
	ACK	= 4,
	ERR	= 5,
} nbt_tftp_opcode;

typedef enum {
	ERROR		= 0,
	ENOTFOUND	= 1,
	EACCESS		= 2,
	ENOSPACE	= 3,
	EOPERATION	= 4,
	ETRANS		= 5,
	EEXISTS		= 6,
	EUSER		= 7,
} nbt_tftp_ecode;

typedef struct {
	nbt_tftp_opcode opcode;
	char* filename;
	char* mode;
} nbt_tftp_packet_rq;

typedef struct {
	nbt_tftp_opcode opcode;
	uint16_t block_num;
	char* data;
} nbt_tftp_packet_data;

typedef struct {
	nbt_tftp_opcode opcode;
	uint16_t block_num;
} nbt_tftp_packet_ack;

typedef struct {
	nbt_tftp_opcode opcode;
	nbt_tftp_ecode err;
	char* emsg;
} nbt_tftp_packet_error;



#endif