Accessing promiscuous mode on the ESP32?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
chibill
Posts: 47
Joined: Thu Oct 31, 2019 10:44 pm

Accessing promiscuous mode on the ESP32?

Post by chibill » Sun Nov 03, 2019 4:27 am

I noticed the network API does not have any support for promiscuous mode. I was wondering if this is just because it wasn't added when it got support in idf a long while ago?

Also could someone point me towards the files that define the network library when use don't on the ESP32? It seems the modnetwork.c and modnetwork,h don't actually contain the function declares for the network library.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Accessing promiscuous mode on the ESP32?

Post by jimmo » Mon Nov 04, 2019 12:24 am

chibill wrote:
Sun Nov 03, 2019 4:27 am
I noticed the network API does not have any support for promiscuous mode. I was wondering if this is just because it wasn't added when it got support in idf a long while ago?
Yep, it's a combination of doing the work to enable the feature, but also providing an API to work with it. (i.e. raw sockets I guess)
chibill wrote:
Sun Nov 03, 2019 4:27 am
Also could someone point me towards the files that define the network library when use don't on the ESP32? It seems the modnetwork.c and modnetwork,h don't actually contain the function declares for the network library.
esp32/modnetwork.c contains all the code for configuring the WLAN interface.

I'm not sure what you mean by the network library... perhaps esp32/modsocket.c which provides the socket code (via ESP32 IDF's LWIP) ?

chibill
Posts: 47
Joined: Thu Oct 31, 2019 10:44 pm

Re: Accessing promiscuous mode on the ESP32?

Post by chibill » Mon Nov 04, 2019 12:32 am

I know inside of modnetwork the methods used for the connect method don’t exist. Was wondering where that was defined. Unless it’s esp_connect. But if it is I don’t know how it ends up being network.connect at least based of the C extension information that says the functions are package_name

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Accessing promiscuous mode on the ESP32?

Post by jimmo » Mon Nov 04, 2019 1:03 am

At the end of modnetwork.c, the WLAN class is provided by:

Code: Select all

STATIC const mp_rom_map_elem_t mp_module_network_globals_table[] = {
...
    { MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&get_wlan_obj) },
Slightly further up, WLAN.connect is provide by

Code: Select all

STATIC const mp_rom_map_elem_t wlan_if_locals_dict_table[] = {
    { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&esp_connect_obj) },
Which is implemented in

Code: Select all

STATIC mp_obj_t esp_connect(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
...
    ESP_EXCEPTIONS( esp_wifi_connect() );
...
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp_connect_obj, 1, esp_connect);

chibill
Posts: 47
Joined: Thu Oct 31, 2019 10:44 pm

Re: Accessing promiscuous mode on the ESP32?

Post by chibill » Mon Nov 04, 2019 4:53 pm

Also as for an API to use promiscuous mode I don't see a problem with using a callback like is used in the C code. where your given an object the represents that packet with all the information in it. Sort of like desktop python api's for wifi packet capture.

chibill
Posts: 47
Joined: Thu Oct 31, 2019 10:44 pm

Re: Accessing promiscuous mode on the ESP32?

Post by chibill » Tue Nov 12, 2019 6:52 pm

I might try and implement some sort of basic implementation of this. Need to wrap my head around how functions are passed around in the C++/C code.

kai
Posts: 3
Joined: Wed Dec 25, 2019 12:24 am

Re: Accessing promiscuous mode on the ESP32?

Post by kai » Sun Oct 11, 2020 9:17 am

hi chibill,

did you progress?

I would like to transfer my PAXCounter to Micropython

maybe I can also help a little

Post Reply