/** * @brief sends next data block during TFTP READ operation * @param upcb: pointer on a udp pcb * @param args: pointer on structure of type tftp_connection_args * @param to_ip: pointer on remote IP address * @param to_port: pointer on remote udp port * @retval None */ void tftp_send_next_block(struct udp_pcb *upcb, tftp_connection_args *args, struct ip_addr *to_ip, u16_t to_port) { /* Function to read 512 bytes from the file to send (file_SD), put them * in "args->data" and return the number of bytes read */ f_read(&file_SD, (uint8_t*)args->data, TFTP_DATA_LEN_MAX, (UINT*)(&args->data_len)); /* NOTE: We need to send data packet even if args->data_len = 0*/ /* sEndTransferthe data */ tftp_send_data_packet(upcb, to_ip, to_port, args->block, args->data, args->data_len); }
void tftp_send_next_block(struct udp_pcb *upcb, tftp_connection_args *args, struct ip_addr *to_ip, u16_t to_port) { /* Function to read 512 bytes from the file to sEndTransfer(file_SD), put them * in "args->data" and return the number of bytes read */ args->data_len = file_read(&file_SD, TFTP_DATA_LEN_MAX, (euint8*)args->data); /* NOTE: We need to sEndTransferanother data packet even if args->data_len = 0 The reason for this is as follows: 1) This function is only ever called if the previous packet payload was 512 bytes. 2) If args->data_len = 0 then that means the file being sent is an exact multiple of 512 bytes. 3) RFC1350 specifically states that only a payload of <= 511 can EndTransfera transfer. 4) Therefore, we must sEndTransferanother data message of length 0 to complete the transfer. */ /* sEndTransferthe data */ tftp_send_data_packet(upcb, to_ip, to_port, args->block, args->data, args->data_len); }