feat(lwip): formatted code
@@ -49,10 +49,12 @@ static int low_level_send_cb(esp_aio_t* aio);
static inline bool check_pbuf_to_insert(struct pbuf* p)
{
uint8_t* buf = (uint8_t*)p->payload;
+
/*Check if pbuf is tcp ip*/
if (buf[12] == 0x08 && buf[13] == 0x00 && buf[23] == 0x06) {
return true;
}
+
return false;
}
@@ -70,6 +72,7 @@ static void insert_to_list(int fd, struct pbuf* p)
}
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Insert %p,%d\n", p, pbuf_send_list_num));
+
if (pbuf_list_head == NULL) {
tmp_pbuf_list1 = (pbuf_send_list_t*)malloc(sizeof(pbuf_send_list_t));
@@ -77,6 +80,7 @@ static void insert_to_list(int fd, struct pbuf* p)
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("no menory malloc pbuf list error\n"));
return;
}
+
pbuf_ref(p);
tmp_pbuf_list1->aiofd = fd;
tmp_pbuf_list1->p = p;
@@ -95,6 +99,7 @@ static void insert_to_list(int fd, struct pbuf* p)
tmp_pbuf_list1->err_cnt ++;
return;
}
+
tmp_pbuf_list2 = tmp_pbuf_list1;
tmp_pbuf_list1 = tmp_pbuf_list2->next;
}
@@ -142,6 +147,7 @@ void send_from_list()
if (err == ERR_MEM) {
pbuf_list_head->err_cnt++;
+
if (pbuf_list_head->err_cnt >= 3) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
pbuf_free(pbuf_list_head->p);
@@ -149,6 +155,7 @@ void send_from_list()
pbuf_send_list_num--;
pbuf_list_head = tmp_pbuf_list1;
}
+
return;
} else if (err == ERR_OK) {
LWIP_DEBUGF(PBUF_CACHE_DEBUG, ("Delete %p,%d\n", pbuf_list_head->p, pbuf_send_list_num));
@@ -255,8 +262,10 @@ static inline struct pbuf *ethernetif_transform_pbuf(struct pbuf *pbuf)
}
p = pbuf_alloc(PBUF_RAW, pbuf->len, PBUF_RAM);
- if (!p)
+
+ if (!p) {
return NULL;
+ }
if (IS_IRAM(p->payload)) {
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: data in IRAM\n"));
@@ -308,6 +317,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
#endif
p = ethernetif_transform_pbuf(p);
+
if (!p) {
LWIP_DEBUGF(NETIF_DEBUG, ("low_level_output: lack memory\n"));
return ERR_OK;
@@ -328,6 +338,7 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
#if ESP_UDP
udp_sync_set_ret(netif, err);
#endif
+
if (err != ERR_OK) {
if (err == ERR_MEM) {
insert_to_list(aio.fd, p);
