]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/net/common/v2_0/include/tftp_support.h
Initial revision
[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(char *, char *, int, char *, int, int, int *);
81 __externC int tftp_client_put(char *, char *, int, char *, int, int, int *);
82
83 /* IPv4 only */
84 __externC int tftp_get(char *, struct sockaddr_in *, char *, int, int, int *);
85 __externC int tftp_put(char *, struct sockaddr_in *, char *, int, int, int *);
86
87 #define TFTP_TIMEOUT_PERIOD  5          // Seconds between retries
88 #define TFTP_TIMEOUT_MAX    50          // Max timeouts over all blocks
89 #define TFTP_RETRIES_MAX     5          // retries per block before giving up
90
91 #endif // _TFTP_SUPPORT_H_