Go to the documentation of this file.
31 #ifndef _TFTP_SERVER_H
32 #define _TFTP_SERVER_H
39 #ifndef TFTP_SERVER_SUPPORT
40 #define TFTP_SERVER_SUPPORT ENABLED
41 #elif (TFTP_SERVER_SUPPORT != ENABLED && TFTP_SERVER_SUPPORT != DISABLED)
42 #error TFTP_SERVER_SUPPORT parameter is not valid
46 #ifndef TFTP_SERVER_STACK_SIZE
47 #define TFTP_SERVER_STACK_SIZE 650
48 #elif (TFTP_SERVER_STACK_SIZE < 1)
49 #error TFTP_SERVER_STACK_SIZE parameter is not valid
53 #ifndef TFTP_SERVER_PRIORITY
54 #define TFTP_SERVER_PRIORITY OS_TASK_PRIORITY_NORMAL
58 #ifndef TFTP_SERVER_MAX_CONNECTIONS
59 #define TFTP_SERVER_MAX_CONNECTIONS 2
60 #elif (TFTP_SERVER_MAX_CONNECTIONS < 1)
61 #error TFTP_SERVER_MAX_CONNECTIONS parameter is not valid
65 #ifndef TFTP_SERVER_TICK_INTERVAL
66 #define TFTP_SERVER_TICK_INTERVAL 500
67 #elif (TFTP_SERVER_TICK_INTERVAL < 100)
68 #error TFTP_SERVER_TICK_INTERVAL parameter is not valid
72 #ifndef TFTP_SERVER_MAX_RETRIES
73 #define TFTP_SERVER_MAX_RETRIES 5
74 #elif (TFTP_SERVER_MAX_RETRIES < 1)
75 #error TFTP_SERVER_MAX_RETRIES parameter is not valid
79 #ifndef TFTP_SERVER_TIMEOUT
80 #define TFTP_SERVER_TIMEOUT 5000
81 #elif (TFTP_SERVER_TIMEOUT < 1000)
82 #error TFTP_SERVER_TIMEOUT parameter is not valid
86 #ifndef TFTP_SERVER_FINAL_DELAY
87 #define TFTP_SERVER_FINAL_DELAY 10000
88 #elif (TFTP_SERVER_FINAL_DELAY < 1000)
89 #error TFTP_SERVER_FINAL_DELAY parameter is not valid
93 #ifndef TFTP_SERVER_BLOCK_SIZE
94 #define TFTP_SERVER_BLOCK_SIZE 512
95 #elif (TFTP_SERVER_BLOCK_SIZE < 512)
96 #error TFTP_SERVER_BLOCK_SIZE parameter is not valid
100 #ifndef TFTP_SERVER_PRIVATE_CONTEXT
101 #define TFTP_SERVER_PRIVATE_CONTEXT
105 #define TFTP_SERVER_MAX_PACKET_SIZE (sizeof(TftpDataPacket) + TFTP_SERVER_BLOCK_SIZE)
109 #define TftpClientConnection struct _TftpClientConnection
113 #define TftpServerContext struct _TftpServerContext
149 size_t offset,
const uint8_t *
data,
size_t length);
157 size_t offset, uint8_t *
data,
size_t size,
size_t *
length);
bool_t running
Operational state of the TFTP server.
error_t(* TftpServerReadFileCallback)(void *file, size_t offset, uint8_t *data, size_t size, size_t *length)
Read file callback function.
TftpClientConnection connection[TFTP_SERVER_MAX_CONNECTIONS]
Client connections.
TftpConnectionState state
Connection state.
void(* TftpServerCloseFileCallback)(void *file)
Close file callback function.
TftpServerCloseFileCallback closeFileCallback
Close file callback function.
uint16_t block
Block number.
uint16_t port
TFTP port number.
NetInterface * interface
Underlying network interface.
error_t tftpServerStart(TftpServerContext *context)
Start TFTP server.
#define TftpServerContext
void tftpServerTask(TftpServerContext *context)
TFTP server task.
TftpServerSettings * settings
User settings.
TftpServerSettings settings
User settings.
error_t tftpServerInit(TftpServerContext *context, const TftpServerSettings *settings)
TFTP server initialization.
uint8_t packet[TFTP_SERVER_MAX_PACKET_SIZE]
Incoming TFTP packet.
Structure describing socket events.
TftpServerReadFileCallback readFileCallback
Read file callback function.
TftpServerWriteFileCallback writeFileCallback
Write file callback function.
OsTaskParameters task
Task parameters.
#define TFTP_SERVER_MAX_PACKET_SIZE
OsTaskParameters taskParams
Task parameters.
Socket * socket
Listening socket.
TftpServerOpenFileCallback openFileCallback
Open file callback function.
#define TFTP_SERVER_MAX_CONNECTIONS
@ TFTP_STATE_WRITE_COMPLETE
@ TFTP_STATE_READ_COMPLETE
TftpConnectionState
TFTP connection state.
systime_t timestamp
Time stamp to manage retransmissions.
#define TFTP_SERVER_PRIVATE_CONTEXT
SocketEventDesc eventDesc[TFTP_SERVER_MAX_CONNECTIONS+1]
The events the application is interested in.
uint32_t systime_t
System time.
error_t tftpServerStop(TftpServerContext *context)
Stop TFTP server.
size_t packetLen
Length of the outgoing packet.
void *(* TftpServerOpenFileCallback)(const char_t *filename, const char_t *mode, bool_t writeAccess)
Open file callback function.
void tftpServerDeinit(TftpServerContext *context)
Release TFTP server context.
uint8_t packet[TFTP_SERVER_MAX_PACKET_SIZE]
Outgoing TFTP packet.
#define TftpClientConnection
OsTaskId taskId
Task identifier.
Definitions common to TFTP client and server.
void tftpServerGetDefaultSettings(TftpServerSettings *settings)
Initialize settings with default values.
thread_t * OsTaskId
Task identifier.
error_t(* TftpServerWriteFileCallback)(void *file, size_t offset, const uint8_t *data, size_t length)
Write file callback function.
uint_t retransmitCount
Retransmission counter.
Socket * socket
Underlying socket.
OsEvent event
Event object used to poll the sockets.