123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /**
- ******************************************************************************
- * @file LwIP/LwIP_TFTP_Server/Inc/tftpserver.h
- * @author MCD Application Team
- * @brief This file is the header of tftpserver file.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© Copyright © 2016 STMicroelectronics International N.V.
- * All rights reserved.</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted, provided that the following conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of other
- * contributors to this software may be used to endorse or promote products
- * derived from this software without specific written permission.
- * 4. This software, including modifications and/or derivative works of this
- * software, must execute solely and exclusively on microcontroller or
- * microprocessor devices manufactured by or for STMicroelectronics.
- * 5. Redistribution and use of this software other than as permitted under
- * this license is void and will automatically terminate your rights under
- * this license.
- *
- * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
- * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
- * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- #ifndef __TFTPSERVER_H_
- #define __TFTPSERVER_H_
- #include "lwip/mem.h"
- #include "lwip/udp.h"
- #define TFTP_OPCODE_LEN 2
- #define TFTP_BLKNUM_LEN 2
- #define TFTP_DATA_LEN_MAX 512
- #define TFTP_DATA_PKT_HDR_LEN (TFTP_OPCODE_LEN + TFTP_BLKNUM_LEN)
- #define TFTP_ERR_PKT_HDR_LEN (TFTP_OPCODE_LEN + TFTP_ERRCODE_LEN)
- #define TFTP_ACK_PKT_LEN (TFTP_OPCODE_LEN + TFTP_BLKNUM_LEN)
- #define TFTP_DATA_PKT_LEN_MAX (TFTP_DATA_PKT_HDR_LEN + TFTP_DATA_LEN_MAX)
- #define TFTP_MAX_RETRIES 3
- #define TFTP_TIMEOUT_INTERVAL 5
- typedef struct
- {
- int op; /*WRQ */
- /* last block read */
- char data[TFTP_DATA_PKT_LEN_MAX];
- int data_len;
- /* destination ip:port */
- ip_addr_t to_ip;
- int to_port;
- /* next block number */
- int block;
- /* total number of bytes transferred */
- int tot_bytes;
- /* timer interrupt count when last packet was sent */
- /* this should be used to resend packets on timeout */
- unsigned long long last_time;
-
- }tftp_connection_args;
- /* TFTP opcodes as specified in RFC1350 */
- typedef enum {
- TFTP_RRQ = 1,
- TFTP_WRQ = 2,
- TFTP_DATA = 3,
- TFTP_ACK = 4,
- TFTP_ERROR = 5
- } tftp_opcode;
- /* TFTP error codes as specified in RFC1350 */
- typedef enum {
- TFTP_ERR_NOTDEFINED,
- TFTP_ERR_FILE_NOT_FOUND,
- TFTP_ERR_ACCESS_VIOLATION,
- TFTP_ERR_DISKFULL,
- TFTP_ERR_ILLEGALOP,
- TFTP_ERR_UKNOWN_TRANSFER_ID,
- TFTP_ERR_FILE_ALREADY_EXISTS,
- TFTP_ERR_NO_SUCH_USER,
- } tftp_errorcode;
- void IAP_tftpd_init(void);
- #endif
|