wifi_send_pkt_freedom always returns -1

bakercp

wifi_send_pkt_freedom always returns -1

Postby bakercp » Mon Nov 09, 2015 3:54 am

Hello there,

I am trying to use the wifi_send_pkt_freedom system to send user-generated 802.11 packets, but am unable to successfully send a packet. The callback is registered successfully with wifi_register_send_pkt_freedom_cb, but wifi_send_pkt_freedom returns -1 and the freedom_outside_cb_t function is never called. No packets are seen when monitoring the channels using wireshark and a dedicated wifi adapter. An example beacon packet includes:

Code: Select all

/* Frame (255 bytes) */
uint8_t beacon[255] = {
0x00, 0x00, 0x1a, 0x00, 0x2f, 0x48, 0x00, 0x00, /* ..../H.. */
0xd7, 0xf2, 0xa9, 0x91, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x10, 0x02, 0x6c, 0x09, 0xc0, 0x00, 0xc8, 0x00, /* ..l..... */
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, /* ........ */
0xff, 0xff, 0xff, 0xff, 0x02, 0x03, 0x04, 0x05, /* ........ */
0x06, 0x07, 0x02, 0x1a, 0x11, 0xfa, 0x05, 0x6d, /* .m.....m */
0xa0, 0xfe, 0x87, 0xd1, 0xcd, 0x3d, 0x01, 0x00, /* .....=.. */
0x00, 0x00, 0x64, 0x00, 0x11, 0x05, 0x00, 0x14, /* ..d..... */
0x48, 0x45, 0x4C, 0x4C, 0x4F, 0x5F, 0x57, 0x4F, /* HELLO_WO */
0x52, 0x4C, 0x44, 0x5F, 0x54, 0x45, 0x53, 0x54, /* RLD_TEST */
0x5F, 0x4E, 0x55, 0x4D, 0x01, 0x08, 0x82, 0x84, /* _NUM.... */
0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, 0x03, 0x01, /* ..$0Hl.. */
0x01, 0x05, 0x04, 0x01, 0x02, 0x00, 0x00, 0x07, /* ........ */
0x06, 0x51, 0x32, 0x20, 0x01, 0x0b, 0x1e, 0x20, /* .Q2 ...  */
0x01, 0x00, 0x23, 0x02, 0x12, 0x00, 0x2a, 0x01, /* ..#...*. */
0x00, 0x2f, 0x01, 0x00, 0x30, 0x14, 0x01, 0x00, /* ./..0... */
0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, /* ........ */
0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, /* ........ */
0x0c, 0x00, 0x32, 0x04, 0x0c, 0x12, 0x18, 0x60, /* ..2....` */
0x2d, 0x1a, 0x2d, 0x11, 0x17, 0xff, 0x00, 0x00, /* -.-..... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x3d, 0x16, 0x01, 0x08, /* ....=... */
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x7f, 0x08, 0x04, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xdd, 0x09, /* .....@.. */
0x00, 0x10, 0x18, 0x02, 0x01, 0x00, 0x1c, 0x00, /* ........ */
0x00, 0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, /* ....P... */
0x01, 0x80, 0x00, 0x03, 0xa4, 0x00, 0x00, 0x27, /* .......' */
0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, /* ...BC^.b */
0x32, 0x2f, 0x00, 0xa1, 0xaa, 0x93, 0xa7        /* 2/..... */
};


and is set using

Code: Select all

int result = wifi_send_pkt_freedom(beacon, 255, true);
os_printf("\tResult => %d ...\n", result);


Others seem to be having the same problem here:

https://github.com/pulkin/esp8266-injec ... e/issues/1

I have tested this with esp_iot_sdk_v1.4.1_pre5 and esp_iot_sdk_v1.4.0 with no luck.

Can you please provide an example code for using the wifi_send_pkt_freedom functions?

Thank you,
Christopher

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: wifi_send_pkt_freedom always returns -1

Postby ESP_Faye » Tue Nov 10, 2015 6:59 pm

Hi,

1. wifi_send_pkt_freedom can not send management packets and encrypted packets, beacon is one kind of the management packets. We add this limitation because it may effect other devices.

2. If you really want to send beacon, please start from "0x80, 0x00 ... " which means that the first 26 bytes need to be deleted. If you start from "0x00,0x00", wifi_send_pkt_freedom will detect the 80211 header and find out that it's a management packet, and send fail.

3. wifi_send_pkt_freedom data format : start from 802.11 header, no more extra data in the front.

Thanks for your interest in ESP8266 !

bojanpotocnik
Posts: 9
Joined: Wed Jan 14, 2015 6:20 pm

Re: wifi_send_pkt_freedom always returns -1

Postby bojanpotocnik » Wed Feb 03, 2016 9:12 pm

Is there any change?

I want to send beacon packets - I changed first byte from 0x00 to 0x80 but wifi_send_pkt_freedom() still always returns -1.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: wifi_send_pkt_freedom always returns -1

Postby ESP_Faye » Fri Feb 05, 2016 9:53 am

Hi,

Sorry that wifi_send_pkt_freedom can not send beacon in ESP8266_RTOS_SDK_V1.3.0, but it will be added in next version of RTOS SDK, ESP8266_RTOS_SDK_V1.4.0. Sorry for the inconvenience.

Kokusnuss
Posts: 2
Joined: Tue Oct 18, 2016 4:35 am

Re: wifi_send_pkt_freedom always returns -1

Postby Kokusnuss » Tue Oct 18, 2016 5:12 am

Hi,

I was trying to send a ARP broadcast with wifi_send_pkt_freedom(). I always get -1. If I add "0x80, 0x00 ... " I get 0. But I wasn't able to detect the package in wireshark, so this doesn't work either.

The pakage bytes are the same the ESP8266 sends when it's connected with the network. I copied the broadcast.

Here is the code:

Code: Select all

uint8_t packet_bytes[42] = {
  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaa, 0xaa,
  0xaa, 0xaa, 0xaa, 0xaa, 0x08, 0x06, 0x00, 0x01,
  0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xaa, 0xaa,
  0xaa, 0xaa, 0xaa, 0xaa, 0xc0, 0xa8, 0x00, 0x77,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8,
  0x00, 0x01
};
  Serial.println(wifi_send_pkt_freedom(packet_bytes,42,true));


I use the Arduino IDE and tested this with all available SDK versions.
Just to be safe I changed the mac adress to aa:aa:aa:aa:aa:aa in my example.

And I'm really new to this whole stuff, does ARP count as management packets?

Kokusnuss
Posts: 2
Joined: Tue Oct 18, 2016 4:35 am

Re: wifi_send_pkt_freedom always returns -1

Postby Kokusnuss » Wed Oct 19, 2016 6:55 pm

wait.. wifi_send_pkt_freedom can't send packets like this, right?
From the documentation:
Can send: unencrypted data packet, unencrypted beacon/probe req/probe resp.
Can NOT send: all encrypted packets (the encrypt bit in the packet has to be 0, otherwise it is not supported), control packet, other management packet except unencrypted beacon/probe req/probe resp.


:( but why? I really would like to send my own packets! And you guys should really change the function description in the SDK reference. Because
Send user-defined 802.11 packets.
is really confusing when you can only send unencrypted beacon and probe packets.

Who is online

Users browsing this forum: No registered users and 59 guests