ES TFTP Packet
file: es_tftp_pkt.h
Description: ES TFTP Packet
Opcodes
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_ACESS_VIOLATION
Defines
Packets
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;
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_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.