提交 84bf0602 编写于 作者: B bernard.xiong

tftp put is ok.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@191 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 18bb6d8a
...@@ -166,9 +166,13 @@ void tftp_put(const char* host, const char* dir, const char* filename) ...@@ -166,9 +166,13 @@ void tftp_put(const char* host, const char* dir, const char* filename)
tftp_buffer[3] = block_number & 0xff; tftp_buffer[3] = block_number & 0xff;
lwip_sendto(sock_fd, tftp_buffer, length + 4, 0, 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 */ /* receive ack */
length = lwip_recvfrom(sock_fd, tftp_buffer, sizeof(tftp_buffer), 0, 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) ...@@ -177,10 +181,11 @@ void tftp_put(const char* host, const char* dir, const char* filename)
{ {
if ((tftp_buffer[0] == 0 && if ((tftp_buffer[0] == 0 &&
tftp_buffer[1] == TFTP_ACK && tftp_buffer[1] == TFTP_ACK &&
tftp_buffer[3] == (block_number >> 8) & 0xff) && tftp_buffer[2] == (block_number >> 8) & 0xff) &&
tftp_buffer[2] == (block_number & 0xff)) tftp_buffer[3] == (block_number & 0xff))
{ {
block_number ++; block_number ++;
rt_kprintf("#");
} }
else else
{ {
...@@ -188,6 +193,11 @@ void tftp_put(const char* host, const char* dir, const char* filename) ...@@ -188,6 +193,11 @@ void tftp_put(const char* host, const char* dir, const char* filename)
break; break;
} }
} }
else if (length == 0)
{
rt_kprintf("server timeout\n");
break;
}
} }
close(fd); close(fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册