tftp put is ok.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@191 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2009-12-03 13:12:23 +00:00
parent 18bb6d8a39
commit 84bf060294
1 changed files with 14 additions and 4 deletions

View File

@ -166,9 +166,13 @@ void tftp_put(const char* host, const char* dir, const char* filename)
tftp_buffer[3] = block_number & 0xff;
lwip_sendto(sock_fd, tftp_buffer, length + 4, 0,
(struct sockaddr *)&tftp_addr, fromlen);
(struct sockaddr *)&from_addr, fromlen);
}
else
{
rt_kprintf("done\n");
break; /* no data yet */
}
else break; /* no data yet */
/* receive ack */
length = lwip_recvfrom(sock_fd, tftp_buffer, sizeof(tftp_buffer), 0,
@ -177,10 +181,11 @@ void tftp_put(const char* host, const char* dir, const char* filename)
{
if ((tftp_buffer[0] == 0 &&
tftp_buffer[1] == TFTP_ACK &&
tftp_buffer[3] == (block_number >> 8) & 0xff) &&
tftp_buffer[2] == (block_number & 0xff))
tftp_buffer[2] == (block_number >> 8) & 0xff) &&
tftp_buffer[3] == (block_number & 0xff))
{
block_number ++;
rt_kprintf("#");
}
else
{
@ -188,6 +193,11 @@ void tftp_put(const char* host, const char* dir, const char* filename)
break;
}
}
else if (length == 0)
{
rt_kprintf("server timeout\n");
break;
}
}
close(fd);