Compare commits
No commits in common. "a0e790ff76e1066560ed963aaecc420ab2d700a1" and "d210b60a03bce4ec21dd421fe27819a7251f78cc" have entirely different histories.
a0e790ff76
...
d210b60a03
4 changed files with 6 additions and 19 deletions
|
@ -46,6 +46,3 @@ Espressif only ships a binary blob and header file.
|
||||||
* [IPv4 Header](https://en.wikipedia.org/wiki/Internet_Protocol_version_4)
|
* [IPv4 Header](https://en.wikipedia.org/wiki/Internet_Protocol_version_4)
|
||||||
* [UDP Datagram structure](https://en.wikipedia.org/wiki/User_Datagram_Protocol#UDP_datagram_structure)
|
* [UDP Datagram structure](https://en.wikipedia.org/wiki/User_Datagram_Protocol#UDP_datagram_structure)
|
||||||
* [Universal TUN/TAP device driver](https://www.kernel.org/doc/html/latest/networking/tuntap.html)
|
* [Universal TUN/TAP device driver](https://www.kernel.org/doc/html/latest/networking/tuntap.html)
|
||||||
|
|
||||||
### Radiotap
|
|
||||||
* [radiotap.org](https://www.radiotap.org/)
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#define ERR_BIND_FAILED (-3)
|
#define ERR_BIND_FAILED (-3)
|
||||||
#define ERR_FILTER_FAILED (-4)
|
#define ERR_FILTER_FAILED (-4)
|
||||||
|
|
||||||
typedef int (*ifnow_now_receive_cb)(void *now_cfg, uint8_t *buf, ssize_t len);
|
typedef int (*ifnow_now_receive_cb)(void *now_cfg, uint8_t *buf, uint32_t len);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd_if_socket;
|
int fd_if_socket;
|
||||||
|
|
18
src/main.c
18
src/main.c
|
@ -1,5 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <strings.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "ifnow.h"
|
#include "ifnow.h"
|
||||||
|
@ -33,7 +33,7 @@ char *color_chart[] = {
|
||||||
};
|
};
|
||||||
uint8_t color_size = 15;
|
uint8_t color_size = 15;
|
||||||
|
|
||||||
int ifnow_now_receive_callback(void *cfg, uint8_t *buf, ssize_t len) {
|
int ifnow_now_receive_callback(void *cfg, uint8_t *buf, uint32_t len) {
|
||||||
ifnow_now_cfg_t *now_cfg = cfg;
|
ifnow_now_cfg_t *now_cfg = cfg;
|
||||||
|
|
||||||
printf("NOW receive_count: %d\n", len);
|
printf("NOW receive_count: %d\n", len);
|
||||||
|
@ -43,22 +43,12 @@ int ifnow_now_receive_callback(void *cfg, uint8_t *buf, ssize_t len) {
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
struct IEEE80211_radiotap radiotap;
|
|
||||||
struct IEEE80211_wlan wlan;
|
|
||||||
|
|
||||||
memcpy(&radiotap, buf, sizeof(struct IEEE80211_radiotap));
|
|
||||||
memcpy(&wlan, buf + radiotap.length, len - radiotap.length);
|
|
||||||
|
|
||||||
// TODO apply buf to actual structs of headers
|
// TODO apply buf to actual structs of headers
|
||||||
uint8_t bp = radiotap.length + 24 + 7 + 8;
|
uint8_t bp = 57;
|
||||||
|
int err = ifnow_tun_send(&tun_cfg, buf + bp, len - bp);
|
||||||
int err = ifnow_tun_send(&tun_cfg, buf + bp, len - bp - 4);
|
|
||||||
|
|
||||||
if(err < 0) {
|
if(err < 0) {
|
||||||
perror("Failed to send over tunnel");
|
perror("Failed to send over tunnel");
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ifnow_tun_receive_callback(void *cfg, uint8_t *buf, uint32_t len) {
|
int ifnow_tun_receive_callback(void *cfg, uint8_t *buf, uint32_t len) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ void *ifnow_thread_handle(void *arg) {
|
||||||
receive_count = recv(now_cfg->fd_if_socket, receive_buffer, IFNOW_MAX_RECEIVE, MSG_TRUNC);
|
receive_count = recv(now_cfg->fd_if_socket, receive_buffer, IFNOW_MAX_RECEIVE, MSG_TRUNC);
|
||||||
|
|
||||||
if(receive_count > 0 && now_cfg->receive != NULL) {
|
if(receive_count > 0 && now_cfg->receive != NULL) {
|
||||||
now_cfg->receive(now_cfg, (uint8_t*)&receive_buffer, receive_count);
|
now_cfg->receive(now_cfg, receive_buffer, receive_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue