1 //==========================================================================
3 // include/tftp_support.h
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas, andrew.lunn@ascom.ch
28 //####DESCRIPTIONEND####
30 //==========================================================================
32 #ifndef _TFTP_SUPPORT_H_
33 #define _TFTP_SUPPORT_H_
35 #include <fcntl.h> // O_RDONLY
39 #define TFTP_NETASCII 0 // Text files
40 #define TFTP_OCTET 1 // Binary files
46 // These initial 7 are passed across the net in "ERROR" packets.
47 #define TFTP_ENOTFOUND 1 /* file not found */
48 #define TFTP_EACCESS 2 /* access violation */
49 #define TFTP_ENOSPACE 3 /* disk full or allocation exceeded */
50 #define TFTP_EBADOP 4 /* illegal TFTP operation */
51 #define TFTP_EBADID 5 /* unknown transfer ID */
52 #define TFTP_EEXISTS 6 /* file already exists */
53 #define TFTP_ENOUSER 7 /* no such user */
54 // These extensions are return codes in our API, *never* passed on the net.
55 #define TFTP_TIMEOUT 8 /* operation timed out */
56 #define TFTP_NETERR 9 /* some sort of network error */
57 #define TFTP_INVALID 10 /* invalid parameter */
58 #define TFTP_PROTOCOL 11 /* protocol violation */
59 #define TFTP_TOOLARGE 12 /* file is larger than buffer */
65 struct tftpd_fileops {
66 int (*open)(const char *, int);
68 int (*write)(int, const void *, int);
69 int (*read)(int, void *, int);
72 __externC int tftpd_start(int, struct tftpd_fileops *);
73 __externC int tftpd_stop(int);
80 __externC int tftp_client_get(const char * const filename,
81 const char * const server,
88 __externC int tftp_client_put(const char * const filename,
89 const char * const server,
97 __externC int tftp_get(const char * const filename,
98 const struct sockaddr_in * const server,
104 __externC int tftp_put(const char * const filename,
105 const struct sockaddr_in * const server,
111 #define TFTP_TIMEOUT_PERIOD 5 // Seconds between retries
112 #define TFTP_TIMEOUT_MAX 50 // Max timeouts over all blocks
113 #define TFTP_RETRIES_MAX 5 // retries per block before giving up
115 #endif // _TFTP_SUPPORT_H_