Embedded Xinu Operating System
An ongoing research project and educational operating system.
|
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) |
Trivial File Transfer Protocol client.
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.
[in] | filename | Name of the file to download. |
[in] | local_ip | Local protocol address to use for the connection. |
[in] | server_ip | Remote protocol address to use for the connection (address of TFTP server). |
[in] | recvDataFunc | Callback 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] | recvDataCtx | Extra parameter that will be passed literally to recvDataFunc . |
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.
[in] | filename | Name of the file to download. |
[in] | local_ip | Local protocol address to use for the connection. |
[in] | server_ip | Remote protocol address to use for the connection (address of TFTP server). |
[out] | len_ret | On success, the length of the file in bytes, which is also the length of the returned buffer, is written into this location. |