gpt4 book ai didi

c++ - 解析文本文件而不存储(tftp)

转载 作者:太空宇宙 更新时间:2023-11-04 08:47:34 25 4
gpt4 key购买 nike

我需要在下载后解析文本文件流,而不使用 tftp 协议(protocol)将文本文件保存到硬盘或 sdcard。我有有效载荷中的数据。请帮忙。

struct pbuf {

struct pbuf *next;
void *payload;
u16_t tot_len;
u16_t len;
u8_t type;
u8_t flags;
u16_t ref;

};

以下代码分配操作码和文件名。但是如何获取文件的内容呢?

/* Extract the opcode from a TFTP message in a buffer */
tftp_opcode tftp_decode_op(char *buf)
{
return (tftp_opcode)(buf[1]);
}

void tftp_extract_filename(char *fname, char *buf)
{
strcpy(fname, buf + 2);
}

最佳答案

在TFTP协议(protocol)中,你首先得到一个写请求包(操作码WRQ),然后数据在单独的数据包中(操作码DATA)。每当收到数据包时,您都需要做一些事情来处理文件的内容。如果您还没有读过 TFTP 协议(protocol),我建议您阅读一下。概述位于 http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol#Protocol_walkthrough规范(可读性很强)位于 https://www.rfc-editor.org/rfc/rfc1350 .

关于c++ - 解析文本文件而不存储(tftp),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21085543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com