提交 5f878bb6 编写于 作者: B bernard.xiong

update tftp client code (tftp_put).

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@140 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 3c41a849
......@@ -146,22 +146,34 @@ void tftp_put(const char* host, const char* filename)
do
{
rt_uint16_t *ptr;
ptr = (rt_uint16_t*)&tftp_buffer[0];
length = read(fd, &tftp_buffer[4], 512);
if (length > 0)
{
/* make opcode and block number */
tftp_buffer[0] = 0; tftp_buffer[1] = TFTP_DATA;
tftp_buffer[2] = block_number ; tftp_buffer[3] = block_number;
*ptr = TFTP_DATA; *(ptr + 1) = block_number;
lwip_sendto(sock_fd, tftp_buffer, length + 4, 0,
(struct sockaddr *)&from_addr, fromlen);
(struct sockaddr *)&tftp_addr, fromlen);
}
else break; /* no data yet */
/* receive ack */
length = lwip_recvfrom(sock_fd, tftp_buffer, sizeof(tftp_buffer), 0,
(struct sockaddr *)&from_addr, &fromlen);
if (length > 0)
{
if (*ptr == TFTP_ACK && *(ptr + 1) == block_number)
{
block_number ++;
}
else
{
rt_kprintf("server respondes with an error\n");
break;
}
}
} while (length != 516);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册