@@ -81,10 +81,10 @@ typedef enum {
81
81
LWIP_TCP_ACCEPT,
82
82
LWIP_TCP_CONNECTED,
83
83
LWIP_TCP_DNS
84
- } lwip_event_t ;
84
+ } lwip_tcp_event_t ;
85
85
86
86
typedef struct {
87
- lwip_event_t event;
87
+ lwip_tcp_event_t event;
88
88
void * arg;
89
89
union {
90
90
struct {
@@ -118,7 +118,7 @@ typedef struct {
118
118
ip_addr_t addr;
119
119
} dns;
120
120
};
121
- } lwip_event_packet_t ;
121
+ } lwip_tcp_event_packet_t ;
122
122
123
123
static QueueHandle_t _async_queue;
124
124
static TaskHandle_t _async_service_task_handle = NULL ;
@@ -137,23 +137,23 @@ static uint32_t _closed_index = []() {
137
137
138
138
static inline bool _init_async_event_queue () {
139
139
if (!_async_queue) {
140
- _async_queue = xQueueCreate (CONFIG_ASYNC_TCP_QUEUE_SIZE, sizeof (lwip_event_packet_t *));
140
+ _async_queue = xQueueCreate (CONFIG_ASYNC_TCP_QUEUE_SIZE, sizeof (lwip_tcp_event_packet_t *));
141
141
if (!_async_queue) {
142
142
return false ;
143
143
}
144
144
}
145
145
return true ;
146
146
}
147
147
148
- static inline bool _send_async_event (lwip_event_packet_t ** e, TickType_t wait = portMAX_DELAY) {
148
+ static inline bool _send_async_event (lwip_tcp_event_packet_t ** e, TickType_t wait = portMAX_DELAY) {
149
149
return _async_queue && xQueueSend (_async_queue, e, wait) == pdPASS;
150
150
}
151
151
152
- static inline bool _prepend_async_event (lwip_event_packet_t ** e, TickType_t wait = portMAX_DELAY) {
152
+ static inline bool _prepend_async_event (lwip_tcp_event_packet_t ** e, TickType_t wait = portMAX_DELAY) {
153
153
return _async_queue && xQueueSendToFront (_async_queue, e, wait) == pdPASS;
154
154
}
155
155
156
- static inline bool _get_async_event (lwip_event_packet_t ** e) {
156
+ static inline bool _get_async_event (lwip_tcp_event_packet_t ** e) {
157
157
if (!_async_queue) {
158
158
return false ;
159
159
}
@@ -178,7 +178,7 @@ static inline bool _get_async_event(lwip_event_packet_t** e) {
178
178
It won't be effective if user would run multiple simultaneous long running callbacks due to message interleaving.
179
179
todo: implement some kind of fair dequeing or (better) simply punish user for a bad designed callbacks by resetting hog connections
180
180
*/
181
- lwip_event_packet_t * next_pkt = NULL ;
181
+ lwip_tcp_event_packet_t * next_pkt = NULL ;
182
182
while (xQueuePeek (_async_queue, &next_pkt, 0 ) == pdPASS) {
183
183
if (next_pkt->arg == (*e)->arg && next_pkt->event == LWIP_TCP_POLL) {
184
184
if (xQueueReceive (_async_queue, &next_pkt, 0 ) == pdPASS) {
@@ -219,8 +219,8 @@ static bool _remove_events_with_arg(void* arg) {
219
219
return false ;
220
220
}
221
221
222
- lwip_event_packet_t * first_packet = NULL ;
223
- lwip_event_packet_t * packet = NULL ;
222
+ lwip_tcp_event_packet_t * first_packet = NULL ;
223
+ lwip_tcp_event_packet_t * packet = NULL ;
224
224
225
225
// figure out which is the first non-matching packet so we can keep the order
226
226
while (!first_packet) {
@@ -261,7 +261,7 @@ static bool _remove_events_with_arg(void* arg) {
261
261
return true ;
262
262
}
263
263
264
- static void _handle_async_event (lwip_event_packet_t * e) {
264
+ static void _handle_async_event (lwip_tcp_event_packet_t * e) {
265
265
if (e->arg == NULL ) {
266
266
// do nothing when arg is NULL
267
267
// ets_printf("event arg == NULL: 0x%08x\n", e->recv.pcb);
@@ -301,7 +301,7 @@ static void _async_service_task(void* pvParameters) {
301
301
log_w (" Failed to add async task to WDT" );
302
302
}
303
303
#endif
304
- lwip_event_packet_t * packet = NULL ;
304
+ lwip_tcp_event_packet_t * packet = NULL ;
305
305
for (;;) {
306
306
if (_get_async_event (&packet)) {
307
307
_handle_async_event (packet);
@@ -362,7 +362,7 @@ static bool _start_async_task() {
362
362
* */
363
363
364
364
static int8_t _tcp_clear_events (void * arg) {
365
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
365
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
366
366
e->event = LWIP_TCP_CLEAR;
367
367
e->arg = arg;
368
368
if (!_prepend_async_event (&e)) {
@@ -373,7 +373,7 @@ static int8_t _tcp_clear_events(void* arg) {
373
373
374
374
static int8_t _tcp_connected (void * arg, tcp_pcb* pcb, int8_t err) {
375
375
// ets_printf("+C: 0x%08x\n", pcb);
376
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
376
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
377
377
e->event = LWIP_TCP_CONNECTED;
378
378
e->arg = arg;
379
379
e->connected .pcb = pcb;
@@ -393,7 +393,7 @@ static int8_t _tcp_poll(void* arg, struct tcp_pcb* pcb) {
393
393
}
394
394
395
395
// ets_printf("+P: 0x%08x\n", pcb);
396
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
396
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
397
397
e->event = LWIP_TCP_POLL;
398
398
e->arg = arg;
399
399
e->poll .pcb = pcb;
@@ -405,7 +405,7 @@ static int8_t _tcp_poll(void* arg, struct tcp_pcb* pcb) {
405
405
}
406
406
407
407
static int8_t _tcp_recv (void * arg, struct tcp_pcb * pcb, struct pbuf * pb, int8_t err) {
408
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
408
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
409
409
e->arg = arg;
410
410
if (pb) {
411
411
// ets_printf("+R: 0x%08x\n", pcb);
@@ -429,7 +429,7 @@ static int8_t _tcp_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* pb, int8_t
429
429
430
430
static int8_t _tcp_sent (void * arg, struct tcp_pcb * pcb, uint16_t len) {
431
431
// ets_printf("+S: 0x%08x\n", pcb);
432
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
432
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
433
433
e->event = LWIP_TCP_SENT;
434
434
e->arg = arg;
435
435
e->sent .pcb = pcb;
@@ -442,7 +442,7 @@ static int8_t _tcp_sent(void* arg, struct tcp_pcb* pcb, uint16_t len) {
442
442
443
443
static void _tcp_error (void * arg, int8_t err) {
444
444
// ets_printf("+E: 0x%08x\n", arg);
445
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
445
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
446
446
e->event = LWIP_TCP_ERROR;
447
447
e->arg = arg;
448
448
e->error .err = err;
@@ -452,7 +452,7 @@ static void _tcp_error(void* arg, int8_t err) {
452
452
}
453
453
454
454
static void _tcp_dns_found (const char * name, struct ip_addr * ipaddr, void * arg) {
455
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
455
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
456
456
// ets_printf("+DNS: name=%s ipaddr=0x%08x arg=%x\n", name, ipaddr, arg);
457
457
e->event = LWIP_TCP_DNS;
458
458
e->arg = arg;
@@ -469,7 +469,7 @@ static void _tcp_dns_found(const char* name, struct ip_addr* ipaddr, void* arg)
469
469
470
470
// Used to switch out from LwIP thread
471
471
static int8_t _tcp_accept (void * arg, AsyncClient* client) {
472
- lwip_event_packet_t * e = (lwip_event_packet_t *)malloc (sizeof (lwip_event_packet_t ));
472
+ lwip_tcp_event_packet_t * e = (lwip_tcp_event_packet_t *)malloc (sizeof (lwip_tcp_event_packet_t ));
473
473
e->event = LWIP_TCP_ACCEPT;
474
474
e->arg = arg;
475
475
e->accept .client = client;
0 commit comments