ES TFTP Packet

file: es_tftp_pkt.h

Description: ES TFTP Packet

Opcodes

enumerator es_tftp_opcode_t
[source]

DEFINES

enumerator ES_TFTP_ACK
[source]

Acknowedge packet.

enumerator ES_TFTP_DATA
[source]

Data packet.

enumerator ES_TFTP_ERROR
[source]

Error packet.

enumerator ES_TFTP_RRQ
[source]

Read request. Request a transfer of a file from the server to the client

enumerator ES_TFTP_WRQ
[source]

Write request. Request a transfer of a file from the client to the server

Error Codes

enumerator es_tftp_err_code_t
[source]
enumerator ES_TFTP_ERR_ACESS_VIOLATION
[source]

This error is seen when we ask for a file on which we do not have the right to read or write.

enumerator ES_TFTP_ERR_DISK_FULL_OR_ALLOCATION_EXCEEDED
[source]

TFTP client receives this error when there is limited storage area on the server.

enumerator ES_TFTP_ERR_FILE_NOT_FOUND
[source]

The client receives this error code when the requested file does not exist.

enumerator ES_TFTP_ERR_ILLEGAL_TFTP_OPERATION
[source]

Any TFTP packet does not follow the RFC is called illegal. A packet with an unknown opcode, a packet with a malformed payload, or a packet that is out of sequence with the normal flow of commands/responses would all be considered “illegal”

enumerator ES_TFTP_ERR_NO_SUCH_USER
[source]

Unused Once the protocol was first adopted, it supported three modes of transferring, which were netascii, octet and mail mode, which was used for sending files to an email address. This error is received when the recipient username does not exist on the server. This mode is not used anymore. .. note:: We do not support the mode field.

enumerator ES_TFTP_ERR_UNKNOWN_TRANSFER_ID
[source]

When a TFTP client sends a duplicate read request (typically this happens when the first read request times out), the requests may create an unexpected situation on the server.

Defines

ES_TFTP_BLOCK_SIZE
[source]
ES_TFTP_FILENAME_MAX_SIZE
[source]
ES_TFTP_ERR_MSG_MAX_SIZE
[source]
ES_TFTP_PKT_MAX_SIZE
[source]
ES_TFTP_PKT_MIN_SIZE
[source]
ES_TFTP_BLOCK_N_MAX_VALUE
[source]

Packets

ES TFTP packet structure
 1 /* ES TFTP Packet structure */
 2 typedef struct __attribute__((__packed__)) _es_tftp_pkt_t {
 3       uint8_t opcode; /**< Packet type @see es_tftp_opcode_t */
 4       union {
 5             es_tftp_request_t request;
 6             es_tftp_data_t data;
 7             es_tftp_ack_t ack;
 8             es_tftp_err_t err;
 9        };
10 } es_tftp_pkt_t;
struct es_tftp_request_t
[source]

TYPEDEFS

uint8_t filename[]
[source]

File system path. Flexible array member with size x, x ∈ [1;512]

uint8_t mode
[source]

Mode (Unused)

struct es_tftp_data_t
[source]
uint8_t block[]
[source]

Data: Flexible array member with size x, x ∈ [1;512]

uint16_t block_number
[source]
struct es_tftp_ack_t
[source]
uint16_t block_number
[source]
struct es_tftp_err_t
[source]
uint8_t code
[source]

Error code. es_tftp_err_code_t

uint8_t msg[]
[source]

Error mesasge in free text format. Flexible array member with size x, x ∈ [1;512]

Interface Functions

es_tftp_pkt_t *es_tftp_ipkt_get(uint8_t *buffer, size_t buffer_len)
[source]

Get a new TFTP packet.

Note

The packet is mapped on the memory provided by buffer

Parameters:
  • buffer: – Input buffer containing TFTP packet.

  • buffer_len: – Size of the input buffer.

Returns:

: Reference to ES TFTP packet (es_tftp_pkt_t)

ssize_t es_tftp_ipkt_data_size(es_tftp_pkt_t *pkt, ssize_t buffer_len)
[source]
ssize_t es_tftp_opkt_request(uint8_t *buffer, es_tftp_opcode_t opcode, const uint8_t *filename)
[source]

Create TFTP request packet

Parameters:
  • buffer: – Storage memory for the packet

  • opcode: – Opcode RRQ or WRQ

  • filename: – Path to the file on the remote (RWQ) / local (RRQ) disk.

Returns:

: Size of the packet, -1 in case of an err.

ssize_t es_tftp_opkt_err(uint8_t *buffer, es_tftp_err_code_t err_code, const uint8_t *err_msg)
[source]

Create TFTP Error packet

es_tftp_err_code_t

Parameters:
  • buffer: – Storage memory for the packet.

  • err_code: – Error code

  • err_msg: – Error message in free text format

Returns:

: Size of the packet, -1 in case of an err.

ssize_t es_tftp_opkt_ack(uint8_t *buffer, uint16_t block_number)
[source]

Create TFTP Acknowledge packet

Parameters:
  • buffer: – Storage memory for the packet.

  • block_number: – The block number of the data packet being acknowledged.

Returns:

: Size of the packet, -1 in case of an err.

ssize_t es_tftp_opkt_data(uint8_t *buffer, uint16_t block_number, es_tftp_pkt_data_get_t data_get, void *file_handle, ssize_t *bytes_read)
[source]

Create TFTP Data packet

Parameters:
  • buffer: – Storage memory for the packet.

  • block_number: – Block number of the data packet.

  • data_get: – Function pointer of type es_tftp_pkt_data_get_t.

  • file_handle: – OS dependent file handle.

  • bytes_read: – Amount of read bytes from the file associated with file_handle.

Returns:

: Size of the packet, -1 in case of an err.