XINU
tftp.h
Go to the documentation of this file.
1 /* tftp.h - definitions for trivial file transfer protocol */
2 
3 /* TFTP Packet Op codes */
4 #define TFTP_RRQ 1 /* Read Request */
5 #define TFTP_WRQ 2 /* Write Request */
6 #define TFTP_DATA 3 /* Data Packet */
7 #define TFTP_ACK 4 /* Acknowledgement */
8 #define TFTP_ERROR 5 /* Error */
9 
10 /* TFTP Error Codes */
11 #define TFTP_ERROR_NOT_DEFINED 0 /* Not defined, see error message (if any). */
12 #define TFTP_ERROR_FILE_NOT_FOUND 1 /* File not found. */
13 #define TFTP_ERROR_ACCESS_VIOLATION 2 /* Access violation. */
14 #define TFTP_ERROR_DISK_FULL 3 /* Disk full or allocation exceeded. */
15 #define TFTP_ERROR_ILLEGAL_OP 4 /* Illegal TFTP operation. */
16 #define TFTP_ERROR_UNKNOWN_TRANSFER_ID 5 /* Unknown transfer ID. */
17 #define TFTP_ERROR_FILE_EXISTS 6 /* File already exists. */
18 #define TFTP_ERROR_NO_SUCH_USER 7 /* No such user. */
19 
20 #define TFTP_PORT 69 /* UDP Port for TFTP */
21 #define TFTP_MAXNAM 64 /* Max length of a file name */
22 #define TFTP_MAXDATA 512 /* Max size of a data packet */
23 #define TFTP_MAXRETRIES 3 /* Number of retranmissions */
24 #define TFTP_WAIT 5000 /* Time to wait for reply (ms) */
25 
26 /* Xinu Specific Flags */
27 #define TFTP_NON_VERBOSE 0 /* Do not use verbose output */
28 #define TFTP_VERBOSE 1 /* Use verbose output */
29 
30 /* Format of a TFTP message (items following opcode depend on msg type) */
31 
32 #pragma pack(1)
33 struct tftp_msg {
34  uint16 tf_opcode; /* One of the opcodes above */
35  union {
36 
37  /* Items in a RRQ or WRQ message */
38 
39  struct {
40  char tf_filemode[TFTP_MAXNAM+10]; /* file name and mode */
41  };
42 
43  /* Items in a Data packet */
44 
45  struct {
46  uint16 tf_dblk; /* Block number of this data */
47  char tf_data[TFTP_MAXDATA]; /* Actual data */
48  };
49 
50  /* Items in an ACK packet */
51 
52  struct {
53  uint16 tf_ablk; /* Block number being acked */
54  };
55 
56  /* Items in an Error packet */
57 
58  struct {
59  uint16 tf_ercode; /* Integer error code */
60  char tf_ermsg[TFTP_MAXDATA]; /* Error message */
61  };
62  };
63 };
64 #pragma pack()
65 
66 status tftpget(uint32 serverip, const char* filename, char* rcv_buf, uint32 rcv_buf_size, byte verbose);
67 status tftpget_mb(uint32 serverip, const char* filename, char** rcv_bufs, uint32* rcv_buf_sizes, uint32 rcv_buf_count, byte verbose);
#define TFTP_MAXNAM
Definition: tftp.h:21
unsigned char byte
符号なし8ビット値(unsigned char)
Definition: kernel.h:7
int32 status
ステータスを意味する返り値の型(OK/SYSERR)
Definition: kernel.h:57
char tf_filemode[TFTP_MAXNAM+10]
Definition: tftp.h:40
char tf_data[TFTP_MAXDATA]
Definition: tftp.h:47
#define TFTP_MAXDATA
Definition: tftp.h:22
Definition: tftp.h:33
char tf_ermsg[TFTP_MAXDATA]
Definition: tftp.h:60
uint16 tf_opcode
Definition: tftp.h:34
unsigned short uint16
符号なし16ビット整数(unsigned short)
Definition: kernel.h:17
uint16 tf_ablk
Definition: tftp.h:53
status tftpget_mb(uint32 serverip, const char *filename, char **rcv_bufs, uint32 *rcv_buf_sizes, uint32 rcv_buf_count, byte verbose)
Definition: tftp.c:118
uint16 tf_dblk
Definition: tftp.h:46
unsigned int uint32
符号なし32ビット整数(unsigned int)
Definition: kernel.h:15
uint16 tf_ercode
Definition: tftp.h:59
status tftpget(uint32 serverip, const char *filename, char *rcv_buf, uint32 rcv_buf_size, byte verbose)
Definition: tftp.c:100