Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
TFTP Client library

Data Structures

struct  tftp_data_param
 Parameters for data event. More...
 
struct  tftp_error_param
 Parameters for error event. More...
 
union  tftp_evt_param
 Defines event parameters notified along with asynchronous events to the application. More...
 
struct  tftp_evt
 Defines TFTP asynchronous event notified to the application. More...
 
struct  tftpc
 TFTP client definition to maintain information relevant to the client. More...
 

Macros

#define TFTP_BLOCK_SIZE   512
 RFC1350: the file is sent in fixed length blocks of 512 bytes.
 
#define TFTP_HEADER_SIZE   4
 RFC1350: For non-request TFTP message, the header contains 2-byte operation code plus 2-byte block number or error code.
 
#define TFTPC_MAX_BUF_SIZE   (TFTP_BLOCK_SIZE + TFTP_HEADER_SIZE)
 Maximum amount of data that can be sent or received.
 

Typedefs

typedef void(* tftp_callback_t) (const struct tftp_evt *evt)
 TFTP event notification callback registered by the application.
 

Enumerations

enum  tftp_evt_type { TFTP_EVT_DATA , TFTP_EVT_ERROR }
 TFTP Asynchronous Events notified to the application from the module through the callback registered by the application. More...
 

Functions

int tftp_get (struct tftpc *client, const char *remote_file, const char *mode)
 This function gets data from a "file" on the remote server.
 
int tftp_put (struct tftpc *client, const char *remote_file, const char *mode, const uint8_t *user_buf, uint32_t user_buf_size)
 This function puts data to a "file" on the remote server.
 

TFTP client error codes.

#define TFTPC_SUCCESS   0
 Success.
 
#define TFTPC_DUPLICATE_DATA   -1
 Duplicate data received.
 
#define TFTPC_BUFFER_OVERFLOW   -2
 User buffer is too small.
 
#define TFTPC_UNKNOWN_FAILURE   -3
 Unknown failure.
 
#define TFTPC_REMOTE_ERROR   -4
 Remote server error.
 
#define TFTPC_RETRIES_EXHAUSTED   -5
 Retries exhausted.
 

Detailed Description

Since
2.3
Version
0.1.0

Macro Definition Documentation

◆ TFTP_BLOCK_SIZE

#define TFTP_BLOCK_SIZE   512

#include <zephyr/net/tftp.h>

RFC1350: the file is sent in fixed length blocks of 512 bytes.

Each data packet contains one block of data, and must be acknowledged by an acknowledgment packet before the next packet can be sent. A data packet of less than 512 bytes signals termination of a transfer.

◆ TFTP_HEADER_SIZE

#define TFTP_HEADER_SIZE   4

#include <zephyr/net/tftp.h>

RFC1350: For non-request TFTP message, the header contains 2-byte operation code plus 2-byte block number or error code.

◆ TFTPC_BUFFER_OVERFLOW

#define TFTPC_BUFFER_OVERFLOW   -2

#include <zephyr/net/tftp.h>

User buffer is too small.

◆ TFTPC_DUPLICATE_DATA

#define TFTPC_DUPLICATE_DATA   -1

#include <zephyr/net/tftp.h>

Duplicate data received.

◆ TFTPC_MAX_BUF_SIZE

#define TFTPC_MAX_BUF_SIZE   (TFTP_BLOCK_SIZE + TFTP_HEADER_SIZE)

#include <zephyr/net/tftp.h>

Maximum amount of data that can be sent or received.

◆ TFTPC_REMOTE_ERROR

#define TFTPC_REMOTE_ERROR   -4

#include <zephyr/net/tftp.h>

Remote server error.

◆ TFTPC_RETRIES_EXHAUSTED

#define TFTPC_RETRIES_EXHAUSTED   -5

#include <zephyr/net/tftp.h>

Retries exhausted.

◆ TFTPC_SUCCESS

#define TFTPC_SUCCESS   0

#include <zephyr/net/tftp.h>

Success.

◆ TFTPC_UNKNOWN_FAILURE

#define TFTPC_UNKNOWN_FAILURE   -3

#include <zephyr/net/tftp.h>

Unknown failure.

Typedef Documentation

◆ tftp_callback_t

typedef void(* tftp_callback_t) (const struct tftp_evt *evt)

#include <zephyr/net/tftp.h>

TFTP event notification callback registered by the application.

Parameters
[in]evtEvent description along with result and associated parameters (if any).

Enumeration Type Documentation

◆ tftp_evt_type

#include <zephyr/net/tftp.h>

TFTP Asynchronous Events notified to the application from the module through the callback registered by the application.

Enumerator
TFTP_EVT_DATA 

DATA event when data is received from remote server.

Note
DATA event structure contains payload data and size.
TFTP_EVT_ERROR 

ERROR event when error is received from remote server.

Note
ERROR event structure contains error code and message.

Function Documentation

◆ tftp_get()

int tftp_get ( struct tftpc * client,
const char * remote_file,
const char * mode )

#include <zephyr/net/tftp.h>

This function gets data from a "file" on the remote server.

Parameters
clientClient information of type tftpc.
remote_fileName of the remote file to get.
modeTFTP Client "mode" setting.
Return values
Thesize of data being received if the operation completed successfully.
TFTPC_BUFFER_OVERFLOWif the file is larger than the user buffer.
TFTPC_REMOTE_ERRORif the server failed to process our request.
TFTPC_RETRIES_EXHAUSTEDif the client timed out waiting for server.
-EINVALif client is NULL.
Note
This function blocks until the transfer is completed or network error happens. The integrity of the client structure must be ensured until the function returns.

◆ tftp_put()

int tftp_put ( struct tftpc * client,
const char * remote_file,
const char * mode,
const uint8_t * user_buf,
uint32_t user_buf_size )

#include <zephyr/net/tftp.h>

This function puts data to a "file" on the remote server.

Parameters
clientClient information of type tftpc.
remote_fileName of the remote file to put.
modeTFTP Client "mode" setting.
user_bufData buffer containing the data to put.
user_buf_sizeLength of the data to put.
Return values
Thesize of data being sent if the operation completed successfully.
TFTPC_REMOTE_ERRORif the server failed to process our request.
TFTPC_RETRIES_EXHAUSTEDif the client timed out waiting for server.
-EINVALif client or user_buf is NULL or if user_buf_size is zero.
Note
This function blocks until the transfer is completed or network error happens. The integrity of the client structure must be ensured until the function returns.