lwip中怎样使用http协议传输文件

lwip中怎样使用http协议传输文件,第1张

第一步:用tftpserver.c中的err_t tftp_send_message(struct udp_pcb *upcb, struct ip_addr *to_ip, int to_port, char *buf, int buflen)向指定地址发送写文件请求;第二步:用tftpserver.c中的void process_tftp_request(struct pbuf *pkt_buf, struct ip_addr *addr, u16_t port)函数处理回应,如果接收到回应后,process_tftp_request函数中的int tftp_process_write(struct udp_pcb *upcb, struct ip_addr *to, int to_port, char *FileName)函数发送数据文件。基本流程就是上述所说,但是tftp_send_message()函数中的参数struct udp_pcb *upcb,数据结构非常复杂struct udp_pcb {/* Common members of all PCB types */ IP_PCB/* Protocol specific PCB members */ struct udp_pcb *next u8_t flags /* ports are in host byte order */ u16_t local_port, remote_port#if LWIP_IGMP /* outgoing network interface for multicast packets */ struct ip_addr multicast_ip#endif /* LWIP_IGMP */#if LWIP_UDPLITE /* used for UDP_LITE only */ u16_t chksum_len_rx, chksum_len_tx#endif /* LWIP_UDPLITE */ /* receive callback function * addr and port are in same byte order as in the pcb * The callback is responsible for freeing the pbuf * if it's not used any more. * * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf *makes 'addr' invalid, too. * * @param arg user supplied argument (udp_pcb.recv_arg) * @param pcb the udp_pcb which received data * @param p the packet buffer that was received * @param addr the remote IP address from which the packet was received * @param port the remote port from which the packet was received */ void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,struct ip_addr *addr, u16_t port) /* user-supplied argument for the recv callback */ void *recv_arg }

第一步:用tftpserverc中的err_t tftp_send_message(struct udp_pcb *upcb, struct ip_addr *to_ip, int to_port, char *buf, int buflen)向指定地址发送写文件请求; 第二步:用tftpserverc中的void process_tftp_request(struct pbuf *pkt_bSTM32F4怎么用LWIP协议栈里面的TFTP协议上传文件

1、要说明用的哪个版本的LwIP,不同版本的LwIP,在发送方面有所不同。2、LwIP是单片机上的TCP/IP协议,不是PC机上的TCP/IP协议,在内存使用方面要注意的。 查看更多答案>>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12105236.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存