RTEMS 6.1-rc6
Loading...
Searching...
No Matches
Data Structures | Macros | Functions

This source file contains the implementation of a Trivial File Transfer Protocol (TFTP) client library. More...

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <rtems.h>
#include <rtems/tftp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "tftp_driver.h"

Data Structures

union  tftpPacket
 
struct  tftpPacket::tftpRWRQ
 
struct  tftpPacket::tftpDATA
 
struct  tftpPacket::tftpACK
 
struct  tftpPacket::tftpOACK
 
struct  tftpPacket::tftpERROR
 
struct  tftpStream
 

Macros

#define UDP_PORT_BASE   3180
 
#define PACKET_FIRST_TIMEOUT_MILLISECONDS   400L
 
#define TFTP_WINDOW_SIZE_MIN   1
 
#define TFTP_BLOCK_SIZE_MIN   8
 
#define TFTP_BLOCK_SIZE_MAX   65464
 
#define TFTP_BLOCK_SIZE_OPTION   "blksize"
 
#define TFTP_WINDOW_SIZE_OPTION   "windowsize"
 
#define TFTP_DECIMAL_BASE   10
 
#define TFTP_DEFAULT_SERVER_PORT   69
 
#define TFTP_RFC7440_DATA_RETRANSMISSIONS   6
 
#define TFTP_RFC7440_TIMEOUT_MILLISECONDS   1000
 
#define TFTP_OPCODE_RRQ   1
 
#define TFTP_OPCODE_WRQ   2
 
#define TFTP_OPCODE_DATA   3
 
#define TFTP_OPCODE_ACK   4
 
#define TFTP_OPCODE_ERROR   5
 
#define TFTP_OPCODE_OACK   6
 
#define TFTP_ERROR_CODE_NOT_DEFINED   0
 
#define TFTP_ERROR_CODE_NOT_FOUND   1
 
#define TFTP_ERROR_CODE_NO_ACCESS   2
 
#define TFTP_ERROR_CODE_DISK_FULL   3
 
#define TFTP_ERROR_CODE_ILLEGAL   4
 
#define TFTP_ERROR_CODE_UNKNOWN_ID   5
 
#define TFTP_ERROR_CODE_FILE_EXISTS   6
 
#define TFTP_ERROR_CODE_NO_USER   7
 
#define TFTP_ERROR_CODE_OPTION_NEGO   8
 
#define GOT_EXPECTED_PACKET   0
 
#define GOT_DUPLICATE_OF_CURRENT_PACKET   -1
 
#define GOT_OLD_PACKET   -2
 
#define GOT_FIRST_OUT_OF_ORDER_PACKET   -3
 
#define GET_PACKET_DONT_WAIT   -1
 
#define DO_NOT_SEND_PACKET   0
 
#define PKT_SIZE_FROM_BLK_SIZE(_blksize)   ((_blksize) + 2 * sizeof (uint16_t))
 
#define BLK_SIZE_FROM_PKT_SIZE(_pktsize)   ((_pktsize) - 2 * sizeof (uint16_t))
 
#define MUST_SEND_OPTIONS(_options)
 

Functions

void tftp_initialize_net_config (tftp_net_config *config)
 Set all members of a tftp_net_config structure to their default values.
 
int tftp_open (const char *hostname, const char *path, bool is_for_reading, const tftp_net_config *config, void **tftp_handle)
 Opens and starts a TFTP client session to read or write a single file.
 
ssize_t tftp_read (void *tftp_handle, void *buffer, size_t count)
 Read data from a TFTP server.
 
int tftp_close (void *tftp_handle)
 Close a TFTP client connection.
 
ssize_t tftp_write (void *tftp_handle, const void *buffer, size_t count)
 Write data to a TFTP server.
 
void _Tftp_Destroy (void *tftp_handle)
 Free the resources associated with a TFTP client connection.
 

Detailed Description

This source file contains the implementation of a Trivial File Transfer Protocol (TFTP) client library.

The code in this file provides the ability to read files from and to write files to remote servers using the Trivial File Transfer Protocol (TFTP). It is used by the TFTP file system and tested through its test suite. The following RFCs are implemented:

Macro Definition Documentation

◆ MUST_SEND_OPTIONS

#define MUST_SEND_OPTIONS (   _options)
Value:
(\
(_options).block_size != TFTP_RFC1350_BLOCK_SIZE || \
(_options).window_size != TFTP_RFC1350_WINDOW_SIZE )
#define TFTP_RFC1350_BLOCK_SIZE
This block size meets RFC 1350 and avoids the sending of the blksize option to the TFTP server.
Definition: tftp.h:146
#define TFTP_RFC1350_WINDOW_SIZE
This window size avoids the sending of the windowsize option to the TFTP server.
Definition: tftp.h:155