BeRTOS
|
TFTP protocol implementation. More...
Go to the source code of this file.
Functions | |
int | tftp_init (TftpSession *ctx, unsigned short port, mtime_t timeout) |
Init a server session. | |
KFile * | tftp_listen (TftpSession *ctx, char *filename, size_t len, TftpOpenMode *mode) |
Listen for incoming tftp sessions. |
TFTP protocol implementation.
This module implements a TFTP server with a handy KFile interface. The call to tftp_listen() will block until a client tries to connect, then it returns a KFile. If you want to accept the transfer, start reading from the handle and the transfer will continue. Otherwise, don't access it and immediately call kfile_close(). Close the KFile when you're done.
The usage pattern is as follows:
// initialize a TFTP session tftp_init(); // start listening for connections KFile *f = tftp_listen(); // now you can check the returned file name // and change behaviour at runtime if (!strcmp(filename, "firmware.bin")) // do something else if (!strcmp(filename, "conf.ini")) // update the configuration kfile_close(f);
Definition in file tftp.h.
int tftp_init | ( | TftpSession * | ctx, |
unsigned short | port, | ||
mtime_t | timeout | ||
) |
KFile* tftp_listen | ( | TftpSession * | ctx, |
char * | filename, | ||
size_t | len, | ||
TftpOpenMode * | mode | ||
) |