]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/common/v2_0/include/tftp_support.h
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / net / common / v2_0 / include / tftp_support.h
1 //==========================================================================
2 //
3 //      include/tftp_support.h
4 //
5 //      TFTP support
6 //
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 //
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.
14 //
15 // -------------------------------------------
16 //
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
20 //
21 // Author(s):    gthomas
22 // Contributors: gthomas, andrew.lunn@ascom.ch
23 // Date:         2000-04-06
24 // Purpose:      
25 // Description:  
26 //              
27 //
28 //####DESCRIPTIONEND####
29 //
30 //==========================================================================
31
32 #ifndef _TFTP_SUPPORT_H_
33 #define _TFTP_SUPPORT_H_
34
35 #include <fcntl.h> // O_RDONLY
36 /*
37  * File transfer modes
38  */
39 #define TFTP_NETASCII   0              // Text files
40 #define TFTP_OCTET      1              // Binary files
41
42 /*
43  * Errors
44  */
45
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 */
60
61 /*
62  * Server support
63  */
64
65 struct tftpd_fileops {
66     int (*open)(const char *, int);
67     int (*close)(int);
68     int (*write)(int, const void *, int);
69     int (*read)(int, void *, int);
70 };
71
72 __externC int tftpd_start(int, struct tftpd_fileops *);
73 __externC int tftpd_stop(int);
74
75 /*
76  * Client support
77  */
78
79 /* IPv4 and IPv6 */
80 __externC int tftp_client_get(const char * const filename,
81                               const char * const server, 
82                               const int port, 
83                               char * buff, 
84                               int len,
85                               const int mode, 
86                               int * const err);
87
88 __externC int tftp_client_put(const char * const filename,
89                               const char * const server, 
90                               const int port, 
91                               const char * buf, 
92                               int len, 
93                               const int mode, 
94                               int * const err);
95
96 /* IPv4 only */
97 __externC int tftp_get(const char * const filename, 
98                        const struct sockaddr_in * const server, 
99                        char * buf, 
100                        int len, 
101                        const int mode, 
102                        int * const error);
103
104 __externC int tftp_put(const char * const filename, 
105                        const struct sockaddr_in * const server, 
106                        const char * buffer, 
107                        int len, 
108                        const int mode, 
109                        int * const err);
110
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
114
115 #endif // _TFTP_SUPPORT_H_