Zephyr API Documentation  3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tftp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 InnBlue
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
16#ifndef ZEPHYR_INCLUDE_NET_TFTP_H_
17#define ZEPHYR_INCLUDE_NET_TFTP_H_
18
19#include <zephyr/kernel.h>
20#include <zephyr/net/socket.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
32#define TFTP_BLOCK_SIZE 512
33
38#define TFTP_HEADER_SIZE 4
39
41#define TFTPC_MAX_BUF_SIZE (TFTP_BLOCK_SIZE + TFTP_HEADER_SIZE)
42
47#define TFTPC_SUCCESS 0
48#define TFTPC_DUPLICATE_DATA -1
49#define TFTPC_BUFFER_OVERFLOW -2
50#define TFTPC_UNKNOWN_FAILURE -3
51#define TFTPC_REMOTE_ERROR -4
52#define TFTPC_RETRIES_EXHAUSTED -5
68
75};
76
81};
82
85 char *msg;
86 int code;
87};
88
96
99};
100
102struct tftp_evt {
105
108};
109
118typedef void (*tftp_callback_t)(const struct tftp_evt *evt);
119
127struct tftpc {
130
133
136};
137
154int tftp_get(struct tftpc *client,
155 const char *remote_file, const char *mode);
156
174int tftp_put(struct tftpc *client,
175 const char *remote_file, const char *mode,
176 const uint8_t *user_buf, uint32_t user_buf_size);
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif /* ZEPHYR_INCLUDE_NET_TFTP_H_ */
183
int tftp_get(struct tftpc *client, const char *remote_file, const char *mode)
This function gets data from a "file" on the remote server.
tftp_evt_type
TFTP Asynchronous Events notified to the application from the module through the callback registered ...
Definition: tftp.h:61
#define TFTPC_MAX_BUF_SIZE
Maximum amount of data that can be sent or received.
Definition: tftp.h:41
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.
void(* tftp_callback_t)(const struct tftp_evt *evt)
TFTP event notification callback registered by the application.
Definition: tftp.h:118
@ TFTP_EVT_ERROR
ERROR event when error is received from remote server.
Definition: tftp.h:74
@ TFTP_EVT_DATA
DATA event when data is received from remote server.
Definition: tftp.h:67
Public kernel APIs.
BSD Sockets compatible API definitions.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Generic sockaddr struct.
Definition: net_ip.h:385
Parameters for data event.
Definition: tftp.h:78
uint32_t len
Length of binary data.
Definition: tftp.h:80
uint8_t * data_ptr
Pointer to binary data.
Definition: tftp.h:79
Parameters for error event.
Definition: tftp.h:84
char * msg
Error message.
Definition: tftp.h:85
int code
Error code.
Definition: tftp.h:86
Defines TFTP asynchronous event notified to the application.
Definition: tftp.h:102
enum tftp_evt_type type
Identifies the event.
Definition: tftp.h:104
union tftp_evt_param param
Contains parameters (if any) accompanying the event.
Definition: tftp.h:107
TFTP client definition to maintain information relevant to the client.
Definition: tftp.h:127
tftp_callback_t callback
Event notification callback.
Definition: tftp.h:132
struct sockaddr server
Socket address pointing to the remote TFTP server.
Definition: tftp.h:129
uint8_t tftp_buf[(512+4)]
Buffer for internal usage.
Definition: tftp.h:135
Defines event parameters notified along with asynchronous events to the application.
Definition: tftp.h:93
struct tftp_error_param error
Parameters accompanying TFTP_EVT_ERROR event.
Definition: tftp.h:98
struct tftp_data_param data
Parameters accompanying TFTP_EVT_DATA event.
Definition: tftp.h:95