Skip to content

Commit 4172219

Browse files
mdns tests: adapt mdns fuzzer test to compile with event loop library
* Original commit: espressif/esp-idf@38d15cb
1 parent 9a0803a commit 4172219

File tree

3 files changed

+67
-40
lines changed

3 files changed

+67
-40
lines changed

components/mdns/test_afl_fuzz_host/esp32_compat.h

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// Not to include
2121
#define ESP_MDNS_NETWORKING_H_
2222
#define _TCPIP_ADAPTER_H_
23-
#define __ESP_EVENT_H__
2423

2524

2625
#ifdef USE_BSD_STRING
@@ -116,6 +115,47 @@ typedef enum {
116115
WIFI_MODE_MAX
117116
} wifi_mode_t;
118117

118+
extern const char * WIFI_EVENT;
119+
extern const char * IP_EVENT;
120+
extern const char * ETH_EVENT;
121+
122+
typedef enum {
123+
WIFI_EVENT_WIFI_READY = 0, /**< ESP32 WiFi ready */
124+
WIFI_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */
125+
WIFI_EVENT_STA_START, /**< ESP32 station start */
126+
WIFI_EVENT_STA_STOP, /**< ESP32 station stop */
127+
WIFI_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
128+
WIFI_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
129+
WIFI_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
130+
131+
WIFI_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */
132+
WIFI_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
133+
WIFI_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
134+
WIFI_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */
135+
136+
WIFI_EVENT_AP_START, /**< ESP32 soft-AP start */
137+
WIFI_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
138+
WIFI_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
139+
WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
140+
141+
WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
142+
} wifi_event_t;
143+
144+
typedef enum {
145+
ETHERNET_EVENT_START, /**< ESP32 ethernet start */
146+
ETHERNET_EVENT_STOP, /**< ESP32 ethernet stop */
147+
ETHERNET_EVENT_CONNECTED, /**< ESP32 ethernet phy link up */
148+
ETHERNET_EVENT_DISCONNECTED, /**< ESP32 ethernet phy link down */
149+
} eth_event_t;
150+
151+
typedef enum {
152+
IP_EVENT_STA_GOT_IP, /*!< ESP32 station got IP from connected AP */
153+
IP_EVENT_STA_LOST_IP, /*!< ESP32 station lost IP and the IP is reset to 0 */
154+
IP_EVENT_AP_STAIPASSIGNED, /*!< ESP32 soft-AP assign an IP to a connected station */
155+
IP_EVENT_GOT_IP6, /*!< ESP32 station or ap or ethernet interface v6IP addr is preferred */
156+
IP_EVENT_ETH_GOT_IP, /*!< ESP32 ethernet got IP from connected AP */
157+
} ip_event_t;
158+
119159
/* status of DHCP client or DHCP server */
120160
typedef enum {
121161
TCPIP_ADAPTER_DHCP_INIT = 0, /**< DHCP client/server in initial state */
@@ -124,34 +164,6 @@ typedef enum {
124164
TCPIP_ADAPTER_DHCP_STATUS_MAX
125165
} tcpip_adapter_dhcp_status_t;
126166

127-
typedef enum {
128-
SYSTEM_EVENT_WIFI_READY = 0, /**< ESP32 WiFi ready */
129-
SYSTEM_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */
130-
SYSTEM_EVENT_STA_START, /**< ESP32 station start */
131-
SYSTEM_EVENT_STA_STOP, /**< ESP32 station stop */
132-
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
133-
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
134-
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
135-
SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */
136-
SYSTEM_EVENT_STA_LOST_IP, /**< ESP32 station lost IP and the IP is reset to 0 */
137-
SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */
138-
SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
139-
SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
140-
SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */
141-
SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */
142-
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
143-
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
144-
SYSTEM_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
145-
SYSTEM_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
146-
SYSTEM_EVENT_GOT_IP6, /**< ESP32 station or ap or ethernet interface v6IP addr is preferred */
147-
SYSTEM_EVENT_ETH_START, /**< ESP32 ethernet start */
148-
SYSTEM_EVENT_ETH_STOP, /**< ESP32 ethernet stop */
149-
SYSTEM_EVENT_ETH_CONNECTED, /**< ESP32 ethernet phy link up */
150-
SYSTEM_EVENT_ETH_DISCONNECTED, /**< ESP32 ethernet phy link down */
151-
SYSTEM_EVENT_ETH_GOT_IP, /**< ESP32 ethernet got IP from connected AP */
152-
SYSTEM_EVENT_MAX
153-
} system_event_id_t;
154-
155167
struct udp_pcb {
156168
uint8_t dummy;
157169
};
@@ -180,7 +192,6 @@ typedef struct {
180192
ip4_addr_t gw;
181193
} tcpip_adapter_ip_info_t;
182194

183-
// typedef int32_t system_event_id_t;
184195
typedef enum {
185196
TCPIP_ADAPTER_IF_STA = 0, /**< ESP32 station interface */
186197
TCPIP_ADAPTER_IF_AP, /**< ESP32 soft-AP interface */
@@ -191,18 +202,13 @@ typedef enum {
191202
typedef struct {
192203
ip6_addr_t ip;
193204
} tcpip_adapter_ip6_info_t;
194-
typedef struct {
195-
tcpip_adapter_if_t if_index;
196-
tcpip_adapter_ip6_info_t ip6_info;
197-
} system_event_got_ip6_t;
198-
typedef union {
199-
system_event_got_ip6_t got_ip6; /**< ESP32 station or ap or ethernet ipv6 addr state change to preferred */
200-
} system_event_info_t;
201205

202206
typedef struct {
203-
system_event_id_t event_id; /**< event ID */
204-
system_event_info_t event_info; /**< event information */
205-
} system_event_t;
207+
tcpip_adapter_if_t if_index; /*!< Interface for which the event is received */
208+
tcpip_adapter_ip6_info_t ip6_info; /*!< IPv6 address of the interface */
209+
} ip_event_got_ip6_t;
210+
211+
typedef void* system_event_t;
206212

207213
inline esp_err_t esp_wifi_get_mode(wifi_mode_t * mode)
208214
{

components/mdns/test_afl_fuzz_host/esp32_mock.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ void* g_queue;
99
int g_queue_send_shall_fail = 0;
1010
int g_size = 0;
1111

12+
const char * WIFI_EVENT = "wifi_event";
13+
const char * IP_EVENT = "ip_event";
14+
const char * ETH_EVENT = "eth_event";
15+
16+
esp_err_t esp_event_handler_register(const char * event_base,
17+
int32_t event_id,
18+
void* event_handler,
19+
void* event_handler_arg)
20+
{
21+
return ESP_OK;
22+
}
23+
24+
esp_err_t esp_event_handler_unregister(const char * event_base, int32_t event_id, void* event_handler)
25+
{
26+
return ESP_OK;
27+
}
28+
1229
esp_err_t esp_timer_delete(esp_timer_handle_t timer)
1330
{
1431
return ESP_OK;

components/mdns/test_afl_fuzz_host/esp32_mock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ void GetLastItem(void *pvBuffer);
4040

4141
void ForceTaskDelete();
4242

43+
esp_err_t esp_event_handler_register(const char * event_base, int32_t event_id, void* event_handler, void* event_handler_arg);
44+
45+
esp_err_t esp_event_handler_unregister(const char * event_base, int32_t event_id, void* event_handler);
46+
4347
#define _mdns_udp_pcb_write(tcpip_if, ip_protocol, ip, port, data, len) len
4448

4549
#endif /* ESP32_MOCK_H_ */

0 commit comments

Comments
 (0)