我需要在下载后解析文本文件流,而不使用 tftp 协议将文本文件保存到硬盘或 SD 卡。我有有效载荷中的数据。请帮忙。
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);
}