Embedded TCP/IP stack: fnet_tftp_srv_data_handler_t

FNET

typedef fnet_int32_t(* fnet_tftp_srv_data_handler_t) (fnet_tftp_request_t request, fnet_uint8_t *data, fnet_size_t data_size, fnet_tftp_error_t *error_code, fnet_char_t **error_message, void *handler_param)

Prototype of the TFTP-server callback function prototype that is called when the TFTP server has received a new data packet (request_type equals to FNET_TFTP_REQUEST_WRITE). This callback function is also called when the TFTP server is ready to send a new data packet to the TFTP client (request_type equals to FNET_TFTP_REQUEST_READ).

Parameters
request_typeRequest type (read or write) defined by fnet_tftp_request_t.
dataPointer to the data buffer which content defined by request_type:
  • If request_type equals to FNET_TFTP_REQUEST_WRITE,
    this parameter points to the data buffer that contains data received from the remote TFTP client.
  • If request_type equals to FNET_TFTP_REQUEST_READ,
    this parameter points to the data buffer which should be filled by the application with a data that will be sent to the remote TFTP client. If the written data size is less than data_size (FNET_TFTP_DATA_SIZE_MAX), it will mean that this data packet is the last one.
data_sizeSize of the buffer pointed by the data parameter, in bytes.
error_codePointer to the error code that will be sent to the remote TFTP client. Changing of this parameter is optional, by default the error code is set to FNET_TFTP_ERROR_NOT_DEFINED.
This parameter is used only when this callback function returns FNET_ERR.
error_messagePointer to a null-terminated error message string. Changing of this parameter is optional, by default the error string is set to "Not defined".
This parameter is used only when this callback function returns FNET_ERR.
handler_paramUser-application specific parameter. It's set during the TFTP-server service initialization as part of fnet_tftp_srv_params.
Returns
  • If request_type equals to FNET_TFTP_REQUEST_WRITE,
    this function should return FNET_OK if no errors.
  • If request_type equals to FNET_TFTP_REQUEST_READ,
    this function should return number of bytes written to the buffer pointed by data. If this number is less than FNET_TFTP_DATA_SIZE_MAX, it will mean that this data packet is the last one.
  • This function should return FNET_ERR if an error occurs. The TFTP-client service will be released automatically.
See also
fnet_tftp_srv_init(), fnet_tftp_srv_params

Definition at line 146 of file fnet_tftp_srv.h.


© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net