Embedded Xinu Operating System
An ongoing research project and educational operating system.
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
Functions
TFTP client

Trivial File Transfer Protocol client. More...

Functions

syscall tftpGet (const char *filename, const struct netaddr *local_ip, const struct netaddr *server_ip, tftpRecvDataFunc recvDataFunc, void *recvDataCtx)
 
syscall tftpGetIntoBuffer (const char *filename, const struct netaddr *local_ip, const struct netaddr *server_ip, uint *len_ret)
 

Detailed Description

Trivial File Transfer Protocol client.

Function Documentation

syscall tftpGet ( const char *  filename,
const struct netaddr *  local_ip,
const struct netaddr *  server_ip,
tftpRecvDataFunc  recvDataFunc,
void *  recvDataCtx 
)

Download a file from a remote server using TFTP and passes its contents, block-by-block, to a callback function. This callback function can do whatever it wants with the file data, such as store it all into a buffer or write it to persistent storage.

Parameters
[in]filenameName of the file to download.
[in]local_ipLocal protocol address to use for the connection.
[in]server_ipRemote protocol address to use for the connection (address of TFTP server).
[in]recvDataFuncCallback function that will be passed the file data block-by-block. For each call of the callback function, the data (first) argument will be set to a pointer to the next block of data and the len (second) argument will be set to the block's length. All data blocks will be the same size, except possibly the last, which can be anywhere from 0 bytes up to the size of the previous block(s) if any.
In the current implementation, the block size (other than possibly for the last block) is fixed at 512 bytes. However, implementations of this callback SHOULD handle larger block sizes since tftpGet() could be extended to support TFTP block size negotiation.
This callback is expected to return ::OK if successful. If it does not return ::OK, the TFTP transfer is aborted and tftpGet() returns this value.
[in]recvDataCtxExtra parameter that will be passed literally to recvDataFunc.
Returns
::OK on success; ::SYSERR if the TFTP transfer times out or fails, or if one of several other errors occur; or the value returned by recvDataFunc, if it was not ::OK.
syscall tftpGetIntoBuffer ( const char *  filename,
const struct netaddr *  local_ip,
const struct netaddr *  server_ip,
uint *  len_ret 
)

Download a file from a remote server using TFTP and allocates and return an in-memory buffer containing the file contents.

Parameters
[in]filenameName of the file to download.
[in]local_ipLocal protocol address to use for the connection.
[in]server_ipRemote protocol address to use for the connection (address of TFTP server).
[out]len_retOn success, the length of the file in bytes, which is also the length of the returned buffer, is written into this location.
Returns
On success, returns a pointer (cast to an int) to a buffer containing the contents of the downloaded file. This buffer is allocated with memget() and therefore can be freed using memfree(). On out-of-memory, timeout, file not found, or other error, returns ::SYSERR.