esp_wifi_internal

Kokusnuss
Posts: 5
Joined: Sat Nov 26, 2016 8:15 pm

esp_wifi_internal

Postby Kokusnuss » Sat Nov 26, 2016 8:32 pm

Hallo erveryone :)

I finally recieved my ESP32 today! I waited really long and now I wanna test it out.
So I had this project with my ESP8266 where I send beacon packets. I searched for a function similar to the wifi_send_pkt_freedom() in the SDK.
I found this esp_wifi_internal.h file and looked into it.
This is what I've found:

Code: Select all

/**
/*
 * All the APIs declared here are internal only APIs, it can only be used by 
 * espressif internal modules, such as SSC, LWIP, TCPIP adapter etc, espressif 
 * customers are not recommended to use them.
 *
 * If someone really want to use specified APIs declared in here, please contact
 * espressif AE/developer to make sure you know the limitations or risk of 
 * the API, otherwise you may get unexpected behavior!!!
 *
 */

Code: Select all

 * @brief  transmit the buffer via wifi driver
  *
  * @param  wifi_interface_t wifi_if : wifi interface id
  * @param  void *buffer : the buffer to be tansmit
  * @param  u16_t len : the length of buffer
  *
  * @return
  *    - ERR_OK  : Successfully transmit the buffer to wifi driver
  *    - ERR_MEM : Out of memory
  *    - ERR_IF : WiFi driver error
  *    - ERR_ARG : Invalid argument
  */
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, u16_t len);
So ok this is an internal file. I get this, buuuut.... I really want to use these specified APIs ! So @Espressif: can I use this to send my own packets? I tried it out with my beacon packets, but it gave me a WiFi driver error :(

Hope you guys can help me with this. :mrgreen:

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: esp_wifi_internal

Postby ESP_Angus » Wed Nov 30, 2016 4:48 pm

Hi Kokusnuss,

The esp_wifi_internal_tx() function is for sending 802.11 data frames. You can see where it is called inside the LWIP WLAN network interface (in components/lwip/port/netif/wlanif.c).

This function does not allow you to send other types of frames (like Beacon frames.)

The wifi_send_pkt_freedom() function was removed from the ESP8266 SDK, I believe because of the potential for abuse (jamming by spamming beacon frames, sending large numbers of deauth frames, etc.) I don't believe this policy has changed, sorry.

Angus

Kokusnuss
Posts: 5
Joined: Sat Nov 26, 2016 8:15 pm

Re: esp_wifi_internal

Postby Kokusnuss » Thu Dec 01, 2016 8:06 am

Thank you ESP_Angus for answering!

That's what I wanted to know, thx :D
The wifi_send_pkt_freedom() function was removed from the ESP8266 SDK, I believe because of the potential for abuse (jamming by spamming beacon frames, sending large numbers of deauth frames, etc.) I don't believe this policy has changed, sorry.
Thats something I can't understand (and why I wanted to open up an extra topic for this). Why preventing something the WiFi standard allows me? There are obviously vulnerabilities within 802.11, but I don't think that's the right way to prevent them.
And every arduino ethernet shield/chip can send its own packets, every WiFi USB dongle can do the same if you have the right software installed.

I'm a student and I do a lot of research in this topic and I want to build a working piece of hardware which runs my modified protocol maybe with it's own packets. And I think there is no better way to learn how the different protocols work (especially this low level part), as with an ESP.

I hope Espressif will change its mind on this.

Kokusnuss
Posts: 5
Joined: Sat Nov 26, 2016 8:15 pm

Re: esp_wifi_internal

Postby Kokusnuss » Mon Dec 05, 2016 9:01 am

ESP_Angus wrote:The esp_wifi_internal_tx() function is for sending 802.11 data frames.
So I guess beacon spamming is not allowed, but ARP spoofing should be possible? :roll:

But hey what's about the ieee80211_freedom_output function?

Code: Select all

ieee80211_freedom_output(netif, *buffer, len);
It was used for the removed wifi_send_pkt_freedom function:

Code: Select all

uint8 ICACHE_FLASH_ATTR wifi_send_pkt_freedom(void *a, uint8 b)
{
	if(a == NULL || b > 23) return 0x7F;
	int opmode = wifi_get_opmode();
	if(opmode == 1) {
		if(g_ic.g.netif1 == NULL) return 0x76;
		return ieee80211_freedom_output(g_ic.g.netif1, b, a);
	}
	else if(opmode > 4 || opmode < 2) return 0x76;
	else {
		if(g_ic.g.netif2 == NULL) return 0x76;
		return ieee80211_freedom_output(g_ic.g.netif2, b, a);
	}
}
source: https://github.com/pvvx/esp8266web/blob ... nterface.c

It's still a part of the SDK. As well as functions like:
ieee80211_send_mgmt
ieee80211_send_deauth
...

This will be interesting :mrgreen:

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: esp_wifi_internal

Postby ESP_igrr » Mon Dec 05, 2016 11:22 am

Good point! I guess we need to strip our symbols better 8-)

Kokusnuss
Posts: 5
Joined: Sat Nov 26, 2016 8:15 pm

Re: esp_wifi_internal

Postby Kokusnuss » Tue Dec 06, 2016 7:34 am

How about providing an "official" and documented function, so people like me don't have to dig through your code? ;)

But with tools like IDA Pro (with a xtensa plugin) it shouldn't be that hard to guess what the functions do and what parameters they have.
Happy hacking everyone :mrgreen:

HCYE2017
Posts: 1
Joined: Fri Apr 14, 2017 5:08 am

Re: esp_wifi_internal

Postby HCYE2017 » Fri Apr 14, 2017 6:17 am

I have a commercial product that relies on this feature --- it wakes up, sends a packet, and goes to deep sleep. This is a very common pattern for IoT devices, so PLEASE PLEASE PLEASE keep this feature!

liteforsee
Posts: 1
Joined: Mon Apr 17, 2017 7:33 pm

Re: esp_wifi_internal

Postby liteforsee » Mon Apr 17, 2017 7:36 pm

We would also require a very simple way of sending multicast packets between units without any accesspoint.

i can receive packets via esp_wifi_set_promiscuous_rx_cb, but unable to send via esp_wifi_internal_tx.

iosixllc
Posts: 71
Joined: Fri Mar 17, 2017 12:13 am

Re: esp_wifi_internal

Postby iosixllc » Thu May 25, 2017 5:11 am

Looks like someone made a library to use this:
https://github.com/Jeija/esp32free80211

But an API change was made recently that broke it...?

baharxy
Posts: 1
Joined: Fri Sep 29, 2017 8:25 pm

Re: esp_wifi_internal

Postby baharxy » Fri Sep 29, 2017 8:26 pm

Has any one found a solution to this problem?

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 75 guests