mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
tftp.c: use symbolic constant for block size
This commit is contained in:
parent
944dd5932d
commit
22f39b9d26
1 changed files with 5 additions and 2 deletions
|
@ -15,6 +15,9 @@ enum {
|
||||||
TFTP_ERROR = 5, /* Error */
|
TFTP_ERROR = 5, /* Error */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define BLOCK_SIZE 512 /* block size in bytes */
|
||||||
|
|
||||||
|
|
||||||
static int format_request(uint8_t *buf, uint16_t op, const char *filename)
|
static int format_request(uint8_t *buf, uint16_t op, const char *filename)
|
||||||
{
|
{
|
||||||
int len = strlen(filename);
|
int len = strlen(filename);
|
||||||
|
@ -63,11 +66,11 @@ static void rx_callback(uint32_t src_ip, uint16_t src_port,
|
||||||
if(block < 1) return;
|
if(block < 1) return;
|
||||||
if(opcode == TFTP_DATA) { /* Data */
|
if(opcode == TFTP_DATA) { /* Data */
|
||||||
length -= 4;
|
length -= 4;
|
||||||
offset = (block-1)*512;
|
offset = (block-1)*BLOCK_SIZE;
|
||||||
for(i=0;i<length;i++)
|
for(i=0;i<length;i++)
|
||||||
dst_buffer[offset+i] = data[i+4];
|
dst_buffer[offset+i] = data[i+4];
|
||||||
total_length += length;
|
total_length += length;
|
||||||
if(length < 512)
|
if(length < BLOCK_SIZE)
|
||||||
transfer_finished = 1;
|
transfer_finished = 1;
|
||||||
|
|
||||||
length = format_ack(packet_data, block);
|
length = format_ack(packet_data, block);
|
||||||
|
|
Loading…
Reference in a new issue