Wifi modes (promiscuous, injection?)

So in the SDK documentation I see there is support for promiscuous mode, receiving raw wifi packets. However I don't see that Espressif has created any function to send a raw wifi packet in the docs. If we could inject packets the ESP8266 could easily send smart config, not just receive it, for example. Does anyone know how to send raw wifi packets using the ESP8266 or if this is going to be added anytime soon in the SDK? BTW in case you're interested here's an implementation of using promiscuous to get MAC addresses nearby:
Code: Select all
#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"
#include "user_interface.h"
#include "driver/uart.h"
#define user_procTaskPrio 0
#define user_procTaskQueueLen 1
#define CHANNEL_HOP_INTERVAL 200
os_event_t user_procTaskQueue[user_procTaskQueueLen];
static volatile os_timer_t channelHop_timer;
static void loop(os_event_t *events);
static void promisc_cb(uint8 *buf, uint16 len);
void printmac(char* buf, unsigned int o)
{
if(buf[o+4] == 0x00 && buf[o+5] == 0x00)
return;
if(buf[o+4] == 0xff && buf[o+5] == 0xff)
return;
int i;
for(i=0;i<6;i++)
if(buf[o+i] != 0x00 && buf[o+i] != 0xff)
goto good;
return;
good: ;
char mac[strlen("00:00:00:00:00:00\n")];
os_sprintf(mac, "%02x:%02x:%02x:%02x:%02x:%02x\n", buf[o+0], buf[o+1], buf[o+2], buf[o+3], buf[o+4], buf[o+5]);
uart0_sendStr(mac);
}
void channelHop(void *arg)
{
// 1 - 13 channel hopping
uint8 new_channel = wifi_get_channel() % 12 + 1;
os_printf("** hop to %d **\n", new_channel);
wifi_set_channel(new_channel);
}
static void ICACHE_FLASH_ATTR
promisc_cb(uint8 *buf, uint16 len)
{
os_printf("-> %3d: %d", wifi_get_channel(), len);
printmac(buf, 4);
printmac(buf, 10);
printmac(buf, 16);
os_printf("\n");
}
//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
os_delay_us(10);
}
//Init function
void ICACHE_FLASH_ATTR
user_init()
{
uart_init(115200, 115200);
os_delay_us(100);
uart0_sendStr("*** Monitor mode test ***\r\n");
os_printf(" -> Promisc mode setup ... ");
wifi_set_promiscuous_rx_cb(promisc_cb);
wifi_promiscuous_enable(1);
os_printf("done.\n");
os_printf(" -> Timer setup ... ");
os_timer_disarm(&channelHop_timer);
os_timer_setfn(&channelHop_timer, (os_timer_func_t *) channelHop, NULL);
os_timer_arm(&channelHop_timer, CHANNEL_HOP_INTERVAL, 1);
os_printf("done.\n");
os_printf(" -> Set opmode ... ");
wifi_set_opmode( 0x1 );
os_printf("done.\n");
//Start os task
system_os_task(loop, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
os_printf(" -> Init finished!\n\n");
}