Add's support for TFTP protocol parsing. More...

Detailed Description

Add's support for TFTP protocol parsing.

Files

file  tftp.h
 TFTP support library.
 

Macros

#define GNRC_TFTP_MAX_FILENAME_LEN   (64)
 The maximum allowed length of the transfer filename.
 
#define GNRC_TFTP_DEFAULT_SRC_PORT   (10690)
 The base source port to be used by TFTP.
 
#define GNRC_TFTP_DEFAULT_DST_PORT   (69)
 The default destination port of the TFTP server.
 
#define GNRC_TFTP_MAX_TRANSFER_UNIT   (512)
 The maximum allowed data bytes in the data packet.
 
#define GNRC_TFTP_MAX_RETRIES   (5)
 The number of retries that must be made before stopping a transfer.
 
#define GNRC_TFTP_DEFAULT_TIMEOUT   (1 * US_PER_SEC)
 The default timeout of a data packet.
 

Typedefs

typedef bool(* tftp_start_cb_t) (tftp_action_t action, tftp_mode_t mode, const char *file_name, size_t *data_len)
 callback define which is called when a new server request is placed or when an client read request is made and the data length option is received More...
 
typedef int(* tftp_data_cb_t) (uint32_t offset, void *data, size_t data_len)
 callback define which is called to get or set data from/to the user application
 
typedef void(* tftp_stop_cb_t) (tftp_event_t event, const char *msg)
 callback define which is called when an transfer is stopped
 

Enumerations

enum  tftp_action_t { TFTP_READ, TFTP_WRITE }
 TFTP action to perform.
 
enum  tftp_mode_t { TTM_ASCII, TTM_OCTET, TTM_MAIL }
 TFTP Transfer modes.
 
enum  tftp_event_t { TFTP_SUCCESS, TFTP_PEER_ERROR, TFTP_INTERN_ERROR }
 TFTP stop / finish events. More...
 

Functions

int gnrc_tftp_server (tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb, bool use_options)
 Start the TFTP server. More...
 
int gnrc_tftp_server_stop (void)
 Stop the TFTP server. More...
 
int gnrc_tftp_client_read (ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode, tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb, bool use_option)
 Start an TFTP client read action from the given destination. More...
 
int gnrc_tftp_client_write (ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode, tftp_data_cb_t data_cb, size_t total_size, tftp_stop_cb_t stop_cb, bool use_option)
 Start an TFTP client write action to the given destination. More...
 

Typedef Documentation

◆ tftp_start_cb_t

typedef bool(* tftp_start_cb_t) (tftp_action_t action, tftp_mode_t mode, const char *file_name, size_t *data_len)

callback define which is called when a new server request is placed or when an client read request is made and the data length option is received

Parameters
[in]actionThe action the transfer want to perform
[in]modeThe data mode of the transfer
[in]file_nameThe filename of the file being transfered
[in/out]data_len When a read action is performed, the application must give the total transfer size of the data. When a write action is performed the total transfer size will be given.

Definition at line 128 of file tftp.h.

Enumeration Type Documentation

◆ tftp_event_t

TFTP stop / finish events.

Enumerator
TFTP_SUCCESS 

The transfer was successful.

TFTP_PEER_ERROR 

The peer send the given error.

TFTP_INTERN_ERROR 

There was an internal error.

Definition at line 111 of file tftp.h.

Function Documentation

◆ gnrc_tftp_client_read()

int gnrc_tftp_client_read ( ipv6_addr_t addr,
const char *  file_name,
tftp_mode_t  mode,
tftp_data_cb_t  data_cb,
tftp_start_cb_t  start_cb,
tftp_stop_cb_t  stop_cb,
bool  use_option 
)

Start an TFTP client read action from the given destination.

Parameters
[in]addrthe address of the server
[in]file_namethe filename of the file to get
[in]modethe transfer mode
[in]data_cbcalled for each read data block
[in]start_cbcalled if the server returns the transfer_size option
[in]stop_cbcalled if the transfer has finished
[in]use_optionwhen set the client uses the option extensions
Returns
1 on success
-1 on failure

◆ gnrc_tftp_client_write()

int gnrc_tftp_client_write ( ipv6_addr_t addr,
const char *  file_name,
tftp_mode_t  mode,
tftp_data_cb_t  data_cb,
size_t  total_size,
tftp_stop_cb_t  stop_cb,
bool  use_option 
)

Start an TFTP client write action to the given destination.

Parameters
[in]addrthe address of the server
[in]file_namethe filename of the file to write
[in]modethe transfer mode
[in]data_cbcalled to store the received block
[in]total_sizethe total size of the transfer
[in]stop_cbcalled if the server returns the transfer_size option
[in]use_optionwhen set the client uses the option extensions
Returns
1 on success
-1 on failure

◆ gnrc_tftp_server()

int gnrc_tftp_server ( tftp_data_cb_t  data_cb,
tftp_start_cb_t  start_cb,
tftp_stop_cb_t  stop_cb,
bool  use_options 
)

Start the TFTP server.

Parameters
[in]data_cbcalled for each read data block
[in]start_cbcalled if a new client connection is requested
[in]stop_cbcalled if the transfer has finished
[in]use_optionswhen set the client uses the option extensions
Returns
1 on success
-1 on failure

◆ gnrc_tftp_server_stop()

int gnrc_tftp_server_stop ( void  )

Stop the TFTP server.

Returns
1 on success
-1 on failure