📄 tftpc.h
字号:
* had returned with TFTP_OK.
*
* Input: None
*
* Output: None
*
* Side Effects: None
*
* Overview: If file is opened in read mode, it makes sure
* that last ACK is sent to server
* If file is opened in write mode, it makes sure
* that last block is sent out to server and
* waits for server to respond with ACK.
*
* Note: TFTPIsFileClosed() must be called to confirm
* if file was really closed.
********************************************************************/
void TFTPCloseFile(void);
/*********************************************************************
* Function: TFTP_RESULT TFPTIsFileClosed(void)
*
* PreCondition: TFTPCloseFile() is already called.
*
* Input: None
*
* Output: TFTP_OK if file was successfully closdd
*
* TFTP_RETRY if file mode was Write and remote
* server did not receive last packet.
* Application must retry with last block.
*
* TFTP_TIMEOUT if all attempts were exhausted
* in closing file.
*
* TFTP_ERROR if remote server sent an error
* in response to last block.
* Actual error code may be read by calling
* TFTPGetError()
*
* TFTP_NOT_READY if file is not closed yet.
*
* Side Effects: None
*
* Overview: If file mode is Read, it simply makes that
* last block is acknowledged.
* If file mode is Write, it waits for server ack.
* If no ack was received within specified timeout
* instructs appliaction to resend last block.
* It keeps track of retries and declares timeout
* all attempts were exhausted.
*
* Note: None
********************************************************************/
TFTP_RESULT TFTPIsFileClosed(void);
/*********************************************************************
* Function: TFTP_RESULT TFTPIsGetReady(void)
*
* PreCondition: TFTPOpenFile() is called with TFTP_FILE_MODE_READ
* and TFTPIsFileOpened() returned with TRUE.
*
* Input: None
*
* Output: TFTP_OK if it there is more data byte available
* to read
*
* TFTP_TIMEOUT if timeout occurred waiting for
* new data.
*
* TFTP_END_OF_FILE if end of file has reached.
*
* TFTP_ERROR if remote server returned ERROR.
* Actual error code may be read by calling
* TFTPGetError()
*
* TFTP_NOT_READY if still waiting for new data.
*
* Side Effects: None
*
* Overview: Waits for data block. If data block does not
* arrive within specified timeout, it automatically
* sends out ack for previous block to remind
* server to send next data block.
* If all attempts are exhausted, it returns with
* TFTP_TIMEOUT.
*
* Note: By default, this funciton uses "octet" or binary
* mode of file transfer.
********************************************************************/
TFTP_RESULT TFTPIsGetReady(void);
/*********************************************************************
* Function: BYTE TFTPGet(void)
*
* PreCondition: TFTPOpenFile() is called with TFTP_FILE_MODE_READ
* and TFTPIsGetReady() = TRUE
*
* Input: None
*
* Output: data byte as received from remote server.
*
* Side Effects: None
*
* Overview: Fetches next data byte from TFTP socket.
* If end of data block is reached, it issues
* ack to server so that next data block can be
* received.
*
* Note: Use this function to read file from server.
********************************************************************/
BYTE TFTPGet(void);
/*********************************************************************
* Function: TFTP_RESULT TFTPIsPutReady(void)
*
* PreCondition: TFTPOpenFile() is called with TFTP_FILE_MODE_WRITE
* and TFTPIsFileOpened() returned with TRUE.
*
* Input: None
*
* Output: TFTP_OK if it is okay to write more data byte.
*
* TFTP_TIMEOUT if timeout occurred waiting for
* ack from server
*
* TFTP_RETRY if all server did not send ack
* on time and application needs to resend
* last block.
*
* TFTP_ERROR if remote server returned ERROR.
* Actual error code may be read by calling
* TFTPGetError()
*
* TFTP_NOT_READY if still waiting...
*
* Side Effects: None
*
* Overview: Waits for ack from server. If ack does not
* arrive within specified timeout, it it instructs
* application to retry last block by returning
* TFTP_RETRY.
*
* If all attempts are exhausted, it returns with
* TFTP_TIMEOUT.
*
* Note: None
********************************************************************/
TFTP_RESULT TFTPIsPutReady(void);
/*********************************************************************
* Function: void TFTPPut(BYTE c)
*
* PreCondition: TFTPOpenFile() is called with TFTP_FILE_MODE_WRITE
* and TFTPIsPutReady() = TRUE
*
* Input: c - Data byte that is to be written
*
* Output: None
*
* Side Effects: None
*
* Overview: Puts given data byte into TFTP socket.
* If end of data block is reached, it
* transmits entire block.
*
* Note: Use this function to write file to server.
********************************************************************/
void TFTPPut(BYTE c);
/*********************************************************************
* Macro: WORD TFTPGetError(void)
*
* PreCondition: One of the TFTP function returned with
* TFTP_ERROR result.
*
* Input: None
*
* Output: Error code as returned by remote server.
* Application may use TFTP_ACCESS_ERROR enum. to
* decode standard error code.
*
* Side Effects: None
*
* Overview: Returns previously saved error code.
*
* Note: None
********************************************************************/
#define TFTPGetError() (_tftpError)
extern WORD _tftpError;
/*********************************************************************
* Function: TFTP_RESULT TFTP_Connect(IP_ADDR *ServerIP)
*
* PreCondition:
*
*
* Input: ServerIP - Remote server IP address
*
* Output: TFTP_OK if connecting remote server success.
* TFTP_ERROR if connecting timeout is three times.
*
* Side Effects: None
*
* Overview: TFTP client use ServerIP to setup a connection with
* remote server.
*
* Note: None
********************************************************************/
TFTP_RESULT TFTP_Connect(IP_ADDR *ServerIP);
/*********************************************************************************************
* Function: TFTP_RESULT TFTP_Operate(char* fileName,
* TFTP_FILE_MODE operateMode, BYTE* buff)
*
* PreCondition: TFTP_Connect() is called, and return TFTP_OK
*
*
* Input: fileName - the file's name on the remote server root directory
* operateMode - send a read/write file request
* buff - ram address to receive/send the file's data
* length - under reading mode ,length means the receive buff size.
* - under writing mode ,length means the send byte numbers
*
* Output: TFTP_OK if operation success.
* TFTP_ERROR if operation error.
*
* Side Effects: None
*
* Overview: TFTP client use ServerIP to setup a connection with
* remote server.
*
* Note: None
********************************************************************************************/
TFTP_RESULT TFTP_Operate(char* fileName, TFTP_FILE_MODE operateMode, BYTE* buff,unsigned int length);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -