|
|
|
@ -467,26 +467,48 @@ err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, |
|
|
|
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ |
|
|
|
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ |
|
|
|
LWIP_EVENT_ERR, NULL, 0, (err)) |
|
|
|
LWIP_EVENT_ERR, NULL, 0, (err)) |
|
|
|
#else /* LWIP_EVENT_API */ |
|
|
|
#else /* LWIP_EVENT_API */ |
|
|
|
#define TCP_EVENT_ACCEPT(pcb,err,ret) \ |
|
|
|
|
|
|
|
if((pcb)->accept != NULL) \
|
|
|
|
#define TCP_EVENT_ACCEPT(pcb,err,ret) \ |
|
|
|
(ret = (pcb)->accept((pcb)->callback_arg,(pcb),(err))) |
|
|
|
do { \
|
|
|
|
#define TCP_EVENT_SENT(pcb,space,ret) \ |
|
|
|
if((pcb)->accept != NULL) \
|
|
|
|
if((pcb)->sent != NULL) \
|
|
|
|
(ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \
|
|
|
|
(ret = (pcb)->sent((pcb)->callback_arg,(pcb),(space))) |
|
|
|
} while (0) |
|
|
|
#define TCP_EVENT_RECV(pcb,p,err,ret) \ |
|
|
|
|
|
|
|
if((pcb)->recv != NULL) \
|
|
|
|
#define TCP_EVENT_SENT(pcb,space,ret) \ |
|
|
|
{ ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
|
|
|
|
do { \
|
|
|
|
ret = ERR_OK; \
|
|
|
|
if((pcb)->sent != NULL) \
|
|
|
|
if (p) pbuf_free(p); } |
|
|
|
(ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \
|
|
|
|
#define TCP_EVENT_CONNECTED(pcb,err,ret) \ |
|
|
|
} while (0) |
|
|
|
if((pcb)->connected != NULL) \
|
|
|
|
|
|
|
|
(ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err))) |
|
|
|
#define TCP_EVENT_RECV(pcb,p,err,ret) \ |
|
|
|
#define TCP_EVENT_POLL(pcb,ret) \ |
|
|
|
do { \
|
|
|
|
if((pcb)->poll != NULL) \
|
|
|
|
if((pcb)->recv != NULL) { \
|
|
|
|
(ret = (pcb)->poll((pcb)->callback_arg,(pcb))) |
|
|
|
(ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); \
|
|
|
|
#define TCP_EVENT_ERR(errf,arg,err) \ |
|
|
|
} else { \
|
|
|
|
if((errf) != NULL) \
|
|
|
|
(ret) = ERR_OK; \
|
|
|
|
(errf)((arg),(err)) |
|
|
|
if (p != NULL) \
|
|
|
|
|
|
|
|
pbuf_free(p); \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TCP_EVENT_CONNECTED(pcb,err,ret) \ |
|
|
|
|
|
|
|
do { \
|
|
|
|
|
|
|
|
if((pcb)->connected != NULL) \
|
|
|
|
|
|
|
|
(ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TCP_EVENT_POLL(pcb,ret) \ |
|
|
|
|
|
|
|
do { \
|
|
|
|
|
|
|
|
if((pcb)->poll != NULL) \
|
|
|
|
|
|
|
|
(ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TCP_EVENT_ERR(errf,arg,err) \ |
|
|
|
|
|
|
|
do { \
|
|
|
|
|
|
|
|
if((errf) != NULL) \
|
|
|
|
|
|
|
|
(errf)((arg),(err)); \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#endif /* LWIP_EVENT_API */ |
|
|
|
#endif /* LWIP_EVENT_API */ |
|
|
|
|
|
|
|
|
|
|
|
/* This structure represents a TCP segment on the unsent and unacked queues */ |
|
|
|
/* This structure represents a TCP segment on the unsent and unacked queues */ |
|
|
|
@ -520,16 +542,23 @@ u8_t tcp_segs_free(struct tcp_seg *seg); |
|
|
|
u8_t tcp_seg_free(struct tcp_seg *seg); |
|
|
|
u8_t tcp_seg_free(struct tcp_seg *seg); |
|
|
|
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); |
|
|
|
struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); |
|
|
|
|
|
|
|
|
|
|
|
#define tcp_ack(pcb) if((pcb)->flags & TF_ACK_DELAY) { \ |
|
|
|
#define tcp_ack(pcb) \ |
|
|
|
(pcb)->flags &= ~TF_ACK_DELAY; \
|
|
|
|
do { \
|
|
|
|
(pcb)->flags |= TF_ACK_NOW; \
|
|
|
|
if((pcb)->flags & TF_ACK_DELAY) { \
|
|
|
|
tcp_output(pcb); \
|
|
|
|
(pcb)->flags &= ~TF_ACK_DELAY; \
|
|
|
|
} else { \
|
|
|
|
(pcb)->flags |= TF_ACK_NOW; \
|
|
|
|
(pcb)->flags |= TF_ACK_DELAY; \
|
|
|
|
tcp_output(pcb); \
|
|
|
|
} |
|
|
|
} \
|
|
|
|
|
|
|
|
else { \
|
|
|
|
#define tcp_ack_now(pcb) (pcb)->flags |= TF_ACK_NOW; \ |
|
|
|
(pcb)->flags |= TF_ACK_DELAY; \
|
|
|
|
tcp_output(pcb) |
|
|
|
} \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define tcp_ack_now(pcb) \ |
|
|
|
|
|
|
|
do { \
|
|
|
|
|
|
|
|
(pcb)->flags |= TF_ACK_NOW; \
|
|
|
|
|
|
|
|
tcp_output(pcb); \
|
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags); |
|
|
|
err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags); |
|
|
|
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len, |
|
|
|
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len, |
|
|
|
@ -627,22 +656,32 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ |
|
|
|
} while(0) |
|
|
|
} while(0) |
|
|
|
|
|
|
|
|
|
|
|
#else /* LWIP_DEBUG */ |
|
|
|
#else /* LWIP_DEBUG */ |
|
|
|
#define TCP_REG(pcbs, npcb) do { \ |
|
|
|
|
|
|
|
npcb->next = *pcbs; \
|
|
|
|
#define TCP_REG(pcbs, npcb) \ |
|
|
|
*(pcbs) = npcb; \
|
|
|
|
do { \
|
|
|
|
tcp_timer_needed(); \
|
|
|
|
npcb->next = *pcbs; \
|
|
|
|
} while(0) |
|
|
|
*(pcbs) = npcb; \
|
|
|
|
#define TCP_RMV(pcbs, npcb) do { \ |
|
|
|
tcp_timer_needed(); \
|
|
|
|
if(*(pcbs) == npcb) { \
|
|
|
|
} while (0) |
|
|
|
(*(pcbs)) = (*pcbs)->next; \
|
|
|
|
|
|
|
|
} else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
|
|
|
#define TCP_RMV(pcbs, npcb) \ |
|
|
|
if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
|
|
|
|
do { \
|
|
|
|
tcp_tmp_pcb->next = npcb->next; \
|
|
|
|
if(*(pcbs) == npcb) { \
|
|
|
|
break; \
|
|
|
|
(*(pcbs)) = (*pcbs)->next; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
else { \
|
|
|
|
npcb->next = NULL; \
|
|
|
|
for(tcp_tmp_pcb = *pcbs; \
|
|
|
|
} while(0) |
|
|
|
tcp_tmp_pcb != NULL; \
|
|
|
|
|
|
|
|
tcp_tmp_pcb = tcp_tmp_pcb->next) { \
|
|
|
|
|
|
|
|
if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \
|
|
|
|
|
|
|
|
tcp_tmp_pcb->next = npcb->next; \
|
|
|
|
|
|
|
|
break; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
npcb->next = NULL; \
|
|
|
|
|
|
|
|
} while(0) |
|
|
|
|
|
|
|
|
|
|
|
#endif /* LWIP_DEBUG */ |
|
|
|
#endif /* LWIP_DEBUG */ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus |
|
|
|
#ifdef __cplusplus |
|
|
|
|