STM32F4怎么用LWIP协议栈里面的TFTP协议上传文件
第一步:用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;
};