summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/tun.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2025-07-28 23:37:45 +0200
committerUros Majstorovic <majstor@majstor.org>2025-07-28 23:37:45 +0200
commitfc70c6f78f43dbeda91d47b2d2071d4da4082121 (patch)
treec104744b62d3ea2c1a4a05eaab8283f368215300 /fw/esp32/components/eos/tun.c
parent58f41971b1e801ad2fbcea08e5152afa2b18ca73 (diff)
upgrade to ESP-IDF v5; fixed SPI net and app protocoles; reimplemented power management;
Diffstat (limited to 'fw/esp32/components/eos/tun.c')
-rw-r--r--fw/esp32/components/eos/tun.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fw/esp32/components/eos/tun.c b/fw/esp32/components/eos/tun.c
index a7181ee..f27fcfe 100644
--- a/fw/esp32/components/eos/tun.c
+++ b/fw/esp32/components/eos/tun.c
@@ -6,13 +6,14 @@
#include <lwip/tcpip.h>
#include <lwip/etharp.h>
+#include "net.h"
#include "app.h"
#include "tun.h"
static ip4_addr_t ipaddr, netmask, gw;
static struct netif netif_tun;
-static err_t ESP_IRAM_ATTR tun_output(struct netif *netif, struct pbuf *p, const struct ip4_addr *ipaddr) {
+static err_t IRAM_ATTR tun_output(struct netif *netif, struct pbuf *p, const struct ip4_addr *ipaddr) {
unsigned char *buf;
struct pbuf *q;
@@ -27,7 +28,7 @@ static err_t ESP_IRAM_ATTR tun_output(struct netif *netif, struct pbuf *p, const
return ERR_OK;
}
-static void ESP_IRAM_ATTR tun_input(unsigned char mtype, unsigned char *buffer, uint16_t len) {
+static void IRAM_ATTR tun_input(unsigned char mtype, unsigned char *buffer, uint16_t len) {
struct netif *netif = &netif_tun;
struct pbuf *p;
int rv;
@@ -55,11 +56,15 @@ static err_t tun_init(struct netif *netif) {
}
void eos_tun_init(void) {
+ struct netif *rv;
+
IP4_ADDR(&gw, 0,0,0,0);
IP4_ADDR(&ipaddr, 192,168,10,2);
IP4_ADDR(&netmask, 255,255,255,0);
- netif_add(&netif_tun, &ipaddr, &netmask, &gw, NULL, tun_init, tcpip_input);
+ rv = netif_add(&netif_tun, &ipaddr, &netmask, &gw, NULL, tun_init, tcpip_input);
+ assert(rv != NULL);
+
netif_set_up(&netif_tun);
eos_app_set_handler(EOS_APP_MTYPE_TUN, tun_input);
-} \ No newline at end of file
+}