|

楼主 |
发表于 2024-11-8 13:47:07
|
显示全部楼层
/* 数据连接收到数据 */
static err_t ftpd_data_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)
{
struct ftpd_state *state = arg;
struct pbuf *q;
FRESULT fr;
UINT bw;
if (p != NULL)
{
if (state != NULL)
{
if (strcasecmp(state->cmd, "STOR") == 0)
{
LWIP_DEBUGF(FTPD_DEBUG, ("%s: %d bytes received\n", __FUNCTION__, p->tot_len));
for (q = p; q != NULL; q = q->next)
{
fr = f_write(state->fp, q->payload, q->len, &bw);
if (bw != q->len)
{
LWIP_DEBUGF(FTPD_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("%s: f_write() failed! fr=%d, q->len=%u, bw=%u\n", __FUNCTION__, fr, q->len, bw));
pbuf_free(p);
err = ftpd_free_data(state, FTPD_FREEDATA_ABORT);
state->cmdstep = FTPD_CMDSTEP_CONNABORTED;
ftpd_process_cmd(state);
return err;
}
}
}
}
tcp_recved(tpcb, p->tot_len);
pbuf_free(p);
}
else
{
if (state != NULL)
{
LWIP_DEBUGF(FTPD_DEBUG, ("FTPD data connection [%s]:%d is shutdown by the client!\n", ipaddr_ntoa(&tpcb->remote_ip), tpcb->remote_port));
ftpd_free_data(state, FTPD_FREEDATA_CLOSE);
// 通知命令处理函数, 数据连接已被客户端关闭
state->cmdstep |= FTPD_CMDSTEP_CONNSHUTDOWN;
ftpd_process_cmd(state);
}
else
LWIP_DEBUGF(FTPD_DEBUG, ("FTPD data connection [%s]:%d is closed by the client!\n", ipaddr_ntoa(&tpcb->remote_ip), tpcb->remote_port));
}
return ERR_OK;
}
贴出我认为有问题的接收函数 |
|