📄 tftpc.h
字号:
/*
*Copyright (c) 2000-2002 Viola Systems Ltd.
*All rights reserved.
*
*Redistribution and use in source and binary forms, with or without
*modification, are permitted provided that the following conditions
*are met:
*
*1. Redistributions 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. The end-user documentation included with the redistribution, if
*any, must include the following acknowledgment:
* "This product includes software developed by Viola
* Systems (http://www.violasystems.com/)."
*
*Alternately, this acknowledgment may appear in the software itself,
*if and wherever such third-party acknowledgments normally appear.
*
*4. The names "OpenTCP" and "Viola Systems" must not be used to
*endorse or promote products derived from this software without prior
*written permission. For written permission, please contact
*opentcp@opentcp.org.
*
*5. Products derived from this software may not be called "OpenTCP",
*nor may "OpenTCP" appear in their name, without prior written
*permission of the Viola Systems Ltd.
*
*THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
*WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
*MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
*IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS 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.
*====================================================================
*
*OpenTCP is the unified open source TCP/IP stack available on a series
*of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
*
*For more information on how to network-enable your devices, or how to
*obtain commercial technical support for OpenTCP, please see
*<http://www.violasystems.com/>.
*/
/** \file tftpc.h
* \brief OpenTCP TFTP server interface file
* \author
* \li Jari Lahti (jari.lahti@violasystems.com)
* \version 1.0
* \date 7.10.2002
*
* OpenTCP TFTP server protocol function declarations, constants, etc.
*/
#ifndef INCLUDE_TFTPC_H
#define INCLUDE_TFTPC_H
#include "kernel/system.h"
/* User defined */
/* TFTPC states */
#define TFTPC_UNINITIALIZED 0
//#define TFTPC_STATE_ENABLED 1
#define TFTPC_STATE_CLOSED 1
#define TFTPC_STATE_READ_REQUEST 2
#define TFTPC_STATE_WRITE_REQUEST 3
#define TFTPC_STATE_CONNECTED 4
/* TFTP Error codes */
#define TFTPC_NOTDEFINED 0 /* Not Definet Error */
#define TFTPC_FILENOTFOUND 1 /* File Not Found */
#define TFTPC_ACCESSVIOLATION 2 /* Access Violation Error */
#define TFTPC_FILETOOLONG 3 /* File too long */
#define TFTPC_ILLEGALOPERATION 4 /* Not supported Opcode */
#define TFTPC_UNKNOWNPORT 5 /* Unknown port */
#define TFTPC_FILEEXISTED 6 /* File existed */
#define TFTPC_UNKNOWNUSER 7 /* Unknown USER */
/* TFTP Opcodes */
#define TFTPC_OPCODE_RRQ 1 /* Packet is Read Request */
#define TFTPC_OPCODE_WRQ 2 /* Packet is Write Request */
#define TFTPC_OPCODE_DATA 3 /* Data Packet */
#define TFTPC_OPCODE_ACK 4 /* ACK Packet */
#define TFTPC_OPCODE_ERROR 5 /* Error Packet */
/* TFTP transfer modes */
#define TFTPC_MODE_ASCII 0 // "netascii"
#define TFTPC_MODE_BINARY 1 // "octet"
/** \def TFTPS_FILENAME_MAXLEN
* \brief Maximum filename allowed by the TFTP server
*
* Maximum filename-length TFTP server is ready to process.
*/
#define TFTPC_FILENAME_MAXLEN 20
/** \def TFTPS_DEF_RETRIES
* \brief Default number of retries of TFTP server
*
* Number of retries of resending the data before aborting.
*/
#define TFTPC_DEF_RETRIES 4
/** \def TFTPS_TIMEOUT
* \brief Timeout (in seconds) after which socket is deleted
*
*
*/
#define TFTPC_TIMEOUT 20 /* Secs */
#define UDP_APP_OFFSET 0 //Just for porting
/** \def TFTPS_SERVERPORT
* \brief Default server port for TFTP server
*
* TFTP server will use this UDP port to listen for incoming traffic.
*/
/* SMTP Server Information */
#define TFTP_SERVER_IP 0x0a8a1fa0 //10.138.31.160
#define TFTP_SERVER_PORT 69
#define TFTP_DEFAULT_FILENAME "t4_firmware.bin"
#define TFTP_PUT_FILENAME "t4_put.bin"
#define TFTP_DEFAULT_MODE TFTPC_MODE_BINARY
//#define TFTP_GET_BUF_SIZE 65535 //32K
#define TFTP_PUT_MAX_BLOCK 128 //128*512=64K
/* Prototypes */
INT8 tftpc_connect (UINT32 server_ip, UINT16 server_port, UINT8 request_type);
void tftpc_run(void);
INT8 tftpc_eventlistener(void);
void tftpc_send_request (UINT8 request_type, UINT8 *tftp_filename, UINT8 tftp_mode);
void tftpc_send_ACK(void);
void tftpc_send_ERROR(UINT8 errno);
void tftpc_send_data(UINT8 *buf, UINT16 buf_len);
void tftpc_disconnect(void);
//void tftpc_multiconnect_test(void); //Just for test
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -