1 /*This file has been prepared for Doxygen automatic documentation generation.*/
2 /*! \file *********************************************************************
4 * \brief Basic TFTP Server for AVR32 UC3.
6 * - Compiler: GNU GCC for AVR32
7 * - Supported devices: All AVR32 devices can be used.
10 * \author Atmel Corporation: http://www.atmel.com \n
11 * Support and FAQ: http://support.atmel.no/
13 *****************************************************************************/
15 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are met:
20 * 1. Redistributions of source code must retain the above copyright notice,
21 * this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright notice,
24 * this list of conditions and the following disclaimer in the documentation
25 * and/or other materials provided with the distribution.
27 * 3. The name of ATMEL may not be used to endorse or promote products derived
28 * from this software without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
33 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
34 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
39 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #ifndef BASIC_TFTP_SERVER_H
44 #define BASIC_TFTP_SERVER_H
46 #include "portmacro.h"
53 #define TFTP_NETASCII 0 // Text files
54 #define TFTP_OCTET 1 // Binary files
60 // These initial 7 are passed across the net in "ERROR" packets.
61 #define TFTP_ENOTFOUND 1 /* file not found */
62 #define TFTP_EACCESS 2 /* access violation */
63 #define TFTP_ENOSPACE 3 /* disk full or allocation exceeded */
64 #define TFTP_EBADOP 4 /* illegal TFTP operation */
65 #define TFTP_EBADID 5 /* unknown transfer ID */
66 #define TFTP_EEXISTS 6 /* file already exists */
67 #define TFTP_ENOUSER 7 /* no such user */
68 // These extensions are return codes in our API, *never* passed on the net.
69 #define TFTP_TIMEOUT 8 /* operation timed out */
70 #define TFTP_NETERR 9 /* some sort of network error */
71 #define TFTP_INVALID 10 /* invalid parameter */
72 #define TFTP_PROTOCOL 11 /* protocol violation */
73 #define TFTP_TOOLARGE 12 /* file is larger than buffer */
75 #define TFTP_TIMEOUT_PERIOD 5 // Seconds between retries
76 #define TFTP_TIMEOUT_MAX 50 // Max timeouts over all blocks
77 #define TFTP_RETRIES_MAX 5 // retries per block before giving up
82 char *s_name; /* official service name */
83 char **s_aliases; /* alias list */
84 int s_port; /* port number */
85 char *s_proto; /* protocol to use */
91 * Trivial File Transfer Protocol (IEN-133)
93 #define SEGSIZE 512 /* data segment size */
99 #define th_block th_u.tu_block
100 #define th_code th_u.tu_code
101 #define th_stuff th_u.tu_stuff
102 #define th_msg th_data
107 #define EUNDEF 0 /* not defined */
108 #define ENOTFOUND 1 /* file not found */
109 #define EACCESS 2 /* access violation */
110 #define ENOSPACE 3 /* disk full or allocation exceeded */
111 #define EBADOP 4 /* illegal TFTP operation */
112 #define EBADID 5 /* unknown transfer ID */
113 #define EEXISTS 6 /* file already exists */
114 #define ENOUSER 7 /* no such user */
118 #define RRQ 01 /* read request */
119 #define WRQ 02 /* write request */
120 #define DATA 03 /* data packet */
121 #define ACK 04 /* acknowledgement */
122 #define ERROR 05 /* error code */
128 short th_opcode; /* packet type */
130 unsigned short tu_block; /* block # */
131 short tu_code; /* error code */
132 char tu_stuff[1]; /* request packet stuff */
135 __attribute__ ((packed))
138 char th_data[1]; /* data or error string */
141 __attribute__ ((packed))
148 /* The function that implements the TFTP server task. */
149 portTASK_FUNCTION_PROTO( vBasicTFTPServer, pvParameters );