feat(lwip): Add debug for IPv6 TCP

This commit is contained in:
yuanjm
2020-09-02 16:19:20 +08:00
parent eb6efa8090
commit a42b136d32

View File

@ -78,9 +78,8 @@ void tcp_print_status(int status, void* buf, uint32_t tmp1, uint32_t tmp2, uint3
if (p->tot_len < 50) {
return;
}
uint32_t i;
uint32_t i, offset = 0;
bool tcp_flag = false;
i = *((unsigned char*)p->payload + 12);
if (i == 0x08) { /*ipv4*/
@ -93,36 +92,53 @@ void tcp_print_status(int status, void* buf, uint32_t tmp1, uint32_t tmp2, uint3
i = *((unsigned char*)p->payload + 16);
i <<= 8;
i += *((unsigned char*)p->payload + 17);
tcp_flag = true;
}
}
} else if (i == 0x86) { /*ipv6*/
i = *((unsigned char*)p->payload + 13);
if (i == 0xdd) {
i = *((unsigned char*)p->payload + 20);
if (i == 0x06) { /*tcp*/
i = *((unsigned char*)p->payload + 18);
i <<= 8;
i += *((unsigned char*)p->payload + 19);
tcp_flag = true;
offset = 20;
}
}
}
if (i >= 40) { /*tcp data*/
if (tcp_flag) {
if ((i + offset) >= 40) { /*tcp data*/
uint32_t len, seq, ack, srcport, destport, flags;
wifi_tx_status_t *tx_result = (wifi_tx_status_t *)(&tmp1);
len = i;
i = *((unsigned char*)p->payload + 38);
len = i + offset;
i = *((unsigned char*)p->payload + 38 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 39);
i += *((unsigned char*)p->payload + 39 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 40);
i += *((unsigned char*)p->payload + 40 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 41);
i += *((unsigned char*)p->payload + 41 + offset);
seq = i;
i = *((unsigned char*)p->payload + 42);
i = *((unsigned char*)p->payload + 42 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 43);
i += *((unsigned char*)p->payload + 43 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 44);
i += *((unsigned char*)p->payload + 44 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 45);
i += *((unsigned char*)p->payload + 45 + offset);
ack = i;
i = *((unsigned char*)p->payload + 34);
i = *((unsigned char*)p->payload + 34 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 35);
i += *((unsigned char*)p->payload + 35 + offset);
srcport = i;
i = *((unsigned char*)p->payload + 36);
i = *((unsigned char*)p->payload + 36 + offset);
i <<= 8;
i += *((unsigned char*)p->payload + 37);
i += *((unsigned char*)p->payload + 37 + offset);
destport = i;
flags = *((unsigned char *)p->payload+47);
flags = *((unsigned char *)p->payload + 47 + offset);
switch (status) {
case LWIP_SEND_DATA_TO_WIFI:
@ -158,8 +174,7 @@ void tcp_print_status(int status, void* buf, uint32_t tmp1, uint32_t tmp2, uint3
}
}
}
}
}
#endif
#if ESP_TCP
@ -556,7 +571,9 @@ void ethernetif_input(struct netif* netif, struct pbuf* p)
case ETHTYPE_PPPOEDISC:
case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
#if ESP_TCP_TXRX_PBUF_DEBUG
tcp_print_status(LWIP_RECV_DATA_FROM_WIFI, (void*)p, 0, 0, 0);
#endif
/* full packet send to tcpip_thread to process */
if (netif->input(p, netif) != ERR_OK) {
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));