Page 1 of 1

esp_wifi_internal

Posted: Sat Nov 26, 2016 8:32 pm
by Kokusnuss
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:

Re: esp_wifi_internal

Posted: Wed Nov 30, 2016 4:48 pm
by ESP_Angus
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

Re: esp_wifi_internal

Posted: Thu Dec 01, 2016 8:06 am
by Kokusnuss
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.

Re: esp_wifi_internal

Posted: Mon Dec 05, 2016 9:01 am
by Kokusnuss
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:

Re: esp_wifi_internal

Posted: Mon Dec 05, 2016 11:22 am
by ESP_igrr
Good point! I guess we need to strip our symbols better 8-)

Re: esp_wifi_internal

Posted: Tue Dec 06, 2016 7:34 am
by Kokusnuss
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:

Re: esp_wifi_internal

Posted: Fri Apr 14, 2017 6:17 am
by HCYE2017
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!

Re: esp_wifi_internal

Posted: Mon Apr 17, 2017 7:36 pm
by liteforsee
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.

Re: esp_wifi_internal

Posted: Thu May 25, 2017 5:11 am
by iosixllc
Looks like someone made a library to use this:
https://github.com/Jeija/esp32free80211

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

Re: esp_wifi_internal

Posted: Fri Sep 29, 2017 8:26 pm
by baharxy
Has any one found a solution to this problem?